Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


modified copyright tags
[palacios.git] / palacios / include / geekos / vmm_stubs.h
1 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
2 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
3
4 #ifndef __VMM_STUBS_H
5 #define __VMM_STUBS_H
6
7
8 #include <geekos/mem.h>
9 #include <geekos/malloc.h>
10
11
12 struct guest_info;
13
14
15
16
17 void * Allocate_VMM_Pages(int num_pages);
18 void Free_VMM_Page(void * page);
19
20 void * VMM_Malloc(unsigned int size);
21 void VMM_Free(void * addr);
22
23 void * Identity(void *addr);
24
25
26
27
28 int hook_irq_stub(struct guest_info * info, int irq);
29 int ack_irq(int irq);
30
31
32
33 int geekos_hook_interrupt_new(uint_t irq, void *opaque);
34
35
36 unsigned int get_cpu_khz();
37
38 void Init_Stubs();
39
40
41
42
43
44
45
46
47
48
49 #if 0
50
51 # define do_div(n,base) ({                                      \
52         uint32_t __base = (base);                               \
53         uint32_t __rem;                                         \
54         __rem = ((uint64_t)(n)) % __base;                       \
55         (n) = ((uint64_t)(n)) / __base;                         \
56         __rem;                                                  \
57  })
58
59 #else
60
61 /*
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
65  * does is:
66  *
67  * - modifies the 64-bit dividend _in_place_
68  * - returns the 32-bit remainder
69  *
70  * This ends up being the most efficient "calling
71  * convention" on x86.
72  */
73 #define do_div(n,base) ({                                    \
74       unsigned long __upper, __low, __high, __mod, __base;   \
75       __base = (base);                                       \
76       asm("":"=a" (__low), "=d" (__high):"A" (n));           \
77       __upper = __high;                                      \
78       if (__high) {                                          \
79         __upper = __high % (__base);                         \
80         __high = __high / (__base);                          \
81       }                                                                 \
82       asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
83       asm("":"=A" (n):"a" (__low),"d" (__high));                        \
84       __mod;                                                            \
85     })
86
87 #endif
88
89
90
91
92
93
94 #endif