/[dynamips]/upstream/dynamips-0.2.6-RC3/dev_c3600.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.6-RC3/dev_c3600.c

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

upstream/dynamips-0.2.5/dev_c3600.c revision 1 by dpavlin, Sat Oct 6 16:01:44 2007 UTC upstream/dynamips-0.2.6-RC3/dev_c3600.c revision 4 by dpavlin, Sat Oct 6 16:06:49 2007 UTC
# Line 17  Line 17 
17  #include "memory.h"  #include "memory.h"
18  #include "device.h"  #include "device.h"
19  #include "pci_io.h"  #include "pci_io.h"
20    #include "dev_gt.h"
21  #include "cisco_eeprom.h"  #include "cisco_eeprom.h"
22  #include "dev_c3600.h"  #include "dev_c3600.h"
23  #include "dev_c3600_bay.h"  #include "dev_c3600_bay.h"
# Line 28  Line 29 
29  /* ======================================================================== */  /* ======================================================================== */
30    
31  /* Cisco 3620 mainboard EEPROM */  /* Cisco 3620 mainboard EEPROM */
32  static m_uint16_t eeprom_c3620_mainboard[64] = {  static m_uint16_t eeprom_c3620_mainboard_data[64] = {
33     0x0001, 0x0000, 0x0000, 0x0000, 0x0AFF, 0x7318, 0x5011, 0x0020,     0x0001, 0x0000, 0x0000, 0x0000, 0x0AFF, 0x7318, 0x5011, 0x0020,
34     0x0000, 0x0000, 0xA0FF, 0x9904, 0x19FF, 0xFFFF, 0xFFFF, 0x0002,     0x0000, 0x0000, 0xA0FF, 0x9904, 0x19FF, 0xFFFF, 0xFFFF, 0x0002,
35     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
# Line 39  static m_uint16_t eeprom_c3620_mainboard Line 40  static m_uint16_t eeprom_c3620_mainboard
40     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
41  };  };
42    
43    struct cisco_eeprom eeprom_c3620_mainboard = {
44       "C3620 Mainboard",
45       eeprom_c3620_mainboard_data,
46       sizeof(eeprom_c3620_mainboard_data)/2,
47    };
48    
49  /* Cisco 3640 mainboard EEPROM */  /* Cisco 3640 mainboard EEPROM */
50  static m_uint16_t eeprom_c3640_mainboard[64] = {  static m_uint16_t eeprom_c3640_mainboard_data[64] = {
51     0x0001, 0x0000, 0x0000, 0x0000, 0x0AFF, 0x7316, 0x8514, 0x0040,     0x0001, 0x0000, 0x0000, 0x0000, 0x0AFF, 0x7316, 0x8514, 0x0040,
52     0x0000, 0x0000, 0xA1FF, 0x0102, 0x22FF, 0xFFFF, 0xFFFF, 0x0002,     0x0000, 0x0000, 0xA1FF, 0x0102, 0x22FF, 0xFFFF, 0xFFFF, 0x0002,
53     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
# Line 51  static m_uint16_t eeprom_c3640_mainboard Line 58  static m_uint16_t eeprom_c3640_mainboard
58     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
59  };  };
60    
61    struct cisco_eeprom eeprom_c3640_mainboard = {
62       "C3640 Mainboard",
63       eeprom_c3640_mainboard_data,
64       sizeof(eeprom_c3640_mainboard_data)/2,
65    };
66    
67  /* Cisco 3660 backplane EEPROM */  /* Cisco 3660 backplane EEPROM */
68  static m_uint16_t eeprom_c3660_backplane[64] = {  static m_uint16_t eeprom_c3660_backplane_data[64] = {
69     0x04FF, 0x4000, 0xC841, 0x0100, 0xC046, 0x0320, 0x0012, 0x8402,     0x04FF, 0x4000, 0xC841, 0x0100, 0xC046, 0x0320, 0x0012, 0x8402,
70     0x4243, 0x3080, 0x0000, 0x0000, 0x0202, 0xC18B, 0x4841, 0x4430,     0x4243, 0x3080, 0x0000, 0x0000, 0x0202, 0xC18B, 0x4841, 0x4430,
71     0x3434, 0x3431, 0x3135, 0x4A03, 0x0081, 0x0000, 0x0000, 0x0400,     0x3434, 0x3431, 0x3135, 0x4A03, 0x0081, 0x0000, 0x0000, 0x0400,
# Line 63  static m_uint16_t eeprom_c3660_backplane Line 76  static m_uint16_t eeprom_c3660_backplane
76     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,     0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
77  };  };
78    
79    struct cisco_eeprom eeprom_c3660_backplane = {
80       "C3660 Backplane",
81       eeprom_c3660_backplane_data,
82       sizeof(eeprom_c3660_backplane_data)/2,
83    };
84    
85  /* ======================================================================== */  /* ======================================================================== */
86  /* Chassis Drivers                                                          */  /* Chassis Drivers                                                          */
87  /* ======================================================================== */  /* ======================================================================== */
# Line 71  static int c3640_init(c3600_t *router); Line 90  static int c3640_init(c3600_t *router);
90  static int c3660_init(c3600_t *router);  static int c3660_init(c3600_t *router);
91    
92  static struct c3600_chassis_driver chassis_drivers[] = {  static struct c3600_chassis_driver chassis_drivers[] = {
93     { "3620"  , 3620, 1, c3620_init,     { "3620"  , 3620, 1, c3620_init, &eeprom_c3620_mainboard },
94       eeprom_c3620_mainboard, sizeof(eeprom_c3620_mainboard)/2 },     { "3640"  , 3640, 1, c3640_init, &eeprom_c3640_mainboard },
95     { "3640"  , 3640, 1, c3640_init,     { "3660"  , 3660, 1, c3660_init, &eeprom_c3660_backplane },
96       eeprom_c3640_mainboard, sizeof(eeprom_c3640_mainboard)/2 },     { NULL    , -1,   0, NULL,       NULL },
    { "3660"  , 3660, 1, c3660_init,  
      eeprom_c3660_backplane, sizeof(eeprom_c3660_backplane)/2 },  
   
    { NULL    , -1, 0, NULL },  
97  };  };
98    
99  /* ======================================================================== */  /* ======================================================================== */
# Line 90  static struct c3600_nm_driver *nm_driver Line 105  static struct c3600_nm_driver *nm_driver
105     &dev_c3600_nm_1fe_tx_driver,     &dev_c3600_nm_1fe_tx_driver,
106     &dev_c3600_nm_4t_driver,     &dev_c3600_nm_4t_driver,
107     &dev_c3600_leopard_2fe_driver,     &dev_c3600_leopard_2fe_driver,
108       &dev_c3600_nm_16esw_driver,
109     NULL,     NULL,
110  };  };
111    
# Line 99  static struct c3600_nm_driver *nm_driver Line 115  static struct c3600_nm_driver *nm_driver
115    
116  /* Directly extract the configuration from the NVRAM device */  /* Directly extract the configuration from the NVRAM device */
117  ssize_t c3600_nvram_extract_config(vm_instance_t *vm,char **buffer)  ssize_t c3600_nvram_extract_config(vm_instance_t *vm,char **buffer)
118  {    {
119       u_char *base_ptr,*ios_ptr,*cfg_ptr,*end_ptr;
120       m_uint32_t start,nvlen;
121       m_uint16_t magic1,magic2;
122     struct vdevice *nvram_dev;     struct vdevice *nvram_dev;
123     m_uint32_t start,end,clen,nvlen;     off_t nvram_size;
124     m_uint16_t magic1,magic2;     int fd;
    m_uint64_t addr;  
125    
126     if (!(nvram_dev = dev_get_by_name(vm,"nvram")))     if ((nvram_dev = dev_get_by_name(vm,"nvram")))
127        return(-1);        dev_sync(nvram_dev);
128    
129     addr = nvram_dev->phys_addr + vm->nvram_rom_space;     fd = vm_mmap_open_file(vm,"nvram",&base_ptr,&nvram_size);
    magic1 = physmem_copy_u16_from_vm(vm,addr+0x06);  
    magic2 = physmem_copy_u16_from_vm(vm,addr+0x08);  
130    
131     if ((magic1 != 0xF0A5) || (magic2 != 0xABCD)) {     if (fd == -1)
       vm_error(vm,"unable to find IOS magic numbers (0x%x,0x%x)!\n",  
                magic1,magic2);  
132        return(-1);        return(-1);
    }  
133    
134     start = physmem_copy_u32_from_vm(vm,addr+0x10) + 1;     ios_ptr = base_ptr + vm->nvram_rom_space;
135     end   = physmem_copy_u32_from_vm(vm,addr+0x14);     end_ptr = base_ptr + nvram_size;
    nvlen = physmem_copy_u32_from_vm(vm,addr+0x18);  
    clen  = end - start;  
136    
137     if ((clen + 1) != nvlen) {     if ((ios_ptr + 0x30) >= end_ptr) {
138        vm_error(vm,"invalid configuration size (0x%x)\n",nvlen);        vm_error(vm,"NVRAM file too small\n");
139        return(-1);        return(-1);
140     }     }
141    
142     if (!(*buffer = malloc(clen+1))) {     magic1  = ntohs(*PTR_ADJUST(m_uint16_t *,ios_ptr,0x06));
143        vm_error(vm,"unable to allocate config buffer (%u bytes)\n",clen);     magic2  = ntohs(*PTR_ADJUST(m_uint16_t *,ios_ptr,0x08));
144    
145       if ((magic1 != 0xF0A5) || (magic2 != 0xABCD)) {
146          vm_error(vm,"unable to find IOS magic numbers (0x%x,0x%x)!\n",
147                   magic1,magic2);
148        return(-1);        return(-1);
149     }     }
150    
151     physmem_copy_from_vm(vm,*buffer,addr+start+0x08,clen);     start = ntohl(*PTR_ADJUST(m_uint32_t *,ios_ptr,0x10)) + 1;
152     (*buffer)[clen] = 0;     nvlen = ntohl(*PTR_ADJUST(m_uint32_t *,ios_ptr,0x18));
    return(clen);  
 }  
   
 /* Compute NVRAM checksum */  
 static u_int16_t nvram_cksum(vm_instance_t *vm,m_uint64_t addr,size_t count)  
 {  
    m_uint32_t sum = 0;  
153    
154     while(count > 1) {     if (!(*buffer = malloc(nvlen+1))) {
155        sum = sum + physmem_copy_u16_from_vm(vm,addr);        vm_error(vm,"unable to allocate config buffer (%u bytes)\n",nvlen);
156        addr += sizeof(m_uint16_t);        return(-1);
       count -= sizeof(m_uint16_t);  
157     }     }
158    
159     if (count > 0)     cfg_ptr = ios_ptr + start + 0x08;
       sum = sum + ((physmem_copy_u16_from_vm(vm,addr) & 0xFF) << 8);  
160    
161     while(sum>>16)     if ((cfg_ptr + nvlen) > end_ptr) {
162        sum = (sum & 0xffff) + (sum >> 16);        vm_error(vm,"NVRAM file too small\n");
163          return(-1);
164       }
165    
166     return(~sum);     memcpy(*buffer,cfg_ptr,nvlen-1);
167       (*buffer)[nvlen-1] = 0;
168       return(nvlen-1);
169  }  }
170    
   
