blob: b983b53cd6f307790f13c39f5d9fb6ddc5537290 [file] [log] [blame]
#include "fru_area.hpp"
#include "frup.hpp"
#include <cstdint>
#include <cstring>
#include <phosphor-logging/log.hpp>
using namespace phosphor::logging;
//----------------------------------------------------------------
// Constructor
//----------------------------------------------------------------
IPMIFruArea::IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type,
bool bmc_fru) :
fruid(fruid),
type(type), bmc_fru(bmc_fru)
{
if (type == IPMI_FRU_AREA_INTERNAL_USE)
{
name = "INTERNAL_";
}
else if (type == IPMI_FRU_AREA_CHASSIS_INFO)
{
name = "CHASSIS_";
}
else if (type == IPMI_FRU_AREA_BOARD_INFO)
{
name = "BOARD_";
}
else if (type == IPMI_FRU_AREA_PRODUCT_INFO)
{
name = "PRODUCT_";
}
else if (type == IPMI_FRU_AREA_MULTI_RECORD)
{
name = "MULTI_";
}
else
{
name = IPMI_FRU_AREA_TYPE_MAX;
log<level::ERR>("Invalid Area", entry("TYPE=%d", type));
}
}
//-----------------------------------------------------
// For a FRU area type, accepts the data and updates
// area specific data.
//-----------------------------------------------------
void IPMIFruArea::setData(const uint8_t* value, const size_t length)
{
len = length;
data = new uint8_t[len];
std::memcpy(data, value, len);
}
//-----------------------------------------------------
// Sets the dbus parameters
//-----------------------------------------------------
void IPMIFruArea::updateDbusPaths(const char* bus, const char* path,
const char* intf)
{
bus_name = bus;
obj_path = path;
intf_name = intf;
}
//-------------------
// Destructor
//-------------------
IPMIFruArea::~IPMIFruArea()
{
if (data != NULL)
{
delete[] data;
data = NULL;
}
}