board_inspector: fix an inappropriate call to ord

The stream tracks the AML binary to be parsed as a list of bytes, not
characters. It makes no sense to call `ord` with a byte as the input
parameter.

This patch also adjust the format of the dump and print the formatted using
the logging module.

Tracked-On: #6504
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
This commit is contained in:
Junjie Mao 2022-01-17 19:13:43 +08:00 committed by acrnsi-robot
parent 75884af9ac
commit a7e06cec2f

View File

@ -3,15 +3,17 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
import logging
from .exception import * from .exception import *
from .grammar import AML_EXT_OP_PREFIX from .grammar import AML_EXT_OP_PREFIX
class Stream: class Stream:
def print_binary(self, base): def print_binary(self, base):
acc = f"[{hex(base)}/{hex(len(self.data))}]" acc = f"[{hex(base):>8s}/{hex(len(self.data)):>8s}]"
converted = "" converted = ""
for i in range(base, base + 16): for i in range(base, base + 16):
code = ord(self.data[i]) code = self.data[i]
acc += " %02x" % code acc += " %02x" % code
if code >= 0x20 and code <= 0x7E: if code >= 0x20 and code <= 0x7E:
converted += chr(code) converted += chr(code)
@ -21,7 +23,7 @@ class Stream:
acc += " " acc += " "
converted += " " converted += " "
acc += f" '{converted}'" acc += f" '{converted}'"
print(acc) logging.debug(acc)
def __init__(self, data): def __init__(self, data):
self.data = data self.data = data