ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/BeOS/CreatePCIDrivers/Ethernet.cpp
Revision: 1.5
Committed: 2008-01-01T09:47:38Z (16 years, 5 months ago) by gbeauche
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -1 lines
Log Message:
Happy New Year!

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * Ethernet.cpp - SheepShaver ethernet PCI driver stub
3     *
4 gbeauche 1.5 * SheepShaver (C) 1997-2008 Christian Bauer and Marc Hellwig
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     #include "sysdeps.h"
22 gbeauche 1.4 #include <stddef.h>
23 cebix 1.1 #include "xlowmem.h"
24     #include "ether_defs.h"
25    
26    
27     /*
28     * Driver Description structure
29     */
30    
31     struct DriverDescription {
32     uint32 driverDescSignature;
33     uint32 driverDescVersion;
34     char nameInfoStr[32];
35     uint32 version;
36     uint32 driverRuntime;
37     char driverName[32];
38     uint32 driverDescReserved[8];
39     uint32 nServices;
40     uint32 serviceCategory;
41     uint32 serviceType;
42     uint32 serviceVersion;
43     };
44    
45     #pragma export on
46     DriverDescription TheDriverDescription = {
47     'mtej',
48     0,
49     "\pSheepShaver Ethernet",
50     0x01008000, // V1.0.0final
51     4, // kDriverIsUnderExpertControl
52     "\penet",
53     0, 0, 0, 0, 0, 0, 0, 0,
54     1,
55     'otan',
56     0x000a0b01, // Ethernet, Framing: Ethernet/EthernetIPX/802.2, IsDLPI
57     0x01000000, // V1.0.0
58     };
59     #pragma export off
60    
61    
62     /*
63     * install_info and related structures
64     */
65    
66     static int ether_open(queue_t *rdq, void *dev, int flag, int sflag, void *creds);
67     static int ether_close(queue_t *rdq, int flag, void *creds);
68     static int ether_wput(queue_t *q, msgb *mp);
69     static int ether_wsrv(queue_t *q);
70     static int ether_rput(queue_t *q, msgb *mp);
71     static int ether_rsrv(queue_t *q);
72    
73     struct ot_module_info {
74     uint16 mi_idnum;
75     char *mi_idname;
76     int32 mi_minpsz; // Minimum packet size
77     int32 mi_maxpsz; // Maximum packet size
78     uint32 mi_hiwat; // Queue hi-water mark
79     uint32 mi_lowat; // Queue lo-water mark
80     };
81    
82     static ot_module_info module_information = {
83     kEnetModuleID,
84     "SheepShaver Ethernet",
85     0,
86     kEnetTSDU,
87     6000,
88     5000
89     };
90    
91     typedef int (*putp_t)(queue_t *, msgb *);
92     typedef int (*srvp_t)(queue_t *);
93     typedef int (*openp_t)(queue_t *, void *, int, int, void *);
94     typedef int (*closep_t)(queue_t *, int, void *);
95    
96     struct qinit {
97     putp_t qi_putp;
98     srvp_t qi_srvp;
99     openp_t qi_qopen;
100     closep_t qi_qclose;
101     void *qi_qadmin;
102     struct ot_module_info *qi_minfo;
103     void *qi_mstat;
104     };
105    
106     static qinit read_side = {
107     NULL,
108     ether_rsrv,
109     ether_open,
110     ether_close,
111     NULL,
112     &module_information,
113     NULL
114     };
115    
116     static qinit write_side = {
117     ether_wput,
118     NULL,
119     ether_open,
120     ether_close,
121     NULL,
122     &module_information,
123     NULL
124     };
125    
126     struct streamtab {
127     struct qinit *st_rdinit;
128     struct qinit *st_wrinit;
129     struct qinit *st_muxrinit;
130     struct qinit *st_muxwinit;
131     };
132    
133     static streamtab the_streamtab = {
134     &read_side,
135     &write_side,
136     NULL,
137     NULL
138     };
139    
140     struct install_info {
141     struct streamtab *install_str;
142     uint32 install_flags;
143     uint32 install_sqlvl;
144     char *install_buddy;
145     void *ref_load;
146     uint32 ref_count;
147     };
148    
149     enum {
150     kOTModIsDriver = 0x00000001,
151     kOTModUpperIsDLPI = 0x00002000,
152     SQLVL_MODULE = 3,
153     };
154    
155     static install_info the_install_info = {
156     &the_streamtab,
157     kOTModIsDriver /*| kOTModUpperIsDLPI */,
158     SQLVL_MODULE,
159     NULL,
160     NULL,
161     0
162     };
163    
164    
165     // Prototypes for exported functions
166     extern "C" {
167     #pragma export on
168     extern uint32 ValidateHardware(void *theID);
169     extern install_info* GetOTInstallInfo();
170     extern uint8 InitStreamModule(void *theID);
171     extern void TerminateStreamModule(void);
172     #pragma export off
173     }
174    
175    
176     /*
177     * Validate that our hardware is available (always available)
178     */
179    
180     uint32 ValidateHardware(void *theID)
181     {
182     return 0;
183     }
184    
185    
186     /*
187     * Return pointer to install_info structure
188     */
189    
190     install_info *GetOTInstallInfo(void)
191     {
192     return &the_install_info;
193     }
194    
195    
196     /*
197     * Init module
198     */
199    
200     asm uint8 InitStreamModule(register void *theID)
201     {
202     lwz r2,XLM_TOC
203     lwz r0,XLM_ETHER_INIT
204     mtctr r0
205     bctr
206     }
207    
208    
209     /*
210     * Terminate module
211     */
212    
213     asm void TerminateStreamModule(void)
214     {
215     lwz r2,XLM_TOC
216     lwz r0,XLM_ETHER_TERM
217     mtctr r0
218     bctr
219     }
220    
221    
222     /*
223     * DLPI functions
224     */
225    
226     static asm int ether_open(register queue_t *rdq, register void *dev, register int flag, register int sflag, register void *creds)
227     {
228     lwz r2,XLM_TOC
229     lwz r0,XLM_ETHER_OPEN
230     mtctr r0
231     bctr
232     }
233    
234     static asm int ether_close(register queue_t *rdq, register int flag, register void *creds)
235     {
236     lwz r2,XLM_TOC
237     lwz r0,XLM_ETHER_CLOSE
238     mtctr r0
239     bctr
240     }
241    
242     static asm int ether_wput(register queue_t *q, register msgb *mp)
243     {
244     lwz r2,XLM_TOC
245     lwz r0,XLM_ETHER_WPUT
246     mtctr r0
247     bctr
248     }
249    
250     static asm int ether_rsrv(register queue_t *q)
251     {
252     lwz r2,XLM_TOC
253     lwz r0,XLM_ETHER_RSRV
254     mtctr r0
255     bctr
256     }