Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


symbiotic module updates
[palacios.git] / palacios / src / palacios / vmm_symmod.c
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19 #include <palacios/vmm.h>
20 #include <palacios/vmm_symmod.h>
21 #include <palacios/vmm_symbiotic.h>
22 #include <palacios/vm_guest.h>
23
24 static struct hashtable * master_mod_table = NULL;
25
26
27 static uint_t mod_hash_fn(addr_t key) {
28     char * name = (char *)key;
29     return v3_hash_buffer((uchar_t *)name, strlen(name));
30 }
31
32 static int mod_eq_fn(addr_t key1, addr_t key2) {
33     char * name1 = (char *)key1;
34     char * name2 = (char *)key2;
35     
36     return (strcmp(name1, name2) == 0);
37 }
38
39
40
41 int V3_init_symmod() {
42     extern struct v3_sym_module __start__v3_modules[];
43     extern struct v3_sym_module __stop__v3_modules[];
44     struct v3_sym_module * tmp_mod = __start__v3_modules;
45     int i = 0;
46
47     master_mod_table = v3_create_htable(0, mod_hash_fn, mod_eq_fn);
48
49     while (tmp_mod != __stop__v3_modules) {
50         if (v3_htable_search(master_mod_table, (addr_t)(tmp_mod->name))) {
51             PrintError("Multiple instances of Module (%s)\n", tmp_mod->name);
52             return -1;
53         }       
54         PrintDebug("Registering Symbiotic Module (%s)\n", tmp_mod->name);
55
56         if (v3_htable_insert(master_mod_table, 
57                              (addr_t)(tmp_mod->name),
58                              (addr_t)(tmp_mod)) == 0) {
59             PrintError("Could not insert module %s to master list\n", tmp_mod->name);
60             return -1;
61         }
62         tmp_mod = &(__start__v3_modules[++i]);
63     }
64     
65     return 0;
66 }
67
68
69
70 int v3_init_symmod_vm(struct v3_vm_info * info, v3_cfg_tree_t * cfg) {
71     return 0;
72 }
73
74
75
76 int v3_set_symmod_loader(struct v3_vm_info * vm, struct v3_symmod_loader_ops * ops, void * priv_data) {
77     struct v3_symmod_state * symmod_state = &(vm->sym_vm_state.symmod_state);
78    
79     symmod_state->loader_ops = ops;
80     symmod_state->loader_data = priv_data;
81  
82     return 0;
83 }
84
85
86
87
88
89 int v3_load_sym_module(struct v3_vm_info * vm, char * mod_name) {
90     struct v3_symmod_state * symmod_state = &(vm->sym_vm_state.symmod_state);
91     struct v3_sym_module * mod = (struct v3_sym_module *)v3_htable_search(master_mod_table, (addr_t)mod_name);
92
93     if (!mod) {
94         PrintError("Could not find module %s\n", mod_name);
95         return -1;
96     }
97
98     PrintDebug("Loading Module (%s)\n", mod_name);
99
100     return symmod_state->loader_ops->load_module(vm, mod->name, mod->end_addr - mod->start_addr, symmod_state->loader_data);
101 }
102
103
104
105
106 struct v3_sym_module * v3_get_sym_module(struct v3_vm_info * vm, char * name) {
107     struct v3_sym_module * mod = (struct v3_sym_module *)v3_htable_search(master_mod_table, (addr_t)name);
108
109     if (!mod) {
110         PrintError("Could not find module %s\n", name);
111         return NULL;
112     }
113
114     return mod;
115 }