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.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
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.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #include <devices/simple_pic.h>
21 #include <palacios/vmm_intr.h>
22 #include <palacios/vmm_types.h>
23 #include <palacios/vmm.h>
31 static int pic_intr_pending(void * private_data) {
32 struct pic_internal * data = (struct pic_internal *)private_data;
34 return (data->pending_irq > 0);
37 static int pic_raise_intr(void * private_data, int irq) {
38 struct pic_internal * data = (struct pic_internal *)private_data;
40 data->pending_irq = irq;
47 static int pic_get_intr_number(void * private_data) {
48 struct pic_internal * data = (struct pic_internal *)private_data;
50 return data->pending_irq;
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
63 static int pic_init_device(struct vm_device * dev) {
64 struct pic_internal * data = (struct pic_internal *)dev->private_data;
65 v3_register_intr_controller(dev->vm, &intr_ops, data);
66 data->pending_irq = 0;
72 static int pic_deinit_device(struct vm_device * dev) {
80 static struct vm_device_ops dev_ops = {
81 .init = pic_init_device,
82 .deinit = pic_deinit_device,
89 struct vm_device * v3_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);
94 struct vm_device * pic_dev = v3_create_device("Simple Pic", &dev_ops, state);