Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 1 | #include "fru_area.hpp" |
2 | |||||
3 | #include "frup.hpp" | ||||
4 | |||||
Patrick Williams | cfa96af | 2023-05-10 07:50:26 -0500 | [diff] [blame] | 5 | #include <phosphor-logging/log.hpp> |
6 | |||||
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 7 | #include <cstdint> |
8 | #include <cstring> | ||||
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 9 | |
10 | using namespace phosphor::logging; | ||||
11 | |||||
Jayanth Othayoth | 70cb067 | 2025-06-07 02:13:23 -0500 | [diff] [blame] | 12 | IPMIFruArea::IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type) : |
13 | fruID(fruID), type(type) | ||||
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 14 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 15 | if (type == IPMI_FRU_AREA_INTERNAL_USE) |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 16 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 17 | name = "INTERNAL_"; |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 18 | } |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 19 | else if (type == IPMI_FRU_AREA_CHASSIS_INFO) |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 20 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 21 | name = "CHASSIS_"; |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 22 | } |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 23 | else if (type == IPMI_FRU_AREA_BOARD_INFO) |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 24 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 25 | name = "BOARD_"; |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 26 | } |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 27 | else if (type == IPMI_FRU_AREA_PRODUCT_INFO) |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 28 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 29 | name = "PRODUCT_"; |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 30 | } |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 31 | else if (type == IPMI_FRU_AREA_MULTI_RECORD) |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 32 | { |
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 33 | name = "MULTI_"; |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 34 | } |
35 | else | ||||
36 | { | ||||
Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 37 | name = IPMI_FRU_AREA_TYPE_MAX; |
38 | log<level::ERR>("Invalid Area", entry("TYPE=%d", type)); | ||||
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 39 | } |
40 | } | ||||
41 | |||||
Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 42 | void IPMIFruArea::setData(const uint8_t* value, const size_t length) |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 43 | { |
Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 44 | data.reserve(length); // pre-allocate the space. |
45 | data.insert(data.begin(), value, value + length); | ||||
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 46 | } |