171  /* Directly push the IOS configuration to the NVRAM device */  /* Directly push the IOS configuration to the NVRAM device */
172  int c3600_nvram_push_config(vm_instance_t *vm,char *buffer,size_t len)  int c3600_nvram_push_config(vm_instance_t *vm,char *buffer,size_t len)
173  {  {
174     struct vdevice *nvram_dev;     u_char *base_ptr,*ios_ptr,*cfg_ptr;
175     m_uint64_t addr,cfg_addr;     m_uint32_t cfg_offset,cklen,tmp;
    m_uint32_t tmp,cfg_offset;  
    m_uint32_t cklen;  
176     m_uint16_t cksum;     m_uint16_t cksum;
177       int fd;
178    
179       fd = vm_mmap_create_file(vm,"nvram",vm->nvram_size*1024,&base_ptr);
180    
181     if (!(nvram_dev = dev_get_by_name(vm,"nvram")))     if (fd == -1)
182        return(-1);        return(-1);
183    
    addr = nvram_dev->phys_addr + vm->nvram_rom_space;  
184     cfg_offset = 0x2c;     cfg_offset = 0x2c;
185     cfg_addr   = addr + cfg_offset;;     ios_ptr = base_ptr + vm->nvram_rom_space;
186       cfg_ptr = ios_ptr  + cfg_offset;
187    
188     /* Write IOS tag, uncompressed config... */     /* Write IOS tag, uncompressed config... */
189     physmem_copy_u16_to_vm(vm,addr+0x06,0xF0A5);     *PTR_ADJUST(m_uint16_t *,ios_ptr,0x06) = htons(0xF0A5);
190     physmem_copy_u16_to_vm(vm,addr+0x08,0xABCD);      /* Magic number */     *PTR_ADJUST(m_uint16_t *,ios_ptr,0x08) = htons(0xABCD);
191     physmem_copy_u16_to_vm(vm,addr+0x0a,0x0001);      /* ??? */     *PTR_ADJUST(m_uint16_t *,ios_ptr,0x0a) = htons(0x0001);
192     physmem_copy_u16_to_vm(vm,addr+0x0c,0x0000);      /* Checksum */     *PTR_ADJUST(m_uint16_t *,ios_ptr,0x0c) = htons(0x0000);
193     physmem_copy_u16_to_vm(vm,addr+0x0e,0x0c04);      /* IOS version */     *PTR_ADJUST(m_uint16_t *,ios_ptr,0x0e) = htons(0x0c04);
194    
195     /* Store file contents to NVRAM */     /* Store file contents to NVRAM */
196     physmem_copy_to_vm(vm,buffer,cfg_addr,len);     memcpy(cfg_ptr,buffer,len);
197    
198     /* Write config addresses + size */     /* Write config addresses + size */
199     tmp = cfg_addr - addr - 0x08;     tmp = cfg_offset - 0x08;
200    
201     physmem_copy_u32_to_vm(vm,addr+0x10,tmp);     *PTR_ADJUST(m_uint32_t *,ios_ptr,0x10) = htonl(tmp);
202     physmem_copy_u32_to_vm(vm,addr+0x14,tmp + len);     *PTR_ADJUST(m_uint32_t *,ios_ptr,0x14) = htonl(tmp + len);
203     physmem_copy_u32_to_vm(vm,addr+0x18,len);     *PTR_ADJUST(m_uint32_t *,ios_ptr,0x18) = htonl(len);
204    
205     /* Compute the checksum */     /* Compute the checksum */
206     cklen = nvram_dev->phys_len - (vm->nvram_rom_space + 0x08);     cklen = (vm->nvram_size*1024) - (vm->nvram_rom_space + 0x08);
207     cksum = nvram_cksum(vm,addr+0x08,cklen);     cksum = nvram_cksum((m_uint16_t *)(ios_ptr+0x08),cklen);
208     physmem_copy_u16_to_vm(vm,addr+0x0c,cksum);     *PTR_ADJUST(m_uint16_t *,ios_ptr,0x0c) = htons(cksum);
209    
210       vm_mmap_close_file(fd,base_ptr,vm->nvram_size*1024);
211     return(0);     return(0);
212  }  }
213    
# Line 252  static int c3600_free_instance(void *dat Line 264  static int c3600_free_instance(void *dat
264        /* Shutdown all Network Modules */        /* Shutdown all Network Modules */
265        c3600_nm_shutdown_all(router);        c3600_nm_shutdown_all(router);
266    
267          /* Free mainboard EEPROM */
268          cisco_eeprom_free(&router->mb_eeprom);
269    
270        /* Free all resources used by VM */        /* Free all resources used by VM */
271        vm_free(vm);        vm_free(vm);
272    
# Line 329  void c3600_save_config_all(FILE *fd) Line 344  void c3600_save_config_all(FILE *fd)
344    
345  /* Set NM EEPROM definition */  /* Set NM EEPROM definition */
346  int c3600_nm_set_eeprom(c3600_t *router,u_int nm_bay,  int c3600_nm_set_eeprom(c3600_t *router,u_int nm_bay,
347                          const struct c3600_eeprom *eeprom)                          const struct cisco_eeprom *eeprom)
348  {  {
349     if (nm_bay >= C3600_MAX_NM_BAYS) {     if (nm_bay >= C3600_MAX_NM_BAYS) {
350        vm_error(router->vm,"c3600_nm_set_eeprom: invalid NM Bay %u.\n",nm_bay);        vm_error(router->vm,"c3600_nm_set_eeprom: invalid NM Bay %u.\n",nm_bay);
351        return(-1);        return(-1);
352     }     }
353        
354     /* 3620/3640 */     if (cisco_eeprom_copy(&router->nm_bay[nm_bay].eeprom,eeprom) == -1) {
355     router->nm_bay[nm_bay].eeprom_data = eeprom->data;        vm_error(router->vm,"c3600_nm_set_eeprom: no memory.\n");
356     router->nm_bay[nm_bay].eeprom_data_len = eeprom->len;        return(-1);
357       }
358     /* 3660 */    
    router->c3660_nm_eeprom_def[nm_bay].data = eeprom->data;  
    router->c3660_nm_eeprom_def[nm_bay].data_len = eeprom->len;  
359     return(0);     return(0);
360  }  }
361    
# Line 354  int c3600_nm_unset_eeprom(c3600_t *route Line 367  int c3600_nm_unset_eeprom(c3600_t *route
367        return(-1);        return(-1);
368     }     }
369        
370     /* 3620/3640 */     cisco_eeprom_free(&router->nm_bay[nm_bay].eeprom);
    router->nm_bay[nm_bay].eeprom_data = NULL;  
    router->nm_bay[nm_bay].eeprom_data_len = 0;  
   
    /* 3660 */  
    router->c3660_nm_eeprom_def[nm_bay].data = NULL;  
    router->c3660_nm_eeprom_def[nm_bay].data_len = 0;  
371     return(0);     return(0);
372  }  }
373    
# Line 370  int c3600_nm_check_eeprom(c3600_t *route Line 377  int c3600_nm_check_eeprom(c3600_t *route
377     if (nm_bay >= C3600_MAX_NM_BAYS)     if (nm_bay >= C3600_MAX_NM_BAYS)
378        return(FALSE);        return(FALSE);
379    
380     return((router->nm_bay[nm_bay].eeprom_data != NULL) ? TRUE : FALSE);     return(cisco_eeprom_valid(&router->nm_bay[nm_bay].eeprom));
381  }  }
382    
383  /* Get bay info */  /* Get bay info */
# Line 745  int c3600_nm_shutdown_all(c3600_t *route Line 752  int c3600_nm_shutdown_all(c3600_t *route
752     return(0);     return(0);
753  }  }
754    
755    /* Show info about all NMs */
756    int c3600_nm_show_all_info(c3600_t *router)
757    {
758       struct c3600_nm_bay *bay;
759       int i;
760    
761       for(i=0;i<C3600_MAX_NM_BAYS;i++) {
762          if (!(bay = c3600_nm_get_info(router,i)) || !bay->nm_driver)
763             continue;
764    
765          if (bay->nm_driver->nm_show_info != NULL)
766             bay->nm_driver->nm_show_info(router,i);
767       }
768    
769       return(0);
770    }
771    
772  /* Maximum number of tokens in a NM description */  /* Maximum number of tokens in a NM description */
773  #define NM_DESC_MAX_TOKENS  8  #define NM_DESC_MAX_TOKENS  8
774    
# Line 953  struct c3600_chassis_driver *c3600_chass Line 977  struct c3600_chassis_driver *c3600_chass
977  }  }
978    
979  /* Set the base MAC address of the chassis */  /* Set the base MAC address of the chassis */
980  static int c3600_burn_mac_addr(m_uint16_t *data,size_t data_len,  static int c3600_burn_mac_addr(c3600_t *router,n_eth_addr_t *addr)
                                n_eth_addr_t *addr)  
981  {  {
982     m_uint8_t eeprom_ver;     m_uint8_t eeprom_ver;
983     size_t offset;     size_t offset;
984    
985     /* Read EEPROM format version */     /* Read EEPROM format version */
986     cisco_eeprom_get_byte(data,data_len,0,&eeprom_ver);     cisco_eeprom_get_byte(&router->mb_eeprom,0,&eeprom_ver);
987    
988     switch(eeprom_ver) {     switch(eeprom_ver) {
989        case 0:        case 0:
990           cisco_eeprom_set_region(data,data_len,2,addr->eth_addr_byte,6);           cisco_eeprom_set_region(&router->mb_eeprom,2,addr->eth_addr_byte,6);
991           break;           break;
992    
993        case 4:        case 4:
994           if (!cisco_eeprom_v4_find_field(data,data_len,0xC3,&offset)) {           if (!cisco_eeprom_v4_find_field(&router->mb_eeprom,0xC3,&offset)) {
995              cisco_eeprom_set_region(data,data_len,offset,              cisco_eeprom_set_region(&router->mb_eeprom,offset,
996                                      addr->eth_addr_byte,6);                                      addr->eth_addr_byte,6);
997           }           }
998           break;           break;
999    
1000        default:        default:
1001           fprintf(stderr,"c3600_burn_mac_addr: unable to handle "           vm_error(router->vm,"c3600_burn_mac_addr: unable to handle "
1002                   "EEPROM version %u\n",eeprom_ver);                    "EEPROM version %u\n",eeprom_ver);
1003           return(-1);           return(-1);
1004     }     }
1005    
# Line 992  int c3600_chassis_set_mac_addr(c3600_t * Line 1015  int c3600_chassis_set_mac_addr(c3600_t *
1015     }     }
1016    
1017     /* Set the chassis base MAC address */     /* Set the chassis base MAC address */
1018     c3600_burn_mac_addr(router->mb_eeprom_data,sizeof(router->mb_eeprom_data),     c3600_burn_mac_addr(router,&router->mac_addr);
                        &router->mac_addr);  
