lazybios 3.0.0
Lightweight SMBIOS/DMI parsing library
Loading...
Searching...
No Matches
lazybios_internal.h File Reference

Internal constants and parser helpers for lazybios implementation files. More...

#include "lazybios/lazybios.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  lazybiosEntryInspection

Macros

#define DEV_MEM   "/dev/mem"
 Absolute path to the physical memory device.
#define LAZYBIOS_CLAMP_STRUCTURE_LENGTH(len, p, end)
 Clamps a structure length against available buffer boundaries.
#define LAZYBIOS_DECODER_BUF_SIZE   1024
 Scratch buffer size for the file-local decoders.
#define LAZYBIOS_MARK_ABSENT(record, field)
 Marks a parsed structure field as absent.
#define LAZYBIOS_MARK_PRESENT(record, field)
 Marks a parsed structure field as present and valid.
#define LAZYBIOS_MARK_UNREACHABLE(record, field)
 Marks a parsed structure field as unreachable (structure too short for newer spec version).
#define lb_dbg(...)
#define lb_log(...)
#define LINUX_SYSFS_DMI_TABLE   "/sys/firmware/dmi/tables/DMI"
 Absolute path to the Linux sysfs DMI table.
#define LINUX_SYSFS_SMBIOS_ENTRY   "/sys/firmware/dmi/tables/smbios_entry_point"
 Absolute path to the Linux sysfs SMBIOS entry point.
#define READSTR(record, field, len, offset, p, end)
#define READU16(record, field, len, offset, p)
#define READU32(record, field, len, offset, p)
#define READU64(record, field, len, offset, p)
#define READU8(record, field, len, offset, p)
#define SMBIOS2_ANCHOR   "_SM_"
#define SMBIOS2_ANCHOR_OFFSET   0x00
#define SMBIOS2_ANCHOR_SIZE   4
#define SMBIOS2_BCD_REVISION_OFFSET   0x1E
#define SMBIOS2_CHECKSUM_OFFSET   0x04
#define SMBIOS2_ENTRY_POINT_LENGTH   0x1F
#define SMBIOS2_ENTRY_POINT_LENGTH_V21   0x1E
#define SMBIOS2_FORMATTED_AREA_OFFSET   0x0B
#define SMBIOS2_FORMATTED_AREA_SIZE   5
#define SMBIOS2_INTERMEDIATE_ANCHOR   "_DMI_"
#define SMBIOS2_INTERMEDIATE_ANCHOR_OFFSET   0x10
#define SMBIOS2_INTERMEDIATE_ANCHOR_SIZE   5
#define SMBIOS2_INTERMEDIATE_CHECKSUM_OFFSET   0x15
#define SMBIOS2_LENGTH_OFFSET   0x05
#define SMBIOS2_MAJOR_OFFSET   0x06
#define SMBIOS2_MAX_STRUCTURE_SIZE_OFFSET   0x08
#define SMBIOS2_MINOR_OFFSET   0x07
#define SMBIOS2_REVISION_OFFSET   0x0A
#define SMBIOS2_STRUCTURE_COUNT_OFFSET   0x1C
#define SMBIOS2_TABLE_ADDRESS_OFFSET   0x18
#define SMBIOS2_TABLE_LENGTH_OFFSET   0x16
#define SMBIOS3_ANCHOR   "_SM3_"
#define SMBIOS3_ANCHOR_OFFSET   0x00
#define SMBIOS3_ANCHOR_SIZE   5
#define SMBIOS3_CHECKSUM_OFFSET   0x05
#define SMBIOS3_DOCREV_OFFSET   0x09
#define SMBIOS3_ENTRY_POINT_LENGTH   0x18
#define SMBIOS3_LENGTH_OFFSET   0x06
#define SMBIOS3_MAJOR_OFFSET   0x07
#define SMBIOS3_MINOR_OFFSET   0x08
#define SMBIOS3_RESERVED_OFFSET   0x0B
#define SMBIOS3_REVISION_OFFSET   0x0A
#define SMBIOS3_TABLE_ADDRESS_OFFSET   0x10
#define SMBIOS3_TABLE_MAX_SIZE_OFFSET   0x0C
#define SMBIOS_HEADER_SIZE   4
 Size of an SMBIOS structure header (type, length, handle).
