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 | |
| 4 | #include <stdint.h> |
| 5 | #include <stddef.h> |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 6 | #include <systemd/sd-bus.h> |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 7 | |
vishwa | f3ca352 | 2015-12-02 10:35:13 -0600 | [diff] [blame] | 8 | #ifndef __cplusplus |
| 9 | #include <stdbool.h> // For bool variable |
| 10 | #endif |
| 11 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 12 | // IPMI commands for Storage net functions. |
| 13 | enum ipmi_netfn_storage_cmds |
| 14 | { |
| 15 | IPMI_CMD_WRITE_FRU_DATA = 0x12 |
| 16 | }; |
| 17 | |
| 18 | // Format of write fru data command |
| 19 | struct write_fru_data_t |
| 20 | { |
| 21 | uint8_t frunum; |
| 22 | uint8_t offsetls; |
| 23 | uint8_t offsetms; |
| 24 | uint8_t data; |
| 25 | }__attribute__ ((packed)); |
| 26 | |
| 27 | // Per IPMI v2.0 FRU specification |
| 28 | struct common_header |
| 29 | { |
| 30 | uint8_t fixed; |
| 31 | uint8_t internal_offset; |
| 32 | uint8_t chassis_offset; |
| 33 | uint8_t board_offset; |
| 34 | uint8_t product_offset; |
| 35 | uint8_t multi_offset; |
| 36 | uint8_t pad; |
| 37 | uint8_t crc; |
| 38 | }__attribute__((packed)); |
| 39 | |
| 40 | // Contains key info about a particular area. |
| 41 | typedef struct |
| 42 | { |
| 43 | uint8_t type; |
| 44 | uint8_t *offset; |
| 45 | size_t len; |
| 46 | }__attribute__((packed)) fru_area_t; |
| 47 | |
| 48 | // first byte in header is 1h per IPMI V2 spec. |
| 49 | #define IPMI_FRU_HDR_BYTE_ZERO 1 |
| 50 | #define IPMI_FRU_INTERNAL_OFFSET offsetof(struct common_header, internal_offset) |
| 51 | #define IPMI_FRU_CHASSIS_OFFSET offsetof(struct common_header, chassis_offset) |
| 52 | #define IPMI_FRU_BOARD_OFFSET offsetof(struct common_header, board_offset) |
| 53 | #define IPMI_FRU_PRODUCT_OFFSET offsetof(struct common_header, product_offset) |
| 54 | #define IPMI_FRU_MULTI_OFFSET offsetof(struct common_header, multi_offset) |
| 55 | #define IPMI_FRU_HDR_CRC_OFFSET offsetof(struct common_header, crc) |
| 56 | #define IPMI_EIGHT_BYTES 8 |
| 57 | |
vishwa | f3ca352 | 2015-12-02 10:35:13 -0600 | [diff] [blame] | 58 | #ifdef __cplusplus |
| 59 | extern "C" { |
| 60 | #endif |
| 61 | |
| 62 | int ipmi_validate_fru_area(const uint8_t, const char *, sd_bus *, const bool); |
| 63 | |
| 64 | #ifdef __cplusplus |
| 65 | } // extern C |
| 66 | #endif |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 67 | |
Vishwa | 4be4b7a | 2015-10-31 22:55:50 -0500 | [diff] [blame] | 68 | #endif |