def write(self):
        fsp_bct = FspBct()
        with FileHarness(None, self._raw.write()) as (relocated, raw):
            fsp_bct.relocate(raw, relocated, self._fsp_base_address)

            with open(relocated, "rb") as data:
                return data.read()
 def compute_min_size_content(self):
     self.handle_children()
     objcopy = Objcopy()
     # Assume the final linking of the object won't change its size.
     with FileHarness(None, self._data.write()) as [binary, partial]:
         objcopy.copy(partial, binary, "-O", "binary")
         with open(binary, "rb") as data:
             return len(data.read())
Exemple #3
0
    def _generate_vblock(self, to_sign):
        vbutil = VbutilFirmware()
        with FileHarness(None, to_sign, self._keyblock.write(),
                         self._signprivate.write(),
                         self._kernelkey.write()) as files:
            vblock, to_sign, keyblock, signprivate, kernelkey = files
            vbutil.vblock(vblock, keyblock, signprivate, self._version,
                          to_sign, kernelkey, self._flags)

            with open(vblock, "rb") as data:
                return data.read()
Exemple #4
0
    def write(self):
        gbb_utility = GbbUtility()
        with FileHarness(None, self._bmpfv.write(), self._rootkey.write(),
                         self._recoverykey.write()) as files:
            gbb, bmpfv, rootkey, recoverykey = files
            sizes = [0x100, 0x1000, self.placed_size - 0x2180, 0x1000]
            gbb_utility.create(sizes, gbb)
            gbb_utility.set(self._hwid, self._flags, bmpfv, rootkey,
                            recoverykey)

            with open(gbb, "rb") as data:
                return data.read()
    def write(self):
        linker_script = _linker_script_template.format(
                base=(self.placed_offset + self._image_base))
        objcopy = Objcopy()
        gcc = GccLd()
        with FileHarness(None, None, linker_script,
                         self._data.write()) as files:
            binary, elf, script, partial = files
            # Do the final link to prepare the image for its new home.
            args = [partial, "-T", script, "-Wl,--no-gc-sections"]
            # Add in the extra symbols we've been supplied.
            defsym_template = "-Wl,--defsym={name}={value:#x}"
            for name, value in self._extra_symbols.iteritems():
                args.append(defsym_template.format(name=name, value=value))
            gcc.link(elf, *args)

            # Convert it to a flat binary.
            objcopy.copy(elf, binary, "-O", "binary")
            with open(binary, "rb") as data:
                return data.read()
Exemple #6
0
    def write(self):
        blobs = []
        if self._base:
            blobs.append(self._base.write())
        else:
            blobs.append(None)
            if not self._bootblock:
                raise ValueError("No bootblock specified")
            blobs.append(self._bootblock.write())

        with FileHarness(*blobs) as files:
            if self._base:
                [base] = files
                cbfstool = Cbfstool(base)
            else:
                base, bootblock = files
                cbfstool = Cbfstool()
                cbfstool.create(base, self.placed_size, bootblock, self._arch,
                                self._align, self._offset)
            for f in self._files:
                f.install(cbfstool)
            with open(base, "rb") as data:
                return data.read()
Exemple #7
0
 def install(self, cbfstool):
     with FileHarness(self._data.write()) as [data]:
         cbfstool.add_payload(data, self._name, self._compression,
                              self._base)
Exemple #8
0
 def install(self, cbfstool):
     with FileHarness(self._data.write()) as [data]:
         cbfstool.add(data, self._name, self._type, self._base)