/[dynamips]/upstream/dynamips-0.2.7-RC1/dev_remote.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 /upstream/dynamips-0.2.7-RC1/dev_remote.c

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

upstream/dynamips-0.2.6-RC5/dev_remote.c revision 6 by dpavlin, Sat Oct 6 16:09:07 2007 UTC upstream/dynamips-0.2.7-RC1/dev_remote.c revision 7 by dpavlin, Sat Oct 6 16:23:47 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   * Cisco C7200 (Predator) Remote Control Module.   * Cisco router simulation platform.
3   * Copyright (C) 2006 Christophe Fillot.  All rights reserved.   * Copyright (C) 2006 Christophe Fillot.  All rights reserved.
4     *
5     * Remote control module.
6   */   */
7    
8  #include <stdio.h>  #include <stdio.h>
# Line 14  Line 16 
16  #include <assert.h>  #include <assert.h>
17    
18  #include "utils.h"  #include "utils.h"
19  #include "mips64.h"  #include "cpu.h"
20  #include "cp0.h"  #include "vm.h"
21  #include "dynamips.h"  #include "dynamips.h"
22  #include "memory.h"  #include "memory.h"
23  #include "device.h"  #include "device.h"
# Line 23  Line 25 
25  #include "net_io.h"  #include "net_io.h"
26  #include "registry.h"  #include "registry.h"
27  #include "ptask.h"  #include "ptask.h"
 #include "vm.h"  
