ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/include/ether.h
Revision: 1.5
Committed: 2008-01-01T09:47:39Z (16 years, 4 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -1 lines
Log Message:
Happy New Year!

File Contents

# Content
1 /*
2 * ether.h - SheepShaver Ethernet Device Driver
3 *
4 * SheepShaver (C) 1997-2008 Marc Hellwig and Christian Bauer
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifndef ETHER_H
22 #define ETHER_H
23
24 struct queue;
25 struct msgb;
26 typedef struct queue queue_t;
27 typedef struct msgb mblk_t;
28
29 extern uint8 InitStreamModule(void *theID);
30 extern void TerminateStreamModule(void);
31 extern int ether_open(queue_t *rdq, void *dev, int flag, int sflag, void *creds);
32 extern int ether_close(queue_t *rdq, int flag, void *creds);
33 extern int ether_wput(queue_t *q, mblk_t *mp);
34 extern int ether_rsrv(queue_t *q);
35
36 // System specific and internal functions/data
37 extern void EtherInit(void);
38 extern void EtherExit(void);
39
40 extern void EtherIRQ(void);
41
42 extern void AO_get_ethernet_address(uint32 addr);
43 extern void AO_enable_multicast(uint32 addr);
44 extern void AO_disable_multicast(uint32 addr);
45 extern void AO_transmit_packet(uint32 mp);
46
47 extern mblk_t *allocb(size_t size, int pri);
48 extern void OTEnterInterrupt(void);
49 extern void OTLeaveInterrupt(void);
50
51 extern void ether_dispatch_packet(uint32 p, uint32 length);
52 extern void ether_packet_received(mblk_t *mp);
53
54 extern bool ether_driver_opened;
55
56 // Ethernet packet allocator (optimized for 32-bit platforms in real addressing mode)
57 class EthernetPacket {
58 #if SIZEOF_VOID_P == 4 && REAL_ADDRESSING
59 uint8 packet[1516];
60 public:
61 uint32 addr(void) const { return (uint32)packet; }
62 #else
63 uint32 packet;
64 public:
65 EthernetPacket();
66 ~EthernetPacket();
67 uint32 addr(void) const { return packet; }
68 #endif
69 };
70
71 // Copy packet data from message block to linear buffer (must hold at
72 // least 1514 bytes), returns packet length
73 static inline int ether_msgb_to_buffer(uint32 mp, uint8 *p)
74 {
75 int len = 0;
76 while (mp) {
77 uint32 size = ReadMacInt32(mp + 16) - ReadMacInt32(mp + 12);
78 Mac2Host_memcpy(p, ReadMacInt32(mp + 12), size);
79 len += size;
80 p += size;
81 mp = ReadMacInt32(mp + 8);
82 }
83 return len;
84 }
85
86 extern int32 num_wput;
87 extern int32 num_error_acks;
88 extern int32 num_tx_packets;
89 extern int32 num_tx_raw_packets;
90 extern int32 num_tx_normal_packets;
91 extern int32 num_tx_buffer_full;
92 extern int32 num_rx_packets;
93 extern int32 num_ether_irq;
94 extern int32 num_unitdata_ind;
95 extern int32 num_rx_fastpath;
96 extern int32 num_rx_no_mem;
97 extern int32 num_rx_dropped;
98 extern int32 num_rx_stream_not_ready;
99 extern int32 num_rx_no_unitdata_mem;
100
101 #endif