Mercurial > hg > Members > kono > nitros9-code
changeset 45:2ce754e62499
Moved booters to 3rdparty directory
author | boisy |
---|---|
date | Sat, 20 Apr 2002 13:36:45 +0000 |
parents | 0f2f6f3a0113 |
children | 60432af73b7e |
files | 3rdparty/booters/boot_ide.asm 3rdparty/booters/boot_kenton.asm 3rdparty/booters/boot_rampak.asm 3rdparty/booters/boot_rom.asm 3rdparty/booters/boot_tc3.asm 3rdparty/booters/boot_wd1002.asm 3rdparty/booters/defsfile 3rdparty/booters/makefile |
diffstat | 8 files changed, 1516 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdparty/booters/boot_ide.asm Sat Apr 20 13:36:45 2002 +0000 @@ -0,0 +1,261 @@ +******************************************************************** +* Boot - Glenside IDE Boot module +* +* $Id$ +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* 1 Created BGP 99/05/11 + + nam Boot + ttl Glenside IDE Boot module + + ifp1 + use defsfile + endc + +tylg set Systm+Objct +atrv set ReEnt+rev +rev set 0 +edition set 1 + + mod eom,name,tylg,atrv,start,size + +blockloc rmb 2 pointer to memory requested +blockimg rmb 2 duplicate of the above +bootloc rmb 3 sector pointer; not byte pointer +bootsize rmb 2 size in bytes +size equ . + +name fcs /Boot/ + fcb edition + +hwport fdb $FF70 + +start clra + ldb #size +clean pshs a + decb + bne clean + tfr s,u get pointer to data area + pshs u save pointer to data area + + lda #$D0 forced interrupt; kill floppy activity + sta $FF48 command register + clrb +pause decb + bne pause + lda $FF48 clear controller + clr $FF40 make sure motors are turned off + sta $FFD9 fast clock + lbsr Init + +* Request memory for LSN0 + ldd #1 + os9 F$SRqMem request one page of RAM + bcs error + bsr getpntr + +* Get LSN0 into memory + clrb MSB sector + ldx #0 LSW sector + bsr mread + bcs error + ldd bootsize,u + beq error + pshs d + +* Return memory + ldd #$100 + ldu blockloc,u + os9 F$SRtMem + puls d + os9 F$BtMem + bcs error + bsr getpntr + std blockimg,u + +* Get os9boot into memory + ldd bootsize,u + leas -2,s same as a PSHS D +getboot std ,s + ldb bootloc,u MSB sector location + ldx bootloc+1,u LSW sector location + bsr mread + ldd bootloc+1,u update sector location by one to 24bit word + addd #1 + std bootloc+1,u + ldb bootloc,u + adcb #0 + stb bootloc,u + inc blockloc,u update memory pointer for upload + ldd ,s update size of file left to read + subd #$100 file read one sector at a time + bhi getboot + + leas 4+size,s reset the stack same as PULS U,D + ldd bootsize,u + ldx blockimg,u pointer to start of os9boot in memory + andcc #^Carry clear carry + rts back to os9p1 + +error leas 2+size,s + ldb #E$NotRdy drive not ready + rts + +getpntr tfr u,d save pointer to requested memory + ldu 2,s recover pointer to data stack + std blockloc,u + rts + +mread tstb + bne read10 + cmpx #0 + bne read10 + bsr read10 + bcc readlsn0 + rts + +readlsn0 pshs a,x,y + ldy blockloc,u + lda DD.Bt,y os9boot pointer + ldx DD.Bt+1,y LSW of 24 bit address + sta bootloc,u + stx bootloc+1,u + ldx DD.BSZ,y os9boot size in bytes + stx bootsize,u + clrb + puls a,x,y,pc + +* Initialize IDE interface +Init ldx #$1500 + ldy hwport,pc +RdyIni1 tst 7,y Wait for drive ready + bpl GoInit + leax -1,x + bne RdyIni1 + lbeq ENotRdy Timed out ... give up on drive + +GoInit ldd #$AF20 Drive is ready -- initialize +* For IDE command $91, DrvHd reg = 101xhhhh binary + sta 6,y $10 heads (x=0-master/1-slave; hhhh=#heads) + stb 2,y $20 sectors/track + lda #$91 + sta 7,y Give drive the Init Drive Parameters IDE command +RdyIni2 tst 7,y + bmi RdyIni2 Wait *forever* until drive is ready + clrb + rts +ENotRdy comb + ldb #E$NotRdy + rts + +* +* READ +* +* B = MSB of OS-9 disk LSN +* X = LSB of OS-9 disk LSN +* +read10 lbsr SetIDE + bcs Ret + ldx blockloc,u + lda #$20 + pshs a + ldy hwport,pc +ReadLp lda ,y + ldb ,y + std ,x++ + lda ,y + ldb ,y + std ,x++ + lda ,y + ldb ,y + std ,x++ + lda ,y + ldb ,y + std ,x++ + dec ,s + bne ReadLp + puls a + +* +* After read or write, check drive status +* Return value = CC, true=error, false=OK +* +WaitOK lda #$80 Is DRQ still true? Just one check necessary + ldy hwport,pc + bita 7,y If it is, sector isn't fully transferred + bne WaitOK + lda #$01 Wait *forever* for drive ready + bita 7,y + bne CmdErr +Ret clrb Nope -- clear CC + rts +CmdErr comb Yep -- set CC + rts + +* +* Setup IDE read or write operation +* trashes D and X +* +SetIDE pshs b,x + ldx #$A000 +CmdLp1 ldy hwport,pc + tst 7,y + bpl SetRdy Should go to ChkDRDY ????? + leax -1,x + bne CmdLp1 + puls b,x + bra ENotRdy + +SetRdy lda 2,s Sector first + anda #$1F + adda #$01 + sta 3,y Store calculated sector number + ldd 1,s + rolb + rola + rolb + rola + rolb + rola + anda #$0F + ora #$A0 + sta 6,y Store calculated drive number + ldd ,s Last, the cylinder number (2-bytes) + rora + rorb + anda #$7F + sta 5,y Store calculated CylHi + stb 4,y Store calculated CylLo + lda #$01 + sta 2,y Sector count = 1 + ldb #$20 + stb 7,y Lastly, push the command to the drive + ldb #$40 + lda #$08 Wait for Drive ready +CmdLp2 bita 7,y + bne CmdDone + decb + bne CmdLp2 + ldx #$0001 If we time out, sleep 1 tick, then loop *forever* + os9 F$Sleep +CmdLp3 bita 7,y + beq CmdLp3 +CmdDone puls b,x + clrb All right, drive ready -- return + rts + +* Fillers to get to $1D0 + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /999999999/ + + emod + +eom equ *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdparty/booters/boot_kenton.asm Sat Apr 20 13:36:45 2002 +0000 @@ -0,0 +1,304 @@ +******************************************************************** +* Boot - Ken-Ton Boot module +* +* $Id$ +* +* This module allows booting from a hard drive that uses RGB-DOS +* and is controlled by a Ken-Ton SCSI controller. +* +* It was later modified to handle hard drives with sector sizes +* larger than 256 bytes, and works on both 256 byte and larger drives, +* so it should totally replace the old Ken-Ton boot module. +* +* Instructions followed by +++ in the comment field were added for this fix. +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* 1 Original Roger Krupski distribution version +* 1b Added code to allow booting from any sector BGP 96/??/?? +* size hard drive + + + nam Boot + ttl Ken-Ton Boot module + + ifp1 + use defsfile + endc + +tylg set Systm+Objct +atrv set ReEnt+rev +rev set 2 +edition set 1 + +* Hard Disk Interface registers for the Ken-ton and RGB HDI +dataport equ $FF74 +status equ dataport+1 +select equ dataport+2 +reset equ dataport+3 + +* Status register equates +req equ $01 +busy equ $02 +msg equ $04 +cmd equ $08 +inout equ $10 +ack equ $20 +sel equ $40 +rst equ $80 + +*SCSI common command set +c$rstr equ 1 +c$rdet equ 3 +c$rblk equ 8 +c$wblk equ 10 + +* Optional command +c$ststop equ $1b park head + +* misc +errsta equ 2 +bsybit equ 8 + +**************************************************** +bootdrv equ 0 +**************************************************** + + mod eom,name,tylg,atrv,start,size + +* Data equates; subroutines must keep data in stack +v$cmd rmb 1 +v$addr0 rmb 1 +v$addr1 rmb 2 +v$blks rmb 1 +v$opts rmb 1 +v$error rmb 4 + +blockloc rmb 2 pointer to memory requested +blockimg rmb 2 duplicate of the above +bootloc rmb 3 sector pointer; not byte pointer +bootsize rmb 2 size in bytes +size equ . + +name fcs /Boot/ + fcb edition + +start clra + ldb #size +clean pshs a + decb + bne clean + tfr s,u get pointer to data area + pshs u save pointer to data area + + lda #$d0 forced interrupt; kill floppy activity + sta $FF48 command register + clrb +pause decb + bne pause + lda $FF48 clear controller + clr $FF40 make sure motors are turned off + sta $FFD9 fast clock + +* Recalibrate hard drive + lbsr restore + +* Request memory for LSN0 + ldd #1 + os9 F$SRqMem request one page of RAM + bcs error + bsr getpntr + +* Get LSN0 into memory + clrb MSB sector + ldx #0 LSW sector + bsr mread + bcs error + ldd bootsize,u + beq error + pshs d + +* Return memory + ldd #$100 + ldu blockloc,u + os9 F$SRtMem + puls d + os9 F$BtMem + bcs error + bsr getpntr + std blockimg,u + +* Get os9boot into memory + ldd bootsize,u + leas -2,s same as a PSHS D +getboot std ,s + ldb bootloc,u MSB sector location + ldx bootloc+1,u LSW sector location + bsr mread + ldd bootloc+1,u update sector location by one to 24bit word + addd #1 + std bootloc+1,u + ldb bootloc,u + adcb #0 + stb bootloc,u + inc blockloc,u update memory pointer for upload + ldd ,s update size of file left to read + subd #$100 file read one sector at a time + bhi getboot + + leas 4+size,s reset the stack same as PULS U,D + ldd bootsize,u + ldx blockimg,u pointer to start of os9boot in memory + andcc #^Carry clear carry + rts back to os9p1 + +error leas 2+size,s + ldb #E$NotRdy drive not ready + rts + +getpntr tfr u,d save pointer to requested memory + ldu 2,s recover pointer to data stack + std blockloc,u + rts + +mread tstb + bne read10 + cmpx #0 + bne read10 + bsr read10 + bcc readlsn0 + rts + +readlsn0 pshs a,x,y + ldy blockloc,u + lda DD.Bt,y os9boot pointer + ldx DD.Bt+1,y LSW of 24 bit address + sta bootloc,u + stx bootloc+1,u + ldx DD.BSZ,y os9boot size in bytes + stx bootsize,u + clrb + puls a,x,y,pc + +* Generic read +read10 lda #c$rblk + bsr setup + bra command + +setup pshs b + sta v$cmd,u + stb v$addr0,u + stx v$addr1,u + ldb #1 + stb v$blks,u + clr v$opts,u + puls b,pc + +wakeup ldx #0 +wake lda status + bita #busy+sel + beq wake1 + leax -1,x + bne wake + bra wake4 +wake1 bsr wake3 + lda #1 + sta dataport + bsr wake3 + sta select + ldx #0 +wake2 lda status + bita #busy + bne wake3 + leax -1,x + bne wake2 +wake4 leas 2,s + comb + ldb #E$NotRdy +wake3 rts + +command bsr wakeup + leax v$cmd,u + bsr send + bsr waitrq + bita #cmd + bne getsta + ldx blockloc,u + bsr read +getsta bsr instat + bita #bsybit + bne command + bita #errsta + beq done + comb +done rts + +send bsr waitrq + bita #cmd + beq done + bita #inout + bne done + lda ,x+ + sta dataport + bra send + +waitrq pshs b,x +wait10 lda status + bita #req + beq wait10 + puls b,x,pc + +* Patch to allow booting from sector sizes > 256 bytes - BGP 08/16/97 +* We ignore any bytes beyond byte 256, but continue to read them from +* the dataport until the CMD bit is set. +read +* next 2 lines added + clrb +++ use B as counter +read2 + bsr waitrq + bita #cmd + bne done + lda dataport + sta ,x+ +* next line commented out and next 8 lines added +* bra read + incb +++ + bne read2 +++ +read3 + bsr waitrq +++ + bita #cmd +++ + bne done +++ + lda dataport +++ + bra read3 +++ + +instat bsr waitrq + lda dataport + anda #%00001111 + pshs a + bsr waitrq + clra + sta dataport + puls a,pc + +restore lda #c$rstr + clrb + ldx #0 + lbsr setup + clr v$blks,u + bra command + +* Fillers to get to $1D0 + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /99999999/ + + emod +eom equ * + end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdparty/booters/boot_rampak.asm Sat Apr 20 13:36:45 2002 +0000 @@ -0,0 +1,145 @@ +******************************************************************** +* Boot - Disto RAMPak boot module +* +* $Id$ +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* 5 Created ADK +* 6 Fixed small bugs, improved speed BGP 98/10/20 + + nam Boot + ttl Disto RAMPak boot module + +* Disassembled 94/06/25 11:37:47 by Alan DeKok + + ifp1 + use defsfile + endc + +tylg set Systm+Objct +atrv set ReEnt+rev +rev set $00 +edition set 6 + + mod eom,name,tylg,atrv,start,size + +* on-stack buffer to use + org 0 +size equ . + +name equ * + fcs /Boot/ + fcb edition + +start orcc #IntMasks ensure IRQ's are off. + + pshs x,d save 4 bytes of junk +R.D equ 1 +R.X equ 3 + + lda >MPI.Slct get current slot + pshs a save off + lda >PakSlot,pcr get multipak slot number + bmi cont if >127, invalid slot number + anda #$03 force it to be legal + ldb #$11 + mul put it into both nibbles + stb >MPI.Slct go to the desired slot + +cont ldd #$0001 request one byte (will round up to 1 page) + os9 F$SRqMem request the memory + bcs L00AE exit on error +* U is implicitely the buffer address to use + + ldx #$0000 X=0: got to sector #$0000 + bsr GetSect load in LSN0, and point Y to the buffer + bcs L00AE + + ldd <DD.BSZ,u size of the bootstrap file + std R.D,s save it on the stack (0,s is junk) + ldx <DD.BT+1,u get starting sector of the bootstrap file + + pshs x save the starting sector number + ldd #$0100 one page of memory + os9 F$SRtMem return the copy of LSN0 to free memory + + ldd R.X,s get size of boot memory to request + os9 F$BtMem ask for the boot memory + puls x restore the starting sector number + bcs L00AE no memory: exit with error + + stu R.X,s save start address of memory allocated + std R.D,s and the size of the boot memory + beq L00A7 if no memory allocated, exit + +SectLp pshs x,d save sector #, size of boot + bsr GetSect read one sector + bcs L00AC if there's an error, exit + puls x,d restor sector, size of boot + + leau $0100,u go up one page in memory + leax $01,x go to the next sector + subd #$0100 take out one sector, need value in B, too. + bhi SectLp loop until all sectors are read + +L00A7 puls a + sta >MPI.Slct + clrb clear carry + puls d return size of boot memory to user + bra L00B0 and go exit + +L00AC leas $04,s remove X,D off of stack +L00AE puls a + sta >MPI.Slct + leas $02,s kill D off of the stack + +L00B0 puls x restore start address of memory allocated +* leas size,s remove the on-stack buffer + clr >$FF40 stop the disk +L00BA rts + +* GetSect: read a sector off of the disk +* Entry: X = sector number to read +GetSect pshs d,x,y + ldy >Address,pcr grab the device address + tfr x,d move 16 bit LSN into 2 8-bit registers + sta 2,y save HB LSN + stb 1,y save LB LSN + leax ,u get buffer address to write into + clrb and start out at byte zero + +ReadLp stb ,y save byte number + lda 3,y grab the byte + sta ,x+ save in the buffer + incb go to the enxt byte + bne ReadLp + clrb no errors + puls d,x,y,pc restore registers and return + + fcc / JABBERWOCKY. / + fcb $0D + fcc /'Twas brillig, and the slithy toves/ + fcb $0D + fcc / Did gyre and gimble in the wabe:/ + fcb $0D + fcc /All mimsy were the borogroves,/ + fcb $0D + fcc / And the mome raths outgrabe./ + fcb $0D + fcb $0D + fcc /"Beware the Jabberwock, my son!/ + fcb $0D + fcc / The jaws that bite, the claws that catch!/ + fcb $0D + fcc /Beware the Jubjub bird, and shun/ + fcb $0D + fcc / The frumious Bandersnatch"/ + fcb $0D + +Address fdb $FF40 address of the device to boot from +PakSlot fcb $01 multipak slot number + + emod +eom equ * + end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdparty/booters/boot_rom.asm Sat Apr 20 13:36:45 2002 +0000 @@ -0,0 +1,159 @@ +******************************************************************** +* Boot - OS-9 Level Two ROM Boot module +* +* $Id$ +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* 1 Created BGP 98/??/?? + + nam Boot + ttl OS-9 Level Two ROM Boot module + + ifp1 + use defsfile + endc + +tylg set Systm+Objct +atrv set ReEnt+rev +rev set $01 +edition set 1 + + mod eom,name,tylg,atrv,start,size + +size equ . + +name fcs /Boot/ + fcb edition + +start equ * +* obtain bootfile size at known offset + pshs u,y,x,a,b,cc + orcc #IntMasks mask interrupts + +* allocate memory from system +* memory will start at $8000, blocks 1, 2, 3 and 3F +* we allocate $100 bytes more so that the memory will start +* exactly at $8000 + ldd #$8000-$1300 + os9 F$BtMem + bcs Uhoh + + stu 3,s save pointer in X on stack + std 1,s save size in D on stack + +* TRICK! Map block 4 into $4000, copy our special ROM copy code +* there, then jmp to it! + lda $FFA2 + pshs a + lda #$04 + sta $FFA2 + ldd #RelCodeL code less than 256 bytes + leax RelCode,pcr + ldy #$4800 +Copy lda ,x+ + sta ,y+ + decb + bne Copy + +Jump jsr $4800 * jump to rel code + puls a restore original block at $4000 + sta $FFA2 + +* Upon exit, we return to the kernel with: +* X = address of bootfile +* D = size of bootfile +* CC = carry cleared +ExitOK andcc #^Carry clear carry +Uhoh puls u,y,x,a,b,cc,pc + + +* this code executes at $4800 +RelCode equ * + lda #$4E CC3 mode, MMU, 32K ROM + sta $FF90 + sta $FFDE ROM/RAM mode + +* Map ROM Blocks in + ldd #$3C3D + std $FFA4 + lda #$3E + sta $FFA6 + +* Map block 1 at $6000 + lda $FFA3 + pshs a + lda #$01 + sta $FFA3 +* Copy first 8K of ROM + ldx #$8000 + ldy #$6000 +Loop1 ldd ,x++ + std ,y++ + cmpx #$A000 + blt Loop1 + +* Map block 2 at $6000 + lda #$02 + sta $FFA3 +* Copy second 8K of ROM + ldx #$A000 + ldy #$6000 +Loop2 ldd ,x++ + std ,y++ + cmpx #$C000 + blt Loop2 + +* Map block 3 at $6000 + lda #$03 + sta $FFA3 +* Copy third 8K of ROM + ldx #$C000 + ldy #$6000 +Loop3 ldd ,x++ + std ,y++ + cmpx #$E000 + blt Loop3 + +* Copy remaining ROM area ($8000-$1400) + lda #$3F + sta $FFA3 + ldx #$E000 + ldy #$6000 +Loop4 clr $FFDE put in ROM/RAM mode to get byte + ldd ,x++ + clr $FFDF put back in RAM mode to store byte + std ,y++ + cmpx #$EC00 + blt Loop4 +* ldx #$6000 +* ldy #$E000 +*Loop5 ldd ,x++ +* std ,y++ +* cmpx #$6C00 +* blt Loop5 + + lda D.HINIT restore GIME HINIT value + sta $FF90 + puls a restore org block at $6000 + sta $FFA3 + lda #$03 + sta $FFA6 + ldd #$0102 + std $FFA4 + rts + +RelCodeL equ *-RelCode + +* Fillers to get to $1D0 + fcc /99999999999999999999999999999999999999999999999999/ +* fcc /99999999999999999999999999999999999999999999999999/ +* fcc /99999999999999999999999999999999999999999999999999/ + fcc /99999999999999999999999999999999999999999999999999/ + fcc /99999999999999999999999999999999999999999999999999/ + fcc /99999999999999999999999999999999999999999999999999/ + fcc /999999999999999999999999999999999999999999999999999/ + + emod +eom equ * + end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdparty/booters/boot_tc3.asm Sat Apr 20 13:36:45 2002 +0000 @@ -0,0 +1,296 @@ +******************************************************************** +* Boot - Cloud-9 TC3 Boot module +* +* $Id$ +* +* This module allows booting from a hard drive that uses RGB-DOS +* and is controlled by a Cloud-9 TC3 SCSI controller. +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* 1 Original Roger Krupski distribution version +* 1b Added code to allow booting from any sector BGP 96/??/?? +* size hard drive + + + nam Boot + ttl Cloud-9 TC3 Boot module + + ifp1 + use defsfile + endc + +tylg set Systm+Objct +atrv set ReEnt+rev +rev set 2 +edition set 1 + +* Hard Disk Interface registers for the TC3 +dataport equ $FF76 +status equ dataport+1 +select equ dataport+1 + +* Status register equates +req equ 1 +busy equ 2 +msg equ 4 +cmd equ 8 +inout equ $10 +ack equ $20 +sel equ $40 +rst equ $80 + +*SCSI common command set +c$rstr equ 1 +c$rdet equ 3 +c$rblk equ 8 +c$wblk equ 10 + +* Optional command +c$ststop equ $1b park head + +* misc +errsta equ 2 +bsybit equ 8 + +**************************************************** +bootdrv equ 0 +**************************************************** + + mod eom,name,tylg,atrv,start,size + +* Data equates; subroutines must keep data in stack +v$cmd rmb 1 +v$addr0 rmb 1 +v$addr1 rmb 2 +v$blks rmb 1 +v$opts rmb 1 +v$error rmb 4 + +blockloc rmb 2 pointer to memory requested +blockimg rmb 2 duplicate of the above +bootloc rmb 3 sector pointer; not byte pointer +bootsize rmb 2 size in bytes +size equ . + +name fcs /Boot/ + fcb edition + +start clra + ldb #size +clean pshs a + decb + bne clean + tfr s,u get pointer to data area + pshs u save pointer to data area + + lda #$d0 forced interrupt; kill floppy activity + sta $FF48 command register + clrb +pause decb + bne pause + lda $FF48 clear controller + clr $FF40 make sure motors are turned off + sta $FFD9 fast clock + +* Recalibrate hard drive + lbsr restore + +* Request memory for LSN0 + ldd #1 + os9 F$SRqMem request one page of RAM + bcs error + bsr getpntr + +* Get LSN0 into memory + clrb MSB sector + ldx #0 LSW sector + bsr mread + bcs error + ldd bootsize,u + beq error + pshs d + +* Return memory + ldd #$100 + ldu blockloc,u + os9 F$SRtMem + puls d + os9 F$BtMem + bcs error + bsr getpntr + std blockimg,u + +* Get os9boot into memory + ldd bootsize,u + leas -2,s same as a PSHS D +getboot std ,s + ldb bootloc,u MSB sector location + ldx bootloc+1,u LSW sector location + bsr mread + ldd bootloc+1,u update sector location by one to 24bit word + addd #1 + std bootloc+1,u + ldb bootloc,u + adcb #0 + stb bootloc,u + inc blockloc,u update memory pointer for upload + ldd ,s update size of file left to read + subd #$100 file read one sector at a time + bhi getboot + + leas 4+size,s reset the stack same as PULS U,D + ldd bootsize,u + ldx blockimg,u pointer to start of os9boot in memory + andcc #^Carry clear carry + rts back to os9p1 + +error leas 2+size,s + ldb #E$NotRdy drive not ready + rts + +getpntr tfr u,d save pointer to requested memory + ldu 2,s recover pointer to data stack + std blockloc,u + rts + +mread tstb + bne read10 + cmpx #0 + bne read10 + bsr read10 + bcc readlsn0 + rts + +readlsn0 pshs a,x,y + ldy blockloc,u + lda DD.Bt,y os9boot pointer + ldx DD.Bt+1,y LSW of 24 bit address + sta bootloc,u + stx bootloc+1,u + ldx DD.BSZ,y os9boot size in bytes + stx bootsize,u + clrb + puls a,x,y,pc + +* Generic read +read10 lda #c$rblk + bsr setup + bra command + +setup pshs b + sta v$cmd,u + stb v$addr0,u + stx v$addr1,u + ldb #1 + stb v$blks,u + clr v$opts,u + puls b,pc + +wakeup ldx #0 +wake lda status + bita #busy+sel + beq wake1 + leax -1,x + bne wake + bra wake4 +wake1 bsr wake3 + lda #1 SCSI ID! + sta dataport + bsr wake3 + sta select + ldx #0 +wake2 lda status + bita #busy + bne wake3 + leax -1,x + bne wake2 +wake4 leas 2,s + comb + ldb #E$NotRdy +wake3 rts + +command bsr wakeup + leax v$cmd,u + bsr send + bsr waitrq + bita #cmd + bne getsta + ldx blockloc,u + bsr read +getsta bsr instat + bita #bsybit + bne command + bita #errsta + beq done + comb +done rts + +send bsr waitrq + bita #cmd + beq done + bita #inout + bne done + lda ,x+ + sta dataport + bra send + +waitrq pshs b,x +wait10 lda status + bita #req + beq wait10 + puls b,x,pc + +* Patch to allow booting from sector sizes > 256 bytes - BGP 08/16/97 +* We ignore any bytes beyond byte 256, but continue to read them from +* the dataport until the CMD bit is set. +read +* next 2 lines added + clrb +++ use B as counter +read2 + bsr waitrq + bita #cmd + bne done + lda dataport + sta ,x+ +* next line commented out and next 8 lines added +* bra read + incb +++ + bne read2 +++ +read3 + bsr waitrq +++ + bita #cmd +++ + bne done +++ + lda dataport +++ + bra read3 +++ + +instat bsr waitrq + lda dataport + anda #%00001111 + pshs a + bsr waitrq + clra + sta dataport + puls a,pc + +restore lda #c$rstr + clrb + ldx #0 + lbsr setup + clr v$blks,u + bra command + +* Fillers to get to $1D0 + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /9999999999/ + fcc /99999999/ + + emod + +eom equ *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdparty/booters/boot_wd1002.asm Sat Apr 20 13:36:45 2002 +0000 @@ -0,0 +1,335 @@ +******************************************************************** +* Boot - WD1002-05 boot module +* +* $Id$ +* +* WD 1002-05 OS-9 Boot Subroutine (called by OS9p1) +* Copyright 1988, 1989 Bruce Isted +* All Rights Reserved +* +* Ed. Comments Who YY/MM/DD +* ------------------------------------------------------------------ +* 2 Created by Bruce Isted BRI ??/??/?? + + nam Boot + ttl WD1002-05 boot module + +* These equates should be set before assembly: +FDStep equ $09 see Step Rate Table +HDStep equ $0F see step rate table + +*Step Rate Table: +*+------------------+------------------+------------------+------------------+ +*! Value=FD/HD Rate ! Value=FD/HD Rate ! Value=FD/HD Rate ! Value=FD/HD Rate ! +*+------------------+------------------+------------------+------------------+ +*! $00=40mS/7.5mS ! $04=16mS/5.5mS ! $08=08mS/3.5mS ! $0C=03mS/1.5mS ! +*! $01=25mS/7.0mS ! $05=14mS/5.0mS ! $09=06mS/3.0mS ! $0D=02mS/1.0mS ! +*! $02=20mS/6.5mS ! $06=12mS/4.5mS ! $0A=05mS/2.5mS ! $0E=01mS/0.5mS ! +*! $03=18mS/6.0mS ! $07=10mS/4.0mS ! $0B=04mS/2.0mS ! $0F=15uS/ 35uS ! +*+------------------+------------------+------------------+------------------+ + + ifp1 + use defsfile + endc + +* These equates should not have to be changed: +BEdtn equ 2 +BVrsn equ 1 +MaxCyls equ 1024 maximum cylinders supported +MaxHeads equ 16 maximum heads supported +MaxSctrs equ 64 maximum sectors per track supported +PhysDrv0 equ %10000000 SDH register mask for HD0 +PhysDrv1 equ %10001000 SDH register mask for HD1 +PhysDrv2 equ %10010000 SDH register mask for HD2 +PhysDrv3 equ %00011000 SDH register mask for FD0 +PhysDrv4 equ %00011010 SDH register mask for FD1 +PhysDrv5 equ %00011100 SDH register mask for FD2 +PhysDrv6 equ %00011110 SDH register mask for FD3 +ReadSctr equ %00100000 read sector command +Restore equ %00010000 base restore command +SelfTest equ %10010000 WD 1002-05 diagnostic test command + +* HCA memory map: + org 0 +WDData rmb 2 WD 1002-05 sector buffer/task files + rmb 2 reserved - do not use +PA equ . PIA PA offset +DDRA rmb 1 PIA DDRA offset +CRA rmb 1 PIA CRA offset +PB equ . PIA PB offset +DDRB rmb 1 PIA DDRB offset +CRB rmb 1 PIA CRB offset + +* WD 1002-05 register definitions: + org 0 +WDBuff rmb 1 WD 1002-05 sector buffer address +ErrReg equ . error register address (read) +WPCReg rmb 1 write precomp register address (write) +SctrCnt rmb 1 sector count register address +SctrReg rmb 1 sector number register address +CylLow rmb 1 cylinder LSB register address +CylHigh rmb 1 cylinder MSB register address +SDHReg rmb 1 Size/Drive/Head register address +StatReg equ . status register address (read) +CmdReg rmb 1 command register address (write) + + org 0 +U.BSZ rmb 2 boot file size +U.BSct rmb 1 number of sectors in boot file +U.BT rmb 3 boot file start LSN +U.BtStrt rmb 2 boot file start address +U.CrtCyl rmb 2 current cylinder number +U.CrtSct rmb 1 current sector number +U.CrtSid rmb 1 current side (head) number +U.Restor rmb 1 restore command incl. step rate code +U.SDH rmb 1 base WD Size/Drive/Head register copy +U.Sides rmb 1 number of disk sides (heads) +U.SPC rmb 2 sectors per cylinder +U.SPT rmb 2 sectors per track +U.StSctr rmb 1 start sector number (HD=0, FD=1) +BootMem equ . + + mod BEnd,BNam,Systm+Objct,ReEnt+BVrsn,BExec,$00 +BNam fcs "Boot" + fcb BEdtn edition number + +* base SDH register table +SDHTable equ * + fcb PhysDrv0,PhysDrv1,PhysDrv2 base SDH for hard drives + fcb PhysDrv3,PhysDrv4,PhysDrv5,PhysDrv6 base SDH for floppys +*** +* Boot subroutine module +* +* INPUT: none +* +* OUTPUT: [D]=size of bootstrap file +* [X]=start address of bootstrap file in memory +* y,u registers altered +* +* ERROR OUTPUT: [CC]=carry set +* [B]=error code +BExec ldy <D.WDAddr get HCA base address (set by auto-boot EPROM) + cmpy #$FF40 base address too low? + blo UnitErr yes, go report error... + cmpy #$FF7F base address too high? + bhi UnitErr yes, go report error... + lda <D.WDBtDr get boot drive number (set by auto-boot EPROM + cmpa #$07 legal drive number? + blo InitPIA yes, go initialize PIA... +UnitErr ldb #E$Unit + coma + rts + +DumpRead clr PB,y set WD address to sector buffer +DumpR0 lda WDData,y get a byte from WD sector buffer + decb done yet? + bne DumpR0 no, go dump another byte + rts +LSN0Info ldb #DD.FMT load number of bytes to dump + bsr DumpRead go dump LSN0 up to DD.FMT + lda WDData,y get DD.FMT (disk density, sides) + anda #$01 mask out all but disk sides bit + inca correction to bit coding + sta U.Sides,u save disk sides (not valid if HD > 2 heads) + ldd WDData,y get DD.SPT (sectors per track) + std U.SPT,u + ldb #DD.BT-DD.RES load number of bytes to dump + bsr DumpRead go dump LSN0 from DD.RES to DD.BT + lda WDData,y get DD.BT (boot file start LSN) MSB + sta U.BT,u + ldd WDData,y get DD.BT (boot file start LSN) LSBs + std U.BT+1,u + ldd WDData,y get DD.BSZ (boot file size) + std U.BSZ,u + ldb U.StSctr,u floppy drive? (start sector = 1) + bne GotInfo yes, sides info OK, go return + ldb #DD.OPT+(PD.SID-PD.OPT)-DD.DAT load number of bytes to dump + bsr DumpRead go dump LSN0 from DD.DAT to number of sides in option table + lda WDData,y get number of sides from DD.OPT section + sta U.Sides,u +GotInfo rts + +InitPIA clr CRA,y enable PIA DDRA + ldd #$033E [A]=DDRA: PA bits 7-2 = inputs, bits 1-0 = outputs + std DDRA,y [B]=CRA: PIA CA2 out high, PA slct, CA1 low to high, no IRQs + clr CRB,y enable PIA DDRB + lda #$FF [A]=DDRB: PB bits 7-0 all outputs + std DDRB,y [B]=CRB: PIA CB2 out high, PB slct, CB1 low to high, no IRQs + leas -BootMem,s open up some space for variables + leau ,s point [U] to start of variables + ldb #BootMem number of bytes to clear + leax ,u point [X] to start of variables +ClrLoop clr ,x+ initialize a byte to 0 + decb done yet? + bne ClrLoop no, go clear another byte + lda #SelfTest WD 1002-05 internal diagnostic command + lbsr CmdUpdat go issue WD command, ensure everything is ready... + bcs ReadErr error, go report it... + lda #Restore!($0F&^HDStep) default to Restore with HD step rate + ldb <D.WDBtDr get boot drive number + cmpb #$03 hard drive? + blo SaveRstr yes, go save HD Restore command... + inc U.StSctr,u set start sector to 1 for floppy disks + lda #Restore!($0F&^FDStep) get Restore with FD step rate +SaveRstr sta U.Restor,u + leax SDHTable,pc + lda b,x get base SDH register + sta U.SDH,u save it... +* restore head to track 0 + lbsr SetupTF go update WD task files (except command) + lda U.Restor,u load WD restore command code + lbsr CmdUpdat go issue WD command + bcs ReadErr error, go report it... +* read cylinder 0, head 0, first sector + lbsr GetSctr go set up, issue read command + bcs ReadErr error, go report it... + bsr LSN0Info go get disk info from LSN0 + ldd U.BSZ,u get boot file size/cylinder offset number + bne ChkInfo must be boot file size, go check other LSN0 info... + ldd U.BT+1,u get offset cylinder number + beq ReadErr must not be boot disk, go report error... + cmpd #MaxCyls offset cylinder number OK? + bhs ReadErr no, go return error... + std U.CrtCyl,u save offset cylinder +* read offset cylinder, head 0, first sector + lbsr GetSctr go set up, issue read command + bcs ReadErr error, go exit... + lbsr LSN0Info go get disk info from offset LSN0 + ldd U.BSZ,u get boot file size + beq ReadErr must not be boot disk, go report error... +* check LSN0 info +ChkInfo ldd U.SPT,u get sectors per track + beq ReadErr 0 sectors per track, go return error + cmpd #MaxSctrs sectors per track OK? + bhi ReadErr no, go return error + lda U.Sides,u get disk sides (heads) + beq ReadErr 0 sides, go return error + cmpa #MaxHeads number of heads OK? + bhi ReadErr no, go return error + mul calculate sectors per cylinder + std U.SPC,u save sectors per cylinder + ldd U.BSZ,u get boot file size + addd #$00FF round up to even sector... + sta U.BSct,u save number of sectors in boot file +* calculate boot file start cylinder, head, & sector + ldd U.BT+1,u get boot file LSN LSBs + ldx U.CrtCyl,u get current (offset) cylinder number +CylLoop subd U.SPC,u subtract sectors/cylinder + blo ChkBtMSB [D] underflow, go check boot file LSN MSB +CylLoop0 leax 1,x increment current cylinder number + bne CylLoop no overflow, go do another subtraction +ReadErr ldb #E$Read + coma set Carry for error + leas BootMem,s restore stack pointer + rts +ChkBtMSB tst U.BT,u boot file LSN MSB = 0? + beq GotCyl yes, go determine head number + dec U.BT,u decrement boot file LSN MSB + bra CylLoop0 go on... +GotCyl addd U.SPC,u restore sector number + stx U.CrtCyl,u save current cylinder number +TrkLoop subd U.SPT,u subtract sectors/track + blo GotSide [D] underflow, go save current sector number + inc U.CrtSid,u increment current side number + bra TrkLoop go do another subtraction +GotSide addd U.SPT,u restore sector number + stb U.CrtSct,u save it +* request boot file memory + pshs u save data pointer + ldd U.BSZ,u get boot file size + os9 F$SRqMem + tfr u,x move start address into [X] + puls u recover data pointer + bcs BtExit0 go return F$SRqMem error + stx U.BtStrt,u save boot file start address + ldd U.CrtCyl,u get cylinder number + bra ChkCyl go check cylinder & get first sector + +* load boot file into memory +BootLoad inc U.CrtSct,u move on to next sector + lda U.SPT+1,u get sectors per track LSB (MSB is always 0) + cmpa U.CrtSct,u done track? + bhi LoadSctr no, go get sector + clr U.CrtSct,u reset current sector number to 0 + inc U.CrtSid,u move on to next side + lda U.CrtSid,u get side number + cmpa U.Sides,u done cylinder? + blo LoadSctr no, go get sector + clr U.CrtSid,u reset side number to 0 + ldd U.CrtCyl,u get cylinder number + addd #1 move on to next cylinder + std U.CrtCyl,u save cylinder number +ChkCyl cmpd #MaxCyls cylinder number OK? + bhs ReadErr no, go return error +LoadSctr bsr GetSctr go get current sector from WD 1002-05 + bcs ReadErr error, go exit + clrb transfer 256 bytes + stb PB,y set WD sector buffer address +ReadLoop lda WDData,y get byte from WD 1002-05 + sta ,x+ save byte to buffer + decb done yet? + bne ReadLoop no, go get another byte + dec U.BSct,u count down boot file sectors remaining + bne BootLoad + clrb clear carry + ldd U.BSZ,u get boot file size + ldx U.BtStrt,u get boot file start address +BtExit0 leas BootMem,s restore stack pointer + rts + +GetSctr bsr SetupTF go set up WD task files (except command) + lda #ReadSctr load WD read sector command code +CmdUpdat ldb #CmdReg load WD command register address + bsr TFUpdat go issue command... +BusyWait ldb #StatReg + stb PB,y set WD status register address +BusyW0 ldb WDData,y get WD 1002-05 status + bitb #%00000010 valid data? (WD 1002-05 powered & connected?) + bne BWErr no, go report error... + tstb ensure [CC] sign flag is current + bmi BusyW0 yes, go check again + ldb WDData,y get valid controller status + rorb rotate error bit into carry + bcc NoError + ldb #ErrReg + stb PB,y set WD error register address + ldb WDData,y get error register contents + bne BWErr +NoError clrb + rts +BWErr comb error, set [CC] Carry... + rts + +SetupTF ldd #$01*256+SctrCnt single sector commands only + bsr TFUpdat + lda U.CrtCyl,u get current cylinder number MSB + ldb #CylHigh + bsr TFUpdat + lda U.CrtCyl+1,u get current cylinder number LSB + ldb #CylLow + bsr TFUpdat + lda U.CrtSct,u get current sector number + adda U.StSctr,u add offset... + ldb #SctrReg + bsr TFUpdat + clrb default extended head disabled + lda U.CrtSid,u get current side (head) number + cmpa #$08 extended head? + blo StdHead no, go on... + incb set enable code + anda #$07 mask out all but standard head number +StdHead stb PA,y set extended head enable/disable + ora U.SDH,u mask in base SDH copy + ldb #SDHReg +TfUpdat stb PB,y set WD register address + sta WDData,y write data to WD 1002-05 + rts + +* pad Boot module out to $01D0 exactly + fcb $39,$39,$39,$39,$39,$39,$39,$39 + fcb $39,$39,$39,$39,$39,$39,$39,$39 + + emod +BEnd equ * + end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdparty/booters/defsfile Sat Apr 20 13:36:45 2002 +0000 @@ -0,0 +1,4 @@ +Level equ 2 + use os9defs + use rbfdefs + use systype.l2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdparty/booters/makefile Sat Apr 20 13:36:45 2002 +0000 @@ -0,0 +1,12 @@ +include ../../Makefile.rules + +DEPENDS = ./Makefile +BOOTERS = boot_kenton boot_rampak boot_ide boot_tc3 boot_wd1002 \ + boot_rom +ALLOBJS = $(BOOTERS) + +all: $(ALLOBJS) $(DEPENDS) + +clean: + $(RM) $(ALLOBJS) +