Browse Source

ISA bus driver updated to report devices as present only if a driver

thinks they are.
Other bus drivers modified for consistency.
tags/v0.9.3
Michael Brown 19 years ago
parent
commit
3dbdeb588f

+ 1
- 2
src/arch/i386/drivers/disk/floppy.c View File

21
 	
21
 	
22
 }
22
 }
23
 
23
 
24
-static struct bios_disk_driver floppy_driver =
25
-	BIOS_DISK_DRIVER ( fill_floppy_name, 0x00, 0x7f );
24
+BIOS_DISK_DRIVER ( floppy_driver, fill_floppy_name, 0x00, 0x7f );
26
 
25
 
27
 DRIVER ( "floppy", disk_driver, bios_disk_driver, floppy_driver,
26
 DRIVER ( "floppy", disk_driver, bios_disk_driver, floppy_driver,
28
 	 floppy_probe, floppy_disable );
27
 	 floppy_probe, floppy_disable );

+ 6
- 5
src/arch/i386/include/bios_disks.h View File

47
  * Define a BIOS disk driver
47
  * Define a BIOS disk driver
48
  *
48
  *
49
  */
49
  */
50
-#define BIOS_DISK_DRIVER( _fill_drive_name, _min_drive, _max_drive ) {	      \
51
-	.fill_drive_name = _fill_drive_name,				      \
52
-	.min_drive = _min_drive,					      \
53
-	.max_drive = _max_drive,					      \
54
-}
50
+#define BIOS_DISK_DRIVER( _name, _fill_drive_name, _min_drive, _max_drive )   \
51
+	static struct bios_disk_driver _name = {			      \
52
+		.fill_drive_name = _fill_drive_name,			      \
53
+		.min_drive = _min_drive,				      \
54
+		.max_drive = _max_drive,				      \
55
+	}
55
 
56
 
56
 /*
57
 /*
57
  * Functions in bios_disks.c
58
  * Functions in bios_disks.c

+ 3
- 0
src/arch/i386/scripts/i386.lds View File

145
 	device_drivers = .;
145
 	device_drivers = .;
146
 	*(.drivers.device)
146
 	*(.drivers.device)
147
 	device_drivers_end = .;
147
 	device_drivers_end = .;
148
+	isa_drivers = . ;
149
+	*(.drivers.isa)
150
+	isa_drivers_end = .;
148
 	bus_drivers = .;
151
 	bus_drivers = .;
149
 	*(.drivers.bus)
152
 	*(.drivers.bus)
150
 	bus_drivers_end = .;
153
 	bus_drivers_end = .;

+ 52
- 38
src/drivers/bus/isa.c View File

17
  *
17
  *
18
  * The ISA probe address list can be overridden by config.h; if the
18
  * The ISA probe address list can be overridden by config.h; if the
19
  * user specifies ISA_PROBE_ADDRS then that list will be used first.
19
  * user specifies ISA_PROBE_ADDRS then that list will be used first.
20
- * (If ISA_PROBE_ADDRS ends with a zero, the driver's own list will
21
- * never be used).
20
+ * (If ISA_PROBE_ONLY is defined, the driver's own list will never be
21
+ * used).
22
  */
22
  */
23
 
23
 
