Mercurial > hg > Members > kono > nitros9-code
changeset 1882:c96f594fe098
Added fragmented boot support... needs additional testing.
author | boisy |
---|---|
date | Tue, 11 Oct 2005 11:10:25 +0000 |
parents | a9154d83aff9 |
children | 4a1da412e363 |
files | level1/modules/boot_1773.asm |
diffstat | 1 files changed, 190 insertions(+), 123 deletions(-) [+] |
line wrap: on
line diff
--- a/level1/modules/boot_1773.asm Wed Sep 21 11:09:41 2005 +0000 +++ b/level1/modules/boot_1773.asm Tue Oct 11 11:10:25 2005 +0000 @@ -22,6 +22,9 @@ * * 6r4 2004/02/17 Rodney Hamilton * Minor optimizations, improvements in source comments +* +* 7 2005/10/10 Boisy G. Pitre +* Added fragmented bootfile support nam Boot ttl WD1773 Boot module @@ -72,18 +75,20 @@ tylg set Systm+Objct atrv set ReEnt+rev -rev set $04 -edition set 6 +rev set $00 +edition set 7 mod eom,name,tylg,atrv,start,size * NOTE: these are U-stack offsets, not DP +seglist rmb 2 pointer to segment list +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 drvsel rmb 1 -buffptr rmb 2 currtrak rmb 1 -*ddfmt rmb 1 ddtks rmb 1 no. of sectors per track -*ddtot rmb 1 dblsided rmb 1 side rmb 1 side 2 flag size equ . @@ -91,32 +96,156 @@ name fcs /Boot/ fcb edition -start clra clear A - ldb #size get our 'stack' size -MakeStak pshs a save 0 on stack - decb and continue... - bne MakeStak until we've created our stack +start orcc #IntMasks ensure IRQs are off (necessary?) + leas -size,s + tfr s,u get pointer to data area + pshs u save pointer to data area + +* Device Specific Init + lbsr HWInit +* bcs error2 + +* Request memory for LSN0 + ldd #256 get sector/fd buffer + os9 F$SRqMem get it! + bcs error2 + bsr getpntr restore U to point to our statics + +* Read LSN0 + clrb MSB sector + ldx #0 LSW sector + lbsr HWRead read LSN 0 + bcs error branch if error + + ifgt Level-1 + lda #'0 --- loaded in LSN0' + jsr <D.BtBug --- + endc + +* Pull relevant values from LSN0 + lda DD.TKS,x number of tracks on this disk + sta ddtks,u + lda DD.FMT,x disk format byte + sta dblsided,u + lda DD.BT,x os9boot pointer + sta bootloc,u + ldd DD.BT+1,x LSW of 24 bit address + std bootloc+1,u + ldd DD.BSZ,x os9boot size in bytes + std bootsize,u + beq FragBoot if zero, do frag boot +* Old style boot -- make a fake FD segment + leax FD.SEG,x + addd #$00FF round up to next page + exg a,b + std FDSL.B,x save file size + lda bootloc,u + sta FDSL.A,x + ldd bootloc+1,u + std FDSL.A+1,x save LSN of file (contiguous) + clr FDSL.S,x make next segment entry 0 + clr FDSL.S+1,x + clr FDSL.S+2,x + ldd bootsize,u + bra GrabBootMem + +Back2Krn ldx blockimg,u pointer to start of os9boot in memory + clrb clear carry + ldd bootsize,u +error2 leas 2+size,s reset the stack same as PULS U + rts return to kernel + +* Error point - return allocated memory and then return to kernel +error +* Return memory allocated for sector buffers + ldd #256 + ldu blockloc,u + os9 F$SRtMem + bra error2 + +* Routine to save off alloced mem from F$SRqMem into blockloc,u and restore +* the statics pointer in U +getpntr tfr u,d save pointer to requested memory + ldu 2,s recover pointer to data stack + std blockloc,u +ret rts + +* NEW! Fragmented boot support! +FragBoot ldb bootloc,u MSB fd sector location + ldx bootloc+1,u LSW fd sector location + lbsr HWRead get fd sector + ldd FD.SIZ+2,x get file size (we skip first two bytes) + std bootsize,u + leax FD.SEG,x point to segment table + +GrabBootMem + ifgt Level-1 + os9 F$BtMem + else + os9 F$SRqMem + endc + bcs error + bsr getpntr + std blockimg,u + +* Get os9boot into memory +BootLoop stx seglist,u update segment list + ldb FDSL.A,x MSB sector location +BL2 ldx FDSL.A+1,x LSW sector location + bne BL3 + tstb + beq Back2Krn +BL3 lbsr HWRead + inc blockloc,u point to next input sector in mem + + ifgt Level-1 + lda #'. Show .' + jsr <D.BtBug + endc + + ldx seglist,u get pointer to segment list + dec FDSL.B+1,x get segment size + beq NextSeg if <=0, get next segment + + ldd FDSL.A+1,x update sector location by one to 24bit word + addd #1 + std FDSL.A+1,x + ldb FDSL.A,x + adcb #0 + stb FDSL.A,x + bra BL2 + +NextSeg leax FDSL.S,x advance to next segment entry + bra BootLoop + - tfr s,u put 'stack statics' in U -* ldx #DPort - lda #%11010000 ($D0) Force Interrupt (stops any command in progress) - sta >DPort+CMDREG write command to command register -* sta CMDREG,x write command to command register - lbsr Delay2 delay 54~ - lda >DPort+STATREG clear status register -* lda STATREG,x read status register + +************************************************************ +************************************************************ +* Hardware-Specific Booter Area * +************************************************************ +************************************************************ + +* Device Specific Init +* HWInit - Initialize the device +HWInit + ldy Address,pcr get hardware address + lda #%11010000 ($D0) Force Interrupt (stops any command in progress) + sta CMDREG,y write command to command register + lbsr Delay2 delay 54~ + lda STATREG,y clear status register lda #$FF - sta currtrak,u set current track to 255 - leax >NMIRtn,pcr point to NMI routine + sta currtrak,u set current track to 255 + leax >NMIRtn,pcr point to NMI routine IFGT Level-1 - stx <D.NMI save address + stx <D.NMI save address ELSE - stx >D.XNMI+1 save address + stx >D.XNMI+1 save address lda #$7E sta >D.XNMI ENDC lda #MOTON+BootDr turn on drive motor - sta >DPort+CONTROL + sta CONTROL,y * MOTOR ON spin-up delay loop (~307 mSec) IFGT Level-1 @@ -136,80 +265,8 @@ ENDC subd #$0001 bne L003A - -* search for memory to use as a sector buffer - pshs u,y,x,b,a save regs - ldd #SECTSIZE get sector size in D - os9 F$SRqMem request that much memory - bcs L00AA branch if there is an error - tfr u,d move pointer to D temporarily - ldu $06,s restore U (saved earlier) - std buffptr,u save alloced mem pointer in statics - clrb - -* go get LSN0 - ldx #$0000 we want LSN0 - bsr ReadSect go get it - bcs L00AA branch if error + rts -* From LSN0, we get various pieces of info. -* ldd DD.TOT+1,y -* std ddtot,u - lda <DD.FMT,y get format byte of LSN0 -* sta ddfmt,u save it for ??? - anda #FMT.SIDE keep side bit - sta dblsided,u and save it - lda DD.TKS,y get sectors per track - sta ddtks,u and save - ldd <DD.BSZ,y get bootfile size - std ,s save on stack - ldx <DD.BT+1,y get start sector of bootfile - pshs x push on the stack - ldd #SECTSIZE load D with sector size - ldu buffptr,u and point to the buffer pointer - os9 F$SRtMem return the memory - ldd $02,s get the bootfile size - IFGT Level-1 - os9 F$BtMem - ELSE - os9 F$SRqMem get the memory from the system - ENDC - puls x pull bootfile start sector off stack - bcs L00AA branch if error - stu 2,s save pointer to bootfile mem on stack - stu 8+buffptr,s also save to buffptr,u - ldu 6,s reload original U -* ldd 2,s get pointer to bootfile mem -* std buffptr,u and save pointer - ldd ,s get bootfile size - beq L00A3 branch if zero - -* this loop reads a sector at a time from the bootfile -* X = start sector -* D = bootfile size -L0091 pshs x,b,a save params - clrb - bsr ReadSect read sector - bcs L00A8 branch if error - IFGT Level-1 - lda #'. dump out a period for boot debugging - jsr <D.BtBug do the debug stuff - ENDC - puls x,b,a restore params -* RVH NOTE: the next 3 lines assume sector size=256=LSN size? - inc buffptr,u point to next 256 bytes - leax 1,x move to next sector - subd #SECTSIZE subtract sector bytes from size - bhi L0091 continue if more space -L00A3 clrb - puls b,a - bra L00AC -L00A8 leas $04,s -L00AA leas $02,s -L00AC puls u,y,x - leas size,s clean up stack - clr >DPort+CONTROL shut off floppy disk - rts L00B7 lda #DDEN+MOTON+BootDr permit alternate drives sta drvsel,u save drive selection byte @@ -219,14 +276,20 @@ ldb #0+STEP RESTORE cmd lbra L0195 +* +* HWRead - Read a 256 byte sector from the device +* Entry: Y = hardware address +* B = bits 23-16 of LSN +* X = bits 15-0 of LSN +* blockloc,u = ptr to 256 byte sector +* Exit: X = ptr to data (i.e. ptr in blockloc,u) +* * Read a sector from the 1773 -* Entry: X = LSN to read -ReadSect lda #$91 - cmpx #$0000 LSN0? - bne L00DF branch if not +* Entry: B,X = LSN to read +HWRead lda #$91 bsr L00DF else branch subroutine bcs L00D6 branch if error - ldy buffptr,u get buffer pointer in Y for caller + ldx blockloc,u get buffer pointer in X for caller clrb L00D6 rts @@ -242,12 +305,12 @@ bne L00D7 L00EA bsr L013C bcs L00D6 if error, return to caller - ldx buffptr,u get address of buffer to fill + ldx blockloc,u get address of buffer to fill orcc #IntMasks mask interrupts - pshs y save Y - ldy #$FFFF + pshs x save X + ldx #$FFFF ldb #%10000000 ($80) READ SECTOR command - stb >DPort+CMDREG write to command register + stb CMDREG,y write to command register ldb drvsel,u (DDEN+MOTORON+BootDr) * NOTE: The 1773 FDC multiplexes the write precomp enable and ready * signals on the ENP/RDY pin, so the READY bit must always be ON for @@ -256,7 +319,7 @@ tst side,u are we on side 2? beq L0107 orb #SIDESEL set side 2 bit -L0107 stb >DPort+CONTROL +L0107 stb CONTROL,y lbsr Delay2 delay 54~ orb #HALTENA HALT enable ($80) * lda #%00000010 RESTORE cmd ($02) @@ -268,13 +331,14 @@ * sta >DPort+CONTROL * puls y * bra L0138 - stb >DPort+CONTROL + stb CONTROL,y nop nop - bra L0123 +* bra L0123 + ldx ,s get X saved earlier * Sector READ Loop -L0123 lda >DPort+DATAREG read from WD DATA register +L0123 lda DATAREG,y read from WD DATA register sta ,x+ * stb >DPort+CONTROL nop @@ -286,13 +350,13 @@ * use a polled I/O loop instead. NMIRtn leas R$Size,s adjust stack - puls y - ldb >DPort+STATREG read WD STATUS register - bitb #$9C any errors? + puls x + ldb STATREG,y read WD STATUS register + bitb #$9C any errors? * bitb #$04 LOST DATA bit set? beq RetOK branch if not * beq ChkErr branch if not -L0138 comb else we will return error +L0138 comb else we will return error ldb #E$Read RetOK rts @@ -302,7 +366,7 @@ tfr x,d cmpd #$0000 beq L016C - clr ,-s clear space on stack + clr ,-s clear space on stack tst dblsided,u double sided disk? beq L0162 branch if not bra L0158 @@ -318,16 +382,16 @@ L0162 subb ddtks,u sbca #$00 bcc L0160 -L0168 addb #18 add sectors per track - puls a get current track indicator off of stack +L0168 addb #18 add sectors per track + puls a get current track indicator off of stack L016C incb - stb >DPort+SECTREG save in sector register + stb SECTREG,y save in sector register L0170 ldb currtrak,u get current track in B - stb >DPort+TRACKREG save in track register + stb TRACKREG,y save in track register cmpa currtrak,u same as A? beq L018D branch if so sta currtrak,u - sta >DPort+DATAREG + sta DATAREG,y ldb #$10+STEP SEEK command bsr L0195 send command to controller pshs x @@ -345,15 +409,15 @@ * rts L0195 bsr L01A8 issue FDC cmd, wait 54~ -L0197 ldb >DPort+STATREG +L0197 ldb STATREG,y bitb #$01 still BUSY? bne L0197 loop until command completes rts * Entry: B = command byte L019F lda drvsel,u - sta >DPort+CONTROL - stb >DPort+CMDREG + sta CONTROL,y + stb CMDREG,y rts * issue command and wait 54 clocks @@ -383,9 +447,12 @@ IFGT Level-1 * Filler to get $1D0 -Filler fill $39,$1D0-3-* +Filler fill $39,$1D0-3-2-1-* ENDC +Address fdb DPort +WhichDrv fcb 0 + emod eom equ * end