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

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

upstream/dynamips-0.2.7/nmc93cX6.c revision 10 by dpavlin, Sat Oct 6 16:29:14 2007 UTC upstream/dynamips-0.2.8-RC1/nmc93cX6.c revision 11 by dpavlin, Sat Oct 6 16:33:40 2007 UTC
# Line 54  static void nmc93cX6_check_cs(struct nmc Line 54  static void nmc93cX6_check_cs(struct nmc
54    
55     for(i=0;i<g->nr_eeprom;i++)     for(i=0;i<g->nr_eeprom;i++)
56     {     {
57        g->state[i].dataout_val = 1;        if (g->dout_status == EEPROM_DOUT_HIGH)
58             g->state[i].dataout_val = 1;
59    
60        if (g->debug)        if (g->debug)
61        {        {
# Line 68  static void nmc93cX6_check_cs(struct nmc Line 69  static void nmc93cX6_check_cs(struct nmc
69        if ((res = check_bit(old,new,g->def[i]->select_bit)) != 0) {        if ((res = check_bit(old,new,g->def[i]->select_bit)) != 0) {
70           g->state[i].cmd_len = 0;     /* no bit for command sent now */           g->state[i].cmd_len = 0;     /* no bit for command sent now */
71           g->state[i].cmd_val = 0;           g->state[i].cmd_val = 0;
72             //g->state[i].dataout_val = 1;
73    
74           if (res == 2)           if (res == 2)
75              g->state[i].state = EEPROM_STATE_WAIT_CMD;              g->state[i].state = EEPROM_STATE_WAIT_CMD;
# Line 94  static void nmc93cX6_check_clk_group(str Line 96  static void nmc93cX6_check_clk_group(str
96        printf("EEPROM %s(%d): check_clk: check_bit(old,new,select_bit) "        printf("EEPROM %s(%d): check_clk: check_bit(old,new,select_bit) "
97               "[%8.8x, %8.8x, %d (mask = %8.8x)] = %d\n",               "[%8.8x, %8.8x, %d (mask = %8.8x)] = %d\n",
98               g->description, group_id,               g->description, group_id,
99               old,new, clk_bit, 1 << clk_bit, check_bit(old,new,clk_bit));               old, new, clk_bit, 1 << clk_bit, check_bit(old,new,clk_bit));
100     }     }
101    
102     /* CLK bit set ? */     /* CLK bit set ? */
# Line 104  static void nmc93cX6_check_clk_group(str Line 106  static void nmc93cX6_check_clk_group(str
106     switch(g->state[group_id].state)     switch(g->state[group_id].state)
107     {     {
108        case EEPROM_STATE_WAIT_CMD:        case EEPROM_STATE_WAIT_CMD:
109             /* The first bit must be set to "1" */
110             if ((g->state[group_id].cmd_len == 0) && !(new & (1 << din_bit)))
111                break;
112    
113           /* Read DATAIN bit */           /* Read DATAIN bit */
114           if (new & (1 << din_bit))           if (new & (1 << din_bit))
115              g->state[group_id].cmd_val |= (1 << g->state[group_id].cmd_len);              g->state[group_id].cmd_val |= (1 << g->state[group_id].cmd_len);
# Line 113  static void nmc93cX6_check_clk_group(str Line 119  static void nmc93cX6_check_clk_group(str
119           cmd_len = nmc94cX6_get_cmd_len(g);           cmd_len = nmc94cX6_get_cmd_len(g);
120    
121           /* Command is complete ? */           /* Command is complete ? */
122           if ((g->state[group_id].cmd_len == cmd_len) &&           if (g->state[group_id].cmd_len == cmd_len)
              (g->state[group_id].cmd_val & 1))  
123           {           {
124  #if DEBUG_EEPROM  #if DEBUG_EEPROM
125              printf("nmc93cX6: %s(%d): command = %x\n",              printf("nmc93cX6: %s(%d): command = %x\n",
# Line 125  static void nmc93cX6_check_clk_group(str Line 130  static void nmc93cX6_check_clk_group(str
130              /* we have the command! extract the opcode */              /* we have the command! extract the opcode */
131              cmd = g->state[group_id].cmd_val;              cmd = g->state[group_id].cmd_val;
132              op = cmd & 0x7;              op = cmd & 0x7;
133                
134              switch(op) {              switch(op) {
135                 case NMC93CX6_CMD_READ:                 case NMC93CX6_CMD_READ:
136                    g->state[group_id].state = EEPROM_STATE_DATAOUT;                    g->state[group_id].state = EEPROM_STATE_DATAOUT;
# Line 143  static void nmc93cX6_check_clk_group(str Line 148  static void nmc93cX6_check_clk_group(str
148        case EEPROM_STATE_DATAOUT:        case EEPROM_STATE_DATAOUT:
149           /*           /*
150            * user want to read data. we read 16-bits.            * user want to read data. we read 16-bits.
151            * extract address (6 bits) from command.            * extract address (6/9 bits) from command.
152            */            */
153                        
154           cmd = g->state[group_id].cmd_val;           cmd = g->state[group_id].cmd_val;
155           addr = nmc94cX6_get_addr(g,cmd);           addr = nmc94cX6_get_addr(g,cmd);
156    
157  #if DEBUG_EEPROM  #if DEBUG_EEPROM
158           if (g->state[group_id].dataout_pos == 0)           if (g->state[group_id].dataout_pos == 0) {
159              printf("nmc93cX6: %s(%d): read addr=%x (%d), val = %4.4x\n",              printf("nmc93cX6: %s(%d): "
160                       "read addr=%x (%d), val=%4.4x [eeprom=%p]\n",
161                     g->description,group_id,addr,addr,                     g->description,group_id,addr,addr,
162                     g->state[group_id].cmd_val);                     g->state[group_id].cmd_val,
163                       g->eeprom[group_id]);
164             }
165  #endif  #endif
166                        
167           pos = g->state[group_id].dataout_pos++;           pos = g->state[group_id].dataout_pos++;
168    
169             if (g->reverse_data)
170                pos = 15 - pos;
171    
172           eeprom = g->eeprom[group_id];           eeprom = g->eeprom[group_id];
173    
174           if (eeprom && eeprom->data && (addr < eeprom->len)) {           if (eeprom && eeprom->data && (addr < eeprom->len)) {
# Line 198  void nmc93cX6_write(struct nmc93cX6_grou Line 210  void nmc93cX6_write(struct nmc93cX6_grou
210     g->eeprom_reg = new;     g->eeprom_reg = new;
211  }  }
212    
213    /* Returns the TRUE if the EEPROM is active */
214    u_int nmc93cX6_is_active(struct nmc93cX6_group *g,u_int group_id)
215    {
216       return(g->eeprom_reg & (1 << g->def[group_id]->select_bit));
217    }
218    
219    /* Returns the DOUT bit value */
220    u_int nmc93cX6_get_dout(struct nmc93cX6_group *g,u_int group_id)
221    {
222       if (g->state[group_id].dataout_val)
223          return(1 << g->def[group_id]->dout_bit);
224       else
225          return(0);
226    }
227    
228  /* Handle read */  /* Handle read */
229  u_int nmc93cX6_read(struct nmc93cX6_group *g)  u_int nmc93cX6_read(struct nmc93cX6_group *g)
230  {  {

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

  ViewVC Help
Powered by ViewVC 1.1.26