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.


Add Virtual PCI and Virtual NIC
[palacios.git] / geekos / include / geekos / vmm_stubs.h
1 /*
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #ifndef __VMM_STUBS_H
21 #define __VMM_STUBS_H
22
23
24 #include <geekos/mem.h>
25 #include <geekos/malloc.h>
26
27
28 struct guest_info;
29
30
31
32
33 void * Allocate_VMM_Pages(int num_pages);
34 void Free_VMM_Page(void * page);
35
36 void * VMM_Malloc(unsigned int size);
37 void VMM_Free(void * addr);
38
39 void * Identity(void *addr);
40
41
42
43
44 int hook_irq_stub(struct guest_info * info, int irq);
45 int ack_irq(int irq);
46
47
48
49 int geekos_hook_interrupt(struct guest_info * info, uint_t irq);
50
51
52
53 unsigned int get_cpu_khz();
54
55 void Init_Stubs(struct guest_info * info);
56
57
58
59
60 /**** 
61  * 
62  * stubs called by geekos....
63  * 
64  ***/
65 void send_key_to_vmm(unsigned char status, unsigned char scancode);
66 void send_mouse_to_vmm(unsigned char packet[3]);
67 void send_tick_to_vmm(unsigned int period_us);
68
69
70 #if 0
71
72 # define do_div(n,base) ({                                      \
73         uint32_t __base = (base);                               \
74         uint32_t __rem;                                         \
75         __rem = ((uint64_t)(n)) % __base;                       \
76         (n) = ((uint64_t)(n)) / __base;                         \
77         __rem;                                                  \
78  })
79
80 #else
81
82 /*
83  * do_div() is NOT a C function. It wants to return
84  * two values (the quotient and the remainder), but
85  * since that doesn't work very well in C, what it
86  * does is:
87  *
88  * - modifies the 64-bit dividend _in_place_
89  * - returns the 32-bit remainder
90  *
91  * This ends up being the most efficient "calling
92  * convention" on x86.
93  */
94 #define do_div(n,base) ({                                    \
95       unsigned long __upper, __low, __high, __mod, __base;   \
96       __base = (base);                                       \
97       asm("":"=a" (__low), "=d" (__high):"A" (n));           \
98       __upper = __high;                                      \
99       if (__high) {                                          \
100         __upper = __high % (__base);                         \
101         __high = __high / (__base);                          \
102       }                                                                 \
103       asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
104       asm("":"=A" (n):"a" (__low),"d" (__high));                        \
105       __mod;                                                            \
106     })
107
108 #endif
109
110
111
112
113
114
115 #endif