Skip to content

Commit

Permalink
Merge patch series "upl: Prerequite patches for updated spec"
Browse files Browse the repository at this point in the history
Simon Glass <[email protected]> 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/[email protected]
  • Loading branch information
trini committed Jan 22, 2025
2 parents 2eed5a1 + 8985ff5 commit a3b71cc
Show file tree
Hide file tree
Showing 45 changed files with 369 additions and 110 deletions.
9 changes: 0 additions & 9 deletions arch/x86/include/asm/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,6 @@ u32 cpu_get_family_model(void);
*/
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);

Expand Down
3 changes: 3 additions & 0 deletions arch/x86/lib/bdinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright 2021 Google LLC
*/

#include <cpu.h>
#include <efi.h>
#include <init.h>
#include <asm/cpu.h>
Expand Down Expand Up @@ -32,6 +33,8 @@ void arch_print_bdinfo(void)
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();
}
15 changes: 13 additions & 2 deletions arch/x86/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ static int boot_prep_linux(struct bootm_headers *images)
#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;
Expand Down Expand Up @@ -259,3 +259,14 @@ int do_bootm_linux(int flag, struct bootm_info *bmi)

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;
}
12 changes: 10 additions & 2 deletions arch/x86/lib/spl.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,19 @@ void spl_board_init(void)
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");
}
}
11 changes: 8 additions & 3 deletions arch/x86/lib/tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -59,10 +60,14 @@ static struct table_info table_list[] = {
* 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
};

Expand Down
4 changes: 2 additions & 2 deletions boot/image-board.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,8 @@ int image_locate_script(void *buf, int size, const char *fit_uname,
}

/* 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;
}
Expand Down
30 changes: 14 additions & 16 deletions boot/image-fit.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ void fit_image_print(const void *fit, int image_noffset, const char *p)
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);
Expand Down Expand Up @@ -902,22 +902,22 @@ int fit_image_get_entry(const void *fit, int noffset, ulong *entry)
}

/**
* 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.
*
* returns:
* 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;

Expand Down Expand Up @@ -1031,23 +1031,23 @@ int fit_image_get_data_size_unciphered(const void *fit, int noffset,
}

/**
* 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.
*
* returns:
* 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;
Expand All @@ -1074,7 +1074,7 @@ int fit_image_get_data_and_size(const void *fit, int noffset,
*size = len;
}
} else {
ret = fit_image_get_data(fit, noffset, data, size);
ret = fit_image_get_emb_data(fit, noffset, data, size);
}

return ret;
Expand Down Expand Up @@ -1432,7 +1432,7 @@ int fit_image_verify(const void *fit, int image_noffset)
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;
}
Expand Down Expand Up @@ -1781,8 +1781,7 @@ int fit_conf_find_compat(const void *fit, const void *fdt)
}

/* 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;
}
Expand Down Expand Up @@ -1941,7 +1940,7 @@ static int fit_get_data_tail(const void *fit, int noffset,
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))
Expand Down Expand Up @@ -2198,8 +2197,7 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
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;
Expand Down
4 changes: 2 additions & 2 deletions cmd/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -900,14 +900,14 @@ config MD5SUM_VERIFY

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
Expand Down
3 changes: 1 addition & 2 deletions cmd/ximg.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ do_imgextract(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}

/* 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;
}
Expand Down
2 changes: 2 additions & 0 deletions common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,8 @@ if BLOBLIST

choice
prompt "Bloblist location"
default BLOBLIST_FIXED if SANDBOX
default BLOBLIST_ALLOC
help
Select the location of the bloblist, via various means.

Expand Down
2 changes: 1 addition & 1 deletion common/spl/spl_fit.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,
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;
}
Expand Down
17 changes: 4 additions & 13 deletions common/splash_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,19 +395,10 @@ static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
}

/* 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;
Expand Down
1 change: 1 addition & 0 deletions configs/chromebook_bob_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
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
Expand Down
2 changes: 1 addition & 1 deletion configs/chromebook_coral_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CONFIG_LOGF_FUNC=y
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
Expand Down Expand Up @@ -128,4 +129,3 @@ CONFIG_GENERATE_ACPI_TABLE=y
CONFIG_CMD_DHRYSTONE=y
CONFIG_TPM=y
# CONFIG_GZIP is not set
CONFIG_BLOBLIST_TABLES=y
1 change: 1 addition & 0 deletions configs/chromebook_kevin_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
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
Expand Down
1 change: 1 addition & 0 deletions configs/chromebook_samus_tpl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
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
Expand Down
6 changes: 4 additions & 2 deletions configs/qemu-x86_64_defconfig
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -34,6 +35,7 @@ CONFIG_SPL_LOG=y
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
Expand Down
4 changes: 4 additions & 0 deletions configs/qemu-x86_defconfig
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,6 +24,9 @@ CONFIG_LOG=y
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
Expand Down
2 changes: 2 additions & 0 deletions configs/qemu_arm64_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ CONFIG_USE_PREBOOT=y
# 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
Expand Down
2 changes: 2 additions & 0 deletions configs/qemu_arm_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ CONFIG_USE_PREBOOT=y
# 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
Expand Down
Loading

0 comments on commit a3b71cc

Please sign in to comment.