changeset 2270:07b2433f0c65

moved dwdefs.d to defs/, major changes to drivers due to new globals arrangement.
author boisy
date Mon, 28 Dec 2009 13:01:37 +0000
parents 659876305d1d
children 1091e798e5db
files defs/dwdefs.d defs/os9defs level1/modules/clock2_dw3.asm level1/modules/dwdefs.d level1/modules/rbdw3.asm level1/modules/scdwp.asm level1/modules/scdwt.asm
diffstat 7 files changed, 145 insertions(+), 121 deletions(-) [+]
line wrap: on
line diff
--- a/defs/dwdefs.d	Mon Dec 28 04:48:08 2009 +0000
+++ b/defs/dwdefs.d	Mon Dec 28 13:01:37 2009 +0000
@@ -31,6 +31,8 @@
 OP_GETSTA   equ    'G		GetStat routine called
 OP_SETSTA   equ    'S		SetStat routine called
 OP_TERM     equ    'T		Term routine called
+OP_SERINIT  equ    'E
+OP_SERTERM  equ    'E+128
 
 * Printer opcodes
 OP_PRINT    equ    'P		Print byte to the print buffer
--- a/defs/os9defs	Mon Dec 28 04:48:08 2009 +0000
+++ b/defs/os9defs	Mon Dec 28 13:01:37 2009 +0000
@@ -420,9 +420,9 @@
                RMB       5
 D.COCOXT       RMB       1                   Busy flag for CoCo-XT driver (one drive at a time)
 D.DbgMem       RMB       2                   Debug memory pointer
-D.DWSUB        RMB       2                   DriveWire Subroutine Module entry point
-D.DWSTATS      RMB  	 7
-D.DWVIRQPkt    RMB       5
+D.DWSubAddr    RMB  	 2                   DriveWire subroutine module pointer
+D.DWStat       RMB  	 2                   DriveWire statics page
+
                ORG       $20
 
                IFEQ      Level-1
--- a/level1/modules/clock2_dw3.asm	Mon Dec 28 04:48:08 2009 +0000
+++ b/level1/modules/clock2_dw3.asm	Mon Dec 28 13:01:37 2009 +0000
@@ -47,7 +47,7 @@
 	 pshs  a
 	 leax  ,s
 	 ldy   #$0001
-         ldu   >D.DWSUB
+         ldu   >D.DWSubAddr
 	 jsr   6,u
          puls  a        
 * Consider the following optimization
@@ -71,10 +71,10 @@
          puls    x
          stx     <D.Proc
          bcs     InitEx
-         sty     <D.DWSUB
+         sty     <D.DWSubAddr
          ELSE
          bcs     ex
-         sty     >D.DWSUB
+         sty     >D.DWSubAddr
          ENDC
          jsr     ,y			call initialization routine
 InitEx   rts
