Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 1 | #ifndef __IPMI_WRITE_FRU_DATA_H__ |
| 2 | #define __IPMI_WRITE_FRU_DATA_H__ |
| 3 | |
Patrick Venture | a8093a2 | 2018-10-21 09:07:11 -0700 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 5 | |
| 6 | // IPMI commands for Storage net functions. |
| 7 | enum ipmi_netfn_storage_cmds |
| 8 | { |
| 9 | IPMI_CMD_WRITE_FRU_DATA = 0x12 |
| 10 | }; |
| 11 | |
| 12 | // Format of write fru data command |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 13 | struct write_fru_data_t |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 14 | { |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 15 | uint8_t frunum; |
| 16 | uint8_t offsetls; |
| 17 | uint8_t offsetms; |
| 18 | uint8_t data; |
| 19 | } __attribute__((packed)); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 20 | |
| 21 | // Per IPMI v2.0 FRU specification |
| 22 | struct common_header |
| 23 | { |
| 24 | uint8_t fixed; |
| 25 | uint8_t internal_offset; |
| 26 | uint8_t chassis_offset; |
| 27 | uint8_t board_offset; |
| 28 | uint8_t product_offset; |
| 29 | uint8_t multi_offset; |
| 30 | uint8_t pad; |
| 31 | uint8_t crc; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 32 | } __attribute__((packed)); |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 33 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 34 | // first byte in header is 1h per IPMI V2 spec. |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 35 | #define IPMI_FRU_HDR_BYTE_ZERO 1 |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 36 | #define IPMI_FRU_INTERNAL_OFFSET offsetof(struct common_header, internal_offset) |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 37 | #define IPMI_FRU_CHASSIS_OFFSET offsetof(struct common_header, chassis_offset) |
| 38 | #define IPMI_FRU_BOARD_OFFSET offsetof(struct common_header, board_offset) |
| 39 | #define IPMI_FRU_PRODUCT_OFFSET offsetof(struct common_header, product_offset) |
| 40 | #define IPMI_FRU_MULTI_OFFSET offsetof(struct common_header, multi_offset) |
| 41 | #define IPMI_FRU_HDR_CRC_OFFSET offsetof(struct common_header, crc) |
| 42 | #define IPMI_EIGHT_BYTES 8 |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 43 | |
Patrick Venture | 32c4e36 | 2018-10-20 09:19:29 -0700 | [diff] [blame] | 44 | /** |
| 45 | * Validate a FRU. |
| 46 | * |
| 47 | * @param[in] fruid - The ID to use for this FRU. |
Patrick Venture | ef83b99 | 2018-10-21 09:32:44 -0700 | [diff] [blame] | 48 | * @param[in] fruFilename - the filename of the FRU. |
Patrick Venture | a8093a2 | 2018-10-21 09:07:11 -0700 | [diff] [blame] | 49 | * @param[in] bus - an sdbusplus systemd bus for publishing the information. |
Patrick Venture | ef83b99 | 2018-10-21 09:32:44 -0700 | [diff] [blame] | 50 | * @param[in] bmcOnlyFru - If a particular area accessible only by BMC. |
Patrick Venture | 32c4e36 | 2018-10-20 09:19:29 -0700 | [diff] [blame] | 51 | */ |
Patrick Venture | ef83b99 | 2018-10-21 09:32:44 -0700 | [diff] [blame] | 52 | int validateFRUArea(const uint8_t fruid, const char* fruFilename, |
| 53 | sdbusplus::bus::bus& bus, const bool bmcOnlyFru); |
vishwa | f3ca352 | 2015-12-02 10:35:13 -0600 | [diff] [blame] | 54 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 55 | #endif |