#define SMBIOS_OEM_DELL_TYPE177   177
#define SMBIOS_OEM_DELL_TYPE212   212
#define SMBIOS_OEM_DELL_TYPE218   218
#define SMBIOS_OEM_HP_TYPE204   204
#define SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION   18
#define SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION   33
#define SMBIOS_TYPE_ADDITIONAL_INFORMATION   40
#define SMBIOS_TYPE_BASEBOARD   2
#define SMBIOS_TYPE_BIOS   0
#define SMBIOS_TYPE_BOOT_INTEGRITY_SERVICES_ENTRY_POINT   31
#define SMBIOS_TYPE_BUILT_IN_POINTING_DEVICE   21
#define SMBIOS_TYPE_CACHES   7
#define SMBIOS_TYPE_CHASSIS   3
#define SMBIOS_TYPE_COOLING_DEVICE   27
#define SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE   29
#define SMBIOS_TYPE_END   127
#define SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION   45
#define SMBIOS_TYPE_FIRMWARE_LANGUAGE_INFORMATION   13
#define SMBIOS_TYPE_GROUP_ASSOCIATIONS   14
#define SMBIOS_TYPE_HARDWARE_SECURITY   24
#define SMBIOS_TYPE_IPMI_DEVICE_INFORMATION   38
#define SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE   42
#define SMBIOS_TYPE_MANAGEMENT_DEVICE   34
#define SMBIOS_TYPE_MANAGEMENT_DEVICE_COMPONENT   35
#define SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA   36
#define SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS   19
#define SMBIOS_TYPE_MEMORY_CHANNEL   37
#define SMBIOS_TYPE_MEMORY_CONTROLLER   5
#define SMBIOS_TYPE_MEMORY_DEVICE   17
#define SMBIOS_TYPE_MEMORY_DEVICE_MAPPED_ADDRESS   20
#define SMBIOS_TYPE_MEMORY_MODULE   6
#define SMBIOS_TYPE_OEM_STRINGS   11
#define SMBIOS_TYPE_ONBOARD_DEVICES   10
#define SMBIOS_TYPE_ONBOARD_DEVICES_EXTENDED_INFORMATION   41
#define SMBIOS_TYPE_OUT_OF_BAND_REMOTE_ACCESS   30
#define SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY   16
#define SMBIOS_TYPE_PORT_CONNECTOR   8
#define SMBIOS_TYPE_PORTABLE_BATTERY   22
#define SMBIOS_TYPE_PROCESSOR   4
#define SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION   44
#define SMBIOS_TYPE_STRING_PROPERTY   46
#define SMBIOS_TYPE_SYSTEM   1
#define SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION   32
#define SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS   12
#define SMBIOS_TYPE_SYSTEM_EVENT_LOG   15
#define SMBIOS_TYPE_SYSTEM_POWER_CONTROLS   25
#define SMBIOS_TYPE_SYSTEM_POWER_SUPPLY   39
#define SMBIOS_TYPE_SYSTEM_RESET   23
#define SMBIOS_TYPE_SYSTEM_SLOTS   9
#define SMBIOS_TYPE_TEMPERATURE_PROBE   28
#define SMBIOS_TYPE_TPM_DEVICE   43
#define SMBIOS_TYPE_VOLTAGE_PROBE   26

Functions

const uint8_t * DMINext (const uint8_t *p, const uint8_t *end)
 Locates the next SMBIOS structure in a DMI table.
const char * DMIString (const uint8_t *p, uint8_t length, uint8_t index, const uint8_t *end)
 Copies a string from an SMBIOS structure's string-set.
static void lazybios_log_internal (const char *prefix, const char *fmt,...)
size_t lazybiosCountStructsByType (const lazybiosDMI_t *DMIData, uint8_t target_type)
 Counts SMBIOS structures having a specified type identifier.
static void lazybiosDecoderAppend (char *buf, size_t buf_len, size_t *len, const char *fmt,...)
 Appends formatted text to a decoder output buffer.
static char * lazybiosDup (const char *src)
 Duplicates a NUL-terminated string with malloc.
LAZYBIOS_WARN_UNUSED int lazybiosFile (lazybiosCTX_t *ctx, const char *entry_path, const char *dmi_path)
 Loads an SMBIOS entry point and DMI table from separate files.
int lazybiosFindSMBIOSEntryPoint (const uint8_t *image, size_t image_len, size_t *entry_offset, size_t *entry_len)
 Finds a valid SMBIOS entry point within a memory image.
int lazybiosGetSingleFileLayout (const uint8_t *entry_data, size_t available, size_t file_len, size_t *entry_len, size_t *table_offset, size_t *table_len)
 Determines the entry-point and table layout in a combined dump file.
int lazybiosGetSMBIOSTableLocation (const uint8_t *entry_data, size_t available, size_t *entry_len, uint64_t *table_address, size_t *table_len)
 Extracts an SMBIOS table address and length from an entry point.
int lazybiosInspectEntryPoint (const uint8_t *entry_data, size_t available, lazybiosEntryInspection *inspection)
 Inspects and validates an SMBIOS 2.x or 3.x entry point.
int lazybiosLoadRawBuffers (lazybiosCTX_t *ctx, const uint8_t *entry_data, size_t entry_len, const uint8_t *dmi_data, size_t dmi_len)
 Copies validated raw entry-point and DMI-table buffers into a context.
int lazybiosLoadWindowsRawSMBIOSData (lazybiosCTX_t *ctx, const uint8_t *raw_data, size_t raw_len)
 Loads the Windows raw SMBIOS table format into a context.
