X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fvnet%2Fvnet_host.h;h=ec6a28ceb4467ddda7785bf2a0c83dfe99ac6f90;hb=de5c2110458436a9300aa0a171dbbe83e415ee4d;hp=5fe3cff7967a874c3a5ec6f728690f76e87048db;hpb=f47bc5f7b2fa7169df0c618369224fffb12007b3;p=palacios.git diff --git a/palacios/include/vnet/vnet_host.h b/palacios/include/vnet/vnet_host.h index 5fe3cff..ec6a28c 100644 --- a/palacios/include/vnet/vnet_host.h +++ b/palacios/include/vnet/vnet_host.h @@ -32,13 +32,14 @@ struct vnet_timer { }; typedef unsigned long vnet_lock_t; - +typedef void *vnet_intr_flags_t; struct vnet_host_hooks { void *(*thread_start)(int (*fn)(void * arg), void * arg, - char * thread_name); + char * thread_name, + v3_resource_control_t *resource_control); void (*thread_sleep)(long timeout); void (*thread_wakeup)(void * thread); @@ -58,10 +59,10 @@ struct vnet_host_hooks { /* duplicate part from os_hooks */ void (*yield_cpu)(void); - void (*print)(const char * format, ...) - __attribute__ ((format (printf, 1, 2))); + void (*print)(void *vm , int core, const char * format, ...) + __attribute__ ((format (printf, 3, 4))); - void *(*allocate_pages)(int num_pages, unsigned int alignment); + void *(*allocate_pages)(int num_pages, unsigned int alignment, int node_id); void (*free_pages)(void * page, int num_pages); void *(*malloc)(unsigned int size); @@ -74,6 +75,8 @@ struct vnet_host_hooks { void (*mutex_free)(void * mutex); void (*mutex_lock)(void * mutex, int must_spin); void (*mutex_unlock)(void * mutex); + vnet_intr_flags_t (*mutex_lock_irqsave)(void * mutex, int must_spin); + void (*mutex_unlock_irqrestore)(void * mutex, vnet_intr_flags_t flags); }; @@ -90,7 +93,7 @@ extern struct vnet_host_hooks * host_hooks; /* 4KB-aligned */ static inline void * Vnet_AllocPages(int num_pages){ if ((host_hooks) && host_hooks->allocate_pages) { - return host_hooks->allocate_pages(num_pages, PAGE_SIZE_4KB); + return host_hooks->allocate_pages(num_pages, PAGE_SIZE_4KB,-1); } return NULL; @@ -140,8 +143,7 @@ static inline void Vnet_Yield(void){ } /* 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){ @@ -216,17 +218,17 @@ static inline void vnet_reset_timer(struct vnet_timer * timer, if(level <= net_debug) { \ extern struct vnet_host_hooks * host_hooks; \ if ((host_hooks) && (host_hooks)->print) { \ - (host_hooks)->print((fmt), ##args); \ + (host_hooks)->print(0, -1, (fmt), ##args); \ } \ } \ } while (0) -#define Vnet_Debug(fmt, args...) \ +#define Vnet_Debug(fmt, args...) \ do { \ extern struct vnet_host_hooks * host_hooks; \ if ((host_hooks) && (host_hooks)->print) { \ - (host_hooks)->print((fmt), ##args); \ + (host_hooks)->print(0, -1, (fmt), ##args); \ } \ } while (0) @@ -234,33 +236,51 @@ static inline void vnet_reset_timer(struct vnet_timer * timer, /* Lock Utilities */ -int vnet_lock_init(vnet_lock_t * lock); +static inline int vnet_lock_init(vnet_lock_t * lock) { + if((host_hooks) && host_hooks->mutex_alloc){ + *lock = (addr_t)(host_hooks->mutex_alloc()); + if (*lock) { + return 0; + } + } + return -1; +} static inline void vnet_lock_deinit(vnet_lock_t * lock) { - host_hooks->mutex_free((void *)*lock); - *lock = 0; + if (host_hooks && (host_hooks->mutex_free)) { + host_hooks->mutex_free((void *)*lock); + *lock = 0; + } } static inline void vnet_lock(vnet_lock_t lock) { - host_hooks->mutex_lock((void *)lock, 0); + if (host_hooks && (host_hooks->mutex_lock)) { + host_hooks->mutex_lock((void *)lock,0); + } } static inline void vnet_unlock(vnet_lock_t lock) { - host_hooks->mutex_unlock((void *)lock); + if (host_hooks && (host_hooks->mutex_lock)) { + host_hooks->mutex_unlock((void *)lock); + } } -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 0; +static inline vnet_intr_flags_t vnet_lock_irqsave(vnet_lock_t lock) +{ + if (host_hooks && host_hooks->mutex_lock_irqsave) { + return (host_hooks->mutex_lock_irqsave((void *)lock, 1)); + } else { + return NULL; + } } -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); +static inline void vnet_unlock_irqrestore(vnet_lock_t lock, vnet_intr_flags_t irq_state) +{ + if (host_hooks && (host_hooks->mutex_unlock_irqrestore)) { + host_hooks->mutex_unlock_irqrestore((void *)lock,irq_state); + } } - #endif