[apps] switch to the __start __stop section linker magic

This commit is contained in:
Travis Geiselbrecht
2020-05-14 23:57:42 -07:00
parent f10d9baadb
commit 243975bbce
4 changed files with 5 additions and 15 deletions

View File

@@ -9,8 +9,8 @@
#include <app.h>
#include <kernel/thread.h>
extern const struct app_descriptor __apps_start;
extern const struct app_descriptor __apps_end;
extern const struct app_descriptor __start_apps __WEAK;
extern const struct app_descriptor __stop_apps __WEAK;
static void start_app(const struct app_descriptor *app);
@@ -19,13 +19,13 @@ void apps_init(void) {
const struct app_descriptor *app;
/* call all the init routines */
for (app = &__apps_start; app != &__apps_end; app++) {
for (app = &__start_apps; app != &__stop_apps; app++) {
if (app->init)
app->init(app);
}
/* start any that want to start on boot */
for (app = &__apps_start; app != &__apps_end; app++) {
for (app = &__start_apps; app != &__stop_apps; app++) {
if (app->entry && (app->flags & APP_FLAG_DONT_START_ON_BOOT) == 0) {
start_app(app);
}

View File

@@ -1,8 +0,0 @@
SECTIONS {
.apps : {
__apps_start = .;
KEEP (*(.apps))
__apps_end = .;
}
}
INSERT AFTER .rodata;

View File

@@ -33,7 +33,7 @@ struct app_descriptor {
size_t stack_size;
};
#define APP_START(appname) const struct app_descriptor _app_##appname __ALIGNED(sizeof(void *)) __SECTION(".apps") = { .name = #appname,
#define APP_START(appname) const struct app_descriptor _app_##appname __ALIGNED(sizeof(void *)) __SECTION("apps") = { .name = #appname,
#define APP_END };

View File

@@ -5,6 +5,4 @@ MODULE := $(LOCAL_DIR)
MODULE_SRCS += \
$(LOCAL_DIR)/app.c
EXTRA_LINKER_SCRIPTS += $(LOCAL_DIR)/app.ld
include make/module.mk