Skip to content

Commit ac8a3d2

Browse files
committed
tools: sof_ri_info: parse all plat_auth extensions
Add full parsing support for plat_auth extensions and their module entries, including partition info, signed package variants, and info 0x16. Update extension dumps to print these parsed fields and nested structures. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent c3de0ca commit ac8a3d2

1 file changed

Lines changed: 142 additions & 4 deletions

File tree

tools/sof_ri_info/sof_ri_info.py

Lines changed: 142 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -998,13 +998,78 @@ def parse_mft_extension(reader, ext_id):
998998
begin_off = reader.get_offset()
999999
ext_type = reader.read_dw()
10001000
ext_len = reader.read_dw()
1001-
if ext_type == 15:
1001+
if ext_type == 3:
1002+
reader.info("Partition info extension")
1003+
ext = PartitionInfoExtension(ext_id, reader.get_offset()-8)
1004+
ext.add_a(Astring('name', reader.read_string(4)))
1005+
ext.add_a(Auint('partition_length', reader.read_dw()))
1006+
ext.add_a(Abytes('hash', reader.read_bytes(32)))
1007+
ext.add_a(Auint('vcn', reader.read_dw()))
1008+
ext.add_a(Auint('part_version', reader.read_dw()))
1009+
ext.add_a(Auint('fmt_version', reader.read_dw()))
1010+
ext.add_a(Auint('instance_id', reader.read_dw()))
1011+
ext.add_a(Auint('part_flags', reader.read_dw()))
1012+
ext.add_a(Abytes('reserved', reader.read_bytes(20), 'red'))
1013+
1014+
mod_idx = 0
1015+
while reader.get_offset() < begin_off + ext_len:
1016+
mod = Component('partition_info_module_{}'.format(mod_idx),
1017+
'Partition Info Module', reader.get_offset())
1018+
mod.add_a(Astring('name', chararr_to_string(reader.read_bytes(12), 12)))
1019+
mod.add_a(Auint('type', reader.read_b()))
1020+
mod.add_a(Abytes('reserved', reader.read_bytes(3), 'red'))
1021+
mod.add_a(Auint('meta_size', reader.read_dw()))
1022+
mod.add_a(Abytes('hash', reader.read_bytes(32)))
1023+
ext.add_comp(mod)
1024+
mod_idx += 1
1025+
1026+
if reader.get_offset() != begin_off + ext_len:
1027+
raise Exception('Malformed partition info extension length')
1028+
elif ext_type == 15:
10021029
reader.info("Plat Fw Auth extension")
10031030
ext = PlatFwAuthExtension(ext_id, reader.get_offset()-8)
10041031
ext.add_a(Astring('name', reader.read_string(4)))
10051032
ext.add_a(Auint('vcn', reader.read_dw()))
10061033
ext.add_a(Abytes('bitmap', reader.read_bytes(16), 'red'))
10071034
ext.add_a(Auint('svn', reader.read_dw()))
1035+
1036+
# Signed package info extension common fields
1037+
ext.add_a(Auint('fw_type', reader.read_b()))
1038+
ext.add_a(Auint('fw_sub_type', reader.read_b()))
1039+
ext.add_a(Abytes('reserved', reader.read_bytes(14), 'red'))
1040+
1041+
mod_idx = 0
1042+
while reader.get_offset() < begin_off + ext_len:
1043+
mod = Component('signed_pkg_module_{}'.format(mod_idx),
1044+
'Signed Package Module', reader.get_offset())
1045+
mod.add_a(Astring('name', chararr_to_string(reader.read_bytes(12), 12)))
1046+
mod.add_a(Auint('type', reader.read_b()))
1047+
mod.add_a(Auint('hash_algo', reader.read_b()))
1048+
hash_size = reader.read_w()
1049+
mod.add_a(Auint('hash_size', hash_size))
1050+
mod.add_a(Auint('meta_size', reader.read_dw()))
1051+
mod.add_a(Abytes('hash', reader.read_bytes(hash_size)))
1052+
ext.add_comp(mod)
1053+
mod_idx += 1
1054+
1055+
if reader.get_offset() != begin_off + ext_len:
1056+
raise Exception('Malformed signed package extension length')
1057+
elif ext_type == 0x16:
1058+
reader.info("Info extension 0x16")
1059+
ext = InfoExtension0x16(ext_id, reader.get_offset()-8)
1060+
ext.add_a(Astring('name', reader.read_string(4)))
1061+
ext.add_a(Auint('size', reader.read_dw()))
1062+
ext.add_a(Auint('data0', reader.read_dw()))
1063+
ext.add_a(Auint('data1', reader.read_dw()))
1064+
ext.add_a(Auint('data2', reader.read_dw()))
1065+
ext.add_a(Auint('data3', reader.read_dw()))
1066+
ext.add_a(Auint('data4', reader.read_dw()))
1067+
ext.add_a(Abytes('hash', reader.read_bytes(48)))
1068+
ext.add_a(Auint('data1_0', reader.read_dw()))
1069+
ext.add_a(Auint('data1_1', reader.read_dw()))
1070+
ext.add_a(Auint('data1_2', reader.read_dw()))
1071+
ext.add_a(Auint('data1_3', reader.read_dw()))
1072+
ext.add_a(Auint('data1_4', reader.read_dw()))
10081073
read_len = reader.get_offset() - begin_off
10091074
reader.ff_data(ext_len - read_len)
10101075
elif ext_type == 17:
@@ -1027,9 +1092,30 @@ def parse_mft_extension(reader, ext_id):
10271092
ext.add_a(Astring('name', reader.read_string(4)))
10281093
ext.add_a(Auint('vcn', reader.read_dw()))
10291094
ext.add_a(Auint('svn', reader.read_dw()))
1030-
ext.add_a(Auint('partition_usage', reader.read_b(), 'red'))
1031-
read_len = reader.get_offset() - begin_off
1032-
reader.ff_data(ext_len - read_len)
1095+
ext.add_a(Auint('partition_usage', reader.read_b()))
1096+
ext.add_a(Auint('reserved0', reader.read_b(), 'red'))
1097+
ext.add_a(Auint('fw_type', reader.read_b()))
1098+
ext.add_a(Auint('fw_sub_type', reader.read_b()))
1099+
number_of_modules = reader.read_b()
1100+
ext.add_a(Auint('number_of_modules', number_of_modules))
1101+
ext.add_a(Auint('boot_strap_svn', reader.read_b()))
1102+
ext.add_a(Abytes('reserved', reader.read_bytes(14), 'red'))
1103+
1104+
mod_idx = 0
1105+
while reader.get_offset() < begin_off + ext_len:
1106+
mod = Component('signed_pkg_ace_module_{}'.format(mod_idx),
1107+
'Signed Package Module', reader.get_offset())
1108+
mod.add_a(Astring('name', chararr_to_string(reader.read_bytes(12), 12)))
1109+
mod.add_a(Auint('type', reader.read_b()))
1110+
mod.add_a(Auint('hash_algo', reader.read_b()))
1111+
mod.add_a(Abytes('reserved', reader.read_bytes(2), 'red'))
1112+
mod.add_a(Auint('meta_size', reader.read_dw()))
1113+
mod.add_a(Abytes('hash', reader.read_bytes(48)))
1114+
ext.add_comp(mod)
1115+
mod_idx += 1
1116+
1117+
if reader.get_offset() != begin_off + ext_len:
1118+
raise Exception('Malformed signed package ACE extension length')
10331119
else:
10341120
reader.info("Other extension")
10351121
ext = MftExtension(ext_id, 'Other Extension', reader.get_offset()-8)
@@ -1532,6 +1618,7 @@ def dump_info(self, pref, comp_filter):
15321618
print('{}{} type {} file offset 0x{:x} length {}'.
15331619
format(pref, self.name,
15341620
self.adir['type'], self.file_offset, self.adir['length']))
1621+
self.dump_comp_info(pref, comp_filter)
15351622

