/[dynamips]/trunk/hv_vm.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/hv_vm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.6-RC3/hv_vm.c revision 4 by dpavlin, Sat Oct 6 16:06:49 2007 UTC upstream/dynamips-0.2.7-RC3/hv_vm.c revision 9 by dpavlin, Sat Oct 6 16:26:06 2007 UTC
# Line 1  Line 1 
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.
# Line 23  Line 23 
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"
# Line 44  Line 44 
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    
# Line 163  static int cmd_set_ram_mmap(hypervisor_c Line 163  static int cmd_set_ram_mmap(hypervisor_c
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  {  {
# Line 180  static int cmd_set_clock_divisor(hypervi Line 195  static int cmd_set_clock_divisor(hypervi
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  {  {
# Line 200  static int cmd_set_idle_pc_online(hyperv Line 231  static int cmd_set_idle_pc_online(hyperv
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);
# Line 208  static int cmd_set_idle_pc_online(hyperv Line 239  static int cmd_set_idle_pc_online(hyperv
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");
# Line 219  static int cmd_set_idle_pc_online(hyperv Line 250  static int cmd_set_idle_pc_online(hyperv
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)))
# Line 228  static int cmd_get_idle_pc_prop(hypervis Line 259  static int cmd_get_idle_pc_prop(hypervis
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]",
# Line 245  static int cmd_get_idle_pc_prop(hypervis Line 276  static int cmd_get_idle_pc_prop(hypervis
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)))
# Line 269  static int cmd_show_idle_pc_prop(hypervi Line 300  static int cmd_show_idle_pc_prop(hypervi
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);
# Line 289  static int cmd_set_idle_sleep_time(hyper Line 320  static int cmd_set_idle_sleep_time(hyper
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);
# Line 309  static int cmd_show_timer_drift(hypervis Line 340  static int cmd_show_timer_drift(hypervis
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);
# Line 317  static int cmd_show_timer_drift(hypervis Line 348  static int cmd_show_timer_drift(hypervis
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);
# Line 539  static int cmd_push_config(hypervisor_co Line 572  static int cmd_push_config(hypervisor_co
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);
# Line 547  static int cmd_show_cpu_info(hypervisor_ Line 580  static int cmd_show_cpu_info(hypervisor_
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);
# Line 635  static int cmd_vm_list(hypervisor_conn_t Line 668  static int cmd_vm_list(hypervisor_conn_t
668     return(0);     return(0);
669  }  }
670    
671    /* Show console TCP port info about VM object */
672    static void cmd_show_vm_list_con_ports(registry_entry_t *entry,void *opt,
673                                           int *err)
674    {
675       hypervisor_conn_t *conn = opt;
676       vm_instance_t *vm = entry->data;
677    
678       if (vm->vtty_con_type == VTTY_TYPE_TCP)
679          hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%s (%d)",
680                                vm->name,vm->vtty_con_tcp_port);
681    }
682    
683    /* VM console TCP port list */
684    static int cmd_vm_list_con_ports(hypervisor_conn_t *conn,int argc,char *argv[])
685    {
686       int err = 0;
687       registry_foreach_type(OBJ_TYPE_VM,cmd_show_vm_list_con_ports,conn,&err);
688       hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
689       return(0);
690    }
691    
692  /* VM commands */  /* VM commands */
693  static hypervisor_cmd_t vm_cmd_array[] = {  static hypervisor_cmd_t vm_cmd_array[] = {
694     { "set_debug_level", 2, 2, cmd_set_debug_level, NULL },     { "set_debug_level", 2, 2, cmd_set_debug_level, NULL },
# Line 643  static hypervisor_cmd_t vm_cmd_array[] = Line 697  static hypervisor_cmd_t vm_cmd_array[] =
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 },
# Line 655  static hypervisor_cmd_t vm_cmd_array[] = Line 711  static hypervisor_cmd_t vm_cmd_array[] =
711     { "set_idle_max", 3, 3, cmd_set_idle_max, NULL },     { "set_idle_max", 3, 3, cmd_set_idle_max, NULL },
712     { "set_idle_sleep_time", 3, 3, cmd_set_idle_sleep_time, NULL },     { "set_idle_sleep_time", 3, 3, cmd_set_idle_sleep_time, NULL },
713     { "show_timer_drift", 2, 2, cmd_show_timer_drift, NULL },     { "show_timer_drift", 2, 2, cmd_show_timer_drift, NULL },
714     { "set_ghost_file", 3, 3, cmd_set_ghost_file, NULL },     { "set_ghost_file", 2, 2, cmd_set_ghost_file, NULL },
715     { "set_ghost_status", 3, 3, cmd_set_ghost_status, NULL },     { "set_ghost_status", 2, 2, cmd_set_ghost_status, NULL },
716     { "set_con_tcp_port", 2, 2, cmd_set_con_tcp_port, NULL },     { "set_con_tcp_port", 2, 2, cmd_set_con_tcp_port, NULL },
717     { "set_aux_tcp_port", 2, 2, cmd_set_aux_tcp_port, NULL },     { "set_aux_tcp_port", 2, 2, cmd_set_aux_tcp_port, NULL },
718     { "extract_config", 1, 1, cmd_extract_config, NULL },     { "extract_config", 1, 1, cmd_extract_config, NULL },
# Line 667  static hypervisor_cmd_t vm_cmd_array[] = Line 723  static hypervisor_cmd_t vm_cmd_array[] =
723     { "send_con_msg", 2, 2, cmd_send_con_msg, NULL },     { "send_con_msg", 2, 2, cmd_send_con_msg, NULL },
724     { "send_aux_msg", 2, 2, cmd_send_aux_msg, NULL },     { "send_aux_msg", 2, 2, cmd_send_aux_msg, NULL },
725     { "list", 0, 0, cmd_vm_list, NULL },     { "list", 0, 0, cmd_vm_list, NULL },
726       { "list_con_ports", 0, 0, cmd_vm_list_con_ports, NULL },
727     { NULL, -1, -1, NULL, NULL },     { NULL, -1, -1, NULL, NULL },
728  };  };
729    

Legend:
Removed from v.4  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26