/[dynamips]/upstream/dynamips-0.2.6-RC2/dev_c3600_iofpga.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-RC2/dev_c3600_iofpga.c

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

upstream/dynamips-0.2.5/dev_c3600_iofpga.c revision 1 by dpavlin, Sat Oct 6 16:01:44 2007 UTC upstream/dynamips-0.2.6-RC2/dev_c3600_iofpga.c revision 3 by dpavlin, Sat Oct 6 16:05:34 2007 UTC
# Line 39  Line 39 
39  #define EEPROM_NM_CLK   2  #define EEPROM_NM_CLK   2
40  #define EEPROM_NM_CS    4  #define EEPROM_NM_CS    4
41    
42    #define C3600_NET_IRQ_CLEARING_DELAY  16
43    
44  /* IO FPGA structure */  /* IO FPGA structure */
45  struct iofpga_data {  struct iofpga_data {
46     vm_obj_t vm_obj;     vm_obj_t vm_obj;
47     struct vdevice dev;     struct vdevice dev;
48     c3600_t *router;     c3600_t *router;
49      
50       /*
51        * Used to introduce a "delay" before clearing the network interrupt
52        * on 3620/3640 platforms. Added due to a packet loss when using an
53        * Ethernet NM on these platforms.
54        *
55        * Anyway, we should rely on the device information with appropriate IRQ
56        * routing.
57        */
58       int net_irq_clearing_count;
59      
60     /* Slot select for EEPROM access */     /* Slot select for EEPROM access */
61     u_int eeprom_slot;     u_int eeprom_slot;
62    
# Line 58  struct iofpga_data { Line 70  struct iofpga_data {
70  static const struct nmc93c46_eeprom_def eeprom_mb_def = {  static const struct nmc93c46_eeprom_def eeprom_mb_def = {
71     EEPROM_MB_CLK, EEPROM_MB_CS,     EEPROM_MB_CLK, EEPROM_MB_CS,
72     EEPROM_MB_DIN, EEPROM_MB_DOUT,     EEPROM_MB_DIN, EEPROM_MB_DOUT,
    NULL, 0,  
73  };  };
74    
75  /* Mainboard EEPROM */  /* Mainboard EEPROM */
76  static const struct nmc93c46_group eeprom_mb_group = {  static const struct nmc93c46_group eeprom_mb_group = {
77     1, 0, "Mainboard EEPROM", 0, { NULL }, { { 0, 0, 0, 0, 0} },     1, 0, "Mainboard EEPROM", 0, { &eeprom_mb_def },
78  };  };
79    
80  /* NM EEPROM definition */  /* NM EEPROM definition */
81  static const struct nmc93c46_eeprom_def eeprom_nm_def = {  static const struct nmc93c46_eeprom_def eeprom_nm_def = {
82     EEPROM_NM_CLK, EEPROM_NM_CS,     EEPROM_NM_CLK, EEPROM_NM_CS,
83     EEPROM_NM_DIN, EEPROM_NM_DOUT,     EEPROM_NM_DIN, EEPROM_NM_DOUT,
    NULL, 0,  
84  };  };
85    
86  /* NM EEPROM */  /* NM EEPROM */
87  static const struct nmc93c46_group eeprom_nm_group = {  static const struct nmc93c46_group eeprom_nm_group = {
88     1, 0, "NM EEPROM", 0, { NULL }, { { 0, 0, 0, 0, 0} },     1, 0, "NM EEPROM", 0, { &eeprom_nm_def },
89  };  };
90    
91  /* C3660 NM presence masks */  /* C3660 NM presence masks */
# Line 91  static const m_uint16_t c3660_nm_masks[6 Line 101  static const m_uint16_t c3660_nm_masks[6
101  /* Select the current NM EEPROM */  /* Select the current NM EEPROM */
102  static void nm_eeprom_select(struct iofpga_data *d,u_int slot)  static void nm_eeprom_select(struct iofpga_data *d,u_int slot)
103  {  {
104     d->router->nm_eeprom.data = d->router->nm_bay[slot].eeprom_data;     d->router->nm_eeprom_group.eeprom[0] = &d->router->nm_bay[slot].eeprom;
    d->router->nm_eeprom.data_len = d->router->nm_bay[slot].eeprom_data_len;  
105  }  }
106    
107  /* Return the NM status register given the detected EEPROM (3620/3640) */  /* Return the NM status register given the detected EEPROM (3620/3640) */
# Line 232  dev_c3620_c3640_iofpga_access(cpu_mips_t Line 241  dev_c3620_c3640_iofpga_access(cpu_mips_t
241        case 0x20001:        case 0x20001:
242        case 0x20002:        case 0x20002:
243        case 0x20003:        case 0x20003:
244           /* XXX Thisn't seem to be correct (at least on 3620) */           /* XXX This doesn't seem to be correct (at least on 3620) */
245           slot = offset - 0x20000;           slot = offset - 0x20000;
246    
247           if (op_type == MTS_READ)           if (op_type == MTS_READ)
248              *data = 0xFF;              *data = 0xFF;
249    
250           vm_clear_irq(d->router->vm,C3600_NETIO_IRQ);           if (++d->net_irq_clearing_count == C3600_NET_IRQ_CLEARING_DELAY) {
251                vm_clear_irq(d->router->vm,C3600_NETIO_IRQ);
252                d->net_irq_clearing_count = 0;
253             }
254           break;           break;
255    
256        /*        /*
# Line 584  dev_c3660_iofpga_access(cpu_mips_t *cpu, Line 596  dev_c3660_iofpga_access(cpu_mips_t *cpu,
596  /* Initialize EEPROM groups */  /* Initialize EEPROM groups */
597  void c3600_init_eeprom_groups(c3600_t *router)  void c3600_init_eeprom_groups(c3600_t *router)
598  {  {
    struct nmc93c46_group *g;  
599     int i;     int i;
600    
601     /* Copy Mainboard EEPROM definition */     /* Initialize Mainboard EEPROM */
602     memcpy(&router->mb_eeprom,&eeprom_mb_def,sizeof(eeprom_mb_def));     router->mb_eeprom_group = eeprom_mb_group;
603       router->mb_eeprom_group.eeprom[0] = &router->mb_eeprom;
604     /* Initialize group */     router->mb_eeprom.data = NULL;
605     g = &router->mb_eeprom_group;     router->mb_eeprom.len  = 0;
606     memcpy(g,&eeprom_mb_group,sizeof(eeprom_mb_group));  
607     g->def[0] = &router->mb_eeprom;     /* Initialize NM EEPROM for 3620/3640 */
608       router->nm_eeprom_group = eeprom_nm_group;
609     /* Copy NM EEPROM definition (3620/3640) */     router->nm_eeprom_group.eeprom[0] = NULL;
    memcpy(&router->nm_eeprom,&eeprom_nm_def,sizeof(eeprom_nm_def));  
    router->nm_eeprom.data = NULL;  
    router->nm_eeprom.data_len = 0;  
   
    /* Initialize group (3620/3640) */  
    g = &router->nm_eeprom_group;  
    memcpy(g,&eeprom_nm_group,sizeof(eeprom_nm_group));  
    g->def[0] = &router->nm_eeprom;  
610    
611     /* 3660 NM EEPROM */     /* Initialize NM EEPROM for 3660 */
612     for(i=0;i<C3600_MAX_NM_BAYS;i++) {     for(i=0;i<C3600_MAX_NM_BAYS;i++) {
613        memcpy(&router->c3660_nm_eeprom_def[i],&eeprom_nm_def,        router->c3660_nm_eeprom_group[i] = eeprom_nm_group;
614               sizeof(struct nmc93c46_eeprom_def));        router->c3660_nm_eeprom_group[i].eeprom[0] = &router->nm_bay[i].eeprom;
   
       memcpy(&router->c3660_nm_eeprom_group[i],&eeprom_nm_group,  
              sizeof(struct nmc93c46_group));  
   
       router->c3660_nm_eeprom_group[i].def[0] =  
          &router->c3660_nm_eeprom_def[i];  
615     }     }
616  }  }
617    

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

  ViewVC Help
Powered by ViewVC 1.1.26