int lazybiosParseEntry (lazybiosCTX_t *ctx, const uint8_t *entry_buf, size_t buf_len)
 Validates and identifies an SMBIOS entry point.
LAZYBIOS_WARN_UNUSED int lazybiosSingleFile (lazybiosCTX_t *ctx, const char *bin_path)
 Loads SMBIOS entry point and DMI data from one merged file.

Detailed Description

Internal constants and parser helpers for lazybios implementation files.

Author
LazySeldi

Definition in file lazybios_internal.h.

Macro Definition Documentation

◆ DEV_MEM

#define DEV_MEM   "/dev/mem"

Absolute path to the physical memory device.

Definition at line 151 of file lazybios_internal.h.

◆ LAZYBIOS_CLAMP_STRUCTURE_LENGTH

#define LAZYBIOS_CLAMP_STRUCTURE_LENGTH ( len,
p,
end )
Value:
do { \
if ((size_t)((end) - (p)) < (size_t)(len)) { \
(len) = (uint8_t)((end) - (p)); \
} \
} while (0)

Clamps a structure length against available buffer boundaries.

Definition at line 264 of file lazybios_internal.h.

◆ LAZYBIOS_DECODER_BUF_SIZE

#define LAZYBIOS_DECODER_BUF_SIZE   1024

Scratch buffer size for the file-local decoders.

The longest decoding in the corpus is a Type 0 characteristics list at just over 500 bytes, so this leaves generous headroom; the decoded text is copied to an exact-sized allocation afterwards.

Definition at line 122 of file lazybios_internal.h.

◆ LAZYBIOS_MARK_ABSENT

#define LAZYBIOS_MARK_ABSENT ( record,
field )
Value:
do { \
(record)->field_status.field = (lazybiosFieldStatus_t)LAZYBIOS_FIELD_ABSENT; \
} while (0)
@ LAZYBIOS_FIELD_ABSENT
Definition lazybios.h:102
uint8_t lazybiosFieldStatus_t
Storage for one field's availability.
Definition lazybios.h:115

Marks a parsed structure field as absent.

Definition at line 254 of file lazybios_internal.h.

◆ LAZYBIOS_MARK_PRESENT

#define LAZYBIOS_MARK_PRESENT ( record,
field )
Value:
do { \
(record)->field_status.field = (lazybiosFieldStatus_t)LAZYBIOS_FIELD_PRESENT; \
} while (0)
@ LAZYBIOS_FIELD_PRESENT
Definition lazybios.h:103

Marks a parsed structure field as present and valid.

Definition at line 249 of file lazybios_internal.h.

◆ LAZYBIOS_MARK_UNREACHABLE

#define LAZYBIOS_MARK_UNREACHABLE ( record,
field )
Value:
do { \
(record)->field_status.field = (lazybiosFieldStatus_t)LAZYBIOS_FIELD_UNREACHABLE; \
} while (0)
@ LAZYBIOS_FIELD_UNREACHABLE
Definition lazybios.h:104

Marks a parsed structure field as unreachable (structure too short for newer spec version).

Definition at line 259 of file lazybios_internal.h.

◆ lb_dbg

#define lb_dbg ( ...)
Value:
((void)0)

Definition at line 63 of file lazybios_internal.h.

◆ lb_log

#define lb_log ( ...)
Value:
lazybios_log_internal("[lazybios] ", __VA_ARGS__)
static void lazybios_log_internal(const char *prefix, const char *fmt,...)

Definition at line 62 of file lazybios_internal.h.

◆ LINUX_SYSFS_DMI_TABLE

#define LINUX_SYSFS_DMI_TABLE   "/sys/firmware/dmi/tables/DMI"

Absolute path to the Linux sysfs DMI table.

Definition at line 148 of file lazybios_internal.h.

◆ LINUX_SYSFS_SMBIOS_ENTRY

#define LINUX_SYSFS_SMBIOS_ENTRY   "/sys/firmware/dmi/tables/smbios_entry_point"

Absolute path to the Linux sysfs SMBIOS entry point.

Definition at line 145 of file lazybios_internal.h.

◆ READSTR

#define READSTR ( record,
field,
len,
offset,
p,
end )
Value:
do { \
if ((len) > (offset)) { \
(record)->field = DMIString((p), (len), (p)[(offset)], (end)); \
if ((record)->field != NULL) { \
LAZYBIOS_MARK_PRESENT((record), field); \
} else { \
LAZYBIOS_MARK_ABSENT((record), field); \
} \
} else { \
(record)->field = NULL; \
LAZYBIOS_MARK_ABSENT((record), field); \
} \
} while (0)
const char * DMIString(const uint8_t *p, uint8_t length, uint8_t index, const uint8_t *end)
Copies a string from an SMBIOS structure's string-set.

Definition at line 350 of file lazybios_internal.h.

◆ READU16

