]> xenbits.xensource.com Git - seabios.git/commitdiff
Define unified entry points for irq handlers.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 17 May 2009 03:31:27 +0000 (23:31 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 17 May 2009 03:31:27 +0000 (23:31 -0400)
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.

src/entryfuncs.S
src/post.c
src/romlayout.S
vgasrc/vgaentry.S

index ad0c79d2eff64ac8770aeab1a085360686ccdd11..96a2fcfc77958594529f3d6d165a3bc79238ebd0 100644 (file)
         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
         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
         .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
index f961cd8b4603fcb2b30df44ce742c889674bab32..a642e182a53d03290a794d45b11c6a53ed0d2a57 100644 (file)
@@ -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);
index 736dc9b31be8fc4a9e96736200e08e74014ffb71..f354c74a519dc0a6e12e298b9d70d4bdc037c9f2 100644 (file)
@@ -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
index 48264cf6ae28f7ff91845c989cfa60b0f1bdebf9..7802bdb52765896b8a50a3d5f446768e1b0eb780 100644 (file)
@@ -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