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.


lots of changes...
[palacios-OLD.git] / palacios / src / palacios / vmm_irq.c
1 #if 0
2 #include <palacios/vmm_irq.h>
3 #include <palacios/vmm.h>
4
5 void init_irq_map(struct vmm_irq_map * map) {
6   map->head = NULL;
7   map->num_hooks = 0;
8 }
9
10
11 int add_irq_hook(struct vmm_irq_map * map, struct vmm_irq_hook * hook) {
12   if (!(map->head)) {
13     map->head = hook;
14     map->num_hooks = 1;
15     return 0;
16   } else if (map->head->irq > hook->irq) {
17     hook->next = map->head;
18
19     map->head->prev = hook;
20     map->head = hook;
21     map->num_hooks++;
22
23     return 0;
24   } else {
25     struct vmm_irq_hook * tmp_hook = map->head;
26     while ((tmp_hook->next) &&
27            (tmp_hook->next->irq <= hook->irq)) {
28       tmp_hook = tmp_hook->next;
29     }
30
31     if (tmp_hook->irq == hook->irq) {
32       return -1;
33     } else {
34       hook->prev = tmp_hook;
35       hook->next = tmp_hook->next;
36
37       if (tmp_hook->next) {
38         tmp_hook->next->prev = hook;
39       }
40
41       tmp_hook->next = hook;
42
43       map->num_hooks++;
44       return 0;
45     }
46   }
47   return -1;
48 }
49
50
51 int remove_irq_hook(struct vmm_irq_map * map, struct vmm_irq_hook * hook) {
52   if (map->head == hook) {
53     map->head = hook->next;
54   } else if (hook->prev) {
55     hook->prev->next = hook->next;
56   } else {
57     return -1;
58   }
59
60   if (hook->next) {
61     hook->next->prev = hook->prev;
62   }
63
64   map->num_hooks--;
65
66   return 0;
67 }
68
69
70 int hook_irq(struct vmm_irq_map * map, uint_t irq, 
71              int(*handler)(uint_t irq, void * private_data), 
72              void * private_data) {
73
74   struct vmm_irq_hook * hook = NULL;
75   V3_Malloc(struct vmm_irq_hook *, hook, sizeof(struct vmm_irq_hook));
76
77   if (!hook) {
78     // big problems
79     return -1;
80   }
81
82   hook->irq = irq;
83   hook->handler = handler;
84   hook->private_data = private_data;
85   hook->next = NULL;
86   hook->prev = NULL;
87   
88   if (add_irq_hook(map, hook) != 0) {
89     V3_Free(hook);
90     return -1;
91   }
92
93   return 0;
94 }
95
96
97 int unhook_irq(struct vmm_irq_map * map, uint_t irq) {
98   struct vmm_irq_hook * hook = get_irq_hook(map, irq);
99
100   if (!hook) {
101     return -1;
102   }
103
104   remove_irq_hook(map, hook);
105   return 0;
106 }
107
108
109 struct vmm_irq_hook * get_irq_hook(struct vmm_irq_map * map, uint_t irq) {
110   struct vmm_irq_hook * tmp_hook = map->head;
111   
112   while (tmp_hook) {
113     if (tmp_hook->irq == irq) {
114       return tmp_hook;
115     }
116     tmp_hook = tmp_hook->next;
117   }
118   return NULL;
119 }
120
121
122 #endif