From: Jan Kiszka <[email protected]>

Fill in the missing pieces to enable interrupt handling also in 32-bit
inmates.

Signed-off-by: Jan Kiszka <[email protected]>
---
 inmates/lib/x86/Makefile |  4 ++--
 inmates/lib/x86/int.c    | 26 +++++++++++++++++++++++---
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/inmates/lib/x86/Makefile b/inmates/lib/x86/Makefile
index 97a37341..dc017b90 100644
--- a/inmates/lib/x86/Makefile
+++ b/inmates/lib/x86/Makefile
@@ -40,10 +40,10 @@ include $(INMATES_LIB)/Makefile.lib

 always := lib.a lib32.a

-TARGETS := header.o ioapic.o printk.o setup.o smp.o uart.o
+TARGETS := header.o ioapic.o printk.o setup.o smp.o uart.o int.o
 TARGETS += ../alloc.o ../pci.o ../string.o ../cmdline.o ../setup.o
 TARGETS += ../uart-8250.o ../printk.o
-TARGETS_64_ONLY := int.o mem.o pci.o timing.o
+TARGETS_64_ONLY := mem.o pci.o timing.o

 lib-y := $(TARGETS) $(TARGETS_64_ONLY)

diff --git a/inmates/lib/x86/int.c b/inmates/lib/x86/int.c
index e85e3e12..663fa65e 100644
--- a/inmates/lib/x86/int.c
+++ b/inmates/lib/x86/int.c
@@ -63,7 +63,6 @@ void int_set_handler(unsigned int vector, int_handler_t 
handler)
        idt[vector * 2 + 1] = entry >> 32;
 }

-#ifdef __x86_64__
 asm(
 ".macro eoi\n\t"
        /* write 0 as ack to x2APIC EOI register (0x80b) */
@@ -74,8 +73,13 @@ asm(
 ".endm\n"

 ".macro irq_prologue irq\n\t"
+#ifdef __x86_64__
        "push %rax\n\t"
        "mov $irq * 8,%rax\n\t"
+#else
+       "push %eax\n\t"
+       "mov $irq * 4,%eax\n\t"
+#endif
        "jmp irq_common\n"
        ".balign 16\n"
 ".endm\n\t"
@@ -90,6 +94,7 @@ asm(
 ".endr\n"

 "irq_common:\n\t"
+#ifdef __x86_64__
        "push %rcx\n\t"
        "push %rdx\n\t"
        "push %rsi\n\t"
@@ -114,10 +119,25 @@ asm(
        "pop %rax\n\t"

        "iretq"
-);
 #else
-#error implement me!
+       "push %ecx\n\t"
+       "push %edx\n\t"
+       "push %esi\n\t"
+       "push %edi\n\t"
+
+       "call *int_handler(%eax)\n\t"
+
+       "eoi\n\t"
+
+       "pop %edi\n\t"
+       "pop %esi\n\t"
+       "pop %edx\n\t"
+       "pop %ecx\n\t"
+       "pop %eax\n\t"
+
+       "iret"
 #endif
+);

 void int_send_ipi(unsigned int cpu_id, unsigned int vector)
 {
--
2.16.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/d51321d5ed55d50057666d0af7c5ce1cc89d6621.1557914551.git.jan.kiszka%40web.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to