[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH ARM v3 4/7] mini-os: moved events code under arch



From: Karim Raslan <karim.allah.ahmed@xxxxxxxxx>

This is all code motion, except that we now initialise
the ev_actions array before calling the arch-specific code
to make it more robust against future changes.

Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@xxxxxxxxx>
[talex5@xxxxxxxxx: separated from big ARM commit]
Signed-off-by: Thomas Leonard <talex5@xxxxxxxxx>
---
 extras/mini-os/arch/x86/events.c | 31 +++++++++++++++++++++++++++++++
 extras/mini-os/events.c          | 24 ++++--------------------
 extras/mini-os/include/events.h  |  3 +++
 3 files changed, 38 insertions(+), 20 deletions(-)
 create mode 100644 extras/mini-os/arch/x86/events.c

diff --git a/extras/mini-os/arch/x86/events.c b/extras/mini-os/arch/x86/events.c
new file mode 100644
index 0000000..e420a98
--- /dev/null
+++ b/extras/mini-os/arch/x86/events.c
@@ -0,0 +1,31 @@
+#include <mini-os/os.h>
+#include <mini-os/mm.h>
+#include <mini-os/events.h>
+
+#if defined(__x86_64__)
+char irqstack[2 * STACK_SIZE];
+
+static struct pda
+{
+    int irqcount;       /* offset 0 (used in x86_64.S) */
+    char *irqstackptr;  /*        8 */
+} cpu0_pda;
+#endif
+
+void arch_init_events(void)
+{
+#if defined(__x86_64__)
+    asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
+    wrmsrl(0xc0000101, &cpu0_pda); /* 0xc0000101 is MSR_GS_BASE */
+    cpu0_pda.irqcount = -1;
+    cpu0_pda.irqstackptr = (void*) (((unsigned long)irqstack + 2 * STACK_SIZE)
+                                    & ~(STACK_SIZE - 1));
+#endif
+}
+
+void arch_fini_events(void)
+{
+#if defined(__x86_64__)
+    wrmsrl(0xc0000101, NULL); /* 0xc0000101 is MSR_GS_BASE */
+#endif
+}
diff --git a/extras/mini-os/events.c b/extras/mini-os/events.c
index 2da9b01..d60630b 100644
--- a/extras/mini-os/events.c
+++ b/extras/mini-os/events.c
@@ -167,44 +167,28 @@ evtchn_port_t bind_pirq(uint32_t pirq, int will_share,
        return op.port;
 }
 
-#if defined(__x86_64__)
-char irqstack[2 * STACK_SIZE];
-
-static struct pda
-{
-    int irqcount;       /* offset 0 (used in x86_64.S) */
-    char *irqstackptr;  /*        8 */
-} cpu0_pda;
-#endif
-
 /*
  * Initially all events are without a handler and disabled
  */
 void init_events(void)
 {
     int i;
-#if defined(__x86_64__)
-    asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
-    wrmsrl(0xc0000101, &cpu0_pda); /* 0xc0000101 is MSR_GS_BASE */
-    cpu0_pda.irqcount = -1;
-    cpu0_pda.irqstackptr = (void*) (((unsigned long)irqstack + 2 * STACK_SIZE)
-                                    & ~(STACK_SIZE - 1));
-#endif
+
     /* initialize event handler */
     for ( i = 0; i < NR_EVS; i++ )
        {
         ev_actions[i].handler = default_handler;
         mask_evtchn(i);
     }
+
+    arch_init_events();
 }
 
 void fini_events(void)
 {
     /* Dealloc all events */
     unbind_all_ports();
-#if defined(__x86_64__)
-    wrmsrl(0xc0000101, NULL); /* 0xc0000101 is MSR_GS_BASE */
-#endif
+    arch_fini_events();
 }
 
 void default_handler(evtchn_port_t port, struct pt_regs *regs, void *ignore)
diff --git a/extras/mini-os/include/events.h b/extras/mini-os/include/events.h
index 0e9d3a7..0452d21 100644
--- a/extras/mini-os/include/events.h
+++ b/extras/mini-os/include/events.h
@@ -25,6 +25,9 @@
 typedef void (*evtchn_handler_t)(evtchn_port_t, struct pt_regs *, void *);
 
 /* prototypes */
+void arch_init_events(void);
+void arch_fini_events(void);
+
 int do_event(evtchn_port_t port, struct pt_regs *regs);
 evtchn_port_t bind_virq(uint32_t virq, evtchn_handler_t handler, void *data);
 evtchn_port_t bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t 
handler, void *data);
-- 
2.0.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.