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.
14 static int pci_probe(struct dev
*dev
, const char *type_name
)
17 * NIC probing is in pci device order, followed by the
18 * link order of the drivers. A driver that matches
19 * on vendor and device id will supersede a driver
20 * that matches on pci class.
22 * If you want to probe for another device behind the same pci
23 * device just increment index. And the previous probe call
26 struct pci_probe_state
*state
= &dev
->state
.pci
;
27 printf("Probing pci %s...\n", type_name
);
28 if (dev
->how_probe
== PROBE_FIRST
) {
30 state
->dev
.driver
= 0;
36 if ((dev
->how_probe
!= PROBE_AWAKE
) && state
->advance
) {
37 find_pci(dev
->type
, &state
->dev
);
42 if (state
->dev
.driver
== 0)
46 /* FIXME the romaddr code needs a total rethought to be useful */
47 if (state
->dev
.romaddr
!= ((unsigned long) rom
.rom_segment
<< 4)) {
51 if (dev
->how_probe
!= PROBE_AWAKE
) {
54 dev
->devid
.bus_type
= PCI_BUS_TYPE
;
55 dev
->devid
.vendor_id
= htons(state
->dev
.vendor
);
56 dev
->devid
.device_id
= htons(state
->dev
.dev_id
);
57 /* FIXME how do I handle dev->index + PROBE_AGAIN?? */
59 printf("[%s]", state
->dev
.name
);
60 if (state
->dev
.driver
->probe(dev
, &state
->dev
)) {
61 state
->advance
= (dev
->index
== -1);
71 static int isa_probe(struct dev
*dev
, const char *type_name
)
74 * NIC probing is in the order the drivers were linked togeter.
75 * If for some reason you want to change the order,
76 * just change the order you list the drivers in.
78 struct isa_probe_state
*state
= &dev
->state
.isa
;
79 printf("Probing isa %s...\n", type_name
);
80 if (dev
->how_probe
== PROBE_FIRST
) {
82 state
->driver
= isa_drivers
;
87 if ((dev
->how_probe
!= PROBE_AWAKE
) && state
->advance
) {
93 if (state
->driver
>= isa_drivers_end
)
96 if (state
->driver
->type
!= dev
->type
)
99 if (dev
->how_probe
!= PROBE_AWAKE
) {
102 printf("[%s]", state
->driver
->name
);
103 dev
->devid
.bus_type
= ISA_BUS_TYPE
;
104 /* FIXME how do I handle dev->index + PROBE_AGAIN?? */
105 /* driver will fill in vendor and device IDs */
106 if (state
->driver
->probe(dev
, state
->driver
->ioaddrs
)) {
107 state
->advance
= (dev
->index
== -1);
115 #define isa_probe(d,tn) (PROBE_FAILED)
117 static const char *driver_name
[] = {
122 int probe(struct dev
*dev
)
124 const char *type_name
;
126 EnterFunction("probe");
129 if ((dev
->type
>= 0) &&
130 (dev
->type
< sizeof(driver_name
)/sizeof(driver_name
[0]))) {
131 type_name
= driver_name
[dev
->type
];
133 if (dev
->how_probe
== PROBE_FIRST
) {
134 dev
->to_probe
= PROBE_PCI
;
135 memset(&dev
->state
, 0, sizeof(dev
->state
));
137 if (dev
->to_probe
== PROBE_PCI
) {
138 dev
->how_probe
= pci_probe(dev
, type_name
);
139 if (dev
->how_probe
== PROBE_FAILED
) {
140 dev
->to_probe
= PROBE_ISA
;
143 if (dev
->to_probe
== PROBE_ISA
) {
144 dev
->how_probe
= isa_probe(dev
, type_name
);
145 if (dev
->how_probe
== PROBE_FAILED
) {
146 dev
->to_probe
= PROBE_NONE
;
149 if ((dev
->to_probe
!= PROBE_PCI
) &&
150 (dev
->to_probe
!= PROBE_ISA
)) {
151 dev
->how_probe
= PROBE_FAILED
;
155 LeaveFunction("probe");
156 return dev
->how_probe
;
159 void disable(struct dev
*dev
)