blob: a5abf00ec85472513b693b4e83189bffd487c049 [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
Patrick Venture9f65a082018-10-21 13:18:17 -070012IPMIFruArea::IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type,
13 bool bmcOnlyFru) :
14 fruID(fruID),
15 type(type), bmcOnlyFru(bmcOnlyFru)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070016{
Patrick Ventureb9d33732018-10-20 20:41:57 -070017 if (type == IPMI_FRU_AREA_INTERNAL_USE)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070018 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070019 name = "INTERNAL_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070020 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070021 else if (type == IPMI_FRU_AREA_CHASSIS_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070022 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070023 name = "CHASSIS_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070024 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070025 else if (type == IPMI_FRU_AREA_BOARD_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070026 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070027 name = "BOARD_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070028 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070029 else if (type == IPMI_FRU_AREA_PRODUCT_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070030 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070031 name = "PRODUCT_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070032 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070033 else if (type == IPMI_FRU_AREA_MULTI_RECORD)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070034 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070035 name = "MULTI_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070036 }
37 else
38 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070039 name = IPMI_FRU_AREA_TYPE_MAX;
40 log<level::ERR>("Invalid Area", entry("TYPE=%d", type));
Patrick Venturea19bd0c2018-10-20 20:09:42 -070041 }
42}
43
Patrick Venturef22b36a2018-10-20 20:59:07 -070044void IPMIFruArea::setData(const uint8_t* value, const size_t length)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070045{
Patrick Venturef0f1ab92018-10-21 13:03:01 -070046 data.reserve(length); // pre-allocate the space.
47 data.insert(data.begin(), value, value + length);
Patrick Venturea19bd0c2018-10-20 20:09:42 -070048}