1019     return(0);     return(0);
1020  }  }
1021    
# Line 1015  int c3600_chassis_set_type(c3600_t *rout Line 1037  int c3600_chassis_set_type(c3600_t *rout
1037     router->chassis_driver = driver;     router->chassis_driver = driver;
1038    
1039     /* Copy the mainboard EEPROM */     /* Copy the mainboard EEPROM */
1040     memcpy(router->mb_eeprom_data,driver->mb_eeprom,driver->mb_eeprom_len << 1);     if (cisco_eeprom_copy(&router->mb_eeprom,driver->eeprom) == -1) {
1041          vm_error(router->vm,"unable to set chassis EEPROM '%s'.\n",chassis_type);
1042          return(-1);
1043       }
1044    
1045     /* Set the chassis base MAC address */     /* Set the chassis base MAC address */
1046     c3600_burn_mac_addr(router->mb_eeprom_data,sizeof(router->mb_eeprom_data),     c3600_burn_mac_addr(router,&router->mac_addr);
                        &router->mac_addr);  
   
    router->mb_eeprom.data = router->mb_eeprom_data;  
    router->mb_eeprom.data_len = driver->mb_eeprom_len;  
1047     return(0);     return(0);
1048  }  }
1049    
# Line 1211  void c3600_init_defaults(c3600_t *router Line 1232  void c3600_init_defaults(c3600_t *router
1232    
1233     /* Generate a chassis MAC address based on the instance ID */     /* Generate a chassis MAC address based on the instance ID */
1234     m = &router->mac_addr;     m = &router->mac_addr;
1235     m->eth_addr_byte[0] = 0xCC;     m->eth_addr_byte[0] = vm_get_mac_addr_msb(vm);
1236     m->eth_addr_byte[1] = vm->instance_id & 0xFF;     m->eth_addr_byte[1] = vm->instance_id & 0xFF;
1237     m->eth_addr_byte[2] = pid >> 8;     m->eth_addr_byte[2] = pid >> 8;
1238     m->eth_addr_byte[3] = pid & 0xFF;     m->eth_addr_byte[3] = pid & 0xFF;
# Line 1225  void c3600_init_defaults(c3600_t *router Line 1246  void c3600_init_defaults(c3600_t *router
1246     vm->ram_size          = C3600_DEFAULT_RAM_SIZE;     vm->ram_size          = C3600_DEFAULT_RAM_SIZE;
1247     vm->rom_size          = C3600_DEFAULT_ROM_SIZE;     vm->rom_size          = C3600_DEFAULT_ROM_SIZE;
1248     vm->nvram_size        = C3600_DEFAULT_NVRAM_SIZE;     vm->nvram_size        = C3600_DEFAULT_NVRAM_SIZE;
1249     vm->conf_reg          = C3600_DEFAULT_CONF_REG;     vm->conf_reg_setup    = C3600_DEFAULT_CONF_REG;
1250     vm->clock_divisor     = C3600_DEFAULT_CLOCK_DIV;     vm->clock_divisor     = C3600_DEFAULT_CLOCK_DIV;
1251     vm->nvram_rom_space   = C3600_NVRAM_ROM_RES_SIZE;     vm->nvram_rom_space   = C3600_NVRAM_ROM_RES_SIZE;
1252     router->nm_iomem_size = C3600_DEFAULT_IOMEM_SIZE;     router->nm_iomem_size = C3600_DEFAULT_IOMEM_SIZE;
1253    
1254     vm->pcmcia_disk_size[0] = C3600_DEFAULT_DISK0_SIZE;     vm->pcmcia_disk_size[0] = C3600_DEFAULT_DISK0_SIZE;
1255     vm->pcmcia_disk_size[1] = C3600_DEFAULT_DISK1_SIZE;     vm->pcmcia_disk_size[1] = C3600_DEFAULT_DISK1_SIZE;
1256    
1257       /* Enable NVRAM operations to load/store configs */
1258       vm->nvram_extract_config = c3600_nvram_extract_config;
1259       vm->nvram_push_config = c3600_nvram_push_config;
1260  }  }
1261    
1262  /* Initialize the C3600 Platform */  /* Initialize the C3600 Platform */
# Line 1263  int c3600_init_platform(c3600_t *router) Line 1288  int c3600_init_platform(c3600_t *router)
1288    
1289     /* Mark the Network IO interrupt as high priority */     /* Mark the Network IO interrupt as high priority */
1290     cpu->irq_idle_preempt[C3600_NETIO_IRQ] = TRUE;     cpu->irq_idle_preempt[C3600_NETIO_IRQ] = TRUE;
1291       cpu->irq_idle_preempt[C3600_GT64K_IRQ] = TRUE;
1292     cpu->irq_idle_preempt[C3600_DUART_IRQ] = TRUE;     cpu->irq_idle_preempt[C3600_DUART_IRQ] = TRUE;
1293    
1294     /* Copy some parameters from VM to CPU (idle PC, ...) */     /* Copy some parameters from VM to CPU (idle PC, ...) */
# Line 1303  int c3600_init_platform(c3600_t *router) Line 1329  int c3600_init_platform(c3600_t *router)
1329        return(-1);        return(-1);
1330    
1331     /* Initialize RAM */     /* Initialize RAM */
1332     dev_ram_init(vm,"ram",vm->ram_mmap,0x00000000ULL,vm->ram_size*1048576);     vm_ram_init(vm,0x00000000ULL);
1333    
1334     /* Initialize ROM */     /* Initialize ROM */
1335     if (!vm->rom_filename) {     if (!vm->rom_filename) {
# Line 1311  int c3600_init_platform(c3600_t *router) Line 1337  int c3600_init_platform(c3600_t *router)
1337        dev_rom_init(vm,"rom",C3600_ROM_ADDR,vm->rom_size*1048576);        dev_rom_init(vm,"rom",C3600_ROM_ADDR,vm->rom_size*1048576);
1338     } else {     } else {
1339        /* use alternate ROM */        /* use alternate ROM */
1340        dev_ram_init(vm,"rom",TRUE,C3600_ROM_ADDR,vm->rom_size*1048576);        dev_ram_init(vm,"rom",TRUE,TRUE,NULL,
1341                       C3600_ROM_ADDR,vm->rom_size*1048576);
1342     }     }
1343    
1344     /* Initialize the NS16552 DUART */     /* Initialize the NS16552 DUART */
1345     dev_ns16552_init(vm,C3600_DUART_ADDR,0x1000,C3600_DUART_IRQ,     dev_ns16552_init(vm,C3600_DUART_ADDR,0x1000,3,C3600_DUART_IRQ,
1346                      vm->vtty_con,vm->vtty_aux);                      vm->vtty_con,vm->vtty_aux);
1347    
1348     /* Cirrus Logic PD6729 (PCI-to-PCMCIA host adapter) */     /* Cirrus Logic PD6729 (PCI-to-PCMCIA host adapter) */
# Line 1335  int c3600_init_platform(c3600_t *router) Line 1362  int c3600_init_platform(c3600_t *router)
1362        }        }
1363     }     }
1364    
    /* Enable NVRAM operations to load/store configs */  
    vm->nvram_extract_config = c3600_nvram_extract_config;  
    vm->nvram_push_config = c3600_nvram_push_config;  
   
