* redistribute, and modify it as specified in the file "V3VEE_LICENSE".
*/
-#include <devices/simple_pic.h>
+
#include <palacios/vmm_intr.h>
#include <palacios/vmm_types.h>
#include <palacios/vmm.h>
-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)