1 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
2 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
8 #include <geekos/mem.h>
9 #include <geekos/malloc.h>
17 void * Allocate_VMM_Pages(int num_pages);
18 void Free_VMM_Page(void * page);
20 void * VMM_Malloc(unsigned int size);
21 void VMM_Free(void * addr);
23 void * Identity(void *addr);
28 int hook_irq_stub(struct guest_info * info, int irq);
33 int geekos_hook_interrupt_new(uint_t irq, void *opaque);
36 unsigned int get_cpu_khz();
51 # define do_div(n,base) ({ \
52 uint32_t __base = (base); \
54 __rem = ((uint64_t)(n)) % __base; \
55 (n) = ((uint64_t)(n)) / __base; \
62 * do_div() is NOT a C function. It wants to return
63 * two values (the quotient and the remainder), but
64 * since that doesn't work very well in C, what it
67 * - modifies the 64-bit dividend _in_place_
68 * - returns the 32-bit remainder
70 * This ends up being the most efficient "calling
73 #define do_div(n,base) ({ \
74 unsigned long __upper, __low, __high, __mod, __base; \
76 asm("":"=a" (__low), "=d" (__high):"A" (n)); \
79 __upper = __high % (__base); \
80 __high = __high / (__base); \
82 asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
83 asm("":"=A" (n):"a" (__low),"d" (__high)); \