From cd5cef000fc6decd40fc25d8a1760cf58884547c Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 13 Jun 2011 05:34:19 +0000 Subject: [PATCH] pbs: dont rely on chainloader to hand us a partition table and properly get the partition offset from nhidden in the fat header, add compare after mul because MUL doesnt set ZF but makes it undefined! --- sys/src/boot/pc/pbs.s | 52 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/sys/src/boot/pc/pbs.s b/sys/src/boot/pc/pbs.s index 07c189e1c..8a11b8279 100644 --- a/sys/src/boot/pc/pbs.s +++ b/sys/src/boot/pc/pbs.s @@ -36,8 +36,10 @@ TEXT _nhiddenhi(SB), $0 TEXT _bigvolsize(SB), $0 BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x00; /* FAT32 structure, starting @0x24 */ -TEXT _fatsz32(SB), $0 - BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x00 +TEXT _fatsz32lo(SB), $0 + BYTE $0x00; BYTE $0x00 +TEXT _fatsz32hi(SB), $0 + BYTE $0x00; BYTE $0x00 TEXT _extflags(SB), $0 BYTE $0x00; BYTE $0x00 TEXT _fsver(SB), $0 @@ -76,14 +78,12 @@ _start0x5A: MTSR(rAX, rES) LWI(0x100, rCX) - MW(rSI,rBX) /* address of partition record -> rBX */ LWI(RELOC, rSI) MW(rSI, rSP) LWI(_magic(SB), rDI) CLD REP; MOVSL /* MOV DS:[(E)SI] -> ES:[(E)DI] */ - PUSHA MW(rSP, rBP) PUSHR(rCX) @@ -96,39 +96,41 @@ _halt: TEXT start16(SB), $0 STI + LWI(hello(SB), rSI) CALL16(print16(SB)) - PUSHR(rDX) - PUSHR(rBX) + PUSHR(rDX) /* drive */ - LB(_nfats(SB), rCL) /* # of fats */ - LW(_fatsize(SB), rAX) /* fat size */ - MUL(rCX) /* DX:AX = #sectors */ - JNE _fatszok /* zero? it's FAT32 */ + CLR(rDX) + LW(_fatsize(SB), rAX) + CLR(rCX) + LB(_nfats(SB), rCL) + MUL(rCX) + OR(rCX, rCX) + JNE _fatszok /* zero? it's FAT32 */ - LW(_fatsz32+2(SB), rBX) /* hi word */ - IMUL(rCX, rBX) /* ... in sectors */ - LW(_fatsz32(SB), rAX) /* lo word */ - MUL(rCX) /* ... in sectors */ - ADD(rBX, rDX) /* DX:AX = #sectors */ + LW(_fatsz32hi(SB), rBX) + IMUL(rCX, rBX) + LW(_fatsz32lo(SB), rAX) + MUL(rCX) + ADD(rBX, rDX) _fatszok: - POPR(rBX) /* address of partition record */ - - LXW(8, xBX, rCX) /* lo partition LBA */ + LW(_nhiddenlo(SB), rCX) ADD(rCX, rAX) - LXW(10, xBX, rCX) /* hi partition LBA */ + LW(_nhiddenhi(SB), rCX) ADC(rCX, rDX) CLR(rBX) - LW(_nresrv(SB), rCX) /* # of reserved */ + LW(_nresrv(SB), rCX) ADD(rCX, rAX) ADC(rDX, rBX) - SW(rAX, _volid(SB)) /* save for later use */ - SW(rDX, _volid+2(SB)) - POPR(rDX) + SW(rAX, _volid(SB)) /* save for later use */ + SW(rBX, _volid+2(SB)) + + POPR(rDX) /* drive */ PUSHR(rBP) LW(_sectsize(SB), rCX) @@ -164,7 +166,7 @@ _nextdir: JMP _nextsect _found: - PUSHR(rDX) + PUSHR(rDX) /* drive */ CLR(rBX) @@ -208,7 +210,7 @@ _found: MW(rAX, rCX) POPR(rBX) POPR(rAX) - POPR(rDX) + POPR(rDX) /* drive */ LWI(RELOC, rSI) PUSHR(rSI)