From cdb8b09f6b67b270b1c21f1a7f42d5e8a604caa8 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 9 Sep 2005 09:24:25 +0000 Subject: Xenbus implementation ported from Linux to Mini-os, simple thread support introduced to simplify the porting. 64 bit version of Mini-os now compiles, but does not work because of the pagetables and some bits of scheduler not being written. Signed-off-by: Grzegorz Milos --- extras/mini-os/events.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'extras/mini-os/events.c') diff --git a/extras/mini-os/events.c b/extras/mini-os/events.c index 8ca49d284b..5263c8757e 100644 --- a/extras/mini-os/events.c +++ b/extras/mini-os/events.c @@ -17,13 +17,13 @@ */ #include +#include #include #include #include -#include static ev_action_t ev_actions[NR_EVS]; -void default_handler(u32 port, struct pt_regs *regs); +void default_handler(int port, struct pt_regs *regs); /* @@ -32,7 +32,6 @@ void default_handler(u32 port, struct pt_regs *regs); int do_event(u32 port, struct pt_regs *regs) { ev_action_t *action; - if (port >= NR_EVS) { printk("Port number too large: %d\n", port); return 0; @@ -57,11 +56,23 @@ int do_event(u32 port, struct pt_regs *regs) } +void bind_evtchn( u32 port, void (*handler)(int, struct pt_regs *) ) +{ + if(ev_actions[port].handler) + printk("WARN: Handler for port %d already registered, replacing\n", + port); + + ev_actions[port].handler = handler; + ev_actions[port].status &= ~EVS_DISABLED; + + /* Finally unmask the port */ + unmask_evtchn(port); +} + int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *) ) { evtchn_op_t op; int ret = 0; - u32 port; /* Try to bind the virq to a port */ op.cmd = EVTCHNOP_bind_virq; @@ -73,22 +84,13 @@ int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *) ) printk("Failed to bind virtual IRQ %d\n", virq); goto out; } - - port = op.u.bind_virq.port; - - if(ev_actions[port].handler) - printk("WARN: Handler for port %d already registered, replacing\n", - port); - - ev_actions[port].handler = handler; - ev_actions[port].status &= ~EVS_DISABLED; - - /* Finally unmask the port */ - unmask_evtchn(port); + bind_evtchn(op.u.bind_virq.port, handler); out: return ret; } + + /* * Initially all events are without a handler and disabled */ @@ -100,10 +102,10 @@ void init_events(void) for ( i = 0; i < NR_EVS; i++ ) { ev_actions[i].status = EVS_DISABLED; - ev_actions[i].handler = NULL; + ev_actions[i].handler = default_handler; } } -void default_handler(u32 port, struct pt_regs *regs) { +void default_handler(int port, struct pt_regs *regs) { printk("[Port %d] - event received\n", port); } -- cgit v1.2.3