--- upstream/dynamips-0.2.6-RC5/dev_vtty.c 2007/10/06 16:09:07 6 +++ upstream/dynamips-0.2.7-RC1/dev_vtty.c 2007/10/06 16:23:47 7 @@ -1,5 +1,5 @@ /* - * Cisco 7200 (Predator) simulation platform. + * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * * Virtual console TTY. @@ -27,18 +27,21 @@ #include -#include "mips64.h" -#include "cp0.h" +#include "utils.h" #include "cpu.h" +#include "vm.h" #include "dynamips.h" #include "mips64_exec.h" +#include "ppc32_exec.h" #include "device.h" #include "memory.h" #include "dev_c7200.h" #include "dev_c3600.h" +#include "dev_c2691.h" +#include "dev_c3725.h" +#include "dev_c3745.h" +#include "dev_c2600.h" #include "dev_vtty.h" -#include "vm.h" -#include "utils.h" /* VTTY list */ static pthread_mutex_t vtty_list_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -589,12 +592,76 @@ return(-1); } +/* Remote control for MIPS64 processors */ +static int remote_control_mips64(vtty_t *vtty,char c,cpu_mips_t *cpu) +{ + switch(c) { + /* Show information about JIT compiled pages */ + case 'b': + printf("\nCPU0: %u JIT compiled pages [Exec Area Pages: %lu/%lu]\n", + cpu->compiled_pages, + (u_long)cpu->exec_page_alloc, + (u_long)cpu->exec_page_count); + break; + + /* Non-JIT mode statistics */ + case 'j': + mips64_dump_stats(cpu); + break; + + default: + return(FALSE); + } + + return(TRUE); +} + +/* Remote control for PPC32 processors */ +static int remote_control_ppc32(vtty_t *vtty,char c,cpu_ppc_t *cpu) +{ + switch(c) { + /* Show information about JIT compiled pages */ + case 'b': + printf("\nCPU0: %u JIT compiled pages [Exec Area Pages: %lu/%lu]\n", + cpu->compiled_pages, + (u_long)cpu->exec_page_alloc, + (u_long)cpu->exec_page_count); + break; + + /* Non-JIT mode statistics */ + case 'j': + ppc32_dump_stats(cpu); + break; + + default: + return(FALSE); + } + + return(TRUE); +} + /* Process remote control char */ static void remote_control(vtty_t *vtty,u_char c) { vm_instance_t *vm = vtty->vm; - cpu_mips_t *cpu0 = cpu_group_find_id(vm->cpu_group,0); + cpu_gen_t *cpu0; + cpu0 = vm->boot_cpu; + + /* Specific commands for the different CPU models */ + if (cpu0) { + switch(cpu0->type) { + case CPU_TYPE_MIPS64: + if (remote_control_mips64(vtty,c,CPU_MIPS64(cpu0))) + return; + break; + case CPU_TYPE_PPC32: + if (remote_control_ppc32(vtty,c,CPU_PPC32(cpu0))) + return; + break; + } + } + switch(c) { /* Show the object list */ case 'o': @@ -608,8 +675,10 @@ /* Reboot the C7200 */ case 'k': +#if 0 if (vm->type == VM_TYPE_C7200) c7200_boot_ios(VM_C7200(vm)); +#endif break; /* Show the device list */ @@ -628,19 +697,31 @@ case VM_TYPE_C7200: c7200_pa_show_all_info(VM_C7200(vm)); break; + case VM_TYPE_C2691: + c2691_nm_show_all_info(VM_C2691(vm)); + break; + case VM_TYPE_C3725: + c3725_nm_show_all_info(VM_C3725(vm)); + break; + case VM_TYPE_C3745: + c3745_nm_show_all_info(VM_C3745(vm)); + break; + case VM_TYPE_C2600: + c2600_nm_show_all_info(VM_C2600(vm)); + break; } break; /* Dump the MIPS registers */ case 'r': - if (cpu0) mips64_dump_regs(cpu0); + if (cpu0) cpu0->reg_dump(cpu0); break; - + /* Dump the latest memory accesses */ case 'm': if (cpu0) memlog_dump(cpu0); - break; - + break; + /* Suspend CPU emulation */ case 's': vm_suspend(vm); @@ -651,58 +732,44 @@ vm_resume(vm); break; - /* Dump the MIPS TLB */ + /* Dump the MMU information */ case 't': - if (cpu0) tlb_dump(cpu0); + if (cpu0) cpu0->mmu_dump(cpu0); break; - /* Dump the MIPS TLB (raw mode) */ + /* Dump the MMU information (raw mode) */ case 'z': - if (cpu0) tlb_raw_dump(cpu0); + if (cpu0) cpu0->mmu_raw_dump(cpu0); break; - - /* Show information about JIT compiled pages */ - case 'b': - if (cpu0) { - printf("\nCPU0: %u JIT compiled pages " - "[Exec Area Pages: %lu/%lu]\n", - cpu0->compiled_pages, - (u_long)cpu0->exec_page_alloc, - (u_long)cpu0->exec_page_count); - } - break; - - /* MTS64 cache statistics */ + + /* Memory translation cache statistics */ case 'l': - if (cpu0) { - cpu0->mts_show_stats(cpu0); - } + if (cpu0) cpu0->mts_show_stats(cpu0); break; - + /* Extract the configuration from the NVRAM */ case 'c': vm_ios_save_config(vm); break; - /* Non-JIT mode statistics */ - case 'j': - if (cpu0) mips64_dump_stats(cpu0); - break; - /* Determine an idle pointer counter */ case 'i': - if (cpu0) { - mips64_get_idling_pc(cpu0); - } + if (cpu0) + cpu0->get_idling_pc(cpu0); break; /* Experimentations / Tests */ case 'x': if (cpu0) { /* IRQ triggering */ - mips64_set_irq(cpu0,2/*C7200_PA_MGMT_IRQ*/); - //mips64_set_irq(cpu0,3/*C7200_PA_MGMT_IRQ*/); - //mips64_set_irq(cpu0,C7200_PA_MGMT_IRQ); + vm_set_irq(vm,2); + } + break; + + case 'y': + if (cpu0) { + /* IRQ clearing */ + vm_clear_irq(vm,2); } break; @@ -717,16 +784,16 @@ printf("o - Show the VM object list\n" "d - Show the device list\n" - "r - Dump MIPS CPU registers\n" - "t - Dump MIPS TLB entries\n" - "z - Dump MIPS TLB entries (raw mode)\n" + "r - Dump CPU registers\n" + "t - Dump MMU information\n" + "z - Dump MMU information (raw mode)\n" "m - Dump the latest memory accesses\n" "s - Suspend CPU emulation\n" "u - Resume CPU emulation\n" "q - Quit the emulator\n" "k - Reboot the virtual machine\n" "b - Show info about JIT compiled pages\n" - "l - MTS64 cache statistics\n" + "l - MTS cache statistics\n" "c - Write IOS configuration to disk\n" "j - Non-JIT mode statistics\n" "i - Determine an idling pointer counter\n" @@ -919,7 +986,7 @@ return(res); } -/* put char to vtty */ +/* Put char to vtty */ void vtty_put_char(vtty_t *vtty, char ch) { switch(vtty->type) { @@ -952,6 +1019,15 @@ } } +/* Put a buffer to vtty */ +void vtty_put_buffer(vtty_t *vtty,char *buf,size_t len) +{ + size_t i; + + for(i=0;i