Merge patch series "upl: Prerequite patches for updated spec"
Simon Glass <sjg@chromium.org> says:
The current UPL spec[1] has been tidied up and improved over the last
year, since U-Boot's original UPL support was written.
This series includes some prerequisite patches needed for the real UPL
patches. It is split from [2]
[1] https://github.com/UniversalPayload/spec/tree/3f1450d
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=438574&state=*
Link: https://lore.kernel.org/r/20250111000029.245022-1-sjg@chromium.org
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index 8c1ef4c..fd389d4 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -284,15 +284,6 @@
*/
u32 cpu_get_stepping(void);
-/**
- * cpu_phys_address_size() - Get the physical address size in bits
- *
- * This is 32 for older CPUs but newer ones may support 36.
- *
- * Return: address size (typically 32 or 36)
- */
-int cpu_phys_address_size(void);
-
void board_final_init(void);
void board_final_cleanup(void);
diff --git a/arch/x86/lib/bdinfo.c b/arch/x86/lib/bdinfo.c
index 2a78f57..4b016d4 100644
--- a/arch/x86/lib/bdinfo.c
+++ b/arch/x86/lib/bdinfo.c
@@ -5,6 +5,7 @@
* Copyright 2021 Google LLC
*/
+#include <cpu.h>
#include <efi.h>
#include <init.h>
#include <asm/cpu.h>
@@ -32,6 +33,8 @@
bdinfo_print_num_l(" high start", gd->arch.table_start_high);
bdinfo_print_num_l(" high end", gd->arch.table_end_high);
+ bdinfo_print_num_ll("tsc", rdtsc());
+
if (IS_ENABLED(CONFIG_EFI_STUB))
efi_show_bdinfo();
}
diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 0cf3824..0827a88 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -105,8 +105,8 @@
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os && is_zimage) {
ret = fit_image_get_data(images->fit_hdr_os,
- images->fit_noffset_os,
- (const void **)&data, &len);
+ images->fit_noffset_os,
+ (const void **)&data, &len);
if (ret) {
puts("Can't get image data/size!\n");
goto error;
@@ -259,3 +259,14 @@
return boot_jump_linux(images);
}
+
+int arch_upl_jump(ulong entry, const struct abuf *buf)
+{
+ typedef EFIAPI void (*h_func)(void *hoff);
+ h_func func;
+
+ func = (h_func)(ulong)entry;
+ func(buf->data);
+
+ return -EFAULT;
+}
diff --git a/arch/x86/lib/spl.c b/arch/x86/lib/spl.c
index f761fbc..7a03350 100644
--- a/arch/x86/lib/spl.c
+++ b/arch/x86/lib/spl.c
@@ -298,11 +298,19 @@
if (IS_ENABLED(CONFIG_QEMU))
qemu_chipset_init();
+ if (CONFIG_IS_ENABLED(UPL_OUT))
+ gd->flags |= GD_FLG_UPL;
+
if (CONFIG_IS_ENABLED(VIDEO)) {
struct udevice *dev;
+ int ret;
/* Set up PCI video in SPL if required */
- uclass_first_device_err(UCLASS_PCI, &dev);
- uclass_first_device_err(UCLASS_VIDEO, &dev);
+ ret = uclass_first_device_err(UCLASS_PCI, &dev);
+ if (ret)
+ panic("Failed to set up PCI");
+ ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
+ if (ret)
+ panic("Failed to set up video");
}
}
diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index 45a70e9..44fe80c 100644
--- a/arch/x86/lib/tables.c
+++ b/arch/x86/lib/tables.c
@@ -16,6 +16,7 @@
#include <asm/tables.h>
#include <asm/coreboot_tables.h>
#include <linux/log2.h>
+#include <linux/sizes.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -59,10 +60,14 @@
* that the calculation of gd->table_end works properly
*/
#ifdef CONFIG_GENERATE_ACPI_TABLE
- { "acpi", write_acpi_tables, BLOBLISTT_ACPI_TABLES, 0x10000, 0x1000},
+ { "acpi", write_acpi_tables, BLOBLISTT_ACPI_TABLES, SZ_64K, SZ_4K},
#endif
-#if defined(CONFIG_GENERATE_SMBIOS_TABLE) && !defined(CONFIG_QFW_SMBIOS)
- { "smbios", write_smbios_table, BLOBLISTT_SMBIOS_TABLES, 0x1000, 0x100},
+#ifdef CONFIG_GENERATE_SMBIOS_TABLE
+ /*
+ * align this to a 4K boundary, since UPL adds a reserved-memory node
+ * for it
+ */
+ { "smbios", write_smbios_table, BLOBLISTT_SMBIOS_TABLES, SZ_4K, SZ_4K},
#endif
};
diff --git a/boot/image-board.c b/boot/image-board.c
index 4e86a9a..514f8e6 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -1087,8 +1087,8 @@
}
/* get script subimage data address and length */
- if (fit_image_get_data_and_size(fit_hdr, noffset,
- &fit_data, &fit_len)) {
+ if (fit_image_get_data(fit_hdr, noffset, &fit_data,
+ &fit_len)) {
puts("Could not find script subimage data\n");
return 1;
}
diff --git a/boot/image-fit.c b/boot/image-fit.c
index db7fb61..70080d1 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -509,7 +509,7 @@
fit_image_get_comp(fit, image_noffset, &comp);
printf("%s Compression: %s\n", p, genimg_get_comp_name(comp));
- ret = fit_image_get_data_and_size(fit, image_noffset, &data, &size);
+ ret = fit_image_get_data(fit, image_noffset, &data, &size);
if (!tools_build()) {
printf("%s Data Start: ", p);
@@ -902,13 +902,13 @@
}
/**
- * fit_image_get_data - get data property and its size for a given component image node
+ * fit_image_get_emb_data - get data property and its size for a given component image node
* @fit: pointer to the FIT format image header
* @noffset: component image node offset
* @data: double pointer to void, will hold data property's data address
* @size: pointer to size_t, will hold data property's data size
*
- * fit_image_get_data() finds data property in a given component image node.
+ * fit_image_get_emb_data() finds data property in a given component image node.
* If the property is found its data start address and size are returned to
* the caller.
*
@@ -916,8 +916,8 @@
* 0, on success
* -1, on failure
*/
-int fit_image_get_data(const void *fit, int noffset,
- const void **data, size_t *size)
+int fit_image_get_emb_data(const void *fit, int noffset, const void **data,
+ size_t *size)
{
int len;
@@ -1031,14 +1031,14 @@
}
/**
- * fit_image_get_data_and_size - get data and its size including
+ * fit_image_get_data - get data and its size including
* both embedded and external data
* @fit: pointer to the FIT format image header
* @noffset: component image node offset
* @data: double pointer to void, will hold data property's data address
* @size: pointer to size_t, will hold data property's data size
*
- * fit_image_get_data_and_size() finds data and its size including
+ * fit_image_get_data() finds data and its size including
* both embedded and external data. If the property is found
* its data start address and size are returned to the caller.
*
@@ -1046,8 +1046,8 @@
* 0, on success
* otherwise, on failure
*/
-int fit_image_get_data_and_size(const void *fit, int noffset,
- const void **data, size_t *size)
+int fit_image_get_data(const void *fit, int noffset, const void **data,
+ size_t *size)
{
bool external_data = false;
int offset;
@@ -1074,7 +1074,7 @@
*size = len;
}
} else {
- ret = fit_image_get_data(fit, noffset, data, size);
+ ret = fit_image_get_emb_data(fit, noffset, data, size);
}
return ret;
@@ -1432,7 +1432,7 @@
goto err;
}
/* Get image data and data length */
- if (fit_image_get_data_and_size(fit, image_noffset, &data, &size)) {
+ if (fit_image_get_data(fit, image_noffset, &data, &size)) {
err_msg = "Can't get image data/size";
goto err;
}
@@ -1781,8 +1781,7 @@
}
/* search in this config's kernel FDT */
- if (fit_image_get_data_and_size(fit, kfdt_noffset,
- &fdt, &sz)) {
+ if (fit_image_get_data(fit, kfdt_noffset, &fdt, &sz)) {
debug("Failed to get fdt \"%s\".\n", kfdt_name);
continue;
}
@@ -1941,7 +1940,7 @@
if (!fit_image_verify(fit, noffset))
return -EINVAL;
- if (fit_image_get_data_and_size(fit, noffset, data, size))
+ if (fit_image_get_data(fit, noffset, data, size))
return -ENOENT;
if (!fit_get_desc(fit, noffset, &desc))
@@ -2198,8 +2197,7 @@
bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL_OK);
/* get image data address and length */
- if (fit_image_get_data_and_size(fit, noffset,
- (const void **)&buf, &size)) {
+ if (fit_image_get_data(fit, noffset, (const void **)&buf, &size)) {
printf("Could not find %s subimage data!\n", prop_name);
bootstage_error(bootstage_id + BOOTSTAGE_SUB_GET_DATA);
return -ENOENT;
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 2a5a77f..d00e743 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -900,14 +900,14 @@
config CMD_MEMINFO
bool "meminfo"
- default y if SANDBOX
+ default y if SANDBOX || X86
help
Display memory information.
config CMD_MEMINFO_MAP
bool "- with memory map"
depends on CMD_MEMINFO
- default y if SANDBOX
+ default y if SANDBOX || X86
help
Shows a memory map, in addition to just the DRAM size. This allows
seeing where U-Boot's memory area is, at the top of DRAM, as well as
diff --git a/cmd/ximg.c b/cmd/ximg.c
index 1c96f5a..29d7c32 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -161,8 +161,7 @@
}
/* get subimage/external data address and length */
- if (fit_image_get_data_and_size(fit_hdr, noffset,
- &fit_data, &fit_len)) {
+ if (fit_image_get_data(fit_hdr, noffset, &fit_data, &fit_len)) {
puts("Could not find script subimage data\n");
return 1;
}
diff --git a/common/Kconfig b/common/Kconfig
index 0e8c44f..7685914 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1047,6 +1047,8 @@
choice
prompt "Bloblist location"
+ default BLOBLIST_FIXED if SANDBOX
+ default BLOBLIST_ALLOC
help
Select the location of the bloblist, via various means.
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index ac84625..64c4349 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -289,7 +289,7 @@
src = src_ptr + overhead;
} else {
/* Embedded data */
- if (fit_image_get_data(fit, node, &data, &length)) {
+ if (fit_image_get_emb_data(fit, node, &data, &length)) {
puts("Cannot get image data/size\n");
return -ENOENT;
}
diff --git a/common/splash_source.c b/common/splash_source.c
index f43e7cc..2df78a4 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -395,19 +395,10 @@
}
/* Extract the splash data from FIT */
- /* 1. Test if splash is in FIT internal data. */
- if (!fit_image_get_data(fit_header, node_offset, &internal_splash_data, &internal_splash_size))
- memmove((void *)(uintptr_t)bmp_load_addr, internal_splash_data, internal_splash_size);
- /* 2. Test if splash is in FIT external data with fixed position. */
- else if (!fit_image_get_data_position(fit_header, node_offset, &external_splash_addr))
- is_splash_external = true;
- /* 3. Test if splash is in FIT external data with offset. */
- else if (!fit_image_get_data_offset(fit_header, node_offset, &external_splash_addr)) {
- /* Align data offset to 4-byte boundary */
- fit_size = ALIGN(fdt_totalsize(fit_header), 4);
- /* External splash offset means the offset by end of FIT header */
- external_splash_addr += location->offset + fit_size;
- is_splash_external = true;
+ if (!fit_image_get_data(fit_header, node_offset, &internal_splash_data,
+ &internal_splash_size)) {
+ memmove((void *)(uintptr_t)bmp_load_addr, internal_splash_data,
+ internal_splash_size);
} else {
printf("Failed to get splash image from FIT\n");
return -ENODATA;
diff --git a/configs/chromebook_bob_defconfig b/configs/chromebook_bob_defconfig
index 5e67de3..1b018ef 100644
--- a/configs/chromebook_bob_defconfig
+++ b/configs/chromebook_bob_defconfig
@@ -24,6 +24,7 @@
CONFIG_BOARD_EARLY_INIT_R=y
CONFIG_BLOBLIST=y
# CONFIG_TPL_BLOBLIST is not set
+CONFIG_BLOBLIST_FIXED=y
CONFIG_BLOBLIST_ADDR=0x100000
CONFIG_BLOBLIST_SIZE=0x1000
CONFIG_SPL_MAX_SIZE=0x40000
diff --git a/configs/chromebook_coral_defconfig b/configs/chromebook_coral_defconfig
index b4f7e61..93e3355 100644
--- a/configs/chromebook_coral_defconfig
+++ b/configs/chromebook_coral_defconfig
@@ -45,6 +45,7 @@
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_BLOBLIST=y
# CONFIG_TPL_BLOBLIST is not set
+CONFIG_BLOBLIST_FIXED=y
CONFIG_BLOBLIST_ADDR=0xfef10000
CONFIG_BLOBLIST_SIZE=0x1000
CONFIG_SPL_NO_BSS_LIMIT=y
@@ -128,4 +129,3 @@
CONFIG_CMD_DHRYSTONE=y
CONFIG_TPM=y
# CONFIG_GZIP is not set
-CONFIG_BLOBLIST_TABLES=y
diff --git a/configs/chromebook_kevin_defconfig b/configs/chromebook_kevin_defconfig
index 0be6e44..1ee0c0e 100644
--- a/configs/chromebook_kevin_defconfig
+++ b/configs/chromebook_kevin_defconfig
@@ -25,6 +25,7 @@
CONFIG_BOARD_EARLY_INIT_R=y
CONFIG_BLOBLIST=y
# CONFIG_TPL_BLOBLIST is not set
+CONFIG_BLOBLIST_FIXED=y
CONFIG_BLOBLIST_ADDR=0x100000
CONFIG_BLOBLIST_SIZE=0x1000
CONFIG_SPL_MAX_SIZE=0x40000
diff --git a/configs/chromebook_samus_tpl_defconfig b/configs/chromebook_samus_tpl_defconfig
index fc524da..42337d7 100644
--- a/configs/chromebook_samus_tpl_defconfig
+++ b/configs/chromebook_samus_tpl_defconfig
@@ -34,6 +34,7 @@
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_MISC_INIT_R=y
CONFIG_BLOBLIST=y
+CONFIG_BLOBLIST_FIXED=y
CONFIG_BLOBLIST_ADDR=0xff7c0000
CONFIG_BLOBLIST_SIZE=0x1000
CONFIG_SPL_NO_BSS_LIMIT=y
diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig
index 812b206..792ba06 100644
--- a/configs/qemu-x86_64_defconfig
+++ b/configs/qemu-x86_64_defconfig
@@ -1,13 +1,14 @@
CONFIG_X86=y
CONFIG_TEXT_BASE=0x1110000
CONFIG_SYS_MALLOC_F_LEN=0x1000
+CONFIG_BLOBLIST_SIZE_RELOC=0x20000
CONFIG_NR_DRAM_BANKS=8
CONFIG_ENV_SIZE=0x40000
CONFIG_MAX_CPUS=2
CONFIG_SPL_DM_SPI=y
CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx"
-CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000
-CONFIG_SPL_TEXT_BASE=0xfffd4000
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x3000
+CONFIG_SPL_TEXT_BASE=0xfffd0000
CONFIG_DEBUG_UART_BASE=0x3f8
CONFIG_DEBUG_UART_CLOCK=1843200
CONFIG_X86_RUN_64BIT=y
@@ -34,6 +35,7 @@
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_PCI_INIT_R=y
CONFIG_BLOBLIST=y
+CONFIG_BLOBLIST_FIXED=y
CONFIG_BLOBLIST_ADDR=0x10000
CONFIG_SPL_NO_BSS_LIMIT=y
CONFIG_SPL_BOARD_INIT=y
diff --git a/configs/qemu-x86_defconfig b/configs/qemu-x86_defconfig
index 947d15c..0b0e10c 100644
--- a/configs/qemu-x86_defconfig
+++ b/configs/qemu-x86_defconfig
@@ -1,6 +1,7 @@
CONFIG_X86=y
CONFIG_TEXT_BASE=0xFFF00000
CONFIG_SYS_MALLOC_F_LEN=0x1000
+CONFIG_BLOBLIST_SIZE_RELOC=0x20000
CONFIG_NR_DRAM_BANKS=8
CONFIG_ENV_SIZE=0x40000
CONFIG_MAX_CPUS=2
@@ -23,6 +24,9 @@
CONFIG_LOGF_FUNC=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_PCI_INIT_R=y
+CONFIG_BLOBLIST=y
+CONFIG_BLOBLIST_FIXED=y
+CONFIG_BLOBLIST_ADDR=0x10000
CONFIG_CMD_CPU=y
CONFIG_CMD_BOOTEFI_SELFTEST=y
CONFIG_CMD_NVEDIT_EFI=y
diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig
index 0c7107c..11a4c4e 100644
--- a/configs/qemu_arm64_defconfig
+++ b/configs/qemu_arm64_defconfig
@@ -26,6 +26,8 @@
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_PCI_INIT_R=y
+CONFIG_BLOBLIST=y
+CONFIG_BLOBLIST_SIZE_RELOC=0x2000
CONFIG_CMD_SMBIOS=y
CONFIG_CMD_BOOTZ=y
CONFIG_CMD_BOOTEFI_SELFTEST=y
diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig
index e164407..d8e916d 100644
--- a/configs/qemu_arm_defconfig
+++ b/configs/qemu_arm_defconfig
@@ -27,6 +27,8 @@
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_PCI_INIT_R=y
+CONFIG_BLOBLIST=y
+CONFIG_BLOBLIST_SIZE_RELOC=0x2000
CONFIG_CMD_BOOTEFI_SELFTEST=y
CONFIG_CMD_NVEDIT_EFI=y
CONFIG_CMD_DFU=y
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index c816182..26e014d 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -118,7 +118,7 @@
return log_msg_ret("liv", ret);
tree = oftree_from_np(root);
} else {
- const int size = 1024;
+ const int size = 4096;
void *fdt;
ret = check_tree_count();
@@ -309,6 +309,29 @@
return (strlen(name) == len) && !strncmp(node_name, name, len);
}
+bool ofnode_name_eq_unit(ofnode node, const char *name)
+{
+ const char *node_name, *p;
+ int len;
+
+ assert(ofnode_valid(node));
+
+ node_name = ofnode_get_name(node);
+
+ /* check the whole name */
+ if (!strcmp(node_name, name))
+ return true;
+
+ /* if @name has no unit address, try the node name without it */
+ len = strlen(name);
+ p = strchr(node_name, '@');
+ if (p && !strchr(name, '@') && len == p - node_name &&
+ !strncmp(node_name, name, len))
+ return true;
+
+ return false;
+}
+
int ofnode_read_u8(ofnode node, const char *propname, u8 *outp)
{
const u8 *cell;
@@ -576,14 +599,9 @@
log_debug("%s: %s: ", __func__, subnode_name);
if (ofnode_is_np(node)) {
- struct device_node *np = ofnode_to_np(node);
-
- for (np = np->child; np; np = np->sibling) {
- if (!strcmp(subnode_name, np->name))
- break;
- }
- subnode = np_to_ofnode(np);
+ subnode = ofnode_find_subnode_unit(node, subnode_name);
} else {
+ /* special case to avoid code-size increase */
int ooffset = fdt_subnode_offset(ofnode_to_fdt(node),
ofnode_to_offset(node), subnode_name);
subnode = noffset_to_ofnode(node, ooffset);
@@ -594,6 +612,26 @@
return subnode;
}
+ofnode ofnode_find_subnode_unit(ofnode node, const char *subnode_name)
+{
+ ofnode subnode, found = ofnode_null();
+
+ assert(ofnode_valid(node));
+ log_debug("%s: ", subnode_name);
+
+ ofnode_for_each_subnode(subnode, node) {
+ if (ofnode_name_eq_unit(subnode, subnode_name)) {
+ found = subnode;
+ break;
+ }
+ }
+
+ log_debug("%s\n", ofnode_valid(found) ?
+ ofnode_get_name(found) : "<none>");
+
+ return found;
+}
+
int ofnode_read_u32_array(ofnode node, const char *propname,
u32 *out_values, size_t sz)
{
@@ -1710,9 +1748,10 @@
int ofnode_write_prop(ofnode node, const char *propname, const void *value,
int len, bool copy)
{
+ int ret;
+
if (of_live_active()) {
void *newval;
- int ret;
if (copy) {
newval = malloc(len);
@@ -1726,8 +1765,12 @@
free(newval);
return ret;
} else {
- return fdt_setprop(ofnode_to_fdt(node), ofnode_to_offset(node),
- propname, value, len);
+ ret = fdt_setprop(ofnode_to_fdt(node), ofnode_to_offset(node),
+ propname, value, len);
+ if (ret)
+ return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EINVAL;
+
+ return 0;
}
}
@@ -2015,7 +2058,7 @@
ret = -EEXIST;
}
if (offset < 0)
- return -EINVAL;
+ return offset == -FDT_ERR_NOSPACE ? -ENOSPC : -EINVAL;
subnode = noffset_to_ofnode(node, offset);
}
diff --git a/drivers/misc/qfw_acpi.c b/drivers/misc/qfw_acpi.c
index 7ffed1e..0d0cf76 100644
--- a/drivers/misc/qfw_acpi.c
+++ b/drivers/misc/qfw_acpi.c
@@ -7,6 +7,7 @@
#define LOG_CATEGORY UCLASS_QFW
#include <acpi/acpi_table.h>
+#include <bloblist.h>
#include <errno.h>
#include <malloc.h>
#include <mapmem.h>
@@ -160,6 +161,15 @@
struct bios_linker_entry *entry;
uint32_t size;
struct udevice *dev;
+ struct acpi_ctx *ctx;
+
+ ctx = malloc(sizeof(*ctx));
+ if (!ctx) {
+ printf("error: out of memory for acpi ctx\n");
+ return addr;
+ }
+
+ acpi_setup_ctx(ctx, addr);
ret = qfw_get_dev(&dev);
if (ret) {
@@ -257,6 +267,29 @@
return file->addr;
}
+void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt,
+ struct acpi_xsdt *xsdt)
+{
+ memset(rsdp, 0, sizeof(struct acpi_rsdp));
+
+ memcpy(rsdp->signature, RSDP_SIG, 8);
+ memcpy(rsdp->oem_id, OEM_ID, 6);
+
+ if (rsdt)
+ rsdp->rsdt_address = nomap_to_sysmem(rsdt);
+
+ if (xsdt)
+ rsdp->xsdt_address = nomap_to_sysmem(xsdt);
+
+ rsdp->length = sizeof(struct acpi_rsdp);
+ rsdp->revision = ACPI_RSDP_REV_ACPI_2_0;
+
+ /* Calculate checksums */
+ rsdp->checksum = table_compute_checksum(rsdp, 20);
+ rsdp->ext_checksum = table_compute_checksum(rsdp,
+ sizeof(struct acpi_rsdp));
+}
+
#ifndef CONFIG_X86
static int evt_write_acpi_tables(void)
{
@@ -264,9 +297,9 @@
void *ptr;
/* Reserve 64K for ACPI tables, aligned to a 4K boundary */
- ptr = memalign(SZ_4K, SZ_64K);
+ ptr = bloblist_add(BLOBLISTT_ACPI_TABLES, SZ_64K, 12);
if (!ptr)
- return -ENOMEM;
+ return -ENOBUFS;
addr = map_to_sysmem(ptr);
/* Generate ACPI tables */
diff --git a/drivers/misc/qfw_smbios.c b/drivers/misc/qfw_smbios.c
index c3e8c31..93c4a80 100644
--- a/drivers/misc/qfw_smbios.c
+++ b/drivers/misc/qfw_smbios.c
@@ -5,6 +5,7 @@
#define LOG_CATEGORY UCLASS_QFW
+#include <bloblist.h>
#include <efi_loader.h>
#include <errno.h>
#include <log.h>
@@ -15,6 +16,7 @@
#include <tables_csum.h>
#include <linux/sizes.h>
#include <asm/global_data.h>
+#include <linux/err.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -105,11 +107,10 @@
/**
* qfw_write_smbios_tables() - copy SMBIOS tables from QEMU
*
- * @addr: target buffer
- * @size: size of target buffer
+ * @addr: address of target buffer
* Return: 0 for success, -ve on error
*/
-static int qfw_write_smbios_tables(u8 *addr, uint32_t size)
+ulong write_smbios_table(ulong addr)
{
int ret;
struct udevice *dev;
@@ -143,16 +144,13 @@
table = qfw_load_smbios_table(dev, &table_size,
"etc/smbios/smbios-tables");
- if (table_size + sizeof(struct smbios3_entry) > size) {
- free(table);
- return -ENOMEM;
- }
- memcpy(addr, table, table_size);
+ memcpy((void *)addr, table, table_size);
free(table);
- return 0;
+ return addr + table_size;
}
+#ifndef CONFIG_X86
/**
* qfw_evt_write_smbios_tables() - event handler for copying QEMU SMBIOS tables
*
@@ -160,9 +158,9 @@
*/
static int qfw_evt_write_smbios_tables(void)
{
- phys_addr_t addr;
+ ulong addr, end;
void *ptr;
- int ret;
+
/*
* TODO:
* This size is currently hard coded in lib/efi_loader/efi_smbios.c.
@@ -170,22 +168,21 @@
*/
uint32_t size = SZ_4K;
- /* Reserve 64K for SMBIOS tables, aligned to a 4K boundary */
- ptr = memalign(SZ_4K, size);
- if (!ptr) {
- log_err("Out of memory\n");
- return -ENOMEM;
- }
+ log_debug("qfw_evt_write_smbios_tables bloblist\n");
+ /* Reserve 4K for SMBIOS tables, aligned to a 4K boundary */
+ ptr = bloblist_add(BLOBLISTT_SMBIOS_TABLES, size, 12);
+ if (!ptr)
+ return log_msg_ret("bloblist", -ENOBUFS);
+
addr = map_to_sysmem(ptr);
/* Generate SMBIOS tables */
- ret = qfw_write_smbios_tables(ptr, size);
- if (ret) {
- if (CONFIG_IS_ENABLED(GENERATE_SMBIOS_TABLE)) {
- log_info("Falling back to U-Boot generated SMBIOS tables\n");
- write_smbios_table(addr);
- }
+ end = write_smbios_table(addr);
+ if (IS_ERR_VALUE(end)) {
+ log_warning("SMBIOS: Failed to write (err=%dE)\n", (int)end);
} else {
+ if (end - addr > size)
+ return -ENOMEM;
log_debug("SMBIOS tables copied from QEMU\n");
}
@@ -193,5 +190,5 @@
return 0;
}
-
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, qfw_evt_write_smbios_tables);
+#endif /* !X86 */
diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 2753df2..3697ad0 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -347,6 +347,7 @@
case 32:
case 24:
uc_priv->bpix = VIDEO_BPP32;
+ uc_priv->format = VIDEO_X8B8G8R8;
break;
case 16:
uc_priv->bpix = VIDEO_BPP16;
@@ -392,6 +393,7 @@
uc_priv->ysize = ho->ysize;
uc_priv->line_length = ho->line_length;
uc_priv->bpix = ho->bpix;
+ uc_priv->format = ho->format;
} else {
bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display");
ret = dm_pci_run_vga_bios(dev, int15_handler,
@@ -438,6 +440,7 @@
ho->ysize = uc_priv->ysize;
ho->line_length = uc_priv->line_length;
ho->bpix = uc_priv->bpix;
+ ho->format = uc_priv->format;
}
return 0;
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index c3b884b..039da83 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -464,7 +464,7 @@
struct ns16550_plat *plat = com_port->plat;
/* save code size */
- if (!not_xpl())
+ if (!not_xpl() && !CONFIG_IS_ENABLED(UPL_OUT))
return -ENOSYS;
info->type = SERIAL_CHIP_16550_COMPATIBLE;
diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c
index 00e673a..c34bc23 100644
--- a/drivers/video/bochs.c
+++ b/drivers/video/bochs.c
@@ -64,6 +64,7 @@
uc_priv->xsize = xsize;
uc_priv->ysize = ysize;
uc_priv->bpix = VIDEO_BPP32;
+ uc_priv->format = VIDEO_X8B8G8R8;
/* setup video mode */
bochs_write(mmio, INDEX_ENABLE, 0);
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index a5b3e89..ff4f219 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -589,6 +589,7 @@
ho->ysize = priv->ysize;
ho->line_length = priv->line_length;
ho->bpix = priv->bpix;
+ ho->format = priv->format;
}
if (IS_ENABLED(CONFIG_VIDEO_COPY) && plat->copy_base)
diff --git a/dts/Kconfig b/dts/Kconfig
index ffd50c04..6a5141b 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -183,7 +183,6 @@
config OF_HAS_PRIOR_STAGE
bool
- depends on !BLOBLIST
help
Indicates that a prior stage of the firmware (before U-Boot proper)
makes use of device tree and this board normally boots with that prior
diff --git a/include/abuf.h b/include/abuf.h
index be98ec7..62ff649 100644
--- a/include/abuf.h
+++ b/include/abuf.h
@@ -9,7 +9,11 @@
#ifndef __ABUF_H
#define __ABUF_H
+#ifdef USE_HOSTCC
+#include <sys/types.h>
+#else
#include <linux/types.h>
+#endif
/**
* struct abuf - buffer that can be allocated and freed
@@ -43,6 +47,14 @@
}
/**
+ * abuf_addr() - Get the address of a buffer's data
+ *
+ * @abuf: Buffer to check
+ * Return: address of buffer
+ */
+ulong abuf_addr(const struct abuf *abuf);
+
+/**
* abuf_set() - set the (unallocated) data in a buffer
*
* This simply makes the abuf point to the supplied data, which must be live
@@ -146,6 +158,19 @@
void abuf_init_set(struct abuf *abuf, void *data, size_t size);
/**
+ * abuf_init_const() - Set up a new const abuf
+ *
+ * Inits a new abuf and sets up its (unallocated) data. The only current
+ * difference between this and abuf_init_set() is the 'data' parameter is a
+ * const pointer. At some point a flag could be used to indicate const-ness.
+ *
+ * @abuf: abuf to set up
+ * @data: New contents of abuf
+ * @size: New size of abuf
+ */
+void abuf_init_const(struct abuf *abuf, const void *data, size_t size);
+
+/**
* abuf_uninit() - Free any memory used by an abuf
*
* The buffer must be inited before this can be called.
diff --git a/include/cpu.h b/include/cpu.h
index 0018910..d0cd104 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -179,4 +179,18 @@
* @return 0 if OK, -ve on error
*/
int cpu_release_core(const struct udevice *dev, phys_addr_t addr);
+
+/**
+ * cpu_phys_address_size() - Get the physical-address size for the CPU
+ *
+ * x86 CPUs have a setting which indicates how many bits of address space are
+ * available on the CPU. This is 32 for older CPUs but newer ones may support 36
+ * or more.
+ *
+ * For non-x86 CPUs the result may simply be 32 for 32-bit CPUS or 64 for 64-bit
+ *
+ * Return: address size (typically 32 or 36)
+ */
+int cpu_phys_address_size(void);
+
#endif
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 890f0e6..1203934 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -386,16 +386,29 @@
void oftree_dispose(oftree tree);
/**
- * ofnode_name_eq() - Check if the node name is equivalent to a given name
- * ignoring the unit address
+ * ofnode_name_eq() - Check a node name ignoring its unit address
*
- * @node: valid node reference that has to be compared
- * @name: name that has to be compared with the node name
+ * @node: valid node to compared, which may have a unit address
+ * @name: name (without unit address) to compare with the node name
* Return: true if matches, false if it doesn't match
*/
bool ofnode_name_eq(ofnode node, const char *name);
/**
+ * ofnode_name_eq_unit() - Check a node name ignoring its unit address
+ *
+ * This is separate from ofnode_name_eq() to avoid code-size increase for
+ * boards which don't need this function
+ *
+ * @node: valid node to compared, which may have a unit address
+ * @name: name to compare with the node name. If this contains a unit
+ * address, it is matched, otherwise the unit address is ignored
+ * when searching for matches
+ * Return: true if matches, false if it doesn't match
+ */
+bool ofnode_name_eq_unit(ofnode node, const char *name);
+
+/**
* ofnode_read_u8() - Read a 8-bit integer from a property
*
* @node: valid node reference to read property from
@@ -594,6 +607,18 @@
*/
ofnode ofnode_find_subnode(ofnode node, const char *subnode_name);
+/**
+ * ofnode_find_subnode_unit() - find a named subnode of a parent node
+ *
+ * @node: valid reference to parent node
+ * @subnode_name: name of subnode to find, including any unit address. If the
+ * unit address is omitted, any subnode which matches the name (excluding
+ * any unit address) is returned
+ * Return: reference to subnode (which can be invalid if there is no such
+ * subnode)
+ */
+ofnode ofnode_find_subnode_unit(ofnode node, const char *subnode_name);
+
#if CONFIG_IS_ENABLED(DM_INLINE_OFNODE)
#include <asm/global_data.h>
@@ -1809,7 +1834,7 @@
* of_add_subnode() - add a new subnode to a node
*
* @parent: parent node to add to
- * @name: name of subnode
+ * @name: name of subnode (allocated by this function)
* @nodep: returns pointer to new subnode (valid if the function returns 0
* or -EEXIST)
* Returns 0 if OK, -EEXIST if already exists, -ENOMEM if out of memory, other
diff --git a/include/image.h b/include/image.h
index 0a61dfd..8a9f779 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1160,16 +1160,16 @@
int fit_image_get_comp(const void *fit, int noffset, uint8_t *comp);
int fit_image_get_load(const void *fit, int noffset, ulong *load);
int fit_image_get_entry(const void *fit, int noffset, ulong *entry);
-int fit_image_get_data(const void *fit, int noffset,
- const void **data, size_t *size);
+int fit_image_get_emb_data(const void *fit, int noffset, const void **data,
+ size_t *size);
int fit_image_get_data_offset(const void *fit, int noffset, int *data_offset);
int fit_image_get_data_position(const void *fit, int noffset,
int *data_position);
int fit_image_get_data_size(const void *fit, int noffset, int *data_size);
int fit_image_get_data_size_unciphered(const void *fit, int noffset,
size_t *data_size);
-int fit_image_get_data_and_size(const void *fit, int noffset,
- const void **data, size_t *size);
+int fit_image_get_data(const void *fit, int noffset, const void **data,
+ size_t *size);
/**
* fit_image_get_phase() - Get the phase from a FIT image
diff --git a/include/video.h b/include/video.h
index 4ec71ab..a1f7fd7 100644
--- a/include/video.h
+++ b/include/video.h
@@ -150,6 +150,7 @@
* set by the driver, but if not, the uclass will set it after
* probing
* @bpix: Encoded bits per pixel (enum video_log2_bpp)
+ * @format: Video format (enum video_format)
*/
struct video_handoff {
u64 fb;
@@ -158,6 +159,7 @@
u16 ysize;
u32 line_length;
u8 bpix;
+ u8 format;
};
/** enum colour_idx - the 16 colors supported by consoles */
diff --git a/lib/Kconfig b/lib/Kconfig
index baeb615..0a29516 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1067,6 +1067,7 @@
config BLOBLIST_TABLES
bool "Put tables in a bloblist"
depends on BLOBLIST
+ default y if X86
default y if (ARM && EFI_LOADER && GENERATE_ACPI_TABLE)
default n
help
diff --git a/lib/Makefile b/lib/Makefile
index 3595086..fc6e68c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -41,7 +41,12 @@
obj-$(CONFIG_FIT) += fdtdec_common.o
obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
+
+# With QEMU the SMBIOS tables come from there, not from U-Boot
+ifndef CONFIG_QFW_SMBIOS
obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
+endif
+
obj-$(CONFIG_SMBIOS_PARSER) += smbios-parser.o
obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o
obj-y += initcall.o
diff --git a/lib/abuf.c b/lib/abuf.c
index 937c3df..61adf7f 100644
--- a/lib/abuf.c
+++ b/lib/abuf.c
@@ -26,6 +26,12 @@
{
abuf_set(abuf, map_sysmem(addr, size), size);
}
+
+ulong abuf_addr(const struct abuf *abuf)
+{
+ return map_to_sysmem(abuf->data);
+}
+
#else
/* copied from lib/string.c for convenience */
static char *memdup(const void *src, size_t len)
@@ -113,6 +119,12 @@
abuf_set(abuf, data, size);
}
+void abuf_init_const(struct abuf *abuf, const void *data, size_t size)
+{
+ /* for now there is no flag indicating that the abuf data is constant */
+ abuf_init_set(abuf, (void *)data, size);
+}
+
void abuf_init_move(struct abuf *abuf, void *data, size_t size)
{
abuf_init_set(abuf, data, size);
diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c
index 67bd7f8..ff305a6 100644
--- a/lib/efi_loader/efi_acpi.c
+++ b/lib/efi_loader/efi_acpi.c
@@ -25,6 +25,16 @@
ulong addr, start, end;
efi_status_t ret;
+ /*
+ * The bloblist is already marked reserved. For now, we don't bother
+ * marking it with EFI_ACPI_RECLAIM_MEMORY since we would need to cut a
+ * hole in the EFI_BOOT_SERVICES_CODE region added by
+ * add_u_boot_and_runtime(). At some point that function could create a
+ * more detailed map.
+ */
+ if (IS_ENABLED(CONFIG_BLOBLIST_TABLES))
+ return EFI_SUCCESS;
+
/* Mark space used for tables */
start = ALIGN_DOWN(gd->arch.table_start, EFI_PAGE_MASK);
end = ALIGN(gd->arch.table_end, EFI_PAGE_MASK);
diff --git a/test/common/Makefile b/test/common/Makefile
index 53c4f16..95bd007 100644
--- a/test/common/Makefile
+++ b/test/common/Makefile
@@ -1,9 +1,13 @@
# SPDX-License-Identifier: GPL-2.0+
obj-y += cmd_ut_common.o
obj-$(CONFIG_AUTOBOOT) += test_autoboot.o
+
ifneq ($(CONFIG_$(XPL_)BLOBLIST),)
+ifdef CONFIG_BLOBLIST_FIXED
obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o
endif
+endif
+
obj-$(CONFIG_CYCLIC) += cyclic.o
obj-$(CONFIG_EVENT_DYNAMIC) += event.o
obj-y += cread.o
diff --git a/test/dm/core.c b/test/dm/core.c
index c59ffc6..959b834 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -186,10 +186,30 @@
ut_assert(ofnode_valid(node));
ut_assert(ofnode_name_eq(node, "mmio-bus"));
+ ut_assert(!ofnode_name_eq(node, "mmio-bus@0"));
+
return 0;
}
DM_TEST(dm_test_compare_node_name, UTF_SCAN_PDATA);
+/* compare node names ignoring the unit address */
+static int dm_test_compare_node_name_unit(struct unit_test_state *uts)
+{
+ ofnode node;
+
+ node = ofnode_path("/mmio-bus@0");
+ ut_assert(ofnode_valid(node));
+ ut_assert(ofnode_name_eq_unit(node, "mmio-bus"));
+
+ ut_assert(ofnode_name_eq_unit(node, "mmio-bus@0"));
+ ut_assert(!ofnode_name_eq_unit(node, "mmio-bus@1"));
+ ut_assert(!ofnode_name_eq_unit(node, "mmio-bu"));
+ ut_assert(!ofnode_name_eq_unit(node, "mmio-buss@0"));
+
+ return 0;
+}
+DM_TEST(dm_test_compare_node_name_unit, UTF_SCAN_PDATA);
+
/* Test that binding with uclass plat setting occurs correctly */
static int dm_test_autobind_uclass_pdata_valid(struct unit_test_state *uts)
{
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index f16b643..4a23a3c 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -1303,6 +1303,25 @@
}
DM_TEST(dm_test_ofnode_find_subnode, UTF_SCAN_FDT);
+/* check ofnode_find_subnode() with unit addresses */
+static int dm_test_ofnode_find_subnode_unit(struct unit_test_state *uts)
+{
+ ofnode node, subnode;
+
+ node = ofnode_path("/some-bus");
+ ut_assert(ofnode_valid(node));
+ subnode = ofnode_find_subnode_unit(node, "c-test@5");
+ ut_assert(ofnode_valid(subnode));
+ ut_asserteq_str("c-test@5", ofnode_get_name(subnode));
+
+ subnode = ofnode_find_subnode_unit(node, "c-test");
+ ut_assert(ofnode_valid(subnode));
+ ut_asserteq_str("c-test@5", ofnode_get_name(subnode));
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_find_subnode_unit, UTF_SCAN_FDT);
+
/* test ofnode_find_subnode() on the 'other' tree */
static int dm_test_ofnode_find_subnode_ot(struct unit_test_state *uts)
{
diff --git a/test/lib/abuf.c b/test/lib/abuf.c
index 7c0481a..b38690f 100644
--- a/test/lib/abuf.c
+++ b/test/lib/abuf.c
@@ -46,7 +46,29 @@
}
LIB_TEST(lib_test_abuf_set, 0);
-/* Test abuf_map_sysmem() */
+/* Test abuf_init_const() */
+static int lib_test_abuf_init_const(struct unit_test_state *uts)
+{
+ struct abuf buf;
+ ulong start;
+ void *ptr;
+
+ start = ut_check_free();
+
+ ptr = map_sysmem(0x100, 0);
+
+ abuf_init_const(&buf, ptr, 10);
+ ut_asserteq_ptr(ptr, buf.data);
+ ut_asserteq(10, buf.size);
+
+ /* No memory should have been allocated */
+ ut_assertok(ut_check_delta(start));
+
+ return 0;
+}
+LIB_TEST(lib_test_abuf_init_const, 0);
+
+/* Test abuf_map_sysmem() and abuf_addr() */
static int lib_test_abuf_map_sysmem(struct unit_test_state *uts)
{
struct abuf buf;
@@ -60,6 +82,8 @@
ut_asserteq(TEST_DATA_LEN, buf.size);
ut_asserteq(false, buf.alloced);
+ ut_asserteq(addr, abuf_addr(&buf));
+
return 0;
}
LIB_TEST(lib_test_abuf_map_sysmem, 0);
diff --git a/test/py/tests/test_upl.py b/test/py/tests/test_upl.py
index 3164bda..90125c4 100644
--- a/test/py/tests/test_upl.py
+++ b/test/py/tests/test_upl.py
@@ -17,7 +17,7 @@
proper and runs a test to check that the parameters are correct.
The entire FIT is loaded into memory in SPL (in upl_load_from_image()) so
- that it can be inpected in upl_test_info_norun
+ that it can be inspected in upl_test_info_norun
"""
cons = u_boot_console
ram = os.path.join(cons.config.build_dir, 'ram.bin')
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 0fccfbb..caed8d5 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -876,7 +876,7 @@
int ret;
/* get the data address and size of component at offset "image_noffset" */
- ret = fit_image_get_data_and_size(fit, image_noffset, &file_data, &file_size);
+ ret = fit_image_get_data(fit, image_noffset, &file_data, &file_size);
if (ret) {
fprintf(stderr, "Could not get component information\n");
return ret;
diff --git a/tools/image-host.c b/tools/image-host.c
index 16389bd..84095d7 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -574,7 +574,7 @@
}
/* Get image data and data length */
- if (fit_image_get_data(fit, image_noffset, &data, &size)) {
+ if (fit_image_get_emb_data(fit, image_noffset, &data, &size)) {
fprintf(stderr, "Can't get image data/size\n");
return -1;
}
@@ -654,7 +654,7 @@
int noffset;
/* Get image data and data length */
- if (fit_image_get_data(fit, image_noffset, &data, &size)) {
+ if (fit_image_get_emb_data(fit, image_noffset, &data, &size)) {
fprintf(stderr, "Can't get image data/size\n");
return -1;
}
diff --git a/tools/mkimage.h b/tools/mkimage.h
index d92a3ff..15741f2 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -37,7 +37,7 @@
return (void *)(uintptr_t)paddr;
}
-static inline ulong map_to_sysmem(void *ptr)
+static inline ulong map_to_sysmem(const void *ptr)
{
return (ulong)(uintptr_t)ptr;
}