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.


*** empty log message ***
[palacios.git] / palacios / src / geekos / vmm_stubs.c
1 #include <geekos/vmm_stubs.h>
2 #include <geekos/serial.h>
3 #include <palacios/vm_guest.h>
4
5
6 void * Identity(void *addr) { return addr; };
7
8 void * Allocate_VMM_Pages(int num_pages) {
9   void * start_page = Alloc_Page();
10   //SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages); 
11   int i = 1;
12
13   while (i < num_pages) {
14     void * tmp_page = Alloc_Page();
15     //SerialPrint("Allocating Page: %x (%d of %d)\n",tmp_page, i+1, num_pages); 
16     
17     if (tmp_page != start_page + (PAGE_SIZE * i)) {
18       //we have to start over...;
19       while (i >= 0) {
20         Free_Page(start_page + (PAGE_SIZE * i));
21         i--;
22       }
23       start_page = Alloc_Page();
24       //SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages);
25       i = 1;
26       continue;
27     }
28     i++;
29   }
30
31   return start_page;
32 }
33
34 void Free_VMM_Page(void * page) {
35   Free_Page(page);
36 }
37
38
39 void * VMM_Malloc(unsigned int size) {
40   return Malloc((unsigned long) size);
41 }
42
43
44 void VMM_Free(void * addr) {
45   Free(addr);
46 }
47
48
49
50 struct guest_info * irq_map[256];
51
52 static void pic_intr_handler(struct Interrupt_State * state) {
53   Begin_IRQ(state);
54   struct guest_info * info =   irq_map[state->intNum - 32];
55   SerialPrint("Interrupt %d (IRQ=%d)\n", state->intNum, state->intNum - 32);
56
57   if (info) {
58     info->vm_ops.raise_irq(info, state->intNum - 32, state->errorCode);
59   } else {
60     SerialPrint("Interrupt handler error: NULL pointer found, no action taken\n");
61     End_IRQ(state);
62     return;
63   }
64
65   // End_IRQ(state);
66 }
67
68
69 int hook_irq_stub(struct guest_info * info, int irq) {
70   if (irq_map[irq]) {
71     return -1;
72   }
73
74   SerialPrint("Hooking IRQ: %d (vm=0x%x)\n", irq, info);
75   irq_map[irq] = info;
76   volatile void *foo = pic_intr_handler;
77   foo=0;
78   //  Install_IRQ(irq, pic_intr_handler);
79   // Enable_IRQ(irq);
80   return 0;
81 }
82
83
84 int ack_irq(int irq) {
85   End_IRQ_num(irq);
86   return 0;
87 }
88
89   
90 void Init_Stubs() {
91   memset(irq_map, 0, sizeof(struct guest_info *) * 256);
92 }