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.


added new copyright and license
[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 #include <devices/simple_pic.h>
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 int pic_init_device(struct vm_device * dev) {
64   struct pic_internal * data = (struct pic_internal *)dev->private_data;
65   set_intr_controller(dev->vm, &intr_ops, data);
66   data->pending_irq = 0;
67
68   return 0;
69 }
70
71
72 int pic_deinit_device(struct vm_device * dev) {
73   return 0;
74 }
75
76
77
78
79
80 static struct vm_device_ops dev_ops = {
81   .init = pic_init_device,
82   .deinit = pic_deinit_device,
83   .reset = NULL,
84   .start = NULL,
85   .stop = NULL
86 };
87
88
89 struct vm_device * create_simple_pic() {
90   struct pic_internal * state = NULL;
91   state = (struct pic_internal *)V3_Malloc(sizeof(struct pic_internal));
92   V3_ASSERT(state != NULL);
93
94   struct vm_device * pic_dev = create_device("Simple Pic", &dev_ops, state);
95
96
97   return pic_dev;
98 }