diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-05-06 01:15:46 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-05-06 01:15:46 +0200 |
commit | cd66b11f67654edfa54cab05422310d5c923784a (patch) | |
tree | ffb3e300f0068f6976cf838e087294bfe459930d /sys/src/boot | |
parent | d3b727db18c04b1eb485399dfcebff8ff61d8c7b (diff) |
pbs: allow 9bootfat start cluster beyond 0xFFFF
pbs failed to load (silently loading garbage) 9BOOTFAT from start
cluster beyond FFFF because we ignored the low word from the
directory entry. now taking the high 16 bit of the directory's
start cluster into account.
Diffstat (limited to 'sys/src/boot')
-rw-r--r-- | sys/src/boot/pc/pbs.s | 26 | ||||
-rw-r--r-- | sys/src/boot/pc/x16.h | 1 |
2 files changed, 16 insertions, 11 deletions
diff --git a/sys/src/boot/pc/pbs.s b/sys/src/boot/pc/pbs.s index bff333617..e79c61998 100644 --- a/sys/src/boot/pc/pbs.s +++ b/sys/src/boot/pc/pbs.s @@ -156,43 +156,47 @@ _nextdir: _found: CLR(rBX) - LW(_rootsize(SB), rAX) /* calculate and save Xrootsz */ LWI(0x20, rCX) MUL(rCX) LW(_sectsize(SB), rCX) - PUSHR(rCX) DEC(rCX) ADD(rCX, rAX) ADC(rBX, rDX) - POPR(rCX) /* _sectsize(SB) */ + INC(rCX) DIV(rCX) PUSHR(rAX) /* Xrootsz */ - LXW(0x1a, xSI, rAX) /* starting sector address */ - DEC(rAX) /* that's just the way it is */ - DEC(rAX) - LB(_clustsize(SB), rCL) - CLRB(rCH) + CLR(rCX) + LXW(0x1a, xSI, rAX) /* start cluster low */ + LXW(0x14, xSI, rBX) /* start cluster high */ + SUBI(2, rAX) /* cluster -= 2 */ + SBB(rCX, rBX) + + LB(_clustsize(SB), rCL) /* convert to sectors (AX:DX) */ + IMUL(rCX, rBX) MUL(rCX) + ADD(rBX, rDX) + LW(_volid(SB), rCX) /* Xrootlo */ ADD(rCX, rAX) LW(_volid+2(SB), rCX) /* Xroothi */ ADC(rCX, rDX) + + CLR(rBX) POPR(rCX) /* Xrootsz */ ADD(rCX, rAX) ADC(rBX, rDX) - PUSHR(rAX) /* calculate how many sectors to read */ + PUSHR(rAX) /* calculate how many sectors to read (CX) */ PUSHR(rDX) LXW(0x1c, xSI, rAX) LXW(0x1e, xSI, rDX) LW(_sectsize(SB), rCX) - PUSHR(rCX) DEC(rCX) ADD(rCX, rAX) ADC(rBX, rDX) - POPR(rCX) /* _sectsize(SB) */ + INC(rCX) DIV(rCX) MW(rAX, rCX) POPR(rBX) diff --git a/sys/src/boot/pc/x16.h b/sys/src/boot/pc/x16.h index f0c9376dc..21edbac46 100644 --- a/sys/src/boot/pc/x16.h +++ b/sys/src/boot/pc/x16.h @@ -117,6 +117,7 @@ BYTE $i; #define SHRBI(i, r) OPrr(0xC0, 0x05, r); /* r>>i -> r */ \ BYTE $i; +#define SBB(r0, r1) OPrr(0x19, r0, r1) /* r1-r0 -> r1 */ #define SUB(r0, r1) OPrr(0x29, r0, r1) /* r1-r0 -> r1 */ #define SUBI(i, r) OP(0x81, 0x03, 0x05, r);/* r-i -> r */ \ WORD $i; |