blob: 97ac3bd9ea944a3cb080541e64dc0e7edf50a40a [file] [log] [blame]
Patrick Venturea19bd0c2018-10-20 20:09:42 -07001#include "fru_area.hpp"
2
3#include "frup.hpp"
4
5#include <cstdint>
6#include <cstring>
7#include <phosphor-logging/log.hpp>
8
9using namespace phosphor::logging;
10
Patrick Venture9f65a082018-10-21 13:18:17 -070011IPMIFruArea::IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type,
12 bool bmcOnlyFru) :
13 fruID(fruID),
14 type(type), bmcOnlyFru(bmcOnlyFru)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070015{
Patrick Ventureb9d33732018-10-20 20:41:57 -070016 if (type == IPMI_FRU_AREA_INTERNAL_USE)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070017 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070018 name = "INTERNAL_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070019 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070020 else if (type == IPMI_FRU_AREA_CHASSIS_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070021 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070022 name = "CHASSIS_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070023 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070024 else if (type == IPMI_FRU_AREA_BOARD_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070025 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070026 name = "BOARD_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070027 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070028 else if (type == IPMI_FRU_AREA_PRODUCT_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070029 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070030 name = "PRODUCT_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070031 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070032 else if (type == IPMI_FRU_AREA_MULTI_RECORD)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070033 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070034 name = "MULTI_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070035 }
36 else
37 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070038 name = IPMI_FRU_AREA_TYPE_MAX;
39 log<level::ERR>("Invalid Area", entry("TYPE=%d", type));
Patrick Venturea19bd0c2018-10-20 20:09:42 -070040 }
41}
42
Patrick Venturef22b36a2018-10-20 20:59:07 -070043void IPMIFruArea::setData(const uint8_t* value, const size_t length)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070044{
Patrick Venturef0f1ab92018-10-21 13:03:01 -070045 data.reserve(length); // pre-allocate the space.
46 data.insert(data.begin(), value, value + length);
Patrick Venturea19bd0c2018-10-20 20:09:42 -070047}