#define READU16 ( record,
field,
len,
offset,
p )
Value:
do { \
if ((size_t)(len) >= (size_t)(offset) + sizeof(uint16_t)) { \
memcpy(&(record)->field, (p) + (offset), sizeof(uint16_t)); \
LAZYBIOS_MARK_PRESENT((record), field); \
} else { \
(record)->field = 0; \
LAZYBIOS_MARK_ABSENT((record), field); \
} \
} while (0)

Definition at line 374 of file lazybios_internal.h.

◆ READU32

#define READU32 ( record,
field,
len,
offset,
p )
Value:
do { \
if ((size_t)(len) >= (size_t)(offset) + sizeof(uint32_t)) { \
memcpy(&(record)->field, (p) + (offset), sizeof(uint32_t)); \
LAZYBIOS_MARK_PRESENT((record), field); \
} else { \
(record)->field = 0; \
LAZYBIOS_MARK_ABSENT((record), field); \
} \
} while (0)

Definition at line 384 of file lazybios_internal.h.

◆ READU64

#define READU64 ( record,
field,
len,
offset,
p )
Value:
do { \
if ((size_t)(len) >= (size_t)(offset) + sizeof(uint64_t)) { \
memcpy(&(record)->field, (p) + (offset), sizeof(uint64_t)); \
LAZYBIOS_MARK_PRESENT((record), field); \
} else { \
(record)->field = 0; \
LAZYBIOS_MARK_ABSENT((record), field); \
} \
} while (0)

Definition at line 394 of file lazybios_internal.h.

◆ READU8

#define READU8 ( record,
field,
len,
offset,
p )
Value:
do { \
if ((len) > (offset)) { \
(record)->field = (p)[(offset)]; \
LAZYBIOS_MARK_PRESENT((record), field); \
} else { \
(record)->field = 0; \
LAZYBIOS_MARK_ABSENT((record), field); \
} \
} while (0)

Definition at line 364 of file lazybios_internal.h.

◆ SMBIOS2_ANCHOR

#define SMBIOS2_ANCHOR   "_SM_"

Definition at line 226 of file lazybios_internal.h.

◆ SMBIOS2_ANCHOR_OFFSET

#define SMBIOS2_ANCHOR_OFFSET   0x00

Definition at line 228 of file lazybios_internal.h.

◆ SMBIOS2_ANCHOR_SIZE

#define SMBIOS2_ANCHOR_SIZE   4

Definition at line 244 of file lazybios_internal.h.

◆ SMBIOS2_BCD_REVISION_OFFSET

#define SMBIOS2_BCD_REVISION_OFFSET   0x1E

Definition at line 241 of file lazybios_internal.h.

◆ SMBIOS2_CHECKSUM_OFFSET

#define SMBIOS2_CHECKSUM_OFFSET   0x04

Definition at line 229 of file lazybios_internal.h.

◆ SMBIOS2_ENTRY_POINT_LENGTH

#define SMBIOS2_ENTRY_POINT_LENGTH   0x1F

Definition at line 242 of file lazybios_internal.h.

◆ SMBIOS2_ENTRY_POINT_LENGTH_V21

#define SMBIOS2_ENTRY_POINT_LENGTH_V21   0x1E

Definition at line 243 of file lazybios_internal.h.

◆ SMBIOS2_FORMATTED_AREA_OFFSET

#define SMBIOS2_FORMATTED_AREA_OFFSET   0x0B

Definition at line 235 of file lazybios_internal.h.

◆ SMBIOS2_FORMATTED_AREA_SIZE

#define SMBIOS2_FORMATTED_AREA_SIZE   5

Definition at line 246 of file lazybios_internal.h.

◆ SMBIOS2_INTERMEDIATE_ANCHOR

#define SMBIOS2_INTERMEDIATE_ANCHOR   "_DMI_"

Definition at line 227 of file lazybios_internal.h.

◆ SMBIOS2_INTERMEDIATE_ANCHOR_OFFSET

#define SMBIOS2_INTERMEDIATE_ANCHOR_OFFSET   0x10

Definition at line 236 of file lazybios_internal.h.

◆ SMBIOS2_INTERMEDIATE_ANCHOR_SIZE

#define SMBIOS2_INTERMEDIATE_ANCHOR_SIZE   5

Definition at line 245 of file lazybios_internal.h.

◆ SMBIOS2_INTERMEDIATE_CHECKSUM_OFFSET

#define SMBIOS2_INTERMEDIATE_CHECKSUM_OFFSET   0x15

Definition at line 237 of file lazybios_internal.h.

◆ SMBIOS2_LENGTH_OFFSET

#define SMBIOS2_LENGTH_OFFSET   0x05

Definition at line 230 of file lazybios_internal.h.

◆ SMBIOS2_MAJOR_OFFSET

#define SMBIOS2_MAJOR_OFFSET   0x06

Definition at line 231 of file lazybios_internal.h.

◆ SMBIOS2_MAX_STRUCTURE_SIZE_OFFSET

