xref: /openbmc/ipmi-fru-parser/writefrudata.hpp (revision a0aae953bb912e6f4afc699f6339b4d6eb00d140)
1 #ifndef __IPMI_WRITE_FRU_DATA_H__
2 #define __IPMI_WRITE_FRU_DATA_H__
3 
4 #include <systemd/sd-bus.h>
5 
6 // IPMI commands for Storage net functions.
7 enum ipmi_netfn_storage_cmds
8 {
9     IPMI_CMD_WRITE_FRU_DATA = 0x12
10 };
11 
12 // Format of write fru data command
13 struct write_fru_data_t
14 {
15     uint8_t frunum;
16     uint8_t offsetls;
17     uint8_t offsetms;
18     uint8_t data;
19 } __attribute__((packed));
20 
21 // Per IPMI v2.0 FRU specification
22 struct 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;
32 } __attribute__((packed));
33 
34 // first byte in header is 1h per IPMI V2 spec.
35 #define IPMI_FRU_HDR_BYTE_ZERO 1
36 #define IPMI_FRU_INTERNAL_OFFSET offsetof(struct common_header, internal_offset)
37 #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
43 
44 int ipmi_validate_fru_area(const uint8_t, const char*, sd_bus*, const bool);
45 
46 #endif
47