浏览代码

dev.c uses the new tables infrastructure.

tags/v0.9.3
Michael Brown 19 年前
父节点
当前提交
f37e0a06d7
共有 3 个文件被更改,包括 13 次插入30 次删除
  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 查看文件

@@ -145,18 +145,9 @@ SECTIONS {
145 145
 	*(SORT(.tbl.*))	
146 146
 
147 147
 
148
-	device_drivers = .;
149
-	*(.drivers.device)
150
-	device_drivers_end = .;
151 148
 	isa_drivers = . ;
152 149
 	*(.drivers.isa)
153 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 152
 	_progbits_end = .;
162 153
     }

+ 9
- 10
src/core/dev.c 查看文件

@@ -3,19 +3,18 @@
3 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 18
 /* Current attempted boot device */
20 19
 struct dev dev = {
21 20
 	.bus_driver = bus_drivers,

+ 4
- 11
src/include/dev.h 查看文件

@@ -4,6 +4,7 @@
4 4
 #include "stdint.h"
5 5
 #include "string.h"
6 6
 #include "dhcp.h" /* for dhcp_dev_id */
7
+#include "tables.h"
7 8
 
8 9
 /*
9 10
  * Forward declarations
@@ -158,7 +159,7 @@ struct bus_driver {
158 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 165
  * A structure fully describing the bus-independent parts of a
@@ -187,7 +188,7 @@ struct type_driver {
187 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 194
  * A driver for a device.
@@ -205,7 +206,7 @@ struct device_driver {
205 206
 };
206 207
 
207 208
 #define __device_driver \
208
-	__attribute__ (( used, __section__ ( ".drivers.device" ) ))
209
+	__attribute__ (( used, __table_section(device_driver,01) ))
209 210
 
210 211
 #define DRIVER(_name,_type_driver,_bus_driver,_bus_info,	 	      \
211 212
 	       _probe,_disable) 		 			      \
@@ -283,12 +284,4 @@ static inline int load ( struct dev *dev,
283 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 287
 #endif /* DEV_H */

正在加载...
取消
保存