Browse Source

dev.c uses the new tables infrastructure.

tags/v0.9.3
Michael Brown 19 years ago
parent
commit
f37e0a06d7
3 changed files with 13 additions and 30 deletions
  1. 0
    9
      src/arch/i386/scripts/i386.lds
  2. 9
    10
      src/core/dev.c
  3. 4
    11
      src/include/dev.h

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

145
 	*(SORT(.tbl.*))	
145
 	*(SORT(.tbl.*))	
146
 
146
 
147
 
147
 
148
-	device_drivers = .;
149
-	*(.drivers.device)
150
-	device_drivers_end = .;
151
 	isa_drivers = . ;
148
 	isa_drivers = . ;
152
 	*(.drivers.isa)
149
 	*(.drivers.isa)
153
 	isa_drivers_end = .;
150
 	isa_drivers_end = .;
154
-	bus_drivers = .;
155
-	*(.drivers.bus)
156
-	bus_drivers_end = .;
157
-	type_drivers = .;
158
-	*(.drivers.type)
159
-	type_drivers_end = .;
160
 
151
 
161
 	_progbits_end = .;
152
 	_progbits_end = .;
162
     }
153
     }

+ 9
- 10
src/core/dev.c View File

3
 #include "dev.h"
3
 #include "dev.h"
4
 
4
 
5
 /*
5
 /*
6
- * Each driver specifies a name, the bus-scanning function
7
- * (find_bus_boot_device) that it wants to use, a driver information
8
- * structure (bus_driver) containing e.g. device IDs to be passed to
9
- * find_bus_boot_device, and a probe function (probe) to be called
10
- * whenever a suitable device is found.
6
+ * Each bus driver defines several methods, which are described in
7
+ * dev.h.  This file provides a centralised, bus-independent mechanism
8
+ * for locating devices and drivers.
11
  *
9
  *
12
- * The generic device-probing code knows nothing about particular bus
13
- * types; it simply passes the driver information structure
14
- * (bus_driver) to the bus-scanning function (find_bus_boot_device),
15
- * then passes the result of that function (if not NULL) to the probe
16
- * function (probe).
17
  */
10
  */
18
 
11
 
12
+/* Linker symbols for the various tables */
13
+static struct bus_driver bus_drivers[0] __table_start ( bus_driver );
14
+static struct bus_driver bus_drivers_end[0] __table_end ( bus_driver );
15
+static struct device_driver device_drivers[0] __table_start ( device_driver );
16
+static struct device_driver device_drivers_end[0] __table_end (device_driver );
17
+
19
 /* Current attempted boot device */
18
 /* Current attempted boot device */
20
 struct dev dev = {
19
 struct dev dev = {
21
 	.bus_driver = bus_drivers,
20
 	.bus_driver = bus_drivers,

+ 4
- 11
src/include/dev.h View File

4
 #include "stdint.h"
4
 #include "stdint.h"
5
 #include "string.h"
5
 #include "string.h"
6
 #include "dhcp.h" /* for dhcp_dev_id */
6
 #include "dhcp.h" /* for dhcp_dev_id */
7
+#include "tables.h"
7
 
8
 
8
 /*
9
 /*
9
  * Forward declarations
10
  * Forward declarations
158
 	const char * ( *name_device ) ( struct bus_dev *bus_dev );
159
 	const char * ( *name_device ) ( struct bus_dev *bus_dev );
159
 };
160
 };
160
 
161
 
161
-#define __bus_driver __attribute__ (( used, __section__ ( ".drivers.bus" ) ))
162
+#define __bus_driver __attribute__ (( used, __table_section(bus_driver,01) ))
162
 
163
 
163
 /*
164
 /*
164
  * A structure fully describing the bus-independent parts of a
165
  * A structure fully describing the bus-independent parts of a
187
 					     unsigned int len, int eof ) );
188
 					     unsigned int len, int eof ) );
188
 };
189
 };
189
 
190
 
190
-#define __type_driver __attribute__ (( used, __section__ ( ".drivers.type" ) ))
191
+#define __type_driver __attribute__ (( used, __table_section(type_driver,01) ))
191
 
192
 
192
 /*
193
 /*
193
  * A driver for a device.
194
  * A driver for a device.
205
 };
206
 };
206
 
207
 
207
 #define __device_driver \
208
 #define __device_driver \
208
-	__attribute__ (( used, __section__ ( ".drivers.device" ) ))
209
+	__attribute__ (( used, __table_section(device_driver,01) ))
209
 
210
 
210
 #define DRIVER(_name,_type_driver,_bus_driver,_bus_info,	 	      \
211
 #define DRIVER(_name,_type_driver,_bus_driver,_bus_info,	 	      \
211
 	       _probe,_disable) 		 			      \
212
 	       _probe,_disable) 		 			      \
283
 	return dev->type_driver->load ( dev->type_dev, process );
284
 	return dev->type_driver->load ( dev->type_dev, process );
284
 }
285
 }
285
 
286
 
286
-/* Linker symbols for the various tables */
287
-extern struct bus_driver bus_drivers[];
288
-extern struct bus_driver bus_drivers_end[];
289
-extern struct type_driver type_drivers[];
290
-extern struct type_driver type_drivers_end[];
291
-extern struct device_driver device_drivers[];
292
-extern struct device_driver device_drivers_end[];
293
-
294
 #endif /* DEV_H */
287
 #endif /* DEV_H */

Loading…
Cancel
Save