Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
boot_drive:
.byte 0xff /* the disk to load kernel from */
/* 0xff means use the boot drive */
First of all what is a "forced disk reference"?
The code above doesn't make sense to me. It loads %al with 0xff, then compares the same %al with 0xff, then jumps to 1. In what case movb %al, %dl is executed?
By the way, is 0xff a drive code used in INT 13H? Is there a list of those codes somewhere?
The stage1 loader is compiled with 0xff at the location boot_drive:
As an option, the installer (also known as grub) will patch the 0xff there and write a different byte. Then when the stage1 loader runs, it will prefer that value and ignore the value in %dl
This is to fix bugs where the value supplied in %dl sends stage1 off looking for stage1.5 someplace where it can't find it, and preventing grub from booting.
sounds wrote:As an option, the installer (also known as grub) will patch the 0xff there and write a different byte. Then when the stage1 loader runs, it will prefer that value and ignore the value in %dl.
This is to fix bugs where the value supplied in %dl sends stage1 off looking for stage1.5 someplace where it can't find it, and preventing grub from booting.
, so that when the installer has patched the 0xFF and written a different byte, it prefers the different byte, and in case it is 0xFF, it uses the value in %dl?
, so that when the installer has patched the 0xFF and written a different byte, it prefers the different byte, and in case it is 0xFF, it uses the value in %dl?
It's gas syntax. The 'output' from this little snippet is in dl. If boot_drive is not 0xff then dl is overwritten with whatever it contains, otherwise dl is left as it was set up by the bios.
sounds wrote:This is to fix bugs where the value supplied in %dl sends stage1 off looking for stage1.5 someplace where it can't find it, and preventing grub from booting.
But how does the grub installer know that a wrong value will be passed to %dl? And does the value it puts on boot_drive address corresponds to the device it is being installed, like 0x80 for hdd?