/* utility definitions */
+#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)
+
+
#define PrintDebug(fmt, args...) \
do { \
extern struct v3_os_hooks * os_hooks; \
- if ((os_hooks) && (os_hooks)->print_debug) { \
- (os_hooks)->print_debug((fmt), ##args); \
+ if ((os_hooks) && (os_hooks)->print) { \
+ (os_hooks)->print((fmt), ##args); \
} \
} while (0)
-#if 1
-#else
-#define PrintDebug(fmt,args ...)
-#endif
-
-
#define PrintError(fmt, args...) \
do { \
extern struct v3_os_hooks * os_hooks; \
- if ((os_hooks) && (os_hooks)->print_debug) { \
- (os_hooks)->print_debug("%s(%d): " fmt, __FILE__, __LINE__, ##args); \
+ if ((os_hooks) && (os_hooks)->print) { \
+ (os_hooks)->print("%s(%d): " fmt, __FILE__, __LINE__, ##args); \
} \
} while (0)
-#ifdef VMM_INFO
-#define PrintInfo(fmt, args...) \
- do { \
- extern struct v3_os_hooks * os_hooks; \
- if ((os_hooks) && (os_hooks)->print_info) { \
- (os_hooks)->print_info((fmt), ##args); \
- } \
- } while (0)
-#else
-#define PrintInfo(fmt, args...)
-#endif
-
-
-#ifdef VMM_TRACE
-#define PrintTrace(fmt, args...) \
- do { \
- extern struct v3_os_hooks * os_hooks; \
- if ((os_hooks) && (os_hooks)->print_trace) { \
- (os_hooks)->print_trace(fmt, ##args); \
- } \
- } while (0)
-#else
-#define PrintTrace(fmt, args...)
-#endif
-
-
#define V3_AllocPages(num_pages) \
({ \
extern struct v3_os_hooks * os_hooks; \
/* This will contain function pointers that provide OS services */
struct v3_os_hooks {
- void (*print_info)(const char * format, ...)
- __attribute__ ((format (printf, 1, 2)));
- void (*print_debug)(const char * format, ...)
- __attribute__ ((format (printf, 1, 2)));
- void (*print_trace)(const char * format, ...)
+ void (*print)(const char * format, ...)
__attribute__ ((format (printf, 1, 2)));
void *(*allocate_pages)(int numPages);
-// These are the GPRs layed out according to 'pusha'
-struct VMM_GPRs {
- uint_t edi;
- uint_t esi;
- uint_t ebp;
- uint_t esp;
- uint_t ebx;
- uint_t edx;
- uint_t ecx;
- uint_t eax;
-};
-
-
#define GET_LOW_32(x) (*((uint_t*)(&(x))))
#define GET_HIGH_32(x) (*((uint_t*)(((uchar_t*)(&(x)))+4)))
-void PrintTraceHex(uchar_t x);
-void PrintTraceLL(ullong_t num);
-void PrintTraceMemDump(uchar_t * start, int n);
+
+void v3_dump_mem(uint8_t * start, int n);
val = tsc; \
} while (0)
-/*
- #if __V3_32BIT__
-
- #define rdtscll(val) \
- __asm__ __volatile__("rdtsc" : "=A" (val))
-
- #elif __V3_64BIT__
-
- #define rdtscll(val) do { \
- unsigned int a,d; \
- asm volatile("rdtsc" : "=a" (a), "=d" (d)); \
- (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \
- } while(0)
-
- #endif
-*/
PrintDebug("Host Address of rip = 0x%p\n", (void *)host_addr);
PrintDebug("Instr (15 bytes) at %p:\n", (void *)host_addr);
- PrintTraceMemDump((uchar_t *)host_addr, 15);
+ v3_dump_mem((uint8_t *)host_addr, 15);
break;
}
struct v3_socket_hooks * sock_hooks = 0;
void V3_Init_Sockets(struct v3_socket_hooks * hooks) {
- PrintInfo("Initializing Socket Interface\n");
sock_hooks = hooks;
PrintDebug("V3 sockets inited\n");
* This is free software. You are permitted to use,
* redistribute, and modify it as specified in the file "V3VEE_LICENSE".
*/
-
-
#include <palacios/vmm_util.h>
#include <palacios/vmm.h>
-extern struct v3_os_hooks * os_hooks;
-
-
-void PrintTraceHex(unsigned char x) {
- unsigned char z;
-
- z = (x >> 4) & 0xf;
- PrintTrace("%x", z);
- z = x & 0xf;
- PrintTrace("%x", z);
-}
-
-void PrintTraceLL(ullong_t num) {
- unsigned char * z = (unsigned char *)#
- int i;
-
- for (i = 7; i >= 0; i--) {
- PrintTraceHex(*(z + i));
- }
-}
-
-void PrintTraceMemDump(uchar_t * start, int n) {
+void v3_dump_mem(uint8_t * start, int n) {
int i, j;
for (i = 0; i < n; i += 16) {
- PrintTrace("%p", (void *)(start + i));
+ V3_Print("%p", (void *)(start + i));
for (j = i; (j < (i + 16)) && (j < n); j += 2) {
- PrintTrace(" ");
- PrintTraceHex(*(uchar_t *)(start + j));
+ V3_Print(" ");
+ V3_Print("%x", *(uint8_t *)(start + j));
if ((j + 1) < n) {
- PrintTraceHex(*((uchar_t *)(start + j + 1)));
+ V3_Print("%x", *((uint8_t *)(start + j + 1)));
}
}
- PrintTrace(" ");
+ V3_Print(" ");
for (j = i; (j < (i + 16)) && (j < n); j++) {
- PrintTrace("%c", ((start[j] >= 32) && (start[j] <= 126)) ? start[j] : '.');
+ V3_Print("%c", ((start[j] >= 32) && (start[j] <= 126)) ? start[j] : '.');
}
- PrintTrace("\n");
+ V3_Print("\n");
}
}
if (ecx & CPUID_1_ECX_VTXFLAG) {
v3_get_msr(VMX_FEATURE_CONTROL_MSR, &(feature_msr.hi), &(feature_msr.lo));
- PrintTrace("MSRREGlow: 0x%.8x\n", feature_msr.lo);
+ PrintDebug("MSRREGlow: 0x%.8x\n", feature_msr.lo);
if ((feature_msr.lo & FEATURE_CONTROL_VALID) != FEATURE_CONTROL_VALID) {
PrintDebug("VMX is locked -- enable in the BIOS\n");