--- a/level1/modules/dwdefs.d	Mon Dec 28 04:48:08 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-********************************************************************
-* dwdefs - DriveWire Definitions File
-*
-* $Id$
-*
-* Ed.    Comments                                       Who YY/MM/DD
-* ------------------------------------------------------------------
-*   1    Started                                        BGP 03/04/03
-
-         nam   dwdefs
-         ttl   DriveWire Definitions File
-
-* Addresses
-BBOUT       equ    $FF20
-BBIN        equ    $FF22
-
-* Opcodes
-OP_NOP      equ    $00		No-Op
-OP_RESET1   equ    $FE		Server Reset
-OP_RESET2   equ    $FF		Server Reset
-OP_TIME     equ   '#	 	Current time requested
-OP_INIT     equ   'I		Init routine called
-OP_READ     equ   'R		Read one sector
-OP_REREAD   equ   'r		Re-read one sector
-OP_READEX   equ   'R+128	Read one sector
-OP_REREADEX equ   'r+128	Re-read one sector
-OP_WRITE    equ   'W		Write one sector
-OP_REWRIT   equ   'w		Re-write one sector
-OP_GETSTA   equ   'G		GetStat routine called
-OP_SETSTA   equ   'S		SetStat routine called
-OP_TERM     equ   'T		Term routine called
-
-* Printer opcodes
-OP_PRINT    equ   'P		Print byte to the print buffer
-OP_PRINTFLUSH equ 'F		Flush the server print buffer
-
-* Serial opcodes
-OP_SERREAD equ 'C
-OP_SERREADM equ 'c
-OP_SERWRITE equ 'C+128
-OP_SERGETSTAT equ 'D
-OP_SERSETSTAT equ 'D+128
-
-* WireBug opcodes (Server-initiated)
-OP_WIREBUG_MODE  equ   'B
-* WireBug opcodes (Server-initiated)
-OP_WIREBUG_READREGS   equ  'R	Read the CoCo's registers
-OP_WIREBUG_WRITEREGS  equ  'r	Write the CoCo's registers
-OP_WIREBUG_READMEM    equ  'M	Read the CoCo's memory
-OP_WIREBUG_WRITEMEM   equ  'm	Write the CoCo's memory
-OP_WIREBUG_GO         equ  'G	Tell CoCo to get out of WireBug mode and continue execution
-
-* VPort opcodes (CoCo-initiated)
-OP_VPORT_READ         equ  'V
-OP_VPORT_WRITE        equ  'v
-
-* Error definitions
-E_CRC      equ   $F3            Same as NitrOS-9 E$CRC
--- a/level1/modules/rbdw3.asm	Mon Dec 28 04:48:08 2009 +0000
+++ b/level1/modules/rbdw3.asm	Mon Dec 28 13:01:37 2009 +0000
@@ -80,9 +80,9 @@
          sta   ,x
          ldy   #$0001
          IFGT  LEVEL-1
-         ldu   <D.DWSUB
+         ldu   <D.DWSubAddr
          ELSE
-         ldu   >D.DWSUB
+         ldu   >D.DWSubAddr
          ENDC
          jsr   6,u
          puls  a,cc,pc
@@ -126,9 +126,9 @@
          bcs   InitEx 
          tfr   y,u		 
          IFGT  LEVEL-1
-         stu   <D.DWSUB
+         stu   <D.DWSubAddr
          ELSE
-         stu   >D.DWSUB
+         stu   >D.DWSubAddr
          ENDC
 * Initialize the low level device
          jsr   ,u
@@ -201,9 +201,9 @@
          std   ,x
          ldy    #5 
          IFGT  LEVEL-1
-         ldu   <D.DWSUB
+         ldu   <D.DWSubAddr
          ELSE
-         ldu   >D.DWSUB
+         ldu   >D.DWSubAddr
          ENDC
          orcc  #IntMasks
          jsr   6,u
@@ -278,9 +278,9 @@
          std   ,x
          ldy   #$0005
          IFGT  LEVEL-1
-         ldu   <D.DWSUB
+         ldu   <D.DWSubAddr
          ELSE
-         ldu   >D.DWSUB
+         ldu   >D.DWSubAddr
          ENDC
          orcc  #IntMasks
          jsr   6,u
@@ -365,9 +365,9 @@
          leax  ,s
          ldy   #$0003
          IFGT  LEVEL-1
-         ldu   <D.DWSUB
+         ldu   <D.DWSubAddr
          ELSE
-         ldu   >D.DWSUB
+         ldu   >D.DWSubAddr
          ENDC
          jsr   6,u
          leas  3,s
--- a/level1/modules/scdwp.asm	Mon Dec 28 04:48:08 2009 +0000
+++ b/level1/modules/scdwp.asm	Mon Dec 28 13:01:37 2009 +0000
@@ -74,15 +74,15 @@
 *    B  = error code
 *
 Init
-* Check if D.DWSUB already holds a valid subroutine module pointer
+* Check if D.DWSubAddr already holds a valid subroutine module pointer
          IFGT  Level-1
