blob: 35f8d16f9dee319928c2d570f31deb9ba39928a2 [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
Vishwa4be4b7a2015-10-31 22:55:50 -05006// Format of write fru data command
vishwac93d6d42015-12-16 11:55:16 -06007struct write_fru_data_t
Vishwa4be4b7a2015-10-31 22:55:50 -05008{
Patrick Venturec9508db2018-10-16 17:18:43 -07009 uint8_t frunum;
10 uint8_t offsetls;
11 uint8_t offsetms;
12 uint8_t data;
13} __attribute__((packed));
Vishwa4be4b7a2015-10-31 22:55:50 -050014
15// Per IPMI v2.0 FRU specification
16struct common_header
17{
18 uint8_t fixed;
19 uint8_t internal_offset;
20 uint8_t chassis_offset;
21 uint8_t board_offset;
22 uint8_t product_offset;
23 uint8_t multi_offset;
24 uint8_t pad;
25 uint8_t crc;
Patrick Venturec9508db2018-10-16 17:18:43 -070026} __attribute__((packed));
Vishwa4be4b7a2015-10-31 22:55:50 -050027
Vishwa4be4b7a2015-10-31 22:55:50 -050028// first byte in header is 1h per IPMI V2 spec.
Patrick Venturec9508db2018-10-16 17:18:43 -070029#define IPMI_FRU_HDR_BYTE_ZERO 1
Vishwa4be4b7a2015-10-31 22:55:50 -050030#define IPMI_FRU_INTERNAL_OFFSET offsetof(struct common_header, internal_offset)
Patrick Venturec9508db2018-10-16 17:18:43 -070031#define IPMI_FRU_CHASSIS_OFFSET offsetof(struct common_header, chassis_offset)
32#define IPMI_FRU_BOARD_OFFSET offsetof(struct common_header, board_offset)
33#define IPMI_FRU_PRODUCT_OFFSET offsetof(struct common_header, product_offset)
34#define IPMI_FRU_MULTI_OFFSET offsetof(struct common_header, multi_offset)
35#define IPMI_FRU_HDR_CRC_OFFSET offsetof(struct common_header, crc)
36#define IPMI_EIGHT_BYTES 8
Thang Q. Nguyen472d3e22021-01-06 04:17:40 +000037#define IPMI_FRU_MULTIREC_HDR_BYTES 5
Vishwa4be4b7a2015-10-31 22:55:50 -050038
Patrick Venture32c4e362018-10-20 09:19:29 -070039/**
40 * Validate a FRU.
41 *
42 * @param[in] fruid - The ID to use for this FRU.
Patrick Ventureef83b992018-10-21 09:32:44 -070043 * @param[in] fruFilename - the filename of the FRU.
Patrick Venturea8093a22018-10-21 09:07:11 -070044 * @param[in] bus - an sdbusplus systemd bus for publishing the information.
Patrick Venture32c4e362018-10-20 09:19:29 -070045 */
Patrick Ventureef83b992018-10-21 09:32:44 -070046int validateFRUArea(const uint8_t fruid, const char* fruFilename,
Jayanth Othayoth70cb0672025-06-07 02:13:23 -050047 sdbusplus::bus_t& bus);
vishwaf3ca3522015-12-02 10:35:13 -060048
Vishwa4be4b7a2015-10-31 22:55:50 -050049#endif