#define SMBIOS2_MAX_STRUCTURE_SIZE_OFFSET   0x08

Definition at line 233 of file lazybios_internal.h.

◆ SMBIOS2_MINOR_OFFSET

#define SMBIOS2_MINOR_OFFSET   0x07

Definition at line 232 of file lazybios_internal.h.

◆ SMBIOS2_REVISION_OFFSET

#define SMBIOS2_REVISION_OFFSET   0x0A

Definition at line 234 of file lazybios_internal.h.

◆ SMBIOS2_STRUCTURE_COUNT_OFFSET

#define SMBIOS2_STRUCTURE_COUNT_OFFSET   0x1C

Definition at line 240 of file lazybios_internal.h.

◆ SMBIOS2_TABLE_ADDRESS_OFFSET

#define SMBIOS2_TABLE_ADDRESS_OFFSET   0x18

Definition at line 239 of file lazybios_internal.h.

◆ SMBIOS2_TABLE_LENGTH_OFFSET

#define SMBIOS2_TABLE_LENGTH_OFFSET   0x16

Definition at line 238 of file lazybios_internal.h.

◆ SMBIOS3_ANCHOR

#define SMBIOS3_ANCHOR   "_SM3_"

Definition at line 212 of file lazybios_internal.h.

◆ SMBIOS3_ANCHOR_OFFSET

#define SMBIOS3_ANCHOR_OFFSET   0x00

Definition at line 213 of file lazybios_internal.h.

◆ SMBIOS3_ANCHOR_SIZE

#define SMBIOS3_ANCHOR_SIZE   5

Definition at line 224 of file lazybios_internal.h.

◆ SMBIOS3_CHECKSUM_OFFSET

#define SMBIOS3_CHECKSUM_OFFSET   0x05

Definition at line 214 of file lazybios_internal.h.

◆ SMBIOS3_DOCREV_OFFSET

#define SMBIOS3_DOCREV_OFFSET   0x09

Definition at line 218 of file lazybios_internal.h.

◆ SMBIOS3_ENTRY_POINT_LENGTH

#define SMBIOS3_ENTRY_POINT_LENGTH   0x18

Definition at line 223 of file lazybios_internal.h.

◆ SMBIOS3_LENGTH_OFFSET

#define SMBIOS3_LENGTH_OFFSET   0x06

Definition at line 215 of file lazybios_internal.h.

◆ SMBIOS3_MAJOR_OFFSET

#define SMBIOS3_MAJOR_OFFSET   0x07

Definition at line 216 of file lazybios_internal.h.

◆ SMBIOS3_MINOR_OFFSET

#define SMBIOS3_MINOR_OFFSET   0x08

Definition at line 217 of file lazybios_internal.h.

◆ SMBIOS3_RESERVED_OFFSET

#define SMBIOS3_RESERVED_OFFSET   0x0B

Definition at line 220 of file lazybios_internal.h.

◆ SMBIOS3_REVISION_OFFSET

#define SMBIOS3_REVISION_OFFSET   0x0A

Definition at line 219 of file lazybios_internal.h.

◆ SMBIOS3_TABLE_ADDRESS_OFFSET

#define SMBIOS3_TABLE_ADDRESS_OFFSET   0x10

Definition at line 222 of file lazybios_internal.h.

◆ SMBIOS3_TABLE_MAX_SIZE_OFFSET

#define SMBIOS3_TABLE_MAX_SIZE_OFFSET   0x0C

Definition at line 221 of file lazybios_internal.h.

◆ SMBIOS_HEADER_SIZE

#define SMBIOS_HEADER_SIZE   4

Size of an SMBIOS structure header (type, length, handle).

Definition at line 142 of file lazybios_internal.h.

◆ SMBIOS_OEM_DELL_TYPE177

#define SMBIOS_OEM_DELL_TYPE177   177

Definition at line 207 of file lazybios_internal.h.

◆ SMBIOS_OEM_DELL_TYPE212

#define SMBIOS_OEM_DELL_TYPE212   212

Definition at line 208 of file lazybios_internal.h.

◆ SMBIOS_OEM_DELL_TYPE218

#define SMBIOS_OEM_DELL_TYPE218   218

Definition at line 209 of file lazybios_internal.h.

◆ SMBIOS_OEM_HP_TYPE204

#define SMBIOS_OEM_HP_TYPE204   204

Definition at line 203 of file lazybios_internal.h.

◆ SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION

#define SMBIOS_TYPE_32BIT_MEMORY_ERROR_INFORMATION   18

Definition at line 171 of file lazybios_internal.h.

◆ SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION

#define SMBIOS_TYPE_64BIT_MEMORY_ERROR_INFORMATION   33

Definition at line 186 of file lazybios_internal.h.

◆ SMBIOS_TYPE_ADDITIONAL_INFORMATION

#define SMBIOS_TYPE_ADDITIONAL_INFORMATION   40

