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)
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)
def ObtainContents(self): Entry_blob.ObtainContents(self) # If the image does not need microcode, there is nothing to do ucode_dest_entry = self.image.FindEntryType( 'u-boot-spl-with-ucode-ptr') if not ucode_dest_entry or not ucode_dest_entry.target_pos: ucode_dest_entry = self.image.FindEntryType( 'u-boot-with-ucode-ptr') if not ucode_dest_entry or not ucode_dest_entry.target_pos: return True # Create a new file to hold the copied device tree dtb_name = 'u-boot-dtb-with-ucode.dtb' fname = tools.GetOutputFilename(dtb_name) with open(fname, 'wb') as fd: fd.write(self.data) # Remove the microcode fdt = fdt_select.FdtScan(fname) fdt.Scan() ucode = fdt.GetNode('/microcode') if not ucode: raise self.Raise("No /microcode node found in '%s'" % fname) # There's no need to collate it (move all microcode into one place) # if we only have one chunk of microcode. self.collate = len(ucode.subnodes) > 1 for node in ucode.subnodes: data_prop = node.props.get('data') if data_prop: self.ucode_data += ''.join(data_prop.bytes) if not self.collate: poffset = data_prop.GetOffset() if poffset is None: # We cannot obtain a property offset. Collate instead. self.collate = True else: # Find the offset in the device tree of the ucode data self.ucode_offset = poffset + 12 self.ucode_size = len(data_prop.bytes) if self.collate: prop = node.DeleteProp('data') if self.collate: fdt.Pack() fdt.Flush() # Make this file the contents of this entry self._pathname = fname self.ReadContents() return True
def ObtainContents(self): # Call the base class just in case it does something important. Entry_blob.ObtainContents(self) self._pathname = control.GetFdtPath(self._filename) self.ReadBlobContents() if self.ucode: for node in self.ucode.subnodes: data_prop = node.props.get('data') if data_prop and not self.collate: # Find the offset in the device tree of the ucode data self.ucode_offset = data_prop.GetOffset() + 12 self.ucode_size = len(data_prop.bytes) self.ready = True return True