coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
smbios.c File Reference
#include <assert.h>
#include <string.h>
#include <smbios.h>
#include <console/console.h>
#include <version.h>
#include <device/device.h>
#include <device/dram/spd.h>
#include <arch/cpu.h>
#include <cpu/x86/name.h>
#include <elog.h>
#include <endian.h>
#include <memory_info.h>
#include <spd.h>
#include <cbmem.h>
#include <commonlib/helpers.h>
#include <device/pci_ids.h>
#include <device/pci_def.h>
#include <device/pci.h>
#include <drivers/vpd/vpd.h>
#include <stdlib.h>
Include dependency graph for smbios.c:

Go to the source code of this file.

Macros

#define update_max(len, max_len, stmt)
 
#define VERSION_VPD   "firmware_version"
 
#define SPACES    " "
 

Functions

static u8 smbios_checksum (u8 *p, u32 length)
 
int smbios_add_string (u8 *start, const char *str)
 
int smbios_string_table_len (u8 *start)
 
int smbios_full_table_len (struct smbios_header *header, u8 *str_table_start)
 
voidsmbios_carve_table (unsigned long start, u8 type, u8 length, u16 handle)
 
static int smbios_cpu_vendor (u8 *start)
 
static int smbios_processor_name (u8 *start)
 
void smbios_fill_dimm_manufacturer_from_id (uint16_t mod_id, struct smbios_type17 *t)
 
static void trim_trailing_whitespace (char *buffer, size_t buffer_size)
 
static void smbios_fill_dimm_part_number (const char *part_number, struct smbios_type17 *t)
 This function will fill the corresponding part number. More...
 
static void smbios_fill_dimm_serial_number (const struct dimm_info *dimm, struct smbios_type17 *t)
 
static int create_smbios_type17_for_dimm (struct dimm_info *dimm, unsigned long *current, int *handle, int type16_handle)
 
static const char * vpd_get_bios_version (void)
 
static const char * get_bios_version (void)
 
static int smbios_write_type0 (unsigned long *current, int handle)
 
static int get_socket_type (void)
 
unsigned int __weak smbios_processor_external_clock (void)
 
unsigned int __weak smbios_processor_characteristics (void)
 
unsigned int __weak smbios_processor_family (struct cpuid_result res)
 
unsigned int __weak smbios_cache_error_correction_type (u8 level)
 
unsigned int __weak smbios_cache_sram_type (void)
 
unsigned int __weak smbios_cache_conf_operation_mode (u8 level)
 
unsigned int __weak smbios_cpu_get_voltage (void)
 
static size_t get_number_of_caches (size_t max_logical_cpus_sharing_cache)
 
static int smbios_write_type1 (unsigned long *current, int handle)
 
static int smbios_write_type2 (unsigned long *current, int handle, const int chassis_handle)
 
static int smbios_write_type3 (unsigned long *current, int handle)
 
static int smbios_write_type4 (unsigned long *current, int handle)
 
static int smbios_write_type7 (unsigned long *current, const int handle, const u8 level, const u8 sram_type, const enum smbios_cache_associativity associativity, const enum smbios_cache_type type, const size_t max_cache_size, const size_t cache_size)
 
static enum smbios_cache_associativity smbios_cache_associativity (const u8 num)
 
static int smbios_write_type7_cache_parameters (unsigned long *current, int *handle, int *max_struct_size, struct smbios_type4 *type4)
 
int smbios_write_type8 (unsigned long *current, int *handle, const struct port_information *port, size_t num_ports)
 
int smbios_write_type9 (unsigned long *current, int *handle, const char *name, const enum misc_slot_type type, const enum slot_data_bus_bandwidth bandwidth, const enum misc_slot_usage usage, const enum misc_slot_length length, const u16 id, u8 slot_char1, u8 slot_char2, u8 bus, u8 dev_func)
 
static int smbios_write_type11 (unsigned long *current, int *handle)
 
static int smbios_write_type16 (unsigned long *current, int *handle)
 
static int smbios_write_type17 (unsigned long *current, int *handle, int type16)
 
static int smbios_write_type19 (unsigned long *current, int *handle, int type16)
 
static int smbios_write_type20_table (unsigned long *current, int *handle, u32 addr_start, u32 addr_end, int type17_handle, int type19_handle)
 
static int smbios_write_type20 (unsigned long *current, int *handle, int type17_handle, int type19_handle)
 
static int smbios_write_type32 (unsigned long *current, int handle)
 
int smbios_write_type38 (unsigned long *current, int *handle, const enum smbios_bmc_interface_type interface_type, const u8 ipmi_rev, const u8 i2c_addr, const u8 nv_addr, const u64 base_addr, const u8 base_modifier, const u8 irq)
 
int smbios_write_type41 (unsigned long *current, int *handle, const char *name, u8 instance, u16 segment, u8 bus, u8 device, u8 function, u8 device_type)
 
