5 #include <geekos/mem.h>
6 #include <geekos/malloc.h>
14 void * Allocate_VMM_Pages(int num_pages);
15 void Free_VMM_Page(void * page);
17 void * VMM_Malloc(unsigned int size);
18 void VMM_Free(void * addr);
20 void * Identity(void *addr);
25 int hook_irq_stub(struct guest_info * info, int irq);
30 int geekos_hook_interrupt_new(uint_t irq, void *opaque);
33 unsigned int get_cpu_khz();
48 # define do_div(n,base) ({ \
49 uint32_t __base = (base); \
51 __rem = ((uint64_t)(n)) % __base; \
52 (n) = ((uint64_t)(n)) / __base; \
59 * do_div() is NOT a C function. It wants to return
60 * two values (the quotient and the remainder), but
61 * since that doesn't work very well in C, what it
64 * - modifies the 64-bit dividend _in_place_
65 * - returns the 32-bit remainder
67 * This ends up being the most efficient "calling
70 #define do_div(n,base) ({ \
71 unsigned long __upper, __low, __high, __mod, __base; \
73 asm("":"=a" (__low), "=d" (__high):"A" (n)); \
76 __upper = __high % (__base); \
77 __high = __high / (__base); \
79 asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
80 asm("":"=A" (n):"a" (__low),"d" (__high)); \