Ver código fonte

Updated all common buses to new API.

tags/v0.9.3
Michael Brown 19 anos atrás
pai
commit
924143661a
9 arquivos alterados com 537 adições e 366 exclusões
  1. 94
    61
      src/drivers/bus/eisa.c
  2. 117
    99
      src/drivers/bus/isa.c
  3. 144
    96
      src/drivers/bus/isapnp.c
  4. 87
    54
      src/drivers/bus/mca.c
  5. 10
    10
      src/drivers/bus/pci.c
  6. 21
    12
      src/include/eisa.h
  7. 23
    10
      src/include/isa.h
  8. 27
    12
      src/include/isapnp.h
  9. 14
    12
      src/include/mca.h

+ 94
- 61
src/drivers/bus/eisa.c Ver arquivo

@@ -1,15 +1,29 @@
1 1
 #include "string.h"
2 2
 #include "io.h"
3 3
 #include "timer.h"
4
+#include "console.h"
4 5
 #include "eisa.h"
5 6
 
6 7
 /*
7
- * Ensure that there is sufficient space in the shared dev_bus
8
- * structure for a struct pci_device.
8
+ * Increment a bus_loc structure to the next possible EISA location.
9
+ * Leave the structure zeroed and return 0 if there are no more valid
10
+ * locations.
9 11
  *
10 12
  */
11
-DEV_BUS( struct eisa_device, eisa_dev );
12
-static char eisa_magic[0]; /* guaranteed unique symbol */
13
+static int eisa_next_location ( struct bus_loc *bus_loc ) {
14
+	struct eisa_loc *eisa_loc = ( struct eisa_loc * ) bus_loc;
15
+	
16
+	/*
17
+	 * Ensure that there is sufficient space in the shared bus
18
+	 * structures for a struct isa_loc and a struct
19
+	 * isa_dev, as mandated by bus.h.
20
+	 *
21
+	 */
22
+	BUS_LOC_CHECK ( struct eisa_loc );
23
+	BUS_DEV_CHECK ( struct eisa_device );
24
+
25
+	return ( ++eisa_loc->slot & EISA_MAX_SLOT );
26
+}
13 27
 
14 28
 /*
15 29
  * Fill in parameters for an EISA device based on slot number
@@ -17,9 +31,20 @@ static char eisa_magic[0]; /* guaranteed unique symbol */
17 31
  * Return 1 if device present, 0 otherwise
18 32
  *
19 33
  */