Definition at line 193 of file lazybios_internal.h.

◆ SMBIOS_TYPE_BASEBOARD

#define SMBIOS_TYPE_BASEBOARD   2

Definition at line 155 of file lazybios_internal.h.

◆ SMBIOS_TYPE_BIOS

#define SMBIOS_TYPE_BIOS   0

Definition at line 153 of file lazybios_internal.h.

◆ SMBIOS_TYPE_BOOT_INTEGRITY_SERVICES_ENTRY_POINT

#define SMBIOS_TYPE_BOOT_INTEGRITY_SERVICES_ENTRY_POINT   31

Definition at line 184 of file lazybios_internal.h.

◆ SMBIOS_TYPE_BUILT_IN_POINTING_DEVICE

#define SMBIOS_TYPE_BUILT_IN_POINTING_DEVICE   21

Definition at line 174 of file lazybios_internal.h.

◆ SMBIOS_TYPE_CACHES

#define SMBIOS_TYPE_CACHES   7

Definition at line 160 of file lazybios_internal.h.

◆ SMBIOS_TYPE_CHASSIS

#define SMBIOS_TYPE_CHASSIS   3

Definition at line 156 of file lazybios_internal.h.

◆ SMBIOS_TYPE_COOLING_DEVICE

#define SMBIOS_TYPE_COOLING_DEVICE   27

Definition at line 180 of file lazybios_internal.h.

◆ SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE

#define SMBIOS_TYPE_ELECTRICAL_CURRENT_PROBE   29

Definition at line 182 of file lazybios_internal.h.

◆ SMBIOS_TYPE_END

#define SMBIOS_TYPE_END   127

Definition at line 200 of file lazybios_internal.h.

◆ SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION

#define SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION   45

Definition at line 198 of file lazybios_internal.h.

◆ SMBIOS_TYPE_FIRMWARE_LANGUAGE_INFORMATION

#define SMBIOS_TYPE_FIRMWARE_LANGUAGE_INFORMATION   13

Definition at line 166 of file lazybios_internal.h.

◆ SMBIOS_TYPE_GROUP_ASSOCIATIONS

#define SMBIOS_TYPE_GROUP_ASSOCIATIONS   14

Definition at line 167 of file lazybios_internal.h.

◆ SMBIOS_TYPE_HARDWARE_SECURITY

#define SMBIOS_TYPE_HARDWARE_SECURITY   24

Definition at line 177 of file lazybios_internal.h.

◆ SMBIOS_TYPE_IPMI_DEVICE_INFORMATION

#define SMBIOS_TYPE_IPMI_DEVICE_INFORMATION   38

Definition at line 191 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE

#define SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE   42

Definition at line 195 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MANAGEMENT_DEVICE

#define SMBIOS_TYPE_MANAGEMENT_DEVICE   34

Definition at line 187 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MANAGEMENT_DEVICE_COMPONENT

#define SMBIOS_TYPE_MANAGEMENT_DEVICE_COMPONENT   35

Definition at line 188 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA

#define SMBIOS_TYPE_MANAGEMENT_DEVICE_THRESHOLD_DATA   36

Definition at line 189 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS

#define SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS   19

Definition at line 172 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MEMORY_CHANNEL

#define SMBIOS_TYPE_MEMORY_CHANNEL   37

Definition at line 190 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MEMORY_CONTROLLER

#define SMBIOS_TYPE_MEMORY_CONTROLLER   5

Definition at line 158 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MEMORY_DEVICE

#define SMBIOS_TYPE_MEMORY_DEVICE   17

Definition at line 170 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MEMORY_DEVICE_MAPPED_ADDRESS

#define SMBIOS_TYPE_MEMORY_DEVICE_MAPPED_ADDRESS   20

Definition at line 173 of file lazybios_internal.h.

◆ SMBIOS_TYPE_MEMORY_MODULE

#define SMBIOS_TYPE_MEMORY_MODULE   6

Definition at line 159 of file lazybios_internal.h.

◆ SMBIOS_TYPE_OEM_STRINGS

#define SMBIOS_TYPE_OEM_STRINGS   11

Definition at line 164 of file lazybios_internal.h.

◆ SMBIOS_TYPE_ONBOARD_DEVICES

#define SMBIOS_TYPE_ONBOARD_DEVICES   10

Definition at line 163 of file lazybios_internal.h.

◆ SMBIOS_TYPE_ONBOARD_DEVICES_EXTENDED_INFORMATION

#define SMBIOS_TYPE_ONBOARD_DEVICES_EXTENDED_INFORMATION   41

Definition at line 194 of file lazybios_internal.h.

◆ SMBIOS_TYPE_OUT_OF_BAND_REMOTE_ACCESS

#define SMBIOS_TYPE_OUT_OF_BAND_REMOTE_ACCESS   30

Definition at line 183 of file lazybios_internal.h.

◆ SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY

#define SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY   16

Definition at line 169 of file lazybios_internal.h.

