changeset 93:0c12245b7bdc

Fixed NitrOS-9 and OS-9 Level Two bug where Address was too far off the end of the module for the ldy <Address,pcr to work
author boisy
date Wed, 03 Jul 2002 19:19:16 +0000
parents 3f67d4e039f0
children 41d00dbe5f9a
files 3rdparty/booters/boot_ide.asm 3rdparty/booters/makefile
diffstat 2 files changed, 215 insertions(+), 224 deletions(-) [+]
line wrap: on
line diff
--- a/3rdparty/booters/boot_ide.asm	Wed Jul 03 07:01:37 2002 +0000
+++ b/3rdparty/booters/boot_ide.asm	Wed Jul 03 19:19:16 2002 +0000
@@ -1,14 +1,26 @@
 ********************************************************************
-* Boot - Glenside IDE Boot module
+* Boot - SCSI Boot module
 *
 * $Id$
 *
+* This module allows booting from a hard drive that uses RGB-DOS
+* and is controlled by a TC^3 or 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 SCSI boot module.
+*
+* Instructions followed by +++ in the comment field were added for this fix.
+*
 * Ed.    Comments                                       Who YY/MM/DD
 * ------------------------------------------------------------------
-* 1      Created                                        BGP 99/05/11
+* ?      Disassembled                                   AD  94/06/25
+* 6      Redone for IDE                                 PTB 99/08/17
+* 7      Added use of LSN bits 23-16                    BGP 02/06/27
+
 
          nam   Boot
-         ttl   Glenside IDE Boot module
+         ttl   IDE booter for LBA mode
 
          ifp1
          use   defsfile
@@ -16,246 +28,218 @@
 
 tylg     set   Systm+Objct
 atrv     set   ReEnt+rev
-rev      set   0
-edition  set   1
+rev      set   2
+edition  set   7
+
+
+* Disassembled 94/06/25 11:37:47 by Alan DeKok 
+* ReDone by Paul T. Barton 99/08/17, for IDE 
+* 
+Port     equ   $FF70      still leaves room for SSPak & SSP & MPI 
+RData    equ   0          data 0..7 
+WData    equ   0          data 0..7 
+ErrReg   equ   1          Has the errors 
+SecCnt   equ   2          always =1 
+SecNum   equ   3
+CylLow   equ   4
+CylHigh  equ   5
+DevHead  equ   6          0,1,0,DEV,0,0,0,0 
+Status   equ   7          Results of read/write 
+CmdIde   equ   7          Commands 
+Latch    equ   8          Latch
+
+ReadCmd  equ   $20
+Diagnos  equ   $90
+
+BusyBit  equ   %10000000  BUSY=1 
+DrdyBit  equ   %01000000  drive ready=1 
+DscBit   equ   %00010000  seek finished=1 
+DrqBit   equ   %00001000  data requested=1 
+ErrBit   equ   %00000001  error_reg has it 
+RdyTrk   equ   %01010000  ready & over track 
+RdyDrq   equ   %01011000  ready w/ data 
+Master   equ   %11100000  LBA MODE 
+Slave    equ   %11110000  LBA MODE 
+
+
+WhchDriv equ   Master     Drive to use (Master or Slave)
 
          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
+* on-stack buffer to use 
+         org   0
+btmem    rmb   2
+btsiz    rmb   2
+btloc    rmb   3
 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
+start          
+         orcc  #IntMasks  ensure IRQ's are off. 
+         leas  -size,s
 
-         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
+         clr   >$FF40     stop the disk 
+         lbsr  Init 
+
+         ldd   #$0001     request one byte (will round up to 1 page) 
+         os9   F$SRqMem   request the memory 
+         bcs   L00B0      exit on error 
+
+* U is implicitely the buffer address to use 
 
-* Request memory for LSN0
-         ldd   #1
-         os9   F$SRqMem                request one page of RAM
-         bcs   error
-         bsr   getpntr
+         clrb  
+         ldx   #$0000     X=0: got to sector #$0000 
+         bsr   GetSect    load in LSN0, U = buffer start 
+         bcs   L00B0
+
+         ifne  NitrOS9
+         lda   #'0        --- loaded in LSN0 
+         jsr   <D.BtBug   --- 
+         endc  
 
-* Get LSN0 into memory
-         clrb                          MSB sector
-         ldx   #0                      LSW sector
-         bsr   mread
-         bcs   error
-         ldd   bootsize,u
-         beq   error
-         pshs  d
+         ldd   <DD.BSZ,u  size of the bootstrap file 
+         std   btsiz,s    save it on the stack (0,s is junk) 
+         lda   <DD.BT,u   get starting sector bits 23-16
+         ldx   <DD.BT+1,u get starting sector of the bootstrap file 
+         sta   btloc,s
+         stx   btloc+1,s
 
-* Return memory
-         ldd   #$100
-         ldu   blockloc,u
-         os9   F$SRtMem
-         puls  d
-         os9   F$BtMem
-         bcs   error
-         bsr   getpntr
-         std   blockimg,u
+         ldd   #256       one page of memory 
+         os9   F$SRtMem   return the copy of LSN0 to free memory 
 
-* 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
+         ldd   btsiz,s    get size of boot memory to request 
+         ifeq  Level-2
+         os9   F$BtMem    ask for the boot memory 
+         else  
+         os9   F$SRqMem   ask for the boot memory 
+         endc  
+         bcs   L00AE      no memory: exit with error 
 
