#define __VMM_H__
-/*#include <palacios/vm_guest.h>*/
-
-struct guest_info;
#ifdef __V3VEE__
#include <palacios/vmm_mem.h>
#include <palacios/vmm_types.h>
-
-//#include <palacios/vmm_types.h>
#include <palacios/vmm_string.h>
/* utility definitions */
+#define VM_NONE ((struct v3_vm_info *)0)
+#define VCORE_NONE ((struct guest_info *)0)
-#define V3_Print(fmt, args...) \
- do { \
- extern struct v3_os_hooks * os_hooks; \
- if ((os_hooks) && (os_hooks)->print) { \
- (os_hooks)->print((fmt), ##args); \
- } \
- } while (0)
+void *v3_get_host_vm(struct v3_vm_info *);
+int v3_get_vcore(struct guest_info *);
+#define V3_Print(vm, vcore, fmt, args...) \
+ do { \
+ extern struct v3_os_hooks * os_hooks; \
+ if ((os_hooks) && (os_hooks)->print) { \
+ (os_hooks)->print(v3_get_host_vm(vm), v3_get_vcore(vcore), (fmt), ##args); \
+ } \
+ } while (0)
-#define PrintDebug(fmt, args...) \
- do { \
- extern struct v3_os_hooks * os_hooks; \
- if ((os_hooks) && (os_hooks)->print) { \
- (os_hooks)->print((fmt), ##args); \
- } \
- } while (0)
+#define PrintDebug(vm, vcore, fmt, args...) V3_Print(vm, vcore, "DEBUG: " fmt, ##args)
-#define PrintError(fmt, args...) \
- do { \
- extern struct v3_os_hooks * os_hooks; \
- if ((os_hooks) && (os_hooks)->print) { \
- (os_hooks)->print("%s(%d): " fmt, __FILE__, __LINE__, ##args); \
- } \
- } while (0)
+#define PrintError(vm, vcore, fmt, args...) V3_Print(vm, vcore, "ERROR at %s(%d): " fmt, __FILE__, __LINE__, ##args)
if ((os_hooks) && (os_hooks)->malloc) { \
var = (os_hooks)->malloc(size); \
} \
- if (!var) PrintError("MALLOC FAILURE. Memory LEAK!!\n"); \
+ if (!var) PrintError(VM_NONE,VCORE_NONE,"MALLOC FAILURE. Memory LEAK!!\n"); \
var; \
})
/* ** */
-#define V3_ASSERT(x) \
+#define V3_ASSERT(vm, vcore, x) \
do { \
extern struct v3_os_hooks * os_hooks; \
if (!(x)) { \
- PrintDebug("Failed assertion in %s: %s at %s, line %d, RA=%lx\n", \
+ PrintDebug(vm, vcore, "Failed assertion in %s: %s at %s, line %d, RA=%lx\n", \
__func__, #x, __FILE__, __LINE__, \
(ulong_t) __builtin_return_address(0)); \
while(1){ \
} while (0) \
-#define V3_Yield_Timed(usec) \
+#define V3_Sleep(usec) \
do { \
extern struct v3_os_hooks * os_hooks; \
- if ((os_hooks) && (os_hooks)->yield_cpu_timed) {\
- (os_hooks)->yield_cpu_timed(usec); \
+ if ((os_hooks) && (os_hooks)->sleep_cpu) {\
+ (os_hooks)->sleep_cpu(usec); \
} else { \
V3_Yield(); \
} \
} while (0) \
+#define V3_Wakeup(cpu) \
+ do { \
+ extern struct v3_os_hooks * os_hooks; \
+ if ((os_hooks) && (os_hooks)->wakeup_cpu) { \
+ (os_hooks)->wakeup_cpu(cpu); \
+ } \
+ } while (0) \
typedef enum v3_vm_class {V3_INVALID_VM, V3_PC_VM, V3_CRAY_VM} v3_vm_class_t;
/* This will contain function pointers that provide OS services */
struct v3_os_hooks {
- void (*print)(const char * format, ...)
- __attribute__ ((format (printf, 1, 2)));
+ // the vm pointer is the host os's "priv_data" from v3_create_vm
+ // if vm is null, this is a general palacios printout
+ // if vm is not null, and vcore is negative, this is a general print form the vm
+ // if vm is not null, and vcore is non-negative, this is a print from a specific vcore
+ void (*print)(void *vm, int vcore, const char * format, ...)
+ __attribute__ ((format (printf, 3, 4)));
void *(*allocate_pages)(int num_pages, unsigned int alignment);
void (*free_pages)(void * page, int num_pages);
unsigned int (*get_cpu_khz)(void);
-
void (*yield_cpu)(void);
-
- void (*yield_cpu_timed)(unsigned int usec);
+ void (*sleep_cpu)(unsigned int usec);
+ void (*wakeup_cpu)(void *cpu);
void *(*mutex_alloc)(void);
void (*mutex_free)(void * mutex);
};
+typedef enum {V3_VM_UNKNOWN, V3_VM_INVALID, V3_VM_RUNNING, V3_VM_STOPPED, V3_VM_PAUSED, V3_VM_ERROR, V3_VM_SIMULATING} v3_vm_state_t;
+typedef enum {V3_VCORE_UNKNOWN, V3_VCORE_INVALID, V3_VCORE_RUNNING, V3_VCORE_STOPPED} v3_vcore_state_t;
+typedef enum {V3_VCORE_CPU_UNKNOWN, V3_VCORE_CPU_REAL, V3_VCORE_CPU_PROTECTED, V3_VCORE_CPU_PROTECTED_PAE, V3_VCORE_CPU_LONG, V3_VCORE_CPU_LONG_32_COMPAT, V3_VCORE_CPU_LONG_16_COMPAT} v3_vcore_cpu_mode_t;
+typedef enum {V3_VCORE_MEM_STATE_UNKNOWN, V3_VCORE_MEM_STATE_SHADOW, V3_VCORE_MEM_STATE_NESTED} v3_vcore_mem_state_t;
+typedef enum {V3_VCORE_MEM_MODE_UNKNOWN, V3_VCORE_MEM_MODE_PHYSICAL, V3_VCORE_MEM_MODE_VIRTUAL} v3_vcore_mem_mode_t;
-void Init_V3(struct v3_os_hooks * hooks, char * cpus, int num_cpus);
+struct v3_vcore_state {
+ v3_vcore_state_t state;
+ v3_vcore_cpu_mode_t cpu_mode;
+ v3_vcore_mem_state_t mem_state;
+ v3_vcore_mem_mode_t mem_mode;
+ unsigned long pcore;
+ void * last_rip;
+ unsigned long long num_exits;
+};
+
+struct v3_vm_state {
+ v3_vm_state_t state;
+ void * mem_base_paddr;
+ unsigned long long mem_size;
+ unsigned long num_vcores;
+ struct v3_vcore_state vcore[0];
+};
+
+char *v3_lookup_option(char *name);
+void Init_V3(struct v3_os_hooks * hooks, char * cpus, int num_cpus, char *options);
void Shutdown_V3( void );
int v3_continue_vm(struct v3_vm_info * vm);
int v3_simulate_vm(struct v3_vm_info * vm, unsigned int msecs);
+int v3_save_vm(struct v3_vm_info * vm, char * store, char * url, unsigned long long opts);
+int v3_load_vm(struct v3_vm_info * vm, char * store, char * url, unsigned long long opts);
-int v3_save_vm(struct v3_vm_info * vm, char * store, char * url);
-int v3_load_vm(struct v3_vm_info * vm, char * store, char * url);
+int v3_send_vm(struct v3_vm_info * vm, char * store, char * url, unsigned long long opts);
+int v3_receive_vm(struct v3_vm_info * vm, char * store, char * url, unsigned long long opts);
int v3_move_vm_core(struct v3_vm_info * vm, int vcore_id, int target_cpu);
int v3_free_vm(struct v3_vm_info * vm);
+int v3_get_state_vm(struct v3_vm_info *vm, struct v3_vm_state *out);
+
int v3_deliver_irq(struct v3_vm_info * vm, struct v3_interrupt * intr);