Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-7978

ReactOS boot code of MBR can't boot USB-HDD due to error reading sectors with int13h_ah=42h

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • Bootloader
    • None

    Description

      ReactOS boot code of MBR can't boot from USB-HDD due to error reading sectors with int13h ah=42h
      Booting process failed with messages: "Load failed!\nPress any key to reboot..."
      Tested in VirtualBox 4.3.8 and on Real Machine

      The boot code of MBR reads OK from built-in HDD, but when reading USB-HDD
      the ReadSectors asm procedure in MBR boot code
      (here: \boot\freeldr\bootsect\fatx.S line 489 )
      returns zero-filled buffer (no real data in it).
      But, the int13h function ah=42h returns clear carry flag, thus not signalizing any error!
      That is why jump "jc BootFailure" after int13h on line 530 is not fired,
      and this "read" operation continues.
      (the jump to BootFailure occurred later when no any "FREELDR SYS" record was found).

      I have tested this with FAT16 formatted drive, but the same ReadSectors asm procedure is called in case
      of FAT32 (ReadCluster, Line:428 of FAT32 uses ReadSectors)

      The solution would be to use (for this case) int13 ah=02h function, as does GRUB.
      As I read, there is int13h function informing about HDD is USB-HDD.
      So the possible solution would be - test the HDD type and in case of USB call int13h ah=02h function (which is with CHS addressing) instead of ah=42h function.

      Useful links:
      [1] Similar problem discussion on OsDev (was helpful): http://f.osdev.org/viewtopic.php?f=1&t=19422
      "Writing a FAT16 Bootsector for USB booting"

      Links: In searches for ASM Code for LBA-CHS convertion:
      [2] Could be also helpful: http://en.wikipedia.org/wiki/Logical_block_addressing#CHS_conversion

      And finally "The Reference"
      [3] http://thestarman.pcministry.com/asm/mbr/GRUB.htm
      The very detailed explanation of how does GRUB stage1 loader works, take attention on code at address 7CBC:
      > 7CBC 7205 JB 7CC3 ; If LBA not supported,
      > ; go to CHS mode only.

      and few lines further goes CHS params of drive reading and calculation of right CHS-offset fot int13h/ah=02h

      (On Real Machine I used GRUB-2 to workaround this bug and go further.
      So I changed only the freeldr.sys booting method, and problem of not-booting was "solved".
      With grub-2 installed the freeldr.sys was loaded OK and then ntoskrnl.exe starts working, etc)

      ((((How it was installed on USB-HDD:
      Installing within VirtualBox mounted the whole disk as storage failed: very much of repeating:
      (../../ntoskrnl/cc/copy.c:290) IoPageWrite failed, Status c000009c
      (../../ntoskrnl/cc/view.c:261) CC: Failed to flush cache segment.
      (../../drivers/storage/scsiport/scsiport.c:1842) ScsiPortLogError() called
      in virtual serial console.

      Then I installed ROS into fixed-size virtual image, .vdi file and copied the resulted ros-partition from there to real disk partition using linux dd and 3rd receipt from (https://www.reactos.org/wiki/Transfer_files_from_the_host_OS_to_the_virtual_drive#Mounting_a_VirtualBox_.28.vdi.29_image )
      The MBR-boot code was copied manually, from the same place (first 446 bytes only - to keep MBR partition records intact)
      ))))

      Attachments

        Activity

          People

            Unassigned Unassigned
            Mna. Mna.
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: