xref: /openbmc/ipmi-fru-parser/writefrudata.hpp (revision 1a843d07246220bf888352d2ebd1410ef505a993)
1 #ifndef __IPMI_WRITE_FRU_DATA_H__
2 #define __IPMI_WRITE_FRU_DATA_H__
3 
4 #include <sdbusplus/bus.hpp>
5 
6 // Format of write fru data command
7 struct write_fru_data_t
8 {
9     uint8_t frunum;
10     uint8_t offsetls;
11     uint8_t offsetms;
12     uint8_t data;
13 } __attribute__((packed));
14 
15 // Per IPMI v2.0 FRU specification
16 struct 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;
26 } __attribute__((packed));
27 
28 // first byte in header is 1h per IPMI V2 spec.
29 #define IPMI_FRU_HDR_BYTE_ZERO 1
30 #define IPMI_FRU_INTERNAL_OFFSET offsetof(struct common_header, internal_offset)
31 #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
37 #define IPMI_FRU_MULTIREC_HDR_BYTES 5
38 
39 /**
40  * Validate a FRU.
41  *
42  * @param[in] fruid - The ID to use for this FRU.
43  * @param[in] fruFilename - the filename of the FRU.
44  * @param[in] bus - an sdbusplus systemd bus for publishing the information.
45  */
46 int validateFRUArea(const uint8_t fruid, const char* fruFilename,
47                     sdbusplus::bus_t& bus);
48 
49 #endif
50