X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_extensions.c;h=1db9dc6d0229a93e35d60dc5786b8cbe157021b3;hb=94c7ee057b065f64a3e2faa3df3150f72c99260b;hp=40a0dd0beb8bc257552b55a28d2fd31a2084c42c;hpb=adee0fafaa51f4bf28abe7461006be9b9d3dbceb;p=palacios.git diff --git a/palacios/src/palacios/vmm_extensions.c b/palacios/src/palacios/vmm_extensions.c index 40a0dd0..1db9dc6 100644 --- a/palacios/src/palacios/vmm_extensions.c +++ b/palacios/src/palacios/vmm_extensions.c @@ -20,7 +20,7 @@ #include #include - +#include #include @@ -69,9 +69,101 @@ int V3_init_extensions() { } + + int V3_deinit_extensions() { v3_free_htable(ext_table, 0, 0); return 0; } +int v3_init_ext_manager(struct v3_vm_info * vm) { + struct v3_extensions * ext_state = &(vm->extensions); + + INIT_LIST_HEAD(&(ext_state->extensions)); + INIT_LIST_HEAD(&(ext_state->on_exits)); + INIT_LIST_HEAD(&(ext_state->on_entries)); + + return 0; +} + + +int v3_deinit_ext_manager(struct v3_vm_info * vm) { + + PrintError("I should really do something here... \n"); + return -1; +} + + + +int v3_add_extension(struct v3_vm_info * vm, const char * name, v3_cfg_tree_t * cfg) { + struct v3_extension_impl * impl = NULL; + struct v3_extension * ext = NULL; + + impl = (void *)v3_htable_search(ext_table, (addr_t)name); + + if (impl == NULL) { + PrintError("Could not find requested extension (%s)\n", name); + return -1; + } + + V3_ASSERT(impl->init); + + ext = V3_Malloc(sizeof(struct v3_extension)); + + if (!ext) { + PrintError("Could not allocate extension\n"); + return -1; + } + + ext->impl = impl; + + if (impl->init(vm, cfg, &(ext->priv_data)) == -1) { + PrintError("Error initializing Extension (%s)\n", name); + V3_Free(ext); + return -1; + } + + list_add(&(ext->node), &(vm->extensions.extensions)); + + if (impl->on_exit) { + list_add(&(ext->exit_node), &(vm->extensions.on_exits)); + } + + if (impl->on_entry) { + list_add(&(ext->entry_node), &(vm->extensions.on_entries)); + } + + return 0; +} + +int v3_init_core_extensions(struct guest_info * core) { + struct v3_extension * ext = NULL; + + list_for_each_entry(ext, &(core->vm_info->extensions.extensions), node) { + if ((ext->impl) && (ext->impl->core_init)) { + if (ext->impl->core_init(core, ext->priv_data) == -1) { + PrintError("Error configuring per core extension %s on core %d\n", + ext->impl->name, core->cpu_id); + return -1; + } + } + } + + return 0; +} + + + + +void * v3_get_extension_state(struct v3_vm_info * vm, const char * name) { + struct v3_extension * ext = NULL; + + list_for_each_entry(ext, &(vm->extensions.extensions), node) { + if (strncmp(ext->impl->name, name, strlen(ext->impl->name)) == 0) { + return ext->priv_data; + } + } + + return NULL; +}