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

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * ether.h - Ethernet device driver
3     *
4 gbeauche 1.10 * Basilisk II (C) 1997-2008 Christian Bauer
5 cebix 1.1 *
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 cebix 1.4 struct sockaddr_in;
25    
26     extern void EtherInit(void);
27     extern void EtherExit(void);
28    
29 cebix 1.1 extern int16 EtherOpen(uint32 pb, uint32 dce);
30     extern int16 EtherControl(uint32 pb, uint32 dce);
31 gbeauche 1.9 extern void EtherReadPacket(uint32 &src, uint32 &dest, uint32 &len, uint32 &remaining);
32 cebix 1.1
33     // System specific and internal functions/data
34     extern void EtherReset(void);
35     extern void EtherInterrupt(void);
36    
37 cebix 1.4 extern bool ether_init(void);
38     extern void ether_exit(void);
39 cebix 1.5 extern void ether_reset(void);
40 cebix 1.1 extern int16 ether_add_multicast(uint32 pb);
41     extern int16 ether_del_multicast(uint32 pb);
42     extern int16 ether_attach_ph(uint16 type, uint32 handler);
43     extern int16 ether_detach_ph(uint16 type);
44     extern int16 ether_write(uint32 wds);
45 cebix 1.4 extern bool ether_start_udp_thread(int socket_fd);
46     extern void ether_stop_udp_thread(void);
47 gbeauche 1.9 extern void ether_udp_read(uint32 packet, int length, struct sockaddr_in *from);
48 cebix 1.1
49 cebix 1.4 extern uint8 ether_addr[6]; // Ethernet address (set by ether_init())
50 cebix 1.1
51     // Ethernet driver data in MacOS RAM
52     enum {
53     ed_DeferredTask = 0, // Deferred Task struct
54     ed_Code = 20, // DT code is stored here
55     ed_Result = 30, // Result for DT
56     ed_DCE = 34, // DCE for DT (must come directly behind ed_Result)
57     ed_RHA = 38, // Read header area
58     ed_ReadPacket = 52, // ReadPacket/ReadRest routines
59     SIZEOF_etherdata = 76
60     };
61    
62     extern uint32 ether_data; // Mac address of driver data in MacOS RAM
63 cebix 1.4
64 gbeauche 1.9 // Ethernet packet allocator (optimized for 32-bit platforms in real addressing mode)
65     class EthernetPacket {
66     #if SIZEOF_VOID_P == 4 && REAL_ADDRESSING
67     uint8 packet[1516];
68     public:
69     uint32 addr(void) const { return (uint32)packet; }
70     #else
71     uint32 packet;
72     public:
73     EthernetPacket();
74     ~EthernetPacket();
75     uint32 addr(void) const { return packet; }
76     #endif
77     };
78    
79 cebix 1.4 // Copy packet data from WDS to linear buffer (must hold at least 1514 bytes),
80     // returns packet length
81     static inline int ether_wds_to_buffer(uint32 wds, uint8 *p)
82     {
83     int len = 0;
84     while (len < 1514) {
85     int w = ReadMacInt16(wds);
86     if (w == 0)
87     break;
88     Mac2Host_memcpy(p, ReadMacInt32(wds + 2), w);
89     len += w;
90     p += w;
91     wds += 6;
92     }
93     return len;
94     }
95 cebix 1.1
96     #endif