Commit 2ba2be90 authored by ROOL's avatar ROOL :robot:
Browse files

Participate in keyboard scan dependencies

Detail:
  Replace keyboard scan code with list of modules that the kernel needs to do the same.
  Reorder the HALEntries to match Kernel-5_89.
  Delete unused workspace.
Admin:
  Submission for USB bounty.

Version 0.36. Tagged as 'IOMD-0_36'
parent 0e1d5716
/* (0.35) /* (0.36)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 0.35 #define Module_MajorVersion_CMHG 0.36
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 29 Nov 2016 #define Module_Date_CMHG 09 Sep 2017
#define Module_MajorVersion "0.35" #define Module_MajorVersion "0.36"
#define Module_Version 35 #define Module_Version 36
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "29 Nov 2016" #define Module_Date "09 Sep 2017"
#define Module_ApplicationDate "29-Nov-16" #define Module_ApplicationDate "09-Sep-17"
#define Module_ComponentName "IOMD" #define Module_ComponentName "IOMD"
#define Module_ComponentPath "castle/RiscOS/Sources/HAL/IOMD" #define Module_ComponentPath "castle/RiscOS/Sources/HAL/IOMD"
#define Module_FullVersion "0.35" #define Module_FullVersion "0.36"
#define Module_HelpVersion "0.35 (29 Nov 2016)" #define Module_HelpVersion "0.36 (09 Sep 2017)"
#define Module_LibraryVersionInfo "0:35" #define Module_LibraryVersionInfo "0:36"
...@@ -62,14 +62,6 @@ DMACDeviceStruct # (80+4)*1 ; (DMAC + 1 private) * 1 controller ...@@ -62,14 +62,6 @@ DMACDeviceStruct # (80+4)*1 ; (DMAC + 1 private) * 1 controller
DMABChannelPtrs # 4*6 ; 6 pointers DMABChannelPtrs # 4*6 ; 6 pointers
DMABChannelStructs # (112+16)*6 ; (DMAB + 4 private) * 6 channels DMABChannelStructs # (112+16)*6 ; (DMAB + 4 private) * 6 channels
; workspace for keyboard scan
KbdFlags # 4
KbdKeyNumTable # 4
KbdCountDown # 4
KbdPort2Present # 1
KbdPresentFlags # 1
# 2
; workspace for IDE controller ; workspace for IDE controller
IDEDeviceStruct # 76+4 IDEDeviceStruct # 76+4
......
...@@ -106,10 +106,7 @@ HALdescriptor DATA ...@@ -106,10 +106,7 @@ HALdescriptor DATA
IMPORT HAL_MachineID IMPORT HAL_MachineID
IMPORT HAL_KbdScanSetup IMPORT HAL_KbdScanDependencies
IMPORT HAL_KbdScanFinish
IMPORT HAL_KbdScan
IMPORT HAL_KbdScanInterrupt
IMPORT HAL_DebugRX IMPORT HAL_DebugRX
IMPORT HAL_DebugTX IMPORT HAL_DebugTX
...@@ -210,8 +207,8 @@ HAL_EntryTable DATA ...@@ -210,8 +207,8 @@ HAL_EntryTable DATA
NullEntry ;HAL_UARTModemControl NullEntry ;HAL_UARTModemControl
NullEntry ;HAL_UARTModemStatus NullEntry ;HAL_UARTModemStatus
NullEntry ;HAL_UARTDevice NullEntry ;HAL_UARTDevice
NullEntry ;HAL_UARTDefault
HALEntry HAL_Reset
HALEntry HAL_DebugRX HALEntry HAL_DebugRX
HALEntry HAL_DebugTX HALEntry HAL_DebugTX
...@@ -232,14 +229,14 @@ HAL_EntryTable DATA ...@@ -232,14 +229,14 @@ HAL_EntryTable DATA
HALEntry HAL_InitDevices HALEntry HAL_InitDevices
HALEntry HAL_KbdScanSetup HALEntry HAL_KbdScanDependencies
HALEntry HAL_KbdScan NullEntry ;Unused
HALEntry HAL_KbdScanFinish NullEntry ;Unused
HALEntry HAL_KbdScanInterrupt NullEntry ;Unused
HALEntry HAL_PhysInfo HALEntry HAL_PhysInfo
NullEntry ;HAL_USBControllerInfo HALEntry HAL_Reset
HALEntry HAL_IRQMax HALEntry HAL_IRQMax
......
...@@ -15,217 +15,20 @@ ...@@ -15,217 +15,20 @@
GET Hdr:ListOpts GET Hdr:ListOpts
GET Hdr:Macros GET Hdr:Macros
GET Hdr:System GET Hdr:System
GET Hdr:Machine.<Machine>
$GetIO
GET Hdr:OSEntries
GET Hdr:HALEntries GET Hdr:HALEntries
GET Hdr:Proc
GET Hdr:DevNos
GET hdr.StaticWS
EXPORT HAL_KbdScanSetup
EXPORT HAL_KbdScanFinish
EXPORT HAL_KbdScan
EXPORT HAL_KbdScanInterrupt
IMPORT HAL_IRQEnable
IMPORT HAL_IRQDisable
IMPORT HAL_IRQClear
AREA |Asm$$Code|, CODE, READONLY, PIC AREA |Asm$$Code|, CODE, READONLY, PIC
; This file contains the minimal PC keyboard control stuff required for the boot-time keyboard scan EXPORT HAL_KbdScanDependencies
; PC command codes we send.
PCReset * &FF ; Outgoing command
; PC keyboard codes we are interested in.
PCSpecial * &E0
PCCTRLL * &14
PCCTRLR * &14 ; Preceded by &E0
PCSHIFTL * &12
PCSHIFTR * &59
PCR * &2D
PCT * &2C
PCDelete * &71 ; Preceded by &E0
PCEnd * &69 ; Preceded by &E0
; How long we're prepared to wait for activity (cs)
TimeoutPost * 75 ; Longest BAT time
TimeoutPress * 50 ; If initial key down missed, wait 1 typematic delay
TimeoutMargin * 75 ; Generous to a fault
KeyData
DCB PCCTRLL, KbdFlag_Ctrl
DCB PCSHIFTL, KbdFlag_Shift
DCB PCSHIFTR, KbdFlag_Shift
DCB PCR, KbdFlag_R
DCB PCT, KbdFlag_T
DCB 0
ALIGN
SpecialData
DCB PCCTRLR, KbdFlag_Ctrl
DCB PCDelete, KbdFlag_Delete
DCB PCEnd, KbdFlag_Copy
DCB 0
ALIGN
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HAL_KbdScanSetup ROUT
EntryS
MRS r0, CPSR
ORR r0, r0, #I32_bit
MSR CPSR_c, r0
LDR r0, IOMD_Address
MOV r1, #IOMD_KBDCR_Enable
STRB r1, [r0, #IOMD_KBDCR]
10
LDRB r1, [r0, #IOMD_KBDCR]
TST r1, #IOMD_KBDCR_TxE
MOVNE r1, #PCReset
STRNEB r1, [r0, #IOCSERTX]
BEQ %BT10
[ MorrisSupport
LDRB r1, [r0, #IOMD_ID0]
LDRB r2, [r0, #IOMD_ID1]
ORR r1, r1, r2, LSL #8
LDR r2, =IOMD_Original
TEQ r1, r2
BEQ %FT30
MOV R1, #IOMD_MSECR_Enable ; 7500(FE), so initialise 2nd PS2 (mouse) port cos
STRB R1, [R0, #IOMD_MSECR] ; keyboard may be connected there instead
20
LDRB R1, [R0, #IOMD_MSECR]
TST R1, #IOMD_MSECR_TxE ; Is port ready to accept data
MOVNE R1, #PCReset ; NE: port ready, so send 'reset' command
STRNEB R1, [R0, #IOMD_MSEDAT] ;
BEQ %BT20 ; EQ: loop til port ready
; Enable mouse RX interrupt
MOV r0, #IOMD_MouseRxFull_DevNo
BL HAL_IRQEnable
MOV R1, #2
STRB R1, KbdPort2Present
30
]
ADR r1, KeyData
STR r1, KbdKeyNumTable
; Enable main keyboard RX interrupt
MOV r0, #IOMD_SerialRx_DevNo
BL HAL_IRQEnable
; And your time starts now
LDR r1, =TimeoutPost + TimeoutPress + TimeoutMargin
STR r1, KbdCountDown
MOV r0, #IOMD_Timer0_DevNo
BL HAL_IRQEnable
EXITS
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HAL_KbdScanFinish ROUT HAL_KbdScanDependencies ROUT
MOV r0, #IOMD_Timer0_DevNo ADR a1, %FT10
B HAL_IRQDisable
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HAL_KbdScan ROUT
; HAL spec says that bits which are reported as being set must
; never be cleared later on. But with MorrisSupport keyboards can
; vanish after being detected; assume that it's not a serious issue
; if a keyboard vanishes before any keys have been pressed
LDR r2, KbdCountDown
LDRB r1, KbdPresentFlags
LDR r0, KbdFlags
CMP r1, #0
ORRNE r0, r0, #KbdFlag_Present
CMP r2, #0
ORREQ r0, r0, #KbdFlag_Done
MOV pc, lr MOV pc, lr
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HAL_KbdScanInterrupt ROUT
Entry
TEQ r0, #IOMD_Timer0_DevNo
BNE %FT3
BL HAL_IRQClear
LDR r1, KbdCountDown
SUBS r1, r1, #1 ; Be a little more patient
STRPL r1, KbdCountDown
B %FT90
3
LDR r2, IOMD_Address
[ MorrisSupport
LDRB r1, KbdPort2Present ; Check if 2nd PS2 port (in Morris) is available
TEQ r1, #0
BEQ %FT4
TEQ r0, #IOMD_MouseRxFull_DevNo
LDREQB r2, [r2, #IOMD_MSEDAT] ; EQ: 2nd port present and interrupting, get scan code
MOVEQ r1, #2 ; EQ: indicate which port
BEQ %FT5 ; EQ: process it
; NE: 2nd port not present or interrupting
; drop through and check 1st port
4
]
TEQ r0, #IOMD_SerialRx_DevNo
EXIT NE ; If not keyboard then exit.
LDRB r2, [r2, #IOCSERRX] ; Get scan code.
[ MorrisSupport
MOV r1, #1
5
LDRB r0, KbdPresentFlags
TEQ r2, #0 ; Assume that zero is the end of a mouse AA 00 start up
BICEQ r0, r0, r1 ; sequence, so clear keyboard present indication.
STREQB r0, KbdPresentFlags
BEQ %FT90 ; and exit
ORR r0, r0, r1 ; Not zero, mark keyboard present
|
MOV r0, #1 ; Medusa keyboard, not a mouse
]
STRB r0, KbdPresentFlags
ADR r1, SpecialData
TEQ r2, #PCSpecial ; If special code then
STREQ r1, KbdKeyNumTable ; switch tables
BEQ %FT90 ; and exit.
LDR r0, KbdKeyNumTable ; Get pointer to current table.
TEQ r0, r1 ; Only use special table once, then
ADREQ r1, KeyData ; switch back to normal table.
STREQ r1, KbdKeyNumTable
10 10
LDRB r1, [r0], #2 ; Get key code from table. ; Modules needed for keyboard scanning, no need to list those
TEQ r1, #0 ; If at end of table then ; before 'FirstUnpluggableModule' since they can't be unplugged
BEQ %FT90 ; ignore key. DCB "PS2Driver,InternationalKeyboard", 0
TEQ r1, r2 ; If not this key then
BNE %BT10 ; try the next.
LDRB r1, [r0, #-1] ; Get flag.
LDR r3, KbdFlags
ORR r3, r3, #KbdFlag_Present :OR: KbdFlag_Done ; End the scan if we got a valid key
ORR r3, r3, r1
STR r3, KbdFlags
90
MOV r0, #-1 ; IRQ handled
EXIT
END END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment