blob: 6b5ed475305b58cd6740ea4e9281f36ffdc8a811 [file] [log] [blame]
Vishwa4be4b7a2015-10-31 22:55:50 -05001#ifndef __IPMI_WRITE_FRU_DATA_H__
2#define __IPMI_WRITE_FRU_DATA_H__
3
Vishwa4be4b7a2015-10-31 22:55:50 -05004#include <stddef.h>
Patrick Venturec9508db2018-10-16 17:18:43 -07005#include <stdint.h>
vishwa13555bd2015-11-10 12:10:38 -06006#include <systemd/sd-bus.h>
Vishwa4be4b7a2015-10-31 22:55:50 -05007
vishwaf3ca3522015-12-02 10:35:13 -06008#ifndef __cplusplus
9#include <stdbool.h> // For bool variable
10#endif
11
Vishwa4be4b7a2015-10-31 22:55:50 -050012// IPMI commands for Storage net functions.
13enum ipmi_netfn_storage_cmds
14{
15 IPMI_CMD_WRITE_FRU_DATA = 0x12
16};
17
18// Format of write fru data command
vishwac93d6d42015-12-16 11:55:16 -060019struct write_fru_data_t
Vishwa4be4b7a2015-10-31 22:55:50 -050020{
Patrick Venturec9508db2018-10-16 17:18:43 -070021 uint8_t frunum;
22 uint8_t offsetls;
23 uint8_t offsetms;
24 uint8_t data;
25} __attribute__((packed));
Vishwa4be4b7a2015-10-31 22:55:50 -050026
27// Per IPMI v2.0 FRU specification
28struct common_header
29{
30 uint8_t fixed;
31 uint8_t internal_offset;
32 uint8_t chassis_offset;
33 uint8_t board_offset;
34 uint8_t product_offset;
35 uint8_t multi_offset;
36 uint8_t pad;
37 uint8_t crc;
Patrick Venturec9508db2018-10-16 17:18:43 -070038} __attribute__((packed));
Vishwa4be4b7a2015-10-31 22:55:50 -050039
Vishwa4be4b7a2015-10-31 22:55:50 -050040// first byte in header is 1h per IPMI V2 spec.
Patrick Venturec9508db2018-10-16 17:18:43 -070041#define IPMI_FRU_HDR_BYTE_ZERO 1
Vishwa4be4b7a2015-10-31 22:55:50 -050042#define IPMI_FRU_INTERNAL_OFFSET offsetof(struct common_header, internal_offset)
Patrick Venturec9508db2018-10-16 17:18:43 -070043#define IPMI_FRU_CHASSIS_OFFSET offsetof(struct common_header, chassis_offset)
44#define IPMI_FRU_BOARD_OFFSET offsetof(struct common_header, board_offset)
45#define IPMI_FRU_PRODUCT_OFFSET offsetof(struct common_header, product_offset)
46#define IPMI_FRU_MULTI_OFFSET offsetof(struct common_header, multi_offset)
47#define IPMI_FRU_HDR_CRC_OFFSET offsetof(struct common_header, crc)
48#define IPMI_EIGHT_BYTES 8
Vishwa4be4b7a2015-10-31 22:55:50 -050049
vishwaf3ca3522015-12-02 10:35:13 -060050#ifdef __cplusplus
51extern "C" {
52#endif
53
Patrick Venturec9508db2018-10-16 17:18:43 -070054int ipmi_validate_fru_area(const uint8_t, const char*, sd_bus*, const bool);
vishwaf3ca3522015-12-02 10:35:13 -060055
56#ifdef __cplusplus
57} // extern C
58#endif
Vishwa4be4b7a2015-10-31 22:55:50 -050059#endif