X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fvnet%2Fvnet_host.h;h=5fe3cff7967a874c3a5ec6f728690f76e87048db;hb=fccca933d65b563aa073d28e35e3a61c3e089bb7;hp=616d7b630f7b5274772a3344ed02a496436a82cb;hpb=6cff7c8b0ec58e3b94d9583f709ca9056ae928dd;p=palacios.releases.git diff --git a/palacios/include/vnet/vnet_host.h b/palacios/include/vnet/vnet_host.h index 616d7b6..5fe3cff 100644 --- a/palacios/include/vnet/vnet_host.h +++ b/palacios/include/vnet/vnet_host.h @@ -20,6 +20,7 @@ #ifndef __VNET_HOST_H__ #define __VNET_HOST_H__ +#include #include struct vnet_thread { @@ -30,21 +31,27 @@ struct vnet_timer { void * host_timer; }; -typedef addr_t vnet_lock_t; +typedef unsigned long vnet_lock_t; struct vnet_host_hooks { - void *(*thread_start)(int (*fn)(void * arg), void * arg, char * thread_name); - void (*thread_sleep)(int timeout); + void *(*thread_start)(int (*fn)(void * arg), + void * arg, + char * thread_name); + + void (*thread_sleep)(long timeout); void (*thread_wakeup)(void * thread); void (*thread_stop)(void * thread); - int (*thread_should_stop)(); + int (*thread_should_stop)(void); + + void *(*timer_create)(unsigned long interval, + void (* timer_fun)(void * priv_data), + void * data); - void *(*timer_create)(unsigned long interval, void (* timer_fun)(void * priv_data), void * data); void (*timer_del)(void * timer); - int (*timer_start)(void * timer); - int (*timer_stop)(void * timer); + void (*timer_start)(void * timer); + void (*timer_stop)(void * timer); void (*timer_reset)(void * timer, unsigned long interval); void (*udelay)(unsigned long usecs); @@ -71,6 +78,8 @@ struct vnet_host_hooks { +#ifdef __V3VEE__ + extern struct vnet_host_hooks * host_hooks; @@ -101,7 +110,7 @@ static inline void * Vnet_VAddr(void * addr) { return NULL; } -static inline void * Vnet_PAddr(void *addr) { +static inline void * Vnet_PAddr(void * addr) { if ((host_hooks) && host_hooks->vaddr_to_paddr) { return host_hooks->vaddr_to_paddr(addr); } @@ -124,14 +133,15 @@ static inline void Vnet_Free(void * addr){ } -static inline void Vnet_Yield(){ +static inline void Vnet_Yield(void){ if ((host_hooks) && (host_hooks)->yield_cpu) { host_hooks->yield_cpu(); } } /* THREAD FUNCTIONS */ -struct vnet_thread * vnet_start_thread(int (*func)(void *), void *arg, char * name); +struct vnet_thread * vnet_start_thread(int (*func)(void *), + void * arg, char * name); static inline void vnet_thread_sleep(long timeout){ if((host_hooks) && host_hooks->thread_sleep){ @@ -152,7 +162,7 @@ static inline void vnet_thread_stop(struct vnet_thread * thread){ } } -static inline int vnet_thread_should_stop(){ +static inline int vnet_thread_should_stop(void){ if((host_hooks) && host_hooks->thread_should_stop){ return host_hooks->thread_should_stop(); } @@ -168,7 +178,9 @@ static inline void vnet_udelay(unsigned long usecs){ /* TIMER FUNCTIONS */ /* interval, in jittes */ -struct vnet_timer * vnet_create_timer(unsigned long interval, void (* timer_fun)(void * priv_data), void * pri_data); +struct vnet_timer * vnet_create_timer(unsigned long interval, + void (* timer_fun)(void * priv_data), + void * pri_data); static inline void vnet_del_timer(struct vnet_timer * timer){ if((host_hooks) && host_hooks->timer_del){ @@ -177,23 +189,20 @@ static inline void vnet_del_timer(struct vnet_timer * timer){ } } -static inline int vnet_start_timer(struct vnet_timer * timer){ +static inline void vnet_start_timer(struct vnet_timer * timer){ if((host_hooks) && host_hooks->timer_start){ - return host_hooks->timer_start(timer->host_timer); + host_hooks->timer_start(timer->host_timer); } - - return -1; } -static inline int vnet_stop_timer(struct vnet_timer * timer){ +static inline void vnet_stop_timer(struct vnet_timer * timer){ if((host_hooks) && host_hooks->timer_stop){ - return host_hooks->timer_stop(timer->host_timer); + host_hooks->timer_stop(timer->host_timer); } - - return -1; } -static inline void vnet_reset_timer(struct vnet_timer * timer, unsigned long new_interval){ +static inline void vnet_reset_timer(struct vnet_timer * timer, + unsigned long new_interval){ if((host_hooks) && host_hooks->timer_reset){ host_hooks->timer_reset(timer->host_timer, new_interval); } @@ -202,23 +211,23 @@ static inline void vnet_reset_timer(struct vnet_timer * timer, unsigned long new #define Vnet_Print(level, fmt, args...) \ - do { \ - extern int vnet_debug; \ - if(level <= vnet_debug) { \ + do { \ + extern int net_debug; \ + if(level <= net_debug) { \ extern struct vnet_host_hooks * host_hooks; \ if ((host_hooks) && (host_hooks)->print) { \ (host_hooks)->print((fmt), ##args); \ - } \ - } \ + } \ + } \ } while (0) #define Vnet_Debug(fmt, args...) \ - do { \ + do { \ extern struct vnet_host_hooks * host_hooks; \ if ((host_hooks) && (host_hooks)->print) { \ (host_hooks)->print((fmt), ##args); \ - } \ + } \ } while (0) @@ -240,23 +249,23 @@ static inline void vnet_unlock(vnet_lock_t lock) { host_hooks->mutex_unlock((void *)lock); } -static inline addr_t vnet_lock_irqsave(vnet_lock_t lock) { - addr_t irq_state = v3_irq_save(); +static inline unsigned long vnet_lock_irqsave(vnet_lock_t lock) { + //addr_t irq_state = v3_irq_save(); host_hooks->mutex_lock((void *)lock, 1); - return irq_state; + return 0; } static inline void vnet_unlock_irqrestore(vnet_lock_t lock, addr_t irq_state) { host_hooks->mutex_unlock((void *)lock); - v3_irq_restore(irq_state); + //v3_irq_restore(irq_state); } +#endif - - void init_vnet(struct vnet_host_hooks * hooks); +void deinit_vnet(void); #endif