◆ SMBIOS_TYPE_PORT_CONNECTOR

#define SMBIOS_TYPE_PORT_CONNECTOR   8

Definition at line 161 of file lazybios_internal.h.

◆ SMBIOS_TYPE_PORTABLE_BATTERY

#define SMBIOS_TYPE_PORTABLE_BATTERY   22

Definition at line 175 of file lazybios_internal.h.

◆ SMBIOS_TYPE_PROCESSOR

#define SMBIOS_TYPE_PROCESSOR   4

Definition at line 157 of file lazybios_internal.h.

◆ SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION

#define SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION   44

Definition at line 197 of file lazybios_internal.h.

◆ SMBIOS_TYPE_STRING_PROPERTY

#define SMBIOS_TYPE_STRING_PROPERTY   46

Definition at line 199 of file lazybios_internal.h.

◆ SMBIOS_TYPE_SYSTEM

#define SMBIOS_TYPE_SYSTEM   1

Definition at line 154 of file lazybios_internal.h.

◆ SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION

#define SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION   32

Definition at line 185 of file lazybios_internal.h.

◆ SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS

#define SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS   12

Definition at line 165 of file lazybios_internal.h.

◆ SMBIOS_TYPE_SYSTEM_EVENT_LOG

#define SMBIOS_TYPE_SYSTEM_EVENT_LOG   15

Definition at line 168 of file lazybios_internal.h.

◆ SMBIOS_TYPE_SYSTEM_POWER_CONTROLS

#define SMBIOS_TYPE_SYSTEM_POWER_CONTROLS   25

Definition at line 178 of file lazybios_internal.h.

◆ SMBIOS_TYPE_SYSTEM_POWER_SUPPLY

#define SMBIOS_TYPE_SYSTEM_POWER_SUPPLY   39

Definition at line 192 of file lazybios_internal.h.

◆ SMBIOS_TYPE_SYSTEM_RESET

#define SMBIOS_TYPE_SYSTEM_RESET   23

Definition at line 176 of file lazybios_internal.h.

◆ SMBIOS_TYPE_SYSTEM_SLOTS

#define SMBIOS_TYPE_SYSTEM_SLOTS   9

Definition at line 162 of file lazybios_internal.h.

◆ SMBIOS_TYPE_TEMPERATURE_PROBE

#define SMBIOS_TYPE_TEMPERATURE_PROBE   28

Definition at line 181 of file lazybios_internal.h.

◆ SMBIOS_TYPE_TPM_DEVICE

#define SMBIOS_TYPE_TPM_DEVICE   43

Definition at line 196 of file lazybios_internal.h.

◆ SMBIOS_TYPE_VOLTAGE_PROBE

#define SMBIOS_TYPE_VOLTAGE_PROBE   26

Definition at line 179 of file lazybios_internal.h.

Function Documentation

◆ DMINext()

const uint8_t * DMINext ( const uint8_t * p,
const uint8_t * end )

Locates the next SMBIOS structure in a DMI table.

Parameters
pStart of the current SMBIOS structure.
endOne-past-the-end address of the DMI table buffer.
Returns
Pointer to the next structure, or end when no complete structure remains.

References DMINext().

Referenced by DMINext().

◆ DMIString()

const char * DMIString ( const uint8_t * p,
uint8_t length,
uint8_t index,
const uint8_t * end )

Copies a string from an SMBIOS structure's string-set.

Parameters
pStart of the SMBIOS structure.
lengthLength of the structure's formatted section.
indexOne-based index of the requested string.
endAddress of the next structure, as returned by DMINext, which is two bytes past this structure's string-set terminator.
Returns
Pointer to a string in the DMI table, or NULL if the string is unavailable or invalid.

References DMIString(), index, and length.

Referenced by DMIString().

◆ lazybios_log_internal()

void lazybios_log_internal ( const char * prefix,
const char * fmt,
... )
inlinestatic

Definition at line 43 of file lazybios_internal.h.

References fmt, and lazybios_log_internal().

Referenced by lazybios_log_internal().

◆ lazybiosCountStructsByType()

size_t lazybiosCountStructsByType ( const lazybiosDMI_t * DMIData,
uint8_t target_type )

Counts SMBIOS structures having a specified type identifier.

Parameters
DMIDataRaw DMI table container to inspect.
target_typeSMBIOS structure type identifier to count.
Returns
Number of matching structures in the table, -1 if index is already filled.

References lazybiosCountStructsByType().

Referenced by lazybiosCountStructsByType().

◆ lazybiosDecoderAppend()

void lazybiosDecoderAppend ( char * buf,
size_t buf_len,
size_t * len,
const char * fmt,
... )
inlinestatic

Appends formatted text to a decoder output buffer.

snprintf returns the length the output would have had, so accumulating its return value lets the running length run past the buffer: the next append then writes at buf + len with a wrapped-around buf_len - len. This keeps *len at the number of bytes actually written, never above buf_len - 1, so later appends and the trailing-separator trim stay inside the buffer.

