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
1 changed files with 5 additions and 3 deletions

View File

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