/[gxemul]/trunk/src/devices/dev_sn.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/src/devices/dev_sn.c

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

revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_sn.c,v 1.16 2006/12/30 13:30:59 debug Exp $   *  $Id: dev_sn.c,v 1.19 2007/06/15 19:57:34 debug Exp $
29   *     *  
30   *  National Semiconductor SONIC ("sn") DP83932 ethernet.   *  COMMENT: National Semiconductor SONIC ("sn") DP83932 ethernet controller
  *  
31   *   *
32   *  TODO   *  TODO
33   */   */
# Line 51  Line 50 
50  #define DEV_SN_LENGTH           0x1000  #define DEV_SN_LENGTH           0x1000
51    
52  struct sn_data {  struct sn_data {
53          int             irq_nr;          struct interrupt irq;
54          unsigned char   macaddr[6];          unsigned char   macaddr[6];
55          uint32_t        reg[SONIC_NREGS];          uint32_t        reg[SONIC_NREGS];
56  };  };
57    
58    
 /*  
  *  dev_sn_access():  
  */  
59  DEVICE_ACCESS(sn)  DEVICE_ACCESS(sn)
60  {  {
61          struct sn_data *d = (struct sn_data *) extra;          struct sn_data *d = extra;
62          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
63          int regnr;          int regnr;
64    
# Line 79  DEVICE_ACCESS(sn) Line 75  DEVICE_ACCESS(sn)
75          }          }
76    
77          switch (regnr) {          switch (regnr) {
78    
79          default:          default:
80                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
81                          fatal("[ sn: unimplemented write to address 0x%x"                          fatal("[ sn: unimplemented write to address 0x%x"
# Line 88  DEVICE_ACCESS(sn) Line 85  DEVICE_ACCESS(sn)
85                          fatal("[ sn: unimplemented read from address 0x%x "                          fatal("[ sn: unimplemented read from address 0x%x "
86                              "(regnr %i) ]\n", (int)relative_addr, regnr);                              "(regnr %i) ]\n", (int)relative_addr, regnr);
87                  }                  }
88                    /*  exit(1);  */
89          }          }
90    
91          if (writeflag == MEM_READ)          if (writeflag == MEM_READ)
# Line 101  DEVINIT(sn) Line 99  DEVINIT(sn)
99  {  {
100          char *name2;          char *name2;
101          size_t nlen = 55;          size_t nlen = 55;
102          struct sn_data *d = malloc(sizeof(struct sn_data));          struct sn_data *d;
103    
104          if (d == NULL) {          CHECK_ALLOCATION(d = malloc(sizeof(struct sn_data)));
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
105          memset(d, 0, sizeof(struct sn_data));          memset(d, 0, sizeof(struct sn_data));
106          d->irq_nr = devinit->irq_nr;  
107            INTERRUPT_CONNECT(devinit->interrupt_path, d->irq);
108    
109          net_generate_unique_mac(devinit->machine, d->macaddr);          net_generate_unique_mac(devinit->machine, d->macaddr);
110    
111          name2 = malloc(nlen);          CHECK_ALLOCATION(name2 = malloc(nlen));
         if (name2 == NULL) {  
                 fprintf(stderr, "out of memory in dev_sn_init()\n");  
                 exit(1);  
         }  
112          snprintf(name2, nlen, "%s [%02x:%02x:%02x:%02x:%02x:%02x]",          snprintf(name2, nlen, "%s [%02x:%02x:%02x:%02x:%02x:%02x]",
113              devinit->name, d->macaddr[0], d->macaddr[1], d->macaddr[2],              devinit->name, d->macaddr[0], d->macaddr[1], d->macaddr[2],
114              d->macaddr[3], d->macaddr[4], d->macaddr[5]);              d->macaddr[3], d->macaddr[4], d->macaddr[5]);

Legend:
Removed from v.34  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26