1 #pragma once
2 
3 #include "common/utils.hpp"
4 #include "libpldmresponder/fru.hpp"
5 #include "libpldmresponder/oem_handler.hpp"
6 
7 #include <libpldm/oem/ibm/fru.h>
8 
9 namespace pldm
10 {
11 namespace responder
12 {
13 using ObjectPath = std::string;
14 using AssociatedEntityMap = std::map<ObjectPath, pldm_entity>;
15 
16 namespace oem_ibm_fru
17 {
18 
19 // structure of the PCIE config space data
20 struct PcieConfigSpaceData
21 {
22     uint16_t vendorId;
23     uint16_t deviceId;
24     uint32_t first_reserved;
25     uint8_t revisionId;
26     std::array<uint8_t, 3> classCode;
27     uint32_t second_reserved[8];
28     uint16_t subSystemVendorId;
29     uint16_t subSystemId;
30     uint32_t last_reserved[4];
31 
32 } __attribute__((packed));
33 
34 class Handler : public oem_fru::Handler
35 {
36   public:
37     Handler(pldm_pdr* repo) : pdrRepo(repo) {}
38 
39     /** @brief Method to set the fru handler in the
40      *    oem_ibm_handler class
41      *
42      *  @param[in] handler - pointer to PLDM platform handler
43      */
44     void setIBMFruHandler(pldm::responder::fru::Handler* handler);
45 
46     /** @brief Process OEM FRU table
47      *
48      *  @param[in] fruData - the data of the fru records
49      *
50      *  @return success or failure
51      */
52     int processOEMFRUTable(const std::vector<uint8_t>& fruData);
53 
54     virtual const AssociatedEntityMap& getAssociateEntityMap()
55     {
56         return fruHandler->getAssociateEntityMap();
57     }
58 
59     ~Handler() = default;
60 
61   private:
62     /** @brief pointer to BMC's primary PDR repo */
63     const pldm_pdr* pdrRepo;
64 
65     pldm::responder::fru::Handler* fruHandler; //!< pointer to PLDM fru handler
66 
67     /** @brief update the DBus property
68      *
69      *  @param[in] fruRSI - fru record set identifier
70      *  @param[in] fruAssociationMap - the dbus path to pldm entity stored while
71      *                                 creating the pldm fru records
72      *  @param[in] vendorId - the vendor ID
73      *  @param[in] deviceId - the device ID
74      *  @param[in] revisionId - the revision ID
75      *  @param[in] classCode - the class Code
76      *  @param[in] subSystemVendorId - the subSystemVendor ID
77      *  @param[in] subSystemId - the subSystem ID
78      */
79     void updateDBusProperty(
80         uint16_t fruRSI, const AssociatedEntityMap& fruAssociationMap,
81         const std::string& vendorId, const std::string& deviceId,
82         const std::string& revisionId, const std::string& classCode,
83         const std::string& subSystemVendorId, const std::string& subSystemId);
84 
85     /** @brief DBus Map update
86      *
87      *  @param[in] adapterObjectPath - the fru object path
88      *  @param[in] propertyName - the fru property name
89      *  @param[in] propValue - the fru property value
90      */
91     void dbus_map_update(const std::string& adapterObjectPath,
92                          const std::string& propertyName,
93                          const std::string& propValue);
94 };
95 
96 } // namespace oem_ibm_fru
97 } // namespace responder
98 } // namespace pldm
99