blob: 8cb7f7904166e83077ae32cf02096fb47e33dec9 [file] [log] [blame]
Patrick Venturea19bd0c2018-10-20 20:09:42 -07001#include "fru_area.hpp"
2
3#include "frup.hpp"
4
George Liu98de42a2025-07-30 09:54:21 +08005#include <phosphor-logging/lg2.hpp>
Patrick Williamscfa96af2023-05-10 07:50:26 -05006
Patrick Venturea19bd0c2018-10-20 20:09:42 -07007#include <cstdint>
8#include <cstring>
Patrick Venturea19bd0c2018-10-20 20:09:42 -07009
Jayanth Othayoth70cb0672025-06-07 02:13:23 -050010IPMIFruArea::IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type) :
11 fruID(fruID), type(type)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070012{
Patrick Ventureb9d33732018-10-20 20:41:57 -070013 if (type == IPMI_FRU_AREA_INTERNAL_USE)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070014 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070015 name = "INTERNAL_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070016 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070017 else if (type == IPMI_FRU_AREA_CHASSIS_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070018 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070019 name = "CHASSIS_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070020 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070021 else if (type == IPMI_FRU_AREA_BOARD_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070022 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070023 name = "BOARD_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070024 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070025 else if (type == IPMI_FRU_AREA_PRODUCT_INFO)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070026 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070027 name = "PRODUCT_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070028 }
Patrick Ventureb9d33732018-10-20 20:41:57 -070029 else if (type == IPMI_FRU_AREA_MULTI_RECORD)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070030 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070031 name = "MULTI_";
Patrick Venturea19bd0c2018-10-20 20:09:42 -070032 }
33 else
34 {
Patrick Ventureb9d33732018-10-20 20:41:57 -070035 name = IPMI_FRU_AREA_TYPE_MAX;
George Liu98de42a2025-07-30 09:54:21 +080036 lg2::error("type: {TYPE} is an invalid Area", "TYPE", type);
Patrick Venturea19bd0c2018-10-20 20:09:42 -070037 }
38}
39
Patrick Venturef22b36a2018-10-20 20:59:07 -070040void IPMIFruArea::setData(const uint8_t* value, const size_t length)
Patrick Venturea19bd0c2018-10-20 20:09:42 -070041{
Patrick Venturef0f1ab92018-10-21 13:03:01 -070042 data.reserve(length); // pre-allocate the space.
43 data.insert(data.begin(), value, value + length);
Patrick Venturea19bd0c2018-10-20 20:09:42 -070044}