Mercurial > hg > Members > kono > nitros9-code
changeset 1893:1827bb446188
Modified booters to use new boot strategy with boot_common.asm
author | boisy |
---|---|
date | Sat, 15 Oct 2005 15:32:45 +0000 |
parents | 77d83b367eba |
children | 6d5bd8549d28 |
files | level1/modules/boot_1773.asm level1/modules/boot_common.asm level1/modules/boot_rampak.asm |
diffstat | 3 files changed, 212 insertions(+), 196 deletions(-) [+] |
line wrap: on
line diff
--- a/level1/modules/boot_1773.asm Fri Oct 14 01:56:25 2005 +0000 +++ b/level1/modules/boot_1773.asm Sat Oct 15 15:32:45 2005 +0000 @@ -92,18 +92,15 @@ drvsel rmb 1 currtrak rmb 1 ddtks rmb 1 no. of sectors per track -dblsided rmb 1 +ddfmt rmb 1 side rmb 1 side 2 flag size equ . name fcs /Boot/ fcb edition -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 - +FLOPPY equ 1 + ************ START OF DEVICE-SPECIFIC INIT *********** * HWInit - Initialize the device HWInit @@ -147,127 +144,11 @@ * ENDC subd #$0001 4 cycles bne L003A 3 cycles +HWTerm rts ************ END OF DEVICE-SPECIFIC INIT *********** - -* 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 - beq FragBoot if zero, do frag boot - std bootsize,u -* Old style boot -- make a fake FD segment - leax FD.SEG,x - addd #$00FF round up to next page -* Important note: We are making an assumption that the upper 8 bits of the -* FDSL.B field will always be zero. That is a safe assumption, since an -* FDSL.B value of $00FF would mean the file is 65280 bytes. A bootfile -* under NitrOS-9 cannot be this large, and therefore this assumption -* is safe. - sta FDSL.B+1,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 + + use ../../6809l1/modules/boot_common.asm -* 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 - 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 - - - ************************************************************ ************************************************************ * Hardware-Specific Booter Area * @@ -276,7 +157,7 @@ DoDDns lda #DDEN+MOTON double density enable and motor on - ora WhichDrv,pcr OR in selected drive + ora WhichDrv,pcr OR in selected drive sta drvsel,u save drive selection byte clr currtrak,u clear current track lda #$05 @@ -376,7 +257,7 @@ cmpd #$0000 zero? beq L016C branch if so clr ,-s else clear space on stack - tst dblsided,u double sided disk? + tst ddfmt,u double sided disk? beq SnglSid branch if not bra DblSid * Double-sided code
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level1/modules/boot_common.asm Sat Oct 15 15:32:45 2005 +0000 @@ -0,0 +1,162 @@ +******************************************************************** +* Boot Common - Common code for NitrOS-9 booters +* +* $Id$ +* +* This common file is not a stand-alone module, but is 'used' by boot module +* source files to bring in support for booting from RBF file systems that have +* either standard or new-style fragmented bootfiles. +* +* This code uses several static variables which are expected to be defined in +* the main boot source code. See a booter like boot_1773.asm for an example on +* how to write a booter which uses this code. +* +* FLOPPY BOOTERS: Take note. Only the lower 16 bits of DD.BT are used, so +* in that case, we can save some code by ignoring the loading of B as well as +* loading bits 23-16 of DD.BT. Floppy booters should have the following +* line in their code to take advantage of this optimization: +* +* FLOPPY equ 1 +* +* Edt/Rev YYYY/MM/DD Modified by +* Comment +* ------------------------------------------------------------------ +* 1 2005/10/14 Boisy G. Pitre +* Created as a stand-alone file. + +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 + +* 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 + +* Initialize Hardware + lbsr HWInit + +* Read LSN0 + IFEQ FLOPPY + clrb MSB sector + ENDC + 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 + IFNE FLOPPY + lda DD.TKS,x number of tracks on this disk + sta ddtks,u + lda DD.FMT,x disk format byte + sta ddfmt,u + ELSE + lda DD.BT,x os9boot pointer + sta bootloc,u + ENDC + ldd DD.BT+1,x LSW of 24 bit address + std bootloc+1,u + ldd DD.BSZ,x os9boot size in bytes + beq FragBoot if zero, do frag boot + std bootsize,u +* Old style boot -- make a fake FD segment + leax FD.SEG,x + addd #$00FF round up to next page +* Important note: We are making an assumption that the upper 8 bits of the +* FDSL.B field will always be zero. That is a safe assumption, since an +* FDSL.B value of $00FF would mean the file is 65280 bytes. A bootfile +* under NitrOS-9 cannot be this large, and therefore this assumption +* is safe. + sta FDSL.B+1,x save file size + IFEQ FLOPPY + lda bootloc,u + sta FDSL.A,x + ENDC + 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 lbsr HWTerm call HW termination routine + 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 + 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 + IFEQ FLOPPY + ldb FDSL.A,x MSB sector location + ENDC +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 + IFEQ FLOPPY + ldb FDSL.A,x + adcb #0 + stb FDSL.A,x + ENDC + bra BL2 + +NextSeg leax FDSL.S,x advance to next segment entry + bra BootLoop
--- a/level1/modules/boot_rampak.asm Fri Oct 14 01:56:25 2005 +0000 +++ b/level1/modules/boot_rampak.asm Sat Oct 15 15:32:45 2005 +0000 @@ -11,6 +11,9 @@ * * 6 1998/10/20 Boisy G. Pitre * Fixed small bugs, improved speed. +* +* 7 2005/10/14 Boisy G. Pitre +* Now uses boot_common.asm for fragmented bootfile support. nam Boot ttl Disto RAMPak Boot Module @@ -24,109 +27,79 @@ tylg set Systm+Objct atrv set ReEnt+rev rev set $00 -edition set 6 +edition set 7 mod eom,name,tylg,atrv,start,size * on-stack buffer to use org 0 +mpisave rmb 1 +* common booter required static variables +ddtks rmb 1 +ddfmt rmb 1 +seglist rmb 2 +bootsize rmb 2 +bootloc rmb 2 +blockloc rmb 2 +blockimg rmb 2 size equ . name equ * fcs /Boot/ fcb edition -start orcc #IntMasks ensure IRQ's are off. + use ../../6809l1/modules/boot_common.asm - 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 +* HWInit +* +* Entry: None +* Exit: Y = base address of hardware +* Hardware has been initialized +HWInit lda >MPI.Slct get current slot + sta mpisave,u + ldy >Address,pcr grab the device address 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 +cont rts - 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 - IFGT Level-1 - os9 F$BtMem ask for the boot memory - ELSE - os9 F$SRqMem ask for the boot memory - ENDC - 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 +* HWTerm +* +* Entry: Y = base address of hardware +* Exit: Hardware has been deinitialized +HWTerm lda mpisave,u sta >MPI.Slct - clrb clear carry - puls d return size of boot memory to user - bra L00B0 and go exit + rts -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 >DPort 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 +* 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) +HWRead 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 + + ldx blockloc,u 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 + incb go to the next byte bne ReadLp + leax -256,x clrb no errors - puls d,x,y,pc restore registers and return + rts IFGT Level-1 -Pad fill $39,$1D0-6-* +Pad fill $39,$1D0-3-2-1-* ENDC Address fdb $FF40 address of the device to boot from