summaryrefslogtreecommitdiff
path: root/include/host_command.h
diff options
context:
space:
mode:
authorSam Hurst <shurst@google.com>2016-10-31 09:04:09 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-11-23 15:36:00 -0800
commitc459c8278ed2dc84100693eab93389a0df9429bd (patch)
treef5196db2f5f97c98c1494ee6ab37535cb7286ed7 /include/host_command.h
parente4609af63c3b2884b4dd89e04175c7fbc2abab21 (diff)
downloadchrome-ec-c459c8278ed2dc84100693eab93389a0df9429bd.tar.gz
ec: Improve efficiency of host command dispatcher
Use binary search in host command lookup dispatcher BUG=chrome-os-partner:570895 TEST=manual testing on kevin - Kevin boots - ectool hello make buildall -j Verify *.smap hcmds section is sorted: 100bca94 R __hcmds 100bca94 R __host_cmd_0x0000 100bcaa0 R __host_cmd_0x0001 100bcaac R __host_cmd_0x0002 100bcab8 R __host_cmd_0x0003 100bcac4 R __host_cmd_0x0004 100bcad0 R __host_cmd_0x0005 100bcadc R __host_cmd_0x0006 100bcae8 R __host_cmd_0x0007 100bcaf4 R __host_cmd_0x0008 100bcb00 R __host_cmd_0x0009 100bcb0c R __host_cmd_0x000a 100bcb18 R __host_cmd_0x000b 100bcb24 R __host_cmd_0x000d 100bcb30 R __host_cmd_0x0010 100bcb3c R __host_cmd_0x0011 100bcb48 R __host_cmd_0x0012 100bcb54 R __host_cmd_0x0013 100bcb60 R __host_cmd_0x0015 100bcb6c R __host_cmd_0x0016 100bcb78 R __host_cmd_0x0017 100bcb84 R __host_cmd_0x0025 100bcb90 R __host_cmd_0x0026 100bcb9c R __host_cmd_0x0029 100bcba8 R __host_cmd_0x002a 100bcbb4 R __host_cmd_0x002b 100bcbc0 R __host_cmd_0x002c 100bcbcc R __host_cmd_0x0044 100bcbd8 R __host_cmd_0x0045 100bcbe4 R __host_cmd_0x0046 100bcbf0 R __host_cmd_0x0047 100bcbfc R __host_cmd_0x0061 100bcc08 R __host_cmd_0x0062 100bcc14 R __host_cmd_0x0064 100bcc20 R __host_cmd_0x0065 100bcc2c R __host_cmd_0x0067 100bcc38 R __host_cmd_0x0087 100bcc44 R __host_cmd_0x008c 100bcc50 R __host_cmd_0x008d 100bcc5c R __host_cmd_0x008f 100bcc68 R __host_cmd_0x0092 100bcc74 R __host_cmd_0x0093 100bcc80 R __host_cmd_0x0096 100bcc8c R __host_cmd_0x0097 100bcc98 R __host_cmd_0x0098 100bcca4 R __host_cmd_0x0099 100bccb0 R __host_cmd_0x009e 100bccbc R __host_cmd_0x00a0 100bccc8 R __host_cmd_0x00a1 100bccd4 R __host_cmd_0x00a8 100bcce0 R __host_cmd_0x00a9 100bccec R __host_cmd_0x00b6 100bccf8 R __host_cmd_0x00b7 100bcd04 R __host_cmd_0x00d2 100bcd10 R __host_cmd_0x00d3 100bcd1c R __host_cmd_0x00db 100bcd28 R __host_cmd_0x0101 100bcd34 R __host_cmd_0x0102 100bcd40 R __host_cmd_0x0103 100bcd4c R __host_cmd_0x0104 100bcd58 R __host_cmd_0x0110 100bcd64 R __host_cmd_0x0111 100bcd70 R __host_cmd_0x0112 100bcd7c R __host_cmd_0x0113 100bcd88 R __host_cmd_0x0114 100bcd94 R __host_cmd_0x0115 100bcda0 R __host_cmd_0x0116 100bcdac R __host_cmd_0x0117 100bcdb8 R __host_cmd_0x0118 100bcdc4 R __host_cmd_0x011a 100bcdd0 R __evt_src_EC_MKBP_EVENT_KEY_MATRIX 100bcdd0 R __hcmds_end BRANCH=none Change-Id: Ideb9951b318763f71915e2c4e5052f4b4bfab173 Reviewed-on: https://chromium-review.googlesource.com/405528 Commit-Ready: Sam Hurst <shurst@google.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/host_command.h')
-rw-r--r--include/host_command.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/include/host_command.h b/include/host_command.h
index 720492158e..52ea73ee53 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -197,13 +197,18 @@ 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"))) \
+#define EXPAND(cmd) __host_cmd_(cmd)
+#define __host_cmd_(cmd) __host_cmd_##cmd
+#define EXPANDSTR(cmd) __host_cmd_str(cmd)
+#define __host_cmd_str(cmd) #cmd
+#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
+ const struct host_command __keep EXPAND(command) \
+ __attribute__((section(".rodata.hcmds.__host_cmd_" \
+ EXPANDSTR(command)))) \
= {routine, command, version_mask}
#else
-#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
- int (routine)(struct host_cmd_handler_args *args) \
+#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
+ int (routine)(struct host_cmd_handler_args *args) \
__attribute__((unused))
#endif