static int smbios_write_type127 (unsigned long *current, int handle)
 
static u8 smbios_get_device_type_from_dev (struct device *dev)
 
static bool smbios_get_type41_instance_id (struct device *dev, u8 device_type, u8 *instance_id)
 
static const char * smbios_get_type41_refdes (struct device *dev)
 
static int smbios_generate_type41_from_devtree (struct device *dev, int *handle, unsigned long *current)
 
static int smbios_generate_type9_from_devtree (struct device *dev, int *handle, unsigned long *current)
 
int get_smbios_data (struct device *dev, int *handle, unsigned long *current)
 
static int smbios_walk_device_tree (struct device *tree, int *handle, unsigned long *current)
 
unsigned long smbios_write_tables (unsigned long current)
 

Macro Definition Documentation

◆ SPACES

#define SPACES    " "

◆ update_max

#define update_max (   len,
  max_len,
  stmt 
)
Value:
do { \
int tmp = stmt; \
\
max_len = MAX(max_len, tmp); \
len += tmp; \
} while (0)
#define MAX(a, b)
Definition: helpers.h:40

Definition at line 24 of file smbios.c.

◆ VERSION_VPD

#define VERSION_VPD   "firmware_version"

Definition at line 280 of file smbios.c.

Function Documentation

◆ create_smbios_type17_for_dimm()

◆ get_bios_version()

static const char* get_bios_version ( void  )
static

Definition at line 304 of file smbios.c.

References BIOS_DEBUG, CONFIG, coreboot_version, NULL, printk, s, smbios_mainboard_bios_version(), SPACES, strlen(), and vpd_get_bios_version().

Referenced by smbios_write_type0().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_number_of_caches()

static size_t get_number_of_caches ( size_t  max_logical_cpus_sharing_cache)
static

Definition at line 432 of file smbios.c.

References cpu_have_cpuid(), cpuid, cpuid_ext(), cpuid_get_max_func(), and cpuid_result::ebx.

Referenced by smbios_write_type7_cache_parameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_smbios_data()

int get_smbios_data ( struct device dev,
int *  handle,
unsigned long *  current 
)

Definition at line 1261 of file smbios.c.

References smbios_generate_type41_from_devtree(), and smbios_generate_type9_from_devtree().

Referenced by smbios_walk_device_tree(), and smbios_write_wifi_pcie().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_socket_type()

static int get_socket_type ( void  )
static

Definition at line 382 of file smbios.c.

References CONFIG.

Referenced by smbios_write_type4().

Here is the caller graph for this function:

◆ smbios_add_string()

◆ smbios_cache_associativity()

◆ smbios_cache_conf_operation_mode()

unsigned int __weak smbios_cache_conf_operation_mode ( u8  level)

Definition at line 421 of file smbios.c.

References SMBIOS_CACHE_OP_MODE_UNKNOWN.

Referenced by smbios_cache_associativity().

Here is the caller graph for this function:

◆ smbios_cache_error_correction_type()

unsigned int __weak smbios_cache_error_correction_type ( u8  level)

Definition at line 411 of file smbios.c.

References SMBIOS_CACHE_ERROR_CORRECTION_UNKNOWN.

Referenced by smbios_cache_associativity().

Here is the caller graph for this function:

◆ smbios_cache_sram_type()

unsigned int __weak smbios_cache_sram_type ( void  )

Definition at line 416 of file smbios.c.

References SMBIOS_CACHE_SRAM_TYPE_UNKNOWN.

Referenced by smbios_write_type7_cache_parameters().

Here is the caller graph for this function:

◆ smbios_carve_table()

◆ smbios_checksum()

static u8 smbios_checksum ( u8 p,
u32  length 
)
static

Definition at line 32 of file smbios.c.

References length.

Referenced by smbios_write_tables().

Here is the caller graph for this function:

◆ smbios_cpu_get_voltage()

unsigned int __weak smbios_cpu_get_voltage ( void  )

Definition at line 427 of file smbios.c.

Referenced by smbios_write_type4().

Here is the caller graph for this function:

◆ smbios_cpu_vendor()

static int smbios_cpu_vendor ( u8 start)
static

Definition at line 103 of file smbios.c.

References cpu_have_cpuid(), cpuid, cpuid_result::ebx, cpuid_result::ecx, cpuid_result::edx, and smbios_add_string().

Referenced by smbios_write_type4().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_fill_dimm_manufacturer_from_id()

void smbios_fill_dimm_manufacturer_from_id ( uint16_t  mod_id,
struct smbios_type17 t 
)

Definition at line 142 of file smbios.c.

References smbios_type17::eos, smbios_type17::manufacturer, smbios_add_string(), snprintf(), and spd_manufacturer_name().

