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 / palacios / vmm_intr.c
1 #include <palacios/vmm_intr.h>
2 #include <palacios/vmm.h>
3
4 #include <palacios/vm_guest.h>
5
6
7 void init_interrupt_state(struct guest_info * info) {
8   info->intr_state.excp_pending = 0;
9   info->intr_state.excp_num = 0;
10   info->intr_state.excp_error_code = 0;
11
12   info->vm_ops.raise_irq = &raise_irq;
13 }
14
15 void set_intr_controller(struct guest_info * info, struct intr_ctrl_ops * ops, void * state) {
16   info->intr_state.controller = ops;
17   info->intr_state.controller_state = state;
18 }
19
20
21 int raise_exception(struct guest_info * info, uint_t excp) {
22
23   /* We can't stack exceptions, 
24      but do we need to have some sort of priority?
25   */
26   if (info->intr_state.excp_pending) {
27     info->intr_state.excp_pending = 1;
28     info->intr_state.excp_num = excp;
29   } else {
30     return -1;
31   }
32
33   return 0;
34 }
35
36
37 int raise_irq(struct guest_info * info, int irq, int error_code) {
38   // Look up PIC and resend
39   V3_ASSERT(info);
40   V3_ASSERT(info->intr_state.controller);
41   V3_ASSERT(info->intr_state.controller->raise_intr);
42
43   //  if ((info->intr_state.controller) && 
44   //  (info->intr_state.controller->raise_intr)) {
45     info->intr_state.controller->raise_intr(info->intr_state.controller_state, irq, error_code);
46     //} else {
47     // PrintDebug("There is no registered Interrupt Controller... (NULL POINTER)\n");
48     // return -1;
49     //}
50   return 0;
51 }
52
53
54 int intr_pending(struct vm_intr * intr) {
55   if (intr->excp_pending) {
56     return 1;
57   } else if (intr->controller->intr_pending(intr->controller_state)) {
58     return 1;
59   }
60
61   /* Check [A]PIC */
62
63   return 0;
64 }
65
66
67 uint_t get_intr_number(struct vm_intr * intr) {
68   if (intr->excp_pending) {
69     return intr->excp_num;
70   } else if (intr->controller->intr_pending(intr->controller_state)) {
71     return intr->controller->get_intr_number(intr->controller_state);
72   }
73
74   /* someway to get the [A]PIC intr */
75
76   return 0;
77 }
78
79
80 uint_t get_intr_type(struct vm_intr * intr) {
81   if (intr->excp_pending) {
82     return EXCEPTION;
83   } else if (intr->controller->intr_pending(intr->controller_state)) {
84     return EXTERNAL_IRQ;
85   }
86
87   return INVALID_INTR;
88 }
89
90 int hook_irq(struct guest_info * info, int irq) {
91   extern struct vmm_os_hooks * os_hooks;
92
93   return os_hooks->hook_interrupt(info, irq);
94 }