Hi, some mainboards may want to add their own interrupt handler code to YABEL, these patches allow them to do that... Stefan has already tried this out.
The mainboards will implement their own versions of interrupt handlers and add their handlers into the intFuncArray, sample code is provided in patch 0002 Signed-off-by: Pattrick Hueper <[email protected]> Cheers, Patty
From 49060ac0a31d7bea7202ad44949d609a9210641c Mon Sep 17 00:00:00 2001 From: Pattrick Hueper <[email protected]> Date: Thu, 26 Feb 2009 09:50:58 +0100 Subject: [PATCH 1/5] add intFuncArray to be able to override INT handlers from YABEL caller Signed-off-by: Pattrick Hueper <[email protected]> --- util/x86emu/yabel/biosemu.c | 3 + util/x86emu/yabel/biosemu.h | 8 ++++ util/x86emu/yabel/interrupt.c | 91 ++++++++++++++++++++++------------------- 3 files changed, 60 insertions(+), 42 deletions(-) diff --git a/util/x86emu/yabel/biosemu.c b/util/x86emu/yabel/biosemu.c index 27387d0..4491479 100644 --- a/util/x86emu/yabel/biosemu.c +++ b/util/x86emu/yabel/biosemu.c @@ -52,6 +52,9 @@ static X86EMU_pioFuncs my_pio_funcs = { my_outb, my_outw, my_outl }; +/* interrupt function override array (see biosemu.h) */ +yabel_handleIntFunc yabel_intFuncArray[256]; + void dump(u8 * addr, u32 len); /* main entry into YABEL biosemu, arguments are: diff --git a/util/x86emu/yabel/biosemu.h b/util/x86emu/yabel/biosemu.h index 7ffd5bc..20aff6f 100644 --- a/util/x86emu/yabel/biosemu.h +++ b/util/x86emu/yabel/biosemu.h @@ -37,4 +37,12 @@ // Address, there will only be a call to this INT and a RETF #define PNP_INT_NUM 0xFD +/* array of funtion pointers to override generic interrupt handlers + * a YABEL caller can add functions to this array before calling YABEL + * if a interrupt occurs, YABEL checks wether a function is set in + * this array and only runs the generic interrupt handler code, if + * the function pointer is NULL */ +typedef int (* yabel_handleIntFunc)(void); +extern yabel_handleIntFunc yabel_intFuncArray[256]; + #endif diff --git a/util/x86emu/yabel/interrupt.c b/util/x86emu/yabel/interrupt.c index 62f8c25..254334c 100644 --- a/util/x86emu/yabel/interrupt.c +++ b/util/x86emu/yabel/interrupt.c @@ -518,54 +518,61 @@ handleInterrupt(int intNum) // so we only enable it, if int10 print is disabled DEBUG_PRINTF_INTR("%s(%x)\n", __func__, intNum); #endif - switch (intNum) { - case 0x10: //BIOS video interrupt - case 0x42: // INT 10h relocated by EGA/VGA BIOS - case 0x6d: // INT 10h relocated by VGA BIOS - // get interrupt vector from IDT (4 bytes per Interrupt starting at address 0 - if ((my_rdl(intNum * 4) == 0xF000F065) || //F000:F065 is default BIOS interrupt handler address - (my_rdl(intNum * 4) == 0xF4F4F4F4)) //invalid - { + + /* check wether this interrupt has a function pointer set in yabel_intFuncArray and run that */ + if (yabel_intFuncArray[intNum]) { + DEBUG_PRINTF_INTR("%s(%x) intHandler overridden, calling it...\n", __func__, intNum); + int_handled = (*yabel_intFuncArray[intNum])(); + } else { + switch (intNum) { + case 0x10: //BIOS video interrupt + case 0x42: // INT 10h relocated by EGA/VGA BIOS + case 0x6d: // INT 10h relocated by VGA BIOS + // get interrupt vector from IDT (4 bytes per Interrupt starting at address 0 + if ((my_rdl(intNum * 4) == 0xF000F065) || //F000:F065 is default BIOS interrupt handler address + (my_rdl(intNum * 4) == 0xF4F4F4F4)) //invalid + { #if 0 - // ignore interrupt... - DEBUG_PRINTF_INTR - ("%s(%x): invalid interrupt Vector (%08x) found, interrupt ignored...\n", - __func__, intNum, my_rdl(intNum * 4)); + // ignore interrupt... + DEBUG_PRINTF_INTR + ("%s(%x): invalid interrupt Vector (%08x) found, interrupt ignored...\n", + __func__, intNum, my_rdl(intNum * 4)); + DEBUG_PRINTF_INTR("AX=%04x BX=%04x CX=%04x DX=%04x\n", + M.x86.R_AX, M.x86.R_BX, M.x86.R_CX, + M.x86.R_DX); + //HALT_SYS(); +#endif + handleInt10(); + int_handled = 1; + } + break; + case 0x16: + // Keyboard BIOS Interrupt + handleInt16(); + int_handled = 1; + break; + case 0x1a: + // PCI BIOS Interrupt + handleInt1a(); + int_handled = 1; + break; + case PMM_INT_NUM: + /* the selfdefined PMM INT number, this is called by the code in PMM struct, it + * is handled by pmm_handleInt() + */ + pmm_handleInt(); + int_handled = 1; + break; + default: + printf("Interrupt %#x (Vector: %x) not implemented\n", intNum, + my_rdl(intNum * 4)); DEBUG_PRINTF_INTR("AX=%04x BX=%04x CX=%04x DX=%04x\n", M.x86.R_AX, M.x86.R_BX, M.x86.R_CX, M.x86.R_DX); - //HALT_SYS(); -#endif - handleInt10(); int_handled = 1; + HALT_SYS(); + break; } - break; - case 0x16: - // Keyboard BIOS Interrupt - handleInt16(); - int_handled = 1; - break; - case 0x1a: - // PCI BIOS Interrupt - handleInt1a(); - int_handled = 1; - break; - case PMM_INT_NUM: - /* the selfdefined PMM INT number, this is called by the code in PMM struct, it - * is handled by pmm_handleInt() - */ - pmm_handleInt(); - int_handled = 1; - break; - default: - printf("Interrupt %#x (Vector: %x) not implemented\n", intNum, - my_rdl(intNum * 4)); - DEBUG_PRINTF_INTR("AX=%04x BX=%04x CX=%04x DX=%04x\n", - M.x86.R_AX, M.x86.R_BX, M.x86.R_CX, - M.x86.R_DX); - int_handled = 1; - HALT_SYS(); - break; } // if we did not handle the interrupt, jump to the interrupt vector... if (!int_handled) { -- 1.6.2
From 375fc42720a6f0cd1bbb09bb200cad4bdc005af2 Mon Sep 17 00:00:00 2001 From: Pattrick Hueper <[email protected]> Date: Thu, 26 Feb 2009 09:52:32 +0100 Subject: [PATCH 2/5] test code for YABEL intFuncArray functionality Signed-off-by: Pattrick Hueper <[email protected]> --- device/pci_device.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/device/pci_device.c b/device/pci_device.c index c5cee3c..4e733bc 100644 --- a/device/pci_device.c +++ b/device/pci_device.c @@ -733,6 +733,17 @@ void pci_dev_init(struct device *dev) { printk(BIOS_SPEW, "PCI: pci_dev_init %s\n", dev->dtsname); #ifdef CONFIG_PCI_OPTION_ROM_RUN + int dummy_handleInt10(void) { + printk(BIOS_SPEW, "%s\n", __func__); + return 1; + } +#if 0 + //debug code + typedef int (* yabel_handleIntFunc)(void); + extern yabel_handleIntFunc yabel_intFuncArray[256]; + yabel_intFuncArray[0x10] = dummy_handleInt10; +#endif + void run_bios(struct device *dev, unsigned long addr); struct rom_header *rom, *ram; -- 1.6.2
-- coreboot mailing list: [email protected] http://www.coreboot.org/mailman/listinfo/coreboot

