Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

confused by the several lines of source code in mbr.S



First, I am confused by the following lines of code from the mbr.S in
i386/stand/mbr directory.

---------------------------------- snip
--------------------------------------------------------
216     movw    $lba_info, %si
217     movb    $0x42, %ah
218     pop     %dx                     /* recover drive # */
219     push    %dx                     /* save drive */
220     int     $0x13
221     jc      wait_key                /* abort menu on read fail */
222     cmpw    $MBR_MAGIC, LOADADDR + MBR_MAGIC_OFFSET
223     movw    $nametab - LOADADDR + BOOTADDR, %bx
224     je      next_extended
---------------------------------- snip
--------------------------------------------------------

Moreover, the BOOTADDR and LOADADDR are defined as below:

---------------------------------- snip
--------------------------------------------------------
65 #define BOOTADDR     0x7c00
66 #define LOADADDR     0x0600          /* address were are linked to */
---------------------------------- snip
--------------------------------------------------------

When we call INT 0x13, BIOS will transfer the PBR code to the address
BOOTADDR included in the lba_info struct, and then we should check
whether the PBR code is valid.

The address LOADADDR + MBR_MAGIC_OFFSET in line 222 is 0x0600 +
MBR_MAGIC_OFFSET, which is just the magic number's address of the mbr
code but not the PBR code, and no process will modify the mbr's magic
number, so, there is alwasy a jump to next_extended.

So, is there any other purpos or just a bug because of incaution?

Thanks for any tips or comments.



Home | Main Index | Thread Index | Old Index