X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2F8259a.c;fp=palacios%2Fsrc%2Fdevices%2F8259a.c;h=036b0bf982bdb5edfc9af29fb4472ec6fd27e7d1;hb=37c18b2c2335a41c68c2f0b779fd2b7d51ab216d;hp=83c0ff33612ff0623f9e09f703be5953c3a5f1cb;hpb=0160025157d9bc39687eb0c5df6cb3d965d20e07;p=palacios.git diff --git a/palacios/src/devices/8259a.c b/palacios/src/devices/8259a.c index 83c0ff3..036b0bf 100644 --- a/palacios/src/devices/8259a.c +++ b/palacios/src/devices/8259a.c @@ -18,10 +18,11 @@ */ -#include + #include #include #include +#include #ifndef DEBUG_PIC #undef PrintDebug @@ -685,10 +686,47 @@ static int write_elcr_port(ushort_t port, void * src, uint_t length, struct vm_d -static int pic_init(struct vm_device * dev) { - struct pic_internal * state = (struct pic_internal*)dev->private_data; - v3_register_intr_controller(dev->vm, &intr_ops, state); + + +static int pic_free(struct vm_device * dev) { + v3_dev_unhook_io(dev, MASTER_PORT1); + v3_dev_unhook_io(dev, MASTER_PORT2); + v3_dev_unhook_io(dev, SLAVE_PORT1); + v3_dev_unhook_io(dev, SLAVE_PORT2); + + return 0; +} + + + + + + + +static struct v3_device_ops dev_ops = { + .free = pic_free, + .reset = NULL, + .start = NULL, + .stop = NULL, +}; + + + +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 * dev = v3_allocate_device("8259A", &dev_ops, state); + + if (v3_attach_device(vm, dev) == -1) { + PrintError("Could not attach device %s\n", "8259A"); + return -1; + } + + + v3_register_intr_controller(vm, &intr_ops, state); state->master_irr = 0; state->master_isr = 0; @@ -731,36 +769,5 @@ static int pic_init(struct vm_device * dev) { } -static int pic_deinit(struct vm_device * dev) { - v3_dev_unhook_io(dev, MASTER_PORT1); - v3_dev_unhook_io(dev, MASTER_PORT2); - v3_dev_unhook_io(dev, SLAVE_PORT1); - v3_dev_unhook_io(dev, SLAVE_PORT2); - - return 0; -} - - - - - - -static struct vm_device_ops dev_ops = { - .init = pic_init, - .deinit = pic_deinit, - .reset = NULL, - .start = NULL, - .stop = NULL, -}; - - -struct vm_device * v3_create_pic() { - struct pic_internal * state = NULL; - state = (struct pic_internal *)V3_Malloc(sizeof(struct pic_internal)); - V3_ASSERT(state != NULL); - - struct vm_device *device = v3_create_device("8259A", &dev_ops, state); - - return device; -} +device_register("PIC", pic_init);