15361623
class PlatFwAuthExtension(MftExtension):
15371624
""" Platform FW Auth Extension
@@ -1547,6 +1634,9 @@ def dump_info(self, pref, comp_filter):
15471634
out += ' vcn {}'.format(self.adir['vcn'])
15481635
out += ' bitmap {}'.format(self.adir['bitmap'])
15491636
out += ' svn {}'.format(self.adir['svn'])
1637+
out += ' fw_type {}'.format(self.adir['fw_type'])
1638+
out += ' fw_sub_type {}'.format(self.adir['fw_sub_type'])
1639+
out += ' reserved {}'.format(self.adir['reserved'])
15501640
print(out)
15511641

15521642
class SignedPkgInfoExtension(MftExtension):
@@ -1563,6 +1653,54 @@ def dump_info(self, pref, comp_filter):
15631653
out += ' vcn {}'.format(self.adir['vcn'])
15641654
out += ' svn {}'.format(self.adir['svn'])
15651655
out += ' partition_usage {}'.format(self.adir['partition_usage'])
1656+
out += ' reserved0 {}'.format(self.adir['reserved0'])
1657+
out += ' fw_type {}'.format(self.adir['fw_type'])
1658+
out += ' fw_sub_type {}'.format(self.adir['fw_sub_type'])
1659+
out += ' number_of_modules {}'.format(self.adir['number_of_modules'])
1660+
out += ' boot_strap_svn {}'.format(self.adir['boot_strap_svn'])
1661+
out += ' reserved {}'.format(self.adir['reserved'])
1662+
print(out)
1663+
1664+
class PartitionInfoExtension(MftExtension):
1665+
""" Partition info Extension
1666+
"""
1667+
def __init__(self, ext_id, offset):
1668+
super(PartitionInfoExtension,
1669+
self).__init__(ext_id, 'Partition info Extension', offset)
1670+
1671+
def dump_info(self, pref, comp_filter):
1672+
super().dump_info(pref, comp_filter)
1673+
out = '{}'.format(pref)
1674+
out += ' name {}'.format(self.adir['name'])
1675+
out += ' partition_length {}'.format(self.adir['partition_length'])
1676+
out += ' hash {}'.format(self.adir['hash'])
1677+
out += ' vcn {}'.format(self.adir['vcn'])
1678+
out += ' part_version {}'.format(self.adir['part_version'])
1679+
out += ' fmt_version {}'.format(self.adir['fmt_version'])
1680+
out += ' instance_id {}'.format(self.adir['instance_id'])
1681+
out += ' part_flags {}'.format(self.adir['part_flags'])
1682+
out += ' reserved {}'.format(self.adir['reserved'])
1683+
print(out)
1684+
1685+
class InfoExtension0x16(MftExtension):
1686+
""" info_ext_0x16 Extension
1687+
"""
1688+
def __init__(self, ext_id, offset):
1689+
super(InfoExtension0x16,
1690+
self).__init__(ext_id, 'Info Extension 0x16', offset)
1691+
1692+
def dump_info(self, pref, comp_filter):
1693+
super().dump_info(pref, comp_filter)
1694+
out = '{}'.format(pref)
1695+
out += ' name {}'.format(self.adir['name'])
1696+
out += ' size {}'.format(self.adir['size'])
1697+
out += ' data [{}, {}, {}, {}, {}]'.format(
1698+
self.adir['data0'], self.adir['data1'], self.adir['data2'],
1699+
self.adir['data3'], self.adir['data4'])
1700+
out += ' hash {}'.format(self.adir['hash'])
1701+
out += ' data1 [{}, {}, {}, {}, {}]'.format(
1702+
self.adir['data1_0'], self.adir['data1_1'], self.adir['data1_2'],
1703+
self.adir['data1_3'], self.adir['data1_4'])
15661704
print(out)
15671705

15681706
class AdspMetadataFileExt(MftExtension):

0 commit comments

Comments
 (0)