changeset 1894:6d5bd8549d28

More booter optimizations
author boisy
date Mon, 17 Oct 2005 12:37:49 +0000
parents 1827bb446188
children a783d16e58d5
files level1/makefile level1/modules/boot_1773.asm level1/modules/boot_common.asm level1/modules/boot_rampak.asm
diffstat 4 files changed, 74 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/level1/makefile	Sat Oct 15 15:32:45 2005 +0000
+++ b/level1/makefile	Mon Oct 17 12:37:49 2005 +0000
@@ -73,7 +73,7 @@
 $(DSK360K_1):
 	$(RM) $@
 	$(OS9FORMAT_DS40) -q $@ -n"NitrOS-9/6809 Level 1 Disk 1"
-	$(OS9GEN) $@ -b=$(BOOTFILE_CO51) -t=$(KERNELFILE)
+	$(OS9GEN) $@ -b=$(BOOTFILE_CO32) -t=$(KERNELFILE)
 	$(MAKDIR) $@,CMDS
 	$(MAKDIR) $@,SYS
 	$(CD) cmds; $(CP) $(CMDS) ../$@,CMDS
@@ -130,7 +130,7 @@
 $(DSK720K):
 	$(RM) $@
 	$(OS9FORMAT_DS80) -q $@ -n"NitrOS-9/6809 Level 1"
-	$(OS9GEN) $@ -b=$(BOOTFILE_CO51_DS80) -t=$(KERNELFILE)
+	$(OS9GEN) $@ -b=$(BOOTFILE_CO32_DS80) -t=$(KERNELFILE)
 	$(MAKDIR) $@,CMDS
 	$(MAKDIR) $@,SYS
 	$(MAKDIR) $@,DEFS
--- a/level1/modules/boot_1773.asm	Sat Oct 15 15:32:45 2005 +0000
+++ b/level1/modules/boot_1773.asm	Mon Oct 17 12:37:49 2005 +0000
@@ -87,10 +87,11 @@
 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
 currtrak rmb   1
+* Note, for optimization purposes, the following two variables
+* should be adjacent!!
 ddtks    rmb   1		no. of sectors per track
 ddfmt    rmb   1
 side     rmb   1		side 2 flag
@@ -99,12 +100,15 @@
 name     fcs   /Boot/
          fcb   edition
 
+* Common booter-required defines
+LSN24BIT equ   0
 FLOPPY   equ   1
 
-************ START OF DEVICE-SPECIFIC INIT ***********
 * HWInit - Initialize the device
+*   Entry: Y = hardware address
+*   Exit:  Carry Clear = OK, Set = Error
+*          B = error (Carry Set)
 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~
@@ -144,17 +148,16 @@
 *         ENDC
          subd  #$0001    4 cycles
          bne   L003A     3 cycles
-HWTerm   rts
-************ END OF DEVICE-SPECIFIC INIT ***********
+* HWTerm - Terminate the device
+*   Entry: Y = hardware address
+*   Exit:  Carry Clear = OK, Set = Error
+*          B = error (Carry Set)
+HWTerm   clrb
+         rts
+
 
          use   ../../6809l1/modules/boot_common.asm
                          
-************************************************************
-************************************************************
-*              Hardware-Specific Booter Area               *
-************************************************************
-************************************************************
-
 
 DoDDns   lda   #DDEN+MOTON		double density enable and motor on
          ora   WhichDrv,pcr		OR in selected drive
@@ -165,16 +168,12 @@
          ldb   #0+STEP			RESTORE cmd
          lbra  Talk2FDC			send command and wait for it to complete
 
-*
 * 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: B,X = LSN to read
 HWRead   lda   #$91
          bsr   L00DF		else branch subroutine
          bcs   HWRRts		branch if error
--- a/level1/modules/boot_common.asm	Sat Oct 15 15:32:45 2005 +0000
+++ b/level1/modules/boot_common.asm	Mon Oct 17 12:37:49 2005 +0000
@@ -11,18 +11,29 @@
 * 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:
+* Important Notes:
+* For certain devices, only the lower 16 bits of DD.BT are used.  This special
+* case allows us to save some code by ignoring the loading LSN bits 23-16 in
+* DD.BT and FDSL.A.  Booters for such devices (floppy, RAMPak) should have the
+* following line in their code to take advantage of this optimization:
+*
+* LSN24BIT equ 0
+*
+* Floppy booters require the acquistion of DD.TKS and DD.FMT from LSN0 to make
+* certain decisions about the boot process.  In most cases, non-floppy booters
+* do not need these values.  Hence, floppy booters should have this line in their
+* source code file:
 *
 * FLOPPY equ 1
 *
 * Edt/Rev  YYYY/MM/DD  Modified by
 * Comment
 * ------------------------------------------------------------------
