common: Include host/console commands based on HAS_TASK_HOSTCMD/CONSOLE

Don't build a table of host / console commands if the HOSTCMD or CONSOLE
task is not present. This saves space in the .hcmds / .cmds section and
allows the linker to prune command handler functions which will never be
called.

BUG=chrome-os-partner:41959
TEST=Verify ec.RO.flat shrinks on snoball and glados_pd, and remains the
same size on chell and samus. Also verify basic functions are still
working on snoball and glados_pd.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I79975c18ec1d87fedda8d1f299f30ffc43c24f69
Reviewed-on: https://chromium-review.googlesource.com/319112
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
Shawn Nematbakhsh
2015-12-17 13:08:38 -08:00
committed by chrome-bot
parent 8623942335
commit ee4e0763a1
2 changed files with 10 additions and 1 deletions

View File

@@ -142,7 +142,10 @@ void console_has_input(void);
* @param shorthelp String with one-line description of command.
* @param longhelp String with long description of command.
*/
#ifdef CONFIG_CONSOLE_CMDHELP
#ifndef HAS_TASK_CONSOLE
#define DECLARE_CONSOLE_COMMAND(name, routine, argdesc, shorthelp, longhelp) \
int (routine)(int argc, char **argv) __attribute__((unused))
#elif defined(CONFIG_CONSOLE_CMDHELP)
#define DECLARE_CONSOLE_COMMAND(name, routine, argdesc, shorthelp, longhelp) \
static const char __con_cmd_label_##name[] = #name; \
const struct console_command __keep __con_cmd_##name \

View File

@@ -194,10 +194,16 @@ int host_request_expected_size(const struct ec_host_request *r);
void host_packet_receive(struct host_packet *pkt);
/* Register a host command handler */
#ifdef HAS_TASK_HOSTCMD
#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
const struct host_command __keep __host_cmd_##command \
__attribute__((section(".rodata.hcmds"))) \
= {routine, command, version_mask}
#else
#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
int (routine)(struct host_cmd_handler_args *args) \
__attribute__((unused))
#endif
/**