Loading...
Searching...
No Matches
fru.h
Go to the documentation of this file.
#pragma once
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#define LIBFRU_MAJOR 3L
#define LIBFRU_MINOR 1L
#define LIBFRU_SUBMINOR L
#define LIBFRU_VERSION (LIBFRU_MAJOR << 16 | \
LIBFRU_MINOR << 8 | \
LIBFRU_SUBMINOR)
/*
* Private macro definitions.
*
* These macros aren't for library users, but they are needed for public
* interfaces definition.
*
* @cond PRIVATE
*/
#define fru__zfree(buf) do { \
int err = errno; /* Prevent errno corruption */ \
free(buf); \
(buf) = NULL; \
errno = err; \
} while(0)
#define FRU__BIT(x) (1 << (x))
/*
* Field types per Section 13 of IPMI FRU Specification,
* in their binary/encoded representation
*/
#define FRU__TYPE_BINARY 0x00
#define FRU__TYPE_BCDPLUS 0x01
#define FRU__TYPE_ASCII_6BIT 0x02
#define FRU__TYPE_TEXT 0x03
#define FRU__TYPE_BITS_MASK 0xC0
#define FRU__FIELDLEN(x) ((size_t)(((x) & ~FRU__TYPE_BITS_MASK)))
#define FRU__FIELDMAXLEN FRU__FIELDLEN(UINT8_MAX)
/*
* The `+0LL` trick is to make some old versions of gcc happy
* when `a` is of a smaller type than `b`. Without this trick
* the compiler would always throw a 'comparison is always
* false' warning. Newer versions of gcc don't have that bug,
* but `+0LL` is a no-op anyway, so it's here unconditionally.
*/
#define FRU_MAX(a, b) (((intmax_t)((a) + 0LL) > (intmax_t)((b) + 0LL)) ? (a) : (b))
#define FRU_MIN(a, b) (((intmax_t)((a) + 0LL) > (intmax_t)((b) + 0LL)) ? (b) : (a))
// BCD+ decoded data is twice the length of encoded,
// so is hex string for binary data
#define FRU_FIELDMAXARRAY ((2 * FRU__FIELDMAXLEN) + 1)
/*
* Public definitions
*/
#define FRU_INFO_AREAS 3
#define FRU_FIRST_INFO_AREA FRU_CHASSIS_INFO
#define FRU_LAST_INFO_AREA FRU_PRODUCT_INFO
#define FRU_IS_INFO_AREA(atype) (FRU_FIRST_INFO_AREA <= (atype) \
&& (atype) <= FRU_LAST_INFO_AREA)
#define FRU_ATYPE_TO_INFOIDX(atype) (FRU_IS_INFO_AREA(atype) ? (int)((atype) - FRU_FIRST_INFO_AREA) : -1)
#define FRU_INFOIDX_TO_ATYPE(idx) (((idx) >= 0 && (idx) < FRU_INFO_AREAS) \
? (fru_area_type_t)((idx) + FRU_FIRST_INFO_AREA) \
: (fru_area_type_t)(-1))
#define FRU_INFOIDX(a) FRU_ATYPE_TO_INFOIDX(FRU_##a##_INFO)
#define FRU_FOREACH_INFOIDX(it) for ((it) = 0; (it) <= FRU_INFO_AREAS; (it)++)
#define FRU_FOREACH_INFOFIELD(fru, atype, f, idx) \
for (size_t idx = FRU_LIST_HEAD; \
(f = fru_getfield(fru, atype, idx)); \
idx++)
#define FRU_FOREACH_INFOCUSTOM(fru, atype, f, idx) \
for (size_t idx = FRU_LIST_HEAD; \
(f = fru_get_custom(fru, atype, idx)); \
idx++)
typedef enum {
FRU_FE_EMPTY,
FRU_FE_BASE,
FRU_FE_BINARY = (FRU__TYPE_BINARY + FRU_FE_BASE),
FRU_FE_MIN = FRU_FE_BINARY,
FRU_FE_BCDPLUS = (FRU__TYPE_BCDPLUS + FRU_FE_BASE),
FRU_FE_6BITASCII = (FRU__TYPE_ASCII_6BIT + FRU_FE_BASE),
FRU_FE_TEXT = (FRU__TYPE_TEXT + FRU_FE_BASE),
FRU_FE_MAX = FRU_FE_TEXT,
FRU_FE_AUTO,
FRU_FE_UNKNOWN,
FRU_FE_PRESERVE = FRU_FE_UNKNOWN,
FRU_FE_TOTALCOUNT,
FRU_FE_REALCOUNT = (FRU_FE_MAX - FRU_FE_MIN + 1),
} fru_field_enc_t;
#define FRU_REAL_FE(t) ((t) - FRU_FE_BASE)
#define FRU_FE_FROMREAL(t) ((t) + FRU_FE_BASE)
#define FRU_FE_IS_REAL(t) (FRU_FE_MIN <= (t) && (t) <= FRU_FE_MAX)
#define FRU_FIELD_IS_REAL_ENC(f) ((f) && FRU_FE_IS_REAL((f)->enc))
#define FRU_FIELD_IS_AUTO_ENC(f) ((f) && FRU_FE_AUTO == ((f)->enc))
typedef struct {
fru_field_enc_t enc;
char val[FRU_FIELDMAXARRAY];
} fru_field_t;
typedef void * fru_custom_t; // The actual type is not for public use
typedef struct {
uint8_t type;
fru_field_t pn;
fru_field_t serial;
fru_custom_t cust;
} fru_chassis_t;
typedef enum {
FRU_CHASSIS_PARTNO,
FRU_CHASSIS_SERIAL,
FRU_CHASSIS_FIELD_COUNT
} fru_chassis_field_t;
typedef enum {
FRU_LANG_DEFAULT = 0,
FRU_LANG_ENGLISH = 25,
} fru_lang_t;
typedef struct {
fru_lang_t lang;
struct timeval tv;
bool tv_auto;
fru_field_t mfg;
fru_field_t pname;
fru_field_t serial;
fru_field_t pn;
fru_field_t file;
fru_custom_t cust;
} fru_board_t;
typedef enum {
FRU_BOARD_MFG,
FRU_BOARD_PRODNAME,
FRU_BOARD_SERIAL,
FRU_BOARD_PARTNO,
FRU_BOARD_FILE,
FRU_BOARD_FIELD_COUNT
} fru_board_field_t;
typedef struct {
fru_lang_t lang;
fru_field_t mfg;
fru_field_t pname;
fru_field_t pn;
fru_field_t ver;
fru_field_t serial;
fru_field_t atag;
fru_field_t file;
fru_custom_t cust;
} fru_product_t;
typedef enum {
FRU_PROD_MFG,
FRU_PROD_NAME,
FRU_PROD_MODELPN,
FRU_PROD_VERSION,
FRU_PROD_SERIAL,
FRU_PROD_ASSET,
FRU_PROD_FILE,
FRU_PROD_FIELD_COUNT
} fru_prod_field_t;
#define FRU_MAX_FIELD_COUNT FRU_PROD_FIELD_COUNT
typedef void * fru_mr_t; // The actual type is not for public use
typedef enum {
FRU_INTERNAL_USE,
FRU_MIN_AREA = FRU_INTERNAL_USE,
FRU_CHASSIS_INFO,
FRU_BOARD_INFO,
FRU_PRODUCT_INFO,
FRU_MR,
FRU_MAX_AREA = FRU_MR,
FRU_TOTAL_AREAS
} fru_area_type_t;
#define FRU_IS_VALID_AREA(atype) (FRU_MIN_AREA <= (atype) && (atype) <= FRU_MAX_AREA)
#define FRU_FOREACH_AREA(it) for ((it) = FRU_MIN_AREA; (it) <= FRU_MAX_AREA; (it)++)
typedef struct {
bool present[FRU_TOTAL_AREAS];
fru_area_type_t order[FRU_TOTAL_AREAS];
char * internal;
fru_chassis_t chassis;
fru_board_t board;
fru_product_t product;
fru_mr_t mr;
} fru_t;
#define FRU_ATYPE_HAS_TYPE(atype) (FRU_CHASSIS_INFO == (atype))
#define FRU_ATYPE_HAS_LANG(atype) (FRU_BOARD_INFO == (atype) || FRU_PRODUCT_INFO == (atype))
typedef enum {
FRU_NOFLAGS = 0,
FRU_IGNFVER = FRU__BIT(0),
FRU_IGNFHCKSUM = FRU__BIT(1),
FRU_IGNFDCKSUM = FRU__BIT(2),
FRU_IGNAVER = FRU__BIT(3),
FRU_IGNRVER = FRU__BIT(4),
FRU_IGNACKSUM = FRU__BIT(5),
FRU_IGNRHCKSUM = FRU__BIT(6),
FRU_IGNRDCKSUM = FRU__BIT(7),
FRU_IGNRNOEOL = FRU__BIT(8),
FRU_IGNBIG = FRU__BIT(9),
FRU_IGNAEOF = FRU__BIT(10),
FRU_IGNMRVER = FRU__BIT(11),
FRU_IGNMRDATALEN = FRU__BIT(12),
} fru_flags_t;
bool fru_setfield(fru_field_t * field,
fru_field_enc_t encoding,
const char * string);
bool fru_setfield_binary(fru_field_t * field,
const void * buf,
size_t size);
fru_field_t * fru_getfield(const fru_t * fru,
fru_area_type_t atype,
size_t index);
fru_field_t * fru_add_custom(fru_t * fru,
fru_area_type_t atype,
size_t index,
fru_field_enc_t encoding,
const char * string);
fru_field_t * fru_get_custom(const fru_t * fru,
fru_area_type_t atype,
size_t index);
bool fru_delete_custom(fru_t * fru,
fru_area_type_t atype,
size_t index);
#define FRU_ARRAY_SZ(a) (sizeof(a) / sizeof((a)[0]))
int16_t fru_hex2byte(const char * hex);
#define FRU_LIST_HEAD 0
#define FRU_LIST_TAIL INT_MAX
typedef enum {
FRU_APOS_LAST = -3,
FRU_APOS_FIRST = -2,
FRU_APOS_AUTO = -1,
FRU_AFTER_INTERNAL,
FRU_APOS_MIN = FRU_AFTER_INTERNAL,
FRU_AFTER_CHASSIS,
FRU_AFTER_BOARD,
FRU_AFTER_PRODUCT,
FRU_AFTER_MR,
FRU_APOS_MAX = FRU_AFTER_MR,
} fru_area_position_t;
#define FRU_IS_APOS_VALID(pos) (FRU_APOS_LAST <= (pos) && (pos) <= FRU_APOS_MAX)
fru_t * fru_init(fru_t * fru);
fru_t * fru_loadfile(fru_t * fru,
const char * filename,
fru_flags_t flags);
fru_t * fru_loadbuffer(fru_t * fru,
const void * buf,
size_t size,
fru_flags_t flags);
void fru_wipe(fru_t * fru);
#define fru_free(fru) do { fru_wipe(fru); fru__zfree(fru); } while(0)
bool fru_enable_area(fru_t * fru,
fru_area_type_t area,
fru_area_position_t after);
bool fru_disable_area(fru_t * fru, fru_area_type_t atype);
bool fru_move_area(fru_t * fru,
fru_area_type_t area,
fru_area_position_t after);
bool fru_savebuffer(void ** bufptr, size_t * size, const fru_t * fru);
bool fru_savefile(const char * fname, const fru_t * fru);
typedef enum {
FRU_MR_MIN = 0x00,
FRU_MR_PSU_INFO = 0x00,
FRU_MR_DC_OUT = 0x01,
FRU_MR_DC_LOAD = 0x02,
FRU_MR_MGMT_ACCESS = 0x03,
FRU_MR_BCR = 0x04,
FRU_MR_ECR = 0x05,
FRU_MR_ASF_FIXED_SMBUS = 0x06,
FRU_MR_ASF_LEGACY_ALERTS = 0x07,
FRU_MR_ASF_REMOTE_CTRL = 0x08,
FRU_MR_EXT_DC_OUT = 0x09,
FRU_MR_EXT_DC_LOAD = 0x0A,
FRU_MR_NVME = 0x0B,
FRU_MR_NVME_PCIE_PORT = 0x0C,
FRU_MR_NVME_TOPOLOGY = 0x0D,
FRU_MR_NVME_RSVD_E = 0x0E,
FRU_MR_NVME_RSVD_F = 0x0F,
FRU_MR_OEM_START = 0xC0,
FRU_MR_OEM_END = 0xFF,
FRU_MR_MAX = FRU_MR_OEM_END,
FRU_MR_RAW,
FRU_MR_TYPE_COUNT,
FRU_MR_ANY,
FRU_MR_EMPTY,
} fru_mr_type_t;
#define FRU_MR_IS_VALID_TYPE(t) (FRU_MR_MIN <= (t) && (t) <= FRU_MR_MAX)
#define FRU_MR_OEM_COUNT (FRU_MR_OEM_END - FRU_MR_OEM_START + 1)
#define FRU_MR_OEM(n) (FRU_MR_OEM_START + (n))
#define FRU__FILE_MRR_MAXDATA (UINT8_MAX)
#define FRU__FILE_MRR_OEM_MFGID_LEN 3
/*
* Encoded data must not exceed maximum possible MR record
* data size. That's why we subtract the MFG ID length.
*/
#define FRU_MRR_OEM_MAXDATA \
((FRU__FILE_MRR_MAXDATA - FRU__FILE_MRR_OEM_MFGID_LEN) * 2 + 1)
#define FRU_MRR_RAW_MAXDATA \
(FRU__FILE_MRR_MAXDATA * 2 + 1)
typedef enum {
FRU_MR_MGMT_INVALID = 0x00,
FRU_MR_MGMT_MIN = 0x01,
FRU_MR_MGMT_SYS_URL = 0x01,
FRU_MR_MGMT_SYS_NAME = 0x02,
FRU_MR_MGMT_SYS_PING = 0x03,
FRU_MR_MGMT_COMPONENT_URL = 0x04,
FRU_MR_MGMT_COMPONENT_NAME = 0x05,
FRU_MR_MGMT_COMPONENT_PING = 0x06,
FRU_MR_MGMT_SYS_UUID = 0x07,
FRU_MR_MGMT_MAX = FRU_MR_MGMT_SYS_UUID,
FRU_MR_MGMT_INDEX_COUNT = FRU_MR_MGMT_MAX,
} fru_mr_mgmt_type_t;
#define FRU_MR_MGMT_IS_SUBTYPE_VALID(mt) ((mt) >= FRU_MR_MGMT_MIN && (mt) <= FRU_MR_MGMT_MAX)
#define FRU_MR_MGMT_SUBTYPE_TO_IDX(mt) (FRU_MR_MGMT_IS_SUBTYPE_VALID(mt) \
? (int)((mt) - FRU_MR_MGMT_MIN) \
: -1)
#define FRU_MR_MGMT_IDX_TO_SUBTYPE(i) (((i) >= 0 && (i) <= FRU_MR_MGMT_MAX) \
? ((i) + FRU_MR_MGMT_MIN) \
: FRU_MR_MGMT_INVALID)
typedef enum {
FRU_NVME_FF_UNKNOWN = 0,
} fru_nvme_ff_t;
#define FRU__FILE_MR_MGMT_HDR_LEN (sizeof(uint8_t))
#define FRU__FILE_MR_MGMT_MAXDATA \
(FRU__FILE_MRR_MAXDATA - FRU__FILE_MR_MGMT_HDR_LEN)
/*
* All management subtype records are plain text strings,
* and even UUID, which is binary, in decoded form is
* represented as a sting of 32 hex digits, which is at
* least twice less than the maximum length for any of the
* plain text subtypes.
*
* Hence, encoded and decoded lengths for plain text strings
* are the same, we just use the max encoded length here
*/
#define FRU_MR_MGMT_MAXDATA (FRU__FILE_MR_MGMT_MAXDATA)
typedef struct {
fru_mr_type_t type;
union {
struct {
} psu;
struct {
} dco;
struct {
} edco;
struct {
} dcl;
struct {
} edcl;
struct {
fru_mr_mgmt_type_t subtype;
char data[FRU_MR_MGMT_MAXDATA + 1]; /* 1 byte for terminator */
} mgmt;
struct {
} bcr;
struct {
} ecr;
struct {
union {
struct {
} smbus;
struct {
} legacy;
struct {
} rc;
};
} asf;
struct {
union {
struct {
fru_nvme_ff_t formfactor;
uint8_t p1v8_init;
uint8_t p1v8_max;
uint8_t p3v3_init;
uint8_t p3v3_max;
uint8_t p3v3_aux_max;
uint8_t p5v_init;
uint8_t p5v_max;
uint8_t p12v_init;
uint8_t p12v_max;
uint8_t ptherm_max;
uint64_t capacity_lo;
uint32_t capacity_mid;
uint8_t capacity_hi;
} info;
struct {
} pcie;
struct {
} topology;
};
} nvme;
struct {
uint32_t mfg_id;
fru_field_enc_t enc;
char data[FRU_MRR_OEM_MAXDATA];
} oem;
struct {
uint8_t type;
fru_field_enc_t enc;
char data[FRU_MRR_RAW_MAXDATA];
} raw;
};
} fru_mr_rec_t;
fru_mr_rec_t * fru_add_mr(fru_t * fru, size_t index, fru_mr_rec_t * rec);
fru_mr_rec_t * fru_get_mr(const fru_t * fru, size_t index);
fru_mr_rec_t * fru_find_mr(const fru_t * fru, fru_mr_type_t type, size_t * index);
bool fru_replace_mr(fru_t * fru, size_t index, fru_mr_rec_t * rec);
bool fru_delete_mr(fru_t * fru, size_t index);
bool fru_set_internal_binary(fru_t * fru, const void * buffer, size_t size);
bool fru_set_internal_hexstring(fru_t * fru, const void * hexstr);
bool fru_delete_internal(fru_t * fru);
FRU_FIELDMAXARRAY
#define FRU_FIELDMAXARRAY
For C-string allocation.
Definition fru.h:136
fru_board_field_t
fru_board_field_t
Indices of mandatory fields in Board Info Area.
Definition fru.h:445
fru_lang_t
fru_lang_t
Language code definitions as per IPMI FRU Specification, Table 15-1.
Definition fru.h:407
FRU_BOARD_MFG
@ FRU_BOARD_MFG
Definition fru.h:446
FRU_BOARD_SERIAL
@ FRU_BOARD_SERIAL
Definition fru.h:448
FRU_BOARD_PARTNO
@ FRU_BOARD_PARTNO
Definition fru.h:449
FRU_BOARD_FIELD_COUNT
@ FRU_BOARD_FIELD_COUNT
Definition fru.h:451
FRU_BOARD_FILE
@ FRU_BOARD_FILE
Definition fru.h:450
FRU_BOARD_PRODNAME
@ FRU_BOARD_PRODNAME
Definition fru.h:447
FRU_LANG_ENGLISH
@ FRU_LANG_ENGLISH
English language code.
Definition fru.h:409
FRU_LANG_DEFAULT
@ FRU_LANG_DEFAULT
Default Language code, implies English as per Table 15-1.
Definition fru.h:408
fru_chassis_field_t
fru_chassis_field_t
Indices of mandatory fields in Chassis Info Area.
Definition fru.h:387
FRU_CHASSIS_SERIAL
@ FRU_CHASSIS_SERIAL
Definition fru.h:389
FRU_CHASSIS_PARTNO
@ FRU_CHASSIS_PARTNO
Definition fru.h:388
FRU_CHASSIS_FIELD_COUNT
@ FRU_CHASSIS_FIELD_COUNT
Definition fru.h:390
fru_flags_t
fru_flags_t
Debug flags to FRU decoding functions.
Definition fru.h:625
fru_savefile
bool fru_savefile(const char *fname, const fru_t *fru)
Encode a FRU info structure into a binary file.
fru_area_position_t
fru_area_position_t
Define FRU area position in the binary file.
Definition fru.h:905
fru_savebuffer
bool fru_savebuffer(void **bufptr, size_t *size, const fru_t *fru)
Encode a FRU info structure into a binary buffer.
fru_enable_area
bool fru_enable_area(fru_t *fru, fru_area_type_t area, fru_area_position_t after)
Enable a previously disabled / non-present area.
fru_disable_area
bool fru_disable_area(fru_t *fru, fru_area_type_t atype)
Disable a previously enabled / present area.
fru_loadfile
fru_t * fru_loadfile(fru_t *fru, const char *filename, fru_flags_t flags)
Load FRU information from a binary file.
fru_loadbuffer
fru_t * fru_loadbuffer(fru_t *fru, const void *buf, size_t size, fru_flags_t flags)
Load FRU information from a binary file.
fru_area_type_t
fru_area_type_t
FRU area types.
Definition fru.h:519
fru_init
fru_t * fru_init(fru_t *fru)
Initialize/allocate a fru structure.
fru_wipe
void fru_wipe(fru_t *fru)
Wipe the contents of a fru_t structure.
fru_move_area
bool fru_move_area(fru_t *fru, fru_area_type_t area, fru_area_position_t after)
Move an enabled/present area.
FRU_IGNRDCKSUM
@ FRU_IGNRDCKSUM
Ignore record data checksum for multirecord area.
Definition fru.h:636
FRU_IGNMRDATALEN
@ FRU_IGNMRDATALEN
Ignore invalid MR record data length where possible.
Definition fru.h:646
FRU_IGNACKSUM
@ FRU_IGNACKSUM
Ignore area checksum.
Definition fru.h:633
FRU_IGNFHCKSUM
@ FRU_IGNFHCKSUM
Ignore FRU header checksum.
Definition fru.h:628
FRU_IGNRVER
@ FRU_IGNRVER
Ignore record version for multirecord area.
Definition fru.h:631
FRU_IGNBIG
@ FRU_IGNBIG
Don't fail on binary file load if the file is bigger than 64K, attempt to load it anyway (may be dang...
Definition fru.h:641
FRU_IGNFVER
@ FRU_IGNFVER
Ignore FRU version in FRU header.
Definition fru.h:627
FRU_IGNAVER
@ FRU_IGNAVER
Ignore area version.
Definition fru.h:630
FRU_NOFLAGS
@ FRU_NOFLAGS
No flags, operate normally.
Definition fru.h:626
FRU_IGNMRVER
@ FRU_IGNMRVER
Ignore invalid MR record version where possible.
Definition fru.h:645
FRU_IGNRHCKSUM
@ FRU_IGNRHCKSUM
Ignore record header checksum for multirecord area.
Definition fru.h:634
FRU_IGNAEOF
@ FRU_IGNAEOF
Ignore no end-of-fields marker in info areas.
Definition fru.h:644
FRU_IGNRNOEOL
@ FRU_IGNRNOEOL
Ignore absence of EOL-flagged MR area record, use any previous valid records.
Definition fru.h:638
FRU_IGNFDCKSUM
@ FRU_IGNFDCKSUM
Ignore FRU data checksum.
Definition fru.h:629
FRU_APOS_FIRST
@ FRU_APOS_FIRST
Put an area first in the order.
Definition fru.h:907
FRU_AFTER_BOARD
@ FRU_AFTER_BOARD
Put an area after Board Info Area.
Definition fru.h:913
FRU_AFTER_INTERNAL
@ FRU_AFTER_INTERNAL
Put an area after Internal Use Area.
Definition fru.h:910
FRU_AFTER_PRODUCT
@ FRU_AFTER_PRODUCT
Put an area after Product Info Area.
Definition fru.h:914
FRU_APOS_AUTO
@ FRU_APOS_AUTO
Position an area automatically as per the default order given in FRU Spec.
Definition fru.h:908
FRU_APOS_LAST
@ FRU_APOS_LAST
Put an area last in the order.
Definition fru.h:906
FRU_APOS_MAX
@ FRU_APOS_MAX
Maximum 'real' position.
Definition fru.h:916
FRU_AFTER_MR
@ FRU_AFTER_MR
Put an area after Multirecord Area.
Definition fru.h:915
FRU_APOS_MIN
@ FRU_APOS_MIN
Minimum 'real' position.
Definition fru.h:911
FRU_AFTER_CHASSIS
@ FRU_AFTER_CHASSIS
Put an area after Chassis Info Area.
Definition fru.h:912
FRU_BOARD_INFO
@ FRU_BOARD_INFO
Board information area.
Definition fru.h:523
FRU_INTERNAL_USE
@ FRU_INTERNAL_USE
Internal use area.
Definition fru.h:520
FRU_MR
@ FRU_MR
Multirecord area.
Definition fru.h:525
FRU_MAX_AREA
@ FRU_MAX_AREA
Maximum area type (equals FRU_MR).
Definition fru.h:526
FRU_TOTAL_AREAS
@ FRU_TOTAL_AREAS
Maximum total count of areas in a FRU file.
Definition fru.h:527
FRU_PRODUCT_INFO
@ FRU_PRODUCT_INFO
Product information area.
Definition fru.h:524
FRU_CHASSIS_INFO
@ FRU_CHASSIS_INFO
Chassis information area.
Definition fru.h:522
FRU_MIN_AREA
@ FRU_MIN_AREA
Minimum area type (equals FRU_INTERNAL_USE).
Definition fru.h:521
fru_setfield
bool fru_setfield(fru_field_t *field, fru_field_enc_t encoding, const char *string)
Copy string to the given field, perform length check according to selected encoding,...
fru_delete_custom
bool fru_delete_custom(fru_t *fru, fru_area_type_t atype, size_t index)
Delete a custom data field in the area of the given type in the given fru structure.
fru_custom_t
void * fru_custom_t
A list of custom fields of an info area.
Definition fru.h:356
fru_field_enc_t
fru_field_enc_t
Field encoding type.
Definition fru.h:265
fru_setfield_binary
bool fru_setfield_binary(fru_field_t *field, const void *buf, size_t size)
Copy a binary input buffer into the given field, perform length check, truncate if needed.
fru_add_custom
fru_field_t * fru_add_custom(fru_t *fru, fru_area_type_t atype, size_t index, fru_field_enc_t encoding, const char *string)
Add a custom field to the given area type in the given fru structure.
fru_get_custom
fru_field_t * fru_get_custom(const fru_t *fru, fru_area_type_t atype, size_t index)
Get a pointer to a custom data field in the area of the given type in the given fru structure.
fru_getfield
fru_field_t * fru_getfield(const fru_t *fru, fru_area_type_t atype, size_t index)
Get a pointer to a mandatory field in the info area of the given type in the given fru structure.
FRU_FE_AUTO
@ FRU_FE_AUTO
When saving, detect the encoding automatically based on the character range of fru_field_t....
Definition fru.h:289
FRU_FE_BINARY
@ FRU_FE_BINARY
Encode the field as binary, the value is a hex string (e.g., 1337C0DE).
Definition fru.h:273
FRU_FE_TOTALCOUNT
@ FRU_FE_TOTALCOUNT
Total count of all field encodings (including the extensions).
Definition fru.h:295
FRU_FE_MAX
@ FRU_FE_MAX
Maximim valid 'real' field encoding, equals FRU_FE_TEXT.
Definition fru.h:287
FRU_FE_PRESERVE
@ FRU_FE_PRESERVE
Preserve the field encoding as it was, fail if impossible.
Definition fru.h:292
FRU_FE_BASE
@ FRU_FE_BASE
Base encoding, starting at which all the binary FRU file field encodings are mapped.
Definition fru.h:271
FRU_FE_EMPTY
@ FRU_FE_EMPTY
The field is empty.
Definition fru.h:266
FRU_FE_UNKNOWN
@ FRU_FE_UNKNOWN
Field encoding couldn't be detected or wasn't set.
Definition fru.h:291
FRU_FE_TEXT
@ FRU_FE_TEXT
Encode the field as plain text (ASCII+Latin1).
Definition fru.h:284
FRU_FE_6BITASCII
@ FRU_FE_6BITASCII
Encode the field as 6-bit ASCII, the value may only contain characters per Table 13-1 of IPMI FRU Spe...
Definition fru.h:280
FRU_FE_BCDPLUS
@ FRU_FE_BCDPLUS
Encode the field as BCD+, the value may only contain digits 0-9, space, dash, or period.
Definition fru.h:277
FRU_FE_MIN
@ FRU_FE_MIN
The minumum non-auto (real) encoding, equals FRU_FE_BINARY.
Definition fru.h:275
FRU_FE_REALCOUNT
@ FRU_FE_REALCOUNT
Total count of standard field encodings (not including the extensions).
Definition fru.h:297
fru_delete_internal
bool fru_delete_internal(fru_t *fru)
Delete internal use area from FRU structure.
fru_set_internal_hexstring
bool fru_set_internal_hexstring(fru_t *fru, const void *hexstr)
Set internal use area from a hex string.
fru_set_internal_binary
bool fru_set_internal_binary(fru_t *fru, const void *buffer, size_t size)
Set internal use area from binary buffer.
FRU_MRR_RAW_MAXDATA
#define FRU_MRR_RAW_MAXDATA
Maximum length of Custom/Raw MR record data in decoded form (NUL-terminated hex string).
Definition fru.h:1275
fru_get_mr
fru_mr_rec_t * fru_get_mr(const fru_t *fru, size_t index)
Get a multirecord area record at the given index.
FRU_MR_MGMT_MAXDATA
#define FRU_MR_MGMT_MAXDATA
Maximum length of data in MR Management Access record.
Definition fru.h:1346
fru_nvme_ff_t
fru_nvme_ff_t
NVMe Form-Factor, see NVMe-MI Spec rev 1.2b, Figure 160.
Definition fru.h:1320
fru_mr_type_t
fru_mr_type_t
MultiRecord Area Record Types (Table 16-2).
Definition fru.h:1214
fru_mr_t
void * fru_mr_t
A pointer to multi-record area descriptor.
Definition fru.h:506
fru_replace_mr
bool fru_replace_mr(fru_t *fru, size_t index, fru_mr_rec_t *rec)
Replace a multirecord area record at the given index.
FRU_MRR_OEM_MAXDATA
#define FRU_MRR_OEM_MAXDATA
Maximum length of OEM MR record data in decoded form (NUL-terminated hex string).
Definition fru.h:1269
fru_mr_mgmt_type_t
fru_mr_mgmt_type_t
Management Access Record subtypes (Table 18-6).
Definition fru.h:1281
fru_add_mr
fru_mr_rec_t * fru_add_mr(fru_t *fru, size_t index, fru_mr_rec_t *rec)
Add a multirecord area record.
fru_find_mr
fru_mr_rec_t * fru_find_mr(const fru_t *fru, fru_mr_type_t type, size_t *index)
Find a multirecord area record of the given type or at the given index.
fru_delete_mr
bool fru_delete_mr(fru_t *fru, size_t index)
Delete a multirecord area record at the given index.
FRU_NVME_FF_UNKNOWN
@ FRU_NVME_FF_UNKNOWN
Definition fru.h:1321
FRU_MR_ECR
@ FRU_MR_ECR
Extended Compatibility Record.
Definition fru.h:1221
FRU_MR_RAW
@ FRU_MR_RAW
The raw type.
Definition fru.h:1239
FRU_MR_DC_OUT
@ FRU_MR_DC_OUT
DC Output.
Definition fru.h:1217
FRU_MR_PSU_INFO
@ FRU_MR_PSU_INFO
PSU Information.
Definition fru.h:1216
FRU_MR_DC_LOAD
@ FRU_MR_DC_LOAD
DC Load.
Definition fru.h:1218
FRU_MR_NVME_PCIE_PORT
@ FRU_MR_NVME_PCIE_PORT
NVMe PCIe Port.
Definition fru.h:1231
FRU_MR_ASF_FIXED_SMBUS
@ FRU_MR_ASF_FIXED_SMBUS
ASF Fixed SMBus Addresses.
Definition fru.h:1223
FRU_MR_OEM_END
@ FRU_MR_OEM_END
End of OEM range.
Definition fru.h:1237
FRU_MR_NVME
@ FRU_MR_NVME
NVMe Information.
Definition fru.h:1230
FRU_MR_BCR
@ FRU_MR_BCR
Base Compatibility Record.
Definition fru.h:1220
FRU_MR_NVME_RSVD_F
@ FRU_MR_NVME_RSVD_F
Reserved.
Definition fru.h:1234
FRU_MR_MIN
@ FRU_MR_MIN
The minimum valid MR record type that can be saved.
Definition fru.h:1215
FRU_MR_EXT_DC_OUT
@ FRU_MR_EXT_DC_OUT
Extended DC Output.
Definition fru.h:1227
FRU_MR_MGMT_ACCESS
@ FRU_MR_MGMT_ACCESS
Management Access Record.
Definition fru.h:1219
FRU_MR_EMPTY
@ FRU_MR_EMPTY
MR Record is empty, will be skipped during saving.
Definition fru.h:1242
FRU_MR_TYPE_COUNT
@ FRU_MR_TYPE_COUNT
Total number of MR record types (including 'raw').
Definition fru.h:1240
FRU_MR_ASF_LEGACY_ALERTS
@ FRU_MR_ASF_LEGACY_ALERTS
ASF Lecacy-Device Alerts.
Definition fru.h:1224
FRU_MR_OEM_START
@ FRU_MR_OEM_START
Start of OEM range.
Definition fru.h:1236
FRU_MR_ASF_REMOTE_CTRL
@ FRU_MR_ASF_REMOTE_CTRL
ASF Remote Control.
Definition fru.h:1225
FRU_MR_MAX
@ FRU_MR_MAX
The maximum valid MR record type that can be saved.
Definition fru.h:1238
FRU_MR_NVME_RSVD_E
@ FRU_MR_NVME_RSVD_E
Reserved.
Definition fru.h:1233
FRU_MR_ANY
@ FRU_MR_ANY
Any MR Record type, for use with fru_find_mr() only.
Definition fru.h:1241
FRU_MR_EXT_DC_LOAD
@ FRU_MR_EXT_DC_LOAD
Extended DC Load.
Definition fru.h:1228
FRU_MR_NVME_TOPOLOGY
@ FRU_MR_NVME_TOPOLOGY
NVMe Topolgy.
Definition fru.h:1232
FRU_MR_MGMT_SYS_NAME
@ FRU_MR_MGMT_SYS_NAME
System Name.
Definition fru.h:1285
FRU_MR_MGMT_MIN
@ FRU_MR_MGMT_MIN
The minimum valid (real) subtype.
Definition fru.h:1283
FRU_MR_MGMT_INVALID
@ FRU_MR_MGMT_INVALID
Invalid subtype, do not use.
Definition fru.h:1282
FRU_MR_MGMT_SYS_UUID
@ FRU_MR_MGMT_SYS_UUID
System Unique ID.
Definition fru.h:1290
FRU_MR_MGMT_INDEX_COUNT
@ FRU_MR_MGMT_INDEX_COUNT
The count of 0-based indices of valid subtypes, can be used as an array dimension.
Definition fru.h:1292
FRU_MR_MGMT_COMPONENT_URL
@ FRU_MR_MGMT_COMPONENT_URL
Component URL.
Definition fru.h:1287
FRU_MR_MGMT_MAX
@ FRU_MR_MGMT_MAX
The maximum valid subtype.
Definition fru.h:1291
FRU_MR_MGMT_COMPONENT_NAME
@ FRU_MR_MGMT_COMPONENT_NAME
Component Name.
Definition fru.h:1288
FRU_MR_MGMT_SYS_PING
@ FRU_MR_MGMT_SYS_PING
System Ping Address.
Definition fru.h:1286
FRU_MR_MGMT_SYS_URL
@ FRU_MR_MGMT_SYS_URL
System URL.
Definition fru.h:1284
FRU_MR_MGMT_COMPONENT_PING
@ FRU_MR_MGMT_COMPONENT_PING
Component Ping Address.
Definition fru.h:1289
fru_prod_field_t
fru_prod_field_t
Indices of mandatory fields in Product Info Area.
Definition fru.h:483
FRU_PROD_NAME
@ FRU_PROD_NAME
Definition fru.h:485
FRU_PROD_FILE
@ FRU_PROD_FILE
Definition fru.h:490
FRU_PROD_FIELD_COUNT
@ FRU_PROD_FIELD_COUNT
Definition fru.h:491
FRU_PROD_ASSET
@ FRU_PROD_ASSET
Definition fru.h:489
FRU_PROD_SERIAL
@ FRU_PROD_SERIAL
Definition fru.h:488
FRU_PROD_MFG
@ FRU_PROD_MFG
Definition fru.h:484
FRU_PROD_MODELPN
@ FRU_PROD_MODELPN
Definition fru.h:486
FRU_PROD_VERSION
@ FRU_PROD_VERSION
Definition fru.h:487
fru_hex2byte
int16_t fru_hex2byte(const char *hex)
Convert 2 first bytes of hex string into a binary byte.
fru_board_t
The exploded representation of board info area.
Definition fru.h:420
fru_board_t::tv
struct timeval tv
Manufacturing date/time, in UTC.
Definition fru.h:422
fru_board_t::serial
fru_field_t serial
Board serial number.
Definition fru.h:432
fru_board_t::pname
fru_field_t pname
Board product name.
Definition fru.h:431
fru_board_t::file
fru_field_t file
FRU File ID.
Definition fru.h:434
fru_board_t::mfg
fru_field_t mfg
Board manufacturer name.
Definition fru.h:430
fru_board_t::lang
fru_lang_t lang
Language code.
Definition fru.h:421
fru_board_t::tv_auto
bool tv_auto
On save, use current date/time.
Definition fru.h:423
fru_board_t::cust
fru_custom_t cust
List of custom fields.
Definition fru.h:435
fru_board_t::pn
fru_field_t pn
Board part number.
Definition fru.h:433
fru_chassis_t
The exploded representation of chassis info area.
Definition fru.h:373
fru_chassis_t::type
uint8_t type
Chassis type as per SMBIOS specification.
Definition fru.h:374
fru_chassis_t::pn
fru_field_t pn
Part Number.
Definition fru.h:375
fru_chassis_t::cust
fru_custom_t cust
List of custom fields.
Definition fru.h:377
fru_chassis_t::serial
fru_field_t serial
Serial Number.
Definition fru.h:376
fru_field_t
A generic input (decoded) field structure.
Definition fru.h:347
fru_field_t::enc
fru_field_enc_t enc
The encoding of the field.
Definition fru.h:348
fru_field_t::val
char val[FRU_FIELDMAXARRAY]
The decoded C-string representation of the field value.
Definition fru.h:352
fru_mr_rec_t
MultiRecord area record type.
Definition fru.h:1377
fru_mr_rec_t::enc
fru_field_enc_t enc
OEM data encoding.
Definition fru.h:1485
fru_mr_rec_t::p1v8_max
uint8_t p1v8_max
Definition fru.h:1456
fru_mr_rec_t::p3v3_init
uint8_t p3v3_init
Definition fru.h:1457
fru_mr_rec_t::p12v_init
uint8_t p12v_init
Definition fru.h:1462
fru_mr_rec_t::p12v_max
uint8_t p12v_max
Definition fru.h:1463
fru_mr_rec_t::data
char data[FRU_MR_MGMT_MAXDATA+1]
Management Access Record data.
Definition fru.h:1418
fru_mr_rec_t::p3v3_aux_max
uint8_t p3v3_aux_max
Definition fru.h:1459
fru_mr_rec_t::p5v_max
uint8_t p5v_max
Definition fru.h:1461
fru_mr_rec_t::type
fru_mr_type_t type
Record Type.
Definition fru.h:1378
fru_mr_rec_t::mfg_id
uint32_t mfg_id
Manufacturer ID, 24 bits.
Definition fru.h:1483
fru_mr_rec_t::p5v_init
uint8_t p5v_init
Definition fru.h:1460
fru_mr_rec_t::formfactor
fru_nvme_ff_t formfactor
Form-Factor as per NVMe-MI 1.2b Figure 160.
Definition fru.h:1454
fru_mr_rec_t::ptherm_max
uint8_t ptherm_max
Definition fru.h:1464
fru_mr_rec_t::capacity_lo
uint64_t capacity_lo
Total capacity, higher 8 bytes, 13:6 of 13, host-endian.
Definition fru.h:1465
fru_mr_rec_t::p1v8_init
uint8_t p1v8_init
Definition fru.h:1455
fru_mr_rec_t::p3v3_max
uint8_t p3v3_max
Definition fru.h:1458
fru_mr_rec_t::capacity_mid
uint32_t capacity_mid
Total capacity, middle 4 bytes, 5:2 of 13, host-endian.
Definition fru.h:1466
fru_mr_rec_t::subtype
fru_mr_mgmt_type_t subtype
Management Access Record subtype.
Definition fru.h:1403
fru_mr_rec_t::capacity_hi
uint8_t capacity_hi
Total capacity, middle 4 bytes, 1 of 13.
Definition fru.h:1467
fru_product_t
The exploded representation of product info area.
Definition fru.h:464
fru_product_t::file
fru_field_t file
FRU File ID.
Definition fru.h:472
fru_product_t::serial
fru_field_t serial
Product serial number.
Definition fru.h:470
fru_product_t::mfg
fru_field_t mfg
Product manufacturer.
Definition fru.h:466
fru_product_t::lang
fru_lang_t lang
Definition fru.h:465
fru_product_t::atag
fru_field_t atag
Product asset tag.
Definition fru.h:471
fru_product_t::pn
fru_field_t pn
Product part number.
Definition fru.h:468
fru_product_t::pname
fru_field_t pname
Product name.
Definition fru.h:467
fru_product_t::ver
fru_field_t ver
Product version.
Definition fru.h:469
fru_product_t::cust
fru_custom_t cust
List of custom fields.
Definition fru.h:473
fru_t
Exploded/decoded FRU data structure.
Definition fru.h:574
fru_t::internal
char * internal
Internal use area as a hex string.
Definition fru.h:601
fru_t::mr
fru_mr_t mr
The multi-record area descriptor.
Definition fru.h:605
fru_t::board
fru_board_t board
The board information structure.
Definition fru.h:603
fru_t::order
fru_area_type_t order[FRU_TOTAL_AREAS]
Order of the areas in the original binary fru file, or the order in which to save the structure into ...
Definition fru.h:585
fru_t::chassis
fru_chassis_t chassis
The chassis information structure.
Definition fru.h:602
fru_t::present
bool present[FRU_TOTAL_AREAS]
Area presence flags.
Definition fru.h:575
fru_t::product
fru_product_t product
The product information structure.
Definition fru.h:604