-         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
+         std   btsiz,s
+         stu   btmem,s    save start address of memory allocated 
+         ldd   btsiz,s    and the size of the boot memory 
+         beq   L00B0      if no memory allocated, exit 
+         pshs  d          save off temp size
+SectLp         
+         ldb   btloc+2,s
+         bsr   GetSect    read one sector 
+         bcs   L00AE      if there's an error, exit 
 
-error    leas  2+size,s
-         ldb   #E$NotRdy               drive not ready
-         rts
+         ifne  NitrOS9
+         lda   #'.        dump out a period for boot debugging 
+         jsr   <D.BtBug   do the debug stuff 
+         endc  
 
-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
+         leau  256,u
+         leax  1,x        go to the next sector 
+         bne   Sect2
+         incb  
+         stb   btloc+2,s
+Sect2          
+         ldd   ,s
+         subd  #256       take out one sector, need value in B, too. 
+         std   ,s
+         bhi   SectLp     loop until all sectors are read 
 
-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
+L00A7    clrb             clear carry 
+         ldd   btsiz+2,s
 
-* 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
+L00AE    leas  $02,s      kill D off of the stack 
+         ldx   btmem,s
+L00B0    leas  size,s     remove the on-stack buffer 
+L00BA    rts   
+
+Address  fdb   Port
+
+* GetSect: read a sector off of the disk 
+* Entry: B,X = sector number to read 
+* Memory: U = where to put it 
 
-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
+GetSect        
+         pshs  b,x,y
+         ldy   <Address,pcr grab the device address 
+         bsr   ChkBusy
+
+RdyHuh1        
+         lda   Status,y   is IDE ready for commands? 
+         anda  #DrdyBit   ready ? 
+         beq   RdyHuh1    loop until Drdy =1 
 
-*
-* 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
+         lda   #WhchDriv
+         sta   DevHead,y  0L0d/0hhh device=LBA 
+         lda   #$01       only one at a time 
+         sta   SecCnt,y   only one at a time 
+         stb   CylHigh,y  bits 23-16 
+         tfr   x,d        sector number to read 
+         sta   CylLow,y   hi-byte 
+         stb   SecNum,y
+         leax  ,u         where to put the sector 
+         lda   #ReadCmd   read one sector 
+         sta   CmdIde,y   finish process 
 
-*
-* 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   
+Blk2           
+         lda   Status,y   is IDE ready to send? 
+         anda  #DrqBit    DRQ, data request 
+         beq   Blk2       loop while DRQ =0 
+
+         clr   ,-s
+BlkLp          
+         lda   RData,y    A <- IDE 
+         ldb   Latch,y
+         std   ,x++       into RAM 
+         inc   ,s
+         bpl   BlkLp      go get the rest 
+         puls  b
+
+         lda   Status,y   check for error-bit 
+         clrb  
+         puls  b,x,y,pc
+* ------------------------------------------ 
 
-*
-* 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
+ChkBusy        
+         lda   Status,y
+         anda  #BusyBit   1xxx-xxxx 
+         bne   ChkBusy    if =1 then loop 
+         rts              exit when BUSY =0 
+
+Init           
+         pshs  d,y
+         ldy   <Address,pcr
+         bsr   ChkBusy    could be spinning up... 
+         lda   #Diagnos   hits all drives 
+         sta   CmdIde,y   ./ 
+         bsr   ChkBusy    wait 'til both done 
+         clrb             no errors 
+         puls  d,y,pc
 
-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   
+         ifeq  Level-2
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+         fcb   0,1,2,3,4,5,6,7
+         ifeq  NitrOS9
+         fcb   0,1,2,3,4,5,6,7
+         endc
+         endc
 
-* Fillers to get to $1D0
-         fcc   /9999999999/
-         fcc   /9999999999/
-         fcc   /9999999999/
-         fcc   /9999999999/
-         fcc   /9999999999/
-         fcc   /9999999999/
-         fcc   /9999999999/
-         fcc   /999999999/
+
+         emod  
+eom      equ   *
 
-         emod
+
 
-eom      equ   *
+
--- a/3rdparty/booters/makefile	Wed Jul 03 07:01:37 2002 +0000
+++ b/3rdparty/booters/makefile	Wed Jul 03 19:19:16 2002 +0000
@@ -2,7 +2,8 @@
 
 DEPENDS		= ./Makefile
 BOOTERS		= boot_kenton boot_rampak boot_tc3 boot_ide boot_wd1002 \
-		boot_rom boot_rom_l1 boot_tc3_l1 boot_kenton_l1
+		boot_rom boot_rom_l1 boot_tc3_l1 boot_kenton_l1 boot_ide_l1 \
+		boot_ide_nl2
 ALLOBJS		= $(BOOTERS)
 
 all:	$(ALLOBJS) $(DEPENDS)
@@ -20,9 +21,6 @@
 boot_tc3: boot_scsi.asm
 	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aLevel=2 -aKenton=0 -aTC3=1
 
-boot_ide: boot_ide.asm
-	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aLevel=2
-
 boot_wd1002: boot_wd1002.asm
 	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aLevel=2
 
@@ -38,3 +36,12 @@
 boot_tc3_l1: boot_scsi.asm
 	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aLevel=1 -aKenton=1 -aTC3=0
 
+boot_ide: boot_ide.asm
+	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aLevel=2 -aNitrOS9=0
+
+boot_ide_nl2: boot_ide.asm
+	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aLevel=2 -aNitrOS9=1
+
+boot_ide_l1: boot_ide.asm
+	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aLevel=1 -aNitrOS9=0
+