GRUB using extended registers in stage1?
Posted: Sun Dec 19, 2010 10:59 am
I'm writing a bootloader for fun, and I was looking at GRUB's source code for help when I read this code:
How can GRUB use extended registers in its stage1? Surely stage1 is not running in protected mode? I don't think you can use extended registers in unreal mode, either, can you? I don't see any code for changing mode, anyway...
Code: Select all
lba_mode:
/* save the total number of sectors */
movl 0x10(%si), %ecx
/* set %si to the disk address packet */
movw $ABS(disk_address_packet), %si
/* set the mode to non-zero */
movb $1, -1(%si)
movl ABS(stage2_sector), %ebx
/* the size and the reserved byte */
movw $0x0010, (%si)
/* the blocks */
movw $1, 2(%si)
/* the absolute address (low 32 bits) */
movl %ebx, 8(%si)
/* the segment of buffer address */
movw $STAGE1_BUFFERSEG, 6(%si)
xorl %eax, %eax
movw %ax, 4(%si)
movl %eax, 12(%si)