Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 1 | #include "fru_area.hpp" |
| 2 | |
| 3 | #include "frup.hpp" |
| 4 | |
| 5 | #include <cstdint> |
| 6 | #include <cstring> |
| 7 | #include <phosphor-logging/log.hpp> |
| 8 | |
| 9 | using namespace phosphor::logging; |
| 10 | |
| 11 | //---------------------------------------------------------------- |
| 12 | // Constructor |
| 13 | //---------------------------------------------------------------- |
| 14 | IPMIFruArea::IPMIFruArea(const uint8_t fruid, const ipmi_fru_area_type type, |
Patrick Venture | 98de3b3 | 2018-10-20 20:32:14 -0700 | [diff] [blame^] | 15 | bool bmc_fru) : |
| 16 | iv_fruid(fruid), |
| 17 | iv_type(type), iv_bmc_fru(bmc_fru) |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 18 | { |
Patrick Venture | a19bd0c | 2018-10-20 20:09:42 -0700 | [diff] [blame] | 19 | if (iv_type == IPMI_FRU_AREA_INTERNAL_USE) |
| 20 | { |
| 21 | iv_name = "INTERNAL_"; |
| 22 | } |
| 23 | else if (iv_type == IPMI_FRU_AREA_CHASSIS_INFO) |
| 24 | { |
| 25 | iv_name = "CHASSIS_"; |
| 26 | } |
| 27 | else if (iv_type == IPMI_FRU_AREA_BOARD_INFO) |
| 28 | { |
| 29 | iv_name = "BOARD_"; |
| 30 | } |
| 31 | else if (iv_type == IPMI_FRU_AREA_PRODUCT_INFO) |
| 32 | { |
| 33 | iv_name = "PRODUCT_"; |
| 34 | } |
| 35 | else if (iv_type == IPMI_FRU_AREA_MULTI_RECORD) |
| 36 | { |
| 37 | iv_name = "MULTI_"; |
| 38 | } |
| 39 | else |
| 40 | { |
| 41 | iv_name = IPMI_FRU_AREA_TYPE_MAX; |
| 42 | log<level::ERR>("Invalid Area", entry("TYPE=%d", iv_type)); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | //----------------------------------------------------- |
| 47 | // For a FRU area type, accepts the data and updates |
| 48 | // area specific data. |
| 49 | //----------------------------------------------------- |
| 50 | void IPMIFruArea::set_data(const uint8_t* data, const size_t len) |
| 51 | { |
| 52 | iv_len = len; |
| 53 | iv_data = new uint8_t[len]; |
| 54 | std::memcpy(iv_data, data, len); |
| 55 | } |
| 56 | |
| 57 | //----------------------------------------------------- |
| 58 | // Sets the dbus parameters |
| 59 | //----------------------------------------------------- |
| 60 | void IPMIFruArea::update_dbus_paths(const char* bus_name, const char* obj_path, |
| 61 | const char* intf_name) |
| 62 | { |
| 63 | iv_bus_name = bus_name; |
| 64 | iv_obj_path = obj_path; |
| 65 | iv_intf_name = intf_name; |
| 66 | } |
| 67 | |
| 68 | //------------------- |
| 69 | // Destructor |
| 70 | //------------------- |
| 71 | IPMIFruArea::~IPMIFruArea() |
| 72 | { |
| 73 | if (iv_data != NULL) |
| 74 | { |
| 75 | delete[] iv_data; |
| 76 | iv_data = NULL; |
| 77 | } |
| 78 | } |