28  #include "dev_c7200.h"  #include "dev_c7200.h"
29  #include "dev_c3600.h"  #include "dev_c3600.h"
30  #include "dev_c2691.h"  #include "dev_c2691.h"
31  #include "dev_c3725.h"  #include "dev_c3725.h"
32  #include "dev_c3745.h"  #include "dev_c3745.h"
33    #include "dev_c2600.h"
34    
35  #define DEBUG_ACCESS 0  #define DEBUG_ACCESS 0
36    
# Line 39  struct remote_data { Line 41  struct remote_data {
41    
42     char buffer[512];     char buffer[512];
43     u_int buf_pos;     u_int buf_pos;
44    
45       u_int cookie_pos;
46  };  };
47    
48  /*  /*
49   * dev_remote_control_access()   * dev_remote_control_access()
50   */   */
51  void *dev_remote_control_access(cpu_mips_t *cpu,struct vdevice *dev,  void *dev_remote_control_access(cpu_gen_t *cpu,struct vdevice *dev,
52                                  m_uint32_t offset,u_int op_size,u_int op_type,                                  m_uint32_t offset,u_int op_size,u_int op_type,
53                                  m_uint64_t *data)                                  m_uint64_t *data)
54  {  {
55       vm_instance_t *vm = cpu->vm;
56     struct remote_data *d = dev->priv_data;     struct remote_data *d = dev->priv_data;
57     struct vdevice *storage_dev;     struct vdevice *storage_dev;
58     size_t len;     size_t len;
# Line 57  void *dev_remote_control_access(cpu_mips Line 62  void *dev_remote_control_access(cpu_mips
62    
63  #if DEBUG_ACCESS  #if DEBUG_ACCESS
64     if (op_type == MTS_READ) {     if (op_type == MTS_READ) {
65        cpu_log(cpu,"REMOTE","reading reg 0x%x at pc=0x%llx\n",offset,cpu->pc);        cpu_log(cpu,"REMOTE","reading reg 0x%x at pc=0x%llx\n",
66                  offset,cpu_get_pc(cpu));
67     } else {     } else {
68        cpu_log(cpu,"REMOTE","writing reg 0x%x at pc=0x%llx, data=0x%llx\n",        cpu_log(cpu,"REMOTE","writing reg 0x%x at pc=0x%llx, data=0x%llx\n",
69                offset,cpu->pc,*data);                offset,cpu_get_pc(cpu),*data);
70     }     }
71  #endif  #endif
72    
# Line 80  void *dev_remote_control_access(cpu_mips Line 86  void *dev_remote_control_access(cpu_mips
86        /* Display CPU registers */        /* Display CPU registers */
87        case 0x008:        case 0x008:
88           if (op_type == MTS_WRITE)           if (op_type == MTS_WRITE)
89              mips64_dump_regs(cpu);              cpu->reg_dump(cpu);
90           break;           break;
91    
92        /* Display CPU TLB */        /* Display CPU memory info */
93        case 0x00c:        case 0x00c:
94           if (op_type == MTS_WRITE)           if (op_type == MTS_WRITE)
95              tlb_dump(cpu);              cpu->mmu_dump(cpu);
96           break;           break;
97    
98        /* Reserved/Unused */        /* Reserved/Unused */
# Line 96  void *dev_remote_control_access(cpu_mips Line 102  void *dev_remote_control_access(cpu_mips
102        /* RAM size */        /* RAM size */
103        case 0x014:        case 0x014:
104           if (op_type == MTS_READ)           if (op_type == MTS_READ)
105              *data = cpu->vm->ram_size;              *data = vm->ram_size;
106           break;           break;
107    
108        /* ROM size */        /* ROM size */
109        case 0x018:        case 0x018:
110           if (op_type == MTS_READ)           if (op_type == MTS_READ)
111              *data = cpu->vm->rom_size;              *data = vm->rom_size;
112           break;           break;
113    
114        /* NVRAM size */        /* NVRAM size */
115        case 0x01c:        case 0x01c:
116           if (op_type == MTS_READ)           if (op_type == MTS_READ)
117              *data = cpu->vm->nvram_size;              *data = vm->nvram_size;
118           break;                       break;            
119    
120        /* IOMEM size */        /* IOMEM size */
121        case 0x020:        case 0x020:
122          if (op_type == MTS_READ)          if (op_type == MTS_READ)
123              *data = cpu->vm->iomem_size;              *data = vm->iomem_size;
124           break;           break;
125    
126        /* Config Register */        /* Config Register */
127        case 0x024:        case 0x024:
128           if (op_type == MTS_READ)           if (op_type == MTS_READ)
129              *data = cpu->vm->conf_reg;              *data = vm->conf_reg;
130           break;           break;
131    
132        /* ELF entry point */        /* ELF entry point */
133        case 0x028:        case 0x028:
134           if (op_type == MTS_READ)           if (op_type == MTS_READ)
135              *data = cpu->vm->ios_entry_point;              *data = vm->ios_entry_point;
136           break;                 break;      
137    
138        /* ELF machine id */        /* ELF machine id */
139        case 0x02c:        case 0x02c:
140           if (op_type == MTS_READ)           if (op_type == MTS_READ)
141              *data = cpu->vm->elf_machine_id;              *data = vm->elf_machine_id;
142           break;           break;
143    
144        /* Restart IOS Image */        /* Restart IOS Image */
# Line 142  void *dev_remote_control_access(cpu_mips Line 148  void *dev_remote_control_access(cpu_mips
148    
149        /* Stop the virtual machine */        /* Stop the virtual machine */
150        case 0x034:        case 0x034:
151           cpu->vm->status = VM_STATUS_SHUTDOWN;           vm->status = VM_STATUS_SHUTDOWN;
152           break;           break;
153    
154        /* Debugging/Log message: /!\ physical address */        /* Debugging/Log message: /!\ physical address */
155        case 0x038:        case 0x038:
156           if (op_type == MTS_WRITE) {           if (op_type == MTS_WRITE) {
157              len = physmem_strlen(cpu->vm,*data);              len = physmem_strlen(vm,*data);
158              if (len < sizeof(d->buffer)) {              if (len < sizeof(d->buffer)) {
159                 physmem_copy_from_vm(cpu->vm,d->buffer,*data,len+1);                 physmem_copy_from_vm(vm,d->buffer,*data,len+1);
160                 vm_log(cpu->vm,"ROM",d->buffer);                 vm_log(vm,"ROM",d->buffer);
161              }              }
162           }           }
163           break;           break;
# Line 163  void *dev_remote_control_access(cpu_mips Line 169  void *dev_remote_control_access(cpu_mips
169              d->buffer[d->buf_pos] = 0;              d->buffer[d->buf_pos] = 0;
170    
171              if (d->buffer[d->buf_pos-1] == '\n') {              if (d->buffer[d->buf_pos-1] == '\n') {
172                 vm_log(cpu->vm,"ROM","%s",d->buffer);                 vm_log(vm,"ROM","%s",d->buffer);
173                 d->buf_pos = 0;                 d->buf_pos = 0;
174              }              }
175           } else           } else
# Line 173  void *dev_remote_control_access(cpu_mips Line 179  void *dev_remote_control_access(cpu_mips
179        /* Console output */        /* Console output */
180        case 0x040:        case 0x040:
181           if (op_type == MTS_WRITE)           if (op_type == MTS_WRITE)
182              vtty_put_char(cpu->vm->vtty_con,(char)*data);              vtty_put_char(vm->vtty_con,(char)*data);
183           break;           break;
184    
185        /* NVRAM address */        /* NVRAM address */
186        case 0x044:        case 0x044:
187           if (op_type == MTS_READ) {           if (op_type == MTS_READ) {
188              if ((storage_dev = dev_get_by_name(cpu->vm,"nvram")))              if ((storage_dev = dev_get_by_name(vm,"nvram")))
189                 *data = storage_dev->phys_addr;                 *data = storage_dev->phys_addr;
190    
191              if ((storage_dev = dev_get_by_name(cpu->vm,"ssa")))              if ((storage_dev = dev_get_by_name(vm,"ssa")))
192                 *data = storage_dev->phys_addr;                 *data = storage_dev->phys_addr;
193    
194                if (cpu->type == CPU_TYPE_MIPS64)
195                   *data += MIPS_KSEG1_BASE;
196           }           }
197           break;           break;
198    
199        /* IO memory size for Smart-Init (C3600, others ?) */        /* IO memory size for Smart-Init (C3600, others ?) */
200        case 0x048:        case 0x048:
201           if (op_type == MTS_READ) {           if (op_type == MTS_READ) {
202              switch(cpu->vm->type) {              switch(vm->type) {
203                 case VM_TYPE_C3600:                 case VM_TYPE_C3600:
204                    *data = VM_C3600(cpu->vm)->nm_iomem_size;                    *data = VM_C3600(vm)->nm_iomem_size;
205                    break;                    break;
206                 case VM_TYPE_C2691:                 case VM_TYPE_C2691:
207                    *data = VM_C2691(cpu->vm)->nm_iomem_size;                    *data = VM_C2691(vm)->nm_iomem_size;
208                    break;                    break;
209                 case VM_TYPE_C3725:                 case VM_TYPE_C3725:
210                    *data = VM_C3725(cpu->vm)->nm_iomem_size;                    *data = VM_C3725(vm)->nm_iomem_size;
211                    break;                    break;
212                 case VM_TYPE_C3745:                 case VM_TYPE_C3745:
213                    *data = VM_C3745(cpu->vm)->nm_iomem_size;                    *data = VM_C3745(vm)->nm_iomem_size;
214                      break;
215                   case VM_TYPE_C2600:
216                      *data = VM_C2600(vm)->nm_iomem_size;
217                    break;                    break;
218                 default:                 default:
219                    *data = 0;                    *data = 0;
220              }              }
221           }           }
222           break;           break;
223    
224          /* Cookie position selector */
225          case 0x04c:
226             if (op_type == MTS_READ)
227                *data = d->cookie_pos;
228             else
229                d->cookie_pos = *data;
230             break;
231                    
232          /* Cookie data */
233          case 0x050:
234             if ((op_type == MTS_READ) && (d->cookie_pos < 64))
235                *data = vm->chassis_cookie[d->cookie_pos];
236             break;
237     }     }
238    
239     return NULL;     return NULL;

Legend:
Removed from v.6  
changed lines
  Added in v.7

  ViewVC Help
Powered by ViewVC 1.1.26