5 #include <geekos/mem.h>
6 #include <geekos/malloc.h>
11 void * Allocate_VMM_Pages(int num_pages);
12 void Free_VMM_Page(void * page);
14 void * VMM_Malloc(unsigned int size);
15 void VMM_Free(void * addr);
17 void * Identity(void *addr);
20 int hook_irq_stub(struct guest_info * info, int irq);
24 unsigned int get_cpu_khz();
38 # define do_div(n,base) ({ \
39 uint32_t __base = (base); \
41 __rem = ((uint64_t)(n)) % __base; \
42 (n) = ((uint64_t)(n)) / __base; \
49 * do_div() is NOT a C function. It wants to return
50 * two values (the quotient and the remainder), but
51 * since that doesn't work very well in C, what it
54 * - modifies the 64-bit dividend _in_place_
55 * - returns the 32-bit remainder
57 * This ends up being the most efficient "calling
60 #define do_div(n,base) ({ \
61 unsigned long __upper, __low, __high, __mod, __base; \
63 asm("":"=a" (__low), "=d" (__high):"A" (n)); \
66 __upper = __high % (__base); \
67 __high = __high / (__base); \
69 asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
70 asm("":"=A" (n):"a" (__low),"d" (__high)); \