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