X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fsmbios.h;h=c9df2706f5a6198fc2419b7980a8891f1ad3c248;hb=6786ce1ce14feb4d02854a0c04bc0cce505be46e;hp=d582d4f7abb2c9258509450cf042da85d9e1f549;hpb=e663b350f1699312281ddd1439dda6b5fc86598d;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/smbios.h b/include/smbios.h index d582d4f..c9df270 100644 --- a/include/smbios.h +++ b/include/smbios.h @@ -1,18 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2015, Bin Meng * * Adapted from coreboot src/include/smbios.h - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef _SMBIOS_H_ #define _SMBIOS_H_ +#include + /* SMBIOS spec version implemented */ #define SMBIOS_MAJOR_VER 3 #define SMBIOS_MINOR_VER 0 +enum { + SMBIOS_STR_MAX = 64, /* Maximum length allowed for a string */ +}; + /* SMBIOS structure types */ enum { SMBIOS_BIOS_INFORMATION = 0, @@ -55,7 +60,7 @@ struct __packed smbios_entry { #define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16) #define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0) -#define BIOS_CHARACTERISTICS_EXT1_UEFI (1 << 3) +#define BIOS_CHARACTERISTICS_EXT2_UEFI (1 << 3) #define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2) struct __packed smbios_type0 { @@ -182,14 +187,14 @@ struct __packed smbios_type32 { u16 handle; u8 reserved[6]; u8 boot_status; - u8 eos[SMBIOS_STRUCT_EOS_BYTES]; + char eos[SMBIOS_STRUCT_EOS_BYTES]; }; struct __packed smbios_type127 { u8 type; u8 length; u16 handle; - u8 eos[SMBIOS_STRUCT_EOS_BYTES]; + char eos[SMBIOS_STRUCT_EOS_BYTES]; }; struct __packed smbios_header { @@ -219,22 +224,85 @@ static inline void fill_smbios_header(void *table, int type, } /** - * Function prototype to write a specific type of SMBIOS structure + * write_smbios_table() - Write SMBIOS table + * + * This writes SMBIOS table at a given address. + * + * @addr: start address to write SMBIOS table. If this is not + * 16-byte-aligned then it will be aligned before the table is + * written. + * Return: end address of SMBIOS table (and start address for next entry) + * or NULL in case of an error * - * @addr: start address to write the structure - * @handle: the structure's handle, a unique 16-bit number - * @return: size of the structure */ -typedef int (*smbios_write_type)(uintptr_t *addr, int handle); +ulong write_smbios_table(ulong addr); /** - * write_smbios_table() - Write SMBIOS table + * smbios_entry() - Get a valid struct smbios_entry pointer * - * This writes SMBIOS table at a given address. + * @address: address where smbios tables is located + * @size: size of smbios table + * @return: NULL or a valid pointer to a struct smbios_entry + */ +const struct smbios_entry *smbios_entry(u64 address, u32 size); + +/** + * smbios_header() - Search for SMBIOS header type + * + * @entry: pointer to a struct smbios_entry + * @type: SMBIOS type + * @return: NULL or a valid pointer to a struct smbios_header + */ +const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type); + +/** + * smbios_string() - Return string from SMBIOS + * + * @header: pointer to struct smbios_header + * @index: string index + * @return: NULL or a valid char pointer + */ +char *smbios_string(const struct smbios_header *header, int index); + +/** + * smbios_update_version() - Update the version string + * + * This can be called after the SMBIOS tables are written (e.g. after the U-Boot + * main loop has started) to update the BIOS version string (SMBIOS table 0). + * + * @version: New version string to use + * Return: 0 if OK, -ENOENT if no version string was previously written, + * -ENOSPC if the new string is too large to fit + */ +int smbios_update_version(const char *version); + +/** + * smbios_update_version_full() - Update the version string + * + * This can be called after the SMBIOS tables are written (e.g. after the U-Boot + * main loop has started) to update the BIOS version string (SMBIOS table 0). + * It scans for the correct place to put the version, so does not need U-Boot + * to have actually written the tables itself (e.g. if a previous bootloader + * did it). + * + * @smbios_tab: Start of SMBIOS tables + * @version: New version string to use + * Return: 0 if OK, -ENOENT if no version string was previously written, + * -ENOSPC if the new string is too large to fit + */ +int smbios_update_version_full(void *smbios_tab, const char *version); + +/** + * smbios_prepare_measurement() - Update smbios table for the measurement + * + * TCG specification requires to measure static configuration information. + * This function clear the device dependent parameters such as + * serial number for the measurement. * - * @addr: start address to write SMBIOS table - * @return: end address of SMBIOS table + * @entry: pointer to a struct smbios_entry + * @header: pointer to a struct smbios_header */ -uintptr_t write_smbios_table(uintptr_t addr); +void smbios_prepare_measurement(const struct smbios_entry *entry, + struct smbios_header *header); #endif /* _SMBIOS_H_ */