i guess this email was for me. ;]
On Wed, Apr 7, 2010 at 7:52 PM, <cinap_len...@gmx.de> wrote: > found it! > > the problem was the LBPB() to load byte 0 from the pvd for comparsion. > i loaded it into rBX instead of rBL. found this out after dumping the > buffer and noticed that the contents where the same on t23 and amd > machine. > > it all works now. tested on t23, bochs, and amd machine and its > blazing fast :) > > updated the tarballs: > > /n/sources/contrib/cinap_lenrek/tuttleboot.tgz > http://9hal.ath.cx/usr/cinap_lenrek/tuttleboot.tgz > > attached the file and the diff to this mail... > > -- > cinap > > #include "x16.h" > #include "mem.h" > > /* > * simple Plan 9 bootblock for ISO9660 that can load a uncompressed a.out > kernel > * image. looks for 386/9pcload. if heres no 386 it searches 9pcload in the > root. > * this is a non floppy emulation el torito bootblock! > * > * Diagnostics are: > * ♥ alive! > * ? i/o error, will retry > * ! i/o error, giving up > * F bad a.out magic > * S could not find the file > * > */ > > #define DATA32SEL SELECTOR(1, SELGDT, 0) > #define EXEC32SEL SELECTOR(2, SELGDT, 0) > #define EXEC16SEL SELECTOR(3, SELGDT, 0) > > #define FARRET \ > BYTE $0xCB > #define SWAPB(r) \ > BYTE $0x0F; BYTE $(0xC8|r) > #define XORAL(i) \ > BYTE $0x34; BYTE $i > > /* 2048 byte sectors */ > #define SECTSHIFT 0x0B > #define BY2SECT (1<<SECTSHIFT) > > /* > * Data is kept on the stack, indexed by rBP. > */ > #define Xdap 0x00 /* disc address packet */ > #define Xdrive 0x12 /* boot drive, passed by BIOS or MBR */ > #define Xentry 0x14 /* a.out entry, text, data*/ > #define Xtextsz 0x18 > #define Xdatasz 0x1c > #define Xload 0x20 /* load pointer */ > #define Xcount 0x24 /* # of sectors to load */ > #define Xbuf 0x28 > #define Xtotal (Xbuf+BY2SECT) > > /* a.out header offsets */ > #define Amagic 0x00 > #define Atextsz 0x04 > #define Adatasz 0x08 > #define Aentry 0x14 > #define Aouthdr 0x20 > > TEXT magic(SB), $0 > /* jmp .+ 0x3E (_start0x40); nop; nop; nop; nop; nop; nop */ > BYTE $0xEB; BYTE $0x3E; BYTE $0x90; BYTE $0x90 > BYTE $0x90; BYTE $0x90; BYTE $0x90; BYTE $0x90 > > TEXT bipvd(SB), $0 > LONG $0x00000000 > TEXT bibootfile(SB), $0 > LONG $0x00000000 > TEXT bibootfilelen(SB), $0 > LONG $0x00000000 > TEXT bichecksum(SB), $0 > LONG $0x00000000 > TEXT bireserved(SB), $0 > LONG $0x00000000 > LONG $0x00000000 > LONG $0x00000000 > LONG $0x00000000 > LONG $0x00000000 > LONG $0x00000000 > LONG $0x00000000 > LONG $0x00000000 > LONG $0x00000000 > LONG $0x00000000 > > _start0x40: > CLI > > /* be carefull! do not trash rDL until we reached start() */ > LWI(magic-Xtotal(SB), rSP) > MW(rSP, rBP) > LWI(start(SB), rAX) > > _farret16: > CLR(rCX) > MTSR(rCX, rDS) > MTSR(rCX, rES) > MTSR(rCX, rSS) > PUSHR(rCX) > PUSHR(rAX) > FARRET > > TEXT return16(SB), $0 > MFCR(rCR0, rAX) > XORAL(1) > MTCR(rAX, rCR0) > LWI(return16ret(SB), rAX) > JMP _farret16 > > TEXT return16ret(SB), $0 > STI > RET > > TEXT start(SB), $0 > STI > > SBPB(rDL, Xdrive) > > /* alive! */ > LWI(0x0E03, rAX) > BIOSCALL(0x10) > > /* A20! we has to enable itt! */ > LWI(0x2401, rAX) > BIOSCALL(0x15) > > /* find the primary volume descriptor */ > CLR(rDX) > LWI(0x0010, rAX) > > LWI(0xFF, rCX) > CLR(rBX) > _nextpvd: > CALL16(BIOSread(SB)) > LBPB(Xbuf, rBL) > CMPI(1, rBX) > JEQ _pvdfound > CLR(rBX) > ADDI(1, rAX) > ADC(rBX, rDX) > LOOP _nextpvd > > CALL16(srcherror(SB)) > > _pvdfound: > /* load lba and length of root directory */ > LBPW((Xbuf+156+2), rAX) > LBPW((Xbuf+156+4), rDX) > LBPW((Xbuf+156+10), rCX) > LBPW((Xbuf+156+12), rBX) > > CALL16(walk(SB)) > CALL16(srcherror(SB)) > > TEXT load(SB), $0 > CLR(rCX) > SBPWI(0xFFFF, Xcount+0) > SBPWI(0xFFFF, Xcount+2) > CALL16(BIOSread(SB)) > > _loop: > PUSHA > CALL16(BIOSread(SB)) > CALL16(movehigh(SB)) > POPA > ADDI(1, rAX) > ADC(rCX, rDX) > JMP _loop > > TEXT BIOSread(SB), $0 > > LWI(5, rDI) /* retry count (ATAPI ZIPs suck) */ > > _retry: > PUSHA > PUSHS(rDS) > PUSHS(rES) > PUSHS(rFS) > PUSHS(rGS) > > SBPW(rAX, Xdap+8) > SBPW(rDX, Xdap+10) > SBPWI(0x0010, Xdap+0) /* reserved + packet size */ > SBPWI(0x0001, Xdap+2) /* # of blocks to transfer */ > MW(rBP, rSI) > ADDI(Xbuf, rSI) > SBPW(rSI, Xdap+4) /* transfer buffer :offset */ > MFSR(rSS, rSI) /* transfer buffer seg: */ > SBPW(rSI, Xdap+6) > > MW(rBP, rSI) /* Xdap == BP */ > LBPB(Xdrive, rDL) > LWI(0x4200, rAX) > > BIOSCALL(0x13) > JCC _readok > > _reset: > LWI((0x0E00+'?'), rAX) > BIOSCALL(0x10) > > /* reset the drive */ > LBPB(Xdrive, rDL) > CLR(rAX) > BIOSCALL(0x13) > > POPS(rGS) > POPS(rFS) > POPS(rES) > POPS(rDS) > POPA > > DEC(rDI) > JNE _retry > > TEXT ioerror(SB), $0 > LBI('!', rAL) > JMP _error > > TEXT fmterror(SB), $0 > LBI('F', rAL) > JMP _error > > TEXT srcherror(SB), $0 > LBI('S', rAL) > JMP _error > > _error: > /* print error code */ > LBI(0x0E, rAH) > BIOSCALL(0x10) > > /* wait for almost any key */ > CLR(rAX) > BIOSCALL(0x16) > > /* reset */ > LWI(0x0472, rBX) /* warm-start code address */ > LWI(0x1234, rAX) /* warm-start code */ > POKEW /* MOVW AX, ES:[BX] */ > FARJUMP16(0xFFFF, 0x0000) > > _readok: > POPS(rGS) > POPS(rFS) > POPS(rES) > POPS(rDS) > POPA > > RET > > TEXT walk(SB), $0 > PUSHR(rAX) > PUSHR(rDX) > PUSHR(rCX) > PUSHR(rBX) > > CALL16(BIOSread(SB)) > MW(rBP, rBX) > ADDI(Xbuf, rBX) > MW(rBX, rDI) > > TEXT walknext(SB), $0 > MW(rDI, rSI) > > MW(rSI, rAX) > SUB(rBX, rAX) > CMPI(BY2SECT, rAX) > JGE _nextsector > CLR(rCX) > LXB(0, xSI, rCL) > ORB(rCL, rCL) > JEQ _nextsector > ADD(rCX, rDI) > > PUSHI(walktest(SB)) > RET > > _nextsector: > POPR(rBX) > POPR(rCX) > POPR(rDX) > POPR(rAX) > > OR(rCX, rCX) > JNE _contwalk > OR(rBX, rBX) > JEQ _retwalk > DEC(rBX) > _contwalk: > SUBI(BY2SECT, rCX) > > CLR(rDI) > ADDI(1, rAX) > ADC(rDI, rDX) > PUSHI(walk(SB)) > _retwalk: > RET > > TEXT walktest(SB), $0 > PUSHA > > LXW(2, xSI, rAX) > LXW(4, xSI, rDX) > LXW(10, xSI, rCX) > LXW(12, xSI, rBX) > > PUSHA > CLR(rCX) > LXB(25, xSI, rCL) > ANDI(2, rCX) > POPA > JEQ _notdir > > PUSHA > LWI(dirname(SB), rDX) > CALL16(cmpiname(SB)) > POPA > JNE _skipdir > > ADDI((2*12), rSP) > PUSHI(walk(SB)) > RET > > _notdir: > PUSHA > LWI(filename(SB), rDX) > CALL16(cmpiname(SB)) > POPA > JNE _skipdir > > CALL16(load(SB)) > /* no return */ > > _skipdir: > POPA > PUSHI(walknext(SB)) > RET > > TEXT cmpiname(SB), $0 > CLR(rBX) > CLR(rAX) > > CLR(rCX) > LXB(32, xSI, rCL) > ADDI(33, rSI) > MW(rDX, rDI) > > PUSHR(rDI) > PUSHR(rCX) > _lenloop: > LXB(0, xDI, rAL) > OR(rAX, rAX) > JEQ _endlen > DEC(rCX) > INC(rDI) > JMP _lenloop > _endlen: > OR(rCX, rCX) > POPR(rCX) > POPR(rDI) > JNE _ret > > _cmploop: > LXB(0, xSI, rAL) > LXB(0, xDI, rBL) > CMPI('a', rAX) > JLT _nocasea > CMPI('z', rAX) > JGT _nocasea > ADDI(('A' - 'a'), rAX) > _nocasea: > CMPI('a', rBX) > JLT _nocaseb > CMPI('z', rBX) > JGT _nocaseb > ADDI(('A' - 'a'), rBX) > _nocaseb: > CMP(rAX, rBX) > JNE _ret > INC(rSI) > INC(rDI) > LOOP _cmploop > OR(rCX, rCX) > _ret: > RET > > TEXT movehigh(SB), $0 > CLI > LGDT(tgdtptr(SB)) > > MFCR(rCR0, rAX) > XORAL(1) > MTCR(rAX, rCR0) > > FARJUMP32(EXEC32SEL, movehigh32(SB)) > > TEXT movehigh32(SB), $0 > /* upper bits seem to be fucked */ > ANDL $0xFFFF, BP > ANDL $0xFFFF, SP > > MOVL $DATA32SEL, AX > MOVW AX, DS > MOVW AX, ES > MOVW AX, SS > > MOVL Xload(BP), DI > MOVL Xcount(BP), BX > > MOVL BP, SI > ADDL $Xbuf, SI > > CMPL BX, $0 > JEQ _boot > JGT _movedata > > MOVL Amagic(SI), AX > CMPL AX, $0xeb010000 > JNE _fmterror > > MOVL Aentry(SI), DI > SWAPB(rDI) > ANDL $~0xF0000000, DI > MOVL DI, Xentry(BP) > SUBL $Aouthdr, DI > > MOVL Atextsz(SI), BX > SWAPB(rBX) > MOVL BX, Xtextsz(BP) > > MOVL Adatasz(SI), CX > SWAPB(rCX) > MOVL CX, Xdatasz(BP) > > ADDL CX, BX > ADDL $(BY2SECT-1), BX > SHRL $SECTSHIFT, BX > > _movedata: > MOVL $BY2SECT, CX > REP; MOVSB > DECL BX > > MOVL DI, Xload(BP) > MOVL BX, Xcount(BP) > > _return: > /* Move back to 16 bit code segment from protected mode */ > BYTE $0xEA; LONG $return16(SB); WORD $EXEC16SEL > > _fmterror: > /* patch the 16 bit caller pc to point to the error function */ > MOVL $fmterror(SB), AX > MOVW AX, 0(SP) > JMP _return > > _boot: > /* > * we have to move the data segment to a page aligned > * address. > */ > MOVL Xentry(BP), SI > MOVL SI, AX > ADDL Xtextsz(BP), SI > MOVL SI, DI > ADDL $(BY2PG-1), DI > ANDL $(~(BY2PG-1)), DI > MOVL Xdatasz(BP), CX > DECL CX > ADDL CX, SI > ADDL CX, DI > INCL CX > STD > REP; MOVSB > JMP *AX > > TEXT tgdt(SB),$0 > /* null descriptor */ > LONG $0 > LONG $0 > > /* data segment descriptor for 4 gigabytes (PL 0) */ > LONG $(0xFFFF) > LONG $(SEGG|SEGB|(0xF<<16)|SEGP|SEGPL(0)|SEGDATA|SEGW) > > /* exec segment descriptor for 4 gigabytes (PL 0) */ > LONG $(0xFFFF) > LONG $(SEGG|SEGD|(0xF<<16)|SEGP|SEGPL(0)|SEGEXEC|SEGR) > > /* exec segment descriptor for 4 gigabytes (PL 0) 16-bit */ > LONG $(0xFFFF) > LONG $(SEGG|(0xF<<16)|SEGP|SEGPL(0)|SEGEXEC|SEGR) > > TEXT tgdtptr(SB),$0 > WORD $(4*8) > LONG $tgdt(SB) > > TEXT dirname(SB), $0 > BYTE $'3'; BYTE $'8'; BYTE $'6'; BYTE $'\z' > > TEXT filename(SB), $0 > BYTE $'9'; BYTE $'p'; BYTE $'c'; BYTE $'l' > BYTE $'o'; BYTE $'a'; BYTE $'d'; BYTE $'\z' > /n/dump/2010/0407/usr/cinap_lenrek/code/tuttleboot/sys/src/boot/pc/bootiso.s:120,133 > - bootiso.s:120,135 > CLR(rDX) > LWI(0x0010, rAX) > > - LWI(100, rCX) > + LWI(0xFF, rCX) > + CLR(rBX) > _nextpvd: > CALL16(BIOSread(SB)) > - LBPB(Xbuf, rBX) > + LBPB(Xbuf, rBL) > CMPI(1, rBX) > JEQ _pvdfound > + CLR(rBX) > ADDI(1, rAX) > - ADC(rCX, rDX) > + ADC(rBX, rDX) > LOOP _nextpvd > > CALL16(srcherror(SB)) > /n/dump/2010/0407/usr/cinap_lenrek/code/tuttleboot/sys/src/boot/pc/bootiso.s:158,167 > - bootiso.s:160,174 > JMP _loop > > TEXT BIOSread(SB), $0 > + > LWI(5, rDI) /* retry count (ATAPI ZIPs suck) */ > > _retry: > PUSHA > + PUSHS(rDS) > + PUSHS(rES) > + PUSHS(rFS) > + PUSHS(rGS) > > SBPW(rAX, Xdap+8) > SBPW(rDX, Xdap+10) > /n/dump/2010/0407/usr/cinap_lenrek/code/tuttleboot/sys/src/boot/pc/bootiso.s:170,187 > - bootiso.s:177,195 > MW(rBP, rSI) > ADDI(Xbuf, rSI) > SBPW(rSI, Xdap+4) /* transfer buffer :offset */ > - MFSR(rES, rSI) /* transfer buffer seg: */ > + MFSR(rSS, rSI) /* transfer buffer seg: */ > SBPW(rSI, Xdap+6) > > MW(rBP, rSI) /* Xdap == BP */ > LBPB(Xdrive, rDL) > - LBI(0x42, rAH) > + LWI(0x4200, rAX) > + > BIOSCALL(0x13) > - JCC _popret > + JCC _readok > > _reset: > LWI((0x0E00+'?'), rAX) > - BIOSCALL(0x10) > + BIOSCALL(0x10) > > /* reset the drive */ > LBPB(Xdrive, rDL) > /n/dump/2010/0407/usr/cinap_lenrek/code/tuttleboot/sys/src/boot/pc/bootiso.s:188,194 > - bootiso.s:196,207 > CLR(rAX) > BIOSCALL(0x13) > > + POPS(rGS) > + POPS(rFS) > + POPS(rES) > + POPS(rDS) > POPA > + > DEC(rDI) > JNE _retry > > /n/dump/2010/0407/usr/cinap_lenrek/code/tuttleboot/sys/src/boot/pc/bootiso.s:219,226 > - bootiso.s:232,244 > POKEW /* MOVW AX, ES:[BX] */ > FARJUMP16(0xFFFF, 0x0000) > > - _popret: > + _readok: > + POPS(rGS) > + POPS(rFS) > + POPS(rES) > + POPS(rDS) > POPA > + > RET > > TEXT walk(SB), $0 >