Example #1
0
    def ReadNode(self):
        """Read properties from the section node"""
        super().ReadNode()
        self._pad_byte = fdt_util.GetInt(self._node, 'pad-byte', 0)
        self._sort = fdt_util.GetBool(self._node, 'sort-by-offset')
        self._end_4gb = fdt_util.GetBool(self._node, 'end-at-4gb')
        self._skip_at_start = fdt_util.GetInt(self._node, 'skip-at-start')
        if self._end_4gb:
            if not self.size:
                self.Raise(
                    "Section size must be provided when using end-at-4gb")
            if self._skip_at_start is not None:
                self.Raise("Provide either 'end-at-4gb' or 'skip-at-start'")
            else:
                self._skip_at_start = 0x100000000 - self.size
        else:
            if self._skip_at_start is None:
                self._skip_at_start = 0
        self._name_prefix = fdt_util.GetString(self._node, 'name-prefix')
        self.align_default = fdt_util.GetInt(self._node, 'align-default', 0)
        filename = fdt_util.GetString(self._node, 'filename')
        if filename:
            self._filename = filename

        self._ReadEntries()
Example #2
0
    def ReadNode(self):
        """Read entry information from the node

        This must be called as the first thing after the Entry is created.

        This reads all the fields we recognise from the node, ready for use.
        """
        if 'pos' in self._node.props:
            self.Raise("Please use 'offset' instead of 'pos'")
        self.offset = fdt_util.GetInt(self._node, 'offset')
        self.size = fdt_util.GetInt(self._node, 'size')
        self.orig_offset = fdt_util.GetInt(self._node, 'orig-offset')
        self.orig_size = fdt_util.GetInt(self._node, 'orig-size')
        if self.GetImage().copy_to_orig:
            self.orig_offset = self.offset
            self.orig_size = self.size

        # These should not be set in input files, but are set in an FDT map,
        # which is also read by this code.
        self.image_pos = fdt_util.GetInt(self._node, 'image-pos')
        self.uncomp_size = fdt_util.GetInt(self._node, 'uncomp-size')

        self.align = fdt_util.GetInt(self._node, 'align')
        if tools.NotPowerOfTwo(self.align):
            raise ValueError("Node '%s': Alignment %s must be a power of two" %
                             (self._node.path, self.align))
        self.pad_before = fdt_util.GetInt(self._node, 'pad-before', 0)
        self.pad_after = fdt_util.GetInt(self._node, 'pad-after', 0)
        self.align_size = fdt_util.GetInt(self._node, 'align-size')
        if tools.NotPowerOfTwo(self.align_size):
            self.Raise("Alignment size %s must be a power of two" %
                       self.align_size)
        self.align_end = fdt_util.GetInt(self._node, 'align-end')
        self.offset_unset = fdt_util.GetBool(self._node, 'offset-unset')
        self.expand_size = fdt_util.GetBool(self._node, 'expand-size')
Example #3
0
    def ReadNode(self):
        super().ReadNode()
        self.return_invalid_entry = fdt_util.GetBool(self._node,
                                                     'return-invalid-entry')
        self.return_unknown_contents = fdt_util.GetBool(
            self._node, 'return-unknown-contents')
        self.bad_update_contents = fdt_util.GetBool(self._node,
                                                    'bad-update-contents')
        self.bad_shrink_contents = fdt_util.GetBool(self._node,
                                                    'bad-shrink-contents')
        self.return_contents_once = fdt_util.GetBool(self._node,
                                                     'return-contents-once')
        self.bad_update_contents_twice = fdt_util.GetBool(
            self._node, 'bad-update-contents-twice')
        self.return_contents_later = fdt_util.GetBool(self._node,
                                                      'return-contents-later')

        # Set to True when the entry is ready to process the FDT.
        self.process_fdt_ready = False
        self.never_complete_process_fdt = fdt_util.GetBool(
            self._node, 'never-complete-process-fdt')
        self.require_args = fdt_util.GetBool(self._node, 'require-args')

        # This should be picked up by GetEntryArgsOrProps()
        self.test_existing_prop = 'existing'
        self.force_bad_datatype = fdt_util.GetBool(self._node,
                                                   'force-bad-datatype')
        (self.test_str_fdt, self.test_str_arg, self.test_int_fdt,
         self.test_int_arg, existing) = self.GetEntryArgsOrProps([
             EntryArg('test-str-fdt', str),
             EntryArg('test-str-arg', str),
             EntryArg('test-int-fdt', int),
             EntryArg('test-int-arg', int),
             EntryArg('test-existing-prop', str)
         ], self.require_args)
        if self.force_bad_datatype:
            self.GetEntryArgsOrProps([EntryArg('test-bad-datatype-arg', bool)])
        self.return_contents = True
        self.contents = b'aa'

        # Set to the required bintool when collecting bintools.
        self.bintool_for_contents = None
        self.require_bintool_for_contents = fdt_util.GetString(
            self._node, 'require-bintool-for-contents')
        if self.require_bintool_for_contents == '':
            self.require_bintool_for_contents = '_testing'

        self.bintool_for_pack = None
        self.require_bintool_for_pack = fdt_util.GetString(
            self._node, 'require-bintool-for-pack')
        if self.require_bintool_for_pack == '':
            self.require_bintool_for_pack = '_testing'
