xref: /openbmc/pldm/common/types.hpp (revision de2a132a)
1 #pragma once
2 
3 #include <stdint.h>
4 
5 #include <sdbusplus/message/types.hpp>
6 
7 #include <bitset>
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <unordered_map>
12 #include <variant>
13 #include <vector>
14 
15 namespace pldm
16 {
17 
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 
53 #define PLDM_PLATFORM_GETPDR_MAX_RECORD_BYTES 1024
54 
55 namespace dbus
56 {
57 
58 using ObjectPath = std::string;
59 using Service = std::string;
60 using Interface = std::string;
61 using Interfaces = std::vector<std::string>;
62 using Property = std::string;
63 using PropertyType = std::string;
64 using Value =
65     std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t,
66                  uint64_t, double, std::string, std::vector<uint8_t>>;
67 
68 using PropertyMap = std::map<Property, Value>;
69 using InterfaceMap = std::map<Interface, PropertyMap>;
70 using ObjectValueTree = std::map<sdbusplus::message::object_path, InterfaceMap>;
71 
72 } // namespace dbus
73 
74 namespace fw_update
75 {
76 
77 // Descriptor definition
78 using DescriptorType = uint16_t;
79 using DescriptorData = std::vector<uint8_t>;
80 using VendorDefinedDescriptorTitle = std::string;
81 using VendorDefinedDescriptorData = std::vector<uint8_t>;
82 using VendorDefinedDescriptorInfo =
83     std::tuple<VendorDefinedDescriptorTitle, VendorDefinedDescriptorData>;
84 using Descriptors =
85     std::map<DescriptorType,
86              std::variant<DescriptorData, VendorDefinedDescriptorInfo>>;
87 
88 using DescriptorMap = std::unordered_map<eid, Descriptors>;
89 
90 // Component information
91 using CompClassification = uint16_t;
92 using CompIdentifier = uint16_t;
93 using CompKey = std::pair<CompClassification, CompIdentifier>;
94 using CompClassificationIndex = uint8_t;
95 using ComponentInfo = std::map<CompKey, CompClassificationIndex>;
96 using ComponentInfoMap = std::unordered_map<eid, ComponentInfo>;
97 
98 // PackageHeaderInformation
99 using PackageHeaderSize = size_t;
100 using PackageVersion = std::string;
101 using ComponentBitmapBitLength = uint16_t;
102 using PackageHeaderChecksum = uint32_t;
103 
104 // FirmwareDeviceIDRecords
105 using DeviceIDRecordCount = uint8_t;
106 using DeviceUpdateOptionFlags = std::bitset<32>;
107 using ApplicableComponents = std::vector<size_t>;
108 using ComponentImageSetVersion = std::string;
109 using FirmwareDevicePackageData = std::vector<uint8_t>;
110 using FirmwareDeviceIDRecord =
111     std::tuple<DeviceUpdateOptionFlags, ApplicableComponents,
112                ComponentImageSetVersion, Descriptors,
113                FirmwareDevicePackageData>;
114 using FirmwareDeviceIDRecords = std::vector<FirmwareDeviceIDRecord>;
115 
116 // ComponentImageInformation
117 using ComponentImageCount = uint16_t;
118 using CompComparisonStamp = uint32_t;
119 using CompOptions = std::bitset<16>;
120 using ReqCompActivationMethod = std::bitset<16>;
121 using CompLocationOffset = uint32_t;
122 using CompSize = uint32_t;
123 using CompVersion = std::string;
124 using ComponentImageInfo =
125     std::tuple<CompClassification, CompIdentifier, CompComparisonStamp,
126                CompOptions, ReqCompActivationMethod, CompLocationOffset,
127                CompSize, CompVersion>;
128 using ComponentImageInfos = std::vector<ComponentImageInfo>;
129 
130 enum class ComponentImageInfoPos : size_t
131 {
132     CompClassificationPos = 0,
133     CompIdentifierPos = 1,
134     CompComparisonStampPos = 2,
135     CompOptionsPos = 3,
136     ReqCompActivationMethodPos = 4,
137     CompLocationOffsetPos = 5,
138     CompSizePos = 6,
139     CompVersionPos = 7,
140 };
141 
142 } // namespace fw_update
143 
144 namespace pdr
145 {
146 
147 using EID = uint8_t;
148 using TerminusHandle = uint16_t;
149 using TerminusID = uint8_t;
150 using SensorID = uint16_t;
151 using EntityType = uint16_t;
152 using EntityInstance = uint16_t;
153 using ContainerID = uint16_t;
154 using StateSetId = uint16_t;
155 using CompositeCount = uint8_t;
156 using SensorOffset = uint8_t;
157 using EventState = uint8_t;
158 using TerminusValidity = uint8_t;
159 
160 //!< Subset of the State Set that is supported by a effecter/sensor
161 using PossibleStates = std::set<uint8_t>;
162 //!< Subset of the State Set that is supported by each effecter/sensor in a
163 //!< composite efffecter/sensor
164 using CompositeSensorStates = std::vector<PossibleStates>;
165 using EntityInfo = std::tuple<ContainerID, EntityType, EntityInstance>;
166 using SensorInfo =
167     std::tuple<EntityInfo, CompositeSensorStates, std::vector<StateSetId>>;
168 
169 } // namespace pdr
170 
171 } // namespace pldm
172