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".
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
65 static int pic_free(struct vm_device * dev) {
72 static struct v3_device_ops dev_ops = {
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);
87 struct vm_device * dev = v3_allocate_device("SIMPLE_PIC", &dev_ops, state);
89 if (v3_attach_device(vm, dev) == -1) {
90 PrintError("Could not attach device %s\n", "SIMPLE_PIC");
95 v3_register_intr_controller(vm, &intr_ops, state);
96 state->pending_irq = 0;
101 device_register("SIMPLE_PIC", pic_init)