diff options
author | Ian Moffett <ian@osmora.org> | 2025-04-17 03:07:31 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-04-17 03:08:45 -0400 |
commit | 4993119967d71c190aa806f63c2931a39fa37e87 (patch) | |
tree | c3f6562c115148d1d713d63d3ea01f1b85a88551 /sys/arch/amd64/amd64 | |
parent | e33d2a6430016dbb5973aa6a6ffac04ff29a664c (diff) |
kernel/amd64: isa: Add i8042 keyboard support
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/lapic_intr.S | 5 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 2 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/trap.c | 20 |
3 files changed, 25 insertions, 2 deletions
diff --git a/sys/arch/amd64/amd64/lapic_intr.S b/sys/arch/amd64/amd64/lapic_intr.S index ab6f5ab..e22cbca 100644 --- a/sys/arch/amd64/amd64/lapic_intr.S +++ b/sys/arch/amd64/amd64/lapic_intr.S @@ -33,6 +33,7 @@ .globl lapic_tmr_isr INTRENTRY(lapic_tmr_isr, handle_lapic_tmr) handle_lapic_tmr: - call sched_switch - call lapic_eoi + call sched_switch // Context switch per every timer IRQ + call i8042_sync // Sometimes needed depending on i8042 quirks + call lapic_eoi // Done! Signal that we finished to the Local APIC retq diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index df6d341..07d6cdd 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -42,6 +42,7 @@ #include <machine/uart.h> #include <machine/sync.h> #include <machine/intr.h> +#include <machine/isa/i8042var.h> #if defined(__SPECTRE_IBRS) #define SPECTRE_IBRS __SPECTRE_IBRS @@ -215,6 +216,7 @@ int md_sync_all(void) { lapic_eoi(); + i8042_sync(); return 0; } diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 29056b0..9a3a7ba 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -35,6 +35,8 @@ #include <sys/syscall.h> #include <sys/sched.h> #include <sys/proc.h> +#include <machine/cpu.h> +#include <machine/isa/i8042var.h> #include <machine/trap.h> #include <machine/frame.h> #include <machine/intr.h> @@ -118,6 +120,20 @@ trap_user(struct trapframe *tf) dispatch_signals(td); } +static void +trap_quirks(struct cpu_info *ci) +{ + static uint8_t count; + + if (ISSET(ci->irq_mask, CPU_IRQ(1)) && count < 1) { + ++count; + pr_error("detected buggy i8042\n"); + pr_error("applying I8042_HOSTILE quirk\n"); + i8042_quirk(I8042_HOSTILE); + return; + } +} + void trap_syscall(struct trapframe *tf) { @@ -139,6 +155,8 @@ trap_syscall(struct trapframe *tf) void trap_handler(struct trapframe *tf) { + struct cpu_info *ci; + splraise(IPL_HIGH); if (tf->trapno >= NELEM(trap_type)) { @@ -146,6 +164,8 @@ trap_handler(struct trapframe *tf) } pr_error("got %s\n", trap_type[tf->trapno]); + ci = this_cpu(); + trap_quirks(ci); /* Handle traps from userland */ if (ISSET(tf->cs, 3)) { |