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.


9a508bd7975a279cb1fb27779954c6a27c210cdd
[palacios.git] / palacios / src / palacios / vmm_config_class.h
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
20 #include <palacios/vm_guest_mem.h>
21
22
23 static int pre_config_pc_core(struct guest_info * info, v3_cfg_tree_t * cfg) { 
24
25     info->mem_mode = PHYSICAL_MEM;
26
27
28     info->vm_regs.rdi = 0;
29     info->vm_regs.rsi = 0;
30     info->vm_regs.rbp = 0;
31     info->vm_regs.rsp = 0;
32     info->vm_regs.rbx = 0;
33     info->vm_regs.rdx = 0;
34     info->vm_regs.rcx = 0;
35     info->vm_regs.rax = 0;
36
37     return 0;
38 }
39
40 static int post_config_pc_core(struct guest_info * info, v3_cfg_tree_t * cfg) { 
41
42     v3_print_mem_map(info->vm_info);
43     return 0;
44 }
45
46 static int post_config_pc(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
47
48     v3_cfg_tree_t * bios_tree = NULL;
49     v3_cfg_tree_t * bios_list = NULL;
50
51     bios_tree = v3_cfg_subtree(cfg, "bioses");
52
53
54     if (!v3_cfg_val(bios_tree, "disable_vgabios")) {
55
56 #if defined(V3_CONFIG_SEABIOS) || defined(V3_CONFIG_BOCHSBIOS)
57
58 #define VGABIOS_START 0x000c0000
59         /* layout vgabios */
60         {
61             extern uint8_t v3_vgabios_start[];
62             extern uint8_t v3_vgabios_end[];
63             void * vgabios_dst = 0;
64
65             if (v3_gpa_to_hva(&(vm->cores[0]), VGABIOS_START, (addr_t *)&vgabios_dst) == -1) {
66                 PrintError(vm, VCORE_NONE, "Could not find VGABIOS destination address\n");
67                 return -1;
68             }
69
70             V3_Print(vm,VCORE_NONE,"Mapping VGA BIOS of %llu bytes at address %p\n", (uint64_t)(v3_vgabios_end-v3_vgabios_start), (void*)VGABIOS_START);
71             memcpy(vgabios_dst, v3_vgabios_start, v3_vgabios_end - v3_vgabios_start);   
72         }
73
74 #endif
75
76     }
77
78
79     if (!v3_cfg_val(bios_tree, "disable_rombios")) {
80
81         /* layout rombios */
82         {
83             extern uint8_t v3_rombios_start[];
84             extern uint8_t v3_rombios_end[];
85             void * rombios_dst = 0;
86
87
88
89             if (v3_gpa_to_hva(&(vm->cores[0]), V3_CONFIG_BIOS_START, (addr_t *)&rombios_dst) == -1) {
90                 PrintError(vm, VCORE_NONE, "Could not find ROMBIOS destination address\n");
91                 return -1;
92             }
93
94             V3_Print(vm,VCORE_NONE,"Mapping BIOS of %llu bytes at address %p\n", (uint64_t)(v3_rombios_end-v3_rombios_start), (void*)V3_CONFIG_BIOS_START);
95             memcpy(rombios_dst, v3_rombios_start, v3_rombios_end - v3_rombios_start);
96
97 #ifdef V3_CONFIG_SEABIOS
98             // SEABIOS is also mapped into end of 4GB region
99             if (v3_add_shadow_mem(vm, V3_MEM_CORE_ANY, 
100                         0xfffe0000, 0xffffffff,
101                         (addr_t)V3_PAddr(rombios_dst)) == -1) {
102                 PrintError(vm, VCORE_NONE, "Error mapping SEABIOS to end of memory\n");
103                 return -1;
104             }
105             V3_Print(vm,VCORE_NONE,"Additionally mapping SEABIOS of %llu bytes at address %p\n", (uint64_t)(v3_rombios_end-v3_rombios_start), (void*)0xfffe0000);
106 #endif
107
108         }
109     }
110
111     bios_list = v3_cfg_subtree(bios_tree, "bios");
112
113     while (bios_list) {
114         char * id = v3_cfg_val(bios_list, "file");
115         char * addr = v3_cfg_val(bios_list, "address");
116         uint64_t file_ptr = 0;
117         void * dest = NULL;
118         struct v3_cfg_file * file = NULL;
119
120         if (!id) {
121             PrintError(vm, VCORE_NONE, "Could not find bios file\n");
122             continue;
123         }
124
125         if (!addr) {
126             PrintError(vm, VCORE_NONE, "Could not find bios address\n");
127             continue;
128         }
129
130         file = v3_cfg_get_file(vm, id);
131         if (!file) {
132             PrintError(vm, VCORE_NONE, "Invalid BIOS file: %s\n", id);
133             continue;
134         }
135
136         file_ptr = atox(addr);
137
138         V3_Print(vm, VCORE_NONE, "Copying BIOS ROM (%s) to %p (size=%lld)\n", 
139                  id,
140                  (void*)file_ptr,
141                  file->size);
142
143         if (v3_gpa_to_hva(&(vm->cores[0]), (addr_t)file_ptr, (addr_t *)&dest) == -1) {
144             PrintError(vm, VCORE_NONE, "Could not find BIOS (%s) destination address\n", id);
145             continue;
146         }
147
148         memcpy((void*)dest, file->data, file->size);
149
150         V3_Print(vm, VCORE_NONE, "Moving on to next BIOS file\n");
151         bios_list = v3_cfg_next_branch(bios_list);
152     }
153
154     return 0;
155 }
156