Referenced by create_smbios_type17_for_dimm().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_fill_dimm_part_number()

static void smbios_fill_dimm_part_number ( const char *  part_number,
struct smbios_type17 t 
)
static

This function will fill the corresponding part number.

Definition at line 172 of file smbios.c.

References DIMM_INFO_PART_NUMBER_SIZE, smbios_type17::eos, smbios_type17::part_number, smbios_add_string(), snprintf(), strlen(), strncpy(), and trim_trailing_whitespace().

Referenced by create_smbios_type17_for_dimm().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_fill_dimm_serial_number()

static void smbios_fill_dimm_serial_number ( const struct dimm_info dimm,
struct smbios_type17 t 
)
static

Definition at line 212 of file smbios.c.

References smbios_type17::eos, dimm_info::serial, serial, smbios_type17::serial_number, smbios_add_string(), and snprintf().

Referenced by create_smbios_type17_for_dimm().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_full_table_len()

◆ smbios_generate_type41_from_devtree()

static int smbios_generate_type41_from_devtree ( struct device dev,
int *  handle,
unsigned long *  current 
)
static

◆ smbios_generate_type9_from_devtree()

static int smbios_generate_type9_from_devtree ( struct device dev,
int *  handle,
unsigned long *  current 
)
static

◆ smbios_get_device_type_from_dev()

◆ smbios_get_type41_instance_id()

static bool smbios_get_type41_instance_id ( struct device dev,
u8  device_type,
u8 instance_id 
)
static

Definition at line 1155 of file smbios.c.

References SMBIOS_DEVICE_TYPE_COUNT, SMBIOS_DEVICE_TYPE_OTHER, and SMBIOS_DEVICE_TYPE_UNKNOWN.

Referenced by smbios_generate_type41_from_devtree().

Here is the caller graph for this function:

◆ smbios_get_type41_refdes()

static const char* smbios_get_type41_refdes ( struct device dev)
static

Definition at line 1175 of file smbios.c.

References get_pci_subclass_name().

Referenced by smbios_generate_type41_from_devtree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_processor_characteristics()

unsigned int __weak smbios_processor_characteristics ( void  )

Definition at line 401 of file smbios.c.

Referenced by smbios_write_type4().

Here is the caller graph for this function:

◆ smbios_processor_external_clock()

unsigned int __weak smbios_processor_external_clock ( void  )

Definition at line 396 of file smbios.c.

Referenced by smbios_write_type4().

Here is the caller graph for this function:

◆ smbios_processor_family()

unsigned int __weak smbios_processor_family ( struct cpuid_result  res)

Definition at line 406 of file smbios.c.

References cpuid_result::eax.

Referenced by smbios_write_type4().

Here is the caller graph for this function:

◆ smbios_processor_name()

static int smbios_processor_name ( u8 start)
static

Definition at line 118 of file smbios.c.

References cpu_have_cpuid(), cpuid, cpuid_result::eax, cpuid_result::ebx, cpuid_result::ecx, cpuid_result::edx, and smbios_add_string().

Referenced by smbios_write_type4().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_string_table_len()

int smbios_string_table_len ( u8 start)

Definition at line 69 of file smbios.c.

References strlen().

Referenced by smbios_full_table_len(), and smbios_write_type0().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_walk_device_tree()

static int smbios_walk_device_tree ( struct device tree,
int *  handle,
unsigned long *  current 
)
static

Definition at line 1271 of file smbios.c.

References BIOS_INFO, dev_name, dev_path(), device::enabled, get_smbios_data(), device::next, device::ops, and printk.

Referenced by smbios_write_tables().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_write_tables()

◆ smbios_write_type0()

◆ smbios_write_type1()

◆ smbios_write_type11()

static int smbios_write_type11 ( unsigned long *  current,
int *  handle 
)
static

Definition at line 867 of file smbios.c.

References all_devices, smbios_type11::count, smbios_type11::eos, smbios_type11::header, memset(), device::next, device::ops, smbios_carve_table(), smbios_full_table_len(), and SMBIOS_OEM_STRINGS.

Referenced by smbios_write_tables().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_write_type127()

static int smbios_write_type127 ( unsigned long *  current,
int  handle 
)
static

Definition at line 1110 of file smbios.c.

References smbios_type127::eos, smbios_type127::header, smbios_carve_table(), SMBIOS_END_OF_TABLE, and smbios_full_table_len().

Referenced by smbios_write_tables().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_write_type16()

◆ smbios_write_type17()

static int smbios_write_type17 ( unsigned long *  current,
int *  handle,
int  type16 
)
static

Definition at line 935 of file smbios.c.

References ARRAY_SIZE, BIOS_INFO, cbmem_find(), CBMEM_ID_MEMINFO, create_smbios_type17_for_dimm(), memory_info::dimm, memory_info::dimm_cnt, NULL, and printk.

