diff options
author | Devin Lu <devin.lu@quantatw.com> | 2017-09-05 20:15:10 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-11 22:47:12 -0700 |
commit | a52cfbc80c060d9883aee9de4e764e0b250d184a (patch) | |
tree | 723d6e14d0fc398b350da14746a40db3c68f97f8 /common/system.c | |
parent | 1f17e1cfc9724f5598cfe3d0addbe5beb41810e7 (diff) | |
download | chrome-ec-a52cfbc80c060d9883aee9de4e764e0b250d184a.tar.gz |
common: add host command to push AP SKU ID to ec
add host command to set AP SKU ID to ec.
BUG=b:65359225
BRANCH=reef
TEST=make buildall -j
Change-Id: I76ffa4485be4de996b001097fa3f5a371f3a92ce
Signed-off-by: Devin Lu <Devin.Lu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/650277
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'common/system.c')
-rw-r--r-- | common/system.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/common/system.c b/common/system.c index db6ab782f6..07d43da38b 100644 --- a/common/system.c +++ b/common/system.c @@ -101,6 +101,47 @@ static enum ec_reboot_cmd reboot_at_shutdown; /* On-going actions preventing going into deep-sleep mode */ uint32_t sleep_mask; +#ifdef CONFIG_HOSTCMD_AP_SET_SKUID +static uint32_t ap_sku_id; + +uint32_t system_get_sku_id(void) +{ + return ap_sku_id; +} + +#define AP_SKUID_SYSJUMP_TAG 0x4153 /* AS */ +#define AP_SKUID_HOOK_VERSION 1 + +/** + * Preserve AP SKUID across a sysjump. + */ + +static void ap_sku_id_preserve_state(void) +{ + system_add_jump_tag(AP_SKUID_SYSJUMP_TAG, AP_SKUID_HOOK_VERSION, + sizeof(ap_sku_id), &ap_sku_id); +} +DECLARE_HOOK(HOOK_SYSJUMP, ap_sku_id_preserve_state, HOOK_PRIO_DEFAULT); + +/** + * Restore AP SKUID after a sysjump. + */ +static void ap_sku_id_restore_state(void) +{ + const uint32_t *prev_ap_sku_id; + int size, version; + + prev_ap_sku_id = (const uint32_t *)system_get_jump_tag( + AP_SKUID_SYSJUMP_TAG, &version, &size); + + if (prev_ap_sku_id && version == AP_SKUID_HOOK_VERSION && + size == sizeof(prev_ap_sku_id)) { + memcpy(&ap_sku_id, prev_ap_sku_id, sizeof(ap_sku_id)); + } +} +DECLARE_HOOK(HOOK_INIT, ap_sku_id_restore_state, HOOK_PRIO_DEFAULT); +#endif + /** * Return the program memory address where the image `copy` begins or should * begin. In the case of external storage, the image may or may not currently @@ -1186,7 +1227,7 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_VERSION, #ifdef CONFIG_HOSTCMD_SKUID static int host_command_get_sku_id(struct host_cmd_handler_args *args) { - struct ec_response_sku_id *r = args->response; + struct ec_sku_id_info *r = args->response; r->sku_id = system_get_sku_id(); args->response_size = sizeof(*r); @@ -1198,6 +1239,20 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_SKU_ID, EC_VER_MASK(0)); #endif +#ifdef CONFIG_HOSTCMD_AP_SET_SKUID +static int host_command_set_sku_id(struct host_cmd_handler_args *args) +{ + const struct ec_sku_id_info *p = args->params; + + ap_sku_id = p->sku_id; + + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_SET_SKU_ID, + host_command_set_sku_id, + EC_VER_MASK(0)); +#endif + static int host_command_build_info(struct host_cmd_handler_args *args) { strzcpy(args->response, system_get_build_info(), args->response_max); |