summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2012-01-23 23:07:58 +0000
committerVincent Palatin <vpalatin@chromium.org>2012-01-24 00:50:08 +0000
commitc21f07e58e48144a97a844668aae68644f8e8dec (patch)
tree12a0b7f04e085a0d2035e9bfbe05013530f99501 /include
parenta2a85365d600b93ecd10d44d1a5a2115ce0252f1 (diff)
downloadchrome-ec-c21f07e58e48144a97a844668aae68644f8e8dec.tar.gz
register console commands at compile-time
Instead of using a runtime callback to register the console commands, put them in a special linker section. So we can do a macro to "register" them during the build. It saves 684 bytes and a few microseconds at startup. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=None TEST=run a few commands from the BDS command line. Change-Id: Id33ea210b9035bf76ed720373c74c5dd24ccd1b1
Diffstat (limited to 'include')
-rw-r--r--include/console.h17
1 files changed, 6 insertions, 11 deletions
diff --git a/include/console.h b/include/console.h
index f8f76860da..4aeca1c5f4 100644
--- a/include/console.h
+++ b/include/console.h
@@ -19,14 +19,6 @@ struct console_command {
};
-/* Console command group */
-struct console_group {
- const char *group_name; /* Name of the command group */
- const struct console_command *commands; /* List of commands */
- int command_count; /* Number of commands in list */
-};
-
-
/* Initializes the console module. */
int console_init(void);
@@ -34,8 +26,11 @@ int console_init(void);
/* Called by UART when a line of input is pending. */
void console_has_input(void);
-
-/* Registers a group of console commands. */
-int console_register_commands(const struct console_group *group);
+/* Register a console command handler */
+#define DECLARE_CONSOLE_COMMAND(name, routine) \
+ static const char __con_cmd_label_##name[] = #name; \
+ const struct console_command __con_cmd_##name \
+ __attribute__((section(".rodata.cmds"))) \
+ = {__con_cmd_label_##name, routine}
#endif /* __CROS_EC_CONSOLE_H */