xref: /openbmc/pldm/common/types.hpp (revision 3d34b2c2)
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 Request = std::vector<uint8_t>;
20 using Response = std::vector<uint8_t>;
21 using Command = uint8_t;
22 
23 namespace dbus
24 {
25 
26 using ObjectPath = std::string;
27 using Service = std::string;
28 using Interface = std::string;
29 using Interfaces = std::vector<std::string>;
30 using Property = std::string;
31 using PropertyType = std::string;
32 using Value =
33     std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t,
34                  uint64_t, double, std::string, std::vector<uint8_t>>;
35 
36 using PropertyMap = std::map<Property, Value>;
37 using InterfaceMap = std::map<Interface, PropertyMap>;
38 using ObjectValueTree = std::map<sdbusplus::message::object_path, InterfaceMap>;
39 
40 } // namespace dbus
41 
42 namespace fw_update
43 {
44 
45 // Descriptor definition
46 using DescriptorType = uint16_t;
47 using DescriptorData = std::vector<uint8_t>;
48 using VendorDefinedDescriptorTitle = std::string;
49 using VendorDefinedDescriptorData = std::vector<uint8_t>;
50 using VendorDefinedDescriptorInfo =
51     std::tuple<VendorDefinedDescriptorTitle, VendorDefinedDescriptorData>;
52 using Descriptors =
53     std::map<DescriptorType,
54              std::variant<DescriptorData, VendorDefinedDescriptorInfo>>;
55 
56 using DescriptorMap = std::unordered_map<eid, Descriptors>;
57 
58 // Component information
59 using CompClassification = uint16_t;
60 using CompIdentifier = uint16_t;
61 using CompKey = std::pair<CompClassification, CompIdentifier>;
62 using CompClassificationIndex = uint8_t;
63 using ComponentInfo = std::map<CompKey, CompClassificationIndex>;
64 using ComponentInfoMap = std::unordered_map<eid, ComponentInfo>;
65 
66 // PackageHeaderInformation
67 using PackageHeaderSize = size_t;
68 using PackageVersion = std::string;
69 using ComponentBitmapBitLength = uint16_t;
70 using PackageHeaderChecksum = uint32_t;
71 
72 // FirmwareDeviceIDRecords
73 using DeviceIDRecordCount = uint8_t;
74 using DeviceUpdateOptionFlags = std::bitset<32>;
75 using ApplicableComponents = std::vector<size_t>;
76 using ComponentImageSetVersion = std::string;
77 using FirmwareDevicePackageData = std::vector<uint8_t>;
78 using FirmwareDeviceIDRecord =
79     std::tuple<DeviceUpdateOptionFlags, ApplicableComponents,
80                ComponentImageSetVersion, Descriptors,
81                FirmwareDevicePackageData>;
82 using FirmwareDeviceIDRecords = std::vector<FirmwareDeviceIDRecord>;
83 
84 // ComponentImageInformation
85 using ComponentImageCount = uint16_t;
86 using CompComparisonStamp = uint32_t;
87 using CompOptions = std::bitset<16>;
88 using ReqCompActivationMethod = std::bitset<16>;
89 using CompLocationOffset = uint32_t;
90 using CompSize = uint32_t;
91 using CompVersion = std::string;
92 using ComponentImageInfo =
93     std::tuple<CompClassification, CompIdentifier, CompComparisonStamp,
94                CompOptions, ReqCompActivationMethod, CompLocationOffset,
95                CompSize, CompVersion>;
96 using ComponentImageInfos = std::vector<ComponentImageInfo>;
97 
98 enum class ComponentImageInfoPos : size_t
99 {
100     CompClassificationPos = 0,
101     CompIdentifierPos = 1,
102     CompComparisonStampPos = 2,
103     CompOptionsPos = 3,
104     ReqCompActivationMethodPos = 4,
105     CompLocationOffsetPos = 5,
106     CompSizePos = 6,
107     CompVersionPos = 7,
108 };
109 
110 } // namespace fw_update
111 
112 namespace pdr
113 {
114 
115 using EID = uint8_t;
116 using TerminusHandle = uint16_t;
117 using TerminusID = uint8_t;
118 using SensorID = uint16_t;
119 using EntityType = uint16_t;
120 using EntityInstance = uint16_t;
121 using ContainerID = uint16_t;
122 using StateSetId = uint16_t;
123 using CompositeCount = uint8_t;
124 using SensorOffset = uint8_t;
125 using EventState = uint8_t;
126 using TerminusValidity = uint8_t;
127 
128 //!< Subset of the State Set that is supported by a effecter/sensor
129 using PossibleStates = std::set<uint8_t>;
130 //!< Subset of the State Set that is supported by each effecter/sensor in a
131 //!< composite efffecter/sensor
132 using CompositeSensorStates = std::vector<PossibleStates>;
133 using EntityInfo = std::tuple<ContainerID, EntityType, EntityInstance>;
134 using SensorInfo = std::tuple<EntityInfo, CompositeSensorStates>;
135 
136 } // namespace pdr
137 
138 } // namespace pldm
139