Referenced by smbios_write_tables().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_write_type19()

◆ smbios_write_type2()

◆ smbios_write_type20()

static int smbios_write_type20 ( unsigned long *  current,
int *  handle,
int  type17_handle,
int  type19_handle 
)
static

Definition at line 1030 of file smbios.c.

References ARRAY_SIZE, BIOS_INFO, cbmem_find(), CBMEM_ID_MEMINFO, memory_info::dimm, memory_info::dimm_cnt, dimm_info::dimm_size, NULL, printk, and smbios_write_type20_table().

Referenced by smbios_write_tables().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_write_type20_table()

static int smbios_write_type20_table ( unsigned long *  current,
int *  handle,
u32  addr_start,
u32  addr_end,
int  type17_handle,
int  type19_handle 
)
static

◆ smbios_write_type3()

◆ smbios_write_type32()

static int smbios_write_type32 ( unsigned long *  current,
int  handle 
)
static

Definition at line 1054 of file smbios.c.

References smbios_type32::eos, smbios_type32::header, smbios_carve_table(), smbios_full_table_len(), and SMBIOS_SYSTEM_BOOT_INFORMATION.

Referenced by smbios_write_tables().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_write_type38()

int smbios_write_type38 ( unsigned long *  current,
int *  handle,
const enum smbios_bmc_interface_type  interface_type,
const u8  ipmi_rev,
const u8  i2c_addr,
const u8  nv_addr,
const u64  base_addr,
const u8  base_modifier,
const u8  irq 
)

◆ smbios_write_type4()

static int smbios_write_type4 ( unsigned long *  current,
int  handle 
)
static

Definition at line 519 of file smbios.c.

References BIT, buf, smbios_type4::core_count, smbios_type4::core_count2, smbios_type4::core_enabled, smbios_type4::core_enabled2, cpu_have_cpuid(), cpuid, cpuid_eax(), cpuid_ecx(), cpuid_ext(), cpuid_get_max_func(), smbios_type4::current_speed, cpuid_result::eax, cpuid_result::ebx, cpuid_result::ecx, cpuid_result::edx, smbios_type4::eos, smbios_type4::external_clock, get_socket_type(), smbios_type4::header, smbios_type4::l1_cache_handle, smbios_type4::l2_cache_handle, smbios_type4::l3_cache_handle, smbios_type4::max_speed, MIN, smbios_type4::processor_characteristics, smbios_type4::processor_family, smbios_type4::processor_id, smbios_type4::processor_manufacturer, smbios_type4::processor_type, smbios_type4::processor_upgrade, smbios_type4::processor_version, smbios_type4::serial_number, smbios_add_string(), smbios_carve_table(), smbios_cpu_get_current_speed_mhz(), smbios_cpu_get_max_speed_mhz(), smbios_cpu_get_voltage(), smbios_cpu_vendor(), smbios_full_table_len(), smbios_processor_characteristics(), smbios_processor_external_clock(), smbios_processor_family(), SMBIOS_PROCESSOR_INFORMATION, smbios_processor_name(), smbios_processor_serial_number(), SMBIOS_PROCESSOR_STATUS_CPU_ENABLED, SMBIOS_PROCESSOR_STATUS_POPULATED, snprintf(), smbios_type4::socket_designation, smbios_type4::status, smbios_type4::thread_count, smbios_type4::thread_count2, and smbios_type4::voltage.

Referenced by smbios_write_tables().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smbios_write_type41()

◆ smbios_write_type7()

static int smbios_write_type7 ( unsigned long *  current,
const int  handle,
const u8  level,
const u8  sram_type,
const enum smbios_cache_associativity  associativity,
const enum smbios_cache_type  type,
const size_t  max_cache_size,
const size_t  cache_size 
)
static

Definition at line 623 of file smbios.c.

Referenced by smbios_write_type7_cache_parameters().

Here is the caller graph for this function:

◆ smbios_write_type7_cache_parameters()

◆ smbios_write_type8()

int smbios_write_type8 ( unsigned long *  current,
int *  handle,
const struct port_information port,
size_t  num_ports 
)

◆ smbios_write_type9()

◆ trim_trailing_whitespace()

static void trim_trailing_whitespace ( char *  buffer,
size_t  buffer_size 
)
static

Definition at line 156 of file smbios.c.

References buffer, and strnlen().

Referenced by smbios_fill_dimm_part_number().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vpd_get_bios_version()

static const char* vpd_get_bios_version ( void  )
static

Definition at line 281 of file smbios.c.

References BIOS_DEBUG, BIOS_ERR, malloc(), memcpy(), NULL, printk, s, smbios_type17::size, version, VERSION_VPD, vpd_find(), and VPD_RO.

Referenced by get_bios_version().

Here is the call graph for this function:
Here is the caller graph for this function: