From: Kevin O'Connor Date: Sun, 17 May 2009 03:31:27 +0000 (-0400) Subject: Define unified entry points for irq handlers. X-Git-Tag: rel-0.4.1~63 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9f193b9883da62105238c9b5e199e28508748f09;p=seabios.git Define unified entry points for irq handlers. The irq entry points now push the handler address and jump to a function that does parameter setup. This reduces the code size because the entry setup isn't repeated for every handler. --- diff --git a/src/entryfuncs.S b/src/entryfuncs.S index ad0c79d..96a2fcf 100644 --- a/src/entryfuncs.S +++ b/src/entryfuncs.S @@ -33,6 +33,29 @@ popl %eax .endm + // As above, but get calling function from stack. + .macro ENTRY_ST + cli + cld + pushl %ecx + pushl %edx + pushw %es + pushw %ds + movw %ss, %cx // Move %ss to %ds + movw %cx, %ds + pushl %esp // Backup %esp, then clear high bits + movzwl %sp, %esp + movl 16(%esp), %ecx // Get calling function + movl %eax, 16(%esp) // Save %eax + calll *%ecx + popl %esp // Restore %esp (including high bits) + popw %ds // Restore registers saved above + popw %es + popl %edx + popl %ecx + popl %eax + .endm + // Call a C function with current register list as an // argument. This backs up the registers and sets %eax // to point to the backup. On return, the registers are @@ -65,7 +88,37 @@ popl %eax .endm - // As above, but don't mangle %esp + // As above, but get calling function from stack. + .macro ENTRY_ARG_ST + cli + cld + pushl %ecx + pushl %edx + pushl %ebx + pushl %esi + pushl %edi + pushw %es + pushw %ds + movw %ss, %cx // Move %ss to %ds + movw %cx, %ds + movl %esp, %ebx // Backup %esp, then zero high bits + movzwl %sp, %esp + movl 24(%esp), %ecx // Get calling function + movl %eax, 24(%esp) // Save %eax + movl %esp, %eax // First arg is pointer to struct bregs + calll *%ecx + movl %ebx, %esp // Restore %esp (including high bits) + popw %ds // Restore registers (from struct bregs) + popw %es + popl %edi + popl %esi + popl %ebx + popl %edx + popl %ecx + popl %eax + .endm + + // Same as ENTRY_ARG, but don't mangle %esp .macro ENTRY_ARG_ESP cfunc cli cld @@ -106,29 +159,3 @@ .section .text.asm.\func .global \func .endm - - // Define an entry point for an interrupt (no args passed). - .macro IRQ_ENTRY num - .global entry_\num - entry_\num : - ENTRY handle_\num - iretw - .endm - - // Define an entry point for an interrupt (can read/modify args). - .macro IRQ_ENTRY_ARG num - .global entry_\num - entry_\num : - ENTRY_ARG handle_\num - iretw - .endm - - // Macros that put each handler into its own section - .macro DECL_IRQ_ENTRY num - .section .text.asm.entry_\num - IRQ_ENTRY \num - .endm - .macro DECL_IRQ_ENTRY_ARG num - .section .text.asm.entry_\num - IRQ_ENTRY_ARG \num - .endm diff --git a/src/post.c b/src/post.c index f961cd8..a642e18 100644 --- a/src/post.c +++ b/src/post.c @@ -49,8 +49,8 @@ init_ivt() // Initialize software handlers. set_irq(0x02, entry_02); set_irq(0x10, entry_10); - set_irq(0x11, entry_11_official); - set_irq(0x12, entry_12_official); + set_irq(0x11, entry_11); + set_irq(0x12, entry_12); set_irq(0x13, entry_13_official); set_irq(0x14, entry_14); set_irq(0x15, entry_15); diff --git a/src/romlayout.S b/src/romlayout.S index 736dc9b..f354c74 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -347,9 +347,45 @@ post32: * Interrupt entry points ****************************************************************/ + // Define an entry point for an interrupt (no args passed). + .macro IRQ_ENTRY num + .global entry_\num + entry_\num : + pushl $ handle_\num + jmp irqentry + .endm + + // Define an entry point for an interrupt (can read/modify args). + .macro IRQ_ENTRY_ARG num + .global entry_\num + entry_\num : + pushl $ handle_\num + jmp irqentryarg + .endm + + // Macros that put each handler into its own section + .macro DECL_IRQ_ENTRY num + DECLFUNC entry_\num + IRQ_ENTRY \num + .endm + .macro DECL_IRQ_ENTRY_ARG num + DECLFUNC entry_\num + IRQ_ENTRY_ARG \num + .endm + + // Main entry point for interrupts without args + DECLFUNC irqentry +irqentry: + ENTRY_ST + iretw + + // Main entry point for interrupts with args + DECLFUNC irqentry +irqentryarg: + ENTRY_ARG_ST + iretw + DECL_IRQ_ENTRY_ARG 13 - DECL_IRQ_ENTRY_ARG 12 - DECL_IRQ_ENTRY_ARG 11 DECL_IRQ_ENTRY 76 DECL_IRQ_ENTRY 70 DECL_IRQ_ENTRY 74 @@ -430,14 +466,10 @@ entry_10_0x0f: // 0xf0a4 - VideoParams in misc.c ORG 0xf841 - .global entry_12_official -entry_12_official: - jmp entry_12 + IRQ_ENTRY_ARG 12 ORG 0xf84d - .global entry_11_official -entry_11_official: - jmp entry_11 + IRQ_ENTRY_ARG 11 ORG 0xf859 IRQ_ENTRY_ARG 15 diff --git a/vgasrc/vgaentry.S b/vgasrc/vgaentry.S index 48264cf..7802bdb 100644 --- a/vgasrc/vgaentry.S +++ b/vgasrc/vgaentry.S @@ -40,4 +40,7 @@ _optionrom_entry: ENTRY_ARG vga_post lretw - DECL_IRQ_ENTRY_ARG 10 + DECLFUNC entry_10 +entry_10: + ENTRY_ARG handle_10 + iretw