24
 /*
24
 /*
34
      ( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )
34
      ( sizeof ( isa_extra_probe_addrs ) / sizeof ( isa_extra_probe_addrs[0] ) )
35
 
35
 
36
 #ifdef ISA_PROBE_ONLY
36
 #ifdef ISA_PROBE_ONLY
37
-#  define		ISA_PROBE_IDX_LIMIT	isa_extra_probe_addr_count
37
+#define ISA_PROBE_ADDR_COUNT(driver) ( isa_extra_probe_addr_count )
38
 #else
38
 #else
39
-#  define		ISA_PROBE_IDX_LIMIT	( ISA_MAX_PROBE_IDX + 1 )
39
+#define ISA_PROBE_ADDR_COUNT(driver) \
40
+	( isa_extra_probe_addr_count + (driver)->addr_count )
40
 #endif
41
 #endif
41
 
42
 
43
+/*
44
+ * Symbols defined by linker
45
+ *
46
+ */
47
+extern struct isa_driver isa_drivers[];
48
+extern struct isa_driver isa_drivers_end[];
49
+
42
 /*
50
 /*
43
  * Increment a bus_loc structure to the next possible ISA location.
51
  * 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
52
  * Leave the structure zeroed and return 0 if there are no more valid
45
  * locations.
53
  * locations.
46
  *
54
  *
55
+ * There is no sensible concept of a device location on an ISA bus, so
56
+ * we use the probe address list for each ISA driver to define the
57
+ * list of ISA locations.
58
+ *
47
  */
59
  */
48
 static int isa_next_location ( struct bus_loc *bus_loc ) {
60
 static int isa_next_location ( struct bus_loc *bus_loc ) {
49
 	struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
61
 	struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
50
-	
62
+	struct isa_driver *driver;
63
+
51
 	/*
64
 	/*
52
 	 * Ensure that there is sufficient space in the shared bus
65
 	 * Ensure that there is sufficient space in the shared bus
53
 	 * structures for a struct isa_loc and a struct
66
 	 * structures for a struct isa_loc and a struct
57
 	BUS_LOC_CHECK ( struct isa_loc );
70
 	BUS_LOC_CHECK ( struct isa_loc );
58
 	BUS_DEV_CHECK ( struct isa_device );
71
 	BUS_DEV_CHECK ( struct isa_device );
59
 
72
 
60
-	return ( ( ++isa_loc->probe_idx < ISA_PROBE_IDX_LIMIT ) ?
61
-		 1 : ( isa_loc->probe_idx = 0 ) );
73
+	/* Move to next probe address within this driver */
74
+	driver = &isa_drivers[isa_loc->driver];
75
+	if ( ++isa_loc->probe_idx < ISA_PROBE_ADDR_COUNT ( driver ) )
76
+		return 1;
77
+
78
+	/* Move to next driver */
79
+	isa_loc->probe_idx = 0;
80
+	if ( ( ++isa_loc->driver, ++driver ) < isa_drivers_end )
81
+		return 1;
82
+
83
+	isa_loc->driver = 0;
84
+	return 0;
62
 }
85
 }
63
 
86
 
64
 /*
87
 /*
73
 	struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
96
 	struct isa_loc *isa_loc = ( struct isa_loc * ) bus_loc;
74
 	struct isa_device *isa = ( struct isa_device * ) bus_dev;
97
 	struct isa_device *isa = ( struct isa_device * ) bus_dev;
75
 	signed int driver_probe_idx;
98
 	signed int driver_probe_idx;
76
-
99
+	
100
+	/* Fill in struct isa from struct isa_loc */
101
+	isa->driver = &isa_drivers[isa_loc->driver];
77
 	driver_probe_idx = isa_loc->probe_idx - isa_extra_probe_addr_count;
102
 	driver_probe_idx = isa_loc->probe_idx - isa_extra_probe_addr_count;
78
 	if ( driver_probe_idx < 0 ) {
103
 	if ( driver_probe_idx < 0 ) {
79
 		isa->ioaddr = isa_extra_probe_addrs[isa_loc->probe_idx];
104
 		isa->ioaddr = isa_extra_probe_addrs[isa_loc->probe_idx];
80
 	} else {
105
 	} else {
81
-		isa->ioaddr = 0;
82
-		isa->driver_probe_idx = driver_probe_idx;
106
+		isa->ioaddr = isa->driver->probe_addrs[driver_probe_idx];
107
+	}
108
+
109
+	/* Call driver's probe_addr method to determine if a device is
110
+	 * physically present
111
+	 */
112
+	if ( isa->driver->probe_addr ( isa->ioaddr ) ) {
113
+		isa->name = isa->driver->name;
114
+		isa->mfg_id = isa->driver->mfg_id;
115
+		isa->prod_id = isa->driver->prod_id;
116
+		DBG ( "ISA found %s device at address %hx\n",
117
+		      isa->name, isa->ioaddr );
118
+		return 1;
83
 	}
119
 	}