Parameters
bufOutput buffer, may be NULL only when buf_len is zero.
buf_lenCapacity of buf in bytes.
lenRunning output length, updated in place.
fmtprintf-style format for the text to append.

Definition at line 85 of file lazybios_internal.h.

References fmt, and lazybiosDecoderAppend().

Referenced by lazybiosDecoderAppend().

◆ lazybiosDup()

char * lazybiosDup ( const char * src)
inlinestatic

Duplicates a NUL-terminated string with malloc.

strdup is POSIX rather than C99, so the parsers use this when storing a decoded string that the record owns.

Parameters
srcString to copy, may be NULL.
Returns
Newly allocated copy, or NULL on failure or a NULL input.

Definition at line 133 of file lazybios_internal.h.

References lazybiosDup().

Referenced by lazybiosDup().

◆ lazybiosFile()

LAZYBIOS_WARN_UNUSED int lazybiosFile ( lazybiosCTX_t * ctx,
const char * entry_path,
const char * dmi_path )

Loads an SMBIOS entry point and DMI table from separate files.

Parameters
ctxContext that receives the loaded data.
entry_pathPath to the raw SMBIOS entry point file.
dmi_pathPath to the raw DMI structure table file.
Returns
0 on success, or -1 on failure.

References LAZYBIOS_WARN_UNUSED, and lazybiosFile().

Referenced by lazybiosFile().

◆ lazybiosFindSMBIOSEntryPoint()

int lazybiosFindSMBIOSEntryPoint ( const uint8_t * image,
size_t image_len,
size_t * entry_offset,
size_t * entry_len )

Finds a valid SMBIOS entry point within a memory image.

References lazybiosFindSMBIOSEntryPoint().

Referenced by lazybiosFindSMBIOSEntryPoint().

◆ lazybiosGetSingleFileLayout()

int lazybiosGetSingleFileLayout ( const uint8_t * entry_data,
size_t available,
size_t file_len,
size_t * entry_len,
size_t * table_offset,
size_t * table_len )

Determines the entry-point and table layout in a combined dump file.

References lazybiosGetSingleFileLayout().

Referenced by lazybiosGetSingleFileLayout().

◆ lazybiosGetSMBIOSTableLocation()

int lazybiosGetSMBIOSTableLocation ( const uint8_t * entry_data,
size_t available,
size_t * entry_len,
uint64_t * table_address,
size_t * table_len )

Extracts an SMBIOS table address and length from an entry point.

References lazybiosGetSMBIOSTableLocation().

Referenced by lazybiosGetSMBIOSTableLocation().

◆ lazybiosInspectEntryPoint()

int lazybiosInspectEntryPoint ( const uint8_t * entry_data,
size_t available,
lazybiosEntryInspection * inspection )

Inspects and validates an SMBIOS 2.x or 3.x entry point.

References lazybiosInspectEntryPoint().

Referenced by lazybiosInspectEntryPoint().

◆ lazybiosLoadRawBuffers()

int lazybiosLoadRawBuffers ( lazybiosCTX_t * ctx,
const uint8_t * entry_data,
size_t entry_len,
const uint8_t * dmi_data,
size_t dmi_len )

Copies validated raw entry-point and DMI-table buffers into a context.

References lazybiosLoadRawBuffers().

Referenced by lazybiosLoadRawBuffers().

◆ lazybiosLoadWindowsRawSMBIOSData()

int lazybiosLoadWindowsRawSMBIOSData ( lazybiosCTX_t * ctx,
const uint8_t * raw_data,
size_t raw_len )

Loads the Windows raw SMBIOS table format into a context.

References lazybiosLoadWindowsRawSMBIOSData().

Referenced by lazybiosLoadWindowsRawSMBIOSData().

◆ lazybiosParseEntry()

int lazybiosParseEntry ( lazybiosCTX_t * ctx,
const uint8_t * entry_buf,
size_t buf_len )

Validates and identifies an SMBIOS entry point.

Parameters
ctxContext whose entry tag and tagged union are updated.
entry_bufBuffer containing an SMBIOS 2.x or 3.x entry point.
buf_lenLength of entry_buf in bytes.
Returns
0 on success, or -1 if the entry point is invalid.

References lazybiosParseEntry().

Referenced by lazybiosParseEntry().

◆ lazybiosSingleFile()

LAZYBIOS_WARN_UNUSED int lazybiosSingleFile ( lazybiosCTX_t * ctx,
const char * bin_path )

Loads SMBIOS entry point and DMI data from one merged file.

Parameters
ctxContext that receives the loaded data.
bin_pathPath to a file containing the entry point and DMI table, either concatenated or separated by an advertised file-relative offset.
Returns
0 on success, or -1 on failure.

References LAZYBIOS_WARN_UNUSED, and lazybiosSingleFile().

Referenced by lazybiosSingleFile().