From: cinap_lenrek@gmx.de
To: 9fans@9fans.net
Subject: [9fans] bootiso.s fixed
Date: Thu, 8 Apr 2010 00:52:42 +0200 [thread overview]
Message-ID: <9724ac79049bc26a724978dd60a219b2@gmx.de> (raw)
In-Reply-To: <d1c554291003291911w4e2cedg3408cf43ecae0ce2@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]
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
[-- Attachment #2: Type: text/plain, Size: 8528 bytes --]
#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'
[-- Attachment #3: Type: text/plain, Size: 1880 bytes --]
/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
next prev parent reply other threads:[~2010-04-07 22:52 UTC|newest]
Thread overview: 109+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-21 21:33 [9fans] using acme/Mail from plan9port in Linux Lorenzo Bolla
2009-11-21 22:27 ` Mathieu Lonjaret
2009-12-17 7:48 ` Jason Catena
2010-03-23 11:18 ` hugo rivera
2010-03-23 13:02 ` Mathieu Lonjaret
2010-03-23 13:27 ` hugo rivera
2010-03-23 13:37 ` Mathieu Lonjaret
2010-03-23 14:29 ` erik quanstrom
2010-03-23 15:13 ` Steve Simon
2010-03-23 15:41 ` David Leimbach
2010-03-23 16:10 ` Steve Simon
2010-03-23 16:41 ` Russ Cox
2010-03-23 17:02 ` hugo rivera
2010-03-23 19:47 ` Russ Cox
2010-03-24 9:50 ` [9fans] VIA Rhine II support? EBo
2010-03-24 10:24 ` Federico G. Benavento
2010-03-25 18:56 ` Harri Haataja
2010-03-25 19:08 ` EBo
2010-03-24 9:59 ` [9fans] native install EBo
2010-03-24 14:56 ` David Leimbach
2010-03-24 15:17 ` Richard Miller
2010-03-24 15:22 ` Francisco J Ballesteros
2010-03-24 16:00 ` erik quanstrom
2010-03-24 16:05 ` Steve Simon
2010-03-24 19:18 ` Gabriel Diaz Lopez de la Llave
2010-03-24 19:48 ` Steve Simon
2010-03-24 20:17 ` Lyndon Nerenberg (VE6BBM/VE7TFX)
2010-03-24 21:49 ` David du Colombier
2010-04-09 19:36 ` Tom West
2010-04-09 20:20 ` EBo
2010-04-10 2:26 ` erik quanstrom
2010-04-10 9:21 ` Gabriel Diaz
2010-04-10 12:54 ` erik quanstrom
2010-04-10 16:28 ` Gabriel Diaz
2010-04-10 19:38 ` erik quanstrom
2010-04-11 12:37 ` Gabriel Diaz Lopez de la Llave
2010-04-11 15:36 ` erik quanstrom
2010-04-11 15:37 ` Gabriel Diaz Lopez de la Llave
2010-04-11 15:40 ` erik quanstrom
2010-03-24 20:11 ` EBo
2010-03-24 20:19 ` John Floren
2010-03-24 20:41 ` erik quanstrom
2010-03-25 1:21 ` Jacob Todd
2010-03-25 1:35 ` erik quanstrom
2010-03-25 11:15 ` Jacob Todd
2010-03-25 13:25 ` erik quanstrom
2010-03-25 10:28 ` Jacob Todd
2010-03-25 15:43 ` erik quanstrom
2010-03-25 13:37 ` Jacob Todd
2010-03-25 18:58 ` erik quanstrom
2010-03-25 20:04 ` Steve Simon
2010-03-25 22:34 ` Jorden Mauro
2010-03-26 6:00 ` Federico G. Benavento
2010-03-25 14:10 ` Steve Simon
2010-03-25 1:52 ` Maht
2010-03-25 2:05 ` Federico G. Benavento
2010-03-24 22:34 ` Skip Tavakkolian
2010-03-24 15:23 ` andrey mirtchovski
2010-03-28 14:32 ` Georg Lehner
2010-03-28 14:39 ` erik quanstrom
2010-03-29 19:57 ` Georg Lehner
2010-03-29 20:21 ` michael block
2010-03-28 14:44 ` maht
2010-03-29 20:07 ` Georg Lehner
2010-03-29 20:16 ` erik quanstrom
2010-03-29 22:38 ` Patrick Kelly
2010-03-29 20:52 ` maht
2010-03-29 20:58 ` Corey
2010-03-29 20:57 ` ron minnich
2010-03-29 21:09 ` erik quanstrom
2010-03-30 0:20 ` [9fans] Plan ? (was: native install) Corey
2010-03-30 0:24 ` erik quanstrom
2010-03-30 1:21 ` Corey
2010-03-30 2:02 ` Iruata Souza
2010-03-30 2:07 ` Jacob Todd
2010-03-30 6:41 ` Corey
2010-03-30 2:17 ` Patrick Kelly
2010-03-30 3:10 ` Rahul Murmuria
2010-03-30 18:23 ` Jack Johnson
2010-03-30 18:25 ` Jack Johnson
2010-03-30 18:44 ` Patrick Kelly
2010-04-01 10:13 ` [9fans] Plan ? William Cowan
2010-03-30 9:28 ` [9fans] Plan ? (was: native install) Steve Simon
2010-03-30 10:19 ` hugo rivera
2010-03-30 10:33 ` Gabriel Diaz Lopez de la Llave
2010-03-30 10:40 ` hugo rivera
2010-03-30 11:40 ` Francisco J Ballesteros
2010-03-30 12:20 ` Patrick Kelly
2010-03-30 12:34 ` Steve Simon
2010-03-30 13:28 ` tlaronde
2010-03-30 13:45 ` Patrick Kelly
2010-03-30 17:07 ` Albert Skye
2010-03-30 17:13 ` David Leimbach
2010-03-30 18:09 ` Nick LaForge
2010-03-30 18:03 ` tlaronde
2010-03-30 2:11 ` Iruata Souza
2010-04-07 22:52 ` cinap_lenrek [this message]
2010-04-08 0:08 ` [9fans] bootiso.s fixed ron minnich
2010-04-08 15:04 ` David Leimbach
2010-04-08 1:14 ` Iruata Souza
2010-04-08 14:29 ` erik quanstrom
2010-04-08 15:05 ` David Leimbach
2010-04-08 19:18 ` Jorden M
2010-04-08 18:11 ` ron minnich
2010-04-08 18:17 ` erik quanstrom
2010-04-08 18:28 ` Federico G. Benavento
2010-04-08 19:05 ` ron minnich
2010-04-08 19:07 ` erik quanstrom
2010-04-08 19:36 ` cinap_lenrek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9724ac79049bc26a724978dd60a219b2@gmx.de \
--to=cinap_lenrek@gmx.de \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).