/* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (C) 2018-2019, Intel Corporation. */ #ifndef _PLDMFW_PRIVATE_H_ #define _PLDMFW_PRIVATE_H_ /* The following data structures define the layout of a firmware binary * following the "PLDM For Firmware Update Specification", DMTF standard * #DSP0267. * * pldmfw.c uses these structures to implement a simple engine that will parse * a fw binary file in this format and perform a firmware update for a given * device. * * Due to the variable sized data layout, alignment of fields within these * structures is not guaranteed when reading. For this reason, all multi-byte * field accesses should be done using the unaligned access macros. * Additionally, the standard specifies that multi-byte fields are in * LittleEndian format. * * The structure definitions are not made public, in order to keep direct * accesses within code that is prepared to deal with the limitation of * unaligned access. */ /* UUID for PLDM firmware packages: f018878c-cb7d-4943-9800-a02f059aca02 */ static const uuid_t pldm_firmware_header_id = …; /* Revision number of the PLDM header format this code supports */ #define PACKAGE_HEADER_FORMAT_REVISION … /* timestamp104 structure defined in PLDM Base specification */ #define PLDM_TIMESTAMP_SIZE … struct __pldm_timestamp { … } __packed __aligned(…); /* Package Header Information */ struct __pldm_header { … } __packed __aligned(…); /* Firmware Device ID Record */ struct __pldmfw_record_info { … } __packed __aligned(…); /* Firmware Descriptor Definition */ struct __pldmfw_desc_tlv { … } __aligned(…); /* Firmware Device Identification Area */ struct __pldmfw_record_area { … } __aligned(…); /* Individual Component Image Information */ struct __pldmfw_component_info { … } __packed __aligned(…); /* Component Image Information Area */ struct __pldmfw_component_area { … } __aligned(…); /** * pldm_first_desc_tlv * @start: byte offset of the start of the descriptor TLVs * * Converts the starting offset of the descriptor TLVs into a pointer to the * first descriptor. */ #define pldm_first_desc_tlv(start) … /** * pldm_next_desc_tlv * @desc: pointer to a descriptor TLV * * Finds the pointer to the next descriptor following a given descriptor */ #define pldm_next_desc_tlv(desc) … /** * pldm_for_each_desc_tlv * @i: variable to store descriptor index * @desc: variable to store descriptor pointer * @start: byte offset of the start of the descriptors * @count: the number of descriptors * * for loop macro to iterate over all of the descriptors of a given PLDM * record. */ #define pldm_for_each_desc_tlv(i, desc, start, count) … /** * pldm_first_record * @start: byte offset of the start of the PLDM records * * Converts a starting offset of the PLDM records into a pointer to the first * record. */ #define pldm_first_record(start) … /** * pldm_next_record * @record: pointer to a PLDM record * * Finds a pointer to the next record following a given record */ #define pldm_next_record(record) … /** * pldm_for_each_record * @i: variable to store record index * @record: variable to store record pointer * @start: byte offset of the start of the records * @count: the number of records * * for loop macro to iterate over all of the records of a PLDM file. */ #define pldm_for_each_record(i, record, start, count) … /** * pldm_first_component * @start: byte offset of the start of the PLDM components * * Convert a starting offset of the PLDM components into a pointer to the * first component */ #define pldm_first_component(start) … /** * pldm_next_component * @component: pointer to a PLDM component * * Finds a pointer to the next component following a given component */ #define pldm_next_component(component) … /** * pldm_for_each_component * @i: variable to store component index * @component: variable to store component pointer * @start: byte offset to the start of the first component * @count: the number of components * * for loop macro to iterate over all of the components of a PLDM file. */ #define pldm_for_each_component(i, component, start, count) … #endif