def PackageMsFmpHeader(InputBin, OutputBin, VersionInt, LsvInt, DepList = []): # NOTE: Crash if deps are passed. Return a useful error. # Currently not ported to the new tooling. if len(DepList) > 0: raise RuntimeError("PackageMsFmpHeader has not been ported to support dependencies yet!") #append depedency if supplied # for dep in DepList: # depGuid = dep[0] # depIndex = int(dep[1]) # depMinVer = hex(dep[2]) # depFlag = hex(dep[3]) # logging.debug("Adding a Dependency:\n\tFMP Guid: %s \nt\tFmp Descriptor Index: %d \n\tFmp DepVersion: %s \n\tFmp Flags: %s\n" % (depGuid, depIndex, depMinVer, depFlag)) # params += " --dep " + depGuid + " " + str(depIndex) + " " + depMinVer + " " + depFlag # raise Exception("GenMsPayloadHeader Failed with errorcode %d" % ret) # Attempt to write the payload to the file. # This would normally with open(InputBin, 'rb') as in_file: payload_data = in_file.read() fmp_header = FmpPayloadHeaderClass() fmp_header.FwVersion = VersionInt fmp_header.LowestSupportedVersion = LsvInt fmp_header.Payload = payload_data with open(OutputBin, 'wb') as out_file: out_file.write(fmp_header.Encode()) return 0
try: if args.Verbose: print ('Read binary input file {File}'.format (File = args.InputFile.name)) Buffer = args.InputFile.read () args.InputFile.close () except: print ('GenerateCapsule: error: can not read binary input file {File}'.format (File = args.InputFile.name)) sys.exit (1) # # Create objects # UefiCapsuleHeader = UefiCapsuleHeaderClass () FmpCapsuleHeader = FmpCapsuleHeaderClass () FmpAuthHeader = FmpAuthHeaderClass () FmpPayloadHeader = FmpPayloadHeaderClass () if args.Encode: Result = Buffer if UseSignTool or UseOpenSsl: try: FmpPayloadHeader.FwVersion = args.FwVersion FmpPayloadHeader.LowestSupportedVersion = args.LowestSupportedVersion FmpPayloadHeader.Payload = Result Result = FmpPayloadHeader.Encode () if args.Verbose: FmpPayloadHeader.DumpInfo () except: print ('GenerateCapsule: error: can not encode FMP Payload Header') sys.exit (1)