Example #4
0
    def Create(section, node, etype=None, expanded=False, missing_etype=False):
        """Create a new entry for a node.

        Args:
            section (entry_Section):  Section object containing this node
            node (Node): Node object containing information about the entry to
                create
            etype (str): Entry type to use, or None to work it out (used for
                tests)
            expanded (bool): Use the expanded version of etype
            missing_etype (bool): True to default to a blob etype if the
                requested etype is not found

        Returns:
            A new Entry object of the correct type (a subclass of Entry)
        """
        if not etype:
            etype = fdt_util.GetString(node, 'type', node.name)
        obj = Entry.Lookup(node.path, etype, expanded, missing_etype)
        if obj and expanded:
            # Check whether to use the expanded entry
            new_etype = etype + '-expanded'
            can_expand = not fdt_util.GetBool(node, 'no-expanded')
            if can_expand and obj.UseExpanded(node, etype, new_etype):
                etype = new_etype
            else:
                obj = None
        if not obj:
            obj = Entry.Lookup(node.path, etype, False, missing_etype)

        # Call its constructor to get the object we want.
        return obj(section, etype, node)
Example #5
0
 def ReadEntries(self):
     """Read the subnodes to find out what should go in this IFWI"""
     for node in self._node.subnodes:
         entry = Entry.Create(self.section, node)
         entry.ReadNode()
         entry._ifwi_replace = fdt_util.GetBool(node, 'ifwi-replace')
         entry._ifwi_subpart = fdt_util.GetString(node, 'ifwi-subpart')
         entry._ifwi_entry_name = fdt_util.GetString(node, 'ifwi-entry')
         self._ifwi_entries[entry._ifwi_subpart] = entry
Example #6
0
 def ReadNode(self):
     super().ReadNode()
     self._pattern = fdt_util.GetString(self._node, 'pattern')
     if not self._pattern:
         self.Raise("Missing 'pattern' property")
     self._files_compress = fdt_util.GetString(self._node, 'files-compress',
                                               'none')
     self._files_align = fdt_util.GetInt(self._node, 'files-align')
     self._require_matches = fdt_util.GetBool(self._node, 'require-matches')
Example #7
0
 def ProcessFdt(self, fdt):
     # Figure out where to put the microcode pointer
     fname = tools.GetInputFilename(self.elf_fname)
     sym = elf.GetSymbolAddress(fname, '_dt_ucode_base_size')
     if sym:
         self.target_offset = sym
     elif not fdt_util.GetBool(self._node, 'optional-ucode'):
         self.Raise('Cannot locate _dt_ucode_base_size symbol in u-boot')
     return True
Example #8
0
    def __init__(self, section, etype, node):
        # Put this here to allow entry-docs and help to work without libfdt
        global state
        from binman import state

        super().__init__(section, etype, node)
        self._pattern = fdt_util.GetString(self._node, 'pattern')
        if not self._pattern:
            self.Raise("Missing 'pattern' property")
        self._compress = fdt_util.GetString(self._node, 'compress', 'none')
        self._require_matches = fdt_util.GetBool(self._node, 'require-matches')
Example #9
0
    def __init__(self, section, etype, node):
        super().__init__(section, etype, node)
        self.hardware_id, self.keydir, self.bmpblk = self.GetEntryArgsOrProps(
            [EntryArg('hardware-id', str),
             EntryArg('keydir', str),
             EntryArg('bmpblk', str)])

        # Read in the GBB flags from the config
        self.gbb_flags = 0
        flags_node = node.FindNode('flags')
        if flags_node:
            for flag, value in gbb_flag_properties.items():
                if fdt_util.GetBool(flags_node, flag):
                    self.gbb_flags |= value
Example #10
0
 def __init__(self, section, etype, node):
     super().__init__(section, etype, node)
     self._convert_fit = fdt_util.GetBool(self._node, 'convert-fit')
     self._ifwi_entries = OrderedDict()
Example #11
0
 def testGetBool(self):
     self.assertEqual(True, fdt_util.GetBool(self.node, 'boolval'))
     self.assertEqual(False, fdt_util.GetBool(self.node, 'missing'))
     self.assertEqual(True, fdt_util.GetBool(self.node, 'missing', True))
     self.assertEqual(False, fdt_util.GetBool(self.node, 'missing', False))
Example #12
0
 def ReadNode(self):
     super().ReadNode()
     filename = fdt_util.GetString(self._node, 'filename')
     if filename:
         self._filename = filename
     self.allow_repack = fdt_util.GetBool(self._node, 'allow-repack')
Example #13
0
 def __init__(self, section, etype, node):
     super().__init__(section, etype, node)
     self._strip = fdt_util.GetBool(self._node, 'strip')
Example #14
0
 def __init__(self, section, etype, node):
     Entry_blob.__init__(self, section, etype, node)
     self._strip = fdt_util.GetBool(self._node, 'strip')