| 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 | |||||
| Patrick Venture | 9f65a08 | 2018-10-21 13:18:17 -0700 | [diff] [blame] | 12 | IPMIFruArea::IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type, |
| 13 | bool bmcOnlyFru) : | ||||
| 14 | fruID(fruID), | ||||
| 15 | type(type), bmcOnlyFru(bmcOnlyFru) | ||||
| 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 | if (type == IPMI_FRU_AREA_INTERNAL_USE) |
| 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 | name = "INTERNAL_"; |
| 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 | else if (type == IPMI_FRU_AREA_CHASSIS_INFO) |
| 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 | name = "CHASSIS_"; |
| 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 | else if (type == IPMI_FRU_AREA_BOARD_INFO) |
| 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 | name = "BOARD_"; |
| 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 | else if (type == IPMI_FRU_AREA_PRODUCT_INFO) |
| 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 | name = "PRODUCT_"; |
| 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 | else if (type == IPMI_FRU_AREA_MULTI_RECORD) |
| Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 34 | { |
| Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 35 | name = "MULTI_"; |
| Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 36 | } |
| 37 | else | ||||
| 38 | { | ||||
| Patrick Venture | b9d3373 | 2018-10-20 20:41:57 -0700 | [diff] [blame] | 39 | name = IPMI_FRU_AREA_TYPE_MAX; |
| 40 | log<level::ERR>("Invalid Area", entry("TYPE=%d", type)); | ||||
| Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 41 | } |
| 42 | } | ||||
| 43 | |||||
| Patrick Venture | f22b36a | 2018-10-20 20:59:07 -0700 | [diff] [blame] | 44 | void IPMIFruArea::setData(const uint8_t* value, const size_t length) |
| Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 45 | { |
| Patrick Venture | f0f1ab9 | 2018-10-21 13:03:01 -0700 | [diff] [blame] | 46 | data.reserve(length); // pre-allocate the space. |
| 47 | data.insert(data.begin(), value, value + length); | ||||
| Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 48 | } |