From a986ccea541b8e38ca219dc142f1bfef9a93ab66 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 7 Dec 2023 11:18:49 +0200 Subject: smbios: Simplify reporting of unknown values If a value is not valid during the DT or SYSINFO parsing, we explicitly set that to "Unknown Product" and "Unknown" for the product and manufacturer respectively. It's cleaner if we move the checks insisde smbios_add_prop_si() and provide an alternative string in case the primary is NULL or empty pre-patch dmidecode Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: Unknown Product Name: Unknown Product Version: Not Specified Serial Number: Not Specified UUID: Not Settable Wake-up Type: Reserved SKU Number: Not Specified Family: Not Specified [...] post-patch dmidecode: Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: Unknown Product Name: Unknown Version: Unknown Serial Number: Unknown UUID: Not Settable Wake-up Type: Reserved SKU Number: Unknown Family: Unknown [...] While at it make smbios_add_prop_si() add a string directly if the prop node is NULL and replace smbios_add_string() calls with smbios_add_prop_si(ctx, NULL, ....) Signed-off-by: Ilias Apalodimas Reviewed-by: Peter Robinson Tested-by: Peter Robinson --- lib/smbios.c | 73 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 38 deletions(-) (limited to 'lib/smbios.c') diff --git a/lib/smbios.c b/lib/smbios.c index d7f4999e8b..444aa245a2 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -102,9 +102,6 @@ static int smbios_add_string(struct smbios_ctx *ctx, const char *str) int i = 1; char *p = ctx->eos; - if (!*str) - str = "Unknown"; - for (;;) { if (!*p) { ctx->last_str = p; @@ -134,11 +131,18 @@ static int smbios_add_string(struct smbios_ctx *ctx, const char *str) * * @ctx: context for writing the tables * @prop: property to write + * @dval: Default value to use if the string is not found or is empty * Return: 0 if not found, else SMBIOS string number (1 or more) */ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, - int sysinfo_id) + int sysinfo_id, const char *dval) { + if (!dval || !*dval) + dval = "Unknown"; + + if (!prop) + return smbios_add_string(ctx, dval); + if (sysinfo_id && ctx->dev) { char val[SMBIOS_STR_MAX]; int ret; @@ -151,8 +155,8 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, const char *str; str = ofnode_read_string(ctx->node, prop); - if (str) - return smbios_add_string(ctx, str); + + return smbios_add_string(ctx, str ? str : dval); } return 0; @@ -161,12 +165,15 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, /** * smbios_add_prop() - Add a property from the devicetree * - * @prop: property to write + * @prop: property to write. The default string will be written if + * prop is NULL + * @dval: Default value to use if the string is not found or is empty * Return: 0 if not found, else SMBIOS string number (1 or more) */ -static int smbios_add_prop(struct smbios_ctx *ctx, const char *prop) +static int smbios_add_prop(struct smbios_ctx *ctx, const char *prop, + const char *dval) { - return smbios_add_prop_si(ctx, prop, SYSINFO_ID_NONE); + return smbios_add_prop_si(ctx, prop, SYSINFO_ID_NONE, dval); } static void smbios_set_eos(struct smbios_ctx *ctx, char *eos) @@ -228,11 +235,9 @@ static int smbios_write_type0(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type0)); fill_smbios_header(t, SMBIOS_BIOS_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); - t->vendor = smbios_add_string(ctx, "U-Boot"); + t->vendor = smbios_add_prop(ctx, NULL, "U-Boot"); - t->bios_ver = smbios_add_prop(ctx, "version"); - if (!t->bios_ver) - t->bios_ver = smbios_add_string(ctx, PLAIN_VERSION); + t->bios_ver = smbios_add_prop(ctx, "version", PLAIN_VERSION); if (t->bios_ver) gd->smbios_version = ctx->last_str; log_debug("smbios_version = %p: '%s'\n", gd->smbios_version, @@ -241,7 +246,7 @@ static int smbios_write_type0(ulong *current, int handle, print_buffer((ulong)gd->smbios_version, gd->smbios_version, 1, strlen(gd->smbios_version) + 1, 0); #endif - t->bios_release_date = smbios_add_string(ctx, U_BOOT_DMI_DATE); + t->bios_release_date = smbios_add_prop(ctx, NULL, U_BOOT_DMI_DATE); #ifdef CONFIG_ROM_SIZE t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1; #endif @@ -280,22 +285,19 @@ static int smbios_write_type1(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type1)); fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); - t->manufacturer = smbios_add_prop(ctx, "manufacturer"); - if (!t->manufacturer) - t->manufacturer = smbios_add_string(ctx, "Unknown"); - t->product_name = smbios_add_prop(ctx, "product"); - if (!t->product_name) - t->product_name = smbios_add_string(ctx, "Unknown Product"); + t->manufacturer = smbios_add_prop(ctx, "manufacturer", "Unknown"); + t->product_name = smbios_add_prop(ctx, "product", "Unknown"); t->version = smbios_add_prop_si(ctx, "version", - SYSINFO_ID_SMBIOS_SYSTEM_VERSION); + SYSINFO_ID_SMBIOS_SYSTEM_VERSION, + "Unknown"); if (serial_str) { - t->serial_number = smbios_add_string(ctx, serial_str); + t->serial_number = smbios_add_prop(ctx, NULL, serial_str); strncpy((char *)t->uuid, serial_str, sizeof(t->uuid)); } else { - t->serial_number = smbios_add_prop(ctx, "serial"); + t->serial_number = smbios_add_prop(ctx, "serial", "Unknown"); } - t->sku_number = smbios_add_prop(ctx, "sku"); - t->family = smbios_add_prop(ctx, "family"); + t->sku_number = smbios_add_prop(ctx, "sku", "Unknown"); + t->family = smbios_add_prop(ctx, "family", "Unknown"); len = t->length + smbios_string_table_len(ctx); *current += len; @@ -314,15 +316,12 @@ static int smbios_write_type2(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type2)); fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); - t->manufacturer = smbios_add_prop(ctx, "manufacturer"); - if (!t->manufacturer) - t->manufacturer = smbios_add_string(ctx, "Unknown"); - t->product_name = smbios_add_prop(ctx, "product"); - if (!t->product_name) - t->product_name = smbios_add_string(ctx, "Unknown Product"); + t->manufacturer = smbios_add_prop(ctx, "manufacturer", "Unknown"); + t->product_name = smbios_add_prop(ctx, "product", "Unknown"); t->version = smbios_add_prop_si(ctx, "version", - SYSINFO_ID_SMBIOS_BASEBOARD_VERSION); - t->asset_tag_number = smbios_add_prop(ctx, "asset-tag"); + SYSINFO_ID_SMBIOS_BASEBOARD_VERSION, + "Unknown"); + t->asset_tag_number = smbios_add_prop(ctx, "asset-tag", "Unknown"); t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING; t->board_type = SMBIOS_BOARD_MOTHERBOARD; @@ -343,9 +342,7 @@ static int smbios_write_type3(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type3)); fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle); smbios_set_eos(ctx, t->eos); - t->manufacturer = smbios_add_prop(ctx, "manufacturer"); - if (!t->manufacturer) - t->manufacturer = smbios_add_string(ctx, "Unknown"); + t->manufacturer = smbios_add_prop(ctx, "manufacturer", "Unknown"); t->chassis_type = SMBIOS_ENCLOSURE_DESKTOP; t->bootup_state = SMBIOS_STATE_SAFE; t->power_supply_state = SMBIOS_STATE_SAFE; @@ -388,8 +385,8 @@ static void smbios_write_type4_dm(struct smbios_type4 *t, #endif t->processor_family = processor_family; - t->processor_manufacturer = smbios_add_string(ctx, vendor); - t->processor_version = smbios_add_string(ctx, name); + t->processor_manufacturer = smbios_add_prop(ctx, NULL, vendor); + t->processor_version = smbios_add_prop(ctx, NULL, name); } static int smbios_write_type4(ulong *current, int handle, -- cgit v1.2.3 From 738b34668f289ba98e3657f86e3a58385c09059d Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 7 Dec 2023 11:18:50 +0200 Subject: smbios: Fallback to the default DT if sysinfo nodes are missing In order to fill in the SMBIOS tables U-Boot currently relies on a "u-boot,sysinfo-smbios" compatible node. This is fine for the boards that already include such nodes. However with some recent EFI changes, the majority of boards can boot up distros, which usually rely on things like dmidecode etc for their reporting. For boards that lack this special node the SMBIOS output looks like: System Information Manufacturer: Unknown Product Name: Unknown Version: Unknown Serial Number: Unknown UUID: Not Settable Wake-up Type: Reserved SKU Number: Unknown Family: Unknown This looks problematic since most of the info are "Unknown". The DT spec specifies standard properties containing relevant information like 'model' and 'compatible' for which the suggested format is . Unfortunately the 'model' string found in DTs is usually lacking the manufacturer so we can't use it for both 'Manufacturer' and 'Product Name' SMBIOS entries reliably. So let's add a last resort to our current smbios parsing. If none of the sysinfo properties are found, scan for those information in the root node of the device tree. Use the 'model' to fill the 'Product Name' and the first value of 'compatible' for the 'Manufacturer', since that always contains one. pre-patch: Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: Unknown Product Name: Unknown Version: Unknown Serial Number: 100000000bb24ceb UUID: 30303031-3030-3030-3061-613234636435 Wake-up Type: Reserved SKU Number: Unknown Family: Unknown [...] and post patch: Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: raspberrypi Product Name: Raspberry Pi 4 Model B Rev 1.1 Version: Unknown Serial Number: 100000000bb24ceb UUID: 30303031-3030-3030-3061-613234636435 Wake-up Type: Reserved SKU Number: Unknown Family: Unknown [...] Signed-off-by: Ilias Apalodimas Reviewed-by: Peter Robinson Tested-by: Peter Robinson --- lib/smbios.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 5 deletions(-) (limited to 'lib/smbios.c') diff --git a/lib/smbios.c b/lib/smbios.c index 444aa245a2..3f0e1d5295 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -9,11 +9,14 @@ #include #include #include +#include #include #include #include #include #include +#include +#include #ifdef CONFIG_CPU #include #include @@ -43,6 +46,25 @@ DECLARE_GLOBAL_DATA_PTR; +/** + * struct map_sysinfo - Mapping of sysinfo strings to DT + * + * @sysinfo_str: sysinfo string + * @dt_str: DT string + * @max: Max index of the tokenized string to pick. Counting starts from 0 + * + */ +struct map_sysinfo { + const char *sysinfo_str; + const char *dt_str; + int max; +}; + +static const struct map_sysinfo sysinfo_to_dt[] = { + { .sysinfo_str = "product", .dt_str = "model", 2 }, + { .sysinfo_str = "manufacturer", .dt_str = "compatible", 1 }, +}; + /** * struct smbios_ctx - context for writing SMBIOS tables * @@ -87,6 +109,18 @@ struct smbios_write_method { const char *subnode_name; }; +static const struct map_sysinfo *convert_sysinfo_to_dt(const char *sysinfo_str) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(sysinfo_to_dt); i++) { + if (!strcmp(sysinfo_str, sysinfo_to_dt[i].sysinfo_str)) + return &sysinfo_to_dt[i]; + } + + return NULL; +} + /** * smbios_add_string() - add a string to the string area * @@ -124,6 +158,42 @@ static int smbios_add_string(struct smbios_ctx *ctx, const char *str) } } +/** + * get_str_from_dt - Get a substring from a DT property. + * After finding the property in the DT, the function + * will parse comma-separated values and return the value. + * If nprop->max exceeds the number of comma-separated + * elements, the last non NULL value will be returned. + * Counting starts from zero. + * + * @nprop: sysinfo property to use + * @str: pointer to fill with data + * @size: str buffer length + */ +static +void get_str_from_dt(const struct map_sysinfo *nprop, char *str, size_t size) +{ + const char *dt_str; + int cnt = 0; + char *token; + + memset(str, 0, size); + if (!nprop || !nprop->max) + return; + + dt_str = ofnode_read_string(ofnode_root(), nprop->dt_str); + if (!dt_str) + return; + + memcpy(str, dt_str, size); + token = strtok(str, ","); + while (token && cnt < nprop->max) { + strlcpy(str, token, strlen(token) + 1); + token = strtok(NULL, ","); + cnt++; + } +} + /** * smbios_add_prop_si() - Add a property from the devicetree or sysinfo * @@ -137,6 +207,8 @@ static int smbios_add_string(struct smbios_ctx *ctx, const char *str) static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, int sysinfo_id, const char *dval) { + int ret; + if (!dval || !*dval) dval = "Unknown"; @@ -145,18 +217,30 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, if (sysinfo_id && ctx->dev) { char val[SMBIOS_STR_MAX]; - int ret; ret = sysinfo_get_str(ctx->dev, sysinfo_id, sizeof(val), val); if (!ret) return smbios_add_string(ctx, val); } if (IS_ENABLED(CONFIG_OF_CONTROL)) { - const char *str; - - str = ofnode_read_string(ctx->node, prop); + const char *str = NULL; + char str_dt[128] = { 0 }; + /* + * If the node is not valid fallback and try the entire DT + * so we can at least fill in manufacturer and board type + */ + if (ofnode_valid(ctx->node)) { + str = ofnode_read_string(ctx->node, prop); + } else { + const struct map_sysinfo *nprop; + + nprop = convert_sysinfo_to_dt(prop); + get_str_from_dt(nprop, str_dt, sizeof(str_dt)); + str = (const char *)str_dt; + } - return smbios_add_string(ctx, str ? str : dval); + ret = smbios_add_string(ctx, str && *str ? str : dval); + return ret; } return 0; -- cgit v1.2.3 From 467382ca03758e4f3f13107e3a83669e93a7461e Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 14 Dec 2023 13:16:58 -0500 Subject: lib: Remove inclusion from these files After some header file cleanups to add missing include files, remove common.h from all files in the lib directory. This primarily means just dropping the line but in a few cases we need to add in other header files now. Reviewed-by: Simon Glass Signed-off-by: Tom Rini --- lib/abuf.c | 1 - lib/acpi/acpi.c | 1 - lib/acpi/acpi_device.c | 1 - lib/acpi/acpi_dp.c | 1 - lib/acpi/acpi_table.c | 1 - lib/acpi/acpi_writer.c | 2 +- lib/acpi/acpigen.c | 1 - lib/acpi/base.c | 3 ++- lib/acpi/csrt.c | 2 +- lib/acpi/dsdt.c | 2 +- lib/acpi/facs.c | 2 +- lib/acpi/mcfg.c | 4 +++- lib/acpi/ssdt.c | 3 ++- lib/addr_map.c | 1 - lib/aes.c | 2 +- lib/aes/aes-decrypt.c | 1 - lib/asm-offsets.c | 2 +- lib/at91/at91.c | 1 - lib/bch.c | 1 - lib/binman.c | 1 - lib/bzip2/bzlib.c | 3 +-- lib/bzip2/bzlib_decompress.c | 1 - lib/charset.c | 1 - lib/circbuf.c | 1 - lib/crc16-ccitt.c | 2 -- lib/crc32.c | 1 - lib/crc32c.c | 1 - lib/crc8.c | 2 -- lib/crypt/crypt-port.h | 3 +++ lib/crypt/crypt.c | 1 - lib/crypto/x509_public_key.c | 1 - lib/date.c | 1 - lib/dhry/cmd_dhry.c | 3 ++- lib/dhry/dhry_1.c | 2 +- lib/dhry/dhry_2.c | 2 +- lib/efi/efi.c | 1 - lib/efi/efi_app.c | 1 - lib/efi/efi_info.c | 1 - lib/efi/efi_stub.c | 1 - lib/efi_driver/efi_block_device.c | 1 - lib/efi_driver/efi_uclass.c | 1 - lib/efi_selftest/efi_selftest_esrt.c | 1 - lib/efi_selftest/efi_selftest_miniapp_exception.c | 1 - lib/efi_selftest/efi_selftest_miniapp_exit.c | 1 - lib/efi_selftest/efi_selftest_miniapp_return.c | 1 - lib/elf.c | 1 - lib/errno_str.c | 2 +- lib/fdtdec.c | 1 - lib/fdtdec_common.c | 1 - lib/fdtdec_test.c | 1 - lib/getopt.c | 2 +- lib/gunzip.c | 1 - lib/gzip.c | 1 - lib/hang.c | 2 +- lib/hash-checksum.c | 1 - lib/hashtable.c | 1 - lib/hexdump.c | 2 +- lib/image-sparse.c | 1 - lib/initcall.c | 1 - lib/linux_compat.c | 1 - lib/list_sort.c | 1 - lib/lmb.c | 1 - lib/lz4.c | 1 - lib/lz4_wrapper.c | 1 - lib/lzma/LzmaDec.c | 1 - lib/lzma/LzmaTools.c | 1 - lib/lzo/lzo1x_decompress.c | 3 ++- lib/md5.c | 1 - lib/membuff.c | 1 - lib/net_utils.c | 2 +- lib/of_live.c | 1 - lib/optee/optee.c | 1 - lib/panic.c | 1 - lib/physmem.c | 2 +- lib/qsort.c | 1 - lib/rand.c | 1 - lib/rc4.c | 3 --- lib/rsa/rsa-keyprop.c | 1 - lib/rsa/rsa-mod-exp.c | 1 - lib/rsa/rsa-verify.c | 1 - lib/rtc-lib.c | 1 - lib/semihosting.c | 3 ++- lib/slre.c | 2 +- lib/smbios-parser.c | 1 - lib/smbios.c | 1 - lib/strto.c | 2 +- lib/tables_csum.c | 3 +-- lib/time.c | 1 - lib/tiny-printf.c | 1 - lib/tpm-common.c | 1 - lib/tpm-v1.c | 1 - lib/tpm-v2.c | 1 - lib/tpm_api.c | 1 - lib/trace.c | 2 +- lib/uuid.c | 2 -- lib/vsprintf.c | 1 - lib/zstd/zstd.c | 2 +- 97 files changed, 36 insertions(+), 103 deletions(-) (limited to 'lib/smbios.c') diff --git a/lib/abuf.c b/lib/abuf.c index ce2cff53dc..937c3df351 100644 --- a/lib/abuf.c +++ b/lib/abuf.c @@ -7,7 +7,6 @@ */ #ifndef USE_HOSTCC -#include #include #include #include diff --git a/lib/acpi/acpi.c b/lib/acpi/acpi.c index f21e509461..939a638bb5 100644 --- a/lib/acpi/acpi.c +++ b/lib/acpi/acpi.c @@ -5,7 +5,6 @@ * Copyright 2023 Google LLC */ -#include #include #include #include diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c index 1b838fdbd6..ed94194346 100644 --- a/lib/acpi/acpi_device.c +++ b/lib/acpi/acpi_device.c @@ -6,7 +6,6 @@ * Mostly taken from coreboot file of the same name */ -#include #include #include #include diff --git a/lib/acpi/acpi_dp.c b/lib/acpi/acpi_dp.c index 7e3e3259d8..6733809986 100644 --- a/lib/acpi/acpi_dp.c +++ b/lib/acpi/acpi_dp.c @@ -6,7 +6,6 @@ * Mostly taken from coreboot file acpi_device.c */ -#include #include #include #include diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index a8d4b47000..e74522e997 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -5,7 +5,6 @@ * Copyright 2019 Google LLC */ -#include #include #include #include diff --git a/lib/acpi/acpi_writer.c b/lib/acpi/acpi_writer.c index 946f90e8e7..a8dc207557 100644 --- a/lib/acpi/acpi_writer.c +++ b/lib/acpi/acpi_writer.c @@ -7,13 +7,13 @@ #define LOG_CATEGORY LOGC_ACPI -#include #include #include #include #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c index e395226e3d..b95cabb914 100644 --- a/lib/acpi/acpigen.c +++ b/lib/acpi/acpigen.c @@ -8,7 +8,6 @@ #define LOG_CATEGORY LOGC_ACPI -#include #include #include #include diff --git a/lib/acpi/base.c b/lib/acpi/base.c index 26bf0cb8d3..07b53e0c56 100644 --- a/lib/acpi/base.c +++ b/lib/acpi/base.c @@ -7,12 +7,13 @@ #define LOG_CATEGORY LOGC_ACPI -#include #include #include #include #include #include +#include +#include void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, struct acpi_xsdt *xsdt) diff --git a/lib/acpi/csrt.c b/lib/acpi/csrt.c index 2ba86f2295..00927e5340 100644 --- a/lib/acpi/csrt.c +++ b/lib/acpi/csrt.c @@ -7,11 +7,11 @@ #define LOG_CATEGORY LOGC_ACPI -#include #include #include #include #include +#include __weak int acpi_fill_csrt(struct acpi_ctx *ctx) { diff --git a/lib/acpi/dsdt.c b/lib/acpi/dsdt.c index db98cc20e1..206e1e2678 100644 --- a/lib/acpi/dsdt.c +++ b/lib/acpi/dsdt.c @@ -7,10 +7,10 @@ #define LOG_CATEGORY LOGC_ACPI -#include #include #include #include +#include /* * IASL compiles the dsdt entries and writes the hex values diff --git a/lib/acpi/facs.c b/lib/acpi/facs.c index e89f43ca5c..86c28120c7 100644 --- a/lib/acpi/facs.c +++ b/lib/acpi/facs.c @@ -7,9 +7,9 @@ #define LOG_CATEGORY LOGC_ACPI -#include #include #include +#include int acpi_write_facs(struct acpi_ctx *ctx, const struct acpi_writer *entry) { diff --git a/lib/acpi/mcfg.c b/lib/acpi/mcfg.c index 7404ae586a..8b8a5bfafa 100644 --- a/lib/acpi/mcfg.c +++ b/lib/acpi/mcfg.c @@ -7,11 +7,13 @@ #define LOG_CATEGORY LOGC_ACPI -#include #include #include #include #include +#include +#include +#include int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end) diff --git a/lib/acpi/ssdt.c b/lib/acpi/ssdt.c index b140b4b2ff..b0a96f846e 100644 --- a/lib/acpi/ssdt.c +++ b/lib/acpi/ssdt.c @@ -7,10 +7,11 @@ #define LOG_CATEGORY LOGC_ACPI -#include #include #include #include +#include +#include int acpi_write_ssdt(struct acpi_ctx *ctx, const struct acpi_writer *entry) { diff --git a/lib/addr_map.c b/lib/addr_map.c index 86e932e4b5..f85fb0c7fb 100644 --- a/lib/addr_map.c +++ b/lib/addr_map.c @@ -3,7 +3,6 @@ * Copyright 2008 Freescale Semiconductor, Inc. */ -#include #include #include diff --git a/lib/aes.c b/lib/aes.c index 4fca85ebee..39ad4a990f 100644 --- a/lib/aes.c +++ b/lib/aes.c @@ -22,9 +22,9 @@ */ #ifndef USE_HOSTCC -#include #include #include +#include #else #include #endif diff --git a/lib/aes/aes-decrypt.c b/lib/aes/aes-decrypt.c index 345029fa78..741102a472 100644 --- a/lib/aes/aes-decrypt.c +++ b/lib/aes/aes-decrypt.c @@ -4,7 +4,6 @@ */ #ifndef USE_HOSTCC -#include #include #endif #include diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index 216d9716d0..4e2dbda9a7 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -11,9 +11,9 @@ * #defines from the assembly-language output. */ -#include #include #include +#include #include diff --git a/lib/at91/at91.c b/lib/at91/at91.c index 048597690b..bd31e9e41d 100644 --- a/lib/at91/at91.c +++ b/lib/at91/at91.c @@ -4,7 +4,6 @@ * Wenyou.Yang */ -#include #include #include "atmel_logo_8bpp.h" diff --git a/lib/bch.c b/lib/bch.c index 72b4fdcc9c..a309a8dfcb 100644 --- a/lib/bch.c +++ b/lib/bch.c @@ -54,7 +54,6 @@ */ #ifndef USE_HOSTCC -#include #include #include #include diff --git a/lib/binman.c b/lib/binman.c index cfe1e5f807..9047f5275f 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -6,7 +6,6 @@ * Written by Simon Glass */ -#include #include #include #include diff --git a/lib/bzip2/bzlib.c b/lib/bzip2/bzlib.c index bd589aa810..f7318b7886 100644 --- a/lib/bzip2/bzlib.c +++ b/lib/bzip2/bzlib.c @@ -1,7 +1,6 @@ -#include -#include #include #include +#include /* * This file is a modified version of bzlib.c from the bzip2-1.0.2 diff --git a/lib/bzip2/bzlib_decompress.c b/lib/bzip2/bzlib_decompress.c index 3b417d57b2..e56ab6674b 100644 --- a/lib/bzip2/bzlib_decompress.c +++ b/lib/bzip2/bzlib_decompress.c @@ -1,5 +1,4 @@ #include -#include #include /*-------------------------------------------------------------*/ diff --git a/lib/charset.c b/lib/charset.c index 5e4c4f948a..89057ef7ce 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -5,7 +5,6 @@ * Copyright (c) 2017 Rob Clark */ -#include #include #include #include diff --git a/lib/circbuf.c b/lib/circbuf.c index fa79c148da..2e161ae8d8 100644 --- a/lib/circbuf.c +++ b/lib/circbuf.c @@ -4,7 +4,6 @@ * Gerry Hamel, geh@ti.com, Texas Instruments */ -#include #include #include diff --git a/lib/crc16-ccitt.c b/lib/crc16-ccitt.c index 6cadbc103d..6fa4e93ed1 100644 --- a/lib/crc16-ccitt.c +++ b/lib/crc16-ccitt.c @@ -24,8 +24,6 @@ #ifdef USE_HOSTCC #include -#else -#include #endif #include diff --git a/lib/crc32.c b/lib/crc32.c index f6fad8c15d..f36f176306 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -11,7 +11,6 @@ #ifdef USE_HOSTCC #include #else -#include #include #endif #include diff --git a/lib/crc32c.c b/lib/crc32c.c index 016b34a523..7026ac4c33 100644 --- a/lib/crc32c.c +++ b/lib/crc32c.c @@ -10,7 +10,6 @@ * any later version. */ -#include #include uint32_t crc32c_cal(uint32_t crc, const char *data, int length, diff --git a/lib/crc8.c b/lib/crc8.c index 87b87b675b..20d46d1614 100644 --- a/lib/crc8.c +++ b/lib/crc8.c @@ -5,8 +5,6 @@ #ifdef USE_HOSTCC #include -#else -#include #endif #include diff --git a/lib/crypt/crypt-port.h b/lib/crypt/crypt-port.h index 6b9542d75b..50dde68b5c 100644 --- a/lib/crypt/crypt-port.h +++ b/lib/crypt/crypt-port.h @@ -1,6 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* Copyright (C) 2020 Steffen Jaeckel */ +#include +#include +#include #include #include diff --git a/lib/crypt/crypt.c b/lib/crypt/crypt.c index 247c34b2a9..8f5fadb582 100644 --- a/lib/crypt/crypt.c +++ b/lib/crypt/crypt.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* Copyright (C) 2020 Steffen Jaeckel */ -#include #include #include "crypt-port.h" diff --git a/lib/crypto/x509_public_key.c b/lib/crypto/x509_public_key.c index 30071233ee..a10145a7cd 100644 --- a/lib/crypto/x509_public_key.c +++ b/lib/crypto/x509_public_key.c @@ -7,7 +7,6 @@ #define pr_fmt(fmt) "X.509: "fmt #ifdef __UBOOT__ -#include #include #include #include diff --git a/lib/date.c b/lib/date.c index e3d22459cd..0deac8a1be 100644 --- a/lib/date.c +++ b/lib/date.c @@ -4,7 +4,6 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ -#include #include #include #include diff --git a/lib/dhry/cmd_dhry.c b/lib/dhry/cmd_dhry.c index 77b52a2300..e52beaeaad 100644 --- a/lib/dhry/cmd_dhry.c +++ b/lib/dhry/cmd_dhry.c @@ -3,9 +3,10 @@ * (C) Copyright 2015 Google, Inc */ -#include #include #include +#include +#include #include "dhry.h" static int do_dhry(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/lib/dhry/dhry_1.c b/lib/dhry/dhry_1.c index dcc224fb38..252cd14a65 100644 --- a/lib/dhry/dhry_1.c +++ b/lib/dhry/dhry_1.c @@ -42,8 +42,8 @@ ***************************************************************************/ char SCCSid[] = "@(#) @(#)dhry_1.c:3.4 -- 5/15/91 19:30:21"; -#include #include +#include #include "dhry.h" diff --git a/lib/dhry/dhry_2.c b/lib/dhry/dhry_2.c index 1ba879673e..a74197d884 100644 --- a/lib/dhry/dhry_2.c +++ b/lib/dhry/dhry_2.c @@ -39,7 +39,7 @@ ****************************************************************************/ /* SCCSid is defined in dhry_1.c */ -#include +#include #include "dhry.h" #ifndef REG diff --git a/lib/efi/efi.c b/lib/efi/efi.c index aa42f1842f..bcb34d6746 100644 --- a/lib/efi/efi.c +++ b/lib/efi/efi.c @@ -10,7 +10,6 @@ * Common EFI functions */ -#include #include #include #include diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index c5eb816655..119db6602c 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -8,7 +8,6 @@ * This file implements U-Boot running as an EFI application. */ -#include #include #include #include diff --git a/lib/efi/efi_info.c b/lib/efi/efi_info.c index 4d78923c4d..5b564c5651 100644 --- a/lib/efi/efi_info.c +++ b/lib/efi/efi_info.c @@ -5,7 +5,6 @@ * Access to the EFI information table */ -#include #include #include #include diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index c9eb32ec10..40fc29d9ad 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -9,7 +9,6 @@ * EFI application. It can be built either in 32-bit or 64-bit mode. */ -#include #include #include #include diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index e3abd90275..34a0365739 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -28,7 +28,6 @@ * iPXE uses the simple file protocol to load Grub or the Linux Kernel. */ -#include #include #include #include diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c index 66a45e156d..e1e28df20b 100644 --- a/lib/efi_driver/efi_uclass.c +++ b/lib/efi_driver/efi_uclass.c @@ -17,7 +17,6 @@ * controllers. */ -#include #include #include #include diff --git a/lib/efi_selftest/efi_selftest_esrt.c b/lib/efi_selftest/efi_selftest_esrt.c index 922ff253c7..b7688deb49 100644 --- a/lib/efi_selftest/efi_selftest_esrt.c +++ b/lib/efi_selftest/efi_selftest_esrt.c @@ -4,7 +4,6 @@ * * Copyright (C) 2021 Arm Ltd. */ -#include #include #include diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c index a9ad381001..f668cdac4a 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c @@ -7,7 +7,6 @@ * This EFI application triggers an exception. */ -#include #include #include diff --git a/lib/efi_selftest/efi_selftest_miniapp_exit.c b/lib/efi_selftest/efi_selftest_miniapp_exit.c index 1c42d6dd40..8b2e60cc71 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exit.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exit.c @@ -8,7 +8,6 @@ * It uses the Exit boot service to return. */ -#include #include static efi_guid_t loaded_image_protocol_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID; diff --git a/lib/efi_selftest/efi_selftest_miniapp_return.c b/lib/efi_selftest/efi_selftest_miniapp_return.c index 45366aa9c6..8792d78ab3 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_return.c +++ b/lib/efi_selftest/efi_selftest_miniapp_return.c @@ -8,7 +8,6 @@ * It returns directly without calling the Exit boot service. */ -#include #include /* diff --git a/lib/elf.c b/lib/elf.c index 0476b2614c..9a794f9cba 100644 --- a/lib/elf.c +++ b/lib/elf.c @@ -3,7 +3,6 @@ Copyright (c) 2001 William L. Pitts */ -#include #include #include #include diff --git a/lib/errno_str.c b/lib/errno_str.c index 2e5f4a887d..752d4eb47a 100644 --- a/lib/errno_str.c +++ b/lib/errno_str.c @@ -4,8 +4,8 @@ * * SDPX-License-Identifier: GPL-2.0+ */ -#include #include +#include #define ERRNO_MSG(errno, msg) msg #define SAME_AS(x) (const char *)&errno_message[x] diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 7a69167648..4016bf3c11 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -7,7 +7,6 @@ */ #ifndef USE_HOSTCC -#include #include #include #include diff --git a/lib/fdtdec_common.c b/lib/fdtdec_common.c index ddaca0087e..ca36ff1595 100644 --- a/lib/fdtdec_common.c +++ b/lib/fdtdec_common.c @@ -8,7 +8,6 @@ */ #ifndef USE_HOSTCC -#include #include #include #include diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c index 85351c75ca..1e4d5fc832 100644 --- a/lib/fdtdec_test.c +++ b/lib/fdtdec_test.c @@ -6,7 +6,6 @@ * Copyright (c) 2011 The Chromium OS Authors. */ -#include #include #include #include diff --git a/lib/getopt.c b/lib/getopt.c index 8b4515dc19..e9175e2fff 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -8,9 +8,9 @@ #define LOG_CATEGORY LOGC_CORE -#include #include #include +#include void getopt_init_state(struct getopt_state *gs) { diff --git a/lib/gunzip.c b/lib/gunzip.c index 932e3e8036..e71d8d00cc 100644 --- a/lib/gunzip.c +++ b/lib/gunzip.c @@ -4,7 +4,6 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ -#include #include #include #include diff --git a/lib/gzip.c b/lib/gzip.c index 2595b2d04b..5d9c19598d 100644 --- a/lib/gzip.c +++ b/lib/gzip.c @@ -4,7 +4,6 @@ * Lei Wen , Marvell Inc. */ -#include #include #include #include diff --git a/lib/hang.c b/lib/hang.c index 2735774f9a..3cfb06e9ca 100644 --- a/lib/hang.c +++ b/lib/hang.c @@ -7,9 +7,9 @@ * u-boot. */ -#include #include #include +#include #include /** diff --git a/lib/hash-checksum.c b/lib/hash-checksum.c index 68c290d64d..1970a74129 100644 --- a/lib/hash-checksum.c +++ b/lib/hash-checksum.c @@ -4,7 +4,6 @@ */ #ifndef USE_HOSTCC -#include #include #include #include diff --git a/lib/hashtable.c b/lib/hashtable.c index f2d36bd34b..a0060f6a0d 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -30,7 +30,6 @@ # endif # endif #else /* U-Boot build */ -# include # include # include #endif diff --git a/lib/hexdump.c b/lib/hexdump.c index 149c93ead8..33e3e6e518 100644 --- a/lib/hexdump.c +++ b/lib/hexdump.c @@ -8,9 +8,9 @@ * more details. */ -#include #include #include +#include #include #include #include diff --git a/lib/image-sparse.c b/lib/image-sparse.c index 323aad981c..f828906469 100644 --- a/lib/image-sparse.c +++ b/lib/image-sparse.c @@ -35,7 +35,6 @@ */ #include -#include #include #include #include diff --git a/lib/initcall.c b/lib/initcall.c index 33b7d761dc..ce317af213 100644 --- a/lib/initcall.c +++ b/lib/initcall.c @@ -3,7 +3,6 @@ * Copyright (c) 2013 The Chromium OS Authors. */ -#include #include #include #include diff --git a/lib/linux_compat.c b/lib/linux_compat.c index c83426f59d..985e88eb39 100644 --- a/lib/linux_compat.c +++ b/lib/linux_compat.c @@ -1,5 +1,4 @@ -#include #include #include #include diff --git a/lib/list_sort.c b/lib/list_sort.c index 1c9e061732..a6e54d5bc4 100644 --- a/lib/list_sort.c +++ b/lib/list_sort.c @@ -6,7 +6,6 @@ #include #else #include -#include #include #include #endif diff --git a/lib/lmb.c b/lib/lmb.c index da924c6789..44f9820531 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -6,7 +6,6 @@ * Copyright (C) 2001 Peter Bergner. */ -#include #include #include #include diff --git a/lib/lz4.c b/lib/lz4.c index 5337842126..d365dc727c 100644 --- a/lib/lz4.c +++ b/lib/lz4.c @@ -27,7 +27,6 @@ * - LZ4 homepage : http://www.lz4.org * - LZ4 source repository : https://github.com/lz4/lz4 */ -#include #include #include #include diff --git a/lib/lz4_wrapper.c b/lib/lz4_wrapper.c index 67dea2ff39..4d48e7b0e8 100644 --- a/lib/lz4_wrapper.c +++ b/lib/lz4_wrapper.c @@ -3,7 +3,6 @@ * Copyright 2015 Google Inc. */ -#include #include #include #include diff --git a/lib/lzma/LzmaDec.c b/lib/lzma/LzmaDec.c index a90b35c6a9..1da3f0a14a 100644 --- a/lib/lzma/LzmaDec.c +++ b/lib/lzma/LzmaDec.c @@ -2,7 +2,6 @@ 2009-09-20 : Igor Pavlov : Public domain */ #include -#include #include #include "LzmaDec.h" diff --git a/lib/lzma/LzmaTools.c b/lib/lzma/LzmaTools.c index 55f64cd289..400d606784 100644 --- a/lib/lzma/LzmaTools.c +++ b/lib/lzma/LzmaTools.c @@ -18,7 +18,6 @@ */ #include -#include #include #include diff --git a/lib/lzo/lzo1x_decompress.c b/lib/lzo/lzo1x_decompress.c index 65fef0b0eb..5d70fa4133 100644 --- a/lib/lzo/lzo1x_decompress.c +++ b/lib/lzo/lzo1x_decompress.c @@ -11,8 +11,9 @@ * Richard Purdie */ -#include +#include #include +#include #include #include #include "lzodefs.h" diff --git a/lib/md5.c b/lib/md5.c index 1636ab9366..faf3f78ab1 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -28,7 +28,6 @@ #include "compiler.h" #ifndef USE_HOSTCC -#include #include #endif /* USE_HOSTCC */ #include diff --git a/lib/membuff.c b/lib/membuff.c index 36dc43a523..3c6c0ae125 100644 --- a/lib/membuff.c +++ b/lib/membuff.c @@ -6,7 +6,6 @@ * Copyright (c) 1992 Simon Glass */ -#include #include #include #include diff --git a/lib/net_utils.c b/lib/net_utils.c index 4283c13a31..c70fef0d99 100644 --- a/lib/net_utils.c +++ b/lib/net_utils.c @@ -9,9 +9,9 @@ * Copyright 2009 Dirk Behme, dirk.behme@googlemail.com */ -#include #include #include +#include struct in_addr string_to_ip(const char *s) { diff --git a/lib/of_live.c b/lib/of_live.c index 812c488f60..90b9459ede 100644 --- a/lib/of_live.c +++ b/lib/of_live.c @@ -10,7 +10,6 @@ #define LOG_CATEGORY LOGC_DT -#include #include #include #include diff --git a/lib/optee/optee.c b/lib/optee/optee.c index b036224044..393f2715a9 100644 --- a/lib/optee/optee.c +++ b/lib/optee/optee.c @@ -4,7 +4,6 @@ * Bryan O'Donoghue */ -#include #include #include #include diff --git a/lib/panic.c b/lib/panic.c index 66ae17f3df..0f578b5b51 100644 --- a/lib/panic.c +++ b/lib/panic.c @@ -9,7 +9,6 @@ * Wirzenius wrote this portably, Torvalds fucked it up :-) */ -#include #include #if !defined(CONFIG_PANIC_HANG) #include diff --git a/lib/physmem.c b/lib/physmem.c index fc90ce4d7c..562c74d37f 100644 --- a/lib/physmem.c +++ b/lib/physmem.c @@ -8,11 +8,11 @@ * Software Foundation. */ -#include #include #include #include #include +#include phys_addr_t __weak arch_phys_memset(phys_addr_t s, int c, phys_size_t n) { diff --git a/lib/qsort.c b/lib/qsort.c index 2f18588dfc..a2562c4942 100644 --- a/lib/qsort.c +++ b/lib/qsort.c @@ -17,7 +17,6 @@ #include #include -#include #include #include diff --git a/lib/rand.c b/lib/rand.c index d256baf5ce..d6f2977e8d 100644 --- a/lib/rand.c +++ b/lib/rand.c @@ -7,7 +7,6 @@ * Michael Walle */ -#include #include static unsigned int y = 1U; diff --git a/lib/rc4.c b/lib/rc4.c index 720112d1fd..3839924a2b 100644 --- a/lib/rc4.c +++ b/lib/rc4.c @@ -7,9 +7,6 @@ * Rivest Cipher 4 (RC4) implementation */ -#ifndef USE_HOSTCC -#include -#endif #include void rc4_encode(unsigned char *buf, unsigned int len, const unsigned char key[16]) diff --git a/lib/rsa/rsa-keyprop.c b/lib/rsa/rsa-keyprop.c index 98855f67b8..80d0594a43 100644 --- a/lib/rsa/rsa-keyprop.c +++ b/lib/rsa/rsa-keyprop.c @@ -9,7 +9,6 @@ * Copyright (c) 2016 Thomas Pornin */ -#include #include #include #include diff --git a/lib/rsa/rsa-mod-exp.c b/lib/rsa/rsa-mod-exp.c index d259b2aedf..5b3ea02f82 100644 --- a/lib/rsa/rsa-mod-exp.c +++ b/lib/rsa/rsa-mod-exp.c @@ -4,7 +4,6 @@ */ #ifndef USE_HOSTCC -#include #include #include #include diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 096e7f6d17..1007b6979a 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -4,7 +4,6 @@ */ #ifndef USE_HOSTCC -#include #include #include #include diff --git a/lib/rtc-lib.c b/lib/rtc-lib.c index 1f7bdade29..46dcfba271 100644 --- a/lib/rtc-lib.c +++ b/lib/rtc-lib.c @@ -10,7 +10,6 @@ * - January is month 1. */ -#include #include #include diff --git a/lib/semihosting.c b/lib/semihosting.c index 831774e356..9be5bffd30 100644 --- a/lib/semihosting.c +++ b/lib/semihosting.c @@ -4,9 +4,10 @@ * Copyright 2014 Broadcom Corporation */ -#include #include #include +#include +#include #define SYSOPEN 0x01 #define SYSCLOSE 0x02 diff --git a/lib/slre.c b/lib/slre.c index e1a50443e0..277a59a03a 100644 --- a/lib/slre.c +++ b/lib/slre.c @@ -21,8 +21,8 @@ #include #else #include -#include #include +#include #endif /* SLRE_TEST */ #include diff --git a/lib/smbios-parser.c b/lib/smbios-parser.c index 2b9392936b..b578c30840 100644 --- a/lib/smbios-parser.c +++ b/lib/smbios-parser.c @@ -5,7 +5,6 @@ #define LOG_CATEGORY LOGC_BOOT -#include #include static inline int verify_checksum(const struct smbios_entry *e) diff --git a/lib/smbios.c b/lib/smbios.c index 3f0e1d5295..45480b01af 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -5,7 +5,6 @@ * Adapted from coreboot src/arch/x86/smbios.c */ -#include #include #include #include diff --git a/lib/strto.c b/lib/strto.c index 154921165c..5157332d6c 100644 --- a/lib/strto.c +++ b/lib/strto.c @@ -9,9 +9,9 @@ * Wirzenius wrote this portably, Torvalds fucked it up :-) */ -#include #include #include +#include #include /* from lib/kstrtox.c */ diff --git a/lib/tables_csum.c b/lib/tables_csum.c index e2630d57d9..636aa59676 100644 --- a/lib/tables_csum.c +++ b/lib/tables_csum.c @@ -3,8 +3,7 @@ * Copyright (C) 2015, Bin Meng */ -#include -#include +#include u8 table_compute_checksum(void *v, int len) { diff --git a/lib/time.c b/lib/time.c index 00f4a1ac8f..872f73d521 100644 --- a/lib/time.c +++ b/lib/time.c @@ -4,7 +4,6 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ -#include #include #include #include diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index f661fc6505..9a70c6095b 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -8,7 +8,6 @@ * Copyright (C) 2004,2008 Kustaa Nyholm */ -#include #include #include #include diff --git a/lib/tpm-common.c b/lib/tpm-common.c index 82ffdc5341..b592c22bfc 100644 --- a/lib/tpm-common.c +++ b/lib/tpm-common.c @@ -6,7 +6,6 @@ #define LOG_CATEGORY UCLASS_TPM -#include #include #include #include diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c index 60a18ca504..e66023da5e 100644 --- a/lib/tpm-v1.c +++ b/lib/tpm-v1.c @@ -6,7 +6,6 @@ #define LOG_CATEGORY UCLASS_TPM -#include #include #include #include diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index bd0fb078dc..68eaaa639f 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -5,7 +5,6 @@ * Author: Miquel Raynal */ -#include #include #include #include diff --git a/lib/tpm_api.c b/lib/tpm_api.c index 3ef5e81179..39a5121e30 100644 --- a/lib/tpm_api.c +++ b/lib/tpm_api.c @@ -3,7 +3,6 @@ * Copyright 2019 Google LLC */ -#include #include #include #include diff --git a/lib/trace.c b/lib/trace.c index 4874bef861..cabbe47b58 100644 --- a/lib/trace.c +++ b/lib/trace.c @@ -3,10 +3,10 @@ * Copyright (c) 2012 The Chromium OS Authors. */ -#include #include #include #include +#include #include #include #include diff --git a/lib/uuid.c b/lib/uuid.c index afb40bff50..0be22bc05f 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -9,7 +9,6 @@ #define LOG_CATEGOT LOGC_CORE -#include #include #include #include @@ -18,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/vsprintf.c b/lib/vsprintf.c index e14c6ca9f9..27ea9c907a 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -13,7 +13,6 @@ * from hush: simple_itoa() was lifted from boa-0.93.15 */ -#include #include #include #include diff --git a/lib/zstd/zstd.c b/lib/zstd/zstd.c index 3a2abc8367..14bde36906 100644 --- a/lib/zstd/zstd.c +++ b/lib/zstd/zstd.c @@ -5,10 +5,10 @@ #define LOG_CATEGORY LOGC_BOOT -#include #include #include #include +#include #include int zstd_decompress(struct abuf *in, struct abuf *out) -- cgit v1.2.3 From 58c638330ab15c8ee465fa61e40c66234f9e7909 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 31 Dec 2023 08:25:44 -0700 Subject: smbios: Refactor 32-bit code into an else statement In preparation for adding support for SMBIOS3 move this code into an else statement. There is no functional change. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- lib/smbios.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'lib/smbios.c') diff --git a/lib/smbios.c b/lib/smbios.c index 45480b01af..b417f8a905 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -589,14 +589,6 @@ ulong write_smbios_table(ulong addr) len += tmp; } - memcpy(se->anchor, "_SM_", 4); - se->length = sizeof(struct smbios_entry); - se->major_ver = SMBIOS_MAJOR_VER; - se->minor_ver = SMBIOS_MINOR_VER; - se->max_struct_size = max_struct_size; - memcpy(se->intermediate_anchor, "_DMI_", 5); - se->struct_table_length = len; - /* * We must use a pointer here so things work correctly on sandbox. The * user of this table is not aware of the mapping of addresses to @@ -612,16 +604,28 @@ ulong write_smbios_table(ulong addr) (unsigned long long)table_addr); addr = 0; goto out; + } else { + memcpy(se->anchor, "_SM_", 4); + se->length = sizeof(struct smbios_entry); + se->major_ver = SMBIOS_MAJOR_VER; + se->minor_ver = SMBIOS_MINOR_VER; + se->max_struct_size = max_struct_size; + memcpy(se->intermediate_anchor, "_DMI_", 5); + se->struct_table_length = len; + + se->struct_table_address = table_addr; + + se->struct_count = handle; + + /* calculate checksums */ + istart = (char *)se + SMBIOS_INTERMEDIATE_OFFSET; + isize = sizeof(struct smbios_entry) - + SMBIOS_INTERMEDIATE_OFFSET; + se->intermediate_checksum = table_compute_checksum(istart, + isize); + se->checksum = table_compute_checksum(se, + sizeof(struct smbios_entry)); } - se->struct_table_address = table_addr; - - se->struct_count = handle; - - /* calculate checksums */ - istart = (char *)se + SMBIOS_INTERMEDIATE_OFFSET; - isize = sizeof(struct smbios_entry) - SMBIOS_INTERMEDIATE_OFFSET; - se->intermediate_checksum = table_compute_checksum(istart, isize); - se->checksum = table_compute_checksum(se, sizeof(struct smbios_entry)); out: unmap_sysmem(se); -- cgit v1.2.3 From f19cf8d43adb061f1e744447a4676322cd326829 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 31 Dec 2023 08:25:45 -0700 Subject: smbios: Move the rest of the SMBIOS2 code Move all of this logic into the else clause, since it will not be used for SMBIOS3 Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- lib/smbios.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib/smbios.c') diff --git a/lib/smbios.c b/lib/smbios.c index b417f8a905..eea72670bd 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -544,9 +544,8 @@ static struct smbios_write_method smbios_write_funcs[] = { ulong write_smbios_table(ulong addr) { ofnode parent_node = ofnode_null(); - struct smbios_entry *se; + ulong table_addr, start_addr; struct smbios_ctx ctx; - ulong table_addr; ulong tables; int len = 0; int max_struct_size = 0; @@ -566,9 +565,7 @@ ulong write_smbios_table(ulong addr) /* 16 byte align the table address */ addr = ALIGN(addr, 16); - - se = map_sysmem(addr, sizeof(struct smbios_entry)); - memset(se, 0, sizeof(struct smbios_entry)); + start_addr = addr; addr += sizeof(struct smbios_entry); addr = ALIGN(addr, 16); @@ -603,8 +600,11 @@ ulong write_smbios_table(ulong addr) printf("WARNING: SMBIOS table_address overflow %llx\n", (unsigned long long)table_addr); addr = 0; - goto out; } else { + struct smbios_entry *se; + + se = map_sysmem(start_addr, sizeof(struct smbios_entry)); + memset(se, '\0', sizeof(struct smbios_entry)); memcpy(se->anchor, "_SM_", 4); se->length = sizeof(struct smbios_entry); se->major_ver = SMBIOS_MAJOR_VER; @@ -625,9 +625,8 @@ ulong write_smbios_table(ulong addr) isize); se->checksum = table_compute_checksum(se, sizeof(struct smbios_entry)); + unmap_sysmem(se); } -out: - unmap_sysmem(se); return addr; } -- cgit v1.2.3 From 70924294f375c351339f029b9615b52608e04cf4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 31 Dec 2023 08:25:47 -0700 Subject: smbios: Use SMBIOS 3.0 to support an address above 4GB When the SMBIOS table is written to an address above 4GB a 32-bit table address is not large enough. Use an SMBIOS3 table in that case. Note that we cannot use efi_allocate_pages() since this function has nothing to do with EFI. There is no equivalent function to allocate memory below 4GB in U-Boot. One solution would be to create a separate malloc() pool, or just always put the malloc() pool below 4GB. - Use log_debug() for warning - Rebase on Heinrich's smbios.h patch - Set the checksum for SMBIOS3 Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- include/smbios.h | 6 +++++- lib/smbios.c | 30 +++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) (limited to 'lib/smbios.c') diff --git a/include/smbios.h b/include/smbios.h index e601283d29..77be58887a 100644 --- a/include/smbios.h +++ b/include/smbios.h @@ -12,7 +12,7 @@ /* SMBIOS spec version implemented */ #define SMBIOS_MAJOR_VER 3 -#define SMBIOS_MINOR_VER 0 +#define SMBIOS_MINOR_VER 7 enum { SMBIOS_STR_MAX = 64, /* Maximum length allowed for a string */ @@ -80,6 +80,10 @@ struct __packed smbios3_entry { u64 struct_table_address; }; +/* These two structures should use the same amount of 16-byte-aligned space */ +static_assert(ALIGN(16, sizeof(struct smbios_entry)) == + ALIGN(16, sizeof(struct smbios3_entry))); + /* BIOS characteristics */ #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7) #define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11) diff --git a/lib/smbios.c b/lib/smbios.c index eea72670bd..7f79d969c9 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -567,7 +567,11 @@ ulong write_smbios_table(ulong addr) addr = ALIGN(addr, 16); start_addr = addr; - addr += sizeof(struct smbios_entry); + /* + * So far we don't know which struct will be used, but they both end + * up using the same amount of 16-bit-aligned space + */ + addr += max(sizeof(struct smbios_entry), sizeof(struct smbios3_entry)); addr = ALIGN(addr, 16); tables = addr; @@ -590,16 +594,32 @@ ulong write_smbios_table(ulong addr) * We must use a pointer here so things work correctly on sandbox. The * user of this table is not aware of the mapping of addresses to * sandbox's DRAM buffer. + * + * Check the address of the end of the tables. If it is above 4GB then + * it is sensible to use SMBIOS3 even if the start of the table is below + * 4GB (this case is very unlikely to happen in practice) */ table_addr = (ulong)map_sysmem(tables, 0); - if (sizeof(table_addr) > sizeof(u32) && table_addr > (ulong)UINT_MAX) { + if (sizeof(table_addr) > sizeof(u32) && addr >= (ulong)UINT_MAX) { + struct smbios3_entry *se; /* * We need to put this >32-bit pointer into the table but the * field is only 32 bits wide. */ - printf("WARNING: SMBIOS table_address overflow %llx\n", - (unsigned long long)table_addr); - addr = 0; + log_debug("WARNING: Using SMBIOS3.0 due to table-address overflow %lx\n", + table_addr); + se = map_sysmem(start_addr, sizeof(struct smbios_entry)); + memset(se, '\0', sizeof(struct smbios_entry)); + memcpy(se->anchor, "_SM3_", 5); + se->length = sizeof(struct smbios3_entry); + se->major_ver = SMBIOS_MAJOR_VER; + se->minor_ver = SMBIOS_MINOR_VER; + se->doc_rev = 0; + se->entry_point_rev = 1; + se->max_struct_size = len; + se->struct_table_address = table_addr; + se->checksum = table_compute_checksum(se, + sizeof(struct smbios3_entry)); } else { struct smbios_entry *se; -- cgit v1.2.3 From 31f950a963a382d48193ecd79698f795b7603846 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 31 Dec 2023 08:25:50 -0700 Subject: smbios: Require the caller to align the SMBIOS table All callers handle this alignment, so drop the unnecessary code. This simplifies things a little. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- include/smbios.h | 9 +++++---- lib/smbios.c | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/smbios.c') diff --git a/include/smbios.h b/include/smbios.h index 77be58887a..49de32fec2 100644 --- a/include/smbios.h +++ b/include/smbios.h @@ -258,12 +258,13 @@ static inline void fill_smbios_header(void *table, int type, * * 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. + * @addr: start address to write SMBIOS table, 16-byte-alignment + * recommended. Note that while the SMBIOS tables themself have no alignment + * requirement, some systems may requires alignment. For example x86 systems + * which put tables at f0000 require 16-byte alignment + * * Return: end address of SMBIOS table (and start address for next entry) * or NULL in case of an error - * */ ulong write_smbios_table(ulong addr); diff --git a/lib/smbios.c b/lib/smbios.c index 7f79d969c9..cfd451e408 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -563,8 +563,6 @@ ulong write_smbios_table(ulong addr) ctx.dev = NULL; } - /* 16 byte align the table address */ - addr = ALIGN(addr, 16); start_addr = addr; /* -- cgit v1.2.3 From 1c5f6fa3883d18fbdaea53cae99e911748957bb0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 31 Dec 2023 08:25:51 -0700 Subject: smbios: Drop support for SMBIOS2 tables These tables are a pain since there is no way to handle memory above 4GB. Use SMBIOS3 always. This should hopefully not create problems on x86 devices, since SMBIOS3 was released seven years ago (2015). Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt Reviewed-by: Peter Robinson --- lib/smbios.c | 76 ++++++++++++++---------------------------------------------- 1 file changed, 17 insertions(+), 59 deletions(-) (limited to 'lib/smbios.c') diff --git a/lib/smbios.c b/lib/smbios.c index cfd451e408..d9d52bd58d 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -545,13 +545,12 @@ ulong write_smbios_table(ulong addr) { ofnode parent_node = ofnode_null(); ulong table_addr, start_addr; + struct smbios3_entry *se; struct smbios_ctx ctx; ulong tables; int len = 0; int max_struct_size = 0; int handle = 0; - char *istart; - int isize; int i; ctx.node = ofnode_null(); @@ -565,12 +564,8 @@ ulong write_smbios_table(ulong addr) start_addr = addr; - /* - * So far we don't know which struct will be used, but they both end - * up using the same amount of 16-bit-aligned space - */ - addr += max(sizeof(struct smbios_entry), sizeof(struct smbios3_entry)); - addr = ALIGN(addr, 16); + /* move past the (so-far-unwritten) header to start writing structs */ + addr = ALIGN(addr + sizeof(struct smbios3_entry), 16); tables = addr; /* populate minimum required tables */ @@ -592,59 +587,22 @@ ulong write_smbios_table(ulong addr) * We must use a pointer here so things work correctly on sandbox. The * user of this table is not aware of the mapping of addresses to * sandbox's DRAM buffer. - * - * Check the address of the end of the tables. If it is above 4GB then - * it is sensible to use SMBIOS3 even if the start of the table is below - * 4GB (this case is very unlikely to happen in practice) */ table_addr = (ulong)map_sysmem(tables, 0); - if (sizeof(table_addr) > sizeof(u32) && addr >= (ulong)UINT_MAX) { - struct smbios3_entry *se; - /* - * We need to put this >32-bit pointer into the table but the - * field is only 32 bits wide. - */ - log_debug("WARNING: Using SMBIOS3.0 due to table-address overflow %lx\n", - table_addr); - se = map_sysmem(start_addr, sizeof(struct smbios_entry)); - memset(se, '\0', sizeof(struct smbios_entry)); - memcpy(se->anchor, "_SM3_", 5); - se->length = sizeof(struct smbios3_entry); - se->major_ver = SMBIOS_MAJOR_VER; - se->minor_ver = SMBIOS_MINOR_VER; - se->doc_rev = 0; - se->entry_point_rev = 1; - se->max_struct_size = len; - se->struct_table_address = table_addr; - se->checksum = table_compute_checksum(se, - sizeof(struct smbios3_entry)); - } else { - struct smbios_entry *se; - - se = map_sysmem(start_addr, sizeof(struct smbios_entry)); - memset(se, '\0', sizeof(struct smbios_entry)); - memcpy(se->anchor, "_SM_", 4); - se->length = sizeof(struct smbios_entry); - se->major_ver = SMBIOS_MAJOR_VER; - se->minor_ver = SMBIOS_MINOR_VER; - se->max_struct_size = max_struct_size; - memcpy(se->intermediate_anchor, "_DMI_", 5); - se->struct_table_length = len; - - se->struct_table_address = table_addr; - - se->struct_count = handle; - - /* calculate checksums */ - istart = (char *)se + SMBIOS_INTERMEDIATE_OFFSET; - isize = sizeof(struct smbios_entry) - - SMBIOS_INTERMEDIATE_OFFSET; - se->intermediate_checksum = table_compute_checksum(istart, - isize); - se->checksum = table_compute_checksum(se, - sizeof(struct smbios_entry)); - unmap_sysmem(se); - } + + /* now go back and write the SMBIOS3 header */ + se = map_sysmem(start_addr, sizeof(struct smbios_entry)); + memset(se, '\0', sizeof(struct smbios_entry)); + memcpy(se->anchor, "_SM3_", 5); + se->length = sizeof(struct smbios3_entry); + se->major_ver = SMBIOS_MAJOR_VER; + se->minor_ver = SMBIOS_MINOR_VER; + se->doc_rev = 0; + se->entry_point_rev = 1; + se->max_struct_size = len; + se->struct_table_address = table_addr; + se->checksum = table_compute_checksum(se, sizeof(struct smbios3_entry)); + unmap_sysmem(se); return addr; } -- cgit v1.2.3