blob: e1ac49d35691f695bacb12190ce9e288512667a5 [file] [log] [blame]
Patrick Venturea19bd0c2018-10-20 20:09:42 -07001#include "fru_area.hpp"
2
3#include "frup.hpp"
4
Patrick Williamscfa96af2023-05-10 07:50:26 -05005#include <phosphor-logging/log.hpp>
6
Patrick Venturea19bd0c2018-10-20 20:09:42 -07007#include <cstdint>
8#include <cstring>
Patrick Venturea19bd0c2018-10-20 20:09:42 -07009
10using namespace phosphor::logging;
11
Jayanth Othayoth70cb0672025-06-07 02:13:23 -050012IPMIFruArea::IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type) :
13 fruID(fruID), type(type)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070014{
Patrick Ventureb9d33732018-10-20 20:41:57 -070015 if (type == IPMI_FRU_AREA_INTERNAL_USE)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070016 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070017 name = "INTERNAL_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070018 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070019 else if (type == IPMI_FRU_AREA_CHASSIS_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070020 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070021 name = "CHASSIS_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070022 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070023 else if (type == IPMI_FRU_AREA_BOARD_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070024 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070025 name = "BOARD_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070026 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070027 else if (type == IPMI_FRU_AREA_PRODUCT_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070028 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070029 name = "PRODUCT_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070030 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070031 else if (type == IPMI_FRU_AREA_MULTI_RECORD)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070032 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070033 name = "MULTI_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070034 }
35 else
36 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070037 name = IPMI_FRU_AREA_TYPE_MAX;
38 log<level::ERR>("Invalid Area", entry("TYPE=%d", type));
Patrick Venturea19bd0c2018-10-20 20:09:42 -070039 }
40}
41
Patrick Venturef22b36a2018-10-20 20:59:07 -070042void IPMIFruArea::setData(const uint8_t* value, const size_t length)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070043{
Patrick Venturef0f1ab92018-10-21 13:03:01 -070044 data.reserve(length); // pre-allocate the space.
45 data.insert(data.begin(), value, value + length);
Patrick Venturea19bd0c2018-10-20 20:09:42 -070046}