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: |
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. |
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 |
|
|
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 |
|
|
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; |
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", |