ACK: [PATCH 3/3][Resend]: uefidump: add support for Key#### (LP:#1237263)
Colin Ian King
colin.king at canonical.com
Mon Oct 14 11:42:46 UTC 2013
On 14/10/13 11:11, Ivan Hu wrote:
> Add support for Key#### - The Key#### variable associates a key press
> with a single boot option. Each Key#### variable is the name "Key"
> appended with a unique four digit hexadecimal number. For example,
> Key0001, Key0002, Key00A0, etc.
>
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
> src/lib/include/fwts_uefi.h | 11 ++++++
> src/uefi/uefidump/uefidump.c | 80 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 91 insertions(+)
>
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index d38903e..512ca67 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -115,6 +115,17 @@ typedef struct {
> fwts_uefi_dev_path unused_file_path_list[1];
> } __attribute__((packed)) fwts_uefi_load_option;
>
> +typedef struct {
> + uint32_t keydata;
> + uint32_t bootoptioncrc;
> + uint16_t bootoption;
> +} __attribute__((packed)) fwts_uefi_key_option;
> +
> +typedef struct {
> + uint16_t scancode;
> + uint16_t unicodechar;
> +} __attribute__((packed)) fwts_uefi_input_key;
> +
> typedef enum {
> FWTS_UEFI_HARDWARE_DEV_PATH_TYPE = (0x01),
> FWTS_UEFI_ACPI_DEVICE_PATH_TYPE = (0x02),
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index b414ca9..54d8be3 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -777,6 +777,78 @@ static void uefidump_info_driverdev(fwts_framework *fw, fwts_uefi_var *var)
> }
> }
>
> +static void uefidump_info_keyoption(fwts_framework *fw, fwts_uefi_var *var)
> +{
> + fwts_uefi_key_option *key_option = (fwts_uefi_key_option *)var->data;
> + fwts_uefi_input_key *inputkey = (fwts_uefi_input_key *) (((uint8_t *) var->data) + sizeof (fwts_uefi_key_option));
> + char str[300];
> + size_t keyoptionsize, inputkeycount, index = 0;
> +
> + *str = 0;
> +
> + if (var->datalen < sizeof (fwts_uefi_key_option)) {
> + uefidump_var_hexdump(fw, var);
> + return;
> + }
> +
> + if (key_option->keydata & (1 << 8))
> + strcat(str, "ShiftPressed");
> +
> + if (key_option->keydata & (1 << 9)) {
> + if (*str)
> + strcat(str, ",");
> + strcat(str, "ControlPressed");
> + }
> +
> + if (key_option->keydata & (1 << 10)) {
> + if (*str)
> + strcat(str, ",");
> + strcat(str, "AltPressed");
> + }
> +
> + if (key_option->keydata &(1 << 11)) {
> + if (*str)
> + strcat(str, ",");
> + strcat(str, "LogoPressed");
> + }
> +
> + if (key_option->keydata & (1 << 12)) {
> + if (*str)
> + strcat(str, ",");
> + strcat(str, "MenuPressed");
> + }
> +
> + if (key_option->keydata & (1 << 13)) {
> + if (*str)
> + strcat(str, ",");
> + strcat(str, "SysReqPressed");
> + }
> +
> + if (*str != 0)
> + fwts_log_info_verbatum(fw, " PackedValue: 0x%8.8" PRIx32 " (%s).", key_option->keydata, str);
> + else
> + fwts_log_info_verbatum(fw, " PackedValue: 0x%8.8" PRIx32 ".", key_option->keydata);
> +
> + fwts_log_info_verbatum(fw, " BootOptionCrc: 0x%8.8" PRIx32 ".", key_option->bootoptioncrc);
> + fwts_log_info_verbatum(fw, " BootOption: %4.4" PRIx16 ".", key_option->bootoption);
> +
> + inputkeycount = (key_option->keydata & 0xC0000000) >> 30;
> + for (index = 0; index < inputkeycount; index++) {
> + fwts_log_info_verbatum(fw, " ScanCode: 0x%4.4" PRIx16 ".", inputkey[index].scancode);
> + fwts_log_info_verbatum(fw, " UnicodeChar: 0x%4.4" PRIx16 ".", inputkey[index].unicodechar);
> + }
> +
> + keyoptionsize = sizeof (fwts_uefi_key_option) + inputkeycount * sizeof (fwts_uefi_input_key);
> +
> + /*
> + * there are extra data following the keyoption data structure which the firmware is using,
> + * dump all data for reference
> + */
> + if (var->datalen > keyoptionsize) {
> + uefidump_var_hexdump(fw, var);
> + }
> +}
> +
> static uefidump_info uefidump_info_table[] = {
> { "PlatformLangCodes", uefidump_info_platform_langcodes },
> { "PlatformLang", uefidump_info_platform_lang },
> @@ -844,6 +916,14 @@ static void uefidump_var(fwts_framework *fw, fwts_uefi_var *var)
> return;
> }
>
> + /* Check the key option key####. #### is a printed hex value */
> + if ((strlen(varname) == 7) && (strncmp(varname, "Key", 3) == 0)
> + && isxdigit(varname[3]) && isxdigit(varname[4])
> + && isxdigit(varname[5]) && isxdigit(varname[6])) {
> + uefidump_info_keyoption(fw, var);
> + return;
> + }
> +
> /* otherwise just do a plain old hex dump */
> uefidump_var_hexdump(fw, var);
> }
>
Got some whitespace in this patch:
/home/king/ivan/fwts/.git/rebase-apply/patch:39: space before tab in indent.
fwts_uefi_input_key *inputkey = (fwts_uefi_input_key *) (((uint8_t *)
var->data) + sizeof (fwts_uefi_key_option));
warning: 1 line adds whitespace errors.
Keng-Yu, can you fix this up before applying?
Acked-by: Colin Ian King <colin.king at canonical.com>
More information about the fwts-devel
mailing list