blob: e713bd56936219762636edca8aa1531f71118dbd [file] [log] [blame]
Vishwa4be4b7a2015-10-31 22:55:50 -05001#ifndef __IPMI_WRITE_FRU_DATA_H__
2#define __IPMI_WRITE_FRU_DATA_H__
3
vishwa13555bd2015-11-10 12:10:38 -06004#include <systemd/sd-bus.h>
Vishwa4be4b7a2015-10-31 22:55:50 -05005
6// IPMI commands for Storage net functions.
7enum ipmi_netfn_storage_cmds
8{
9 IPMI_CMD_WRITE_FRU_DATA = 0x12
10};
11
12// Format of write fru data command
vishwac93d6d42015-12-16 11:55:16 -060013struct write_fru_data_t
Vishwa4be4b7a2015-10-31 22:55:50 -050014{
Patrick Venturec9508db2018-10-16 17:18:43 -070015 uint8_t frunum;
16 uint8_t offsetls;
17 uint8_t offsetms;
18 uint8_t data;
19} __attribute__((packed));
Vishwa4be4b7a2015-10-31 22:55:50 -050020
21// Per IPMI v2.0 FRU specification
22struct 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 Venturec9508db2018-10-16 17:18:43 -070032} __attribute__((packed));
Vishwa4be4b7a2015-10-31 22:55:50 -050033
Vishwa4be4b7a2015-10-31 22:55:50 -050034// first byte in header is 1h per IPMI V2 spec.
Patrick Venturec9508db2018-10-16 17:18:43 -070035#define IPMI_FRU_HDR_BYTE_ZERO 1
Vishwa4be4b7a2015-10-31 22:55:50 -050036#define IPMI_FRU_INTERNAL_OFFSET offsetof(struct common_header, internal_offset)
Patrick Venturec9508db2018-10-16 17:18:43 -070037#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
Vishwa4be4b7a2015-10-31 22:55:50 -050043
Patrick Venture32c4e362018-10-20 09:19:29 -070044/**
45 * Validate a FRU.
46 *
47 * @param[in] fruid - The ID to use for this FRU.
48 * @param[in] fru_file_name - the filename of the FRU.
49 * @param[in] bus_type - a systemd bus for publishing the information.
50 * @param[in] bmc_fru - If a particular area accessible only by BMC.
51 */
Patrick Venture98072dc2018-10-20 09:31:35 -070052int validateFRUArea(const uint8_t fruid, const char* fru_file_name,
53 sd_bus* bus_type, const bool bmc_fru);
vishwaf3ca3522015-12-02 10:35:13 -060054
Vishwa4be4b7a2015-10-31 22:55:50 -050055#endif