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