blob: cc5cef6f3deb6659e4c0f4415290275322a26170 [file] [log] [blame]
Vishwa4be4b7a2015-10-31 22:55:50 -05001#ifndef __IPMI_WRITE_FRU_DATA_H__
2#define __IPMI_WRITE_FRU_DATA_H__
3
Patrick Venturea8093a22018-10-21 09:07:11 -07004#include <sdbusplus/bus.hpp>
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.
Patrick Ventureef83b992018-10-21 09:32:44 -070048 * @param[in] fruFilename - the filename of the FRU.
Patrick Venturea8093a22018-10-21 09:07:11 -070049 * @param[in] bus - an sdbusplus systemd bus for publishing the information.
Patrick Ventureef83b992018-10-21 09:32:44 -070050 * @param[in] bmcOnlyFru - If a particular area accessible only by BMC.
Patrick Venture32c4e362018-10-20 09:19:29 -070051 */
Patrick Ventureef83b992018-10-21 09:32:44 -070052int validateFRUArea(const uint8_t fruid, const char* fruFilename,
53 sdbusplus::bus::bus& bus, const bool bmcOnlyFru);
vishwaf3ca3522015-12-02 10:35:13 -060054
Vishwa4be4b7a2015-10-31 22:55:50 -050055#endif