[lib][console] switch the console commands to __start __stop style symbols

This commit is contained in:
Travis Geiselbrecht
2020-05-15 00:03:14 -07:00
parent c6ee887e96
commit d3d22d68a5
4 changed files with 5 additions and 16 deletions

View File

@@ -72,8 +72,8 @@ static cmd_block *command_list = NULL;
/* a linear array of statically defined command blocks,
defined in the linker script.
*/
extern cmd_block __commands_start;
extern cmd_block __commands_end;
extern cmd_block __start_commands __WEAK;
extern cmd_block __stop_commands __WEAK;
static int cmd_help(int argc, const cmd_args *argv);
static int cmd_help_panic(int argc, const cmd_args *argv);
@@ -108,8 +108,7 @@ int console_init(void) {
mutex_init(command_lock);
/* add all the statically defined commands to the list */
cmd_block *block;
for (block = &__commands_start; block != &__commands_end; block++) {
for (cmd_block *block = &__start_commands; block != &__stop_commands; block++) {
console_register_commands(block);
}

View File

@@ -1,8 +0,0 @@
SECTIONS {
.commands : {
__commands_start = .;
KEEP (*(.commands))
__commands_end = .;
}
}
INSERT AFTER .data;

View File

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

View File

@@ -49,13 +49,13 @@ typedef struct _cmd_block {
#define STATIC_COMMAND_START static const cmd _cmd_list[] = {
#define STATIC_COMMAND_END(name) }; cmd_block _cmd_block_##name __ALIGNED(sizeof(void *)) __SECTION(".commands") = \
#define STATIC_COMMAND_END(name) }; cmd_block _cmd_block_##name __ALIGNED(sizeof(void *)) __SECTION("commands") = \
{ NULL, sizeof(_cmd_list) / sizeof(_cmd_list[0]), _cmd_list }
/* same as above but with a suffixed name to make the list unique within the file */
#define STATIC_COMMAND_START_NAMED(name) static const cmd _cmd_list_##name[] = {
#define STATIC_COMMAND_END_NAMED(name) }; cmd_block _cmd_block_##name __ALIGNED(sizeof(void *)) __SECTION(".commands") = \
#define STATIC_COMMAND_END_NAMED(name) }; cmd_block _cmd_block_##name __ALIGNED(sizeof(void *)) __SECTION("commands") = \
{ NULL, sizeof(_cmd_list_##name) / sizeof(_cmd_list_##name[0]), _cmd_list_##name }
#define STATIC_COMMAND(command_str, help_str, func) { command_str, help_str, func, CMD_AVAIL_NORMAL },