Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Revised Nautilus Aerokernel Host Functionality
[palacios.git] / nautilus / palacios.h
1 #ifndef _PALACIOS_H
2 #define _PALACIOS_H
3
4 typedef uint8_t u8;
5 typedef uint32_t u32;
6 typedef uint64_t u64;
7 typedef unsigned int *uintptr_t;
8 typedef int *intptr_t;
9
10 #define LOCKCHECK_ALLOC(x)
11 #define LOCKCHECK_LOCK_PRE(x)
12 #define LOCKCHECK_LOCK_POST(x)
13 #define LOCKCHECK_LOCK_IRQSAVE_PRE(x,y)
14 #define LOCKCHECK_LOCK_IRQSAVE_POST(x,y)
15 #define LOCKCHECK_UNLOCK_PRE(x)
16 #define LOCKCHECK_UNLOCK_POST(x)
17 #define LOCKCHECK_UNLOCK_IRQRESTORE_PRE(x,y)
18 #define LOCKCHECK_UNLOCK_IRQRESTORE_POST(x,y)
19 #define LOCKCHECK_FREE(x)
20
21
22 #define NR_CPUS 64
23
24 #define NR_VMS  32
25
26 #define MAX_VM_NAME 32
27
28 struct nk_vm_state {
29   char   name[MAX_VM_NAME];
30   struct v3_vm_info *vm;
31   struct nk_virtual_console *vc;
32 };
33
34
35 int palacios_vmm_init( char * options );
36
37 void palacios_inform_new_vm_pre(char *name);
38 void palacios_inform_new_vm_post(char *name, struct v3_vm_info *vm);
39 void palacios_inform_free_vm(char *name);
40 void palacios_inform_free_selected_vm();
41 void palacios_inform_select_vm(struct v3_vm_info *vm);
42 void palacios_inform_select_vm_by_name(char *name);
43
44 struct nk_vm_state *palacios_find_vm(struct v3_vm_info *vm);
45 struct nk_vm_state *palacios_find_vm_by_name(char *name);
46 struct nk_vm_state *palacios_get_selected_vm();
47
48 int palacios_vmm_exit( void );
49
50
51 struct v3_resource_control;
52
53 // Selected exported stubs, for use in other palacios components, like vnet
54 // The idea is that everything uses the same stubs
55 void  palacios_print_scoped(void *vm, int vcore, const char *fmt, ...);
56 #define palacios_print(...) palacios_print_scoped(0,-1, __VA_ARGS__)
57 // node_id=-1 => no node constraint
58 void *palacios_allocate_pages(int num_pages, unsigned int alignment, int node_id, int (*filter_func)(void *paddr, void *filter_state), void *filter_state);
59 void  palacios_free_pages(void *page_addr, int num_pages);
60 void *palacios_alloc(unsigned int size);
61 // node_id=-1 => no node constraint
62 void *palacios_alloc_extended(unsigned int size, unsigned int flags, int node_id);
63 void  palacios_free(void *);
64 void *palacios_valloc(unsigned int size); // use instead of vmalloc
65 void  palacios_vfree(void *);             // use instead of vfree
66 void *palacios_vaddr_to_paddr(void *vaddr);
67 void *palacios_paddr_to_vaddr(void *paddr);
68 void  palacios_xcall(int cpu_id, void (*fn)(void *arg), void *arg);
69 void *palacios_create_and_start_kernel_thread(int (*fn)(void * arg), void *arg, char *thread_name, struct v3_resource_control  *rctl);
70 void *palacios_create_thread_on_cpu(int cpu_id, int (*fn)(void * arg), void *arg, char *thread_name, struct v3_resource_control  *rctl);
71 void  palacios_start_thread(void *thread_ptr);
72 void *palacios_creeate_and_start_thread_on_cpu(int cpu_id, int (*fn)(void * arg), void *arg, char *thread_name, struct v3_resource_control  *rctl);
73 int   palacios_move_thread_to_cpu(int new_cpu_id, void *thread_ptr);
74 void  palacios_yield_cpu(void);
75 void  palacios_sleep_cpu(unsigned int us);
76 unsigned int palacios_get_cpu(void);
77 unsigned int palacios_get_cpu_khz(void);
78 void  palacios_used_fpu(void);
79 void  palacios_need_fpu(void);
80 void *palacios_mutex_alloc(void);         // allocates and inits a lock
81 void  palacios_mutex_init(void *mutex);   // only inits a lock
82 void  palacios_mutex_deinit(void *mutex); // only deinits a lock
83 void  palacios_mutex_free(void *mutex);   // deinits and frees a lock
84 void  palacios_mutex_lock(void *mutex, int must_spin);
85 void  palacios_mutex_unlock(void *mutex);
86 void *palacios_mutex_lock_irqsave(void *mutex, int must_spin);
87 void  palacios_mutex_unlock_irqrestore(void *mutex, void *flags);
88 // Macros for spin-locks in the module code
89 // By using these macros, the lock checker will be able
90 // to see the module code as well as the core VMM
91 #define palacios_spinlock_init(l) palacios_mutex_init(l)
92 #define palacios_spinlock_deinit(l) palacios_mutex_deinit(l)
93 #define palacios_spinlock_lock(l) palacios_mutex_lock(l,0)
94 #define palacios_spinlock_unlock(l) palacios_mutex_unlock(l)
95 #define palacios_spinlock_lock_irqsave(l,f) do { f=(unsigned long)palacios_mutex_lock_irqsave(l,0); } while (0)
96 #define palacios_spinlock_unlock_irqrestore(l,f) palacios_mutex_unlock_irqrestore(l,(void*)f)
97
98
99 // Palacios Printing Support
100
101 // These macros affect how palacios_print will generate output
102 // Turn this on for unprefaced output from palacios_print
103 #define V3_PRINTK_OLD_STYLE_OUTPUT 0
104 // Maximum length output from palacios_print
105 #define V3_PRINTK_BUF_SIZE 1024
106 // Turn this on to check if new-style output for palacios_print  contains only 7-bit chars
107 #define V3_PRINTK_CHECK_7BIT 1
108
109 //
110 // The following macros are for printing in nautilus itself, even before
111 // Palacios is initialized and after it it deinitialized
112 // All printk's in nautilus use these macros, for easier control
113 #define KERN_ERR ""
114 #define KERN_WARNING ""
115 #define KERN_NOTICE ""
116 #define KERN_INFO ""
117 #define KERN_DEBUG ""
118 #define ERROR(fmt, args...) ERROR_PRINT(KERN_ERR "palacios (pcore %u) %s(%d): " fmt, palacios_get_cpu(), __FILE__, __LINE__, ##args)
119 #define WARNING(fmt, args...) WARN_PRINT(KERN_WARNING "palacios (pcore %u): " fmt, palacios_get_cpu(), ##args)
120 #define NOTICE(fmt, args...) INFO_PRINT(KERN_NOTICE "palacios (pcore %u): " fmt, palacios_get_cpu(), ##args)
121 #define INFO(fmt, args...) INFO_PRINT(KERN_INFO "palacios (pcore %u): " fmt, palacios_get_cpu(), ##args)
122 #define DEBUG(fmt, args...) DEBUG_PRINT(KERN_DEBUG "palacios (pcore %u): " fmt, palacios_get_cpu(), ##args)
123
124
125 #endif