20
-static int fill_eisa_device ( struct eisa_device *eisa ) {
34
+static int eisa_fill_device  ( struct bus_dev *bus_dev,
35
+			       struct bus_loc *bus_loc ) {
36
+	struct eisa_loc *eisa_loc = ( struct eisa_loc * ) bus_loc;
37
+	struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
21 38
 	uint8_t present;
22 39
 
40
+	/* Copy slot number to struct eisa, set default values */
41
+	eisa->slot = eisa_loc->slot;
42
+	eisa->name = "?";
43
+
44
+	/* Slot 0 is never valid */
45
+	if ( ! eisa->slot )
46
+		return 0;
47
+
23 48
 	/* Set ioaddr */
24 49
 	eisa->ioaddr = EISA_SLOT_BASE ( eisa->slot );
25 50
 
@@ -39,7 +64,7 @@ static int fill_eisa_device ( struct eisa_device *eisa ) {
39 64
 	eisa->prod_id = ( inb ( eisa->ioaddr + EISA_PROD_ID_LO ) << 8 )
40 65
 		+ inb ( eisa->ioaddr + EISA_PROD_ID_HI );
41 66
 
42
-	DBG ( "EISA found slot %d (base %#hx) ID %hx:%hx (\"%s\")\n",
67
+	DBG ( "EISA found slot %hhx (base %#hx) ID %hx:%hx (\"%s\")\n",
43 68
 	      eisa->slot, eisa->ioaddr, eisa->mfg_id, eisa->prod_id,
44 69
 	      isa_id_string ( eisa->mfg_id, eisa->prod_id ) );
45 70
 
@@ -47,78 +72,86 @@ static int fill_eisa_device ( struct eisa_device *eisa ) {
47 72
 }
48 73
 
49 74
 /*
50
- * Find an EISA device matching the specified driver
75
+ * Test whether or not a driver is capable of driving the device.
51 76
  *
52 77
  */
53
-int find_eisa_device ( struct eisa_device *eisa, struct eisa_driver *driver ) {
78
+static int eisa_check_driver ( struct bus_dev *bus_dev,
79
+				 struct device_driver *device_driver ) {
80
+	struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
81
+	struct eisa_driver *driver
82
+		= ( struct eisa_driver * ) device_driver->bus_driver_info;
54 83
 	unsigned int i;
55 84
 
56
-	/* Initialise struct eisa if it's the first time it's been used. */
57
-	if ( eisa->magic != eisa_magic ) {
58
-		memset ( eisa, 0, sizeof ( *eisa ) );
59
-		eisa->magic = eisa_magic;
60
-		eisa->slot = EISA_MIN_SLOT;
61
-	}
62
-
63
-	/* Iterate through all possible EISA slots, starting where we
64
-	 * left off.
65
-	 */
66
-	DBG ( "EISA searching for device matching driver %s\n", driver->name );
67
-	for ( ; eisa->slot <= EISA_MAX_SLOT ; eisa->slot++ ) {
68
-		/* If we've already used this device, skip it */
69
-		if ( eisa->already_tried ) {
70
-			eisa->already_tried = 0;
71
-			continue;
72
-		}
73
-
74
-		/* Fill in device parameters */
75
-		if ( ! fill_eisa_device ( eisa ) ) {
76
-			continue;
77
-		}
78
-
79
-		/* Compare against driver's ID list */
80
-		for ( i = 0 ; i < driver->id_count ; i++ ) {
81
-			struct eisa_id *id = &driver->ids[i];
82
-			
83
-			if ( ( eisa->mfg_id == id->mfg_id ) &&
84
-			     ( ISA_PROD_ID ( eisa->prod_id ) ==
85
-			       ISA_PROD_ID ( id->prod_id ) ) ) {
86
-				DBG ( "EISA found ID %hx:%hx (\"%s\") "
87
-				      "(device %s) matching driver %s\n",
88
-				      eisa->mfg_id, eisa->prod_id,
89
-				      isa_id_string ( eisa->mfg_id,
90
-						      eisa->prod_id ),
91
-				      id->name, driver->name );
92
-				eisa->name = id->name;
93
-				eisa->already_tried = 1;
94
-				return 1;
95
-			}
85
+	/* Compare against driver's ID list */
86
+	for ( i = 0 ; i < driver->id_count ; i++ ) {
87
+		struct eisa_id *id = &driver->ids[i];
88
+		
89
+		if ( ( eisa->mfg_id == id->mfg_id ) &&
90
+		     ( ISA_PROD_ID ( eisa->prod_id ) ==
91
+		       ISA_PROD_ID ( id->prod_id ) ) ) {
92
+			DBG ( "EISA found ID %hx:%hx (\"%s\") "
93
+			      "(device %s) matching driver %s\n",
94
+			      eisa->mfg_id, eisa->prod_id,
95
+			      isa_id_string ( eisa->mfg_id,
96
+					      eisa->prod_id ),
97
+			      id->name, driver->name );
98
+			eisa->name = id->name;
99
+			return 1;
96 100
 		}
97 101
 	}
98 102
 
99 103
 	/* No device found */
100
-	DBG ( "EISA found no device matching driver %s\n", driver->name );
101
-	eisa->slot = EISA_MIN_SLOT;
102 104
 	return 0;
103 105
 }
104 106
 
105 107
 /*
106
- * Find the next EISA device that can be used to boot using the
107
- * specified driver.
108
+ * Describe an EISA device
108 109
  *
109 110
  */
110
-int find_eisa_boot_device ( struct dev *dev, struct eisa_driver *driver ) {
111
-	struct eisa_device *eisa = ( struct eisa_device * )dev->bus;
111
+static char * eisa_describe ( struct bus_dev *bus_dev ) {
112
+	struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
113
+	static char eisa_description[] = "EISA 00";
112 114
 
113
-	if ( ! find_eisa_device ( eisa, driver ) )
114
-		return 0;
115
+	sprintf ( eisa_description + 5, "%hhx", eisa->slot );
116
+	return eisa_description;
117
+}
115 118
 
116
-	dev->name = eisa->name;
117
-	dev->devid.bus_type = ISA_BUS_TYPE;
118
-	dev->devid.vendor_id = eisa->mfg_id;
119
-	dev->devid.device_id = eisa->prod_id;
119
+/*
120
+ * Name an EISA device
121
+ *
122
+ */
123
+static const char * eisa_name ( struct bus_dev *bus_dev ) {
124
+	struct eisa_device *eisa = ( struct eisa_device * ) bus_dev;
125
+	
126
+	return eisa->name;
127
+}
120 128
 
121
-	return 1;
129
+/*
130
+ * EISA bus operations table
131
+ *
132
+ */
133
+struct bus_driver eisa_driver __bus_driver = {
134
+	.next_location	= eisa_next_location,
135
+	.fill_device	= eisa_fill_device,
136
+	.check_driver	= eisa_check_driver,
137
+	.describe	= eisa_describe,
138
+	.name		= eisa_name,
139
+};
140
+
141
+/*
142
+ * Fill in a nic structure
143
+ *
144
+ */
145
+void eisa_fill_nic ( struct nic *nic, struct eisa_device *eisa ) {
146
+
147
+	/* Fill in ioaddr and irqno */
148
+	nic->ioaddr = eisa->ioaddr;
149
+	nic->irqno = 0;
150
+
151
+	/* Fill in DHCP device ID structure */
152
+	nic->dhcp_dev_id.bus_type = ISA_BUS_TYPE;
153
+	nic->dhcp_dev_id.vendor_id = htons ( eisa->mfg_id );
154
+	nic->dhcp_dev_id.device_id = htons ( eisa->prod_id );
122 155
 }
123 156
 
124 157
 /*

+ 117
- 99
src/drivers/bus/isa.c Ver arquivo

@@ -1,4 +1,5 @@
1 1
 #include "string.h"
2
+#include "console.h"
2 3
 #include "config/isa.h"
3 4
 #include "isa.h"
4 5
 
@@ -14,139 +15,156 @@
14 15
  * instead.  Some cards (e.g. the 3c509) implement a proprietary
15 16
  * ISAPnP-like mechanism.
16 17
  *
17
- * The ISA probe address list can be overridden by config.c; if the
18
+ * The ISA probe address list can be overridden by config.h; if the
18 19
  * user specifies ISA_PROBE_ADDRS then that list will be used first.
19 20
  * (If ISA_PROBE_ADDRS ends with a zero, the driver's own list will
20 21
  * never be used).
21 22
  */
22 23
 
23
-/*
24
- * Ensure that there is sufficient space in the shared dev_bus
25
- * structure for a struct isa_device.
26
- *
27
- */
28
-DEV_BUS( struct isa_device, isa_dev );
29
-static char isa_magic[0]; /* guaranteed unique symbol */
30
-
31 24
 /*
32 25
  * User-supplied probe address list
33 26
  *
34 27
  */
28
+static isa_probe_addr_t isa_extra_probe_addrs[] = {
35 29
 #ifdef ISA_PROBE_ADDRS
36
-#  ifdef ISA_PROBE_ONLY
37
-#    define			HAVE_ISA_PROBE_ADDRS	1
38
-#    define			ISA_PROBE_ADDR_LIST	ISA_PROBE_ADDRS, 0
39
-#  else
40
-#    define			HAVE_ISA_PROBE_ADDRS	1
41
-#    define			ISA_PROBE_ADDR_LIST	ISA_PROBE_ADDRS
42
-#  endif
43
-#else
44
-#  define			HAVE_ISA_PROBE_ADDRS	0
45
-#  define			ISA_PROBE_ADDR_LIST	
30
+	ISA_PROBE_ADDRS
46 31
 #endif
47
-
48
-static isa_probe_addr_t isa_extra_probe_addrs[] = {
49
-	ISA_PROBE_ADDR_LIST
50 32
 };
51 33
 #define isa_extra_probe_addr_count \
52 34
      ( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )
53 35
 
36
+#ifdef ISA_PROBE_ONLY
37
+#  define		ISA_PROBE_IDX_LIMIT	isa_extra_probe_addr_count
38
+#else
39
+#  define		ISA_PROBE_IDX_LIMIT	( ISA_MAX_PROBE_IDX + 1 )
40
+#endif
41
+
54 42
 /*
55
- * Find an ISA device matching the specified driver
43
+ * Increment a bus_loc structure to the next possible ISA location.
44
+ * Leave the structure zeroed and return 0 if there are no more valid
45
+ * locations.
56 46
  *
57 47
  */
58
-int find_isa_device ( struct isa_device *isa, struct isa_driver *driver ) {
59
-	unsigned int i;
60
-	uint16_t ioaddr;
61
-
62
-	/* Initialise struct isa if it's the first time it's been used. */
63
-	if ( isa->magic != isa_magic ) {
64
-		memset ( isa, 0, sizeof ( *isa ) );
65
-		isa->magic = isa_magic;
48
+static int isa_next_location ( struct bus_loc *bus_loc ) {
49
+	struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
50
+	
51
+	/*
52
+	 * Ensure that there is sufficient space in the shared bus
53
+	 * structures for a struct isa_loc and a struct
54
+	 * isa_dev, as mandated by bus.h.
55
+	 *
56
+	 */
57
+	BUS_LOC_CHECK ( struct isa_loc );
58
+	BUS_DEV_CHECK ( struct isa_device );
59
+
60
+	return ( ( ++isa_loc->probe_idx < ISA_PROBE_IDX_LIMIT ) ?
61
+		 1 : ( isa_loc->probe_idx = 0 ) );
62
+}
63
+
64
+/*
65
+ * Fill in parameters (vendor & device ids, class, membase etc.) for
66
+ * an ISA device based on bus_loc.
67
+ *
68
+ * Returns 1 if a device was found, 0 for no device present.
69
+ *
70
+ */
71
+static int isa_fill_device ( struct bus_dev *bus_dev,
72
+			     struct bus_loc *bus_loc ) {
73
+	struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
74
+	struct isa_device *isa = ( struct isa_device * ) bus_dev;
75
+	signed int driver_probe_idx;
76
+
77
+	driver_probe_idx = isa_loc->probe_idx - isa_extra_probe_addr_count;
78
+	if ( driver_probe_idx < 0 ) {
79
+		isa->ioaddr = isa_extra_probe_addrs[isa_loc->probe_idx];
80
+	} else {
81
+		isa->ioaddr = 0;
82
+		isa->driver_probe_idx = driver_probe_idx;
66 83
 	}
84
+	isa->mfg_id = isa->prod_id = 0;
85
+	isa->name = "?";
86
+	return 1;
87
+}
67 88
 
68
-	/* Iterate through any ISA probe addresses specified by the
69
-	 * user, starting where we left off.
89
+/*
90
+ * Test whether or not a driver is capable of driving the specified
91
+ * device.
92
+ *
93
+ */
94
+int isa_check_driver ( struct bus_dev *bus_dev,
95
+		       struct device_driver *device_driver ) {
96
+	struct isa_device *isa = ( struct isa_device * ) bus_dev;
97
+	struct isa_driver *driver
98
+		= ( struct isa_driver * ) device_driver->bus_driver_info;
99
+
100
+	/* If ioaddr is zero, it means we're using a driver-specified
101
+	 * ioaddr
70 102
 	 */
71
-	DBG ( "ISA searching for device matching driver %s\n", driver->name );
72
-	for ( i = isa->probe_idx ; i < isa_extra_probe_addr_count ; i++ ) {
73
-		/* If we've already used this device, skip it */
74
-		if ( isa->already_tried ) {
75
-			isa->already_tried = 0;
76
-			continue;
77
-		}
78
-		
79
-		/* Set I/O address */
80
-		ioaddr = isa_extra_probe_addrs[i];
81
-
82
-		/* An I/O address of 0 in extra_probe_addrs list means
83
-		 * stop probing (i.e. don't continue to the
84
-		 * driver-provided list)
85
-		 */
86
-		if ( ! ioaddr )
87
-			goto notfound;
88
-
89
-		/* Use probe_addr method to see if there's a device
90
-		 * present at this address.
91
-		 */
92
-		if ( driver->probe_addr ( ioaddr ) ) {
93
-			isa->probe_idx = i;
94
-			goto found;
95
-		}
96
-	}
103
+	if ( ! isa->ioaddr )
104
+		isa->ioaddr = driver->probe_addrs[isa->driver_probe_idx];
97 105
 
98
-	/* Iterate through all ISA probe addresses provided by the
99
-	 * driver, starting where we left off.
106
+	/* Use probe_addr method to see if there's a device
107
+	 * present at this address.
100 108
 	 */
101
-	for ( i = isa->probe_idx - isa_extra_probe_addr_count ;
102
-	      i < driver->addr_count ; i++ ) {
103
-
104
-		/* If we've already used this device, skip it */
105
-		if ( isa->already_tried ) {
106
-			isa->already_tried = 0;
107
-			continue;
108
-		}
109
-
110
-		/* Set I/O address */
111
-		ioaddr = driver->probe_addrs[i];
112
-
113
-		/* Use probe_addr method to see if there's a device
114
-		 * present at this address.
115
-		 */
116
-		if ( driver->probe_addr ( ioaddr ) ) {
117
-			isa->probe_idx = i + isa_extra_probe_addr_count;
118
-			goto found;
119
-		}
109
+	if ( driver->probe_addr ( isa->ioaddr ) ) {
110
+		DBG ( "ISA found %s device at address %hx\n",
111
+		      driver->name, isa->ioaddr );
112
+		isa->name = driver->name;
113
+		isa->mfg_id = driver->mfg_id;
114
+		isa->prod_id = driver->prod_id;
115
+		return 1;
120 116
 	}
121 117
 
122
- notfound:
123 118
 	/* No device found */
124
-	DBG ( "ISA found no device matching driver %s\n", driver->name );
125
-	isa->probe_idx = 0;
126 119
 	return 0;
120
+}
127 121
 
128
- found:
129
-	DBG ( "ISA found %s device at address %hx\n", driver->name, ioaddr );
130
-	isa->ioaddr = ioaddr;
131
-	isa->already_tried = 1;
132
-	return 1;
122
+/*
123
+ * Describe a ISA device
124
+ *
125
+ */
126
+static char * isa_describe ( struct bus_dev *bus_dev ) {
127
+	struct isa_device *isa = ( struct isa_device * ) bus_dev;
128
+	static char isa_description[] = "ISA 0000";
129
+
130
+	sprintf ( isa_description + 4, "%hx", isa->ioaddr );
131
+	return isa_description;
133 132
 }
134 133
 
135 134
 /*
136
- * Find the next ISA device that can be used to boot using the
137
- * specified driver.
135
+ * Name a ISA device
138 136
  *
139 137
  */
140
-int find_isa_boot_device ( struct dev *dev, struct isa_driver *driver ) {
141
-	struct isa_device *isa = ( struct isa_device * )dev->bus;
138
+static const char * isa_name ( struct bus_dev *bus_dev ) {
139
+	struct isa_device *isa = ( struct isa_device * ) bus_dev;
140
+	
141
+	return isa->name;
142
+}
143
+
144
+/*
145
+ * ISA bus operations table
146
+ *
147
+ */
148
+struct bus_driver isa_driver __bus_driver = {
149
+	.next_location	= isa_next_location,
150
+	.fill_device	= isa_fill_device,
151
+	.check_driver	= isa_check_driver,
152
+	.describe	= isa_describe,
153
+	.name		= isa_name,
154
+};
142 155
 
143
-	if ( ! find_isa_device ( isa, driver ) )
144
-		return 0;
156
+/*
157
+ * Fill in a nic structure
158
+ *
159
+ */
160
+void isa_fill_nic ( struct nic *nic, struct isa_device *isa ) {
145 161
 
146
-	dev->name = driver->name;
147
-	dev->devid.bus_type = ISA_BUS_TYPE;
148
-	dev->devid.vendor_id = driver->mfg_id;
149
-	dev->devid.device_id = driver->prod_id;
162
+	/* Fill in ioaddr and irqno */
163
+	nic->ioaddr = isa->ioaddr;
164
+	nic->irqno = 0;
150 165
 
151
-	return 1;
166
+	/* Fill in DHCP device ID structure */
167
+	nic->dhcp_dev_id.bus_type = ISA_BUS_TYPE;
168
+	nic->dhcp_dev_id.vendor_id = htons ( isa->mfg_id );
169
+	nic->dhcp_dev_id.device_id = htons ( isa->prod_id );
152 170
 }

+ 144
- 96
src/drivers/bus/isapnp.c Ver arquivo

@@ -36,16 +36,9 @@
36 36
 #include "string.h"
37 37
 #include "timer.h"
38 38
 #include "io.h"
39
+#include "console.h"
39 40
 #include "isapnp.h"
40 41
 
41
-/*
42
- * Ensure that there is sufficient space in the shared dev_bus
43
- * structure for a struct isapnp_device.
44
- *
45
- */
46
-DEV_BUS( struct isapnp_device, isapnp_dev );
47
-static char isapnp_magic[0]; /* guaranteed unique symbol */
48
-
49 42
 /*
50 43
  * We can have only one ISAPnP bus in a system.  Once the read port is
51 44
  * known and all cards have been allocated CSNs, there's nothing to be
@@ -56,9 +49,14 @@ static char isapnp_magic[0]; /* guaranteed unique symbol */
56 49
  * ISA bus.  We therefore probe only when we are first asked to find
57 50
  * an ISAPnP device.
58 51
  *
52
+ * External code (e.g. the ISAPnP ROM prefix) may already know the
53
+ * read port address, in which case it can initialise this value.
54
+ * Note that setting the read port address will prevent further
55
+ * isolation from taking place; you should set the read port address
56
+ * only if you know that devices have already been allocated CSNs.
57
+ *
59 58
  */
60
-static uint16_t isapnp_read_port;
61
-static uint16_t isapnp_max_csn;
59
+uint16_t isapnp_read_port;
62 60
 
63 61
 /*
64 62
  * ISAPnP utility functions
@@ -297,7 +295,8 @@ static int isapnp_find_tag ( uint8_t wanted_tag, uint8_t *buf ) {
297 295
  */
298 296
 static int isapnp_try_isolate ( void ) {
299 297
 	struct isapnp_identifier identifier;
300
-	int i, j, seen55aa;
298
+	unsigned int i, j, seen55aa;
299
+	unsigned int csn = 0;
301 300
 	uint16_t data;
302 301
 	uint8_t byte;
303 302
 
@@ -312,7 +311,6 @@ static int isapnp_try_isolate ( void ) {
312 311
 
313 312
 	/* Reset all assigned CSNs */
314 313
 	isapnp_reset_csn ();
315
-	isapnp_max_csn = 0;
316 314
 	isapnp_delay();
317 315
 	isapnp_delay();
318 316
 	
@@ -358,7 +356,7 @@ static int isapnp_try_isolate ( void ) {
358 356
 		/* If we didn't see any 55aa patterns, stop here */
359 357
 		if ( ! seen55aa ) {
360 358
 			DBG ( "ISAPnP saw %s signs of life\n",
361
-			      isapnp_max_csn ? "no futher" : "no" );
359
+			      csn ? "no futher" : "no" );
362 360
 			break;
363 361
 		}
364 362
 
@@ -374,12 +372,12 @@ static int isapnp_try_isolate ( void ) {
374 372
 		}
375 373
 
376 374
 		/* Give the device a CSN */
377
-		isapnp_max_csn++;
375
+		csn++;
378 376
 		DBG ( "ISAPnP found card " ISAPNP_CARD_ID_FMT
379 377
 		      ", assigning CSN %hhx\n",
380
-		      ISAPNP_CARD_ID_DATA ( &identifier ), isapnp_max_csn );
378
+		      ISAPNP_CARD_ID_DATA ( &identifier ), csn );
381 379
 		
382
-		isapnp_write_csn ( isapnp_max_csn );
380
+		isapnp_write_csn ( csn );
383 381
 		isapnp_delay();
384 382
 
385 383
 		/* Send this card back to Sleep and force all cards
@@ -394,8 +392,8 @@ static int isapnp_try_isolate ( void ) {
394 392
 
395 393
 	/* Return number of cards found */
396 394
 	DBG ( "ISAPnP found %d cards at read port %hx\n",
397
-	      isapnp_max_csn, isapnp_read_port );
398
-	return isapnp_max_csn;
395
+	      csn, isapnp_read_port );
396
+	return csn;
399 397
 }
400 398
 
401 399
 /*
@@ -419,17 +417,65 @@ static void isapnp_isolate ( void ) {
419 417
 	}
420 418
 }
421 419
 
420
+/*
421
+ * Increment a bus_loc structure to the next possible ISAPnP location.
422
+ * Leave the structure zeroed and return 0 if there are no more valid
423
+ * locations.
424
+ *
425
+ */
426
+static int isapnp_next_location ( struct bus_loc *bus_loc ) {
427
+	struct isapnp_loc *isapnp_loc = ( struct isapnp_loc * ) bus_loc;
428
+	
429
+	/*
430
+	 * Ensure that there is sufficient space in the shared bus
431
+	 * structures for a struct isapnp_loc and a struct isapnp_dev,
432
+	 * as mandated by bus.h.
433
+	 *
434
+	 */
435
+	BUS_LOC_CHECK ( struct isapnp_loc );
436
+	BUS_DEV_CHECK ( struct isapnp_device );
437
+
438
+	return ( ++isapnp_loc->logdev ? 1 : ++isapnp_loc->csn );
439
+}
440
+
422 441
 /*
423 442
  * Fill in parameters for an ISAPnP device based on CSN
424 443
  *
425 444
  * Return 1 if device present, 0 otherwise
426 445
  *
427 446
  */
428
-static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
447
+static int isapnp_fill_device ( struct bus_dev *bus_dev,
448
+				struct bus_loc *bus_loc ) {
449
+	struct isapnp_device *isapnp = ( struct isapnp_device * ) bus_dev;
450
+	struct isapnp_loc *isapnp_loc = ( struct isapnp_loc * ) bus_loc;
429 451
 	unsigned int i;
430 452
 	struct isapnp_identifier identifier;
431 453
 	struct isapnp_logdevid logdevid;
432
-	
454
+	static struct {
455
+		uint8_t csn;
456
+		uint8_t first_nonexistent_logdev;
457
+	} cache = { 0, 0 };
458
+
459
+	/* Copy CSN and logdev to isapnp_device, set default values */
460
+	isapnp->csn = isapnp_loc->csn;
461
+	isapnp->logdev = isapnp_loc->logdev;
462
+	isapnp->name = "?";
463
+
464
+	/* CSN 0 is never valid, but may be passed in */
465
+	if ( ! isapnp->csn )
466
+		return 0;
467
+
468
+	/* Check cache to see if we are already past the highest
469
+	 * logical device of this CSN
470
+	 */
471
+	if ( ( isapnp->csn == cache.csn ) &&
472
+	     ( isapnp->logdev >= cache.first_nonexistent_logdev ) )
473
+		return 0;
474
+
475
+	/* Perform isolation if it hasn't yet been done */
476
+	if ( ! isapnp_read_port )
477
+		isapnp_isolate();
478
+
433 479
 	/* Wake the card */
434 480
 	isapnp_wait_for_key ();
435 481
 	isapnp_send_key ();
@@ -438,6 +484,14 @@ static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
438 484
 	/* Read the card identifier */
439 485
 	isapnp_peek ( ( char * ) &identifier, sizeof ( identifier ) );
440 486
 
487
+	/* Need to return 0 if no device exists at this CSN */
488
+	if ( identifier.vendor_id & 0x80 ) {
489
+		DBG ( "ISAPnP found no card %hhx\n", isapnp->csn );
490
+		cache.csn = isapnp->csn;
491
+		cache.first_nonexistent_logdev = 0;
492
+		return 0;
493
+	}
494
+
441 495
 	/* Find the Logical Device ID tag corresponding to this device */
442 496
 	for ( i = 0 ; i <= isapnp->logdev ; i++ ) {
443 497
 		if ( ! isapnp_find_tag ( ISAPNP_TAG_LOGDEVID,
@@ -447,6 +501,8 @@ static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
447 501
 			      "card " ISAPNP_CARD_ID_FMT "\n",
448 502
 			      isapnp->csn, isapnp->logdev,
449 503
 			      ISAPNP_CARD_ID_DATA ( &identifier ) );
504
+			cache.csn = isapnp->csn;
505
+			cache.first_nonexistent_logdev = isapnp->logdev;
450 506
 			return 0;
451 507
 		}
452 508
 	}
@@ -475,99 +531,74 @@ static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
475 531
 }
476 532
 
477 533
 /*
478
- * Find an ISAPnP device matching the specified driver
534
+ * Test whether or not a driver is capable of driving the device.
479 535
  *
480 536
  */
481
-int find_isapnp_device ( struct isapnp_device *isapnp,
482
-			 struct isapnp_driver *driver ) {
537
+static int isapnp_check_driver ( struct bus_dev *bus_dev,
538
+				 struct device_driver *device_driver ) {
539
+	struct isapnp_device *isapnp = ( struct isapnp_device * ) bus_dev;
540
+	struct isapnp_driver *driver
541
+		= ( struct isapnp_driver * ) device_driver->bus_driver_info;
483 542
 	unsigned int i;
484 543
 
485
-	/* Initialise struct isapnp if it's the first time it's been used. */
486
-	if ( isapnp->magic != isapnp_magic ) {
487
-		memset ( isapnp, 0, sizeof ( *isapnp ) );
488
-		isapnp->magic = isapnp_magic;
489
-		isapnp->csn = 1;
490
-	}
491
-
492
-	/* Ensure that all ISAPnP cards have CSNs allocated to them,
493
-	 * if we haven't already done so.
494
-	 */
495
-	if ( ! isapnp_read_port ) {
496
-		isapnp_isolate();
497
-	}
498
-
499
-	/* Iterate through all possible ISAPNP CSNs, starting where we
500
-	 * left off.
501
-	 */
502
-	DBG ( "ISAPnP searching for device matching driver %s\n",
503
-	      driver->name );
504
-	for ( ; isapnp->csn <= isapnp_max_csn ; isapnp->csn++ ) {
505
-		for ( ; isapnp->logdev <= 0xff ; isapnp->logdev++ ) {
506
-			/* If we've already used this device, skip it */
507
-			if ( isapnp->already_tried ) {
508
-				isapnp->already_tried = 0;
509
-				continue;
510
-			}
511
-			
512
-			/* Fill in device parameters */
513
-			if ( ! fill_isapnp_device ( isapnp ) ) {
514
-				/* If fill_isapnp_device fails, assume
515
-				 * that we've reached the last logical
516
-				 * device on this card, and proceed to
517
-				 * the next card.
518
-				 */
519
-				isapnp->logdev = 0;
520
-				break;
521
-			}
522
-
523
-			/* Compare against driver's ID list */
524
-			for ( i = 0 ; i < driver->id_count ; i++ ) {
525
-				struct isapnp_id *id = &driver->ids[i];
526
-				
527
-				if ( ( isapnp->vendor_id == id->vendor_id ) &&
528
-				     ( ISA_PROD_ID ( isapnp->prod_id ) ==
529
-				       ISA_PROD_ID ( id->prod_id ) ) ) {
530
-					DBG ( "ISAPnP found ID %hx:%hx "
531
-					      "(\"%s\") (device %s) "
532
-					      "matching driver %s\n",
533
-					      isapnp->vendor_id,
534
-					      isapnp->prod_id,
535
-					      isa_id_string( isapnp->vendor_id,
536
-							     isapnp->prod_id ),
537
-					      id->name, driver->name );
538
-					isapnp->name = id->name;
539
-					isapnp->already_tried = 1;
540
-					return 1;
541
-				}
542
-			}
544
+	/* Compare against driver's ID list */
545
+	for ( i = 0 ; i < driver->id_count ; i++ ) {
546
+		struct isapnp_id *id = &driver->ids[i];
547
+		
548
+		if ( ( isapnp->vendor_id == id->vendor_id ) &&
549
+		     ( ISA_PROD_ID ( isapnp->prod_id ) ==
550
+		       ISA_PROD_ID ( id->prod_id ) ) ) {
551
+			DBG ( "ISAPnP found ID %hx:%hx "
552
+			      "(\"%s\") (device %s) "
553
+			      "matching driver %s\n",
554
+			      isapnp->vendor_id,
555
+			      isapnp->prod_id,
556
+			      isa_id_string( isapnp->vendor_id,
557
+					     isapnp->prod_id ),
558
+			      id->name, driver->name );
559
+			isapnp->name = id->name;
560
+			return 1;
543 561
 		}
544 562
 	}
545 563
 
546
-	/* No device found */
547
-	DBG ( "ISAPnP found no device matching driver %s\n", driver->name );
548
-	isapnp->csn = 1;
549 564
 	return 0;
550 565
 }
551 566
 
552 567
 /*
553
- * Find the next ISAPNP device that can be used to boot using the
554
- * specified driver.
568
+ * Describe an ISAPnP device
555 569
  *
556 570
  */
557
-int find_isapnp_boot_device ( struct dev *dev, struct isapnp_driver *driver ) {
558
-	struct isapnp_device *isapnp = ( struct isapnp_device * ) dev->bus;
559
-
560
-	if ( ! find_isapnp_device ( isapnp, driver ) )
561
-		return 0;
571
+static char * isapnp_describe ( struct bus_dev *bus_dev ) {
572
+	struct isapnp_device *isapnp = ( struct isapnp_device * ) bus_dev;
573
+	static char isapnp_description[] = "ISAPnP 00:00";
562 574
 
563
-	dev->name = isapnp->name;
564
-	dev->devid.bus_type = ISA_BUS_TYPE;
565
-	dev->devid.vendor_id = isapnp->vendor_id;
566
-	dev->devid.device_id = isapnp->prod_id;
575
+	sprintf ( isapnp_description + 7, "%hhx:%hhx",
576
+		  isapnp->csn, isapnp->logdev );
577
+	return isapnp_description;
578
+}
567 579
 
568
-	return 1;
580
+/*
581
+ * Name an ISAPnP device
582
+ *
583
+ */
584
+static const char * isapnp_name ( struct bus_dev *bus_dev ) {
585
+	struct isapnp_device *isapnp = ( struct isapnp_device * ) bus_dev;
586
+	
587
+	return isapnp->name;
569 588
 }
570 589
 
590
+/*
591
+ * ISAPnP bus operations table
592
+ *
593
+ */
594
+struct bus_driver isapnp_driver __bus_driver = {
595
+	.next_location	= isapnp_next_location,
596
+	.fill_device	= isapnp_fill_device,
597
+	.check_driver	= isapnp_check_driver,
598
+	.describe	= isapnp_describe,
599
+	.name		= isapnp_name,
600
+};
601
+
571 602
 /*
572 603
  * Activate or deactivate an ISAPnP device
573 604
  *
@@ -594,3 +625,20 @@ void activate_isapnp_device ( struct isapnp_device *isapnp,
594 625
 	DBG ( "ISAPnP activated device %hhx.%hhx\n",
595 626
 	      isapnp->csn, isapnp->logdev );
596 627
 }
628
+
629
+/*
630
+ * Fill in a nic structure
631
+ *
632
+ */
633
+void isapnp_fill_nic ( struct nic *nic, struct isapnp_device *isapnp ) {
634
+
635
+	/* Fill in ioaddr and irqno */
636
+	nic->ioaddr = isapnp->ioaddr;
637
+	nic->irqno = isapnp->irqno;
638
+
639
+	/* Fill in DHCP device ID structure */
640
+	nic->dhcp_dev_id.bus_type = ISA_BUS_TYPE;
641
+	nic->dhcp_dev_id.vendor_id = htons ( isapnp->vendor_id );
642
+	nic->dhcp_dev_id.device_id = htons ( isapnp->prod_id );
643
+}
644
+

+ 87
- 54
src/drivers/bus/mca.c Ver arquivo

@@ -7,23 +7,45 @@
7 7
 
8 8
 #include "string.h"
9 9
 #include "io.h"
10
+#include "console.h"
11
+#include "nic.h"
10 12
 #include "mca.h"
11 13
 
12 14
 /*
13
- * Ensure that there is sufficient space in the shared dev_bus
14
- * structure for a struct pci_device.
15
+ * Increment a bus_loc structure to the next possible MCA location.
16
+ * Leave the structure zeroed and return 0 if there are no more valid
17
+ * locations.
15 18
  *
16 19
  */
17
-DEV_BUS( struct mca_device, mca_dev );
18
-static char mca_magic[0]; /* guaranteed unique symbol */
20
+static int mca_next_location ( struct bus_loc *bus_loc ) {
21
+	struct mca_loc *mca_loc = ( struct mca_loc * ) bus_loc;
22
+	
23
+	/*
24
+	 * Ensure that there is sufficient space in the shared bus
25
+	 * structures for a struct mca_loc and a struct
26
+	 * mca_dev, as mandated by bus.h.
27
+	 *
28
+	 */
29
+	BUS_LOC_CHECK ( struct mca_loc );
30
+	BUS_DEV_CHECK ( struct mca_device );
31
+
32
+	return ( ++mca_loc->slot & MCA_MAX_SLOT_NR );
33
+}
19 34
 
20 35
 /*
21 36
  * Fill in parameters for an MCA device based on slot number
22 37
  *
23 38
  */
24
-static int fill_mca_device ( struct mca_device *mca ) {
39
+static int mca_fill_device ( struct bus_dev *bus_dev,
40
+			     struct bus_loc *bus_loc ) {
41
+	struct mca_loc *mca_loc = ( struct mca_loc * ) bus_loc;
42
+	struct mca_device *mca = ( struct mca_device * ) bus_dev;
25 43
 	unsigned int i, seen_non_ff;
26 44
 
45
+	/* Store slot in struct mca, set default values */
46
+	mca->slot = mca_loc->slot;
47
+	mca->name = "?";
48
+
27 49
 	/* Make sure motherboard setup is off */
28 50
 	outb_p ( 0xff, MCA_MOTHERBOARD_SETUP_REG );
29 51
 
@@ -58,70 +80,81 @@ static int fill_mca_device ( struct mca_device *mca ) {
58 80
 }
59 81
 
60 82
 /*
61
- * Find an MCA device matching the specified driver
83
+ * Test whether or not a driver is capable of driving the device.
62 84
  *
63 85
  */
64
-int find_mca_device ( struct mca_device *mca, struct mca_driver *driver ) {
86
+static int mca_check_driver ( struct bus_dev *bus_dev,
87
+			      struct device_driver *device_driver ) {
88
+	struct mca_device *mca = ( struct mca_device * ) bus_dev;
89
+	struct mca_driver *driver
90
+		= ( struct mca_driver * ) device_driver->bus_driver_info;
65 91
 	unsigned int i;
66 92
 
67
-	/* Initialise struct mca if it's the first time it's been used. */
68
-	if ( mca->magic != mca_magic ) {
69
-		memset ( mca, 0, sizeof ( *mca ) );
70
-		mca->magic = mca_magic;
71
-	}
72
-
73
-	/* Iterate through all possible MCA slots, starting where we
74
-	 * left off
75
-	 */
76
-	DBG ( "MCA searching for device matching driver %s\n", driver->name );
77
-	for ( ; mca->slot < MCA_MAX_SLOT_NR ; mca->slot++ ) {
78
-		/* If we've already used this device, skip it */
79
-		if ( mca->already_tried ) {
80
-			mca->already_tried = 0;
81
-			continue;
82
-		}
83
-
84
-		/* Fill in device parameters */
85
-		if ( ! fill_mca_device ( mca ) ) {
86
-			continue;
87
-		}
88
-
89
-		/* Compare against driver's ID list */
90
-		for ( i = 0 ; i < driver->id_count ; i++ ) {
91
-			struct mca_id *id = &driver->ids[i];
92
-
93
-			if ( MCA_ID ( mca ) == id->id ) {
94
-				DBG ( "MCA found ID %hx (device %s) "
95
-				      "matching driver %s\n",
96
-				      id->name, id->id, driver->name );
97
-				mca->name = id->name;
98
-				mca->already_tried = 1;
99
-				return 1;
100
-			}
93
+	/* Compare against driver's ID list */
94
+	for ( i = 0 ; i < driver->id_count ; i++ ) {
95
+		struct mca_id *id = &driver->ids[i];
96
+		
97
+		if ( MCA_ID ( mca ) == id->id ) {
98
+			DBG ( "MCA found ID %hx (device %s) "
99
+			      "matching driver %s\n",
100
+			      id->name, id->id, driver->name );
101
+			mca->name = id->name;
102
+			return 1;
101 103
 		}
102 104
 	}
103 105
 
104 106
 	/* No device found */
105
-	DBG ( "MCA found no device matching driver %s\n", driver->name );
106
-	mca->slot = 0;
107 107
 	return 0;
108 108
 }
109 109
 
110 110
 /*
111
- * Find the next MCA device that can be used to boot using the
112
- * specified driver.
111
+ * Describe an MCA device
113 112
  *
114 113
  */
115
-int find_mca_boot_device ( struct dev *dev, struct mca_driver *driver ) {
116
-	struct mca_device *mca = ( struct mca_device * )dev->bus;
114
+static char * mca_describe ( struct bus_dev *bus_dev ) {
115
+	struct mca_device *mca = ( struct mca_device * ) bus_dev;
116
+	static char mca_description[] = "MCA 00";
117 117
 
118
-	if ( ! find_mca_device ( mca, driver ) )
119
-		return 0;
118
+	sprintf ( mca_description + 4, "%hhx", mca->slot );
119
+	return mca_description;
120
+}
121
+
122
+/*
123
+ * Name an MCA device
124
+ *
125
+ */
126
+static const char * mca_name ( struct bus_dev *bus_dev ) {
127
+	struct mca_device *mca = ( struct mca_device * ) bus_dev;
128
+	
129
+	return mca->name;
130
+}
120 131
 
121
-	dev->name = mca->name;
122
-	dev->devid.bus_type = MCA_BUS_TYPE;
123
-	dev->devid.vendor_id = GENERIC_MCA_VENDOR;
124
-	dev->devid.device_id = MCA_ID ( mca );
132
+/*
133
+ * MCA bus operations table
134
+ *
135
+ */
136
+struct bus_driver mca_driver __bus_driver = {
137
+	.next_location	= mca_next_location,
138
+	.fill_device	= mca_fill_device,
139
+	.check_driver	= mca_check_driver,
140
+	.describe	= mca_describe,
141
+	.name		= mca_name,
142
+};
125 143
 
126
-	return 1;
144
+/*
145
+ * Fill in a nic structure
146
+ *
147
+ */
148
+void mca_fill_nic ( struct nic *nic, struct mca_device *mca ) {
149
+
150
+	/* ioaddr and irqno must be read in a device-dependent way
151
+	 * from the POS registers
152
+	 */
153
+	nic->ioaddr = 0;
154
+	nic->irqno = 0;
155
+
156
+	/* Fill in DHCP device ID structure */
157
+	nic->dhcp_dev_id.bus_type = MCA_BUS_TYPE;
158
+	nic->dhcp_dev_id.vendor_id = htons ( GENERIC_MCA_VENDOR );
159
+	nic->dhcp_dev_id.device_id = htons ( MCA_ID ( mca ) );
127 160
 }

+ 10
- 10
src/drivers/bus/pci.c Ver arquivo

@@ -45,7 +45,7 @@ static int pci_fill_device ( struct bus_dev *bus_dev,
45 45
 	struct pci_device *pci = ( struct pci_device * ) bus_dev;
46 46
 	uint16_t busdevfn = pci_loc->busdevfn;
47 47
 	static struct {
48
-		uint16_t devfn0;
48
+		uint16_t busdevfn0;
49 49
 		int is_present;
50 50
 	} cache = { 0, 1 };
51 51
 	uint32_t l;
@@ -65,7 +65,7 @@ static int pci_fill_device ( struct bus_dev *bus_dev,
65 65
 	 * increase scan speed by a factor of 8.
66 66
 	 */
67 67
 	if ( ( PCI_FUNC ( busdevfn ) != 0 ) &&
68
-	     ( PCI_FN0 ( busdevfn ) == cache.devfn0 ) &&
68
+	     ( PCI_FN0 ( busdevfn ) == cache.busdevfn0 ) &&
69 69
 	     ( ! cache.is_present ) ) {
70 70
 		return 0;
71 71
 	}
@@ -79,7 +79,7 @@ static int pci_fill_device ( struct bus_dev *bus_dev,
79 79
 			/* Don't look for subsequent functions if the
80 80
 			 * card itself is not present.
81 81
 			 */
82
-			cache.devfn0 = busdevfn;
82
+			cache.busdevfn0 = busdevfn;
83 83
 			cache.is_present = 0;
84 84
 		}
85 85
 		return 0;
@@ -130,7 +130,7 @@ static int pci_fill_device ( struct bus_dev *bus_dev,
130 130
 		pci_read_config_byte ( pci, PCI_INTERRUPT_LINE, &pci->irq );
131 131
 	}
132 132
 
133
-	DBG ( "found device %hhx:%hhx.%d Class %hx: %hx:%hx (rev %hhx)\n",
133
+	DBG ( "PCI found device %hhx:%hhx.%d Class %hx: %hx:%hx (rev %hhx)\n",
134 134
 	      PCI_BUS ( pci->busdevfn ), PCI_DEV ( pci->busdevfn ),
135 135
 	      PCI_FUNC ( pci->busdevfn ), pci->class, pci->vendor_id,
136 136
 	      pci->device_id, pci->revision );
@@ -152,7 +152,7 @@ static int pci_check_driver ( struct bus_dev *bus_dev,
152 152
 	/* If driver has a class, and class matches, use it */
153 153
 	if ( pci_driver->class && 
154 154
 	     ( pci_driver->class == pci->class ) ) {
155
-		DBG ( "driver %s matches class %hx\n",
155
+		DBG ( "PCI driver %s matches class %hx\n",
156 156
 		      device_driver->name, pci_driver->class );
157 157
 		pci->name = device_driver->name;
158 158
 		return 1;
@@ -164,7 +164,7 @@ static int pci_check_driver ( struct bus_dev *bus_dev,
164 164
 		
165 165
 		if ( ( pci->vendor_id == id->vendor_id ) &&
166 166
 		     ( pci->device_id == id->device_id ) ) {
167
-			DBG ( "driver %s device %s matches ID %hx:%hx\n",
167
+			DBG ( "PCI driver %s device %s matches ID %hx:%hx\n",
168 168
 			      device_driver->name, id->name,
169 169
 			      id->vendor_id, id->device_id );
170 170
 			pci->name = id->name;
@@ -222,7 +222,7 @@ void adjust_pci_device ( struct pci_device *pci ) {
222 222
 	pci_read_config_word ( pci, PCI_COMMAND, &pci_command );
223 223
 	new_command = pci_command | PCI_COMMAND_MASTER | PCI_COMMAND_IO;
224 224
 	if ( pci_command != new_command ) {
225
-		DBG ( "BIOS has not enabled device %hhx:%hhx.%d! "
225
+		DBG ( "PCI BIOS has not enabled device %hhx:%hhx.%d! "
226 226
 		      "Updating PCI command %hX->%hX\n",
227 227
 		      PCI_BUS ( pci->busdevfn ), PCI_DEV ( pci->busdevfn ),
228 228
 		      PCI_FUNC ( pci->busdevfn ), pci_command, new_command );
@@ -230,7 +230,7 @@ void adjust_pci_device ( struct pci_device *pci ) {
230 230
 	}
231 231
 	pci_read_config_byte ( pci, PCI_LATENCY_TIMER, &pci_latency);
232 232
 	if ( pci_latency < 32 ) {
233
-		DBG ( "device %hhx:%hhx.%d latency timer is "
233
+		DBG ( "PCI device %hhx:%hhx.%d latency timer is "
234 234
 		      "unreasonably low at %d. Setting to 32.\n",
235 235
 		      PCI_BUS ( pci->busdevfn ), PCI_DEV ( pci->busdevfn ),
236 236
 		      PCI_FUNC ( pci->busdevfn ), pci_latency );
@@ -338,7 +338,7 @@ int pci_find_capability ( struct pci_device *pci, int cap ) {
338 338
 	while ( ttl-- && pos >= 0x40 ) {
339 339
 		pos &= ~3;
340 340
 		pci_read_config_byte ( pci, pos + PCI_CAP_LIST_ID, &id );
341
-		DBG ( "Capability: %d\n", id );
341
+		DBG ( "PCI Capability: %d\n", id );
342 342
 		if ( id == 0xff )
343 343
 			break;
344 344
 		if ( id == cap )
@@ -349,7 +349,7 @@ int pci_find_capability ( struct pci_device *pci, int cap ) {
349 349
 }
350 350
 
351 351
 /*
352
- * Fill in a DHCP device ID structure
352
+ * Fill in a nic structure
353 353
  *
354 354
  */
355 355
 void pci_fill_nic ( struct nic *nic, struct pci_device *pci ) {

+ 21
- 12
src/include/eisa.h Ver arquivo

@@ -1,8 +1,9 @@
1 1
 #ifndef EISA_H
2 2
 #define EISA_H
3 3
 
4
+#include "stdint.h"
4 5
 #include "isa_ids.h"
5
-#include "dev.h"
6
+#include "nic.h"
6 7
 
7 8
 /*
8 9
  * EISA constants
@@ -10,7 +11,7 @@
10 11
  */
11 12
 
12 13
 #define EISA_MIN_SLOT (0x1)
13
-#define EISA_MAX_SLOT (0xf)
14
+#define EISA_MAX_SLOT (0xf)	/* Must be 2^n - 1 */
14 15
 #define EISA_SLOT_BASE( n ) ( 0x1000 * (n) )
15 16
 
16 17
 #define EISA_MFG_ID_HI ( 0xc80 )
@@ -22,18 +23,24 @@
22 23
 #define EISA_CMD_RESET ( 1 << 2 )
23 24
 #define EISA_CMD_ENABLE ( 1 << 0 )
24 25
 
26
+/*
27
+ * A location on an EISA bus
28
+ *
29
+ */
30
+struct eisa_loc {
31
+	unsigned int slot;
32
+};
33
+
25 34
 /*
26 35
  * A physical EISA device
27 36
  *
28 37
  */
29 38
 struct eisa_device {
30
-	char *magic; /* must be first */
31 39
 	const char *name;
32 40
 	unsigned int slot;
33 41
 	uint16_t ioaddr;
34 42
 	uint16_t mfg_id;
35 43
 	uint16_t prod_id;
36
-	int already_tried;
37 44
 };
38 45
 
39 46
 /*
@@ -59,20 +66,22 @@ struct eisa_driver {
59 66
  * Define an EISA driver
60 67
  *
61 68
  */
62
-#define EISA_DRIVER( driver_name, eisa_ids ) {				\
63
-	.name = driver_name,						\
64
-	.ids = eisa_ids,						\
65
-	.id_count = sizeof ( eisa_ids ) / sizeof ( eisa_ids[0] ),	\
69
+#define EISA_DRIVER( _ids ) {					\
70
+	.ids = _ids,						\
71
+	.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
66 72
 }
67 73
 
68 74
 /*
69 75
  * Functions in eisa.c
70 76
  *
71 77
  */
72
-extern int find_eisa_device ( struct eisa_device *eisa,
73
-			      struct eisa_driver *driver );
74
-extern int find_eisa_boot_device ( struct dev *dev,
75
-				   struct eisa_driver *driver );
76 78
 extern void enable_eisa_device ( struct eisa_device *eisa );
79
+extern void fill_eisa_nic ( struct nic *nic, struct eisa_device *eisa );
80
+
81
+/*
82
+ * EISA bus global definition
83
+ *
84
+ */
85
+extern struct bus_driver eisa_driver;
77 86
 
78 87
 #endif /* EISA_H */

+ 23
- 10
src/include/isa.h Ver arquivo

@@ -1,18 +1,29 @@
1 1
 #ifndef	ISA_H
2 2
 #define ISA_H
3 3
 
4
+#include "stdint.h"
4 5
 #include "isa_ids.h"
5
-#include "dev.h"
6
+#include "nic.h"
7
+
8
+/*
9
+ * A location on an ISA bus
10
+ *
11
+ */
12
+struct isa_loc {
13
+	unsigned int probe_idx;
14
+};
15
+#define ISA_MAX_PROBE_IDX	255 /* Unlikely to ever be more than ~20 */
6 16
 
7 17
 /*
8 18
  * A physical ISA device
9 19
  *
10 20
  */
11 21
 struct isa_device {
12
-	char *magic; /* must be first */
13
-	unsigned int probe_idx;
22
+	const char *name;
23
+	unsigned int driver_probe_idx;
14 24
 	uint16_t ioaddr;
15
-	int already_tried;
25
+	uint16_t mfg_id;
26
+	uint16_t prod_id;
16 27
 };
17 28
 
18 29
 /*
@@ -41,8 +52,7 @@ struct isa_driver {
41 52
  * Define an ISA driver
42 53
  *
43 54
  */
44
-#define ISA_DRIVER( _name, _probe_addrs, _probe_addr, _mfg_id, _prod_id ) { \
45
-	.name = _name,							    \
55
+#define ISA_DRIVER( _probe_addrs, _probe_addr, _mfg_id, _prod_id ) {	    \
46 56
 	.probe_addrs = _probe_addrs,					    \
47 57
 	.addr_count = sizeof ( _probe_addrs ) / sizeof ( _probe_addrs[0] ), \
48 58
 	.probe_addr = _probe_addr,					    \
@@ -61,10 +71,13 @@ struct isa_driver {
61 71
  * Functions in isa.c
62 72
  *
63 73
  */
64
-extern int find_isa_device ( struct isa_device *eisa,
65
-			     struct isa_driver *driver );
66
-extern int find_isa_boot_device ( struct dev *dev,
67
-				  struct isa_driver *driver );
74
+extern void fill_isa_nic ( struct nic *nic, struct isa_device *isa );
75
+
76
+/*
77
+ * ISA bus global definition
78
+ *
79
+ */
80
+extern struct bus_driver isa_driver;
68 81
 
69 82
 #endif /* ISA_H */
70 83
 

+ 27
- 12
src/include/isapnp.h Ver arquivo

@@ -36,8 +36,9 @@
36 36
 #ifndef ISAPNP_H
37 37
 #define ISAPNP_H
38 38
 
39
+#include "stdint.h"
40
+#include "nic.h"
39 41
 #include "isa_ids.h"
40
-#include "dev.h"
41 42
 
42 43
 /*
43 44
  * ISAPnP constants
@@ -154,12 +155,20 @@ struct isapnp_logdevid {
154 155
 	uint16_t flags;
155 156
 } __attribute__ (( packed ));
156 157
 
158
+/*
159
+ * A location on an ISAPnP bus
160
+ *
161
+ */
162
+struct isapnp_loc {
163
+	uint8_t csn;
164
+	uint8_t logdev;
165
+};
166
+
157 167
 /*
158 168
  * A physical ISAPnP device
159 169
  *
160 170
  */
161 171
 struct isapnp_device {
162
-	char *magic; /* must be first */
163 172
 	const char *name;
164 173
 	uint8_t csn;
165 174
 	uint8_t logdev;
@@ -167,7 +176,6 @@ struct isapnp_device {
167 176
 	uint16_t prod_id;
168 177
 	uint16_t ioaddr;
169 178
 	uint8_t irqno;
170
-	int already_tried;
171 179
 };
172 180
 
173 181
 /*
@@ -184,7 +192,6 @@ struct isapnp_id {
184 192
  *
185 193
  */
186 194
 struct isapnp_driver {
187
-	const char *name;
188 195
 	struct isapnp_id *ids;
189 196
 	unsigned int id_count;
190 197
 };
@@ -193,21 +200,29 @@ struct isapnp_driver {
193 200
  * Define an ISAPnP driver
194 201
  *
195 202
  */
196
-#define ISAPNP_DRIVER( driver_name, isapnp_ids ) {			\
197
-	.name = driver_name,						\
198
-	.ids = isapnp_ids,						\
199
-	.id_count = sizeof ( isapnp_ids ) / sizeof ( isapnp_ids[0] ),	\
203
+#define ISAPNP_DRIVER( _ids ) {					\
204
+	.ids = _ids,						\
205
+	.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
200 206
 }
201 207
 
202 208
 /*
203 209
  * Functions in isapnp.c
204 210
  *
205 211
  */
206
-extern int find_isapnp_device ( struct isapnp_device *isapnp,
207
-				struct isapnp_driver *driver );
208
-extern int find_isapnp_boot_device ( struct dev *dev,
209
-				     struct isapnp_driver *driver );
210 212
 extern void activate_isapnp_device ( struct isapnp_device *isapnp,
211 213
 				     int active );
214
+extern void isapnp_fill_nic ( struct nic *nic, struct isapnp_device *isapnp );
215
+
216
+/*
217
+ * ISAPnP bus global definition
218
+ *
219
+ */
220
+extern struct bus_driver isapnp_driver;
221
+
222
+/*
223
+ * ISAPnP read port.  ROM prefix may be able to set this address.
224
+ *
225
+ */
226
+extern uint16_t isapnp_read_port;
212 227
 
213 228
 #endif /* ISAPNP_H */

+ 14
- 12
src/include/mca.h Ver arquivo

@@ -20,22 +20,28 @@
20 20
 
21 21
 #define MCA_MOTHERBOARD_SETUP_REG	0x94
22 22
 #define MCA_ADAPTER_SETUP_REG		0x96
23
-#define MCA_MAX_SLOT_NR			8
23
+#define MCA_MAX_SLOT_NR			0x07	/* Must be 2^n - 1 */
24 24
 #define MCA_POS_REG(n)			(0x100+(n))
25 25
 
26 26
 /* Is there a standard that would define this? */
27 27
 #define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' )
28 28
 
29
+/*
30
+ * A location on an MCA bus
31
+ *
32
+ */
33
+struct mca_loc {
34
+	unsigned int slot;
35
+};
36
+
29 37
 /*
30 38
  * A physical MCA device
31 39
  *
32 40
  */
33 41
 struct mca_device {
34
-	char *magic; /* must be first */
35 42
 	const char *name;
36 43
 	unsigned int slot;
37 44
 	unsigned char pos[8];
38
-	int already_tried;
39 45
 };
40 46
 #define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] )
41 47
 
@@ -53,7 +59,6 @@ struct mca_id {
53 59
  *
54 60
  */
55 61
 struct mca_driver {
56
-	const char *name;
57 62
 	struct mca_id *ids;
58 63
 	unsigned int id_count;
59 64
 };
@@ -62,18 +67,15 @@ struct mca_driver {
62 67
  * Define an MCA driver
63 68
  *
64 69
  */
65
-#define MCA_DRIVER( driver_name, mca_ids ) {			\
66
-	.name = driver_name,					\
67
-	.ids = mca_ids,						\
68
-	.id_count = sizeof ( mca_ids ) / sizeof ( mca_ids[0] ),	\
70
+#define MCA_DRIVER( _ids ) {					\
71
+	.ids = _ids,						\
72
+	.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
69 73
 }
70 74
 
71 75
 /*
72
- * Functions in mca.c
76
+ * MCA bus global definition
73 77
  *
74 78
  */
75
-extern int find_mca_device ( struct mca_device *mca,
76
-			     struct mca_driver *driver );
77
-extern int find_mca_boot_device ( struct dev *dev, struct mca_driver *driver );
79
+extern struct bus_driver mca_driver;
78 80
 
79 81
 #endif

Carregando…
Cancelar
Salvar