Skip to content

Commit

Permalink
Update list_IO_BARs function
Browse files Browse the repository at this point in the history
Function was not properly utilizing bus structure and would not print
out all associated bars

Signed-off-by: brentholtsclaw <[email protected]>
  • Loading branch information
BrentHoltsclaw committed Jul 22, 2024
1 parent 9f84aba commit 84f8219
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions chipsec/hal/iobar.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,34 @@ def list_IO_BARs(self) -> None:
if not self.is_IO_BAR_defined(_bar_name):
continue
_bar = self.cs.Cfg.IO_BARS[_bar_name]
try:
(_base, _size) = self.get_IO_BAR_base_address(_bar_name)
except CSReadError:
if self.logger.HAL:
self.logger.log(f"Unable to find IO BAR {_bar_name}")
continue
_en = self.is_IO_BAR_enabled(_bar_name)

bus_data = []
if 'register' in _bar:
_s = _bar['register']
if 'offset' in _bar:
_s += (f' + 0x{int(_bar["offset"], 16):X}')
bus_data = self.cs.register.get_bus(_bar['register'])
if not bus_data:
if 'bus' in self.cs.register.get_def(_bar['register']):
bus_data = [self.cs.register.get_def(_bar['register'])['bus']]
elif 'bus' in _bar:
bus_data.extend(_bar['bus'])
else:
_s = f'{int(_bar["bus"], 16):02X}:{int(_bar["dev"], 16):02X}.{int(_bar["fun"], 16):01X} + {_bar["reg"]}'
continue

logger().log(f' {_bar_name:12} | {_s:14} | {_base:016X} | {_size:08X} | {_en:d} | {_bar["desc"]}')
for bus in bus_data:
try:
(_base, _size) = self.get_IO_BAR_base_address(_bar_name)
except CSReadError:
if self.logger.HAL:
self.logger.log(f"Unable to find IO BAR {_bar_name}")
continue
_en = self.is_IO_BAR_enabled(_bar_name)

if 'register' in _bar:
_s = _bar['register']
if 'offset' in _bar:
_s += (f' + 0x{_bar["offset"]:X}')
else:
_s = f'{bus:02X}:{_bar["dev"]:02X}.{_bar["fun"]:01X} + {_bar["reg"]}'

logger().log(f' {_bar_name:12} | {_s:14} | {_base:016X} | {_size:08X} | {_en:d} | {_bar["desc"]}')

#
# Read I/O range by I/O BAR name
Expand Down

0 comments on commit 84f8219

Please sign in to comment.