Exemple #1
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')
Exemple #2
0
 def _ReadNode(self):
     """Read properties from the section node"""
     self._offset = fdt_util.GetInt(self._node, 'offset')
     self._size = fdt_util.GetInt(self._node, 'size')
     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._pad_before = fdt_util.GetInt(self._node, 'pad-before', 0)
     self._pad_after = fdt_util.GetInt(self._node, 'pad-after', 0)
     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')
Exemple #3
0
 def __init__(self, section, etype, node):
     Entry.__init__(self, section, etype, node)
     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.process_fdt_ready = False
     self.never_complete_process_fdt = fdt_util.GetBool(self._node,
                                             'never-complete-process-fdt')
Exemple #4
0
    def __init__(self, section, etype, node):
        Entry.__init__(self, section, etype, node)
        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.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')

        # 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'a'
Exemple #5
0
 def __init__(self, section, etype, node):
     Entry_section.__init__(self, 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')
Exemple #6
0
 def _ReadSubnodes(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._ifwi_replace = fdt_util.GetBool(node, '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
Exemple #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
Exemple #8
0
 def _ReadNode(self):
     """Read properties from the image node"""
     self._size = fdt_util.GetInt(self._node, 'size')
     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._pad_before = fdt_util.GetInt(self._node, 'pad-before', 0)
     self._pad_after = fdt_util.GetInt(self._node, 'pad-after', 0)
     self._pad_byte = fdt_util.GetInt(self._node, 'pad-byte', 0)
     filename = fdt_util.GetString(self._node, 'filename')
     if filename:
         self._filename = filename
     self._sort = fdt_util.GetBool(self._node, 'sort-by-pos')
     self._end_4gb = fdt_util.GetBool(self._node, 'end-at-4gb')
     if self._end_4gb and not self._size:
         self._Raise("Image size must be provided when using end-at-4gb")
     if self._end_4gb:
         self._skip_at_start = 0x100000000 - self._size
    def ObtainContents(self):
        # 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_pos = sym
        elif not fdt_util.GetBool(self._node, 'optional-ucode'):
            self.Raise('Cannot locate _dt_ucode_base_size symbol in u-boot')

        return Entry_blob.ObtainContents(self)
Exemple #10
0
    def __init__(self, section, etype, node):
        # Put this here to allow entry-docs and help to work without libfdt
        global state
        import state

        Entry_section.__init__(self, 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')
Exemple #11
0
 def _ReadNode(self):
     """Read properties from the image node"""
     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')
     filename = fdt_util.GetString(self._node, 'filename')
     if filename:
         self._filename = filename
    def ObtainContents(self):
        # Figure out where to put the microcode pointer
        fname = tools.GetInputFilename(self.elf_fname)
        args = [['nm', fname], ['grep', '-w', '_dt_ucode_base_size']]
        out = (command.RunPipe(args, capture=True,
                               raise_on_error=False).stdout.splitlines())
        if len(out) == 1:
            self.target_pos = int(out[0].split()[0], 16)
        elif not fdt_util.GetBool(self._node, 'optional-ucode'):
            self.Raise('Cannot locate _dt_ucode_base_size symbol in u-boot')

        return Entry_blob.ObtainContents(self)
Exemple #13
0
    def ReadNode(self):
        """Read entry information from the node

        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.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):
            raise ValueError("Node '%s': Alignment size %s must be a power "
                             "of two" % (self._node.path, 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')
Exemple #14
0
    def __init__(self, section, etype, node):
        Entry.__init__(self, 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.iteritems():
                if fdt_util.GetBool(flags_node, flag):
                    self.gbb_flags |= value
Exemple #15
0
 def __init__(self, section, etype, node):
     Entry_blob.__init__(self, section, etype, node)
     self._strip = fdt_util.GetBool(self._node, 'strip')
Exemple #16
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))
Exemple #17
0
 def __init__(self, section, etype, node):
     Entry_blob.__init__(self, section, etype, node)
     self._convert_fit = fdt_util.GetBool(self._node, 'convert-fit')
     self._ifwi_entries = OrderedDict()
Exemple #18
0
 def ReadNode(self):
     section.Entry_section.ReadNode(self)
     filename = fdt_util.GetString(self._node, 'filename')
     if filename:
         self._filename = filename
     self.allow_repack = fdt_util.GetBool(self._node, 'allow-repack')