4 #include <palacios/vmm_types.h>
12 typedef union reg_ex {
23 // These are the GPRs layed out according to 'pusha'
36 #define GET_LOW_32(x) (*((uint_t*)(&(x))))
37 #define GET_HIGH_32(x) (*((uint_t*)(((char*)(&(x)))+4)))
40 void PrintTraceHex(unsigned char x);
41 void PrintTraceLL(ullong_t num);
42 void PrintTraceMemDump(unsigned char * start, int n);
47 #define rdtsc(low,high) \
48 __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
51 __asm__ __volatile__("rdtsc" : "=a" (low) : : "edx")
55 #define rdtscll(val) \
56 __asm__ __volatile__("rdtsc" : "=A" (val))
58 #elif defined(__x86_64__)
60 #define rdtscll(val) do { \
62 asm volatile("rdtsc" : "=a" (a), "=d" (d)); \
63 (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \
78 # define do_div(n,base) ({ \
79 uint32_t __base = (base); \
81 __rem = ((uint64_t)(n)) % __base; \
82 (n) = ((uint64_t)(n)) / __base; \
89 * do_div() is NOT a C function. It wants to return
90 * two values (the quotient and the remainder), but
91 * since that doesn't work very well in C, what it
94 * - modifies the 64-bit dividend _in_place_
95 * - returns the 32-bit remainder
97 * This ends up being the most efficient "calling
100 #define do_div(n,base) ({ \
101 unsigned long __upper, __low, __high, __mod, __base; \
103 asm("":"=a" (__low), "=d" (__high):"A" (n)); \
106 __upper = __high % (__base); \
107 __high = __high / (__base); \
109 asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
110 asm("":"=A" (n):"a" (__low),"d" (__high)); \
116 /* This divides two 64bit unsigned ints
117 * The previous version only allows 32 bit bases(?)...
119 * NOTE: This absolutely sucks... there has to be a better way....
121 #define do_divll(n, base) ({ \
122 ullong_t __rem = 0; \
123 ullong_t __num = 0; \