1 #pragma once 2 3 #include <sdbusplus/message/types.hpp> 4 5 #include <bitset> 6 #include <cstdint> 7 #include <map> 8 #include <set> 9 #include <string> 10 #include <unordered_map> 11 #include <variant> 12 #include <vector> 13 14 namespace pldm 15 { 16 17 using Availability = bool; 18 using eid = uint8_t; 19 using UUID = std::string; 20 using Request = std::vector<uint8_t>; 21 using Response = std::vector<uint8_t>; 22 using MCTPMsgTypes = std::vector<uint8_t>; 23 using Command = uint8_t; 24 25 /** @brief MCTP Endpoint Medium type in string 26 * Reserved for future purpose 27 */ 28 29 using MctpMedium = std::string; 30 /** @brief Type definition of MCTP Network Index. 31 * uint32_t is used as defined in MCTP Endpoint D-Bus Interface 32 */ 33 using NetworkId = uint32_t; 34 35 /** @brief Type definition of MCTP interface information between two endpoints. 36 * eid : Endpoint EID in byte. Defined to match with MCTP D-Bus 37 * interface 38 * UUID : Endpoint UUID which is used to different the endpoints 39 * MctpMedium: Endpoint MCTP Medium info (Resersed) 40 * NetworkId: MCTP network index 41 */ 42 using MctpInfo = std::tuple<eid, UUID, MctpMedium, NetworkId>; 43 44 /** @brief Type definition of MCTP endpoint D-Bus properties in 45 * xyz.openbmc_project.MCTP.Endpoint D-Bus interface. 46 * 47 * NetworkId: MCTP network index 48 * eid : Endpoint EID in byte. Defined to match with MCTP D-Bus 49 * interface 50 * MCTPMsgTypes: MCTP message types 51 */ 52 using MctpEndpointProps = std::tuple<NetworkId, eid, MCTPMsgTypes>; 53 54 /** @brief Type defined for list of MCTP interface information 55 */ 56 using MctpInfos = std::vector<MctpInfo>; 57 58 /** 59 * In `Table 2 - Special endpoint IDs` of DSP0236. 60 * EID from 1 to 7 is reserved EID. So the start valid EID is 8 61 */ 62 #define MCTP_START_VALID_EID 8 63 constexpr uint8_t BmcMctpEid = 8; 64 65 #define PLDM_PLATFORM_GETPDR_MAX_RECORD_BYTES 1024 66 /* default the max event message buffer size BMC supported to 4K bytes */ 67 #define PLDM_PLATFORM_EVENT_MSG_MAX_BUFFER_SIZE 4096 68 /* DSP0248 section16.9 EventMessageBufferSize Command, the default message 69 * buffer size is 256 bytes 70 */ 71 #define PLDM_PLATFORM_DEFAULT_MESSAGE_BUFFER_SIZE 256 72 73 namespace dbus 74 { 75 76 using ObjectPath = std::string; 77 using Service = std::string; 78 using Interface = std::string; 79 using Interfaces = std::vector<std::string>; 80 using Property = std::string; 81 using PropertyType = std::string; 82 using Value = 83 std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, 84 uint64_t, double, std::string, std::vector<uint8_t>>; 85 86 using PropertyMap = std::map<Property, Value>; 87 using InterfaceMap = std::map<Interface, PropertyMap>; 88 using ObjectValueTree = std::map<sdbusplus::message::object_path, InterfaceMap>; 89 90 } // namespace dbus 91 92 namespace fw_update 93 { 94 95 // Descriptor definition 96 using DescriptorType = uint16_t; 97 using DescriptorData = std::vector<uint8_t>; 98 using VendorDefinedDescriptorTitle = std::string; 99 using VendorDefinedDescriptorData = std::vector<uint8_t>; 100 using VendorDefinedDescriptorInfo = 101 std::tuple<VendorDefinedDescriptorTitle, VendorDefinedDescriptorData>; 102 using Descriptors = 103 std::map<DescriptorType, 104 std::variant<DescriptorData, VendorDefinedDescriptorInfo>>; 105 106 using DescriptorMap = std::unordered_map<eid, Descriptors>; 107 108 // Component information 109 using CompClassification = uint16_t; 110 using CompIdentifier = uint16_t; 111 using CompKey = std::pair<CompClassification, CompIdentifier>; 112 using CompClassificationIndex = uint8_t; 113 using ComponentInfo = std::map<CompKey, CompClassificationIndex>; 114 using ComponentInfoMap = std::unordered_map<eid, ComponentInfo>; 115 116 // PackageHeaderInformation 117 using PackageHeaderSize = size_t; 118 using PackageVersion = std::string; 119 using ComponentBitmapBitLength = uint16_t; 120 using PackageHeaderChecksum = uint32_t; 121 122 // FirmwareDeviceIDRecords 123 using DeviceIDRecordCount = uint8_t; 124 using DeviceUpdateOptionFlags = std::bitset<32>; 125 using ApplicableComponents = std::vector<size_t>; 126 using ComponentImageSetVersion = std::string; 127 using FirmwareDevicePackageData = std::vector<uint8_t>; 128 using FirmwareDeviceIDRecord = 129 std::tuple<DeviceUpdateOptionFlags, ApplicableComponents, 130 ComponentImageSetVersion, Descriptors, 131 FirmwareDevicePackageData>; 132 using FirmwareDeviceIDRecords = std::vector<FirmwareDeviceIDRecord>; 133 134 // ComponentImageInformation 135 using ComponentImageCount = uint16_t; 136 using CompComparisonStamp = uint32_t; 137 using CompOptions = std::bitset<16>; 138 using ReqCompActivationMethod = std::bitset<16>; 139 using CompLocationOffset = uint32_t; 140 using CompSize = uint32_t; 141 using CompVersion = std::string; 142 using ComponentImageInfo = 143 std::tuple<CompClassification, CompIdentifier, CompComparisonStamp, 144 CompOptions, ReqCompActivationMethod, CompLocationOffset, 145 CompSize, CompVersion>; 146 using ComponentImageInfos = std::vector<ComponentImageInfo>; 147 148 enum class ComponentImageInfoPos : size_t 149 { 150 CompClassificationPos = 0, 151 CompIdentifierPos = 1, 152 CompComparisonStampPos = 2, 153 CompOptionsPos = 3, 154 ReqCompActivationMethodPos = 4, 155 CompLocationOffsetPos = 5, 156 CompSizePos = 6, 157 CompVersionPos = 7, 158 }; 159 160 } // namespace fw_update 161 162 namespace pdr 163 { 164 165 using EID = uint8_t; 166 using TerminusHandle = uint16_t; 167 using TerminusID = uint8_t; 168 using SensorID = uint16_t; 169 using EntityType = uint16_t; 170 using EntityInstance = uint16_t; 171 using ContainerID = uint16_t; 172 using StateSetId = uint16_t; 173 using CompositeCount = uint8_t; 174 using SensorOffset = uint8_t; 175 using EventState = uint8_t; 176 using TerminusValidity = uint8_t; 177 178 //!< Subset of the State Set that is supported by a effecter/sensor 179 using PossibleStates = std::set<uint8_t>; 180 //!< Subset of the State Set that is supported by each effecter/sensor in a 181 //!< composite efffecter/sensor 182 using CompositeSensorStates = std::vector<PossibleStates>; 183 using EntityInfo = std::tuple<ContainerID, EntityType, EntityInstance>; 184 using SensorInfo = 185 std::tuple<EntityInfo, CompositeSensorStates, std::vector<StateSetId>>; 186 187 } // namespace pdr 188 189 } // namespace pldm 190