Updated Xenbus for the Mini-OS
PATCH 1/1 Updated Xenbus for the Mini-OS
Hello!
I merged in the newer Xenbus implementation from Linux to the Mini-OS. The new version compiles and starts up, but I'm not really sure how to test the new xenbus implementation. Anyway, the changes I made to the Mini-OS are:
* Added unbind_evtchn
* Copied parts of the Linux spinlock implementation to make the changes to xenbus compared to Linux smaller. Also added a dummy rwsem implementation.
* Updated the xenbus-files
I've attached the somewhat length patch to this mail. If someone would like to review the Xenbus changes, I guess it's better to diff the mini-os/xenbus-directory against drivers/xen/xenbus in the Linux implementation.
Signature · 1 line
// Simon
extras/mini-os/events.c +15 -1
@@ -56,7 +56,7 @@ } -void bind_evtchn (u32 port,void (*handler)(int ,struct pt_regs *) ) +int 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",
@@ -67,6 +67,16 @@/* Finally unmask the port */ unmask_evtchn (port); + +return port; +} + +void unbind_evtchn (u32 port ) +{ +if (!ev_actions[port].handler) +printk ("WARN: No handler for port %d when unbinding\n" , port); + ev_actions[port].handler =NULL ; + ev_actions[port].status |=EVS_DISABLED ; }int bind_virq (u32 virq,void (*handler)(int ,struct pt_regs *) )
@@ -90,6 +100,10 @@return ret; } +void unbind_virq (u32 port ) +{ +unbind_evtchn (port); +}/*
extras/mini-os/include/events.h +4 -2
@@ -40,10 +40,12 @@/* prototypes */ int do_event (u32 port,struct pt_regs *regs);int bind_virq (u32 virq,void (*handler)(int ,struct pt_regs *) ); -void bind_evtchn (u32 virq,void (*handler)(int ,struct pt_regs *) ); +int bind_evtchn (u32 virq,void (*handler)(int ,struct pt_regs *) ); +void unbind_evtchn (u32 port );void init_events (void ); +void unbind_virq (u32 port ); -static inline int notify_via_evtchn (int port) +static inline int notify_remote_via_evtchn (int port) {evtchn_op_t op; op.cmd = EVTCHNOP_send;
extras/mini-os/include/os.h +2 -0
@@ -131,9 +131,11 @@#if defined(__i386__)#define mb () __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")#define rmb () __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory") +#define wmb () __asm__ __volatile__ ("": : :"memory")#elif defined(__x86_64__)#define mb () __asm__ __volatile__ ("mfence":::"memory")#define rmb () __asm__ __volatile__ ("lfence":::"memory") +#define wmb () __asm__ __volatile__ ("sfence" ::: "memory")/* From CONFIG_UNORDERED_IO (linux) */ #endif
extras/mini-os/include/semaphore.h +39 -0
@@ -2,6 +2,7 @@#define _SEMAPHORE_H_#include <wait.h> +#include <spinlock.h> /* * Implementation of semaphore in Mini-os is simple, because
@@ -14,6 +15,15 @@struct wait_queue_head wait; }; +/* +* the semaphore definition +*/ +struct rw_semaphore { +signed long count; +spinlock_t wait_lock; +struct list_head wait_list; +int debug; +};#define __SEMAPHORE_INITIALIZER (name, n) \ { \
@@ -31,6 +41,12 @@#define DECLARE_MUTEX_LOCKED (name) __DECLARE_SEMAPHORE_GENERIC(name,0) +static inline void init_MUTEX (struct semaphore *sem) +{ + sem->count =1 ; +init_waitqueue_head (&sem->wait); +} +static void inline down (struct semaphore *sem) {wait_event (sem->wait, sem->count >0 );
@@ -43,4 +59,27 @@ wake_up(&sem->wait); } +/* FIXME! Thre read/write semaphores are unimplemented! */ +static inline void init_rwsem (struct rw_semaphore *sem) +{ + sem->count =1 ; +} + +static inline void down_read (struct rw_semaphore *sem) +{ +} + + +static inline void up_read (struct rw_semaphore *sem) +{ +} + +static inline void up_write (struct rw_semaphore *sem) +{ +} + +static inline void down_write (struct rw_semaphore *sem) +{ +} +#endif /* _SEMAPHORE_H */
extras/mini-os/include/wait.h +4 -0
@@ -33,6 +33,10 @@ } +static inline void init_waitqueue_head (struct wait_queue_head *h) +{ +INIT_LIST_HEAD (&h->thread_list); +}static inline void init_waitqueue_entry (struct wait_queue *q,struct thread *thread) {
extras/mini-os/include/xenbus.h +167 -32
224 lines not on this page · raw message
extras/mini-os/include/xmalloc.h +3 -0
@@ -6,6 +6,9 @@/* Allocate space for array of typed objects. */ #define xmalloc_array (_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num)) + +#define malloc (size) _xmalloc(size, 4) +#define free (ptr) xfree(ptr)/* Free any of the above. */ extern void xfree (const void *);
extras/mini-os/kernel.c +1 -0
@@ -35,6 +35,7 @@#include <lib.h> #include <sched.h> #include <xenbus.h> +#include "xenbus/xenbus_comms.h" /* * Shared page for communicating with the hypervisor.
extras/mini-os/xenbus/xenbus_comms.c +84 -131
281 lines not on this page · raw message
extras/mini-os/xenbus/xenbus_comms.h +1 -1
@@ -28,8 +28,8 @@#ifndef _XENBUS_COMMS_H#define _XENBUS_COMMS_H +int xs_init (void );int xb_init_comms (void ); -void xb_suspend_comms (void );/* Low level routines. */ int xb_write (const void *data,unsigned len);
extras/mini-os/xenbus/xenbus_xs.c +462 -225
929 lines not on this page · raw message
extras/mini-os/include/spinlock.h new file +121 -0
121 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel