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

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

revision 32 by dpavlin, Mon Oct 8 16:20:58 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2005-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-2007  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_ether.c,v 1.15 2006/10/07 00:36:29 debug Exp $   *  $Id: dev_ether.c,v 1.17 2006/12/30 13:30:57 debug Exp $
29   *   *
30   *  Basic "ethernet" network device. This is a simple test device which can   *  Basic "ethernet" network device. This is a simple test device which can
31   *  be used to send and receive packets to/from a simulated ethernet network.   *  be used to send and receive packets to/from a simulated ethernet network.
# Line 49  Line 49 
49  #define DEV_ETHER_TICK_SHIFT    14  #define DEV_ETHER_TICK_SHIFT    14
50    
51  struct ether_data {  struct ether_data {
52          unsigned char   buf[DEV_ETHER_BUFFER_SIZE];          unsigned char           buf[DEV_ETHER_BUFFER_SIZE];
53          unsigned char   mac[6];          unsigned char           mac[6];
54    
55          int             status;          int                     status;
56          int             packet_len;          int                     packet_len;
57    
58          int             irq_nr;          struct interrupt        irq;
59  };  };
60    
61    
# Line 71  DEVICE_TICK(ether) Line 71  DEVICE_TICK(ether)
71                  d->status |= DEV_ETHER_STATUS_MORE_PACKETS_AVAILABLE;                  d->status |= DEV_ETHER_STATUS_MORE_PACKETS_AVAILABLE;
72    
73          if (d->status)          if (d->status)
74                  cpu_interrupt(cpu, d->irq_nr);                  INTERRUPT_ASSERT(d->irq);
75          else          else
76                  cpu_interrupt_ack(cpu, d->irq_nr);                  INTERRUPT_DEASSERT(d->irq);
77  }  }
78    
79    
# Line 108  DEVICE_ACCESS(ether) Line 108  DEVICE_ACCESS(ether)
108                  if (writeflag == MEM_READ) {                  if (writeflag == MEM_READ) {
109                          odata = d->status;                          odata = d->status;
110                          d->status = 0;                          d->status = 0;
111                          cpu_interrupt_ack(cpu, d->irq_nr);                          INTERRUPT_DEASSERT(d->irq);
112                  } else                  } else
113                          fatal("[ ether: WARNING: write to status ]\n");                          fatal("[ ether: WARNING: write to status ]\n");
114                  break;                  break;
# Line 211  DEVINIT(ether) Line 211  DEVINIT(ether)
211                  exit(1);                  exit(1);
212          }          }
213          memset(d, 0, sizeof(struct ether_data));          memset(d, 0, sizeof(struct ether_data));
214          d->irq_nr = devinit->irq_nr;  
215            INTERRUPT_CONNECT(devinit->interrupt_path, d->irq);
216    
217          net_generate_unique_mac(devinit->machine, d->mac);          net_generate_unique_mac(devinit->machine, d->mac);
218          snprintf(tmp, sizeof(tmp), "%02x:%02x:%02x:%02x:%02x:%02x",          snprintf(tmp, sizeof(tmp), "%02x:%02x:%02x:%02x:%02x:%02x",

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

  ViewVC Help
Powered by ViewVC 1.1.26