// LBA: 调用BIOS INIT 13中断0x42号功能 /* * BIOS call "INT 0x13 Function 0x42" to read sectors from disk into memory * Call with %ah = 0x42 * %dl = drive number * %ds:%si = segment:offset of disk address packet * Return: * %al = 0x0 on success; err code on failure */
movb $0x42, %ah int $0x13
/* LBA read is not supported, so fallback to CHS. */ jc chs_mode
movw $STAGE1_BUFFERSEG, %bx // STAGE1_BUFFERSEG在stag1.h中定义,为0x7000 jmp copy_buffer
//CHS:调用 BIOS INIT 13中断 0x2 号功能 /* * BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory * Call with %ah = 0x2 * %al = number of sectors * %ch = cylinder * %cl = sector (bits 6-7 are high bits of "cylinder") * %dh = head * %dl = drive (0x80 for hard disk, 0x0 for floppy disk) * %es:%bx = segment:offset of buffer * Return: * %al = 0x0 on success; err code on failure */
movw $STAGE1_BUFFERSEG, %bx // STAGE1_BUFFERSEG在stag1.h中定义,为0x7000 movw %bx, %es /* load %es segment with disk buffer */
xorw %bx, %bx /* %bx = 0, put it at 0 in the segment */ movw $0x0201, %ax /* function 2 */ int $0x13
jc read_error
movw %es, %bx
// COPY_BUFFER copy_buffer: movw ABS(stage2_segment), %es
/* * We need to save %cx and %si because the startup code in * stage2 uses them without initializing them. */ pusha pushw %ds
movw $0x100, %cx movw %bx, %ds xorw %si, %si xorw %di, %di
cld
rep movsw
popw %ds popa
/* boot stage2 */ jmp *(stage2_address) //stage2_address 为0x8000
|