MCPcopy Create free account
hub / github.com/LongSoft/UEFITool / constructPadFile

Method constructPadFile

ffsengine.cpp:3017–3048  ·  view source on GitHub ↗

Construction routines

Source from the content-addressed store, hash-verified

3015
3016// Construction routines
3017UINT8 FfsEngine::constructPadFile(const QByteArray &guid, const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad)
3018{
3019 if (size < sizeof(EFI_FFS_FILE_HEADER) || erasePolarity == ERASE_POLARITY_UNKNOWN)
3020 return ERR_INVALID_PARAMETER;
3021
3022 if (size >= 0xFFFFFF) // TODO: large file support
3023 return ERR_INVALID_PARAMETER;
3024
3025 pad = QByteArray(size - guid.size(), erasePolarity == ERASE_POLARITY_TRUE ? '\xFF' : '\x00');
3026 pad.prepend(guid);
3027 EFI_FFS_FILE_HEADER* header = (EFI_FFS_FILE_HEADER*)pad.data();
3028 uint32ToUint24(size, header->Size);
3029 header->Attributes = 0x00;
3030 header->Type = EFI_FV_FILETYPE_PAD;
3031 header->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;
3032 // Invert state bits if erase polarity is true
3033 if (erasePolarity == ERASE_POLARITY_TRUE)
3034 header->State = ~header->State;
3035
3036 // Calculate header checksum
3037 header->IntegrityCheck.Checksum.Header = 0;
3038 header->IntegrityCheck.Checksum.File = 0;
3039 header->IntegrityCheck.Checksum.Header = calculateChecksum8((const UINT8*)header, sizeof(EFI_FFS_FILE_HEADER) - 1);
3040
3041 // Set data checksum
3042 if (revision == 1)
3043 header->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
3044 else
3045 header->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM2;
3046
3047 return ERR_SUCCESS;
3048}
3049
3050UINT8 FfsEngine::reconstructIntelImage(const QModelIndex& index, QByteArray& reconstructed)
3051{

Callers

nothing calls this directly

Calls 3

uint32ToUint24Function · 0.85
calculateChecksum8Function · 0.85
dataMethod · 0.45

Tested by

no test coverage detected