-         ldx   <D.DWSUB
+         ldx   <D.DWSubAddr
          ELSE
-         ldx   >D.DWSUB
+         ldx   >D.DWSubAddr
          ENDC
          bne   InitEx
 
-* If here, D.DWSUB is 0, so we must link to subroutine module
+* If here, D.DWSubAddr is 0, so we must link to subroutine module
          IFGT  Level-1
          ldx   <D.Proc
          pshs  x
@@ -98,9 +98,9 @@
          ENDC
          bcs   InitEx
          IFGT  Level-1
-         sty   <D.DWSUB
+         sty   <D.DWSubAddr
          ELSE
-         sty   >D.DWSUB
+         sty   >D.DWSubAddr
          ENDC
          jsr   ,y			call init routine
 InitEx   rts
@@ -124,7 +124,7 @@
          pshs  d
          leax  ,s
          ldy   #$0002
-         ldu   >D.DWSUB
+         ldu   >D.DWSubAddr
          jsr   6,u
          puls  d,pc
 
@@ -183,7 +183,7 @@
          pshs  a
          ldy   #$0001
          leax  ,s
-         ldu   >D.DWSUB
+         ldu   >D.DWSubAddr
          jsr   6,u
          puls  a,pc
 
--- a/level1/modules/scdwt.asm	Mon Dec 28 04:48:08 2009 +0000
+++ b/level1/modules/scdwt.asm	Mon Dec 28 13:01:37 2009 +0000
@@ -84,31 +84,36 @@
 
 			lda		<V.PORT+1,u		;get our port #
 
-			* put setstat args on stack for later
-			ldb		#255
-			pshs 	d				;port #, 255 (term) on stack
+			pshs 	a				;port # on stack
 			* clear statics table entry
-			ldx   	#D.DWSTATS
+			IFGT    Level-1
+			ldx   	<D.DWStat
+			ELSE
+			ldx   	>D.DWStat
+			ENDC
+* Cheat: we know DW.StatTbl is at offset $00 from D.DWStat, do not bother with leax
+*			leax    DW.StatTbl,x
 			clr		a,x				;clear out
+
 			* tell server
-			lda     #OP_SERSETSTAT ; load command
+			lda     #OP_SERTERM ; load command
 			pshs   	a      		; command store on stack
 			leax    ,s     		; point X to stack 
-			ldy     #3          ; 3 bytes to send 
+			ldy     #2          ; 2 bytes to send 
     
             pshs    u
 
 			IFGT  Level-1
-			ldu   	<D.DWSUB
+			ldu   	<D.DWSubAddr
 			ELSE
-			ldu   	>D.DWSUB
+			ldu   	>D.DWSubAddr
 			ENDC
 			
     		jsr     6,u      	; call DWrite
 
             puls    u
 			
-    		leas	3,s			; clean 3 DWsub args from stack 
+    		leas	2,s			; clean 3 DWsub args from stack 
 			
 * Check if we need to clean up IRQ
 			bsr     CheckStats
@@ -118,28 +123,53 @@
 			
 * no more ports open.. are we the primary instance?
 DumpVIRQ   	
-			ldy     #D.DWVIRQPkt
+			IFGT    Level-1
+			ldy   	<D.DWStat
+			ELSE
+			ldy   	>D.DWStat
+			ENDC
+			leay    DW.VIRQPkt,y
          	ldx   	#$0000		;code to delete VIRQ entry
          	os9   	F$VIRQ		;remove from VIRQ polling
-         	bcs   	Term.Err	;go report error...
+         	bcs   	ReleaseMem	;go
 DumpIRQ
-			ldx     #D.DWVIRQPkt
+			IFGT    Level-1
+			ldx   	<D.DWStat
+			ELSE
+			ldx   	>D.DWStat
+			ENDC
+			leax    DW.VIRQPkt,x
 			tfr     x,u
          	leax  	Vi.Stat,x	;fake VIRQ status register
          	tfr   	x,d			;copy address...
          	ldx   	#$0000		;code to remove IRQ entry
          	leay  	IRQSvc,pc	;IRQ service routine
          	os9   	F$IRQ
