1 #include <geekos/vmm_stubs.h>
2 #include <geekos/serial.h>
3 #include <palacios/vm_guest.h>
6 void * Identity(void *addr) { return addr; };
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);
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);
17 if (tmp_page != start_page + (PAGE_SIZE * i)) {
18 //we have to start over...;
20 Free_Page(start_page + (PAGE_SIZE * i));
23 start_page = Alloc_Page();
24 //SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages);
34 void Free_VMM_Page(void * page) {
39 void * VMM_Malloc(unsigned int size) {
40 return Malloc((unsigned long) size);
44 void VMM_Free(void * addr) {
51 struct guest_info * irq_map[256];
54 static void pic_intr_handler(struct Interrupt_State * state) {
56 struct guest_info * info = irq_map[state->intNum - 32];
59 info->vm_ops.raise_irq(irq_map[state->intNum], state->intNum, state->errorCode);
61 SerialPrint("Interrupt handler error: NULL pointer found, no action taken\n");
70 int hook_irq_stub(struct guest_info * info, int irq) {
75 SerialPrint("Hooking IRQ: %d (vm=0x%x)\n", irq, info);
77 Install_IRQ(irq, pic_intr_handler);
83 int ack_irq(int irq) {
90 memset(irq_map, 0, sizeof(struct guest_info *) * 256);