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