1 |
/* |
/* |
2 |
* Cisco 7200 (Predator) simulation platform. |
* Cisco router simulation platform. |
3 |
* Copyright (c) 2006 Christophe Fillot (cf@utc.fr) |
* Copyright (c) 2006 Christophe Fillot (cf@utc.fr) |
4 |
* |
* |
5 |
* Hypervisor generic VM routines. |
* Hypervisor generic VM routines. |
23 |
#include <arpa/inet.h> |
#include <arpa/inet.h> |
24 |
#include <pthread.h> |
#include <pthread.h> |
25 |
|
|
26 |
#include "mips64.h" |
#include "cpu.h" |
27 |
#include "cp0.h" |
#include "vm.h" |
28 |
#include "dynamips.h" |
#include "dynamips.h" |
29 |
#include "device.h" |
#include "device.h" |
30 |
#include "dev_c7200.h" |
#include "dev_c7200.h" |
44 |
#include "hypervisor.h" |
#include "hypervisor.h" |
45 |
|
|
46 |
/* Find the specified CPU */ |
/* Find the specified CPU */ |
47 |
static cpu_mips_t *find_cpu(hypervisor_conn_t *conn,vm_instance_t *vm, |
static cpu_gen_t *find_cpu(hypervisor_conn_t *conn,vm_instance_t *vm, |
48 |
u_int cpu_id) |
u_int cpu_id) |
49 |
{ |
{ |
50 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
51 |
|
|
52 |
cpu = cpu_group_find_id(vm->cpu_group,cpu_id); |
cpu = cpu_group_find_id(vm->cpu_group,cpu_id); |
53 |
|
|
163 |
return(0); |
return(0); |
164 |
} |
} |
165 |
|
|
166 |
|
/* Enable/disable use of sparse memory */ |
167 |
|
static int cmd_set_sparse_mem(hypervisor_conn_t *conn,int argc,char *argv[]) |
168 |
|
{ |
169 |
|
vm_instance_t *vm; |
170 |
|
|
171 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
172 |
|
return(-1); |
173 |
|
|
174 |
|
vm->sparse_mem = atoi(argv[1]); |
175 |
|
|
176 |
|
vm_release(vm); |
177 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
178 |
|
return(0); |
179 |
|
} |
180 |
|
|
181 |
/* Set the clock divisor */ |
/* Set the clock divisor */ |
182 |
static int cmd_set_clock_divisor(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_set_clock_divisor(hypervisor_conn_t *conn,int argc,char *argv[]) |
183 |
{ |
{ |
215 |
int argc,char *argv[]) |
int argc,char *argv[]) |
216 |
{ |
{ |
217 |
vm_instance_t *vm; |
vm_instance_t *vm; |
218 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
219 |
|
|
220 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
221 |
return(-1); |
return(-1); |
223 |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
224 |
return(-1); |
return(-1); |
225 |
|
|
226 |
cpu->idle_pc = strtoull(argv[2],NULL,0); |
cpu->set_idle_pc(cpu,strtoull(argv[2],NULL,0)); |
227 |
|
|
228 |
vm_release(vm); |
vm_release(vm); |
229 |
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
234 |
static int cmd_get_idle_pc_prop(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_get_idle_pc_prop(hypervisor_conn_t *conn,int argc,char *argv[]) |
235 |
{ |
{ |
236 |
vm_instance_t *vm; |
vm_instance_t *vm; |
237 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
238 |
int i; |
int i; |
239 |
|
|
240 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
243 |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
244 |
return(-1); |
return(-1); |
245 |
|
|
246 |
mips64_get_idling_pc(cpu); |
cpu->get_idling_pc(cpu); |
247 |
|
|
248 |
for(i=0;i<cpu->idle_pc_prop_count;i++) { |
for(i=0;i<cpu->idle_pc_prop_count;i++) { |
249 |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"0x%llx [%d]", |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"0x%llx [%d]", |
260 |
static int cmd_show_idle_pc_prop(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_show_idle_pc_prop(hypervisor_conn_t *conn,int argc,char *argv[]) |
261 |
{ |
{ |
262 |
vm_instance_t *vm; |
vm_instance_t *vm; |
263 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
264 |
int i; |
int i; |
265 |
|
|
266 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
284 |
static int cmd_set_idle_max(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_set_idle_max(hypervisor_conn_t *conn,int argc,char *argv[]) |
285 |
{ |
{ |
286 |
vm_instance_t *vm; |
vm_instance_t *vm; |
287 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
288 |
|
|
289 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
290 |
return(-1); |
return(-1); |
304 |
int argc,char *argv[]) |
int argc,char *argv[]) |
305 |
{ |
{ |
306 |
vm_instance_t *vm; |
vm_instance_t *vm; |
307 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
308 |
|
|
309 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
310 |
return(-1); |
return(-1); |
324 |
int argc,char *argv[]) |
int argc,char *argv[]) |
325 |
{ |
{ |
326 |
vm_instance_t *vm; |
vm_instance_t *vm; |
327 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
328 |
|
|
329 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
330 |
return(-1); |
return(-1); |
332 |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
333 |
return(-1); |
return(-1); |
334 |
|
|
335 |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Timer Drift: %u", |
if (cpu->type == CPU_TYPE_MIPS64) { |
336 |
cpu->timer_drift); |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Timer Drift: %u", |
337 |
|
CPU_MIPS64(cpu)->timer_drift); |
338 |
|
|
339 |
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Pending Timer IRQ: %u", |
340 |
|
CPU_MIPS64(cpu)->timer_irq_pending); |
341 |
|
} |
342 |
|
|
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Pending Timer IRQ: %u", |
|
|
cpu->timer_irq_pending); |
|
|
|
|
343 |
vm_release(vm); |
vm_release(vm); |
344 |
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
345 |
return(0); |
return(0); |
556 |
static int cmd_show_cpu_info(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_show_cpu_info(hypervisor_conn_t *conn,int argc,char *argv[]) |
557 |
{ |
{ |
558 |
vm_instance_t *vm; |
vm_instance_t *vm; |
559 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
560 |
|
|
561 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
562 |
return(-1); |
return(-1); |
564 |
cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1])); |
cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1])); |
565 |
|
|
566 |
if (cpu) { |
if (cpu) { |
567 |
mips64_dump_regs(cpu); |
cpu->reg_dump(cpu); |
568 |
tlb_dump(cpu); |
cpu->mmu_dump(cpu); |
569 |
} |
} |
570 |
|
|
571 |
vm_release(vm); |
vm_release(vm); |
681 |
{ "set_ram", 2, 2, cmd_set_ram, NULL }, |
{ "set_ram", 2, 2, cmd_set_ram, NULL }, |
682 |
{ "set_nvram", 2, 2, cmd_set_nvram, NULL }, |
{ "set_nvram", 2, 2, cmd_set_nvram, NULL }, |
683 |
{ "set_ram_mmap", 2, 2, cmd_set_ram_mmap, NULL }, |
{ "set_ram_mmap", 2, 2, cmd_set_ram_mmap, NULL }, |
684 |
|
{ "set_sparse_mem", 2, 2, cmd_set_sparse_mem, NULL }, |
685 |
{ "set_clock_divisor", 2, 2, cmd_set_clock_divisor, NULL }, |
{ "set_clock_divisor", 2, 2, cmd_set_clock_divisor, NULL }, |
686 |
{ "set_exec_area", 2, 2, cmd_set_exec_area, NULL }, |
{ "set_exec_area", 2, 2, cmd_set_exec_area, NULL }, |
687 |
{ "set_disk0", 2, 2, cmd_set_disk0, NULL }, |
{ "set_disk0", 2, 2, cmd_set_disk0, NULL }, |