6 #include <palacios/vmm_types.h>
10 #define PAGE_SIZE 4096
14 typedef union reg_ex {
25 // These are the GPRs layed out according to 'pusha'
38 #define GET_LOW_32(x) (*((uint_t*)(&(x))))
39 #define GET_HIGH_32(x) (*((uint_t*)(((char*)(&(x)))+4)))
42 void PrintTraceHex(unsigned char x);
43 void PrintTraceLL(ullong_t num);
44 void PrintTraceMemDump(unsigned char * start, int n);
49 #define rdtsc(low,high) \
50 __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
53 __asm__ __volatile__("rdtsc" : "=a" (low) : : "edx")
57 #define rdtscll(val) \
58 __asm__ __volatile__("rdtsc" : "=A" (val))
60 #elif defined(__x86_64__)
62 #define rdtscll(val) do { \
64 asm volatile("rdtsc" : "=a" (a), "=d" (d)); \
65 (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \
80 # define do_div(n,base) ({ \
81 uint32_t __base = (base); \
83 __rem = ((uint64_t)(n)) % __base; \
84 (n) = ((uint64_t)(n)) / __base; \
91 * do_div() is NOT a C function. It wants to return
92 * two values (the quotient and the remainder), but
93 * since that doesn't work very well in C, what it
96 * - modifies the 64-bit dividend _in_place_
97 * - returns the 32-bit remainder
99 * This ends up being the most efficient "calling
100 * convention" on x86.
102 #define do_div(n,base) ({ \
103 unsigned long __upper, __low, __high, __mod, __base; \
105 asm("":"=a" (__low), "=d" (__high):"A" (n)); \
108 __upper = __high % (__base); \
109 __high = __high / (__base); \
111 asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
112 asm("":"=A" (n):"a" (__low),"d" (__high)); \
118 /* This divides two 64bit unsigned ints
119 * The previous version only allows 32 bit bases(?)...
121 * NOTE: This absolutely sucks... there has to be a better way....
123 #define do_divll(n, base) ({ \
124 ullong_t __rem = 0; \
125 ullong_t __num = 0; \
141 #endif // ! __V3VEE__