xref: /openbmc/openpower-vpd-parser/types.hpp (revision 6555e7efc40c305e5c3c8863c3d1793f474ec7e2)
1 #pragma once
2 
3 #include <climits>
4 #include <map>
5 #include <sdbusplus/server.hpp>
6 #include <string>
7 #include <unordered_map>
8 #include <vector>
9 
10 namespace openpower
11 {
12 namespace vpd
13 {
14 
15 /** @brief The OpenPOWER VPD, in binary, is specified as a
16  *         sequence of characters */
17 static_assert((8 == CHAR_BIT), "A byte is not 8 bits!");
18 using Byte = uint8_t;
19 using Binary = std::vector<Byte>;
20 using BIOSAttrValueType = std::variant<int64_t, std::string>;
21 using PendingBIOSAttrItemType =
22     std::pair<std::string, std::tuple<std::string, BIOSAttrValueType>>;
23 using PendingBIOSAttrsType = std::vector<PendingBIOSAttrItemType>;
24 
25 namespace inventory
26 {
27 
28 using Path = std::string;
29 using Property = std::string;
30 using Value = std::variant<bool, size_t, int64_t, std::string, Binary>;
31 using PropertyMap = std::map<Property, Value>;
32 using kwdVpdValueTypes = std::variant<size_t, Binary, std::string>;
33 
34 using Interface = std::string;
35 using InterfaceMap = std::map<Interface, PropertyMap>;
36 
37 using Object = sdbusplus::message::object_path;
38 using ObjectMap = std::map<Object, InterfaceMap>;
39 
40 using VPDfilepath = std::string;
41 using FruIsMotherboard = bool;
42 using FrusMap =
43     std::multimap<Path, std::tuple<VPDfilepath, VPDfilepath, FruIsMotherboard>>;
44 using LocationCode = std::string;
45 using LocationCodeMap = std::unordered_multimap<LocationCode, Path>;
46 using ListOfPaths = std::vector<sdbusplus::message::object_path>;
47 using NodeNumber = uint16_t;
48 using KeywordVpdMap = std::unordered_map<std::string, kwdVpdValueTypes>;
49 
50 using systemType = std::string;
51 using deviceTree = std::string;
52 using deviceTreeMap = std::unordered_map<systemType, deviceTree>;
53 using PelAdditionalData = std::map<std::string, std::string>;
54 using Keyword = std::string;
55 using KeywordData = std::string;
56 using DbusPropertyMap = std::unordered_map<Keyword, KeywordData>;
57 using PelAdditionalData = std::map<std::string, std::string>;
58 using Service = std::string;
59 using MapperResponse =
60     std::map<Path, std::map<Service, std::vector<Interface>>>;
61 using RestoredEeproms = std::tuple<Path, std::string, Keyword, Binary>;
62 using ReplaceableFrus = std::vector<VPDfilepath>;
63 using EssentialFrus = std::vector<Path>;
64 using RecordName = std::string;
65 using KeywordDefault = Binary;
66 using isPELReqOnRestoreFailure = bool;
67 using isMFGResetRequired = bool;
68 using SystemKeywordInfo =
69     std::tuple<Keyword, KeywordDefault, isPELReqOnRestoreFailure,
70                isMFGResetRequired>;
71 
72 /** Map of system backplane records to list of keywords and its related data. {
73  * Record : { Keyword, Default value, Is PEL required on restore failure, Is MFG
74  * reset required }} **/
75 using SystemKeywordsMap =
76     std::unordered_map<RecordName, std::vector<SystemKeywordInfo>>;
77 
78 using GetAllResultType = std::vector<std::pair<Keyword, Value>>;
79 using IntfPropMap = std::map<RecordName, GetAllResultType>;
80 using RecKwValMap =
81     std::unordered_map<RecordName, std::unordered_map<Keyword, Binary>>;
82 } // namespace inventory
83 
84 } // namespace vpd
85 } // namespace openpower