util/amdfwtool/data_parse: fix PMU subprogram/instance ID handling

The parsing of the PMU binary subprogram and instance numbers only
worked correctly for the cases where the ID in the name in the fw.cfg
file was between 0 and 9, but returned wrong results if it was between a
and f. Switch to using strtol with a base of 16 instead of subtracting
the char '0' from the char in the filename in
find_register_fw_filename_bios_dir to fix this.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: Ic5fd41daf9f26d11c1f86375387c1d7beac04124
Reviewed-on: https://review.coreboot.org/c/coreboot/+/67927
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
This commit is contained in:
Felix Held 2022-09-28 18:00:39 +02:00
parent 542ac2f3f8
commit 3dfb485334
1 changed files with 4 additions and 4 deletions

View File

@ -375,13 +375,13 @@ static uint8_t find_register_fw_filename_bios_dir(char *fw_name, char *filename,
if (strncmp(fw_name, PMUI_STR_BASE, PMU_STR_BASE_LEN) == 0) {
assert(strlen(fw_name) == PMU_STR_ALL_LEN);
fw_type = AMD_BIOS_PMUI;
subprog = fw_name[PMU_STR_SUB_INDEX] - '0';
instance = fw_name[PMU_STR_INS_INDEX] - '0';
subprog = strtol(&fw_name[PMU_STR_SUB_INDEX], NULL, 16);
instance = strtol(&fw_name[PMU_STR_INS_INDEX], NULL, 16);
} else if (strncmp(fw_name, PMUD_STR_BASE, PMU_STR_BASE_LEN) == 0) {
assert(strlen(fw_name) == PMU_STR_ALL_LEN);
fw_type = AMD_BIOS_PMUD;
subprog = fw_name[PMU_STR_SUB_INDEX] - '0';
instance = fw_name[PMU_STR_INS_INDEX] - '0';
subprog = strtol(&fw_name[PMU_STR_SUB_INDEX], NULL, 16);
instance = strtol(&fw_name[PMU_STR_INS_INDEX], NULL, 16);
} else if (strcmp(fw_name, "RTM_PUBKEY_FILE") == 0) {
fw_type = AMD_BIOS_RTM_PUBKEY;
subprog = 0;