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.
16 #include <gpxe/isapnp.h>
18 #include <gpxe/eisa.h>
34 * Structure returned from eth_probe and passed to other driver
38 struct nic_operations *nic_op;
39 int flags; /* driver specific flags */
40 unsigned char *node_addr;
41 unsigned char *packet;
42 unsigned int packetlen;
47 void *priv_data; /* driver private data */
50 struct nic_operations {
51 int ( *connect ) ( struct nic * );
52 int ( *poll ) ( struct nic *, int retrieve );
53 void ( *transmit ) ( struct nic *, const char *,
54 unsigned int, unsigned int, const char * );
55 void ( *irq ) ( struct nic *, irq_action_t );
58 extern struct nic nic;
60 static inline int eth_poll ( int retrieve ) {
61 return nic.nic_op->poll ( &nic, retrieve );
64 static inline void eth_transmit ( const char *dest, unsigned int type,
65 unsigned int size, const void *packet ) {
66 nic.nic_op->transmit ( &nic, dest, type, size, packet );
73 extern int dummy_connect ( struct nic *nic );
74 extern void dummy_irq ( struct nic *nic, irq_action_t irq_action );
75 extern int legacy_probe ( void *hwdev,
76 void ( * set_drvdata ) ( void *hwdev, void *priv ),
78 int ( * probe ) ( struct nic *nic, void *hwdev ),
79 void ( * disable ) ( struct nic *nic, void *hwdev ));
80 void legacy_remove ( void *hwdev,
81 void * ( * get_drvdata ) ( void *hwdev ),
82 void ( * disable ) ( struct nic *nic, void *hwdev ) );
84 #define PCI_DRIVER(_name,_ids,_class) \
86 _name ## _pci_legacy_probe ( struct pci_device *pci, \
87 const struct pci_device_id *id ); \
89 _name ## _pci_legacy_remove ( struct pci_device *pci ); \
90 struct pci_driver _name __pci_driver = { \
92 .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
93 .probe = _name ## _pci_legacy_probe, \
94 .remove = _name ## _pci_legacy_remove, \
96 REQUIRE_OBJECT ( pci );
98 static inline void legacy_pci_set_drvdata ( void *hwdev, void *priv ) {
99 pci_set_drvdata ( hwdev, priv );
101 static inline void * legacy_pci_get_drvdata ( void *hwdev ) {
102 return pci_get_drvdata ( hwdev );
105 #define ISAPNP_DRIVER(_name,_ids) \
107 _name ## _isapnp_legacy_probe ( struct isapnp_device *isapnp, \
108 const struct isapnp_device_id *id ); \
110 _name ## _isapnp_legacy_remove ( struct isapnp_device *isapnp ); \
111 struct isapnp_driver _name __isapnp_driver = { \
113 .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
114 .probe = _name ## _isapnp_legacy_probe, \
115 .remove = _name ## _isapnp_legacy_remove, \
117 REQUIRE_OBJECT ( isapnp );
119 static inline void legacy_isapnp_set_drvdata ( void *hwdev, void *priv ) {
120 isapnp_set_drvdata ( hwdev, priv );
122 static inline void * legacy_isapnp_get_drvdata ( void *hwdev ) {
123 return isapnp_get_drvdata ( hwdev );
126 #define EISA_DRIVER(_name,_ids) \
128 _name ## _eisa_legacy_probe ( struct eisa_device *eisa, \
129 const struct eisa_device_id *id ); \
131 _name ## _eisa_legacy_remove ( struct eisa_device *eisa ); \
132 struct eisa_driver _name __eisa_driver = { \
134 .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
135 .probe = _name ## _eisa_legacy_probe, \
136 .remove = _name ## _eisa_legacy_remove, \
138 REQUIRE_OBJECT ( eisa );
140 static inline void legacy_eisa_set_drvdata ( void *hwdev, void *priv ) {
141 eisa_set_drvdata ( hwdev, priv );
143 static inline void * legacy_eisa_get_drvdata ( void *hwdev ) {
144 return eisa_get_drvdata ( hwdev );
147 #define MCA_DRIVER(_name,_ids) \
149 _name ## _mca_legacy_probe ( struct mca_device *mca, \
150 const struct mca_device_id *id ); \
152 _name ## _mca_legacy_remove ( struct mca_device *mca ); \
153 struct mca_driver _name __mca_driver = { \
155 .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
156 .probe = _name ## _mca_legacy_probe, \
157 .remove = _name ## _mca_legacy_remove, \
159 REQUIRE_OBJECT ( mca );
161 static inline void legacy_mca_set_drvdata ( void *hwdev, void *priv ) {
162 mca_set_drvdata ( hwdev, priv );
164 static inline void * legacy_mca_get_drvdata ( void *hwdev ) {
165 return mca_get_drvdata ( hwdev );
168 #define ISA_DRIVER(_name,_probe_addrs,_probe_addr,_vendor_id,_prod_id) \
170 _name ## _isa_legacy_probe ( struct isa_device *isa ); \
172 _name ## _isa_legacy_probe_at_addr ( struct isa_device *isa ) { \
173 if ( ! _probe_addr ( isa->ioaddr ) ) \
175 return _name ## _isa_legacy_probe ( isa ); \
178 _name ## _isa_legacy_remove ( struct isa_device *isa ); \
179 static const char _name ## _text[]; \
180 struct isa_driver _name __isa_driver = { \
181 .name = _name ## _text, \
182 .probe_addrs = _probe_addrs, \
183 .addr_count = ( sizeof ( _probe_addrs ) / \
184 sizeof ( _probe_addrs[0] ) ), \
185 .vendor_id = _vendor_id, \
186 .prod_id = _prod_id, \
187 .probe = _name ## _isa_legacy_probe_at_addr, \
188 .remove = _name ## _isa_legacy_remove, \
190 REQUIRE_OBJECT ( isa );
192 static inline void legacy_isa_set_drvdata ( void *hwdev, void *priv ) {
193 isa_set_drvdata ( hwdev, priv );
195 static inline void * legacy_isa_get_drvdata ( void *hwdev ) {
196 return isa_get_drvdata ( hwdev );
200 #define DRIVER(_name_text,_unused2,_unused3,_name,_probe,_disable) \
201 static const char _name ## _text[] = _name_text; \
203 _name ## _probe ( struct nic *nic, void *hwdev ) { \
204 return _probe ( nic, hwdev ); \
207 _name ## _disable ( struct nic *nic, void *hwdev ) { \
208 void ( * _unsafe_disable ) () = _disable; \
209 _unsafe_disable ( nic, hwdev ); \
212 _name ## _pci_legacy_probe ( struct pci_device *pci, \
213 const struct pci_device_id *id __unused ) { \
214 return legacy_probe ( pci, legacy_pci_set_drvdata, \
215 &pci->dev, _name ## _probe, \
216 _name ## _disable ); \
219 _name ## _pci_legacy_remove ( struct pci_device *pci ) { \
220 return legacy_remove ( pci, legacy_pci_get_drvdata, \
221 _name ## _disable ); \
224 _name ## _isapnp_legacy_probe ( struct isapnp_device *isapnp, \
225 const struct isapnp_device_id *id __unused ) { \
226 return legacy_probe ( isapnp, legacy_isapnp_set_drvdata, \
227 &isapnp->dev, _name ## _probe, \
228 _name ## _disable ); \
231 _name ## _isapnp_legacy_remove ( struct isapnp_device *isapnp ) { \
232 return legacy_remove ( isapnp, legacy_isapnp_get_drvdata, \
233 _name ## _disable ); \
236 _name ## _eisa_legacy_probe ( struct eisa_device *eisa, \
237 const struct eisa_device_id *id __unused ) { \
238 return legacy_probe ( eisa, legacy_eisa_set_drvdata, \
239 &eisa->dev, _name ## _probe, \
240 _name ## _disable ); \
243 _name ## _eisa_legacy_remove ( struct eisa_device *eisa ) { \
244 return legacy_remove ( eisa, legacy_eisa_get_drvdata, \
245 _name ## _disable ); \
248 _name ## _mca_legacy_probe ( struct mca_device *mca, \
249 const struct mca_device_id *id __unused ) { \
250 return legacy_probe ( mca, legacy_mca_set_drvdata, \
251 &mca->dev, _name ## _probe, \
252 _name ## _disable ); \
255 _name ## _mca_legacy_remove ( struct mca_device *mca ) { \
256 return legacy_remove ( mca, legacy_mca_get_drvdata, \
257 _name ## _disable ); \
260 _name ## _isa_legacy_probe ( struct isa_device *isa ) { \
261 return legacy_probe ( isa, legacy_isa_set_drvdata, \
262 &isa->dev, _name ## _probe, \
263 _name ## _disable ); \
266 _name ## _isa_legacy_remove ( struct isa_device *isa ) { \
267 return legacy_remove ( isa, legacy_isa_get_drvdata, \
268 _name ## _disable ); \