ADJUST_DRIVE
pushw %dx /* 0(%bp) = %dl -> drive number */
+ movw %sp, %bp /* %bp -> frame pointer: LEAVE UNCHANGED */
+
+ /* prepare to read sector size */
+ sub $0x1c, %sp /* -28(%bp) == %sp */
+ pushw $0x1e /* -30(%bp) == %sp */
+ movw $0x200, -6(%bp) /* -6(%bp) sector size */
/* Check to see if we have EBIOS */
pushw %dx /* drive number */
xorb %dh, %dh
stc
int $0x13
+ popw %dx /* restore drive */
+ movb $0x08, %ah /* get CHS geometry */
jc 1f
cmpw $0xaa55, %bx
jne 1f
movl $0xeb42b4+((read_common-read_sector_cbios-4) << 24), \
(read_sector_cbios)
-1:
- popw %dx
+ /*
+ * read sector size.
+ * Should not fail but if it does I assume that at least
+ * previous 512 value is not overridden
+ */
+ movb $0x48, %ah
+ movw %sp, %si
+1:
/* Get (C)HS geometry */
- movb $0x08, %ah
int $0x13
+
+ /* here we computer CHS values or just do some dummy computation for EBIOS */
andw $0x3f, %cx /* Sector count */
- movw %sp, %bp /* %bp -> frame pointer: LEAVE UNCHANGED */
- pushw %cx /* -2(%bp) Save sectors on the stack */
+ pushw %cx /* -32(%bp) Save sectors on the stack */
movzbw %dh, %ax /* dh = max head */
incw %ax /* From 0-based max to count */
mulw %cx /* Heads*sectors -> sectors per cylinder */
/* Save sectors/cylinder on the stack */
- pushw %dx /* -4(%bp) High word */
- pushw %ax /* -6(%bp) Low word */
+ pushw %dx /* -34(%bp) High word */
+ pushw %ax /* -36(%bp) Low word */
/* Load partition table header */
xorl %eax,%eax
call read_sector_phdr
/* Number of partition sectors */
- /* We assume the partition table is 32K or less, and that
- the sector size is 512. */
+ /* We assume the partition table is 32K or less */
movw (80+6)(%bp),%cx /* NumberOfPartitionEntries */
movw (84+6)(%bp),%ax /* SizeOfPartitionEntry */
pushw %ax
pushw %cx
mulw %cx
- shrw $9,%ax
+ divw -6(%bp) /* %dx == 0 here */
xchgw %ax,%cx
incw %cx
movl (32+20)(%si),%eax
movl (36+20)(%si),%edx
call read_sector_phdr
- cmpw $0xaa55, -2(%bx)
+ cmpw $0xaa55, (0x7c00+0x1fe)
jne missing_os /* Not a valid boot sector */
movw %bp, %sp /* driveno == bootsec-6 */
popw %dx /* dl -> drive number */
/* This chunk is skipped if we have ebios */
/* Do not clobber %es:%bx or %edx:%eax before this chunk! */
read_sector_cbios:
- divl -6(%bp) /* secpercyl */
+ divl -36(%bp) /* secpercyl */
shlb $6, %ah
movb %ah, %cl
movb %al, %ch
xchgw %dx, %ax
- divb -2(%bp) /* sectors */
+ divb -32(%bp) /* sectors */
movb %al, %dh
orb %ah, %cl
incw %cx /* Sectors are 1-based */
leaw 16(%si), %sp /* Drop DAPA */
popal
jc disk_error
- addb $2, %bh /* bx += 512: point to the next buffer */
+ addb -5(%bp), %bh /* bx += sector size: point to the next buffer */
/* fall through and increment sector number */