-*   1      2005/10/14  Boisy G. Pitre
+*          2005/10/14  Boisy G. Pitre
 * Created as a stand-alone file.
+*
+*          2005/10/16  Boisy G. Pitre
+* Further optimizations made
                          
 start    orcc  #IntMasks  ensure IRQs are off (necessary?)
          leas  -size,s   
@@ -36,38 +47,33 @@
          bsr   getpntr    restore U to point to our statics
                          
 * Initialize Hardware
+         ldy   Address,pcr				get hardware address
          lbsr  HWInit
 
 * Read LSN0
-         IFEQ             FLOPPY
+         IFNE  LSN24BIT
          clrb             MSB sector
          ENDC
          ldx   #0         LSW sector
          lbsr  HWRead     read LSN 0
          bcs   error      branch if error
                          
-         ifgt  Level-1   
+         IFGT  Level-1   
          lda   #'0        --- loaded in LSN0'
          jsr   <D.BtBug   ---
-         endc            
+         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 
+         ldb   DD.FMT,x   disk format byte
+         std   ddtks,u    TAKE NOTE!  ASSUMES ADJACENT VARS!
          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  
+* Old style boot -- make a fake FD segment right from LSN0!
+         leax  DD.BT,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
@@ -75,16 +81,11 @@
 * 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  
+         IFNE  LSN24BIT
+         clr   FDSL.S,x   make next segment entry 0
          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
@@ -95,7 +96,7 @@
          rts              return to kernel
                          
 * Error point - return allocated memory and then return to kernel
-error                    
+error                 
 * Return memory allocated for sector buffers
          ldd   #256      
          ldu   blockloc,u
@@ -110,48 +111,52 @@
          rts             
                          
 * NEW! Fragmented boot support!
-FragBoot ldb   bootloc,u  MSB fd sector location
-         ldx   bootloc+1,u LSW fd sector location
+*FragBoot ldb   bootloc,u  MSB fd sector location
+*         ldx   bootloc+1,u LSW fd sector location
+FragBoot ldb   DD.BT,x    MSB fd sector location
+         ldx   DD.BT+1,x  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   
+         IFGT  Level-1   
          os9   F$BtMem   
-         else            
+         ELSE            
          os9   F$SRqMem  
-         endc            
+         ENDC            
          bcs   error     
          bsr   getpntr   
          std   blockimg,u
                          
 * Get os9boot into memory
 BootLoop stx   seglist,u  update segment list
-         IFEQ  FLOPPY
+         IFNE  LSN24BIT
          ldb   FDSL.A,x   MSB sector location
          ENDC
 BL2      ldx   FDSL.A+1,x LSW sector location
+         IFNE  LSN24BIT
          bne   BL3       
          tstb            
+         ENDC
          beq   Back2Krn  
 BL3      lbsr  HWRead    
          inc   blockloc,u point to next input sector in mem
                          
-         ifgt  Level-1   
-         lda   #'.        Show .'
+         IFGT  Level-1   
+         lda   #'.        show .'
          jsr   <D.BtBug  
-         endc            
+         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
+         ldd   FDSL.A+1,x update sector location by one
          addd  #1        
          std   FDSL.A+1,x
-         IFEQ  FLOPPY
+         IFNE  LSN24BIT
          ldb   FDSL.A,x  
          adcb  #0        
          stb   FDSL.A,x  
--- a/level1/modules/boot_rampak.asm	Sat Oct 15 15:32:45 2005 +0000
+++ b/level1/modules/boot_rampak.asm	Mon Oct 17 12:37:49 2005 +0000
@@ -31,6 +31,11 @@
 
          mod   eom,name,tylg,atrv,start,size
 
+* Common booter-required defines
+LSN24BIT equ   0
+FLOPPY   equ   0
+
+
 * on-stack buffer to use
          org   0
 mpisave  rmb   1
@@ -39,7 +44,6 @@
 ddfmt    rmb   1
 seglist  rmb   2
 bootsize rmb   2
-bootloc  rmb   2
 blockloc rmb   2
 blockimg rmb   2
 size     equ   .
@@ -50,29 +54,29 @@
 
          use   ../../6809l1/modules/boot_common.asm
 
-* HWInit
-*
-* Entry:  None
-* Exit:   Y = base address of hardware
-*         Hardware has been initialized
+* HWInit - Initialize the device
+*   Entry: Y = hardware address
+*   Exit:  Carry Clear = OK, Set = Error
+*          B = error (Carry Set)
 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     rts
+cont     clrb
+         rts
 
 
-* HWTerm
-*
-* Entry:  Y = base address of hardware
-* Exit:   Hardware has been deinitialized
+* HWTerm - Terminate the device
+*   Entry: Y = hardware address
+*   Exit:  Carry Clear = OK, Set = Error
+*          B = error (Carry Set)
 HWTerm   lda   mpisave,u
          sta   >MPI.Slct
+         clrb
          rts