Skip to content

Commit 8973072

Browse files
committed
amd_bios: Fix argument interpretation
The numeric arguments passed in BIOS debug messages are always hexadecimal. The format string however controls what they're printed as. Adjust accordingly. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
1 parent cacc616 commit 8973072

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/amd_debug/kernel.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,16 @@ def sscanf_bios_args(line):
115115

116116
converted_args = []
117117
arg_index = 0
118-
for specifier in format_specifiers:
118+
for _specifier in format_specifiers:
119119
if arg_index < len(arguments):
120120
value = arguments[arg_index]
121121
if value == "Unknown":
122122
converted_args.append(-1)
123-
elif specifier.lower() == "x":
123+
else:
124124
try:
125125
converted_args.append(int(value, 16))
126126
except ValueError:
127127
return None
128-
else: # Decimal conversion
129-
try:
130-
converted_args.append(int(value))
131-
except ValueError:
132-
try:
133-
converted_args.append(int(value, 16))
134-
except ValueError:
135-
return None
136128
arg_index += 1
137129
else:
138130
break

src/test_kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_sscanf_bios_args(self):
8585

8686
# test a real post code line
8787
line = 'ex_trace_args: " POST CODE: %X ACPI TIMER: %X TIME: %d.%d ms\\n", b0003f33, 83528798, 0, 77, 0, 0'
88-
expected_output = "POST CODE: B0003F33 ACPI TIMER: 83528798 TIME: 0.77 ms"
88+
expected_output = "POST CODE: B0003F33 ACPI TIMER: 83528798 TIME: 0.119 ms"
8989
result = sscanf_bios_args(line)
9090
self.assertEqual(result, expected_output)
9191

0 commit comments

Comments
 (0)