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 |
{ |
{ |
195 |
return(0); |
return(0); |
196 |
} |
} |
197 |
|
|
198 |
|
/* Enable/disable use of block direct jump (compatibility option) */ |
199 |
|
static int cmd_set_blk_direct_jump(hypervisor_conn_t *conn, |
200 |
|
int argc,char *argv[]) |
201 |
|
{ |
202 |
|
vm_instance_t *vm; |
203 |
|
|
204 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
205 |
|
return(-1); |
206 |
|
|
207 |
|
vm->exec_blk_direct_jump = atoi(argv[1]); |
208 |
|
|
209 |
|
vm_release(vm); |
210 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
211 |
|
return(0); |
212 |
|
} |
213 |
|
|
214 |
/* Set the idle PC */ |
/* Set the idle PC */ |
215 |
static int cmd_set_idle_pc(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_set_idle_pc(hypervisor_conn_t *conn,int argc,char *argv[]) |
216 |
{ |
{ |
231 |
int argc,char *argv[]) |
int argc,char *argv[]) |
232 |
{ |
{ |
233 |
vm_instance_t *vm; |
vm_instance_t *vm; |
234 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
235 |
|
|
236 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
237 |
return(-1); |
return(-1); |
239 |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
240 |
return(-1); |
return(-1); |
241 |
|
|
242 |
cpu->idle_pc = strtoull(argv[2],NULL,0); |
cpu->set_idle_pc(cpu,strtoull(argv[2],NULL,0)); |
243 |
|
|
244 |
vm_release(vm); |
vm_release(vm); |
245 |
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
250 |
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[]) |
251 |
{ |
{ |
252 |
vm_instance_t *vm; |
vm_instance_t *vm; |
253 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
254 |
int i; |
int i; |
255 |
|
|
256 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
259 |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
260 |
return(-1); |
return(-1); |
261 |
|
|
262 |
mips64_get_idling_pc(cpu); |
cpu->get_idling_pc(cpu); |
263 |
|
|
264 |
for(i=0;i<cpu->idle_pc_prop_count;i++) { |
for(i=0;i<cpu->idle_pc_prop_count;i++) { |
265 |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"0x%llx [%d]", |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"0x%llx [%d]", |
276 |
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[]) |
277 |
{ |
{ |
278 |
vm_instance_t *vm; |
vm_instance_t *vm; |
279 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
280 |
int i; |
int i; |
281 |
|
|
282 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
300 |
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[]) |
301 |
{ |
{ |
302 |
vm_instance_t *vm; |
vm_instance_t *vm; |
303 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
304 |
|
|
305 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
306 |
return(-1); |
return(-1); |
320 |
int argc,char *argv[]) |
int argc,char *argv[]) |
321 |
{ |
{ |
322 |
vm_instance_t *vm; |
vm_instance_t *vm; |
323 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
324 |
|
|
325 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
326 |
return(-1); |
return(-1); |
340 |
int argc,char *argv[]) |
int argc,char *argv[]) |
341 |
{ |
{ |
342 |
vm_instance_t *vm; |
vm_instance_t *vm; |
343 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
344 |
|
|
345 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
346 |
return(-1); |
return(-1); |
348 |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
349 |
return(-1); |
return(-1); |
350 |
|
|
351 |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Timer Drift: %u", |
if (cpu->type == CPU_TYPE_MIPS64) { |
352 |
cpu->timer_drift); |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Timer Drift: %u", |
353 |
|
CPU_MIPS64(cpu)->timer_drift); |
354 |
|
|
355 |
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Pending Timer IRQ: %u", |
356 |
|
CPU_MIPS64(cpu)->timer_irq_pending); |
357 |
|
} |
358 |
|
|
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Pending Timer IRQ: %u", |
|
|
cpu->timer_irq_pending); |
|
|
|
|
359 |
vm_release(vm); |
vm_release(vm); |
360 |
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
361 |
return(0); |
return(0); |
572 |
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[]) |
573 |
{ |
{ |
574 |
vm_instance_t *vm; |
vm_instance_t *vm; |
575 |
cpu_mips_t *cpu; |
cpu_gen_t *cpu; |
576 |
|
|
577 |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
578 |
return(-1); |
return(-1); |
580 |
cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1])); |
cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1])); |
581 |
|
|
582 |
if (cpu) { |
if (cpu) { |
583 |
mips64_dump_regs(cpu); |
cpu->reg_dump(cpu); |
584 |
tlb_dump(cpu); |
cpu->mmu_dump(cpu); |
585 |
} |
} |
586 |
|
|
587 |
vm_release(vm); |
vm_release(vm); |
697 |
{ "set_ram", 2, 2, cmd_set_ram, NULL }, |
{ "set_ram", 2, 2, cmd_set_ram, NULL }, |
698 |
{ "set_nvram", 2, 2, cmd_set_nvram, NULL }, |
{ "set_nvram", 2, 2, cmd_set_nvram, NULL }, |
699 |
{ "set_ram_mmap", 2, 2, cmd_set_ram_mmap, NULL }, |
{ "set_ram_mmap", 2, 2, cmd_set_ram_mmap, NULL }, |
700 |
|
{ "set_sparse_mem", 2, 2, cmd_set_sparse_mem, NULL }, |
701 |
{ "set_clock_divisor", 2, 2, cmd_set_clock_divisor, NULL }, |
{ "set_clock_divisor", 2, 2, cmd_set_clock_divisor, NULL }, |
702 |
|
{ "set_blk_direct_jump", 2, 2, cmd_set_blk_direct_jump, NULL }, |
703 |
{ "set_exec_area", 2, 2, cmd_set_exec_area, NULL }, |
{ "set_exec_area", 2, 2, cmd_set_exec_area, NULL }, |
704 |
{ "set_disk0", 2, 2, cmd_set_disk0, NULL }, |
{ "set_disk0", 2, 2, cmd_set_disk0, NULL }, |
705 |
{ "set_disk1", 2, 2, cmd_set_disk1, NULL }, |
{ "set_disk1", 2, 2, cmd_set_disk1, NULL }, |