[dev] move the device/driver class api to __start __stop style symbols
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
SECTIONS {
|
||||
.devices : {
|
||||
__devices = .;
|
||||
KEEP (*(.devices))
|
||||
__devices_end = .;
|
||||
}
|
||||
}
|
||||
INSERT AFTER .data;
|
||||
14
dev/driver.c
14
dev/driver.c
@@ -12,14 +12,13 @@
|
||||
#include <lk/trace.h>
|
||||
|
||||
/* static list of devices constructed with DEVICE_INSTANCE macros */
|
||||
extern struct device __devices[];
|
||||
extern struct device __devices_end[];
|
||||
extern struct device __start_devices __WEAK;
|
||||
extern struct device __stop_devices __WEAK;
|
||||
|
||||
status_t device_init_all(void) {
|
||||
status_t res = NO_ERROR;
|
||||
|
||||
struct device *dev = __devices;
|
||||
while (dev != __devices_end) {
|
||||
for (struct device *dev = &__start_devices; dev != &__stop_devices; dev++) {
|
||||
if (dev->flags & DEVICE_FLAG_AUTOINIT) {
|
||||
status_t code = device_init(dev);
|
||||
|
||||
@@ -30,8 +29,6 @@ status_t device_init_all(void) {
|
||||
res = code;
|
||||
}
|
||||
}
|
||||
|
||||
dev++;
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -40,8 +37,7 @@ status_t device_init_all(void) {
|
||||
status_t device_fini_all(void) {
|
||||
status_t res = NO_ERROR;
|
||||
|
||||
struct device *dev = __devices;
|
||||
while (dev != __devices_end) {
|
||||
for (struct device *dev = &__start_devices; dev != &__stop_devices; dev++) {
|
||||
status_t code = device_fini(dev);
|
||||
|
||||
if (code < 0) {
|
||||
@@ -50,8 +46,6 @@ status_t device_fini_all(void) {
|
||||
|
||||
res = code;
|
||||
}
|
||||
|
||||
dev++;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
SECTIONS {
|
||||
.drivers : {
|
||||
__drivers = .;
|
||||
KEEP (*(.drivers))
|
||||
__drivers_end = .;
|
||||
}
|
||||
}
|
||||
INSERT AFTER .rodata;
|
||||
@@ -70,7 +70,7 @@ struct driver {
|
||||
|
||||
#define DRIVER_EXPORT(type_, ops_) \
|
||||
const struct driver concat(__driver_, type_) \
|
||||
__ALIGNED(sizeof(void *)) __SECTION(".drivers") = { \
|
||||
__ALIGNED(sizeof(void *)) __SECTION("drivers") = { \
|
||||
.type = #type_, \
|
||||
.ops = ops_, \
|
||||
}
|
||||
@@ -78,7 +78,7 @@ struct driver {
|
||||
#define DEVICE_INSTANCE(type_, name_, config_, flags_) \
|
||||
extern struct driver concat(__driver_, type_); \
|
||||
struct device concat(__device_, concat(type_, concat(_, name_))) \
|
||||
__ALIGNED(sizeof(void *)) __SECTION(".devices") = { \
|
||||
__ALIGNED(sizeof(void *)) __SECTION("devices") = { \
|
||||
.name = #name_, \
|
||||
.driver = &concat(__driver_, type_), \
|
||||
.flags = flags_, \
|
||||
|
||||
@@ -12,6 +12,4 @@ MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/class/fb_api.c \
|
||||
$(LOCAL_DIR)/class/netif_api.c \
|
||||
|
||||
EXTRA_LINKER_SCRIPTS += $(LOCAL_DIR)/devices.ld $(LOCAL_DIR)/drivers.ld
|
||||
|
||||
include make/module.mk
|
||||
|
||||
Reference in New Issue
Block a user