1365     /* Show device list */     /* Show device list */
1366     c3600_show_hardware(router);     c3600_show_hardware(router);
1367     return(0);     return(0);
# Line 1366  int c3600_boot_ios(c3600_t *router) Line 1389  int c3600_boot_ios(c3600_t *router)
1389    
1390     /* Load IOS image */     /* Load IOS image */
1391     if (mips64_load_elf_image(vm->boot_cpu,vm->ios_image,     if (mips64_load_elf_image(vm->boot_cpu,vm->ios_image,
1392                                 (vm->ghost_status == VM_GHOST_RAM_USE),
1393                               &vm->ios_entry_point) < 0)                               &vm->ios_entry_point) < 0)
1394     {     {
1395        vm_error(vm,"failed to load Cisco IOS image '%s'.\n",vm->ios_image);        vm_error(vm,"failed to load Cisco IOS image '%s'.\n",vm->ios_image);
# Line 1380  int c3600_boot_ios(c3600_t *router) Line 1404  int c3600_boot_ios(c3600_t *router)
1404     vm_log(vm,"C3600_BOOT",     vm_log(vm,"C3600_BOOT",
1405            "starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n",            "starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n",
1406            vm->boot_cpu->pc,vm->boot_cpu->idle_pc,vm->jit_use ? "on":"off");            vm->boot_cpu->pc,vm->boot_cpu->idle_pc,vm->jit_use ? "on":"off");
1407      
1408     /* Start main CPU */     /* Start main CPU */
1409     vm->status = VM_STATUS_RUNNING;     if (vm->ghost_status != VM_GHOST_RAM_GENERATE) {
1410     cpu_start(vm->boot_cpu);        vm->status = VM_STATUS_RUNNING;
1411          cpu_start(vm->boot_cpu);
1412       } else {
1413          vm->status = VM_STATUS_SHUTDOWN;
1414       }
1415     return(0);     return(0);
1416  }  }
1417    
# Line 1416  int c3600_init_instance(c3600_t *router) Line 1444  int c3600_init_instance(c3600_t *router)
1444     rom_entry_point = (m_uint32_t)MIPS_ROM_PC;     rom_entry_point = (m_uint32_t)MIPS_ROM_PC;
1445    
1446     if ((vm->rom_filename != NULL) &&     if ((vm->rom_filename != NULL) &&
1447         (mips64_load_elf_image(cpu0,vm->rom_filename,&rom_entry_point) < 0))         (mips64_load_elf_image(cpu0,vm->rom_filename,0,&rom_entry_point) < 0))
1448     {     {
1449        vm_error(vm,"unable to load alternate ROM '%s', "        vm_error(vm,"unable to load alternate ROM '%s', "
1450                 "fallback to embedded ROM.\n\n",vm->rom_filename);                 "fallback to embedded ROM.\n\n",vm->rom_filename);

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

  ViewVC Help
Powered by ViewVC 1.1.26