X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fnvram.c;h=e2d1e05e6ed8cf34ec3163b26bad300e557eefeb;hb=0956466aad020813d1e470df366d552fdabab2a9;hp=36da2aacd973cf52ac62d54e063a3037393b6fc7;hpb=82b8b87c344fcd1eab22e3f3be5ad54cbb3f8f68;p=palacios.git diff --git a/palacios/src/devices/nvram.c b/palacios/src/devices/nvram.c index 36da2aa..e2d1e05 100644 --- a/palacios/src/devices/nvram.c +++ b/palacios/src/devices/nvram.c @@ -25,6 +25,9 @@ #include #include +#include +#include +#include #ifndef CONFIG_DEBUG_NVRAM #undef PrintDebug @@ -454,7 +457,7 @@ static void update_time( struct vm_device * dev, uint_t period_us) { } -static int handle_timer_event(struct guest_info * info, +static int handle_timer_event(struct v3_vm_info * vm, struct v3_timer_event * evt, void * priv_data) { @@ -589,8 +592,8 @@ static void init_harddrives(struct nvram_internal * nvram) { } } -static int init_nvram_state(struct vm_device * dev) { - struct guest_info * info = dev->vm; +static int init_nvram_state(struct v3_vm_info * vm, struct vm_device * dev) { + struct nvram_internal * nvram = (struct nvram_internal *)dev->private_data; memset(nvram->mem_state, 0, NVRAM_REG_MAX); @@ -669,7 +672,7 @@ static int init_nvram_state(struct vm_device * dev) { nvram->us = 0; nvram->pus = 0; - set_memory_size(nvram, info->mem_size); + set_memory_size(nvram, vm->mem_size); init_harddrives(nvram); nvram->dev_state = NVRAM_READY; @@ -704,10 +707,8 @@ static int nvram_stop_device(struct vm_device * dev) { -static int nvram_write_reg_port(ushort_t port, - void * src, - uint_t length, - struct vm_device * dev) { +static int nvram_write_reg_port(struct guest_info * core, ushort_t port, + void * src, uint_t length, struct vm_device * dev) { struct nvram_internal * data = (struct nvram_internal *)dev->private_data; @@ -717,10 +718,8 @@ static int nvram_write_reg_port(ushort_t port, return 1; } -static int nvram_read_data_port(ushort_t port, - void * dst, - uint_t length, - struct vm_device * dev) { +static int nvram_read_data_port(struct guest_info * core, ushort_t port, + void * dst, uint_t length, struct vm_device * dev) { struct nvram_internal * data = (struct nvram_internal *)dev->private_data; @@ -747,10 +746,8 @@ static int nvram_read_data_port(ushort_t port, } -static int nvram_write_data_port(ushort_t port, - void * src, - uint_t length, - struct vm_device * dev) { +static int nvram_write_data_port(struct guest_info * core, ushort_t port, + void * src, uint_t length, struct vm_device * dev) { struct nvram_internal * data = (struct nvram_internal *)dev->private_data; @@ -791,9 +788,10 @@ static struct v3_device_ops dev_ops = { -static int nvram_init(struct guest_info * vm, void * cfg_data) { +static int nvram_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct nvram_internal * nvram_state = NULL; - struct vm_device * ide = v3_find_dev(vm, (char *)cfg_data); + struct vm_device * ide = v3_find_dev(vm, v3_cfg_val(cfg, "storage")); + char * dev_id = v3_cfg_val(cfg, "ID"); if (!ide) { PrintError("Could not find IDE device\n"); @@ -807,15 +805,15 @@ static int nvram_init(struct guest_info * vm, void * cfg_data) { nvram_state->ide = ide; - struct vm_device * dev = v3_allocate_device("NVRAM", &dev_ops, nvram_state); + struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, nvram_state); if (v3_attach_device(vm, dev) == -1) { - PrintError("Could not attach device %s\n", "NVRAM"); + PrintError("Could not attach device %s\n", dev_id); return -1; } - init_nvram_state(dev); + init_nvram_state(vm, dev); // hook ports v3_dev_hook_io(dev, NVRAM_REG_PORT, NULL, &nvram_write_reg_port);