1# SPDX-License-Identifier: GPL-2.0+
2#
3# Copyright 2025 NXP
4
5from binman.etype.section import Entry_section
6
7class Entry_nxp_header_ddrfw(Entry_section):
8    """Add a header to DDR PHY firmware images
9
10    This entry is used for i.MX95 to combine DDR PHY firmware images and their
11    byte counts together.
12
13    See imx95_evk.rst for how to get DDR PHY Firmware Images.
14    """
15
16    def __init__(self, section, etype, node):
17        super().__init__(section, etype, node)
18
19    def BuildSectionData(self, required):
20        section_data = bytearray()
21        header_data = bytearray()
22
23        for entry in self._entries.values():
24            entry_data = entry.GetData(required)
25
26            section_data += entry_data
27            header_data += entry.contents_size.to_bytes(4, 'little')
28
29        return header_data + section_data
30