Skip to content

Commit

Permalink
KBD Driver Pre Init
Browse files Browse the repository at this point in the history
- Updated KBD driver to use PREINIT to disable interrupts.
  • Loading branch information
wwarthen committed Dec 12, 2024
1 parent 66bc219 commit 26a87a1
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Source/HBIOS/hbios.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5318,9 +5318,9 @@ SYS_RESCOLD:
;
; TURN OFF SPURIOUS INTERRUPT SOURCES
;
#IF ((INTMODE == 2) & KBDINTS))
CALL KBD_DEINIT
#ENDIF
;;;#IF ((INTMODE == 2) & KBDINTS))
;;; CALL KBD_DEINIT
;;;#ENDIF
#IFDEF APPBOOT
JP HB_RESTART
#ELSE
Expand Down
39 changes: 39 additions & 0 deletions Source/HBIOS/kbd.asm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ KBD_IDLE .DB 0 ; IDLE COUNT
; 8242 CONTROLLER COMMANDS AND RESPONSES
;__________________________________________________________________________________________________
;
KBD_CON_DP1 .EQU $AD ; DISABLE PS2 PORT 1 (KEYBOARD)
KBD_CON_DP2 .EQU $A7 ; DISABLE PS2 PORT 2 (MOUSE)
KBD_CON_EP1 .EQU $AE ; ENABLE PS2 PORT 1 (KEYBOARD)
KBD_CON_EP2 .EQU $A8 ; ENABLE PS2 PORT 2 (MOUSE)
KBD_CON_WCR .EQU $60 ; WRITE TO COMMAND REGISTER. VALUE TO FOLLOW.
KBD_CON_CST .EQU $AA ; CONTROLLER SELF TEST. RETURN FF IF CONTROLLER OK
;__________________________________________________________________________________________________
Expand All @@ -94,6 +98,41 @@ KBD_CON_IOF .EQU $20 ; XLAT DISABLED, MOUSE DISABLED, NO INTS
#INCLUDE "ps2iface.inc"
;
;__________________________________________________________________________________________________
; KEYBOARD PRE-INITIALIZATION
;__________________________________________________________________________________________________
;
; TO BE CALLED PRIOR TO INITERRUPTS BEING ENABLED
; MUST BE CALLED FROM VIDEO DRIVER PREINIT WITH IY SET
; THIS PREVENTS INTRERRUPT ISSUES IF 8242 HAS INTERRUPTS ENABLED
;
; AT STARTUP. NOT USING IT FOR NOW BECAUSE IT IS NOT A PROBLEM IF
; YOU DON'T USE THE KEYBOARD DURING BOOT.
;
KBD_PREINIT:
;
#IF (KBDINTS)
; DISABLE DEVICES (KEYBOARD/MOUSE)
LD A,KBD_CON_DP1 ; DISABLE PORT 1 (KEYBOARD)
CALL KBD_PUTCMD ; SEND IT
LD A,KBD_CON_DP2 ; DISABLE PORT 2 (MOUSE)
CALL KBD_PUTCMD ; SEND IT
;
; FLUSH ANY PENDING OUTPUT
LD B,16 ; UP TO 16 BYTES MAY BE WAITING
KBD_PREINIT1:
CALL KBD_IN_P ; BLIND READ
DJNZ KBD_PREINIT1 ; AND LOOP
;
; DISABLE INTERRUPTS
LD A,KBD_CON_WCR ; SET COMMAND REGISTER
CALL KBD_PUTCMD ; SEND IT
LD A,KBD_CON_IOF ; XLAT DISABLED, MOUSE DISABLED, NO INTS
CALL KBD_PUTDATA ; SEND IT
;
#ENDIF
RET
;
;__________________________________________________________________________________________________
; KEYBOARD INITIALIZATION
;__________________________________________________________________________________________________
;
Expand Down
20 changes: 10 additions & 10 deletions Source/HBIOS/ps2iface.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ KBD_INT:
; CALL KBDQDBG
;
RET
;__________________________________________________________________________________________________
; KEYBOARD DEINITIALIZATION
;__________________________________________________________________________________________________
;
KBD_DEINIT:
LD IY,(KBD_IDAT) ; SETUP PORT POINTER
LD A,KBD_CON_WCR ; LOAD WRITE COMMAND
CALL KBD_CMDOUT ; WRITE IT
LD A,KBD_CON_IOF ; LOAD DISABLE INTERRUPTS CFG
JP KBD_DTAOUT ; WRITE IT
;;;;__________________________________________________________________________________________________
;;;; KEYBOARD DEINITIALIZATION
;;;;__________________________________________________________________________________________________
;;;;
;;;KBD_DEINIT:
;;; LD IY,(KBD_IDAT) ; SETUP PORT POINTER
;;; LD A,KBD_CON_WCR ; LOAD WRITE COMMAND
;;; CALL KBD_CMDOUT ; WRITE IT
;;; LD A,KBD_CON_IOF ; LOAD DISABLE INTERRUPTS CFG
;;; JP KBD_DTAOUT ; WRITE IT
#ENDIF
;__________________________________________________________________________________________________
; KEYBOARD READ
Expand Down
4 changes: 4 additions & 0 deletions Source/HBIOS/tms.asm
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ NABUKBENABLE .SET TRUE ; INCLUDE NABU KEYBOARD SUPPORT
;======================================================================
;
TMS_PREINIT:
#IF (TMSKBD == TMSKBD_KBD)
LD IY,TMS_IDAT ; POINTER TO INSTANCE DATA
CALL KBD_PREINIT
#ENDIF
; DISABLE INTERRUPT GENERATION UNTIL AFTER INTERRUPT HANDLER
; HAS BEEN INSTALLED.
LD A, (TMS_INITVDU_REG_1)
Expand Down
2 changes: 1 addition & 1 deletion Source/ver.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#DEFINE RMN 5
#DEFINE RUP 0
#DEFINE RTP 0
#DEFINE BIOSVER "3.5.0-dev.99"
#DEFINE BIOSVER "3.5.0-dev.100"
#define rmj RMJ
#define rmn RMN
#define rup RUP
Expand Down
2 changes: 1 addition & 1 deletion Source/ver.lib
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ rmn equ 5
rup equ 0
rtp equ 0
biosver macro
db "3.5.0-dev.99"
db "3.5.0-dev.100"
endm

0 comments on commit 26a87a1

Please sign in to comment.