1 #include "fru_area.hpp" 2 3 #include "frup.hpp" 4 5 #include <cstdint> 6 #include <cstring> 7 #include <phosphor-logging/log.hpp> 8 9 using namespace phosphor::logging; 10 11 //---------------------------------------------------------------- 12 // Constructor 13 //---------------------------------------------------------------- 14 IPMIFruArea::IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type, 15 bool bmc_fru) : 16 fruid(fruid), 17 type(type), bmc_fru(bmc_fru) 18 { 19 if (type == IPMI_FRU_AREA_INTERNAL_USE) 20 { 21 name = "INTERNAL_"; 22 } 23 else if (type == IPMI_FRU_AREA_CHASSIS_INFO) 24 { 25 name = "CHASSIS_"; 26 } 27 else if (type == IPMI_FRU_AREA_BOARD_INFO) 28 { 29 name = "BOARD_"; 30 } 31 else if (type == IPMI_FRU_AREA_PRODUCT_INFO) 32 { 33 name = "PRODUCT_"; 34 } 35 else if (type == IPMI_FRU_AREA_MULTI_RECORD) 36 { 37 name = "MULTI_"; 38 } 39 else 40 { 41 name = IPMI_FRU_AREA_TYPE_MAX; 42 log<level::ERR>("Invalid Area", entry("TYPE=%d", type)); 43 } 44 } 45 46 //----------------------------------------------------- 47 // For a FRU area type, accepts the data and updates 48 // area specific data. 49 //----------------------------------------------------- 50 void IPMIFruArea::setData(const uint8_t* value, const size_t length) 51 { 52 len = length; 53 data = new uint8_t[len]; 54 std::memcpy(data, value, len); 55 } 56 57 //----------------------------------------------------- 58 // Sets the dbus parameters 59 //----------------------------------------------------- 60 void IPMIFruArea::updateDbusPaths(const char* bus, const char* path, 61 const char* intf) 62 { 63 bus_name = bus; 64 obj_path = path; 65 intf_name = intf; 66 } 67 68 //------------------- 69 // Destructor 70 //------------------- 71 IPMIFruArea::~IPMIFruArea() 72 { 73 if (data != NULL) 74 { 75 delete[] data; 76 data = NULL; 77 } 78 } 79