84
-	isa->mfg_id = isa->prod_id = 0;
85
-	isa->name = "?";
86
-	return 1;
120
+
121
+	return 0;
87
 }
122
 }
88
 
123
 
89
 /*
124
 /*
97
 	struct isa_driver *driver
132
 	struct isa_driver *driver
98
 		= ( struct isa_driver * ) device_driver->bus_driver_info;
133
 		= ( struct isa_driver * ) device_driver->bus_driver_info;
99
 
134
 
100
-	/* If ioaddr is zero, it means we're using a driver-specified
101
-	 * ioaddr
102
-	 */
103
-	if ( ! isa->ioaddr ) {
104
-		if ( isa->driver_probe_idx >= driver->addr_count )
105
-			return 0;
106
-		isa->ioaddr = driver->probe_addrs[isa->driver_probe_idx];
107
-	}
108
-
109
-	/* Use probe_addr method to see if there's a device
110
-	 * present at this address.
111
-	 */
112
-	if ( driver->probe_addr ( isa->ioaddr ) ) {
113
-		DBG ( "ISA found %s device at address %hx\n",
114
-		      driver->name, isa->ioaddr );
115
-		isa->name = driver->name;
116
-		isa->mfg_id = driver->mfg_id;
117
-		isa->prod_id = driver->prod_id;
118
-		return 1;
119
-	}
120
-
121
-	/* No device found */
122
-	return 0;
135
+	return ( driver == isa->driver );
123
 }
136
 }
124
 
137
 
125
 /*
138
 /*
128
  */
141
  */
129
 static char * isa_describe_device ( struct bus_dev *bus_dev ) {
142
 static char * isa_describe_device ( struct bus_dev *bus_dev ) {
130
 	struct isa_device *isa = ( struct isa_device * ) bus_dev;
143
 	struct isa_device *isa = ( struct isa_device * ) bus_dev;
131
-	static char isa_description[] = "ISA 0000";
144
+	static char isa_description[] = "ISA 0000 (00)";
132
 
145
 
133
-	sprintf ( isa_description + 4, "%hx", isa->ioaddr );
146
+	sprintf ( isa_description + 4, "%hx (%hhx)", isa->ioaddr,
147
+		  isa->driver - isa_drivers );
134
 	return isa_description;
148
 	return isa_description;
135
 }
149
 }
136
 
150
 

+ 1
- 1
src/include/dev.h View File

28
  * A physical device location on a bus.
28
  * A physical device location on a bus.
29
  *
29
  *
30
  */
30
  */
31
-#define BUS_LOC_SIZE 4
31
+#define BUS_LOC_SIZE 8
32
 struct bus_loc {
32
 struct bus_loc {
33
 	char bytes[BUS_LOC_SIZE];
33
 	char bytes[BUS_LOC_SIZE];
34
 };
34
 };

+ 5
- 4
src/include/eisa.h View File

66
  * Define an EISA driver
66
  * Define an EISA driver
67
  *
67
  *
68
  */
68
  */
69
-#define EISA_DRIVER( _ids ) {					\
70
-	.ids = _ids,						\
71
-	.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
72
-}
69
+#define EISA_DRIVER( _name, _ids ) 					\
70
+	static struct eisa_driver _name = {				\
71
+		.ids = _ids,						\
72
+		.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
73
+	}
73
 
74
 
74
 /*
75
 /*
75
  * Functions in eisa.c
76
  * Functions in eisa.c

+ 6
- 3
src/include/isa.h View File

9
  * A location on an ISA bus
9
  * A location on an ISA bus
10
  *
10
  *
11
  */
11
  */
