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.


More detailed error handling on msr writes
[palacios.git] / palacios / src / devices / simple_pic.c
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
21 #include <palacios/vmm_intr.h>
22 #include <palacios/vmm_types.h>
23 #include <palacios/vmm.h>
24
25 struct pic_internal {
26     int pending_irq;
27
28 };
29
30
31 static int pic_intr_pending(void * private_data) {
32     struct pic_internal * data = (struct pic_internal *)private_data;
33   
34     return (data->pending_irq > 0);
35 }
36
37 static int pic_raise_intr(void * private_data, int irq) {
38     struct pic_internal * data = (struct pic_internal *)private_data;
39
40     data->pending_irq = irq;
41
42
43     return 0;
44 }
45
46
47 static int pic_get_intr_number(void * private_data) {
48     struct pic_internal * data = (struct pic_internal *)private_data;
49
50     return data->pending_irq;
51 }
52
53
54 static struct intr_ctrl_ops intr_ops = {
55     .intr_pending = pic_intr_pending,
56     .get_intr_number = pic_get_intr_number,
57     .raise_intr = pic_raise_intr
58 };
59
60
61
62
63
64
65 static int pic_free(struct vm_device * dev) {
66     return 0;
67 }
68
69
70
71
72 static struct v3_device_ops dev_ops = { 
73     .free = pic_free,
74     .reset = NULL,
75     .start = NULL,
76     .stop = NULL
77 };
78
79
80
81
82 static int pic_init(struct guest_info * vm, void * cfg_data) {
83     struct pic_internal * state = NULL;
84     state = (struct pic_internal *)V3_Malloc(sizeof(struct pic_internal));
85     V3_ASSERT(state != NULL);
86
87     struct vm_device * dev = v3_allocate_device("SIMPLE_PIC", &dev_ops, state);
88
89     if (v3_attach_device(vm, dev) == -1) {
90         PrintError("Could not attach device %s\n", "SIMPLE_PIC");
91         return -1;
92     }
93
94
95     v3_register_intr_controller(vm, &intr_ops, state);
96     state->pending_irq = 0;
97
98     return 0;
99 }
100
101 device_register("SIMPLE_PIC", pic_init)