1 #include "fru_area.hpp"
2
3 #include "frup.hpp"
4
5 #include <phosphor-logging/log.hpp>
6
7 #include <cstdint>
8 #include <cstring>
9
10 using namespace phosphor::logging;
11
IPMIFruArea(const uint8_t fruID,const ipmi_fru_area_type type,bool bmcOnlyFru)12 IPMIFruArea::IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type,
13 bool bmcOnlyFru) :
14 fruID(fruID), type(type), bmcOnlyFru(bmcOnlyFru)
15 {
16 if (type == IPMI_FRU_AREA_INTERNAL_USE)
17 {
18 name = "INTERNAL_";
19 }
20 else if (type == IPMI_FRU_AREA_CHASSIS_INFO)
21 {
22 name = "CHASSIS_";
23 }
24 else if (type == IPMI_FRU_AREA_BOARD_INFO)
25 {
26 name = "BOARD_";
27 }
28 else if (type == IPMI_FRU_AREA_PRODUCT_INFO)
29 {
30 name = "PRODUCT_";
31 }
32 else if (type == IPMI_FRU_AREA_MULTI_RECORD)
33 {
34 name = "MULTI_";
35 }
36 else
37 {
38 name = IPMI_FRU_AREA_TYPE_MAX;
39 log<level::ERR>("Invalid Area", entry("TYPE=%d", type));
40 }
41 }
42
setData(const uint8_t * value,const size_t length)43 void IPMIFruArea::setData(const uint8_t* value, const size_t length)
44 {
45 data.reserve(length); // pre-allocate the space.
46 data.insert(data.begin(), value, value + length);
47 }
48