2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License as
4 * published by the Free Software Foundation; either version 2, or (at
5 * your option) any later version.
8 FILE_LICENCE ( GPL2_OR_LATER
);
18 #include <gpxe/isapnp.h>
20 #include <gpxe/eisa.h>
36 * Structure returned from eth_probe and passed to other driver
40 struct nic_operations
*nic_op
;
41 int flags
; /* driver specific flags */
42 unsigned char *node_addr
;
43 unsigned char *packet
;
44 unsigned int packetlen
;
49 void *priv_data
; /* driver private data */
52 struct nic_operations
{
53 int ( *connect
) ( struct nic
* );
54 int ( *poll
) ( struct nic
*, int retrieve
);
55 void ( *transmit
) ( struct nic
*, const char *,
56 unsigned int, unsigned int, const char * );
57 void ( *irq
) ( struct nic
*, irq_action_t
);
60 extern struct nic nic
;
62 static inline int eth_poll ( int retrieve
) {
63 return nic
.nic_op
->poll ( &nic
, retrieve
);
66 static inline void eth_transmit ( const char *dest
, unsigned int type
,
67 unsigned int size
, const void *packet
) {
68 nic
.nic_op
->transmit ( &nic
, dest
, type
, size
, packet
);
75 extern int dummy_connect ( struct nic
*nic
);
76 extern void dummy_irq ( struct nic
*nic
, irq_action_t irq_action
);
77 extern int legacy_probe ( void *hwdev
,
78 void ( * set_drvdata
) ( void *hwdev
, void *priv
),
80 int ( * probe
) ( struct nic
*nic
, void *hwdev
),
81 void ( * disable
) ( struct nic
*nic
, void *hwdev
));
82 void legacy_remove ( void *hwdev
,
83 void * ( * get_drvdata
) ( void *hwdev
),
84 void ( * disable
) ( struct nic
*nic
, void *hwdev
) );
86 #define PCI_DRIVER(_name,_ids,_class) \
88 _name ## _pci_legacy_probe ( struct pci_device *pci, \
89 const struct pci_device_id *id ); \
91 _name ## _pci_legacy_remove ( struct pci_device *pci ); \
92 struct pci_driver _name __pci_driver = { \
94 .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
95 .probe = _name ## _pci_legacy_probe, \
96 .remove = _name ## _pci_legacy_remove, \
98 REQUIRE_OBJECT ( pci );
100 static inline void legacy_pci_set_drvdata ( void *hwdev
, void *priv
) {
101 pci_set_drvdata ( hwdev
, priv
);
103 static inline void * legacy_pci_get_drvdata ( void *hwdev
) {
104 return pci_get_drvdata ( hwdev
);
107 #define ISAPNP_DRIVER(_name,_ids) \
109 _name ## _isapnp_legacy_probe ( struct isapnp_device *isapnp, \
110 const struct isapnp_device_id *id ); \
112 _name ## _isapnp_legacy_remove ( struct isapnp_device *isapnp ); \
113 struct isapnp_driver _name __isapnp_driver = { \
115 .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
116 .probe = _name ## _isapnp_legacy_probe, \
117 .remove = _name ## _isapnp_legacy_remove, \
119 REQUIRE_OBJECT ( isapnp );
121 static inline void legacy_isapnp_set_drvdata ( void *hwdev
, void *priv
) {
122 isapnp_set_drvdata ( hwdev
, priv
);
124 static inline void * legacy_isapnp_get_drvdata ( void *hwdev
) {
125 return isapnp_get_drvdata ( hwdev
);
128 #define EISA_DRIVER(_name,_ids) \
130 _name ## _eisa_legacy_probe ( struct eisa_device *eisa, \
131 const struct eisa_device_id *id ); \
133 _name ## _eisa_legacy_remove ( struct eisa_device *eisa ); \
134 struct eisa_driver _name __eisa_driver = { \
136 .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
137 .probe = _name ## _eisa_legacy_probe, \
138 .remove = _name ## _eisa_legacy_remove, \
140 REQUIRE_OBJECT ( eisa );
142 static inline void legacy_eisa_set_drvdata ( void *hwdev
, void *priv
) {
143 eisa_set_drvdata ( hwdev
, priv
);
145 static inline void * legacy_eisa_get_drvdata ( void *hwdev
) {
146 return eisa_get_drvdata ( hwdev
);
149 #define MCA_DRIVER(_name,_ids) \
151 _name ## _mca_legacy_probe ( struct mca_device *mca, \
152 const struct mca_device_id *id ); \
154 _name ## _mca_legacy_remove ( struct mca_device *mca ); \
155 struct mca_driver _name __mca_driver = { \
157 .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
158 .probe = _name ## _mca_legacy_probe, \
159 .remove = _name ## _mca_legacy_remove, \
161 REQUIRE_OBJECT ( mca );
163 static inline void legacy_mca_set_drvdata ( void *hwdev
, void *priv
) {
164 mca_set_drvdata ( hwdev
, priv
);
166 static inline void * legacy_mca_get_drvdata ( void *hwdev
) {
167 return mca_get_drvdata ( hwdev
);
170 #define ISA_DRIVER(_name,_probe_addrs,_probe_addr,_vendor_id,_prod_id) \
172 _name ## _isa_legacy_probe ( struct isa_device *isa ); \
174 _name ## _isa_legacy_probe_at_addr ( struct isa_device *isa ) { \
175 if ( ! _probe_addr ( isa->ioaddr ) ) \
177 return _name ## _isa_legacy_probe ( isa ); \
180 _name ## _isa_legacy_remove ( struct isa_device *isa ); \
181 static const char _name ## _text[]; \
182 struct isa_driver _name __isa_driver = { \
183 .name = _name ## _text, \
184 .probe_addrs = _probe_addrs, \
185 .addr_count = ( sizeof ( _probe_addrs ) / \
186 sizeof ( _probe_addrs[0] ) ), \
187 .vendor_id = _vendor_id, \
188 .prod_id = _prod_id, \
189 .probe = _name ## _isa_legacy_probe_at_addr, \
190 .remove = _name ## _isa_legacy_remove, \
192 REQUIRE_OBJECT ( isa );
194 static inline void legacy_isa_set_drvdata ( void *hwdev
, void *priv
) {
195 isa_set_drvdata ( hwdev
, priv
);
197 static inline void * legacy_isa_get_drvdata ( void *hwdev
) {
198 return isa_get_drvdata ( hwdev
);
202 #define DRIVER(_name_text,_unused2,_unused3,_name,_probe,_disable) \
203 static const char _name ## _text[] = _name_text; \
205 _name ## _probe ( struct nic *nic, void *hwdev ) { \
206 return _probe ( nic, hwdev ); \
209 _name ## _disable ( struct nic *nic, void *hwdev ) { \
210 void ( * _unsafe_disable ) () = _disable; \
211 _unsafe_disable ( nic, hwdev ); \
214 _name ## _pci_legacy_probe ( struct pci_device *pci, \
215 const struct pci_device_id *id __unused ) { \
216 return legacy_probe ( pci, legacy_pci_set_drvdata, \
217 &pci->dev, _name ## _probe, \
218 _name ## _disable ); \
221 _name ## _pci_legacy_remove ( struct pci_device *pci ) { \
222 return legacy_remove ( pci, legacy_pci_get_drvdata, \
223 _name ## _disable ); \
226 _name ## _isapnp_legacy_probe ( struct isapnp_device *isapnp, \
227 const struct isapnp_device_id *id __unused ) { \
228 return legacy_probe ( isapnp, legacy_isapnp_set_drvdata, \
229 &isapnp->dev, _name ## _probe, \
230 _name ## _disable ); \
233 _name ## _isapnp_legacy_remove ( struct isapnp_device *isapnp ) { \
234 return legacy_remove ( isapnp, legacy_isapnp_get_drvdata, \
235 _name ## _disable ); \
238 _name ## _eisa_legacy_probe ( struct eisa_device *eisa, \
239 const struct eisa_device_id *id __unused ) { \
240 return legacy_probe ( eisa, legacy_eisa_set_drvdata, \
241 &eisa->dev, _name ## _probe, \
242 _name ## _disable ); \
245 _name ## _eisa_legacy_remove ( struct eisa_device *eisa ) { \
246 return legacy_remove ( eisa, legacy_eisa_get_drvdata, \
247 _name ## _disable ); \
250 _name ## _mca_legacy_probe ( struct mca_device *mca, \
251 const struct mca_device_id *id __unused ) { \
252 return legacy_probe ( mca, legacy_mca_set_drvdata, \
253 &mca->dev, _name ## _probe, \
254 _name ## _disable ); \
257 _name ## _mca_legacy_remove ( struct mca_device *mca ) { \
258 return legacy_remove ( mca, legacy_mca_get_drvdata, \
259 _name ## _disable ); \
262 _name ## _isa_legacy_probe ( struct isa_device *isa ) { \
263 return legacy_probe ( isa, legacy_isa_set_drvdata, \
264 &isa->dev, _name ## _probe, \
265 _name ## _disable ); \
268 _name ## _isa_legacy_remove ( struct isa_device *isa ) { \
269 return legacy_remove ( isa, legacy_isa_get_drvdata, \
270 _name ## _disable ); \