diff options
Diffstat (limited to 'src/ec/google/wilco/commands.c')
-rw-r--r-- | src/ec/google/wilco/commands.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/src/ec/google/wilco/commands.c b/src/ec/google/wilco/commands.c index a97a28ecce..9d4170f539 100644 --- a/src/ec/google/wilco/commands.c +++ b/src/ec/google/wilco/commands.c @@ -182,8 +182,45 @@ int wilco_ec_signed_fw(void) return !!ec_read(EC_RAM_SIGNED_FW); } -int wilco_ec_err_code(enum ec_err_code err_code) +struct err_code_entry { + uint8_t post_code; + enum ec_err_code ec_err; +}; + +/* + * Any post codes not listed in the post_code_err_map[] use default. + */ +static const enum ec_err_code default_ec_err = DLED_ROM; +static const struct err_code_entry post_code_err_map[] = { + { .post_code = POST_RAM_FAILURE, .ec_err = DLED_MEMORY, }, + { .post_code = POST_VIDEO_FAILURE, .ec_err = DLED_PANEL, }, +}; + +/* Records the most recent post code during boot */ +static uint8_t wilco_ec_saved_post_code; + +void wilco_ec_save_post_code(uint8_t post_code) +{ + wilco_ec_saved_post_code = post_code; +} + +/* Send error code to the EC based on last saved post code */ +void die_notify(void) { - return wilco_ec_mailbox(WILCO_EC_MSG_DEFAULT, KB_ERR_CODE, - &err_code, 1, NULL, 0); + size_t i; + enum ec_err_code err_code = default_ec_err; + + for (i = 0; i < ARRAY_SIZE(post_code_err_map); i++) { + if (post_code_err_map[i].post_code == + wilco_ec_saved_post_code) { + err_code = post_code_err_map[i].ec_err; + break; + } + } + + printk(BIOS_EMERG, "Fatal error: post_code 0x%02x, EC err 0x%02x\n", + wilco_ec_saved_post_code, err_code); + + wilco_ec_mailbox(WILCO_EC_MSG_DEFAULT, KB_ERR_CODE, + &err_code, 1, NULL, 0); } |