DMI_FIELD
Synopsis
#include <opendmi/field.h>
DMI_FIELD(structure, member, wire_type, ...)
DMI_FIELD_STRING(structure, member, ...)
DMI_FIELD_UUID(structure, member, ...)
DMI_FIELD_BCD(structure, member, wire_type, ...)
DMI_FIELD_BINARY(structure, member, length, ...)
DMI_FIELD_SKIP(length)
DMI_FIELD_PRESET(structure, member, value)
DMI_FIELDS({ field, ..., {} })
#define DMI_FIELD_LENGTH_REST SIZE_MAX
#define DMI_FIELD_LENGTH_MEMBER (SIZE_MAX - 1)
Description
The macros declare the fields of a specification, the fields member of
dmi_entity_spec_t, which dmi_fields_decode reads a structure by and
dmi_fields_encode writes it back by. Fields are listed in the order the
structure holds them, starting right after the header, and each one names the
member of the decoded structure it is read into.
Fields describe the bytes, while the attributes declared with
DMI_ATTRIBUTE describe the values they are read into; the two are joined
by the member they name.
DMI_FIELD-
Integer of the width of
wire_type, e.g.dmi_word_t, read little-endian intomember, which may be wider than the field: the value standing for "unknown" is then read as the largest value of the member, so that it does not collide with a value a device may really have. DMI_FIELD_STRING-
String reference, read into a
const char *member pointing at the string it refers to, or atnullptrif it refers to none. DMI_FIELD_UUID-
Sixteen bytes holding a UUID, read into a
dmi_uuid_tmember with the fields put into the order RFC 4122 gives them. DMI_FIELD_BCD-
Binary-coded decimal of the width of
wire_type, read into the number its digits spell. DMI_FIELD_BINARY-
lengthbytes taken as they are, read into admi_binary_tmember which refers to them in place.DMI_FIELD_LENGTH_RESTtakes the bytes running to the end of the structure, andDMI_FIELD_LENGTH_MEMBERas many bytes as thelengthof the member says, which a field before has set. DMI_FIELD_SKIP-
lengthbytes the structure holds and nothing reads, which are stepped over on decoding and kept as they are on encoding. DMI_FIELD_PRESET-
Member the data does not carry, set to
valuebefore any field is read, for the members meaning something other than zero until the rest of the table gives them a value. It occupies no bytes. DMI_FIELDS-
List of the fields, a compound literal of
dmi_field_t. The list is terminated by an empty field,{}, which the list itself ends with.
Other kinds of fields have pages of their own: ranges of bits,
DMI_FIELD_BITS; arrays and vectors, DMI_FIELD_ARRAY; groups and
boundaries, DMI_FIELD_GROUP; fields widened by a later version,
DMI_FIELD_EXTENDED; and fields feeding several members,
DMI_FIELD_SPLIT.
Parameters
structure-
Type of the structure the fields belong to: the decoded structure, or the element of an array.
member-
Member of
structurethe field is read into. wire_type-
Type the field is written with in the data, whose size is the width of the field, e.g.
dmi_byte_t,dmi_word_t,dmi_dword_tordmi_qword_t. …-
Further parameters, given as the designated initializers of
dmi_field_params_t, of which the fields take:.decode,.encode-
Pair of handlers turning the data into the member and back, for the values which mean something other than the number the data carries. They are required in pairs for the structure to be encoded.
.unknown_raw-
Value standing for "unknown" in the data, which the member holds as its largest value. Zero means the field has none.
.absent-
Pointer to the value the member holds when the data ends before the field, for the members whose zero means something else.