blob: 2a6eed09f2fe503cbdca871ee2b0bb653396cf88 [file] [log] [blame]
vishwac93d6d42015-12-16 11:55:16 -06001#ifndef __IPMI_FRU_AREA_H__
2#define __IPMI_FRU_AREA_H__
3
Ratan Gupta19c617b2017-02-10 15:39:40 +05304#include "frup.hpp"
Matthew Barth155c34f2016-10-18 14:33:17 -05005#include "writefrudata.hpp"
vishwac93d6d42015-12-16 11:55:16 -06006
Patrick Ventureb4c333f2018-10-20 20:16:39 -07007#include <cstdint>
Patrick Venturec9508db2018-10-16 17:18:43 -07008#include <memory>
9#include <string>
10#include <vector>
11
Patrick Ventureb4c333f2018-10-20 20:16:39 -070012using std::uint8_t;
13
Patrick Venture9eb82cf2018-10-20 19:36:01 -070014class IPMIFruArea
vishwac93d6d42015-12-16 11:55:16 -060015{
Patrick Venturec9508db2018-10-16 17:18:43 -070016 private:
17 // Unique way of identifying a FRU
Patrick Ventureb9d33732018-10-20 20:41:57 -070018 uint8_t fruid = 0;
vishwac93d6d42015-12-16 11:55:16 -060019
Patrick Venturec9508db2018-10-16 17:18:43 -070020 // Type of the fru matching offsets in common header
Patrick Ventureb9d33732018-10-20 20:41:57 -070021 ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE;
vishwac93d6d42015-12-16 11:55:16 -060022
Patrick Venturec9508db2018-10-16 17:18:43 -070023 // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
Patrick Ventureb9d33732018-10-20 20:41:57 -070024 std::string name;
vishwac93d6d42015-12-16 11:55:16 -060025
Patrick Venturec9508db2018-10-16 17:18:43 -070026 // Length of a specific fru area.
Patrick Ventureb9d33732018-10-20 20:41:57 -070027 size_t len = 0;
vishwac93d6d42015-12-16 11:55:16 -060028
Patrick Venturec9508db2018-10-16 17:18:43 -070029 // Special bit for BMC readable eeprom only.
Patrick Ventureb9d33732018-10-20 20:41:57 -070030 bool bmc_fru = false;
vishwac93d6d42015-12-16 11:55:16 -060031
Patrick Venturec9508db2018-10-16 17:18:43 -070032 // If a FRU is physically present.
Patrick Ventureb9d33732018-10-20 20:41:57 -070033 bool isPresent = false;
vishwac93d6d42015-12-16 11:55:16 -060034
Patrick Venturec9508db2018-10-16 17:18:43 -070035 // Whether a particular area is valid ?
Patrick Ventureb9d33732018-10-20 20:41:57 -070036 bool isValid = false;
vishwac93d6d42015-12-16 11:55:16 -060037
Patrick Venturec9508db2018-10-16 17:18:43 -070038 // Actual area data.
Patrick Ventureb9d33732018-10-20 20:41:57 -070039 uint8_t* data = nullptr;
vishwac93d6d42015-12-16 11:55:16 -060040
Patrick Venturec9508db2018-10-16 17:18:43 -070041 // fru inventory dbus name
Patrick Ventureb9d33732018-10-20 20:41:57 -070042 std::string bus_name;
vishwac93d6d42015-12-16 11:55:16 -060043
Patrick Venturec9508db2018-10-16 17:18:43 -070044 // fru inventory dbus object path
Patrick Ventureb9d33732018-10-20 20:41:57 -070045 std::string obj_path;
vishwac93d6d42015-12-16 11:55:16 -060046
Patrick Venturec9508db2018-10-16 17:18:43 -070047 // fru inventory dbus interface name
Patrick Ventureb9d33732018-10-20 20:41:57 -070048 std::string intf_name;
vishwac93d6d42015-12-16 11:55:16 -060049
Patrick Venturec9508db2018-10-16 17:18:43 -070050 // Default constructor disabled.
Patrick Venture9eb82cf2018-10-20 19:36:01 -070051 IPMIFruArea();
vishwac93d6d42015-12-16 11:55:16 -060052
Patrick Venturec9508db2018-10-16 17:18:43 -070053 public:
54 // constructor
Patrick Venture9eb82cf2018-10-20 19:36:01 -070055 IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type,
56 bool bmc_fru = false);
vishwac93d6d42015-12-16 11:55:16 -060057
Patrick Venturec9508db2018-10-16 17:18:43 -070058 // Destructor
Patrick Venture9eb82cf2018-10-20 19:36:01 -070059 virtual ~IPMIFruArea();
vishwac93d6d42015-12-16 11:55:16 -060060
Patrick Venturec9508db2018-10-16 17:18:43 -070061 // Sets the present bit
62 inline void set_present(const bool present)
63 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070064 isPresent = present;
Patrick Venturec9508db2018-10-16 17:18:43 -070065 }
vishwac93d6d42015-12-16 11:55:16 -060066
Patrick Venturec9508db2018-10-16 17:18:43 -070067 // returns fru id;
68 uint8_t get_fruid() const
69 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070070 return fruid;
Patrick Venturec9508db2018-10-16 17:18:43 -070071 }
vishwac93d6d42015-12-16 11:55:16 -060072
Patrick Venturec9508db2018-10-16 17:18:43 -070073 // Returns the length.
74 size_t get_len() const
75 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070076 return len;
Patrick Venturec9508db2018-10-16 17:18:43 -070077 }
vishwac93d6d42015-12-16 11:55:16 -060078
Patrick Venturec9508db2018-10-16 17:18:43 -070079 // Returns the type of the current fru area
80 ipmi_fru_area_type get_type() const
81 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070082 return type;
Patrick Venturec9508db2018-10-16 17:18:43 -070083 }
vishwac93d6d42015-12-16 11:55:16 -060084
Patrick Venturec9508db2018-10-16 17:18:43 -070085 // Returns the name
86 const char* get_name() const
87 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070088 return name.c_str();
Patrick Venturec9508db2018-10-16 17:18:43 -070089 }
vishwac93d6d42015-12-16 11:55:16 -060090
Patrick Venturec9508db2018-10-16 17:18:43 -070091 // Returns SD bus name
92 const char* get_bus_name() const
93 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070094 return bus_name.c_str();
Patrick Venturec9508db2018-10-16 17:18:43 -070095 }
vishwac93d6d42015-12-16 11:55:16 -060096
Patrick Venturec9508db2018-10-16 17:18:43 -070097 // Retrns SD bus object path
98 const char* get_obj_path() const
99 {
Patrick Ventureb9d33732018-10-20 20:41:57 -0700100 return obj_path.c_str();
Patrick Venturec9508db2018-10-16 17:18:43 -0700101 }
vishwac93d6d42015-12-16 11:55:16 -0600102
Patrick Venturec9508db2018-10-16 17:18:43 -0700103 // Returns SD bus interface name
104 const char* get_intf_name() const
105 {
Patrick Ventureb9d33732018-10-20 20:41:57 -0700106 return intf_name.c_str();
Patrick Venturec9508db2018-10-16 17:18:43 -0700107 }
vishwac93d6d42015-12-16 11:55:16 -0600108
Patrick Venturec9508db2018-10-16 17:18:43 -0700109 // Returns the data portion
110 inline uint8_t* get_data() const
111 {
Patrick Ventureb9d33732018-10-20 20:41:57 -0700112 return data;
Patrick Venturec9508db2018-10-16 17:18:43 -0700113 }
vishwac93d6d42015-12-16 11:55:16 -0600114
Patrick Venturec9508db2018-10-16 17:18:43 -0700115 // Accepts a pointer to data and sets it in the object.
116 void set_data(const uint8_t*, const size_t);
vishwac93d6d42015-12-16 11:55:16 -0600117
Patrick Venturec9508db2018-10-16 17:18:43 -0700118 // Sets the dbus parameters
119 void update_dbus_paths(const char*, const char*, const char*);
vishwac93d6d42015-12-16 11:55:16 -0600120};
121
122#endif