+
+ReleaseMem
+			IFGT    Level-1
+			ldu     <D.DWStat
+			ELSE
+			ldu     >D.DWStat
+			ENDC
+			ldd     #$0100
+			os9     F$SRtMem
 Term.Err    rts
 
 
 ***********************************************************************
-* CheckStats - Check if the D.DWSTATS table is empty
+* CheckStats - Check if the D.DWStat table is empty
 * Entry: None
 * Exit:  B=0, stat table is empty; B!=0, stat table is not empty
 CheckStats
          	pshs  	x
-			ldx     #D.DWSTATS
+			IFGT    Level-1
+			ldx     <D.DWStat
+			ELSE
+			ldx     >D.DWStat
+			ENDC
+* Cheat: we know DW.StatTbl is at offset $00 from D.DWStat, do not bother with leax
+*			leax    DW.StatTbl,x
 			ldb     #7
 CheckLoop   tst     ,x+
 			bne     CheckExit
@@ -181,23 +211,45 @@
          	ENDC
          	lbcs   	InitEx
          	IFGT  	Level-1
-         	sty   	<D.DWSUB
+         	sty   	<D.DWSubAddr
          	ELSE
-         	sty   	>D.DWSUB
+         	sty   	>D.DWSubAddr
          	ENDC
          	jsr   	,y			call DW init routine
        	
          	puls	u				;restore u
       	
-         	bsr     CheckStats
-         	bne		IRQok
+			IFGT    Level-1
+			ldx     <D.DWStat
+			ELSE
+			ldx     >D.DWStat
+			ENDC
+			bne     IRQok
+
+* allocate DW stat page
+			pshs    u
+			ldd     #$0100
+			os9     F$SRqMem
+			tfr     u,d
+			puls    u
+			bcs     InitEx
+			IFGT    Level-1
+			std     <D.DWStat
+			ELSE
+			std     >D.DWStat
+			ENDC
          	
 * If here, we must install ISR
      
 
 * Install the IRQ/VIRQ entry 
 InstIRQ
-			ldx     #D.DWVIRQPkt
+			IFGT    Level-1
+			ldx   	<D.DWStat
+			ELSE
+			ldx   	>D.DWStat
+			ENDC
+			leax    DW.VIRQPkt,x
             pshs    u
 			tfr     x,u
 		    leax  	Vi.Stat,x		;fake VIRQ status register
@@ -210,7 +262,12 @@
 			puls    u
          	bcs   	InitEx   		;exit with error
          	ldd   	#$0003     		;lets try every 6 ticks (0.1 seconds) -- testing 3, gives better response in interactive things
-			ldx     #D.DWVIRQPkt
+			IFGT    Level-1
+			ldx   	<D.DWStat
+			ELSE
+			ldx   	>D.DWStat
+			ENDC
+			leax    DW.VIRQPkt,x
          	std   	Vi.Rst,x		;reset count
 			tfr     x,y             ;move VIRQ software packet to Y
          	ldx   	#$0001     		;code to install new VIRQ
@@ -221,7 +278,13 @@
          	
 IRQok1st	
 IRQok
-         	ldx   	#D.DWSTATS
+			IFGT    Level-1
+			ldx     <D.DWStat
+			ELSE
+			ldx     >D.DWStat
+			ENDC
+* Cheat: we know DW.StatTbl is at offset $00 from D.DWStat, do not bother with leax
+*			leax    DW.StatTbl,x
 			tfr     u,d
 	        ldb		<V.PORT+1,u		;get our port #
 			sta		b,x				;store in table
@@ -236,23 +299,22 @@
 			abx  						;add buffer size to buffer start..
 			stx   	RxBufEnd,u      	;save Rx buffer end address
 
-			* tell DW we've got a new port opening
+			* tell DW we have a new port opening
 			ldb		<V.PORT+1,u		; get our port #			
-			pshs    b
 			lda     #OP_SERSETSTAT 	; command 
 			pshs   	d      			; command + port # on stack
 			leax    ,s     			; point X to stack 
-			ldy     #3          	; 3 bytes to send
+			ldy     #2          	; 2 bytes to send
 			
 			IFGT  Level-1
-			ldu   	<D.DWSUB
+			ldu   	<D.DWSubAddr
 			ELSE
-			ldu   	>D.DWSUB
+			ldu   	>D.DWSubAddr
 			ENDC
     		jsr     6,u      		; call DWrite
     		
 			*for now setstat doesn't respond    		
-    		leas	3,s				;clean dw args off stack
+    		leas	2,s				;clean dw args off stack
     		
 InitEx		equ		*
 			puls	cc,pc
@@ -298,9 +360,9 @@
 			ldy     #3          ; 3 bytes to send
     
 			IFGT  Level-1
-			ldu   	<D.DWSUB
+			ldu   	<D.DWSubAddr
 			ELSE
-			ldu   	>D.DWSUB
+			ldu   	>D.DWSubAddr
 			ENDC
     		jsr     6,u      	; call DWrite
     		
@@ -368,9 +430,9 @@
 			ldy     #1          ; 1 byte to send
     
 			IFGT  Level-1
-			ldu   	<D.DWSUB
+			ldu   	<D.DWSubAddr
 			ELSE
-			ldu   	>D.DWSUB
+			ldu   	>D.DWSubAddr
 			ENDC
     		jsr     6,u      	; call DWrite
     		
@@ -393,7 +455,13 @@
   			anda    #$07		;mask first 5 bits, a is now port #+1
   			deca				;we pass +1 to use 0 for no data
 * here we set U to the static storage area of the device we are working with
-			ldx     #D.DWSTATS
+			IFGT    Level-1
+			ldx   	<D.DWStat
+			ELSE
+			ldx   	>D.DWStat
+			ENDC
+* Cheat: we know DW.StatTbl is at offset $00 from D.DWStat, do not bother with leax
+*			leax    DW.StatTbl,x
 			lda     a,x
 			bne		IRQCont		;if A is 0, then this device is not active, so exit
             puls    d
@@ -409,9 +477,21 @@
 * put byte B in port A's buffer - optimization help from Darren Atkinson       
 IRQPutCh   	ldx     RxBufPut,u	;point X to the data buffer
         
-			* sc6551 now does lots of things with flow control, we might want some of this
-			* but implemented differently.. for now.. skip it
-		   
+* process interrupt/quit characters here
+* note we will have to do this in the multiread (ugh)                     
+*                  lda  #S$Intrpt
+*		  cmpb V.INTR,u
+*                  bne  test2
+test2
+*                  lda  #S$Abort
+*                  cmpb V.QUIT,u
+*                  bne store
+*                  ldb  V.LPRC,u
+*                  exg  a,b
+*                  os9  F$Send 
+*                  bra  IRQExit
+ 
+store
 			* store our data byte
 			stb    	,x+     	; store and increment buffer pointer
         
@@ -468,9 +548,9 @@
          	leax  	,s
          	ldy   	#$0003			; 3 bytes to send.. ugh.  need WRITEM (data mode)
          	IFGT  	Level-1
-         	ldu   	<D.DWSUB
+         	ldu   	<D.DWSubAddr
          	ELSE
-         	ldu   	>D.DWSUB
+         	ldu   	>D.DWSubAddr
          	ENDC
          	jsr   	6,u
 WriteOK   	clrb
@@ -646,9 +726,9 @@
          ldy   #$0001
          leax  ,s
          IFGT  Level-1
-         ldu   <D.DWSUB
+         ldu   <D.DWSubAddr
          ELSE
-         ldu   >D.DWSUB
+         ldu   >D.DWSubAddr
          ENDC
          jsr   6,u
          puls  a,pc