Files
OpenCellular/include/console.h
Vincent Palatin c21f07e58e 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
2012-01-24 00:50:08 +00:00

37 lines
984 B
C

/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* console.h - Debug console for Chrome EC */
#ifndef __CROS_EC_CONSOLE_H
#define __CROS_EC_CONSOLE_H
#include "common.h"
/* Console command */
struct console_command {
/* Command name. Case-insensitive. */
const char *name;
/* Handler for the command. argv[0] will be the command name. */
int (*handler)(int argc, char **argv);
};
/* Initializes the console module. */
int console_init(void);
/* Called by UART when a line of input is pending. */
void console_has_input(void);
/* 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 */