diff --git a/tools/rimage/src/manifest.c b/tools/rimage/src/manifest.c index fb30dc7ab219..f57f15a8b7de 100644 --- a/tools/rimage/src/manifest.c +++ b/tools/rimage/src/manifest.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,29 @@ #include #include +static bool cse_header_is_valid(const struct image *image, const void *buffer, size_t size) +{ + if (image->adsp->man_v2_5 || image->adsp->man_ace_v1_5) { + const struct CsePartitionDirHeader_v2_5 *cse_hdr = buffer; + + return cse_hdr->header_marker == CSE_HEADER_MAKER && + cse_hdr->nb_entries == MAN_CSE_PARTS && + cse_hdr->header_length >= sizeof(*cse_hdr) && + size >= sizeof(*cse_hdr); + } + + if (image->adsp->man_v1_5 || image->adsp->man_v1_8) { + const struct CsePartitionDirHeader *cse_hdr = buffer; + + return cse_hdr->header_marker == CSE_HEADER_MAKER && + cse_hdr->nb_entries == MAN_CSE_PARTS && + cse_hdr->header_length >= sizeof(*cse_hdr) && + size >= sizeof(*cse_hdr); + } + + return false; +} + static int man_open_rom_file(struct image *image) { uint32_t size; @@ -1630,7 +1654,7 @@ int man_write_fw_ace_v1_5(struct image *image) int verify_image(struct image *image) { FILE *in_file; - int ret; + int ret = -EINVAL; void *buffer; size_t size, read, i; @@ -1666,7 +1690,7 @@ int verify_image(struct image *image) } for (i = 0; i < size; i += sizeof(uint32_t)) { /* find CSE header marker "$CPD" */ - if (*(uint32_t *)(buffer + i) == CSE_HEADER_MAKER) { + if (cse_header_is_valid(image, buffer + i, size - i)) { image->fw_image = buffer + i; ret = image->adsp->verify_firmware(image); goto out; @@ -1677,8 +1701,9 @@ int verify_image(struct image *image) fprintf(stderr, "error: could not find valid CSE header $CPD in %s\n", image->verify_file); out: + free(buffer); fclose(in_file); - return 0; + return ret; } @@ -1719,7 +1744,7 @@ int resign_image(struct image *image) for (i = 0; i < size; i += sizeof(uint32_t)) { /* find CSE header marker "$CPD" */ - if (*(uint32_t *)(buffer + i) == CSE_HEADER_MAKER) { + if (cse_header_is_valid(image, buffer + i, size - i)) { image->fw_image = buffer + i; break; } @@ -1781,7 +1806,22 @@ int resign_image(struct image *image) goto out; } - man_write_fw_mod(image); + ret = man_write_fw_mod(image); + if (ret < 0) + goto out; + + if (fclose(image->out_fd)) { + ret = file_error("unable to close file after signing", image->out_file); + goto out; + } + image->out_fd = NULL; + + /* validate the re-signed output with the same private key */ + image->verify_file = image->out_file; + ret = verify_image(image); + image->verify_file = NULL; + if (ret < 0) + unlink(image->out_file); out: free(buffer); diff --git a/tools/rimage/src/rimage.c b/tools/rimage/src/rimage.c index 8e50bf9f5033..2245288dfece 100644 --- a/tools/rimage/src/rimage.c +++ b/tools/rimage/src/rimage.c @@ -33,7 +33,7 @@ static void usage(char *name) fprintf(stdout, "\t -e build extended manifest\n"); fprintf(stdout, "\t -l build loadable modules image (don't treat the first module as a bootloader)\n"); fprintf(stdout, "\t -y verify signed file\n"); - fprintf(stdout, "\t -q resign binary\n"); + fprintf(stdout, "\t -q resign binary from infile and validate the output signature\n"); fprintf(stdout, "\t -p set PV bit\n"); fprintf(stdout, "\t -d ignore detached sections\n"); fprintf(stdout, "\t -Q, --quiet suppress informational stdout logs\n"); @@ -144,6 +144,11 @@ int main(int argc, char *argv[]) return -EINVAL; } + if (image.in_file && image.verify_file) { + fprintf(stderr, "error: resign and verify modes are mutually exclusive\n"); + return -EINVAL; + } + /* firmware version: major.minor.micro */ if (image.fw_ver_string) { ret = sscanf(image.fw_ver_string, "%hu.%hu.%hu", diff --git a/tools/sof_ri_info/sof_ri_info.py b/tools/sof_ri_info/sof_ri_info.py index be78d7aebf50..c97e49398d2f 100755 --- a/tools/sof_ri_info/sof_ri_info.py +++ b/tools/sof_ri_info/sof_ri_info.py @@ -846,14 +846,22 @@ def parse_cse_manifest(reader): nb_entries = reader.read_dw() reader.info('# of entries {}'.format(nb_entries)) hdr.add_a(Adec('nb_entries', nb_entries)) - # read version (1byte for header ver and 1 byte for entry ver) - ver = reader.read_w() - hdr.add_a(Ahex('header_version', ver)) + # read version bytes + hdr.add_a(Ahex('header_version', reader.read_b())) + hdr.add_a(Ahex('entry_version', reader.read_b())) header_length = reader.read_b() hdr.add_a(Ahex('header_length', header_length)) - hdr.add_a(Ahex('checksum', reader.read_b())) + legacy_or_unused = reader.read_b() + if header_length > 12: + hdr.add_a(Ahex('not_used', legacy_or_unused)) + else: + hdr.add_a(Ahex('checksum', legacy_or_unused)) hdr.add_a(Astring('partition_name', reader.read_string(4))) + # CSE v2.5 extends header with a CRC32 checksum dword + if header_length > 12: + hdr.add_a(Ahex('checksum32', reader.read_dw())) + reader.set_offset(cse_mft.file_offset + header_length) # Read entries nb_index = 0 @@ -862,13 +870,13 @@ def parse_cse_manifest(reader): entry_name = reader.read_string(12) entry_offset = reader.read_dw() entry_length = reader.read_dw() - # reserved field - reader.read_dw() + entry_reserved = reader.read_dw() hdr_entry = Component('cse_hdr_entry', 'Entry', reader.get_offset()) hdr_entry.add_a(Astring('entry_name', entry_name)) hdr_entry.add_a(Ahex('entry_offset', entry_offset)) hdr_entry.add_a(Ahex('entry_length', entry_length)) + hdr_entry.add_a(Ahex('entry_reserved', entry_reserved)) hdr.add_comp(hdr_entry) assert cse_mft.file_offset == reader.ext_mft_length @@ -916,12 +924,16 @@ def parse_css_manifest_4(css_mft, reader, size_limit): hdr = Component('css_mft_hdr', 'Header', reader.get_offset()) css_mft.add_comp(hdr) - hdr.add_a(Auint('type', reader.read_dw())) + header_type = reader.read_dw() + hdr.add_a(Auint('type', header_type)) + hdr.add_a(Auint('header_type', header_type)) header_len_dw = reader.read_dw() hdr.add_a(Auint('header_len_dw', header_len_dw)) hdr.add_a(Auint('header_version', reader.read_dw())) hdr.add_a(Auint('reserved0', reader.read_dw(), 'red')) - hdr.add_a(Ahex('mod_vendor', reader.read_dw())) + module_vendor = reader.read_dw() + hdr.add_a(Ahex('mod_vendor', module_vendor)) + hdr.add_a(Ahex('module_vendor', module_vendor)) date_start = reader.get_offset() hdr.add_a(Auint('date_start', date_start)) hdr.add_a(Adate('date', hex(reader.read_dw()))) @@ -930,10 +942,17 @@ def parse_css_manifest_4(css_mft, reader, size_limit): hdr.add_a(Auint('size', size)) hdr.add_a(Astring('header_id', reader.read_string(4))) hdr.add_a(Auint('padding', reader.read_dw())) - hdr.add_a(Aversion('fw_version', reader.read_w(), reader.read_w(), - reader.read_w(), reader.read_w())) + fw_major = reader.read_w() + fw_minor = reader.read_w() + fw_hotfix = reader.read_w() + fw_build = reader.read_w() + hdr.add_a(Auint('fw_major_version', fw_major)) + hdr.add_a(Auint('fw_minor_version', fw_minor)) + hdr.add_a(Auint('fw_hotfix_version', fw_hotfix)) + hdr.add_a(Auint('fw_build_version', fw_build)) + hdr.add_a(Aversion('fw_version', fw_major, fw_minor, fw_hotfix, fw_build)) hdr.add_a(Auint('svn', reader.read_dw())) - reader.read_bytes(18*4) + hdr.add_a(Abytes('reserved1', reader.read_bytes(18*4))) modulus_size = reader.read_dw() hdr.add_a(Adec('modulus_size', modulus_size)) exponent_size = reader.read_dw() @@ -965,56 +984,196 @@ def parse_css_manifest_4(css_mft, reader, size_limit): if ext_type == 0xffffffff: continue reader.set_offset(reader.get_offset() - 4) - css_mft.add_comp(parse_mft_extension(reader, ext_idx)) + css_mft.add_comp(parse_mft_extension(reader, ext_idx, size_limit)) ext_idx += 1 - assert reader.get_offset() == size_limit # wrong extension length + if reader.get_offset() != size_limit: + reader.info('warning: CSS extension parser finished at 0x{:x}, expected 0x{:x}; clamping'.format( + reader.get_offset(), size_limit)) + reader.set_offset(size_limit) css_mft.length = reader.get_offset() - css_mft.file_offset return css_mft -def parse_mft_extension(reader, ext_id): +def parse_mft_extension(reader, ext_id, max_end=None): """ Parses mft extension from sof binary """ begin_off = reader.get_offset() ext_type = reader.read_dw() ext_len = reader.read_dw() - if ext_type == 15: + ext_end = begin_off + ext_len + if max_end is not None and ext_end > max_end: + reader.info('warning: extension 0x{:x} length 0x{:x} exceeds CSS entry end; truncating'.format(ext_type, ext_len)) + ext_end = max_end + if ext_type == 3: + reader.info("Partition info extension") + ext = PartitionInfoExtension(ext_id, reader.get_offset()-8) + ext.add_a(Astring('name', reader.read_string(4))) + ext.add_a(Auint('partition_length', reader.read_dw())) + ext.add_a(Abytes('hash', reader.read_bytes(32))) + ext.add_a(Auint('vcn', reader.read_dw())) + ext.add_a(Auint('part_version', reader.read_dw())) + ext.add_a(Auint('fmt_version', reader.read_dw())) + ext.add_a(Auint('instance_id', reader.read_dw())) + ext.add_a(Auint('part_flags', reader.read_dw())) + ext.add_a(Abytes('reserved', reader.read_bytes(20), 'red')) + + mod_idx = 0 + while reader.get_offset() < ext_end: + mod = Component('partition_info_module_{}'.format(mod_idx), + 'Partition Info Module', reader.get_offset()) + mod.add_a(Astring('name', chararr_to_string(reader.read_bytes(12), 12))) + mod.add_a(Auint('type', reader.read_b())) + mod.add_a(Abytes('reserved', reader.read_bytes(3), 'red')) + mod.add_a(Auint('meta_size', reader.read_dw())) + mod.add_a(Abytes('hash', reader.read_bytes(32))) + ext.add_comp(mod) + mod_idx += 1 + + if reader.get_offset() > ext_end: + raise Exception('Malformed partition info extension length') + if reader.get_offset() < ext_end: + reader.ff_data(ext_end - reader.get_offset()) + elif ext_type == 15: reader.info("Plat Fw Auth extension") ext = PlatFwAuthExtension(ext_id, reader.get_offset()-8) ext.add_a(Astring('name', reader.read_string(4))) ext.add_a(Auint('vcn', reader.read_dw())) ext.add_a(Abytes('bitmap', reader.read_bytes(16), 'red')) ext.add_a(Auint('svn', reader.read_dw())) + + # Signed package info extension common fields + ext.add_a(Auint('fw_type', reader.read_b())) + ext.add_a(Auint('fw_sub_type', reader.read_b())) + ext.add_a(Abytes('reserved', reader.read_bytes(14), 'red')) + + mod_idx = 0 + while reader.get_offset() < ext_end: + mod = Component('signed_pkg_module_{}'.format(mod_idx), + 'Signed Package Module', reader.get_offset()) + mod.add_a(Astring('name', chararr_to_string(reader.read_bytes(12), 12))) + mod.add_a(Auint('type', reader.read_b())) + mod.add_a(Auint('hash_algo', reader.read_b())) + hash_size = reader.read_w() + mod.add_a(Auint('hash_size', hash_size)) + mod.add_a(Auint('meta_size', reader.read_dw())) + mod.add_a(Abytes('hash', reader.read_bytes(hash_size))) + ext.add_comp(mod) + mod_idx += 1 + + if reader.get_offset() > ext_end: + raise Exception('Malformed signed package extension length') + if reader.get_offset() < ext_end: + reader.ff_data(ext_end - reader.get_offset()) + elif ext_type == 0x16: + reader.info("Info extension 0x16") + ext = InfoExtension0x16(ext_id, reader.get_offset()-8) + ext.add_a(Astring('name', reader.read_string(4))) + ext.add_a(Auint('size', reader.read_dw())) + ext.add_a(Auint('data0', reader.read_dw())) + ext.add_a(Auint('data1', reader.read_dw())) + ext.add_a(Auint('data2', reader.read_dw())) + ext.add_a(Auint('data3', reader.read_dw())) + ext.add_a(Auint('data4', reader.read_dw())) + ext.add_a(Abytes('hash', reader.read_bytes(48))) + ext.add_a(Auint('data1_0', reader.read_dw())) + ext.add_a(Auint('data1_1', reader.read_dw())) + ext.add_a(Auint('data1_2', reader.read_dw())) + ext.add_a(Auint('data1_3', reader.read_dw())) + ext.add_a(Auint('data1_4', reader.read_dw())) read_len = reader.get_offset() - begin_off - reader.ff_data(ext_len - read_len) + effective_len = ext_end - begin_off + if read_len < effective_len: + reader.ff_data(effective_len - read_len) elif ext_type == 17: reader.info("ADSP metadata file extension") ext = AdspMetadataFileExt(ext_id, reader.get_offset()-8) ext.add_a(Auint('adsp_imr_type', reader.read_dw(), 'red')) - # skip reserved part - reader.read_bytes(16) - reader.read_dw() - reader.read_dw() - # - ext.add_a(Auint('version', reader.read_dw())) - ext.add_a(Abytes('sha_hash', reader.read_bytes(32))) - ext.add_a(Auint('base_offset', reader.read_dw())) - ext.add_a(Auint('limit_offset', reader.read_dw())) - ext.add_a(Abytes('attributes', reader.read_bytes(16))) + ext.add_a(Abytes('reserved', reader.read_bytes(16), 'red')) + + comp_desc = Component('adsp_comp_desc', 'Component Descriptor', + reader.get_offset()) + comp_desc_res0 = reader.read_dw() + comp_desc_res1 = reader.read_dw() + comp_desc_ver = reader.read_dw() + comp_desc.add_a(Auint('reserved0', comp_desc_res0)) + comp_desc.add_a(Auint('reserved1', comp_desc_res1)) + comp_desc.add_a(Auint('version', comp_desc_ver)) + ext.add_a(Auint('comp_desc_reserved0', comp_desc_res0)) + ext.add_a(Auint('comp_desc_reserved1', comp_desc_res1)) + ext.add_a(Auint('version', comp_desc_ver)) + + remaining = ext_end - reader.get_offset() + if remaining >= 72: + hash_len = 48 + else: + hash_len = 32 + + comp_hash = reader.read_bytes(hash_len) + comp_desc.add_a(Abytes('hash', comp_hash)) + ext.add_a(Abytes('sha_hash', comp_hash)) + + base_offset = reader.read_dw() + limit_offset = reader.read_dw() + comp_desc.add_a(Auint('base_offset', base_offset)) + comp_desc.add_a(Auint('limit_offset', limit_offset)) + ext.add_a(Auint('base_offset', base_offset)) + ext.add_a(Auint('limit_offset', limit_offset)) + + attr0 = reader.read_dw() + attr1 = reader.read_dw() + attr2 = reader.read_dw() + attr3 = reader.read_dw() + comp_desc.add_a(Auint('attribute0', attr0)) + comp_desc.add_a(Auint('attribute1', attr1)) + comp_desc.add_a(Auint('attribute2', attr2)) + comp_desc.add_a(Auint('attribute3', attr3)) + ext.add_a(Abytes('attributes', struct.pack('IIII', attr0, attr1, + attr2, attr3))) + ext.add_comp(comp_desc) + + read_len = reader.get_offset() - begin_off + effective_len = ext_end - begin_off + if read_len < effective_len: + reader.ff_data(effective_len - read_len) + elif read_len > effective_len: + raise Exception('Malformed ADSP metadata file extension length') elif ext_type == 35: reader.info("Signed package info extension") ext = SignedPkgInfoExtension(ext_id, reader.get_offset()-8) ext.add_a(Astring('name', reader.read_string(4))) ext.add_a(Auint('vcn', reader.read_dw())) ext.add_a(Auint('svn', reader.read_dw())) - ext.add_a(Auint('partition_usage', reader.read_b(), 'red')) - read_len = reader.get_offset() - begin_off - reader.ff_data(ext_len - read_len) + ext.add_a(Auint('partition_usage', reader.read_b())) + ext.add_a(Auint('reserved0', reader.read_b(), 'red')) + ext.add_a(Auint('fw_type', reader.read_b())) + ext.add_a(Auint('fw_sub_type', reader.read_b())) + number_of_modules = reader.read_b() + ext.add_a(Auint('number_of_modules', number_of_modules)) + ext.add_a(Auint('boot_strap_svn', reader.read_b())) + ext.add_a(Abytes('reserved', reader.read_bytes(14), 'red')) + + mod_idx = 0 + while reader.get_offset() < ext_end: + mod = Component('signed_pkg_ace_module_{}'.format(mod_idx), + 'Signed Package Module', reader.get_offset()) + mod.add_a(Astring('name', chararr_to_string(reader.read_bytes(12), 12))) + mod.add_a(Auint('type', reader.read_b())) + mod.add_a(Auint('hash_algo', reader.read_b())) + mod.add_a(Abytes('reserved', reader.read_bytes(2), 'red')) + mod.add_a(Auint('meta_size', reader.read_dw())) + mod.add_a(Abytes('hash', reader.read_bytes(48))) + ext.add_comp(mod) + mod_idx += 1 + + if reader.get_offset() > ext_end: + raise Exception('Malformed signed package ACE extension length') + if reader.get_offset() < ext_end: + reader.ff_data(ext_end - reader.get_offset()) else: reader.info("Other extension") ext = MftExtension(ext_id, 'Other Extension', reader.get_offset()-8) - reader.ff_data(ext_len-8) + reader.ff_data(max(0, ext_end - reader.get_offset())) ext.add_a(Auint('type', ext_type)) ext.add_a(Auint('length', ext_len)) reader.info("... end of extension") @@ -1037,16 +1196,22 @@ def parse_adsp_manifest_hdr(reader): reader.get_offset() -4) hdr.add_a(Astring('sig', sig)) - hdr.add_a(Auint('size', reader.read_dw())) + header_len = reader.read_dw() + hdr.add_a(Auint('header_len', header_len)) + hdr.add_a(Auint('size', header_len)) hdr.add_a(Astring('name', chararr_to_string(reader.read_bytes(8), 8))) - hdr.add_a(Auint('preload', reader.read_dw())) + preload_page_count = reader.read_dw() + hdr.add_a(Auint('preload_page_count', preload_page_count)) + hdr.add_a(Auint('preload', preload_page_count)) hdr.add_a(Auint('fw_image_flags', reader.read_dw())) hdr.add_a(Auint('feature_mask', reader.read_dw())) hdr.add_a(Aversion('build_version', reader.read_w(), reader.read_w(), reader.read_w(), reader.read_w())) hdr.add_a(Adec('num_module_entries', reader.read_dw())) - hdr.add_a(Ahex('hw_buf_base_addr', reader.read_dw())) + fw_compat = reader.read_dw() + hdr.add_a(Ahex('fw_compat', fw_compat)) + hdr.add_a(Ahex('hw_buf_base_addr', fw_compat)) hdr.add_a(Auint('hw_buf_length', reader.read_dw())) hdr.add_a(Ahex('load_offset', reader.read_dw())) @@ -1081,7 +1246,9 @@ def parse_adsp_manifest_mod_entry(index, reader): mod.add_a(Adec('cfg_count', reader.read_w())) mod.add_a(Auint('affinity_mask', reader.read_dw())) mod.add_a(Adec('instance_max_count', reader.read_w())) - mod.add_a(Auint('instance_stack_size', reader.read_w())) + instance_bss_size = reader.read_w() + mod.add_a(Auint('instance_bss_size', instance_bss_size)) + mod.add_a(Auint('instance_stack_size', instance_bss_size)) for i in range(0, 3): seg_flags = reader.read_dw() mod.add_a(Astring('seg_'+repr(i)+'_flags', @@ -1092,6 +1259,24 @@ def parse_adsp_manifest_mod_entry(index, reader): return mod +def parse_adsp_manifest_mod_config(index, reader): + """ Parses ADSP manifest module config from sof binary + """ + cfg = Component('mod_cfg_'+repr(index), 'Module Config', + reader.get_offset()) + cfg.add_a(Auint('par0', reader.read_dw())) + cfg.add_a(Auint('par1', reader.read_dw())) + cfg.add_a(Auint('par2', reader.read_dw())) + cfg.add_a(Auint('par3', reader.read_dw())) + cfg.add_a(Auint('is_pages', reader.read_dw())) + cfg.add_a(Auint('cps', reader.read_dw())) + cfg.add_a(Auint('ibs', reader.read_dw())) + cfg.add_a(Auint('obs', reader.read_dw())) + cfg.add_a(Auint('module_flags', reader.read_dw())) + cfg.add_a(Auint('cpc', reader.read_dw())) + cfg.add_a(Auint('obls', reader.read_dw())) + return cfg + def parse_adsp_manifest(reader, name): """ Parses ADSP manifest from sof binary """ @@ -1102,6 +1287,10 @@ def parse_adsp_manifest(reader, name): mod_entry = parse_adsp_manifest_mod_entry(i, reader) adsp_mft.add_comp(mod_entry) + for i in range(0, num_module_entries): + mod_cfg = parse_adsp_manifest_mod_config(i, reader) + adsp_mft.add_comp(mod_cfg) + return adsp_mft def parse_fw_bin(path, no_cse, verbose): @@ -1456,10 +1645,19 @@ def __init__(self, offset): def dump_info(self, pref, comp_filter): hdr = self.cdir['cse_mft_hdr'] - print('{}{} ver {} checksum {} partition name {}'. - format(pref, - self.name, hdr.adir['header_version'], - hdr.adir['checksum'], hdr.adir['partition_name'])) + out = '{}{} header_ver {} entry_ver {} partition name {}'.format( + pref, + self.name, + hdr.adir['header_version'], + hdr.adir['entry_version'], + hdr.adir['partition_name']) + if 'checksum' in hdr.adir: + out += ' checksum {}'.format(hdr.adir['checksum']) + if 'not_used' in hdr.adir: + out += ' not_used {}'.format(hdr.adir['not_used']) + if 'checksum32' in hdr.adir: + out += ' checksum32 {}'.format(hdr.adir['checksum32']) + print(out) self.dump_comp_info(pref, comp_filter + ['Header']) class CssManifest(Component): @@ -1504,6 +1702,7 @@ def dump_info(self, pref, comp_filter): print('{}{} type {} file offset 0x{:x} length {}'. format(pref, self.name, self.adir['type'], self.file_offset, self.adir['length'])) + self.dump_comp_info(pref, comp_filter) class PlatFwAuthExtension(MftExtension): """ Platform FW Auth Extension @@ -1519,6 +1718,9 @@ def dump_info(self, pref, comp_filter): out += ' vcn {}'.format(self.adir['vcn']) out += ' bitmap {}'.format(self.adir['bitmap']) out += ' svn {}'.format(self.adir['svn']) + out += ' fw_type {}'.format(self.adir['fw_type']) + out += ' fw_sub_type {}'.format(self.adir['fw_sub_type']) + out += ' reserved {}'.format(self.adir['reserved']) print(out) class SignedPkgInfoExtension(MftExtension): @@ -1535,6 +1737,54 @@ def dump_info(self, pref, comp_filter): out += ' vcn {}'.format(self.adir['vcn']) out += ' svn {}'.format(self.adir['svn']) out += ' partition_usage {}'.format(self.adir['partition_usage']) + out += ' reserved0 {}'.format(self.adir['reserved0']) + out += ' fw_type {}'.format(self.adir['fw_type']) + out += ' fw_sub_type {}'.format(self.adir['fw_sub_type']) + out += ' number_of_modules {}'.format(self.adir['number_of_modules']) + out += ' boot_strap_svn {}'.format(self.adir['boot_strap_svn']) + out += ' reserved {}'.format(self.adir['reserved']) + print(out) + +class PartitionInfoExtension(MftExtension): + """ Partition info Extension + """ + def __init__(self, ext_id, offset): + super(PartitionInfoExtension, + self).__init__(ext_id, 'Partition info Extension', offset) + + def dump_info(self, pref, comp_filter): + super().dump_info(pref, comp_filter) + out = '{}'.format(pref) + out += ' name {}'.format(self.adir['name']) + out += ' partition_length {}'.format(self.adir['partition_length']) + out += ' hash {}'.format(self.adir['hash']) + out += ' vcn {}'.format(self.adir['vcn']) + out += ' part_version {}'.format(self.adir['part_version']) + out += ' fmt_version {}'.format(self.adir['fmt_version']) + out += ' instance_id {}'.format(self.adir['instance_id']) + out += ' part_flags {}'.format(self.adir['part_flags']) + out += ' reserved {}'.format(self.adir['reserved']) + print(out) + +class InfoExtension0x16(MftExtension): + """ info_ext_0x16 Extension + """ + def __init__(self, ext_id, offset): + super(InfoExtension0x16, + self).__init__(ext_id, 'Info Extension 0x16', offset) + + def dump_info(self, pref, comp_filter): + super().dump_info(pref, comp_filter) + out = '{}'.format(pref) + out += ' name {}'.format(self.adir['name']) + out += ' size {}'.format(self.adir['size']) + out += ' data [{}, {}, {}, {}, {}]'.format( + self.adir['data0'], self.adir['data1'], self.adir['data2'], + self.adir['data3'], self.adir['data4']) + out += ' hash {}'.format(self.adir['hash']) + out += ' data1 [{}, {}, {}, {}, {}]'.format( + self.adir['data1_0'], self.adir['data1_1'], self.adir['data1_2'], + self.adir['data1_3'], self.adir['data1_4']) print(out) class AdspMetadataFileExt(MftExtension): @@ -1553,6 +1803,12 @@ def dump_info(self, pref, comp_filter): out += ' limit offset {}'.format(self.adir['limit_offset']) print(out) print('{} IMR type {}'.format(pref, self.adir['adsp_imr_type'])) + print('{} Reserved {}'.format(pref, self.adir['reserved'])) + print('{} Component desc reserved0 {}'.format(pref, + self.adir['comp_desc_reserved0'])) + print('{} Component desc reserved1 {}'.format(pref, + self.adir['comp_desc_reserved1'])) + print('{} SHA hash {}'.format(pref, self.adir['sha_hash'])) print('{} Attributes'.format(pref)) print('{} {}'.format(pref, self.adir['attributes'])) @@ -1569,6 +1825,7 @@ def dump_info(self, pref, comp_filter): out += ' build ver {}'.format(hdr.adir['build_version']) out += ' feature mask {}'.format(hdr.adir['feature_mask']) out += ' image flags {}'.format(hdr.adir['fw_image_flags']) + out += ' fw compat {}'.format(hdr.adir['fw_compat']) print(out) print('{} HW buffers base address {} length {}'. format(pref, @@ -1781,6 +2038,13 @@ def dump_info(self): DspMemorySegment('l2 lpsram', 0xbe800000, 1*64*1024) ]) +PTL_MEMORY_SPACE = DspMemory('Intel Pantherlake', + [ + DspMemorySegment('imr', 0xb0000000, 16*1024*1024), + DspMemorySegment('l2 hpsram', 0xbe000000, 30*64*1024), + DspMemorySegment('l2 lpsram', 0xbe800000, 1*64*1024) + ]) + DSP_MEM_SPACE_EXT = { 'apl' : APL_MEMORY_SPACE, 'glk' : APL_MEMORY_SPACE, @@ -1797,10 +2061,16 @@ def dump_info(self): 'ehl' : TGL_LP_MEMORY_SPACE, 'adl' : TGL_LP_MEMORY_SPACE, 'rpl' : TGL_LP_MEMORY_SPACE, + 'mtl' : TGL_LP_MEMORY_SPACE, + 'lnl' : TGL_LP_MEMORY_SPACE, + 'arl' : TGL_LP_MEMORY_SPACE, 'tgl-h' : TGL_H_MEMORY_SPACE, 'adl-s' : TGL_H_MEMORY_SPACE, 'rpl-s' : TGL_H_MEMORY_SPACE, + 'arl-s' : TGL_H_MEMORY_SPACE, + 'ptl' : PTL_MEMORY_SPACE, + 'nvl' : PTL_MEMORY_SPACE, } @@ -1923,6 +2193,7 @@ def main(args): comp_filter = [] if args.headers or args.no_modules: comp_filter.append('Module Entry') + comp_filter.append('Module Config') if args.no_headers: comp_filter.append('CSE Manifest') fw_bin.dump_info('', comp_filter)