From 9b0fcbab20f536bd05b034aad6bcad170fe9dea3 Mon Sep 17 00:00:00 2001 From: Sam Tebbs Date: Mon, 1 Jul 2019 21:48:04 +0100 Subject: [PATCH] Add arch.registerInterruptHandler --- src/kernel/arch/x86/arch.zig | 11 +++++++++++ test/kernel/arch_mock.zig | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/src/kernel/arch/x86/arch.zig b/src/kernel/arch/x86/arch.zig index 6789c5b..e5aad02 100644 --- a/src/kernel/arch/x86/arch.zig +++ b/src/kernel/arch/x86/arch.zig @@ -178,3 +178,14 @@ pub fn haltNoInterrupts() noreturn { halt(); } } + +/// +/// Register an interrupt handler. The interrupt number should be the arch-specific number. +/// +/// Arguments: +/// IN int: u16 - The arch-specific interrupt number to register for. +/// IN handler: fn (ctx: *InterruptContext) void - The handler to assign to the interrupt. +/// +pub fn registerInterruptHandler(int: u16, handler: fn (ctx: *InterruptContext) void) void { + irq.registerIrq(int, handler); +} diff --git a/test/kernel/arch_mock.zig b/test/kernel/arch_mock.zig index 30dcaa6..854dc3b 100644 --- a/test/kernel/arch_mock.zig +++ b/test/kernel/arch_mock.zig @@ -30,3 +30,12 @@ pub fn inb(port: u16) u8 {return 0;} /// event being waited. /// pub fn ioWait() void {} + +/// +/// Register an interrupt handler. The interrupt number should be the arch-specific number. +/// +/// Arguments: +/// IN int: u16 - The arch-specific interrupt number to register for. +/// IN handler: fn (ctx: *InterruptContext) void - The handler to assign to the interrupt. +/// +pub fn registerInterruptHandler(int: u16, ctx: fn (ctx: *InterruptContext) void) void {}