/[dynamips]/trunk/dev_nvram.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/dev_nvram.c

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

upstream/dynamips-0.2.5/dev_nvram.c revision 1 by dpavlin, Sat Oct 6 16:01:44 2007 UTC upstream/dynamips-0.2.7/dev_nvram.c revision 10 by dpavlin, Sat Oct 6 16:29:14 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   * Cisco C7200 (Predator) NVRAM with Calendar Module.   * Cisco router simulation platform.
3   * Copyright (c) 2005,2006 Christophe Fillot.  All rights reserved.   * Copyright (c) 2005,2006 Christophe Fillot.  All rights reserved.
4   *   *
5   * Dallas DS1216 chip emulation:   * Dallas DS1216 chip emulation:
# Line 18  Line 18 
18  #include <time.h>  #include <time.h>
19  #include <errno.h>  #include <errno.h>
20    
21  #include "mips64.h"  #include "cpu.h"
22    #include "vm.h"
23  #include "dynamips.h"  #include "dynamips.h"
24  #include "memory.h"  #include "memory.h"
25  #include "device.h"  #include "device.h"
# Line 44  static m_uint8_t u8_to_bcd(m_uint8_t val Line 45  static m_uint8_t u8_to_bcd(m_uint8_t val
45  }  }
46    
47  /* Get the current time (p.8) */  /* Get the current time (p.8) */
48  static m_uint64_t get_current_time(cpu_mips_t *cpu)  static m_uint64_t get_current_time(cpu_gen_t *cpu)
49  {  {
50     m_uint64_t res;     m_uint64_t res;
51     struct tm *tmx;     struct tm *tmx;
# Line 67  static m_uint64_t get_current_time(cpu_m Line 68  static m_uint64_t get_current_time(cpu_m
68  /*  /*
69   * dev_nvram_access()   * dev_nvram_access()
70   */   */
71  void *dev_nvram_access(cpu_mips_t *cpu,struct vdevice *dev,  void *dev_nvram_access(cpu_gen_t *cpu,struct vdevice *dev,
72                         m_uint32_t offset,u_int op_size,u_int op_type,                         m_uint32_t offset,u_int op_size,u_int op_type,
73                         m_uint64_t *data)                         m_uint64_t *data)
74  {  {
# Line 75  void *dev_nvram_access(cpu_mips_t *cpu,s Line 76  void *dev_nvram_access(cpu_mips_t *cpu,s
76    
77  #if DEBUG_ACCESS  #if DEBUG_ACCESS
78     if (op_type == MTS_READ)     if (op_type == MTS_READ)
79        cpu_log(cpu,dev->name,"read  access to offset = 0x%x, pc = 0x%llx\n",        cpu_log(cpu,dev->name,"read  access to offset=0x%x, pc=0x%llx\n",
80                offset,cpu->pc);                offset,cpu_get_pc(cpu));
81     else     else
82        cpu_log(cpu,dev->name,"write access to vaddr = 0x%x, pc = 0x%llx, "        cpu_log(cpu,dev->name,
83                "val = 0x%llx\n",offset,cpu->pc,*data);                "write access to vaddr=0x%x, pc=0x%llx, val=0x%llx\n",
84                  offset,cpu_get_pc(cpu),*data);
85  #endif  #endif
86    
87     switch(offset) {     switch(offset) {
# Line 190  int dev_nvram_init(vm_instance_t *vm,cha Line 192  int dev_nvram_init(vm_instance_t *vm,cha
192     vm_object_add(vm,&d->vm_obj);     vm_object_add(vm,&d->vm_obj);
193     return(0);     return(0);
194  }  }
195    
196    /* Compute NVRAM checksum */
197    m_uint16_t nvram_cksum_old(vm_instance_t *vm,m_uint64_t addr,size_t count)
198    {
199       m_uint32_t sum = 0;
200    
201       while(count > 1) {
202          sum = sum + physmem_copy_u16_from_vm(vm,addr);
203          addr += sizeof(m_uint16_t);
204          count -= sizeof(m_uint16_t);
205       }
206    
207       if (count > 0)
208          sum = sum + ((physmem_copy_u16_from_vm(vm,addr) & 0xFF) << 8);
209    
210       while(sum>>16)
211          sum = (sum & 0xffff) + (sum >> 16);
212    
213       return(~sum);
214    }

Legend:
Removed from v.1  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26