X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fsimple_pic.c;h=96907df2823ad31b190b1ed9286d99846dd72f70;hp=828b588734f453b414bf09f52426e0e690089fa0;hb=571979dad8fc2138a7e11c4fe61e812a0a0b17d1;hpb=4bc3ee757b44d3e466fd89e348106c47fa5511ee diff --git a/palacios/src/devices/simple_pic.c b/palacios/src/devices/simple_pic.c index 828b588..96907df 100644 --- a/palacios/src/devices/simple_pic.c +++ b/palacios/src/devices/simple_pic.c @@ -17,7 +17,7 @@ * redistribute, and modify it as specified in the file "V3VEE_LICENSE". */ -#include + #include #include #include @@ -60,39 +60,42 @@ static struct intr_ctrl_ops intr_ops = { -static int pic_init_device(struct vm_device * dev) { - struct pic_internal * data = (struct pic_internal *)dev->private_data; - v3_register_intr_controller(dev->vm, &intr_ops, data); - data->pending_irq = 0; - - return 0; -} -static int pic_deinit_device(struct vm_device * dev) { +static int pic_free(struct vm_device * dev) { return 0; } - -static struct vm_device_ops dev_ops = { - .init = pic_init_device, - .deinit = pic_deinit_device, +static struct v3_device_ops dev_ops = { + .free = pic_free, .reset = NULL, .start = NULL, .stop = NULL }; -struct vm_device * v3_create_simple_pic() { + + +static int pic_init(struct guest_info * vm, void * cfg_data) { struct pic_internal * state = NULL; state = (struct pic_internal *)V3_Malloc(sizeof(struct pic_internal)); V3_ASSERT(state != NULL); - struct vm_device * pic_dev = v3_create_device("Simple Pic", &dev_ops, state); + struct vm_device * dev = v3_allocate_device("SIMPLE_PIC", &dev_ops, state); + + if (v3_attach_device(vm, dev) == -1) { + PrintError("Could not attach device %s\n", "SIMPLE_PIC"); + return -1; + } + + v3_register_intr_controller(vm, &intr_ops, state); + state->pending_irq = 0; - return pic_dev; + return 0; } + +device_register("SIMPLE_PIC", pic_init)