12
+struct isa_driver;
12
 struct isa_loc {
13
 struct isa_loc {
14
+	unsigned int driver;
13
 	unsigned int probe_idx;
15
 	unsigned int probe_idx;
14
 };
16
 };
15
-#define ISA_MAX_PROBE_IDX	255 /* Unlikely to ever be more than ~20 */
16
 
17
 
17
 /*
18
 /*
18
  * A physical ISA device
19
  * A physical ISA device
20
  */
21
  */
21
 struct isa_device {
22
 struct isa_device {
22
 	const char *name;
23
 	const char *name;
23
-	unsigned int driver_probe_idx;
24
+	struct isa_driver *driver;
24
 	uint16_t ioaddr;
25
 	uint16_t ioaddr;
25
 	uint16_t mfg_id;
26
 	uint16_t mfg_id;
26
 	uint16_t prod_id;
27
 	uint16_t prod_id;
47
 	uint16_t mfg_id;
48
 	uint16_t mfg_id;
48
 	uint16_t prod_id;
49
 	uint16_t prod_id;
49
 };
50
 };
51
+#define __isa_driver __attribute__ (( section ( ".drivers.isa" ) ))
50
 
52
 
51
 /*
53
 /*
52
  * Define an ISA driver
54
  * Define an ISA driver
53
  *
55
  *
54
  */
56
  */
55
-#define ISA_DRIVER( _probe_addrs, _probe_addr, _mfg_id, _prod_id ) {	    \
57
+#define ISA_DRIVER( _name, _probe_addrs, _probe_addr, _mfg_id, _prod_id )   \
58
+static struct isa_driver _name __isa_driver = {				    \
56
 	.probe_addrs = _probe_addrs,					    \
59
 	.probe_addrs = _probe_addrs,					    \
57
 	.addr_count = sizeof ( _probe_addrs ) / sizeof ( _probe_addrs[0] ), \
60
 	.addr_count = sizeof ( _probe_addrs ) / sizeof ( _probe_addrs[0] ), \
58
 	.probe_addr = _probe_addr,					    \
61
 	.probe_addr = _probe_addr,					    \

+ 5
- 4
src/include/isapnp.h View File

200
  * Define an ISAPnP driver
200
  * Define an ISAPnP driver
201
  *
201
  *
202
  */
202
  */
203
-#define ISAPNP_DRIVER( _ids ) {					\
204
-	.ids = _ids,						\
205
-	.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
206
-}
203
+#define ISAPNP_DRIVER( _name, _ids ) 					\
204
+	static struct isapnp_driver _name = {				\
205
+		.ids = _ids,						\
206
+		.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
207
+	}
207
 
208
 
208
 /*
209
 /*
209
  * Functions in isapnp.c
210
  * Functions in isapnp.c

+ 5
- 4
src/include/mca.h View File

67
  * Define an MCA driver
67
  * Define an MCA driver
68
  *
68
  *
69
  */
69
  */
70
-#define MCA_DRIVER( _ids ) {					\
71
-	.ids = _ids,						\
72
-	.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
73
-}
70
+#define MCA_DRIVER( _name, _ids )					\
71
+	static struct mca_driver _name = {				\
72
+		.ids = _ids,						\
73
+		.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
74
+	}
74
 
75
 
75
 /*
76
 /*
76
  * Functions in mca.c
77
  * Functions in mca.c

+ 2
- 1
src/include/pci.h View File

307
  * Define a PCI driver.
307
  * Define a PCI driver.
308
  *
308
  *
309
  */
309
  */
310
-#define PCI_DRIVER( _ids, _class ) {					\
310
+#define PCI_DRIVER( _name, _ids, _class ) 				\
311
+	static struct pci_driver _name = {				\
311
 		.ids = _ids,						\
312
 		.ids = _ids,						\
312
 		.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
313
 		.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ),	\
313
 		.class = _class,					\
314
 		.class = _class,					\

Loading…
Cancel
Save