Skip to content

Commit b596dfa

Browse files
author
Ian Seyler
committed
Configure PS/2 only if it is present
1 parent aad8159 commit b596dfa

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/drivers/ps2.asm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
; -----------------------------------------------------------------------------
1010
ps2_init:
11+
; Check if PS/2 is present via ACPI IAPC_BOOT_ARCH
12+
mov ax, [os_boot_arch]
13+
bt ax, 1 ; 8042
14+
jnc ps2_init_error
15+
1116
call ps2_flush ; Read any pending data
1217

1318
; Disable keyboard
@@ -62,6 +67,7 @@ ps2_init:
6267
call ps2_mouse_init
6368

6469
; Set flag that the PS/2 keyboard was enabled
70+
; TODO - Move to a ps2_keyboard_init function
6571
or qword [os_SysConfEn], 1 << 0
6672

6773
ps2_init_error:

src/init/64.asm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ init_64:
5555
mov esi, 0x00005090 ; PCIe bus count
5656
lodsw
5757
mov [os_pcie_count], ax
58+
lodsw
59+
mov [os_boot_arch], ax
5860
xor eax, eax
5961
mov esi, 0x00005604 ; IOAPIC
6062
lodsd
@@ -101,13 +103,22 @@ make_interrupt_gate_stubs:
101103
dec ecx
102104
jnz make_interrupt_gate_stubs
103105

104-
; Set up the IRQ handlers (Network IRQ handler is configured in init_net)
106+
; Set up the IRQ handlers on enabled PS/2 devices
107+
mov rbx, [os_SysConfEn]
108+
bt ebx, 0
109+
jnc init_64_no_ps2keyboard
105110
mov edi, 0x21
106111
mov rax, int_keyboard
107112
call create_gate
113+
init_64_no_ps2keyboard:
114+
bt ebx, 0
115+
jnc init_64_no_ps2mouse
108116
mov edi, 0x2C
109117
mov rax, int_mouse
110118
call create_gate
119+
init_64_no_ps2mouse:
120+
121+
; Set up IRQ handlers for CPUs
111122
mov edi, 0x80
112123
mov rax, ap_wakeup
113124
call create_gate

src/sysvar.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ os_ps2_mouse_buttons: equ os_SystemVariables + 0x0218 ; Button state, bit 0 - le
132132
os_ps2_mouse_x: equ os_SystemVariables + 0x021A ; Cursor screen position on X axis
133133
os_ps2_mouse_y: equ os_SystemVariables + 0x021C ; Cursor screen position on Y axis
134134
os_ps2_mouse_count: equ os_SystemVariables + 0x021E ; Byte counter
135+
os_boot_arch: equ os_SystemVariables + 0x0220 ; Bit 0 set for legacy ports, bit 1 set for 60/64 support
135136

136137

137138
; DB - Starting at offset 768, increments by 1

0 commit comments

Comments
 (0)