changeset 1838:20adccef595a

Added proper NMI disable for Alpha
author afra
date Thu, 16 Jun 2005 22:17:25 +0000
parents 8c92d803f168
children 613d93786303
files level1/modules/boot_d64.asm level1/modules/ddisk.asm
diffstat 2 files changed, 54 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/level1/modules/boot_d64.asm	Tue May 31 15:20:35 2005 +0000
+++ b/level1/modules/boot_d64.asm	Thu Jun 16 22:17:25 2005 +0000
@@ -15,6 +15,12 @@
 * 2005-05-08, P.Harvey-Smith, added code to force 5/8 line low on
 * Alpha so correct clock selected.
 *
+* 2005-06-16, P.Harvey-Smith.
+*	Added NMI enable/disable code, as I know know how to enable/disable
+*	NMI on the Alpha, having disasembled the Alpha's OS9's ddisk.
+*
+
+
 		nam   Boot
          ttl   os9 system module    
 
@@ -101,7 +107,6 @@
 BuffPtr    	rmb   2
 SideSel    	rmb   1		; Side select mask
 CurrentTrack	rmb   1		; Current track number
-NMIFlag	 	rmb   1		; NMI enabled flag for Alpha.
 size     	equ   .
 
 name     	equ   *
@@ -111,13 +116,14 @@
 
 
 start   equ   	*
-	ldx	#$55AA
 	
 	ldx	#CMdReg
         clra  
 		 
 	IFNE	DragonAlpha
-	clr	NMIFlag,u	; Make sure NMI turned off in Dragon Alpha
+	lda	#$30		; Set PIA2 CA2 as output, as used to control NMI
+	ora	PIA2CRA
+	sta	PIA2CRA
 	ENDC
 	 
  	ldb   	#size
@@ -285,24 +291,13 @@
         ldb   	<dppiadb	
         sta   	,x+		
         bra   	ReadDataWait	; We break out with an NMI
-
-; The following block of code is needed for the Dragon Alpha, because
-; we currently do not know how to disable it's NMI in hardware,
-; So we check a flag here, and if set we simply return from inturrupt
-; as if nothing happened !
+;
+; NMI service routine.
+;
 
 NMIService
-	IFNE	DragonAlpha
-	pshs	cc
-	tst		NMIFlag,u
-	bne		DoNMI
-	puls	cc
-	RTI
 		
-DoNMI	puls	cc
-	ENDC
-		
-L0106   leas  	R$Size,s	; Drop saved Regs from stack
+	leas  	R$Size,s	; Drop saved Regs from stack
         lda   	#MotorOn
 
 	IFNE	DragonAlpha
@@ -425,7 +420,7 @@
 ; converted with a lookup table.
 ; We do not need to preserve the ROM select bit as this code
 ; operates in RAM only mode.
-; Also sets NMIFlag.
+; Also sets PIA2 CA2 to enable/disable NMI
 
 AlphaDskCtlB	
 	pshs	A
@@ -441,7 +436,17 @@
 
 	PSHS	A	
 	ANDA	#NMIEn		; mask out nmi enable bit
-	sta	>NMIFlag,u	; Save it for later use
+
+	beq	NMIoff		; if zero switch off
+	
+	lda	#NMIEnA		; enable NMI
+	ora	PIA2CRA
+	bra	NMISave		; save it
+	
+NMIoff	lda	#NMIDisA	; disable NMI
+	anda	PIA2CRA		
+NMISave
+	sta	PIA2CRA
 		
 	lda	,s		; Convert drives
 	anda	#%00000011	; mask out drive number
--- a/level1/modules/ddisk.asm	Tue May 31 15:20:35 2005 +0000
+++ b/level1/modules/ddisk.asm	Thu Jun 16 22:17:25 2005 +0000
@@ -66,6 +66,13 @@
 *	Added code to make step rates work as on the rb1773 driver, they where
 *	previously working back to front.
 *
+* 2005-06-06, P.Harvey-Smith.
+*	Verified as working on a real Alpha, by Richard Harding.
+*
+* 2005-06-16, P.Harvey-Smith.
+*	Added NMI enable/disable code, as I know know how to enable/disable
+*	NMI on the Alpha, having disasembled the Alpha's OS9's ddisk.
+*
 
          nam   DDisk
          ttl   Dragon Floppy driver
@@ -163,7 +170,6 @@
 SaveACIACmd	rmb	1	; Saved copy of ACIA command reg
 BuffPtr	 	rmb	2	; Buffer pointer
 SideSel	 	rmb	1	; Side select.
-NMIFlag	 	rmb	1	; Flag for Alpha, should this NMI do an RTI ?
 Density		rmb	1	; Density 0=double, %00001000=single D64, %00100000=single Alpha
 
 DskError	rmb	1	; hardware disk error	
@@ -204,7 +210,7 @@
 *    CC = carry set on error
 *    B  = error code
 *
-DragonDebug	EQU	0
+DragonDebug	EQU	1
 Init    
 	IFNE	DragonDebug
 	pshs	y		; This is here so I can find disk driver in mess
@@ -216,6 +222,11 @@
 	sta	>D.DskTmr	; Zero motor timer
 	
 	IFNE	DragonAlpha	; Turn off all drives
+
+	lda	#$30		; Set PIA2 CA2 as output
+	ora	PIA2CRA
+	sta	PIA2CRA
+
 	lbsr	AlphaDskCtl
 	ELSE
         sta   	>DskCtl
@@ -494,23 +505,11 @@
         bra   	WriteDataWait
 	
 
-; The following block of code is needed for the Dragon Alpha, because
-; we currently do not know how to disable it's NMI in hardware,
-; So we check a flag here, and if set we simply return from inturrupt
-; as if nothing happened !
+;
+; NMI Handler code.
+;
 
 NMIService
-	IFNE	DragonAlpha		
-	pshs	cc		; Save flags
-	tst	>NMIFlag,u	; Check NMI enable flag 
-	bne	DoNMI		; if enabled, continue with handler
-	puls	cc		; else restore flags and return
-	RTI
-		
-DoNMI	puls	cc		; restore flags
-	ENDC
-	
-RealNMI    
 	leas  	R$Size,s	; Drop regs from stack
         bsr   	RestoreSavedIO	; Restore saved IO states
         puls  	y,dp,cc
@@ -990,8 +989,7 @@
 ; converted with a lookup table.
 ; We do not need to preserve the ROM select bit as this code
 ; operates in RAM only mode.
-; Also sets NMIFlag.
-
+; Also sets PIA2 CA2 to enable/disable NMI
 
 ADrvTab	FCB		Drive0A,Drive1A,Drive2A,Drive3A
 
@@ -1000,8 +998,18 @@
 
 	PSHS	A	
 	ANDA	#NMIEn		; mask out nmi enable bit
-	sta	>NMIFlag,u	; Save it for later use
-		
+
+	beq	NMIoff		; if zero switch off
+	
+	lda	#NMIEnA		; enable NMI
+	ora	PIA2CRA
+	bra	NMISave		; save it
+	
+NMIoff	lda	#NMIDisA	; disable NMI
+	anda	PIA2CRA		
+NMISave
+	sta	PIA2CRA
+	
 	lda	,s		; Convert drives
 	anda	#%00000011	; mask out drive number
 	leax	ADrvTab,pcr	; point at table