blob: afd983bfdd3df9d0b1819386fdaaed239902ae18 [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 public:
Patrick Ventureac988992018-10-21 08:37:18 -070017 IPMIFruArea() = delete;
Patrick Venture1d001782018-10-21 13:11:08 -070018 ~IPMIFruArea() = default;
Patrick Ventureac988992018-10-21 08:37:18 -070019
Patrick Venturec9508db2018-10-16 17:18:43 -070020 // constructor
Patrick Venture9f65a082018-10-21 13:18:17 -070021 IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type,
22 bool bmcOnlyFru = false);
vishwac93d6d42015-12-16 11:55:16 -060023
Patrick Venturec9508db2018-10-16 17:18:43 -070024 // Sets the present bit
Patrick Venturef22b36a2018-10-20 20:59:07 -070025 inline void setPresent(const bool present)
Patrick Venturec9508db2018-10-16 17:18:43 -070026 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070027 isPresent = present;
Patrick Venturec9508db2018-10-16 17:18:43 -070028 }
vishwac93d6d42015-12-16 11:55:16 -060029
Patrick Venturec9508db2018-10-16 17:18:43 -070030 // returns fru id;
Patrick Venturef22b36a2018-10-20 20:59:07 -070031 uint8_t getFruID() const
Patrick Venturec9508db2018-10-16 17:18:43 -070032 {
Patrick Venture9f65a082018-10-21 13:18:17 -070033 return fruID;
Patrick Venturec9508db2018-10-16 17:18:43 -070034 }
vishwac93d6d42015-12-16 11:55:16 -060035
Patrick Venturec9508db2018-10-16 17:18:43 -070036 // Returns the length.
Patrick Venturef22b36a2018-10-20 20:59:07 -070037 size_t getLength() const
Patrick Venturec9508db2018-10-16 17:18:43 -070038 {
Patrick Venturef0f1ab92018-10-21 13:03:01 -070039 return data.size();
Patrick Venturec9508db2018-10-16 17:18:43 -070040 }
vishwac93d6d42015-12-16 11:55:16 -060041
Patrick Venturec9508db2018-10-16 17:18:43 -070042 // Returns the type of the current fru area
Patrick Venturef22b36a2018-10-20 20:59:07 -070043 ipmi_fru_area_type getType() const
Patrick Venturec9508db2018-10-16 17:18:43 -070044 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070045 return type;
Patrick Venturec9508db2018-10-16 17:18:43 -070046 }
vishwac93d6d42015-12-16 11:55:16 -060047
Patrick Venturec9508db2018-10-16 17:18:43 -070048 // Returns the name
Patrick Venturef22b36a2018-10-20 20:59:07 -070049 const char* getName() const
Patrick Venturec9508db2018-10-16 17:18:43 -070050 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070051 return name.c_str();
Patrick Venturec9508db2018-10-16 17:18:43 -070052 }
vishwac93d6d42015-12-16 11:55:16 -060053
Patrick Venturec9508db2018-10-16 17:18:43 -070054 // Returns the data portion
Patrick Venturef0f1ab92018-10-21 13:03:01 -070055 inline const uint8_t* getData() const
Patrick Venturec9508db2018-10-16 17:18:43 -070056 {
Patrick Venturef0f1ab92018-10-21 13:03:01 -070057 return data.data();
Patrick Venturec9508db2018-10-16 17:18:43 -070058 }
vishwac93d6d42015-12-16 11:55:16 -060059
Patrick Venturec9508db2018-10-16 17:18:43 -070060 // Accepts a pointer to data and sets it in the object.
Patrick Venturef22b36a2018-10-20 20:59:07 -070061 void setData(const uint8_t*, const size_t);
vishwac93d6d42015-12-16 11:55:16 -060062
Patrick Venture524ba9c2018-10-20 20:52:27 -070063 private:
64 // Unique way of identifying a FRU
Patrick Venture9f65a082018-10-21 13:18:17 -070065 uint8_t fruID = 0;
Patrick Venture524ba9c2018-10-20 20:52:27 -070066
67 // Type of the fru matching offsets in common header
68 ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE;
69
70 // Name of the fru area. ( BOARD/CHASSIS/PRODUCT )
71 std::string name;
72
Patrick Venture524ba9c2018-10-20 20:52:27 -070073 // Special bit for BMC readable eeprom only.
Patrick Venture9f65a082018-10-21 13:18:17 -070074 bool bmcOnlyFru = false;
Patrick Venture524ba9c2018-10-20 20:52:27 -070075
76 // If a FRU is physically present.
77 bool isPresent = false;
78
79 // Whether a particular area is valid ?
80 bool isValid = false;
81
82 // Actual area data.
Patrick Venturef0f1ab92018-10-21 13:03:01 -070083 std::vector<uint8_t> data;
vishwac93d6d42015-12-16 11:55:16 -060084};
85
86#endif