summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2022-09-28 18:00:39 +0200
committerFelix Held <felix-coreboot@felixheld.de>2022-09-30 18:03:50 +0000
commit3dfb48533484b8ba6ba1b1c1a39fcfee9491989c (patch)
tree94b2460dffc1113f85c3b11721c30377d5350989 /util
parent542ac2f3f869f75a2b4c9f8b9d1953a94975e497 (diff)
downloadcoreboot-3dfb48533484b8ba6ba1b1c1a39fcfee9491989c.tar.gz
coreboot-3dfb48533484b8ba6ba1b1c1a39fcfee9491989c.tar.bz2
coreboot-3dfb48533484b8ba6ba1b1c1a39fcfee9491989c.zip
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>
Diffstat (limited to 'util')
-rw-r--r--util/amdfwtool/data_parse.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/util/amdfwtool/data_parse.c b/util/amdfwtool/data_parse.c
index 14c156732136..424a68a90cce 100644
--- a/util/amdfwtool/data_parse.c
+++ b/util/amdfwtool/data_parse.c
@@ -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;