diff options
author | Tom Rini <trini@konsulko.com> | 2022-01-13 14:33:02 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-01-13 14:33:02 -0500 |
commit | 25711b07ca1dcf73dc41b45ca040dadbcff0fa08 (patch) | |
tree | de49c129e19ab9b129aca41d59cd8ecdc3e18de7 | |
parent | 743c562d0c5269740236864bdb0002e73ec3e614 (diff) | |
parent | 6c9e3d1fc085977b5b38dfe610f65d1a7f48081b (diff) | |
download | u-boot-WIP/13Jan2022.zip u-boot-WIP/13Jan2022.tar.gz u-boot-WIP/13Jan2022.tar.bz2 |
Merge tag 'dm-pull-13jan22' of https://source.denx.de/u-boot/custodians/u-boot-dmWIP/13Jan2022
bloblist prep for standard passage
switch order of pinctrl and power domain calls
various minor fixes
-rw-r--r-- | arch/sandbox/cpu/os.c | 10 | ||||
-rw-r--r-- | arch/x86/cpu/broadwell/cpu_from_spl.c | 4 | ||||
-rw-r--r-- | common/Kconfig | 95 | ||||
-rw-r--r-- | common/bloblist.c | 119 | ||||
-rw-r--r-- | common/board_f.c | 2 | ||||
-rw-r--r-- | common/spl/spl.c | 4 | ||||
-rw-r--r-- | doc/develop/bloblist.rst | 8 | ||||
-rw-r--r-- | drivers/core/device.c | 16 | ||||
-rw-r--r-- | drivers/serial/serial-uclass.c | 3 | ||||
-rw-r--r-- | include/bloblist.h | 184 | ||||
-rw-r--r-- | include/fdtdec.h | 6 | ||||
-rw-r--r-- | include/linux/stddef.h | 8 | ||||
-rw-r--r-- | include/os.h | 2 | ||||
-rw-r--r-- | test/bloblist.c | 21 | ||||
-rwxr-xr-x | tools/genboardscfg.py | 2 | ||||
-rw-r--r-- | tools/patman/gitutil.py | 11 |
16 files changed, 359 insertions, 136 deletions
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 6837bfc..40ebe32 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -624,7 +624,13 @@ const char *os_dirent_get_typename(enum os_dirent_t type) return os_dirent_typename[OS_FILET_UNKNOWN]; } -int os_get_filesize(const char *fname, loff_t *size) +/* + * For compatibility reasons avoid loff_t here. + * U-Boot defines loff_t as long long. + * But /usr/include/linux/types.h may not define it at all. + * Alpine Linux being one example. + */ +int os_get_filesize(const char *fname, long long *size) { struct stat buf; int ret; @@ -667,7 +673,7 @@ int os_read_ram_buf(const char *fname) { struct sandbox_state *state = state_get_current(); int fd, ret; - loff_t size; + long long size; ret = os_get_filesize(fname, &size); if (ret < 0) diff --git a/arch/x86/cpu/broadwell/cpu_from_spl.c b/arch/x86/cpu/broadwell/cpu_from_spl.c index e5f62e7..df5a967 100644 --- a/arch/x86/cpu/broadwell/cpu_from_spl.c +++ b/arch/x86/cpu/broadwell/cpu_from_spl.c @@ -23,7 +23,7 @@ int dram_init(void) { struct spl_handoff *ho; - ho = bloblist_find(BLOBLISTT_SPL_HANDOFF, sizeof(*ho)); + ho = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(*ho)); if (!ho) return log_msg_ret("Missing SPL hand-off info", -ENOENT); handoff_load_dram_size(ho); @@ -56,7 +56,7 @@ int dram_init_banksize(void) { struct spl_handoff *ho; - ho = bloblist_find(BLOBLISTT_SPL_HANDOFF, sizeof(*ho)); + ho = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(*ho)); if (!ho) return log_msg_ret("Missing SPL hand-off info", -ENOENT); handoff_load_dram_banks(ho); diff --git a/common/Kconfig b/common/Kconfig index 0892d9b..82cd864 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -717,7 +717,7 @@ config BLOBLIST from TPL to SPL to U-Boot proper (and potentially to Linux). The blob list supports multiple binary blobs of data, each with a tag, so that different U-Boot components can store data which can survive - through to the next stage of the boot. + through to the next phase of the boot. config SPL_BLOBLIST bool "Support for a bloblist in SPL" @@ -738,15 +738,17 @@ config TPL_BLOBLIST if BLOBLIST -config BLOBLIST_SIZE - hex "Size of bloblist" - depends on BLOBLIST - default 0x400 +choice + prompt "Bloblist location" help - Sets the size of the bloblist in bytes. This must include all - overhead (alignment, bloblist header, record header). The bloblist - is set up in the first part of U-Boot to run (TPL, SPL or U-Boot - proper), and this sane bloblist is used for subsequent stages. + Select the location of the bloblist, via various means. + +config BLOBLIST_FIXED + bool "Place bloblist at a fixed address in memory" + help + Select this to used a fixed memory address for the bloblist. If the + bloblist exists at this address from a previous phase, it used as is. + If not it is created at this address in U-Boot. config BLOBLIST_ALLOC bool "Allocate bloblist" @@ -755,18 +757,31 @@ config BLOBLIST_ALLOC specify a fixed address on systems where this is unknown or can change at runtime. +endchoice + config BLOBLIST_ADDR hex "Address of bloblist" default 0xc000 if SANDBOX + depends on BLOBLIST_FIXED help Sets the address of the bloblist, set up by the first part of U-Boot - which runs. Subsequent U-Boot stages typically use the same address. + which runs. Subsequent U-Boot phases typically use the same address. This is not used if BLOBLIST_ALLOC is selected. +config BLOBLIST_SIZE + hex "Size of bloblist" + default 0x400 + help + Sets the size of the bloblist in bytes. This must include all + overhead (alignment, bloblist header, record header). The bloblist + is set up in the first part of U-Boot to run (TPL, SPL or U-Boot + proper), and this sane bloblist is used for subsequent phases. + config BLOBLIST_SIZE_RELOC hex "Size of bloblist after relocation" - default BLOBLIST_SIZE + default BLOBLIST_SIZE if BLOBLIST_FIXED || BLOBLIST_ALLOC + default 0 if BLOBLIST_PASSAGE help Sets the size of the bloblist in bytes after relocation. Since U-Boot has a lot more memory available then, it is possible to use a larger @@ -775,6 +790,64 @@ config BLOBLIST_SIZE_RELOC endif # BLOBLIST +if SPL_BLOBLIST + +choice + prompt "Bloblist location in SPL" + help + Select the location of the bloblist, via various means. Typically + you should use the same value for SPL as for U-Boot, since they need + to look in the same place. But if BLOBLIST_ALLOC is used, then a + fresh bloblist will be created each time, since there is no shared + address (between phases) for the bloblist. + +config SPL_BLOBLIST_FIXED + bool "Place bloblist at a fixed address in memory" + help + Select this to used a fixed memory address for the bloblist. If the + bloblist exists at this address from a previous phase, it used as is. + If not it is created at this address in SPL. + +config SPL_BLOBLIST_ALLOC + bool "Allocate bloblist" + help + Allocate the bloblist using malloc(). This avoids the need to + specify a fixed address on systems where this is unknown or can + change at runtime. + +endchoice + +endif # SPL_BLOBLIST + +if TPL_BLOBLIST + +choice + prompt "Bloblist location in TPL" + help + Select the location of the bloblist, via various means. Typically + you should use the same value for SPL as for U-Boot, since they need + to look in the same place. But if BLOBLIST_ALLOC is used, then a + fresh bloblist will be created each time, since there is no shared + address (between phases) for the bloblist. + +config TPL_BLOBLIST_FIXED + bool "Place bloblist at a fixed address in memory" + help + Select this to used a fixed memory address for the bloblist. If the + bloblist exists at this address from a previous phase, it used as is. + If not it is created at this address in TPL. + +config TPL_BLOBLIST_ALLOC + bool "Allocate bloblist" + help + Allocate the bloblist using malloc(). This avoids the need to + specify a fixed address on systems where this is unknown or can + change at runtime. + +endchoice + +endif # TPL_BLOBLIST + endmenu source "common/spl/Kconfig" diff --git a/common/bloblist.c b/common/bloblist.c index 01b0410..056b50c 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -1,9 +1,12 @@ -// SPDX-License-Identifier: GPL-2.0+ +// SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause /* * Copyright 2018 Google, Inc * Written by Simon Glass <sjg@chromium.org> */ +#define LOG_DEBUG +#define LOG_CATEGORY LOGC_BLOBLIST + #include <common.h> #include <bloblist.h> #include <log.h> @@ -29,26 +32,39 @@ DECLARE_GLOBAL_DATA_PTR; -static const char *const tag_name[] = { - [BLOBLISTT_NONE] = "(none)", - [BLOBLISTT_EC_HOSTEVENT] = "EC host event", - [BLOBLISTT_SPL_HANDOFF] = "SPL hand-off", - [BLOBLISTT_VBOOT_CTX] = "Chrome OS vboot context", - [BLOBLISTT_VBOOT_HANDOFF] = "Chrome OS vboot hand-off", - [BLOBLISTT_ACPI_GNVS] = "ACPI GNVS", - [BLOBLISTT_INTEL_VBT] = "Intel Video-BIOS table", - [BLOBLISTT_TPM2_TCG_LOG] = "TPM v2 log space", - [BLOBLISTT_TCPA_LOG] = "TPM log space", - [BLOBLISTT_ACPI_TABLES] = "ACPI tables for x86", - [BLOBLISTT_SMBIOS_TABLES] = "SMBIOS tables for x86", +static struct tag_name { + enum bloblist_tag_t tag; + const char *name; +} tag_name[] = { + { BLOBLISTT_NONE, "(none)" }, + + /* BLOBLISTT_AREA_FIRMWARE_TOP */ + + /* BLOBLISTT_AREA_FIRMWARE */ + { BLOBLISTT_ACPI_GNVS, "ACPI GNVS" }, + { BLOBLISTT_INTEL_VBT, "Intel Video-BIOS table" }, + { BLOBLISTT_TPM2_TCG_LOG, "TPM v2 log space" }, + { BLOBLISTT_TCPA_LOG, "TPM log space" }, + { BLOBLISTT_ACPI_TABLES, "ACPI tables for x86" }, + { BLOBLISTT_SMBIOS_TABLES, "SMBIOS tables for x86" }, + { BLOBLISTT_VBOOT_CTX, "Chrome OS vboot context" }, + + /* BLOBLISTT_PROJECT_AREA */ + { BLOBLISTT_U_BOOT_SPL_HANDOFF, "SPL hand-off" }, + + /* BLOBLISTT_VENDOR_AREA */ }; const char *bloblist_tag_name(enum bloblist_tag_t tag) { - if (tag < 0 || tag >= BLOBLISTT_COUNT) - return "invalid"; + int i; - return tag_name[tag]; + for (i = 0; i < ARRAY_SIZE(tag_name); i++) { + if (tag_name[i].tag == tag) + return tag_name[i].name; + } + + return "invalid"; } static struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr) @@ -120,9 +136,8 @@ static int bloblist_addrec(uint tag, int size, int align, new_alloced = data_start + ALIGN(size, align); if (new_alloced > hdr->size) { - log(LOGC_BLOBLIST, LOGL_ERR, - "Failed to allocate %x bytes size=%x, need size=%x\n", - size, hdr->size, new_alloced); + log_err("Failed to allocate %x bytes size=%x, need size=%x\n", + size, hdr->size, new_alloced); return log_msg_ret("bloblist add", -ENOSPC); } rec = (void *)hdr + hdr->alloced; @@ -236,14 +251,13 @@ static int bloblist_resize_rec(struct bloblist_hdr *hdr, expand_by = ALIGN(new_size - rec->size, BLOBLIST_ALIGN); new_alloced = ALIGN(hdr->alloced + expand_by, BLOBLIST_ALIGN); if (new_size < 0) { - log(LOGC_BLOBLIST, LOGL_DEBUG, - "Attempt to shrink blob size below 0 (%x)\n", new_size); + log_debug("Attempt to shrink blob size below 0 (%x)\n", + new_size); return log_msg_ret("size", -EINVAL); } if (new_alloced > hdr->size) { - log(LOGC_BLOBLIST, LOGL_ERR, - "Failed to allocate %x bytes size=%x, need size=%x\n", - new_size, hdr->size, new_alloced); + log_err("Failed to allocate %x bytes size=%x, need size=%x\n", + new_size, hdr->size, new_alloced); return log_msg_ret("alloc", -ENOSPC); } @@ -334,8 +348,7 @@ int bloblist_check(ulong addr, uint size) return log_msg_ret("Bad size", -EFBIG); chksum = bloblist_calc_chksum(hdr); if (hdr->chksum != chksum) { - log(LOGC_BLOBLIST, LOGL_ERR, "Checksum %x != %x\n", hdr->chksum, - chksum); + log_err("Checksum %x != %x\n", hdr->chksum, chksum); return log_msg_ret("Bad checksum", -EIO); } gd->bloblist = hdr; @@ -348,10 +361,24 @@ int bloblist_finish(void) struct bloblist_hdr *hdr = gd->bloblist; hdr->chksum = bloblist_calc_chksum(hdr); + log_debug("Finished bloblist size %lx at %lx\n", (ulong)hdr->size, + (ulong)map_to_sysmem(hdr)); return 0; } +ulong bloblist_get_base(void) +{ + return map_to_sysmem(gd->bloblist); +} + +ulong bloblist_get_size(void) +{ + struct bloblist_hdr *hdr = gd->bloblist; + + return hdr->size; +} + void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp) { struct bloblist_hdr *hdr = gd->bloblist; @@ -383,10 +410,10 @@ void bloblist_show_list(void) struct bloblist_hdr *hdr = gd->bloblist; struct bloblist_rec *rec; - printf("%-8s %8s Tag Name\n", "Address", "Size"); + printf("%-8s %8s Tag Name\n", "Address", "Size"); for (rec = bloblist_first_blob(hdr); rec; rec = bloblist_next_blob(hdr, rec)) { - printf("%08lx %8x %3d %s\n", + printf("%08lx %8x %4x %s\n", (ulong)map_to_sysmem((void *)rec + rec->hdr_size), rec->size, rec->tag, bloblist_tag_name(rec->tag)); } @@ -403,8 +430,9 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size) int bloblist_init(void) { - bool expected; int ret = -ENOENT; + ulong addr, size; + bool expected; /** * Wed expect to find an existing bloblist in the first phase of U-Boot @@ -413,27 +441,32 @@ int bloblist_init(void) expected = !u_boot_first_phase(); if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST)) expected = false; - if (expected) - ret = bloblist_check(CONFIG_BLOBLIST_ADDR, - CONFIG_BLOBLIST_SIZE); + addr = bloblist_addr(); + size = CONFIG_BLOBLIST_SIZE; + if (expected) { + ret = bloblist_check(addr, size); + if (ret) { + log_warning("Expected bloblist at %lx not found (err=%d)\n", + addr, ret); + } else { + /* Get the real size, if it is not what we expected */ + size = gd->bloblist->size; + } + } if (ret) { - ulong addr; - - log(LOGC_BLOBLIST, expected ? LOGL_WARNING : LOGL_DEBUG, - "Existing bloblist not found: creating new bloblist\n"); - if (IS_ENABLED(CONFIG_BLOBLIST_ALLOC)) { - void *ptr = memalign(BLOBLIST_ALIGN, - CONFIG_BLOBLIST_SIZE); + if (CONFIG_IS_ENABLED(BLOBLIST_ALLOC)) { + void *ptr = memalign(BLOBLIST_ALIGN, size); if (!ptr) return log_msg_ret("alloc", -ENOMEM); addr = map_to_sysmem(ptr); - } else { - addr = CONFIG_BLOBLIST_ADDR; } - ret = bloblist_new(addr, CONFIG_BLOBLIST_SIZE, 0); + log_debug("Creating new bloblist size %lx at %lx\n", size, + addr); + ret = bloblist_new(addr, size, 0); } else { - log(LOGC_BLOBLIST, LOGL_DEBUG, "Found existing bloblist\n"); + log_debug("Found existing bloblist size %lx at %lx\n", size, + addr); } return ret; diff --git a/common/board_f.c b/common/board_f.c index dd69c3b..a687600 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -283,7 +283,7 @@ static int setup_mon_len(void) static int setup_spl_handoff(void) { #if CONFIG_IS_ENABLED(HANDOFF) - gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF, + gd->spl_handoff = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(struct spl_handoff)); debug("Found SPL hand-off info %p\n", gd->spl_handoff); #endif diff --git a/common/spl/spl.c b/common/spl/spl.c index 4c101ec..f51d1f3 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -408,7 +408,7 @@ static int setup_spl_handoff(void) { struct spl_handoff *ho; - ho = bloblist_ensure(BLOBLISTT_SPL_HANDOFF, sizeof(struct spl_handoff)); + ho = bloblist_ensure(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(struct spl_handoff)); if (!ho) return -ENOENT; @@ -425,7 +425,7 @@ static int write_spl_handoff(void) struct spl_handoff *ho; int ret; - ho = bloblist_find(BLOBLISTT_SPL_HANDOFF, sizeof(struct spl_handoff)); + ho = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(struct spl_handoff)); if (!ho) return -ENOENT; handoff_save_dram(ho); diff --git a/doc/develop/bloblist.rst b/doc/develop/bloblist.rst index 47274cf..572aa65 100644 --- a/doc/develop/bloblist.rst +++ b/doc/develop/bloblist.rst @@ -31,7 +31,7 @@ Blobs While each blob in the bloblist can be of any length, bloblists are designed to hold small amounts of data, typically a few KB at most. It is not possible to change the length of a blob once it has been written. Each blob is normally -created from a C structure which can beused to access its fields. +created from a C structure which can be used to access its fields. Blob tags @@ -93,6 +93,12 @@ This should move to using bloblist, to avoid having its own mechanism for passing information between U-Boot parts. +API documentation +----------------- + +.. kernel-doc:: include/bloblist.h + + Simon Glass sjg@chromium.org 12-Aug-2018 diff --git a/drivers/core/device.c b/drivers/core/device.c index 4873c47..d917d4e 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -518,6 +518,14 @@ int device_probe(struct udevice *dev) dev_or_flags(dev, DM_FLAG_ACTIVATED); + if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent && + (device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) && + !(drv->flags & DM_FLAG_DEFAULT_PD_CTRL_OFF)) { + ret = dev_power_domain_on(dev); + if (ret) + goto fail; + } + /* * Process pinctrl for everything except the root device, and * continue regardless of the result of pinctrl. Don't process pinctrl @@ -540,14 +548,6 @@ int device_probe(struct udevice *dev) dev->name, ret, errno_str(ret)); } - if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent && - (device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) && - !(drv->flags & DM_FLAG_DEFAULT_PD_CTRL_OFF)) { - ret = dev_power_domain_on(dev); - if (ret) - goto fail; - } - if (CONFIG_IS_ENABLED(IOMMU) && dev->parent && (device_get_uclass_id(dev) != UCLASS_IOMMU)) { ret = dev_iommu_enable(dev); diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 30d4421..96a1cb6 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -104,7 +104,8 @@ static void serial_find_console_or_panic(void) } } } - if (!SPL_BUILD || !CONFIG_IS_ENABLED(OF_CONTROL) || !blob) { + if (!IS_ENABLED(CONFIG_SPL_BUILD) || !CONFIG_IS_ENABLED(OF_CONTROL) || + !blob) { /* * Try to use CONFIG_CONS_INDEX if available (it is numbered * from 1!). diff --git a/include/bloblist.h b/include/bloblist.h index 9f007c7..173129b 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause */ /* * This provides a standard way of passing information between boot phases * (TPL -> SPL -> U-Boot proper.) @@ -13,6 +13,8 @@ #ifndef __BLOBLIST_H #define __BLOBLIST_H +#include <mapmem.h> + enum { BLOBLIST_VERSION = 0, BLOBLIST_MAGIC = 0xb00757a3, @@ -23,23 +25,57 @@ enum { enum bloblist_tag_t { BLOBLISTT_NONE = 0, - /* Vendor-specific tags are permitted here */ - BLOBLISTT_EC_HOSTEVENT, /* Chromium OS EC host-event mask */ - BLOBLISTT_SPL_HANDOFF, /* Hand-off info from SPL */ - BLOBLISTT_VBOOT_CTX, /* Chromium OS verified boot context */ - BLOBLISTT_VBOOT_HANDOFF, /* Chromium OS internal handoff info */ + /* + * Standard area to allocate blobs used across firmware components, for + * things that are very commonly used, particularly in multiple + * projects. + */ + BLOBLISTT_AREA_FIRMWARE_TOP = 0x1, + + /* Standard area to allocate blobs used across firmware components */ + BLOBLISTT_AREA_FIRMWARE = 0x100, /* * Advanced Configuration and Power Interface Global Non-Volatile * Sleeping table. This forms part of the ACPI tables passed to Linux. */ - BLOBLISTT_ACPI_GNVS, - BLOBLISTT_INTEL_VBT, /* Intel Video-BIOS table */ - BLOBLISTT_TPM2_TCG_LOG, /* TPM v2 log space */ - BLOBLISTT_TCPA_LOG, /* TPM log space */ - BLOBLISTT_ACPI_TABLES, /* ACPI tables for x86 */ - BLOBLISTT_SMBIOS_TABLES, /* SMBIOS tables for x86 */ - - BLOBLISTT_COUNT + BLOBLISTT_ACPI_GNVS = 0x100, + BLOBLISTT_INTEL_VBT = 0x101, /* Intel Video-BIOS table */ + BLOBLISTT_TPM2_TCG_LOG = 0x102, /* TPM v2 log space */ + BLOBLISTT_TCPA_LOG = 0x103, /* TPM log space */ + BLOBLISTT_ACPI_TABLES = 0x104, /* ACPI tables for x86 */ + BLOBLISTT_SMBIOS_TABLES = 0x105, /* SMBIOS tables for x86 */ + BLOBLISTT_VBOOT_CTX = 0x106, /* Chromium OS verified boot context */ + + /* + * Project-specific tags are permitted here. Projects can be open source + * or not, but the format of the data must be fuily documented in an + * open source project, including all fields, bits, etc. Naming should + * be: BLOBLISTT_<project>_<purpose_here> + */ + BLOBLISTT_PROJECT_AREA = 0x8000, + BLOBLISTT_U_BOOT_SPL_HANDOFF = 0x8000, /* Hand-off info from SPL */ + + /* + * Vendor-specific tags are permitted here. Projects can be open source + * or not, but the format of the data must be fuily documented in an + * open source project, including all fields, bits, etc. Naming should + * be BLOBLISTT_<vendor>_<purpose_here> + */ + BLOBLISTT_VENDOR_AREA = 0xc000, + + /* Tags after this are not allocated for now */ + BLOBLISTT_EXPANSION = 0x10000, + + /* + * Tags from here are on reserved for private use within a single + * firmware binary (i.e. a single executable or phase of a project). + * These tags can be passed between binaries within a local + * implementation, but cannot be used in upstream code. Allocate a + * tag in one of the areas above if you want that. + * + * This area may move in future. + */ + BLOBLISTT_PRIVATE_AREA = 0xffff0000, }; /** @@ -50,8 +86,8 @@ enum bloblist_tag_t { * same place in memory as SPL and U-Boot execute, but it can be safely moved * around. * - * None of the bloblist structures contain pointers but it is possible to put - * pointers inside a bloblist record if desired. This is not encouraged, + * None of the bloblist headers themselves contain pointers but it is possible + * to put pointers inside a bloblist record if desired. This is not encouraged, * since it can make part of the bloblist inaccessible if the pointer is * no-longer valid. It is better to just store all the data inside a bloblist * record. @@ -59,11 +95,11 @@ enum bloblist_tag_t { * Each bloblist record is aligned to a 16-byte boundary and follows immediately * from the last. * + * @magic: BLOBLIST_MAGIC * @version: BLOBLIST_VERSION * @hdr_size: Size of this header, normally sizeof(struct bloblist_hdr). The * first bloblist_rec starts at this offset from the start of the header - * @flags: Space for BLOBLISTF_... flags (none yet) - * @magic: BLOBLIST_MAGIC + * @flags: Space for BLOBLISTF... flags (none yet) * @size: Total size of the bloblist (non-zero if valid) including this header. * The bloblist extends for this many bytes from the start of this header. * When adding new records, the bloblist can grow up to this size. @@ -74,14 +110,14 @@ enum bloblist_tag_t { * @chksum: CRC32 for the entire bloblist allocated area. Since any of the * blobs can be altered after being created, this checksum is only valid * when the bloblist is finalised before jumping to the next stage of boot. - * Note: @chksum is last to make it easier to exclude it from the checksum - * calculation. + * Note that chksum is last to make it easier to exclude it from the + * checksum calculation. */ struct bloblist_hdr { + u32 magic; u32 version; u32 hdr_size; u32 flags; - u32 magic; u32 size; u32 alloced; @@ -92,11 +128,11 @@ struct bloblist_hdr { /** * struct bloblist_rec - record for the bloblist * - * NOTE: Only exported for testing purposes. Do not use this struct. - * * The bloblist contains a number of records each consisting of this record * structure followed by the data contained. Each records is 16-byte aligned. * + * NOTE: Only exported for testing purposes. Do not use this struct. + * * @tag: Tag indicating what the record contains * @hdr_size: Size of this header, normally sizeof(struct bloblist_rec). The * record's data starts at this offset from the start of the record @@ -111,6 +147,35 @@ struct bloblist_rec { u32 spare; }; +/* access CONFIG_BLOBLIST_ADDR, dealing with it possibly not being defined */ +static inline ulong bloblist_addr(void) +{ +#ifdef CONFIG_BLOBLIST_FIXED + return CONFIG_BLOBLIST_ADDR; +#else + return 0; +#endif +} + +/** + * bloblist_check_magic() - return a bloblist if the magic matches + * + * @addr: Address to check + * Return: pointer to bloblist, if the magic matches, else NULL + */ +static inline void *bloblist_check_magic(ulong addr) +{ + u32 *ptr; + + if (!addr) + return NULL; + ptr = map_sysmem(addr, 0); + if (*ptr != BLOBLIST_MAGIC) + return NULL; + + return ptr; +} + /** * bloblist_find() - Find a blob * @@ -118,8 +183,8 @@ struct bloblist_rec { * * @tag: Tag to search for (enum bloblist_tag_t) * @size: Expected size of the blob, or 0 for any size - * @return pointer to blob if found, or NULL if not found, or a blob was found - * but it is the wrong size + * Return: pointer to blob if found, or NULL if not found, or a blob was found + * but it is the wrong size */ void *bloblist_find(uint tag, int size); @@ -135,8 +200,8 @@ void *bloblist_find(uint tag, int size); * @tag: Tag to add (enum bloblist_tag_t) * @size: Size of the blob * @align: Alignment of the blob (in bytes), 0 for default - * @return pointer to the newly added block, or NULL if there is not enough - * space for the blob + * Return: pointer to the newly added block, or NULL if there is not enough + * space for the blob */ void *bloblist_add(uint tag, int size, int align); @@ -149,8 +214,8 @@ void *bloblist_add(uint tag, int size, int align); * @size: Size of the blob * @blobp: Returns a pointer to blob on success * @align: Alignment of the blob (in bytes), 0 for default - * @return 0 if OK, -ENOSPC if it is missing and could not be added due to lack - * of space, or -ESPIPE it exists but has the wrong size + * Return: 0 if OK, -ENOSPC if it is missing and could not be added due to lack + * of space, or -ESPIPE it exists but has the wrong size */ int bloblist_ensure_size(uint tag, int size, int align, void **blobp); @@ -161,8 +226,8 @@ int bloblist_ensure_size(uint tag, int size, int align, void **blobp); * * @tag: Tag to add (enum bloblist_tag_t) * @size: Size of the blob - * @return pointer to blob, or NULL if it is missing and could not be added due - * to lack of space, or it exists but has the wrong size + * Return: pointer to blob, or NULL if it is missing and could not be added due + * to lack of space, or it exists but has the wrong size */ void *bloblist_ensure(uint tag, int size); @@ -174,8 +239,8 @@ void *bloblist_ensure(uint tag, int size); * @tag: Tag to add (enum bloblist_tag_t) * @sizep: Size of the blob to create; returns size of actual blob * @blobp: Returns a pointer to blob on success - * @return 0 if OK, -ENOSPC if it is missing and could not be added due to lack - * of space + * Return: 0 if OK, -ENOSPC if it is missing and could not be added due to lack + * of space */ int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp); @@ -187,8 +252,8 @@ int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp); * * @tag: Tag to add (enum bloblist_tag_t) * @new_size: New size of the blob (>0 to expand, <0 to contract) - * @return 0 if OK, -ENOSPC if the bloblist does not have enough space, -ENOENT - * if the tag is not found + * Return: 0 if OK, -ENOSPC if the bloblist does not have enough space, -ENOENT + * if the tag is not found */ int bloblist_resize(uint tag, int new_size); @@ -198,8 +263,8 @@ int bloblist_resize(uint tag, int new_size); * @addr: Address of bloblist * @size: Initial size for bloblist * @flags: Flags to use for bloblist - * @return 0 if OK, -EFAULT if addr is not aligned correctly, -ENOSPC is the - * area is not large enough + * Return: 0 if OK, -EFAULT if addr is not aligned correctly, -ENOSPC is the + * area is not large enough */ int bloblist_new(ulong addr, uint size, uint flags); @@ -208,11 +273,11 @@ int bloblist_new(ulong addr, uint size, uint flags); * * @addr: Address of bloblist * @size: Expected size of blobsize, or 0 to detect the size - * @return 0 if OK, -ENOENT if the magic number doesn't match (indicating that - * there problem is no bloblist at the given address), -EPROTONOSUPPORT - * if the version does not match, -EIO if the checksum does not match, - * -EFBIG if the expected size does not match the detected size, -ENOSPC - * if the size is not large enough to hold the headers + * Return: 0 if OK, -ENOENT if the magic number doesn't match (indicating that + * there problem is no bloblist at the given address), -EPROTONOSUPPORT + * if the version does not match, -EIO if the checksum does not match, + * -EFBIG if the expected size does not match the detected size, -ENOSPC + * if the size is not large enough to hold the headers */ int bloblist_check(ulong addr, uint size); @@ -222,7 +287,7 @@ int bloblist_check(ulong addr, uint size); * This sets the correct checksum for the bloblist. This ensures that the * bloblist will be detected correctly by the next phase of U-Boot. * - * @return 0 + * Return: 0 */ int bloblist_finish(void); @@ -238,6 +303,20 @@ int bloblist_finish(void); void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp); /** + * bloblist_get_base() - Get the base address of the bloblist + * + * Return: base address of bloblist + */ +ulong bloblist_get_base(void); + +/** + * bloblist_get_size() - Get the size of the bloblist + * + * Return: the size in bytes + */ +ulong bloblist_get_size(void); + +/** * bloblist_show_stats() - Show information about the bloblist * * This shows useful information about the bloblist on the console @@ -255,7 +334,7 @@ void bloblist_show_list(void); * bloblist_tag_name() - Get the name for a tag * * @tag: Tag to check - * @return name of tag, or "invalid" if an invalid tag is provided + * Return: name of tag, or "invalid" if an invalid tag is provided */ const char *bloblist_tag_name(enum bloblist_tag_t tag); @@ -263,7 +342,7 @@ const char *bloblist_tag_name(enum bloblist_tag_t tag); * bloblist_reloc() - Relocate the bloblist and optionally resize it * * @to: Pointer to new bloblist location (must not overlap old location) - * @to:size: New size for bloblist (must be larger than from_size) + * @to_size: New size for bloblist (must be larger than from_size) * @from: Pointer to bloblist to relocate * @from_size: Size of bloblist to relocate */ @@ -272,8 +351,19 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size); /** * bloblist_init() - Init the bloblist system with a single bloblist * - * This uses CONFIG_BLOBLIST_ADDR and CONFIG_BLOBLIST_SIZE to set up a bloblist - * for use by U-Boot. + * This locates and sets up the blocklist for use. + * + * If CONFIG_BLOBLIST_FIXED is selected, it uses CONFIG_BLOBLIST_ADDR and + * CONFIG_BLOBLIST_SIZE to set up a bloblist for use by U-Boot. + * + * If CONFIG_BLOBLIST_ALLOC is selected, it allocates memory for a bloblist of + * size CONFIG_BLOBLIST_SIZE. + * + * If CONFIG_BLOBLIST_PASSAGE is selected, it uses the bloblist in the incoming + * standard passage. The size is detected automatically so CONFIG_BLOBLIST_SIZE + * can be 0. + * + * Return: 0 if OK, -ve on error */ int bloblist_init(void); diff --git a/include/fdtdec.h b/include/fdtdec.h index 09525ce..15f2d2b 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -49,12 +49,6 @@ struct fdt_memory { struct bd_info; -#ifdef CONFIG_SPL_BUILD -#define SPL_BUILD 1 -#else -#define SPL_BUILD 0 -#endif - /** * enum fdt_source_t - indicates where the devicetree came from * diff --git a/include/linux/stddef.h b/include/linux/stddef.h index c540f61..a7f546f 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -1,6 +1,8 @@ #ifndef _LINUX_STDDEF_H #define _LINUX_STDDEF_H +#include <linux/compiler_types.h> + #undef NULL #if defined(__cplusplus) #define NULL 0 @@ -14,7 +16,11 @@ #ifndef __CHECKER__ #undef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#ifdef __compiler_offsetof +#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER) +#else +#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER) +#endif #endif #endif diff --git a/include/os.h b/include/os.h index 4cbcbd9..10e198c 100644 --- a/include/os.h +++ b/include/os.h @@ -266,7 +266,7 @@ const char *os_dirent_get_typename(enum os_dirent_t type); * @size: size of file is returned if no error * Return: 0 on success or -1 if an error ocurred */ -int os_get_filesize(const char *fname, loff_t *size); +int os_get_filesize(const char *fname, long long *size); /** * os_putc() - write a character to the controlling OS terminal diff --git a/test/bloblist.c b/test/bloblist.c index b48be38..720be7e 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -19,9 +19,9 @@ DECLARE_GLOBAL_DATA_PTR; UNIT_TEST(_name, _flags, bloblist_test) enum { - TEST_TAG = 1, - TEST_TAG2 = 2, - TEST_TAG_MISSING = 3, + TEST_TAG = BLOBLISTT_U_BOOT_SPL_HANDOFF, + TEST_TAG2 = BLOBLISTT_VBOOT_CTX, + TEST_TAG_MISSING = 0x10000, TEST_SIZE = 10, TEST_SIZE2 = 20, @@ -71,7 +71,9 @@ static int bloblist_test_init(struct unit_test_state *uts) hdr = clear_bloblist(); ut_asserteq(-ENOENT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + ut_asserteq_ptr(NULL, bloblist_check_magic(TEST_ADDR)); ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_asserteq_ptr(hdr, bloblist_check_magic(TEST_ADDR)); hdr->version++; ut_asserteq(-EPROTONOSUPPORT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); @@ -83,6 +85,11 @@ static int bloblist_test_init(struct unit_test_state *uts) ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); ut_assertok(bloblist_finish()); ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + + hdr->magic++; + ut_asserteq_ptr(NULL, bloblist_check_magic(TEST_ADDR)); + hdr->magic--; + hdr->flags++; ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); @@ -100,6 +107,8 @@ static int bloblist_test_blob(struct unit_test_state *uts) hdr = clear_bloblist(); ut_assertnull(bloblist_find(TEST_TAG, TEST_BLOBLIST_SIZE)); ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_asserteq(TEST_BLOBLIST_SIZE, bloblist_get_size()); + ut_asserteq(TEST_ADDR, bloblist_get_base()); ut_asserteq(map_to_sysmem(hdr), TEST_ADDR); /* Add a record and check that we can find it */ @@ -281,10 +290,10 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts) ut_silence_console(uts); console_record_reset(); run_command("bloblist list", 0); - ut_assert_nextline("Address Size Tag Name"); - ut_assert_nextline("%08lx %8x 1 EC host event", + ut_assert_nextline("Address Size Tag Name"); + ut_assert_nextline("%08lx %8x 8000 SPL hand-off", (ulong)map_to_sysmem(data), TEST_SIZE); - ut_assert_nextline("%08lx %8x 2 SPL hand-off", + ut_assert_nextline("%08lx %8x 106 Chrome OS vboot context", (ulong)map_to_sysmem(data2), TEST_SIZE2); ut_assert_console_end(); ut_unsilence_console(uts); diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py index 4ee7aa1..07bf681 100755 --- a/tools/genboardscfg.py +++ b/tools/genboardscfg.py @@ -430,7 +430,7 @@ def main(): # Add options here parser.add_option('-f', '--force', action="store_true", default=False, help='regenerate the output even if it is new') - parser.add_option('-j', '--jobs', type='int', default=cpu_count, + parser.add_option('-j', '--jobs', type='int', default=min(cpu_count, 240), help='the number of jobs to run simultaneously') parser.add_option('-o', '--output', default=OUTPUT_FILE, help='output file [default=%s]' % OUTPUT_FILE) diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 5e4c112..e1ef96d 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -616,9 +616,14 @@ def GetAliasFile(): """ fname = command.OutputOneLine('git', 'config', 'sendemail.aliasesfile', raise_on_error=False) - if fname: - fname = os.path.join(GetTopLevel(), fname.strip()) - return fname + if not fname: + return None + + fname = os.path.expanduser(fname.strip()) + if os.path.isabs(fname): + return fname + + return os.path.join(GetTopLevel(), fname) def GetDefaultUserName(): """Gets the user.name from .gitconfig file. |