Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/28100
Change subject: libpayload/x86/exception: Add ability to handle user defined interrupts ......................................................................
libpayload/x86/exception: Add ability to handle user defined interrupts
I need to setup the APIC timer to fire interrupts. I would like to reuse the existing interrupt table. So I extended it to support user defined interrupts. I just added all 255 vectors so there wouldn't need to be any additional build time configuration.
BUG=b:109749762 TEST=Wrote an interrupt handler and fired an APIC timer interrupt and verified that vector 32 was returned.
Change-Id: Id9c2583c7c3d9be4a06a25e546e64399f2b0620c Signed-off-by: Raul E Rangel rrangel@chromium.org --- M payloads/libpayload/arch/x86/exception.c M payloads/libpayload/arch/x86/exception_asm.S 2 files changed, 34 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/00/28100/1
diff --git a/payloads/libpayload/arch/x86/exception.c b/payloads/libpayload/arch/x86/exception.c index b562660..c9ab6bf 100644 --- a/payloads/libpayload/arch/x86/exception.c +++ b/payloads/libpayload/arch/x86/exception.c @@ -161,7 +161,15 @@ void exception_dispatch(void) { u32 vec = exception_state->vector; - die_if(vec >= EXC_COUNT || !names[vec], "Bad exception vector %u", vec); + + /* Handle user defined vectors */ + if (vec >= 32 && vec <= 255) { + die_if(!hook || !hook(vec), + "Hook required to handle user defined vector %u\n", vec); + } + + die_if(vec >= EXC_COUNT || !names[vec], "Bad exception vector %u\n", + vec);
if (hook && hook(vec)) return; diff --git a/payloads/libpayload/arch/x86/exception_asm.S b/payloads/libpayload/arch/x86/exception_asm.S index a8f9a1d..5bbe69e 100644 --- a/payloads/libpayload/arch/x86/exception_asm.S +++ b/payloads/libpayload/arch/x86/exception_asm.S @@ -68,6 +68,14 @@ jmp exception_common .endm
+ .altmacro + .macro user_defined_stubs from, to + stub \from + .if \to-\from + user_defined_stubs %(from+1),\to + .endif + .endm + stub 0 stub 1 stub 2 @@ -100,6 +108,11 @@ stub 29 stub_err 30 stub 31 + /* Split the macro so we avoid a stack overflow. */ + user_defined_stubs 32, 63 + user_defined_stubs 64, 127 + user_defined_stubs 128, 191 + user_defined_stubs 192, 255
exception_common: /* @@ -215,6 +228,14 @@ .long \target .endm
+ .altmacro + .macro user_defined_gates from, to + interrupt_gate exception_stub_\from + .if \to-\from + user_defined_gates %(from+1),\to + .endif + .endm + .align 8 .global idt idt: @@ -250,6 +271,10 @@ interrupt_gate exception_stub_29 interrupt_gate exception_stub_30 interrupt_gate exception_stub_31 + user_defined_gates 32, 63 + user_defined_gates 64, 127 + user_defined_gates 128, 191 + user_defined_gates 192, 255 idt_end:
/* IDT pointer for use with lidt */