From patchwork Fri Nov 16 01:43:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998686 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1L86PBzz9s47 for ; Fri, 16 Nov 2018 12:46:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 81650C21F97; Fri, 16 Nov 2018 01:44:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 701E5C22252; Fri, 16 Nov 2018 01:44:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9A55FC2219A; Fri, 16 Nov 2018 01:44:27 +0000 (UTC) Received: from mail-io1-f74.google.com (mail-io1-f74.google.com [209.85.166.74]) by lists.denx.de (Postfix) with ESMTPS id 96014C221C6 for ; Fri, 16 Nov 2018 01:44:23 +0000 (UTC) Received: by mail-io1-f74.google.com with SMTP id o8-v6so21188932iom.6 for ; Thu, 15 Nov 2018 17:44:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=aPW40fCiQQtxz4N5oNIqrTkg9oyziC98+tqCCkzRJ80=; b=dgXSTxInMbcFNCYtWXoiCVyon3FlBtSUJzCjBn2WCkLUlX3xEfMr+FZBIdbOhjWTuS VwTtdcrlbJd+wSnZxe+rB871u16jZq2laNiYQxH6RC74CtiBWY6Ky9VqTBuPkxcrM/iC 02GCnFnDpLUoRZ6hQjAWMq9ClWA5aQcqr/6/rHMFC9oFzQd/3wS2QJcJfJrmcId4tv8p 4ac1nqDNV8fGHB16xxYpm1kkgExSAlVb9wONHnaWxjgtHHy9SlrRpr1UrOTVFPJMhMU9 4K2UisH0eAP77cselpnF3duW2qaUyxw0cRgXeF433sH+tgq7v2YikYLxPhTQQTLSVGNp Jgqg== X-Gm-Message-State: AGRZ1gI2b2FTsQdzYQCI7fwGv1VCB4l5MeHR7D/FKgIj5keFqnCSmAuW Zn9dfIx9fElex+BVN6GEQYj5cH8= X-Google-Smtp-Source: AJdET5ez/vCky4G4+3L0s1AP2f3WZO68CdnbkwbO6tDAzDfQO32/ocne86rwoNBIKM5zxE2pSvujCKU= X-Received: by 2002:a24:5650:: with SMTP id o77-v6mr2063381itb.23.1542332662386; Thu, 15 Nov 2018 17:44:22 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:49 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-2-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH v3 01/21] spl: Add support for logging in SPL and TPL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" It is sometimes useful to log information in SPL and TPL. Add support for this. Reviewed-by: Tom Rini Signed-off-by: Simon Glass --- Changes in v3: - Add comments to the log_ret() functions to indicate usage - Update log_msg_ret() to make use of the message and avoid a warning Changes in v2: None common/Kconfig | 36 ++++++++++++++++++++++++++++++++++-- common/Makefile | 4 ++-- common/spl/spl.c | 7 +++++++ include/log.h | 19 +++++++++++++++++-- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/common/Kconfig b/common/Kconfig index d7300c212f5..9bc329a0e61 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -290,6 +290,10 @@ config SPL_LOGLEVEL int default LOGLEVEL +config TPL_LOGLEVEL + int + default LOGLEVEL + config SILENT_CONSOLE bool "Support a silent console" help @@ -486,6 +490,24 @@ config SPL_LOG_MAX_LEVEL 6 - detail 7 - debug +config TPL_LOG_MAX_LEVEL + int "Maximum log level to record in TPL" + depends on TPL_LOG + default 3 + help + This selects the maximum log level that will be recorded. Any value + higher than this will be ignored. If possible log statements below + this level will be discarded at build time. Levels: + + 0 - panic + 1 - critical + 2 - error + 3 - warning + 4 - note + 5 - info + 6 - detail + 7 - debug + config LOG_CONSOLE bool "Allow log output to the console" depends on LOG @@ -496,9 +518,19 @@ config LOG_CONSOLE log message is shown - other details like level, category, file and line number are omitted. -config LOG_SPL_CONSOLE +config SPL_LOG_CONSOLE + bool "Allow log output to the console in SPL" + depends on SPL_LOG + default y + help + Enables a log driver which writes log records to the console. + Generally the console is the serial port or LCD display. Only the + log message is shown - other details like level, category, file and + line number are omitted. + +config TPL_LOG_CONSOLE bool "Allow log output to the console in SPL" - depends on LOG_SPL + depends on TPL_LOG default y help Enables a log driver which writes log records to the console. diff --git a/common/Makefile b/common/Makefile index a2388364d9f..d18897b973b 100644 --- a/common/Makefile +++ b/common/Makefile @@ -118,8 +118,8 @@ obj-y += cli.o obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o obj-$(CONFIG_DFU_OVER_USB) += dfu.o obj-y += command.o -obj-$(CONFIG_$(SPL_)LOG) += log.o -obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o +obj-$(CONFIG_$(SPL_TPL_)LOG) += log.o +obj-$(CONFIG_$(SPL_TPL_)LOG_CONSOLE) += log_console.o obj-y += s_record.o obj-$(CONFIG_CMD_LOADB) += xyzModem.o obj-$(CONFIG_$(SPL_TPL_)YMODEM_SUPPORT) += xyzModem.o diff --git a/common/spl/spl.c b/common/spl/spl.c index 12f9359c0ac..740182a8be6 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -336,6 +336,13 @@ static int spl_common_init(bool setup_malloc) return ret; } bootstage_mark_name(BOOTSTAGE_ID_START_SPL, "spl"); +#if CONFIG_IS_ENABLED(LOG) + ret = log_init(); + if (ret) { + debug("%s: Failed to set up logging\n", __func__); + return ret; + } +#endif if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { ret = fdtdec_setup(); if (ret) { diff --git a/include/log.h b/include/log.h index a872fc6ef5f..ad6870bfed8 100644 --- a/include/log.h +++ b/include/log.h @@ -107,6 +107,8 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, #define log_io(_fmt...) #endif +#if CONFIG_IS_ENABLED(LOG) + /* Emit a log record if the level is less that the maximum */ #define log(_cat, _level, _fmt, _args...) ({ \ int _l = _level; \ @@ -115,6 +117,9 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, __func__, \ pr_fmt(_fmt), ##_args); \ }) +#else +#define log(_cat, _level, _fmt, _args...) +#endif #ifdef DEBUG #define _DEBUG 1 @@ -174,7 +179,16 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line, ({ if (!(x) && _DEBUG) \ __assert_fail(#x, __FILE__, __LINE__, __func__); }) -#ifdef CONFIG_LOG_ERROR_RETURN +#if CONFIG_IS_ENABLED(LOG) && defined(CONFIG_LOG_ERROR_RETURN) +/* + * Log an error return value, possibly with a message. Usage: + * + * return log_ret(fred_call()); + * + * or: + * + * return log_msg_ret("fred failed", fred_call()); + */ #define log_ret(_ret) ({ \ int __ret = (_ret); \ if (__ret < 0) \ @@ -189,8 +203,9 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line, __ret; \ }) #else +/* Non-logging versions of the above which just return the error code */ #define log_ret(_ret) (_ret) -#define log_msg_ret(_msg, _ret) (_ret) +#define log_msg_ret(_msg, _ret) ((void)(_msg), _ret) #endif /** From patchwork Fri Nov 16 01:43:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998692 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1SW4GFFz9s47 for ; Fri, 16 Nov 2018 12:52:11 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 57EDAC2224B; Fri, 16 Nov 2018 01:45:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A3815C22261; Fri, 16 Nov 2018 01:44:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CDB2FC2221B; Fri, 16 Nov 2018 01:44:29 +0000 (UTC) Received: from mail-io1-f74.google.com (mail-io1-f74.google.com [209.85.166.74]) by lists.denx.de (Postfix) with ESMTPS id 22EF9C22245 for ; Fri, 16 Nov 2018 01:44:25 +0000 (UTC) Received: by mail-io1-f74.google.com with SMTP id h7so6791968iof.19 for ; Thu, 15 Nov 2018 17:44:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qmWt8fKIHXkZHq4g3d4KvFeDzyDaa6tVwX/7rbTtsCY=; b=tKjQnz7DQeQMeXMW5aNfw+T/Jtioh+xrdG+rNv+c1e5KAXdH1KqIoVQWvjhO+y1+eu IqK6UZl2vcGfmxSc7PPupfBJiYipZGLtdYQ9GxlQ/hyg+5kwTTJlTx/vsBdA12Bz8/H8 HIS7nReCT5A0oZ/dwXbl61aQ2jezh7PaXjFP6ST+sD9IghDaWmpjEPrBKf5sHg3BKmql sNxsasqCIHCUCgsoE8wXjZdV+1Bt0p+d14fbMGAIG1ahj3nc+uqA7pPjmBKtbQf9+g0B CTCvFl1K7AzqfwwrqtaKdN57OMKn2unqIxonwkNOqVXZWwkFIh+blOz5/wbh2+oRXUsN jZyQ== X-Gm-Message-State: AGRZ1gK0xCfAksAXurekM4LA61mcilXTvSWM1vbsZFzhm13F5LR1HUG8 DEVUHASU/D42sXXDAqReMK9dEY4= X-Google-Smtp-Source: AJdET5d0XF+kqClO7nOy5zayxOuSzvIfp/nRksVOmDZALQ4i4hVo4OS89yBcSXbhClNm8p5uDWFd5Ss= X-Received: by 2002:a24:2a83:: with SMTP id w125mr2100893itw.4.1542332664196; Thu, 15 Nov 2018 17:44:24 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:50 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-3-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH v3 02/21] Add core support for a bloblist to convey data from SPL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present there is no standard way in U-Boot to pass information from SPL to U-Boot proper. But sometimes SPL wants to convey information to U-Boot that U-Boot cannot easily figure out. For example, if SPL sets up SDRAM then it might want to pass the size of SDRAM, or the location of each bank, to U-Boot proper. Add a new 'bloblist' feature which provides this. A bloblist is set up in the first phase of U-Boot that runs (i.e. TPL or SPL). The location of this info may be in SRAM or CAR (x86 cache-as-RAM) or somewhere else. Information placed in this region is preserved (with a checksum) through TPL and SPL and ends up in U-Boot. At this point it is copied into SDRAM so it can be used after relocation. Reviewed-by: Tom Rini Signed-off-by: Simon Glass Acked-by: Andreas Dannenberg --- Changes in v3: - Correct CONFIG_BLOBLIST_ADDR to have a default only for sandbox Changes in v2: - Fix several typos common/Kconfig | 48 +++++++++ common/Makefile | 1 + common/bloblist.c | 239 +++++++++++++++++++++++++++++++++++++++++++++ include/bloblist.h | 195 ++++++++++++++++++++++++++++++++++++ include/log.h | 1 + 5 files changed, 484 insertions(+) create mode 100644 common/bloblist.c create mode 100644 include/bloblist.h diff --git a/common/Kconfig b/common/Kconfig index 9bc329a0e61..a44bfdef9f2 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -715,4 +715,52 @@ config UPDATE_TFTP_MSEC_MAX endmenu +menu "Blob list" + +config BLOBLIST + bool "Support for a bloblist" + help + This enables support for a bloblist in U-Boot, which can be passed + 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. + +config SPL_BLOBLIST + bool "Support for a bloblist in SPL" + depends on BLOBLIST + default y if SPL + help + This enables a bloblist in SPL. If this is the first part of U-Boot + to run, then the bloblist is set up in SPL and passed to U-Boot + proper. If TPL also has a bloblist, then SPL uses the one from there. + +config TPL_BLOBLIST + bool "Support for a bloblist in TPL" + depends on BLOBLIST + default y if TPL + help + This enables a bloblist in TPL. The bloblist is set up in TPL and + passed to SPL and U-Boot proper. + +config BLOBLIST_SIZE + hex "Size of bloblist" + depends on 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 stages. + +config BLOBLIST_ADDR + hex "Address of bloblist" + depends on BLOBLIST + default 0xe000 if SANDBOX + 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. + +endmenu + source "common/spl/Kconfig" diff --git a/common/Makefile b/common/Makefile index d18897b973b..3d97a0dceae 100644 --- a/common/Makefile +++ b/common/Makefile @@ -61,6 +61,7 @@ obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o endif # !CONFIG_SPL_BUILD obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o +obj-$(CONFIG_$(SPL_TPL_)BLOBLIST) += bloblist.o ifdef CONFIG_SPL_BUILD ifdef CONFIG_SPL_DFU_SUPPORT diff --git a/common/bloblist.c b/common/bloblist.c new file mode 100644 index 00000000000..b4cf169b05a --- /dev/null +++ b/common/bloblist.c @@ -0,0 +1,239 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 Google, Inc + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr) +{ + if (hdr->alloced <= hdr->hdr_size) + return NULL; + return (struct bloblist_rec *)((void *)hdr + hdr->hdr_size); +} + +struct bloblist_rec *bloblist_next_blob(struct bloblist_hdr *hdr, + struct bloblist_rec *rec) +{ + ulong offset; + + offset = (void *)rec - (void *)hdr; + offset += rec->hdr_size + ALIGN(rec->size, BLOBLIST_ALIGN); + if (offset >= hdr->alloced) + return NULL; + return (struct bloblist_rec *)((void *)hdr + offset); +} + +#define foreach_rec(_rec, _hdr) \ + for (_rec = bloblist_first_blob(_hdr); \ + _rec; \ + _rec = bloblist_next_blob(_hdr, _rec)) + +static struct bloblist_rec *bloblist_findrec(uint tag) +{ + struct bloblist_hdr *hdr = gd->bloblist; + struct bloblist_rec *rec; + + if (!hdr) + return NULL; + + foreach_rec(rec, hdr) { + if (rec->tag == tag) + return rec; + } + + return NULL; +} + +static int bloblist_addrec(uint tag, int size, struct bloblist_rec **recp) +{ + struct bloblist_hdr *hdr = gd->bloblist; + struct bloblist_rec *rec; + int new_alloced; + + new_alloced = hdr->alloced + sizeof(*rec) + + ALIGN(size, BLOBLIST_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); + return log_msg_ret("bloblist add", -ENOSPC); + } + rec = (void *)hdr + hdr->alloced; + hdr->alloced = new_alloced; + + rec->tag = tag; + rec->hdr_size = sizeof(*rec); + rec->size = size; + rec->spare = 0; + *recp = rec; + + return 0; +} + +static int bloblist_ensurerec(uint tag, struct bloblist_rec **recp, int size) +{ + struct bloblist_rec *rec; + + rec = bloblist_findrec(tag); + if (rec) { + if (size && size != rec->size) + return -ESPIPE; + } else { + int ret; + + ret = bloblist_addrec(tag, size, &rec); + if (ret) + return ret; + } + *recp = rec; + + return 0; +} + +void *bloblist_find(uint tag, int size) +{ + struct bloblist_rec *rec; + + rec = bloblist_findrec(tag); + if (!rec) + return NULL; + if (size && size != rec->size) + return NULL; + + return (void *)rec + rec->hdr_size; +} + +void *bloblist_add(uint tag, int size) +{ + struct bloblist_rec *rec; + + if (bloblist_addrec(tag, size, &rec)) + return NULL; + + return rec + 1; +} + +int bloblist_ensure_size(uint tag, int size, void **blobp) +{ + struct bloblist_rec *rec; + int ret; + + ret = bloblist_ensurerec(tag, &rec, size); + if (ret) + return ret; + *blobp = (void *)rec + rec->hdr_size; + + return 0; +} + +void *bloblist_ensure(uint tag, int size) +{ + struct bloblist_rec *rec; + + if (bloblist_ensurerec(tag, &rec, size)) + return NULL; + + return (void *)rec + rec->hdr_size; +} + +static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr) +{ + struct bloblist_rec *rec; + u32 chksum; + + chksum = crc32(0, (unsigned char *)hdr, + offsetof(struct bloblist_hdr, chksum)); + foreach_rec(rec, hdr) { + chksum = crc32(chksum, (void *)rec, rec->hdr_size); + chksum = crc32(chksum, (void *)rec + rec->hdr_size, rec->size); + } + + return chksum; +} + +int bloblist_new(ulong addr, uint size, uint flags) +{ + struct bloblist_hdr *hdr; + + if (size < sizeof(*hdr)) + return log_ret(-ENOSPC); + if (addr & (BLOBLIST_ALIGN - 1)) + return log_ret(-EFAULT); + hdr = map_sysmem(addr, size); + memset(hdr, '\0', sizeof(*hdr)); + hdr->version = BLOBLIST_VERSION; + hdr->hdr_size = sizeof(*hdr); + hdr->flags = flags; + hdr->magic = BLOBLIST_MAGIC; + hdr->size = size; + hdr->alloced = hdr->hdr_size; + hdr->chksum = 0; + gd->bloblist = hdr; + + return 0; +} + +int bloblist_check(ulong addr, uint size) +{ + struct bloblist_hdr *hdr; + u32 chksum; + + hdr = map_sysmem(addr, sizeof(*hdr)); + if (hdr->magic != BLOBLIST_MAGIC) + return log_msg_ret("Bad magic", -ENOENT); + if (hdr->version != BLOBLIST_VERSION) + return log_msg_ret("Bad version", -EPROTONOSUPPORT); + if (size && hdr->size != 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); + return log_msg_ret("Bad checksum", -EIO); + } + gd->bloblist = hdr; + + return 0; +} + +int bloblist_finish(void) +{ + struct bloblist_hdr *hdr = gd->bloblist; + + hdr->chksum = bloblist_calc_chksum(hdr); + + return 0; +} + +int bloblist_init(void) +{ + bool expected; + int ret = -ENOENT; + + /** + * Wed expect to find an existing bloblist in the first phase of U-Boot + * that runs + */ + expected = !u_boot_first_phase(); + if (expected) + ret = bloblist_check(CONFIG_BLOBLIST_ADDR, + CONFIG_BLOBLIST_SIZE); + if (ret) { + log(LOGC_BLOBLIST, expected ? LOGL_WARNING : LOGL_DEBUG, + "Existing bloblist not found: creating new bloblist\n"); + ret = bloblist_new(CONFIG_BLOBLIST_ADDR, CONFIG_BLOBLIST_SIZE, + 0); + } else { + log(LOGC_BLOBLIST, LOGL_DEBUG, "Found existing bloblist\n"); + } + + return ret; +} diff --git a/include/bloblist.h b/include/bloblist.h new file mode 100644 index 00000000000..85144010abe --- /dev/null +++ b/include/bloblist.h @@ -0,0 +1,195 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * This provides a standard way of passing information between boot phases + * (TPL -> SPL -> U-Boot proper.) + * + * A list of blobs of data, tagged with their owner. The list resides in memory + * and can be updated by SPL, U-Boot, etc. + * + * Copyright 2018 Google, Inc + * Written by Simon Glass + */ + +#ifndef __BLOBLIST_H +#define __BLOBLIST_H + +enum { + BLOBLIST_VERSION = 0, + BLOBLIST_MAGIC = 0xb00757a3, + BLOBLIST_ALIGN = 16, +}; + +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 */ +}; + +/** + * struct bloblist_hdr - header for the bloblist + * + * This is stored at the start of the bloblist which is always on a 16-byte + * boundary. Records follow this header. The bloblist normally stays in the + * 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, + * 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. + * + * Each bloblist record is aligned to a 16-byte boundary and follows immediately + * from the last. + * + * @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 + * @size: Total size of all records (non-zero if valid) including this header. + * The bloblist extends for this many bytes from the start of this header. + * @alloced: Total size allocated for this bloblist. When adding new records, + * the bloblist can grow up to this size. This starts out as + * sizeof(bloblist_hdr) since we need at least that much space to store a + * valid bloblist + * @spare: Space space + * @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. + */ +struct bloblist_hdr { + u32 version; + u32 hdr_size; + u32 flags; + u32 magic; + + u32 size; + u32 alloced; + u32 spare; + u32 chksum; +}; + +/** + * 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. + * + * @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 + * @size: Size of record in bytes, excluding the header size. This does not + * need to be aligned (e.g. 3 is OK). + * @spare: Spare space for other things + */ +struct bloblist_rec { + u32 tag; + u32 hdr_size; + u32 size; + u32 spare; +}; + +/** + * bloblist_find() - Find a blob + * + * Searches the bloblist and returns the blob with the matching tag + * + * @tag: Tag to search for (enum bloblist_tag_t) + * @size: Expected size of the blob + * @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); + +/** + * bloblist_add() - Add a new blob + * + * Add a new blob to the bloblist + * + * This should only be called if you konw there is no existing blob for a + * particular tag. It is typically safe to call in the first phase of U-Boot + * (e.g. TPL or SPL). After that, bloblist_ensure() should be used instead. + * + * @tag: Tag to add (enum bloblist_tag_t) + * @size: Size of 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); + +/** + * bloblist_ensure_size() - Find or add a blob + * + * Find an existing blob, or add a new one if not found + * + * @tag: Tag to add (enum bloblist_tag_t) + * @size: Size of the 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, or -ESPIPE it exists but has the wrong size + */ +int bloblist_ensure_size(uint tag, int size, void **blobp); + +/** + * bloblist_ensure() - Find or add a blob + * + * Find an existing blob, or add a new one if not found + * + * @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 + */ +void *bloblist_ensure(uint tag, int size); + +/** + * bloblist_new() - Create a new, empty bloblist of a given 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 + */ +int bloblist_new(ulong addr, uint size, uint flags); + +/** + * bloblist_check() - Check if a bloblist exists + * + * @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 + */ +int bloblist_check(ulong addr, uint size); + +/** + * bloblist_finish() - Set up the bloblist for the next U-Boot part + * + * 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 + */ +int bloblist_finish(void); + +/** + * 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. + */ +int bloblist_init(void); + +#endif /* __BLOBLIST_H */ diff --git a/include/log.h b/include/log.h index ad6870bfed8..61de319da65 100644 --- a/include/log.h +++ b/include/log.h @@ -47,6 +47,7 @@ enum log_category_t { LOGC_DT, /* Device-tree */ LOGC_EFI, /* EFI implementation */ LOGC_ALLOC, /* Memory allocation */ + LOGC_BLOBLIST, /* Bloblist */ LOGC_COUNT, /* Number of log categories */ LOGC_END, /* Sentinel value for a list of log categories */ From patchwork Fri Nov 16 01:43:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998689 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1Pz0QMkz9sBQ for ; Fri, 16 Nov 2018 12:49:59 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CB999C22251; Fri, 16 Nov 2018 01:47:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3CA45C223D3; Fri, 16 Nov 2018 01:45:10 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9A769C22272; Fri, 16 Nov 2018 01:44:31 +0000 (UTC) Received: from mail-ot1-f74.google.com (mail-ot1-f74.google.com [209.85.210.74]) by lists.denx.de (Postfix) with ESMTPS id 1C2CEC2223C for ; Fri, 16 Nov 2018 01:44:27 +0000 (UTC) Received: by mail-ot1-f74.google.com with SMTP id p29so15122588ote.3 for ; Thu, 15 Nov 2018 17:44:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=o8vWFrkwKWjfHic6hMKCbruGYWs+av3pBBPvybNuAr0=; b=A+RVclY3ARxKwkl9gz7761jgEqC8dQLDfT84UzHWvCq6O3Tj8/bKjGeR7TfC46SqkG jB7E1uUia40Iwgx0qem07PhC5FJYLdMpAm9/q1N/Pmgvt7q/h7rrNLFrH8636/HDUgzP e6jdGFae5hcoM/UMo0JgKydC3pno6HP/K4NIL0hMTGrJ/Lj4/f7fLKD6CW/Me70Uzl1b wAWMfVDmVbs/ToeI//qVn3JI7AW5ofG2vqnVbaCZgrRE6C/jZ97Ar8p13J2catuI+0Kt IDqZCh5RVCZjkf2geBs7XuEaPd+Qr92tRNUhDDduBmFQp+A+Ovq/sE715YGUTu7SZpDO so8g== X-Gm-Message-State: AGRZ1gILa4D35ZyLp4MF/02epzYSCY+9fLHEpnWSSz8KS6UTtH39WEoP Vqgyz4/8ZlxIxjq1U6yRFhckU9U= X-Google-Smtp-Source: AJdET5f0Fpucqpq1rrf47vOP00qHaHWRtSmgmPrE1Zj/Yo0/fILsEgSrAPXBVZnZ+bOoAvjllioEr4U= X-Received: by 2002:a9d:3cd4:: with SMTP id t20mr1950625otf.55.1542332665896; Thu, 15 Nov 2018 17:44:25 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:51 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-4-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 03/21] spl: Set up the bloblist in SPL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The bloblist is normally set up in SPL ready for use by U-Boot. Add a simple implementation of this to the common SPL code. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/spl/spl.c | 18 ++++++++++++++++-- include/spl.h | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 740182a8be6..eea92ec1f8c 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -343,6 +344,14 @@ static int spl_common_init(bool setup_malloc) return ret; } #endif + if (CONFIG_IS_ENABLED(BLOBLIST)) { + ret = bloblist_init(); + if (ret) { + debug("%s: Failed to set up bloblist: ret=%d\n", + __func__, ret); + return ret; + } + } if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { ret = fdtdec_setup(); if (ret) { @@ -481,6 +490,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) BOOT_DEVICE_NONE, }; struct spl_image_info spl_image; + int ret; debug(">>spl:board_init_r()\n"); @@ -527,6 +537,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } spl_perform_fixups(&spl_image); + if (CONFIG_IS_ENABLED(BLOBLIST)) { + ret = bloblist_finish(); + if (ret) + printf("Warning: Failed to finish bloblist (ret=%d)\n", + ret); + } #ifdef CONFIG_CPU_V7M spl_image.entry_point |= 0x1; @@ -563,8 +579,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2) gd->malloc_ptr / 1024); #endif #ifdef CONFIG_BOOTSTAGE_STASH - int ret; - bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl"); ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR, CONFIG_BOOTSTAGE_STASH_SIZE); diff --git a/include/spl.h b/include/spl.h index 9a439f468b9..a56032ae3eb 100644 --- a/include/spl.h +++ b/include/spl.h @@ -21,6 +21,33 @@ #define MMCSD_MODE_FS 2 #define MMCSD_MODE_EMMCBOOT 3 +/* + * u_boot_first_phase() - check if this is the first U-Boot phase + * + * U-Boot has up to three phases: TPL, SPL and U-Boot proper. Depending on the + * build flags we can determine whether the current build is for the first + * phase of U-Boot or not. If there is no SPL, then this is U-Boot proper. If + * there is SPL but no TPL, the the first phase is SPL. If there is TPL, then + * it is the first phase. + * + * @returns true if this is the first phase of U-Boot + * + */ +static inline bool u_boot_first_phase(void) +{ + if (IS_ENABLED(CONFIG_TPL)) { + if (IS_ENABLED(CONFIG_TPL_BUILD)) + return true; + } else if (IS_ENABLED(CONFIG_SPL)) { + if (IS_ENABLED(CONFIG_SPL_BUILD)) + return true; + } else { + return true; + } + + return false; +} + struct spl_image_info { const char *name; u8 os; From patchwork Fri Nov 16 01:43:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998690 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1QQ3F9kz9s47 for ; Fri, 16 Nov 2018 12:50:22 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 27859C22251; Fri, 16 Nov 2018 01:46:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7E802C221A1; Fri, 16 Nov 2018 01:45:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 80FB0C2224A; Fri, 16 Nov 2018 01:44:32 +0000 (UTC) Received: from mail-vk1-f201.google.com (mail-vk1-f201.google.com [209.85.221.201]) by lists.denx.de (Postfix) with ESMTPS id BE711C2225C for ; Fri, 16 Nov 2018 01:44:28 +0000 (UTC) Received: by mail-vk1-f201.google.com with SMTP id c1so3690497vkf.19 for ; Thu, 15 Nov 2018 17:44:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ZrrqKnjpLdqG7zYAfLeWze/i256GIJEYUEAjlTRSJu8=; b=LxYZ1IsAyZ4oJAG4et8P+nTKZGaC4J1LWC3wr1Htjz21soXArG87wv36Z1i03eQCIC JjEZHQpXpwyuxQiiU9S3RqKKDpsQmqX7nQCgkCT7FJlFmMhXl/Cr2oDqBdAYl7LIslnl gxxz7SvvGrySavtduNvNfAKx2YrF0vspc7Q0YX/tv1Pd41fPJTO+12V0WP+4/8SWKY3+ JlIbf+2W5+cKe6uPM8G/Epv+E4xTmFnGPS5tWm4SPk/GLpQ6sy4CBOwFf4o0iaVaZtEC WkTVdUsBFKSAQ7vwitvBa3b0HIMRBHKWOk31tYgJzKtyf4TC4+pg9+JhFUUHvfx3w11n qeKg== X-Gm-Message-State: AGRZ1gKXLJzUqv77SJHvI+hUmwiRvTV2xExTBIYq31PMa8zy5uEye+EV ShBsZE6jUME8Y8MfDj/HJ0n33C8= X-Google-Smtp-Source: AJdET5d9xC0MhgrTvi4D3xxLEkqUimGETNrStNtDUSqFNo1HoSkfO3QEO8c7xP8xnS8YirpxHLQJsV4= X-Received: by 2002:ab0:25c2:: with SMTP id y2mr2456474uan.22.1542332667646; Thu, 15 Nov 2018 17:44:27 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:52 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-5-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH v3 04/21] bloblist: Locate bloblist in U-Boot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add support for locating a bloblist in U-Boot that has been set up by SPL. It is copied into RAM during relocation. Reviewed-by: Tom Rini Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/board_f.c | 34 +++++++++++++++++++++++++++++++ include/asm-generic/global_data.h | 4 ++++ 2 files changed, 38 insertions(+) diff --git a/common/board_f.c b/common/board_f.c index 96503ff8d3c..42378537c8d 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -560,6 +561,16 @@ static int reserve_stacks(void) return arch_reserve_stacks(); } +static int reserve_bloblist(void) +{ +#ifdef CONFIG_BLOBLIST + gd->start_addr_sp -= CONFIG_BLOBLIST_SIZE; + gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE); +#endif + + return 0; +} + static int display_new_sp(void) { debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp); @@ -666,6 +677,24 @@ static int reloc_bootstage(void) return 0; } +static int reloc_bloblist(void) +{ +#ifdef CONFIG_BLOBLIST + if (gd->flags & GD_FLG_SKIP_RELOC) + return 0; + if (gd->new_bloblist) { + int size = CONFIG_BLOBLIST_SIZE; + + debug("Copying bloblist from %p to %p, size %x\n", + gd->bloblist, gd->new_bloblist, size); + memcpy(gd->new_bloblist, gd->bloblist, size); + gd->bloblist = gd->new_bloblist; + } +#endif + + return 0; +} + static int setup_reloc(void) { if (gd->flags & GD_FLG_SKIP_RELOC) { @@ -813,6 +842,9 @@ static const init_fnc_t init_sequence_f[] = { initf_malloc, log_init, initf_bootstage, /* uses its own timer, so does not need DM */ +#ifdef CONFIG_BLOBLIST + bloblist_init, +#endif initf_console_record, #if defined(CONFIG_HAVE_FSP) arch_fsp_init, @@ -913,6 +945,7 @@ static const init_fnc_t init_sequence_f[] = { reserve_global_data, reserve_fdt, reserve_bootstage, + reserve_bloblist, reserve_arch, reserve_stacks, dram_init_banksize, @@ -932,6 +965,7 @@ static const init_fnc_t init_sequence_f[] = { INIT_FUNC_WATCHDOG_RESET reloc_fdt, reloc_bootstage, + reloc_bloblist, setup_reloc, #if defined(CONFIG_X86) || defined(CONFIG_ARC) copy_uboot_to_ram, diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index c83fc01b764..ccf361ed88a 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -122,6 +122,10 @@ typedef struct global_data { struct list_head log_head; /* List of struct log_device */ int log_fmt; /* Mask containing log format info */ #endif +#if CONFIG_IS_ENABLED(BLOBLIST) + struct bloblist_hdr *bloblist; /* Bloblist information */ + struct bloblist_hdr *new_bloblist; /* Relocated blolist info */ +#endif } gd_t; #endif From patchwork Fri Nov 16 01:43:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998691 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1Qz085Xz9s47 for ; Fri, 16 Nov 2018 12:50:51 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9CB97C221A9; Fri, 16 Nov 2018 01:46:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3A0CCC22268; Fri, 16 Nov 2018 01:45:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EBDD9C22242; Fri, 16 Nov 2018 01:44:34 +0000 (UTC) Received: from mail-it1-f202.google.com (mail-it1-f202.google.com [209.85.166.202]) by lists.denx.de (Postfix) with ESMTPS id 5148FC221C6 for ; Fri, 16 Nov 2018 01:44:30 +0000 (UTC) Received: by mail-it1-f202.google.com with SMTP id j71-v6so26011908ita.5 for ; Thu, 15 Nov 2018 17:44:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=z3FR3Cw0+hfSAfSgOTM3vNaBqemjlJ7su+hqBnQb+4s=; b=d7ZXPF/mzYjAwh06ciCbXXCdfHzY++UAElIBo5hQTuAHG7krH+ESbhpj7RtUz0T/zB afJ/WdcpLMm0Mbs2eevKS4qyOv5lXMyIfdaOrsTbBY5CoKFZ0idNJOpXjqXkEpQ5Zq52 kOPo90DUUJl4QcnN+220yZPYncp7c8ionm21+fBOTvn/3yvCn/6Xfq8ePOrjd8O8G1u1 B9bggdW0v0nwUKxbc6EA24WEsTe1Hdiyd/3wPrAkwB4s1fDY2SZ7AdJmw/itgZGVJxsT FG/2KNUgTrzas4jFyAZ9biBkcc0PhC/GIcQ5ZZVvl33Ied5YqrFPbnlvgxhawqLsiULu jWfA== X-Gm-Message-State: AGRZ1gKzcnQbr7Hb9GGaxVdf2UxLsVrtJ76wZ920J8KpkANEE2vhL7NW lGO+7WYo6yWS8z+9Q3qjr9SIj5Q= X-Google-Smtp-Source: AJdET5etn6UAEV8b4RFbi0aivPJgehE5t3ZvHOzLNk0LmN49hTAB5QyjTi7tsNPuGUB2R2+0eueB0Lc= X-Received: by 2002:a24:153:: with SMTP id 80-v6mr1966510itk.19.1542332669366; Thu, 15 Nov 2018 17:44:29 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:53 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-6-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 05/21] test: Add a simple test for bloblist X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add a unit test for the bloblist functionality and enable bloblist for sandbox. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None arch/Kconfig | 1 + include/test/suites.h | 1 + test/Makefile | 1 + test/bloblist.c | 187 ++++++++++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 3 + 5 files changed, 193 insertions(+) create mode 100644 test/bloblist.c diff --git a/arch/Kconfig b/arch/Kconfig index 9fdd2f7e66a..947070fdd35 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -91,6 +91,7 @@ config SANDBOX select SPI select SUPPORT_OF_CONTROL imply BITREVERSE + select BLOBLIST imply CMD_DM imply CMD_GETTIME imply CMD_HASH diff --git a/include/test/suites.h b/include/test/suites.h index abb3a4b8169..77d863b4a6a 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -23,6 +23,7 @@ struct unit_test; int cmd_ut_category(const char *name, struct unit_test *tests, int n_ents, int argc, char * const argv[]); +int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); diff --git a/test/Makefile b/test/Makefile index 1e434730b68..2fe41f489c3 100644 --- a/test/Makefile +++ b/test/Makefile @@ -2,6 +2,7 @@ # # (C) Copyright 2012 The Chromium Authors +obj-$(CONFIG_SANDBOX) += bloblist.o obj-$(CONFIG_UNIT_TEST) += cmd_ut.o obj-$(CONFIG_UNIT_TEST) += ut.o obj-$(CONFIG_SANDBOX) += command_ut.o diff --git a/test/bloblist.c b/test/bloblist.c new file mode 100644 index 00000000000..89bdb012e35 --- /dev/null +++ b/test/bloblist.c @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2018, Google Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/* Declare a new compression test */ +#define BLOBLIST_TEST(_name, _flags) \ + UNIT_TEST(_name, _flags, bloblist_test) + +enum { + TEST_TAG = 1, + TEST_TAG2 = 2, + TEST_TAG_MISSING = 3, + + TEST_SIZE = 10, + TEST_SIZE2 = 20, + + TEST_ADDR = CONFIG_BLOBLIST_ADDR, + TEST_BLOBLIST_SIZE = 0x100, +}; + +static struct bloblist_hdr *clear_bloblist(void) +{ + struct bloblist_hdr *hdr; + + /* Clear out any existing bloblist so we have a clean slate */ + hdr = map_sysmem(CONFIG_BLOBLIST_ADDR, TEST_BLOBLIST_SIZE); + memset(hdr, '\0', TEST_BLOBLIST_SIZE); + + return hdr; +} + +static int bloblist_test_init(struct unit_test_state *uts) +{ + struct bloblist_hdr *hdr; + + hdr = clear_bloblist(); + ut_asserteq(-ENOENT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + hdr->version++; + ut_asserteq(-EPROTONOSUPPORT, bloblist_check(TEST_ADDR, + TEST_BLOBLIST_SIZE)); + + ut_asserteq(-ENOSPC, bloblist_new(TEST_ADDR, 0x10, 0)); + ut_asserteq(-EFAULT, bloblist_new(1, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + ut_assertok(bloblist_finish()); + ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + hdr->flags++; + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + + return 1; +} +BLOBLIST_TEST(bloblist_test_init, 0); + +static int bloblist_test_blob(struct unit_test_state *uts) +{ + struct bloblist_hdr *hdr; + struct bloblist_rec *rec, *rec2; + char *data; + + /* At the start there should be no records */ + hdr = clear_bloblist(); + ut_assertnull(bloblist_find(TEST_TAG, TEST_BLOBLIST_SIZE)); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + + /* Add a record and check that we can find it */ + data = bloblist_add(TEST_TAG, TEST_SIZE); + rec = (void *)(hdr + 1); + ut_asserteq_ptr(rec + 1, data); + data = bloblist_find(TEST_TAG, TEST_SIZE); + ut_asserteq_ptr(rec + 1, data); + + /* Check the 'ensure' method */ + ut_asserteq_ptr(data, bloblist_ensure(TEST_TAG, TEST_SIZE)); + ut_assertnull(bloblist_ensure(TEST_TAG, TEST_SIZE2)); + rec2 = (struct bloblist_rec *)(data + ALIGN(TEST_SIZE, BLOBLIST_ALIGN)); + + /* Check for a non-existent record */ + ut_asserteq_ptr(data, bloblist_ensure(TEST_TAG, TEST_SIZE)); + ut_asserteq_ptr(rec2 + 1, bloblist_ensure(TEST_TAG2, TEST_SIZE2)); + ut_assertnull(bloblist_find(TEST_TAG_MISSING, 0)); + + return 0; +} +BLOBLIST_TEST(bloblist_test_blob, 0); + +static int bloblist_test_bad_blob(struct unit_test_state *uts) +{ + struct bloblist_hdr *hdr; + void *data; + + hdr = clear_bloblist(); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + data = hdr + 1; + data += sizeof(struct bloblist_rec); + ut_asserteq_ptr(data, bloblist_ensure(TEST_TAG, TEST_SIZE)); + ut_asserteq_ptr(data, bloblist_ensure(TEST_TAG, TEST_SIZE)); + + return 0; +} +BLOBLIST_TEST(bloblist_test_bad_blob, 0); + +static int bloblist_test_checksum(struct unit_test_state *uts) +{ + struct bloblist_hdr *hdr; + char *data, *data2; + + hdr = clear_bloblist(); + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + ut_assertok(bloblist_finish()); + ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + + /* + * Now change things amd make sure that the checksum notices. We cannot + * change the size or alloced fields, since that will crash the code. + * It has to rely on these being correct. + */ + hdr->flags--; + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + hdr->flags++; + + hdr->size--; + ut_asserteq(-EFBIG, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + hdr->size++; + + hdr->spare++; + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + hdr->spare--; + + hdr->chksum++; + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + hdr->chksum--; + + /* Make sure the checksum changes when we add blobs */ + data = bloblist_add(TEST_TAG, TEST_SIZE); + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + + data2 = bloblist_add(TEST_TAG2, TEST_SIZE2); + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + ut_assertok(bloblist_finish()); + + /* It should also change if we change the data */ + ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + *data += 1; + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + *data -= 1; + + ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + *data2 += 1; + ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + *data2 -= 1; + + /* + * Changing data outside the range of valid data should not affect + * the checksum. + */ + ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + data[TEST_SIZE]++; + data2[TEST_SIZE2]++; + ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE)); + + return 0; +} + +BLOBLIST_TEST(bloblist_test_checksum, 0); + +int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + struct unit_test *tests = ll_entry_start(struct unit_test, + bloblist_test); + const int n_ents = ll_entry_count(struct unit_test, bloblist_test); + + return cmd_ut_category("bloblist", tests, n_ents, argc, argv); +} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index b7e01a4847e..56924a52726 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -55,6 +55,8 @@ static cmd_tbl_t cmd_ut_sub[] = { #ifdef CONFIG_SANDBOX U_BOOT_CMD_MKENT(compression, CONFIG_SYS_MAXARGS, 1, do_ut_compression, "", ""), + U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist, + "", ""), #endif }; @@ -97,6 +99,7 @@ static int do_ut(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static char ut_help_text[] = "all - execute all enabled tests\n" #ifdef CONFIG_SANDBOX + "ut bloblist - Test bloblist implementation\n" "ut compression - Test compressors and bootm decompression\n" #endif #ifdef CONFIG_UT_DM From patchwork Fri Nov 16 01:43:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998694 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1TT0YFmz9s1x for ; Fri, 16 Nov 2018 12:53:01 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C01A1C22230; Fri, 16 Nov 2018 01:46:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 62315C2225C; Fri, 16 Nov 2018 01:45:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1C7B5C22243; Fri, 16 Nov 2018 01:44:36 +0000 (UTC) Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) by lists.denx.de (Postfix) with ESMTPS id CF4F0C22252 for ; Fri, 16 Nov 2018 01:44:31 +0000 (UTC) Received: by mail-io1-f73.google.com with SMTP id c25-v6so3245815ioi.18 for ; Thu, 15 Nov 2018 17:44:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ZruSMcV9F1z2FMkWc9Mh4qN8XL9d094rArmJFwdig+I=; b=i3IAuo1uvVD6KG8tZWzxNaX+zCGVXhcKa5wnOuPi6B010f/pX9ZohvMuf2lFly8/mS g9Ite0WbGRs63k802M+Jm65YseJVDQg2+iTPjA9fcrHPR2oautavzBMFH8YtX1WOCzZW DdDlZ+nQzzhxtT91Mo/I8Sgj5qPOq6PcE2hjxmad1Fp1fd28DQn/HmpZ+eH7VCqjxxrK WUuxDApwa0o+s6u/SsRuchLJ8o0OKX00bSNd+m9G1a9MnjqE971IvvBMXYubUSrGtqXh 62XPvXoc6XDPDwEOK/pQykF2rrbxo4rG2Xsw5f3JQUIN56zEch6rLLzwFaN0Tl0G+fcp S3BA== X-Gm-Message-State: AGRZ1gLdaJ5y0cNU7BOOOdwOXDFWAm+rC8LSnqR+jH/IZb4gdsOVGbZ/ pUmvsCcoPqWevotWwqjV0QT2tJc= X-Google-Smtp-Source: AJdET5fCVRiYOfipgIztWJcF6AUKyI4fIDZbzIMLbKuCYK0baWyzMhxOW4p01MTCv5Zg0FexIgBz8YA= X-Received: by 2002:a24:8903:: with SMTP id s3-v6mr2164779itd.26.1542332670918; Thu, 15 Nov 2018 17:44:30 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:54 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-7-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 06/21] Add bloblist documentation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add a description of the purpose of bloblist and how to use it. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None doc/README.bloblist | 82 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 doc/README.bloblist diff --git a/doc/README.bloblist b/doc/README.bloblist new file mode 100644 index 00000000000..b0e787b97db --- /dev/null +++ b/doc/README.bloblist @@ -0,0 +1,82 @@ +# SPDX-License-Identifier: GPL-2.0+ + +Blob Lists - bloblist +===================== + +Introduction +------------ + +A bloblist provides a way to store collections of binary information (blobs) in +a central structure. Each record of information is assigned a tag so that its +owner can find it and update it. Each record is generally described by a C +structure defined by the code that owns it. + + +Passing state through the boot process +-------------------------------------- + +The bloblist is created when the first U-Boot component runs (often SPL, +sometimes TPL). It is passed through to each successive part of the boot and +can be accessed as needed. This provides a way to transfer state from one part +to the next. For example, TPL may determine that a watchdog reset occurred by +reading an SoC register. Reading the register may reset the value, so that it +cannot be read a second time. So TPL can store that in a bloblist record which +can be passed through to SPL and U-Boot proper, which can print a message +indicating that something went wrong and the watchdog fired. + + +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. + + +Blob tags +--------- + +Each blob has a tag which is a 32-bit number. This uniquely identifies the +owner of the blob. Blob tags are listed in enum blob_tag_t and are named +with a BLOBT_ prefix. + + +Single structure +---------------- + +There is normally only one bloblist in U-Boot. Since a bloblist can store +multiple blobs it does not seem useful to allow multiple bloblists. Of course +there could be reasons for this, such as needing to spread the blobs around in +different memory areas due to fragmented memory, but it is simpler to just have +a single bloblist. + + +API +--- + +Bloblist provides a fairly simple API which allows blobs to be created and +found. All access is via the blob's tag. + + +Finishing the bloblist +---------------------- + +When a part of U-Boot is about to jump to the next part, it can 'finish' the +bloblist in preparation for the next stage. This involves adding a checksum so +that the next stage can make sure that the data arrived safely. While the +bloblist is in use, changes can be made which will affect the checksum, so it +is easier to calculate the checksum at the end after all changes are made. + + +Future work +----------- + +Bootstage has a mechanism to 'stash' its records for passing to the next part. +This should move to using bloblist, to avoid having its own mechanism for +passing information between U-Boot parts. + + +Simon Glass +sjg@chromium.org +12-Aug-2018 From patchwork Fri Nov 16 01:43:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998702 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1Zg0PbXz9s47 for ; Fri, 16 Nov 2018 12:57:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 93BCEC2224B; Fri, 16 Nov 2018 01:47:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9FBD9C223F4; Fri, 16 Nov 2018 01:45:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 30839C223D1; Fri, 16 Nov 2018 01:44:38 +0000 (UTC) Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by lists.denx.de (Postfix) with ESMTPS id E5626C21F97 for ; Fri, 16 Nov 2018 01:44:33 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id x125so31076554qka.17 for ; Thu, 15 Nov 2018 17:44:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=T4DpnZW4ykddGN/frDQhNlR+OEN/pH8KNlKQAbU7Y/w=; b=RZ0JQLaGbobruXYik+cYwHCjzxsNluzGjjPNwhtluSpxZbp/R/Mn1ONsEqOas7sVEV 8u5OHyLumRHs1OZk3Wezm4BdVwRVfjEwsuixNt+G4z20OdO/7z1zmXBTlxJLQq6Of6Vb yLQESVwVChcK0ctYQrSVs0RQkwB4DmTwCNrA0ROGV0wwwD0TXx6nK07WSqZxkj+CIxWW sChhiOVarzB3qU2Uljqw+CwMoeTaJQ40XCIoL1XNydiYAH4e781bFKnMwXjs/e43mGAi ue/XOvStsqWwf2TxrZ7bXoFbGPcTgu4yeaQ/lkWGerTyPEXvJi0eaAJZzep4vbmQQFDl U69w== X-Gm-Message-State: AGRZ1gJ4F0md/G6AWLMmn1KFF4af6/JETDTCUIAjzSzAFiC5qpmuoKrn EYoPovyVe2oNVtCzPSS5jnOhfyk= X-Google-Smtp-Source: AFSGD/UwEPVbNZUxyjwWmSPJA9JrSLeTccrFtp0H/eUEaEQAgxLj9I1zXsQMfwYgLc+w0RdIMcrDjsg= X-Received: by 2002:a37:3c08:: with SMTP id j8mr2053482qka.51.1542332672640; Thu, 15 Nov 2018 17:44:32 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:55 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-8-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH v3 07/21] spl: Support hash, input, pch, pci, rtc, tpm in SPL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present these subsystems are only supported in U-Boot proper but it is sometimes necessary to support them in SPL, or even TPL. Update the Kconfig and Makefile to support this. Also adjust GPIO so that it can be used in TPL if required. Reviewed-by: Tom Rini Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/spl/Kconfig | 48 +++++++++++++++++++++++++++++++++++++++++++++- drivers/Makefile | 11 ++++++----- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index d0564621d4d..365e692d8b5 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -295,6 +295,16 @@ config SPL_HASH_SUPPORT this option to build system-specific drivers for hash acceleration as part of an SPL build. +config TPL_HASH_SUPPORT + bool "Support hashing drivers in TPL" + select SHA1 + select SHA256 + help + Enable hashing drivers in SPL. These drivers can be used to + accelerate secure boot processing in secure applications. Enable + this option to build system-specific drivers for hash acceleration + as part of an SPL build. + config SPL_DMA_SUPPORT bool "Support DMA drivers" help @@ -376,7 +386,7 @@ config SPL_FPGA_SUPPORT within SPL. config SPL_GPIO_SUPPORT - bool "Support GPIO" + bool "Support GPIO in SPL" help Enable support for GPIOs (General-purpose Input/Output) in SPL. GPIOs allow U-Boot to read the state of an input line (high or @@ -928,6 +938,17 @@ config TPL_ENV_SUPPORT help Enable environment support in TPL. See SPL_ENV_SUPPORT for details. +config TPL_GPIO_SUPPORT + bool "Support GPIO in TPL" + help + Enable support for GPIOs (General-purpose Input/Output) in TPL. + GPIOs allow U-Boot to read the state of an input line (high or + low) and set the state of an output line. This can be used to + drive LEDs, control power to various system parts and read user + input. GPIOs can be useful in TPL to enable a 'sign-of-life' LED, + for example. Enable this option to build the drivers in + drivers/gpio as part of an TPL build. + config TPL_I2C_SUPPORT bool "Support I2C" help @@ -963,6 +984,22 @@ config TPL_NAND_SUPPORT help Enable support for NAND in TPL. See SPL_NAND_SUPPORT for details. +config TPL_PCI_SUPPORT + bool "Support PCI drivers" + help + Enable support for PCI in TPL. For platforms that need PCI to boot, + or must perform some init using PCI in SPL, this provides the + necessary driver support. This enables the drivers in drivers/pci + as part of a TPL build. + +config TPL_PCH_SUPPORT + bool "Support PCH drivers" + help + Enable support for PCH (Platform Controller Hub) devices in TPL. + These are used to set up GPIOs and the SPI peripheral early in + boot. This enables the drivers in drivers/pch as part of a TPL + build. + config TPL_RAM_SUPPORT bool "Support booting from RAM" help @@ -977,6 +1014,15 @@ config TPL_RAM_DEVICE be already in memory when TPL takes over, e.g. loaded by the boot ROM. +config TPL_RTC_SUPPORT + bool "Support RTC drivers" + help + Enable RTC (Real-time Clock) support in TPL. This includes support + for reading and setting the time. Some RTC devices also have some + non-volatile (battery-backed) memory which is accessible if + needed. This enables the drivers in drivers/rtc as part of an TPL + build. + config TPL_SERIAL_SUPPORT bool "Support serial" select TPL_PRINTF diff --git a/drivers/Makefile b/drivers/Makefile index 4453c62ad33..55de10926ef 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -2,14 +2,19 @@ obj-$(CONFIG_$(SPL_TPL_)CLK) += clk/ obj-$(CONFIG_$(SPL_TPL_)DM) += core/ +obj-$(CONFIG_$(SPL_TPL_)GPIO_SUPPORT) += gpio/ obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/ obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/ +obj-$(CONFIG_$(SPL_TPL_)INPUT) += input/ obj-$(CONFIG_$(SPL_TPL_)LED) += led/ obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/ obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/ +obj-$(CONFIG_$(SPL_TPL_)PCH_SUPPORT) += pch/ +obj-$(CONFIG_$(SPL_TPL_)PCI_SUPPORT) += pci/ obj-$(CONFIG_$(SPL_TPL_)PHY) += phy/ obj-$(CONFIG_$(SPL_TPL_)PINCTRL) += pinctrl/ obj-$(CONFIG_$(SPL_TPL_)RAM) += ram/ +obj-$(CONFIG_$(SPL_TPL_)RTC_SUPPORT) += rtc/ obj-$(CONFIG_$(SPL_TPL_)SERIAL_SUPPORT) += serial/ obj-$(CONFIG_$(SPL_TPL_)SPI_FLASH_SUPPORT) += mtd/spi/ obj-$(CONFIG_$(SPL_TPL_)SPI_SUPPORT) += spi/ @@ -17,6 +22,7 @@ obj-$(CONFIG_$(SPL_TPL_)TIMER) += timer/ obj-$(CONFIG_$(SPL_TPL_)VIRTIO) += virtio/ obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/ obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/ +obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/ ifndef CONFIG_TPL_BUILD ifdef CONFIG_SPL_BUILD @@ -24,7 +30,6 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/ obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/ -obj-$(CONFIG_SPL_GPIO_SUPPORT) += gpio/ obj-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/ obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/ @@ -40,9 +45,6 @@ obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/ obj-$(CONFIG_SPL_USB_ETHER) += net/phy/ -obj-$(CONFIG_SPL_PCI_SUPPORT) += pci/ -obj-$(CONFIG_SPL_PCH_SUPPORT) += pch/ -obj-$(CONFIG_SPL_RTC_SUPPORT) += rtc/ obj-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += usb/musb-new/ obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += usb/gadget/ obj-$(CONFIG_SPL_USB_GADGET_SUPPORT) += usb/gadget/udc/ @@ -92,7 +94,6 @@ obj-y += scsi/ obj-y += sound/ obj-y += spmi/ obj-y += sysreset/ -obj-y += tpm/ obj-y += video/ obj-y += watchdog/ obj-$(CONFIG_QE) += qe/ From patchwork Fri Nov 16 01:43:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998685 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1KN0NY0z9s47 for ; Fri, 16 Nov 2018 12:45:59 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6D254C224AC; Fri, 16 Nov 2018 01:45:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 72243C2224D; Fri, 16 Nov 2018 01:44:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A88DBC22244; Fri, 16 Nov 2018 01:44:39 +0000 (UTC) Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) by lists.denx.de (Postfix) with ESMTPS id 4EC19C22214 for ; Fri, 16 Nov 2018 01:44:35 +0000 (UTC) Received: by mail-qk1-f201.google.com with SMTP id s19so48980456qke.20 for ; Thu, 15 Nov 2018 17:44:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=vLumUjl6/o7uWSbk/tWpkUxc2/rzR7aYMexjFXSnN3c=; b=a0tyndRp8DVouQ2e3iFTPjIoYB8nthkSh1Lwr94AUUA/cAN6S+lQw1v/NASl6x9BG7 kTFUEljF4LxR0P5jJTx44Cngx+K7siJoii4BFM4jKwH+b8JUfKBj301y7dMOUsiiGAPm hR1PP4gNIqtbldkgKGloZ3iYZppopCdPOVvXkeHjRWiilUPoa0Nh1hAcI0JbQyLoEhWa Scj5QWuK8T/ewCT+hqkCuBkWGdmYfbyzKE71KxmkQ1mrZGy+L00E9f51tGA7EejuUwwa aplwr174HeWw6KapIaVbKakWby+vpxOA6eilhXZXQiCeWmeEo5ybWDfyPUuD8fQDi7Ti 6vFg== X-Gm-Message-State: AA+aEWaPvNpbKdhbWeT+jZoPMjBVgEcxMZtZ3K6YPXNYXTp26QP5SvKu oc8AvkbH8UgHzJbnNea3PQZDAD0= X-Google-Smtp-Source: AFSGD/VPQQNOBOPzcJM/22HLeOeyj3R9YKLuJjE8Qn7QLk4eHtMjT34DyWCbhp8+1UG/BybHEZR+xec= X-Received: by 2002:ac8:29b3:: with SMTP id 48mr2035188qts.11.1542332674360; Thu, 15 Nov 2018 17:44:34 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:56 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-9-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH v3 08/21] spl: Add a define for SPL_TPL_PROMPT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We should use a macro rather than hard-coding the SPL prompt to 'spl' since the code can be used by TPL too. Add a macro that works for both and use it in various places. This allows TPL to use the same code without printing confusing messages. Note that the string is lower case ('spl', 'tpl') which is a change from previously. Reviewed-by: Tom Rini Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/spl/spl.c | 27 +++++++++++++++------------ include/spl.h | 13 +++++++++++++ test/py/u_boot_console_base.py | 2 +- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index eea92ec1f8c..23be33c5c10 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -58,8 +58,9 @@ __weak void show_boot_progress(int val) {} #ifdef CONFIG_SPL_OS_BOOT __weak int spl_start_uboot(void) { - puts("SPL: Please implement spl_start_uboot() for your board\n"); - puts("SPL: Direct Linux boot not active!\n"); + puts(SPL_TPL_PROMPT + "Please implement spl_start_uboot() for your board\n"); + puts(SPL_TPL_PROMPT "Direct Linux boot not active!\n"); return 1; } @@ -101,13 +102,13 @@ void spl_fixup_fdt(void) /* fixup the memory dt node */ err = fdt_shrink_to_minimum(fdt_blob, 0); if (err == 0) { - printf("spl: fdt_shrink_to_minimum err - %d\n", err); + printf(SPL_TPL_PROMPT "fdt_shrink_to_minimum err - %d\n", err); return; } err = arch_fixup_fdt(fdt_blob); if (err) { - printf("spl: arch_fixup_fdt err - %d\n", err); + printf(SPL_TPL_PROMPT "arch_fixup_fdt err - %d\n", err); return; } #endif @@ -186,7 +187,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image, spl_image->os = IH_OS_U_BOOT; spl_image->name = "U-Boot"; - debug("spl: payload image: %32s load addr: 0x%lx size: %d\n", + debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n", spl_image->name, spl_image->load_addr, spl_image->size); #ifdef CONFIG_SPL_FIT_SIGNATURE @@ -256,7 +257,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image, } spl_image->os = image_get_os(header); spl_image->name = image_get_name(header); - debug("spl: payload image: %32s load addr: 0x%lx size: %d\n", + debug(SPL_TPL_PROMPT + "payload image: %32s load addr: 0x%lx size: %d\n", spl_image->name, spl_image->load_addr, spl_image->size); #else /* LEGACY image not supported */ @@ -285,7 +287,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image, spl_image->load_addr = CONFIG_SYS_LOAD_ADDR; spl_image->entry_point = CONFIG_SYS_LOAD_ADDR; spl_image->size = end - start; - debug("spl: payload zImage, load addr: 0x%lx size: %d\n", + debug(SPL_TPL_PROMPT + "payload zImage, load addr: 0x%lx size: %d\n", spl_image->load_addr, spl_image->size); return 0; } @@ -469,7 +472,7 @@ static int boot_from_devices(struct spl_image_info *spl_image, if (loader) printf("Trying to boot from %s\n", loader->name); else - puts("SPL: Unsupported Boot Device!\n"); + puts(SPL_TPL_PROMPT "Unsupported Boot Device!\n"); #endif if (loader && !spl_load_image(spl_image, loader)) { spl_image->boot_device = spl_boot_list[i]; @@ -492,7 +495,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) struct spl_image_info spl_image; int ret; - debug(">>spl:board_init_r()\n"); + debug(">>" SPL_TPL_PROMPT "board_init_r()\n"); spl_set_bd(); @@ -532,7 +535,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) if (boot_from_devices(&spl_image, spl_boot_list, ARRAY_SIZE(spl_boot_list))) { - puts("SPL: failed to boot from all boot devices\n"); + puts(SPL_TPL_PROMPT "failed to boot from all boot devices\n"); hang(); } @@ -605,8 +608,8 @@ void preloader_console_init(void) gd->have_console = 1; #ifndef CONFIG_SPL_DISABLE_BANNER_PRINT - puts("\nU-Boot SPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \ - U_BOOT_TIME " " U_BOOT_TZ ")\n"); + puts("\nU-Boot " SPL_TPL_NAME " " PLAIN_VERSION " (" U_BOOT_DATE " - " + U_BOOT_TIME " " U_BOOT_TZ ")\n"); #endif #ifdef CONFIG_SPL_DISPLAY_PRINT spl_display_print(); diff --git a/include/spl.h b/include/spl.h index a56032ae3eb..205aaff4b9d 100644 --- a/include/spl.h +++ b/include/spl.h @@ -48,6 +48,19 @@ static inline bool u_boot_first_phase(void) return false; } +/* A string name for SPL or TPL */ +#ifdef CONFIG_SPL_BUILD +# ifdef CONFIG_TPL_BUILD +# define SPL_TPL_NAME "tpl" +# else +# define SPL_TPL_NAME "spl" +# endif +# define SPL_TPL_PROMPT SPL_TPL_NAME ": " +#else +# define SPL_TPL_NAME "" +# define SPL_TPL_PROMPT "" +#endif + struct spl_image_info { const char *name; u8 os; diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index 326b2ac51fb..e044eb3ea1d 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -16,7 +16,7 @@ import sys import u_boot_spawn # Regexes for text we expect U-Boot to send to the console. -pattern_u_boot_spl_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))') +pattern_u_boot_spl_signon = re.compile('(U-Boot spl \\d{4}\\.\\d{2}[^\r\n]*\\))') pattern_u_boot_main_signon = re.compile('(U-Boot \\d{4}\\.\\d{2}[^\r\n]*\\))') pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ') pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'') From patchwork Fri Nov 16 01:43:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998687 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1N56XYmz9s47 for ; Fri, 16 Nov 2018 12:48:21 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A67DFC22255; Fri, 16 Nov 2018 01:46:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1633BC2220C; Fri, 16 Nov 2018 01:45:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 539C9C21F81; Fri, 16 Nov 2018 01:44:39 +0000 (UTC) Received: from mail-it1-f201.google.com (mail-it1-f201.google.com [209.85.166.201]) by lists.denx.de (Postfix) with ESMTPS id A9ABEC22247 for ; Fri, 16 Nov 2018 01:44:36 +0000 (UTC) Received: by mail-it1-f201.google.com with SMTP id s195-v6so27343531itc.6 for ; Thu, 15 Nov 2018 17:44:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=2wJ9B9KpYa+VShpd3F554MBuq/phikTTqLrkLaSZtHQ=; b=dHFo4eD90HWeXdAzfq9sh4DTBsYt57dI4NcCqSgAgA7ft4Jj5ioY7Mlb5g9Zw9nKDL FyfniqN5VxT2mTrSSdDY2vNlKveqF/eERrLM/66V7SN8enObnQ4Bhtf61Hx5AMEHFkvG wPGijtsYoPMULjzwOhMDVC0gmBdromlqsByN2eI453i10id42AKdev3Rd8yPjK5gNLVr CfJXUuTiMnsOVdJl6oJCMhrgkjDvn6NHNv84Xmouf9KAFgc4zCW1JDq4tVyHW5eu/j5l TCILHc7qY07n725F5swqJ+5Im2/TDW197D3faV+YZSYfKHrNxXicu0dZgENW1jqPQznX og/A== X-Gm-Message-State: AGRZ1gKwPIlc0feBqTMfYWWWal1xU2JmSyQCZBFY6O8kwqYI9ATesgfg N2FhBw/fKL3B2kiqhQJoZCig2cs= X-Google-Smtp-Source: AJdET5d+ecdSHcpfOyXxK/9oQl5Wl84j5yPy2y7/f67WHGAWRAIibcpJPE+LCuLmaq0lmwoI4LQb5B0= X-Received: by 2002:a24:3d88:: with SMTP id n130mr2168436itn.6.1542332675748; Thu, 15 Nov 2018 17:44:35 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:57 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-10-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH v3 09/21] spl: Make SPL_DISABLE_BANNER_PRINT a positive option X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Rather than having a negative option, make this a positive option and enable it by default. This makes it easier to understand. Reviewed-by: Tom Rini Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/spl/Kconfig | 17 +++++++++++++---- common/spl/spl.c | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 365e692d8b5..32fa5758bf6 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -135,12 +135,21 @@ config SPL_SEPARATE_BSS location is used. Normally we put the device tree at the end of BSS but with this option enabled, it goes at _image_binary_end. -config SPL_DISABLE_BANNER_PRINT - bool "Disable output of the SPL banner 'U-Boot SPL ...'" +config SPL_BANNER_PRINT + bool "Enable output of the SPL banner 'U-Boot SPL ...'" + default y + help + If this option is enabled, SPL will print the banner with version + info. Disabling this option could be useful to reduce TPL boot time + (e.g. approx. 6 ms faster, when output on i.MX6 with 115200 baud). + +config TPL_BANNER_PRINT + bool "Enable output of the TPL banner 'U-Boot TPL ...'" + default y help If this option is enabled, SPL will not print the banner with version - info. Selecting this option could be useful to reduce SPL boot time - (e.g. approx. 6 ms slower, when output on i.MX6 with 115200 baud). + info. Disabling this option could be useful to reduce SPL boot time + (e.g. approx. 6 ms faster, when output on i.MX6 with 115200 baud). config SPL_DISPLAY_PRINT bool "Display a board-specific message in SPL" diff --git a/common/spl/spl.c b/common/spl/spl.c index 23be33c5c10..5a026b844e9 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -607,7 +607,7 @@ void preloader_console_init(void) gd->have_console = 1; -#ifndef CONFIG_SPL_DISABLE_BANNER_PRINT +#if CONFIG_IS_ENABLED(BANNER_PRINT) puts("\nU-Boot " SPL_TPL_NAME " " PLAIN_VERSION " (" U_BOOT_DATE " - " U_BOOT_TIME " " U_BOOT_TZ ")\n"); #endif From patchwork Fri Nov 16 01:43:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998705 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1cV6bBjz9sBQ for ; Fri, 16 Nov 2018 12:59:06 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 96DDDC22248; Fri, 16 Nov 2018 01:51:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C4C35C22269; Fri, 16 Nov 2018 01:46:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7A92EC21F97; Fri, 16 Nov 2018 01:44:41 +0000 (UTC) Received: from mail-it1-f201.google.com (mail-it1-f201.google.com [209.85.166.201]) by lists.denx.de (Postfix) with ESMTPS id 4CF85C2224B for ; Fri, 16 Nov 2018 01:44:38 +0000 (UTC) Received: by mail-it1-f201.google.com with SMTP id m123-v6so26111138ite.6 for ; Thu, 15 Nov 2018 17:44:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=nGKLHGOhDioNITYTQt04jfDFv3lNvkz/QK7l2PNxppY=; b=IYanR0UGLI7L+CZS62xMfFt9p0BK4i3RFCxP/7OH7cryOAIgix+FZ6ajgtlEckbz2Z Elruw6esNSfg1o91IPqmdLiNCmiFr42W335jAT2/cbYXZQS5QU7GeUipOZ9MJelZap3T SlH6drJWZo1Pr0yBoNiLCRync62cd6K/lR7zKzGTay7ECJyPNvsIFCScCgXpD6rFqQX3 fK//1nopjxiqSrPdhtCAnCZdHwKNwd7UD+R+gmQmvzsEfnDJXwoYYEA6nySWyGhDcPXC glQAIjw+c71NZPaLZYsLZE2Xu/bjXLHajHpA1jAlQ03WNUnIYimN31U6mswHdlSfrq37 BOKw== X-Gm-Message-State: AGRZ1gJBVhbaJQoeUmephcf1NPBi0AUU361nOCybwGTqrdwRSszI8U/G nSIIMrqzKW/erJG9WKjjJc7Vzas= X-Google-Smtp-Source: AJdET5cW6g0fepzD6qaszpzj9X88X2cBslM7G1tJxAl/LopAaCvZCIm4xJtHBQJzaks0Srl5Xi/MowY= X-Received: by 2002:a24:648e:: with SMTP id t136-v6mr2018679itc.25.1542332677429; Thu, 15 Nov 2018 17:44:37 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:58 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-11-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 10/21] spl: Add a comment to spl_set_bd() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" There is a strange feature to set global_data to a data-section variable early in SPL. This only works if SPL actually has access to SRAM which is not the case on x86, for eaxmple. Add a comment to this effect. Reviewed-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/spl/spl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/spl/spl.c b/common/spl/spl.c index 5a026b844e9..43137105bab 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -378,6 +378,10 @@ static int spl_common_init(bool setup_malloc) void spl_set_bd(void) { + /* + * NOTE: On some platforms (e.g. x86) bdata may be in flash and not + * writeable. + */ if (!gd->bd) gd->bd = &bdata; } From patchwork Fri Nov 16 01:43:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998699 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1X70VvWz9sBQ for ; Fri, 16 Nov 2018 12:55:19 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C17DFC22247; Fri, 16 Nov 2018 01:48:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 930A4C221C6; Fri, 16 Nov 2018 01:45:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 521A7C2224D; Fri, 16 Nov 2018 01:44:43 +0000 (UTC) Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) by lists.denx.de (Postfix) with ESMTPS id AD554C22269 for ; Fri, 16 Nov 2018 01:44:39 +0000 (UTC) Received: by mail-io1-f73.google.com with SMTP id y14-v6so20982991ioa.22 for ; Thu, 15 Nov 2018 17:44:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=oxCnw9xC6YlMywe2YOAABrOBHvWD6SrMJQWa74lpsRQ=; b=d4h0e1KWTb1RGFLqI5emqmse8MBXCC9uzbGlO4YkkxOtfFYozmRaxaDISm/MfESxUo NrsLiBUWPBcnDZqcEBSOYL6pLcvraV9zK+Smd4iEokbpHIw5OLTDG1/K9mY1vD9Z89Ih xpzKzVQAHXgWHCmK4l/DXY9yT0rawXz9yffOk8cSImG7ZQmThYl1niDqCJfH/+JLV0/m bFC1rZDXr6uKNYPo0rpdvK1cwtTbbwq5tyW7kjze0qiKvgrG/1DxRfgS7iaX65Fa3x6N iAlMnjQVVhXkGikkJKddM4ID4xGQoCjpNUXYN9YZfMlfK7PvSlspeJ1cWOE0d67YBaab rqBg== X-Gm-Message-State: AGRZ1gKzRy5OHCWf3nQZBgGATv9yRM1DtzWDzicsEqYEX8++LqBpANQN Hk1tIIB90wBkYgWJ470mKrWB72k= X-Google-Smtp-Source: AJdET5ciNnOdPIZ9NSHq6Vndy14iUcnLAcMuCqWYO1RGC3Rkd/j3VodOu49x7F46wXvpq8EBwHp1CpI= X-Received: by 2002:a24:70c2:: with SMTP id f185-v6mr2159351itc.16.1542332678811; Thu, 15 Nov 2018 17:44:38 -0800 (PST) Date: Thu, 15 Nov 2018 18:43:59 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-12-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 11/21] sandbox: Add a memory map to the sandbox README X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We have a few things in the memory map now, so add documentation for this to avoid confusion. Also note that it is possible to run all tests now. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None board/sandbox/README.sandbox | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/board/sandbox/README.sandbox b/board/sandbox/README.sandbox index a28fc9f36c1..6d85901b38d 100644 --- a/board/sandbox/README.sandbox +++ b/board/sandbox/README.sandbox @@ -418,7 +418,19 @@ coverage in U-Boot is limited, as we need to work to improve it. Note that many of these tests are implemented as commands which you can run natively on your board if desired (and enabled). -It would be useful to have a central script to run all of these. +To run all tests use "make check". + + +Memory Map +---------- + +Sandbox has its own emulated memory starting at 0. Here are some of the things +that are mapped into that memory: + + 0 CONFIG_SYS_FDT_LOAD_ADDR Device tree + e000 CONFIG_BLOBLIST_ADDR Blob list + 10000 CONFIG_MALLOC_F_ADDR Early memory allocation + -- Simon Glass From patchwork Fri Nov 16 01:44:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998704 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1bp3hhsz9sBQ for ; Fri, 16 Nov 2018 12:58:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 249E2C22245; Fri, 16 Nov 2018 01:50:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 650F8C224BA; Fri, 16 Nov 2018 01:46:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 883F4C223BA; Fri, 16 Nov 2018 01:44:45 +0000 (UTC) Received: from mail-it1-f202.google.com (mail-it1-f202.google.com [209.85.166.202]) by lists.denx.de (Postfix) with ESMTPS id 2FFC6C22214 for ; Fri, 16 Nov 2018 01:44:41 +0000 (UTC) Received: by mail-it1-f202.google.com with SMTP id 135-v6so16365794itz.1 for ; Thu, 15 Nov 2018 17:44:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=dZpL44NFcJHhE7IYlv9YlbQBR4L2yV0omtubCZ5fwmI=; b=nerQYerrKyRTHqtA5AlVLjWIr6jZ8rbR2PI0UYKKY+oYjVS8jWys4AQHhpDKUdazEY cLvuhD2rCSD/3O+TjM2ozDGKyzlyOrztO+lAsTIKePQZiIFirV5yyYoigwgYsWdbXuHX iPlDL93b81/7grO/wBt7Gd6wbIkXG5we0q9jDIq03ceCIvLhm9Ej3jV1594t19TnuCOd 52pQVRJcgov2rY3TJiLxxP5zZ9akpEj40uHpG9CF5JrDxK1k/7UFzaAV+fbZZxO3ohFC VaJ50cEsPKwAO1QsuV6AXyWFlEyd4CATTap0TWoxmM60aWbspuolHd6//2D0YGEV22r3 mk3w== X-Gm-Message-State: AGRZ1gKfax2ajgwLRmhnTW3SHpvpM80YssQqufyWTbrH9hRGMIi/k4x+ sw5zHJDdXljvtYszhGEzpy6Ynbs= X-Google-Smtp-Source: AJdET5eYPHqF+B8chS/wDIwLB5FqX+xRJyBg+nY8bWIMx41OC1OS8sQZYtoarD107sQn+vUBR1McGRs= X-Received: by 2002:a24:21cd:: with SMTP id e196-v6mr2107879ita.23.1542332680298; Thu, 15 Nov 2018 17:44:40 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:00 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-13-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Stephen Warren Subject: [U-Boot] [PATCH v3 12/21] test/py: Add a way to pass flags to sandbox X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" It is sometimes useful to restart sandbox with some particular flags to test certain functionality. Add a new method to ConsoleSandbox to handle this, without changing the existing APIs. Signed-off-by: Simon Glass Acked-by: Stephen Warren --- Changes in v3: None Changes in v2: - Add back a blank line, and put one in the new function too test/py/u_boot_console_sandbox.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py index 778f6d0983d..836f5a9e2b8 100644 --- a/test/py/u_boot_console_sandbox.py +++ b/test/py/u_boot_console_sandbox.py @@ -24,6 +24,7 @@ class ConsoleSandbox(ConsoleBase): """ super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024) + self.sandbox_flags = [] def get_spawn(self): """Connect to a fresh U-Boot instance. @@ -51,8 +52,25 @@ class ConsoleSandbox(ConsoleBase): '-d', self.config.dtb ] + cmd += self.sandbox_flags return Spawn(cmd, cwd=self.config.source_dir) + def restart_uboot_with_flags(self, flags): + """Run U-Boot with the given command-line flags + + Args: + flags: List of flags to pass, each a string + + Returns: + A u_boot_spawn.Spawn object that is attached to U-Boot. + """ + + try: + self.sandbox_flags = flags + return self.restart_uboot() + finally: + self.sandbox_flags = [] + def kill(self, sig): """Send a specific Unix signal to the sandbox process. From patchwork Fri Nov 16 01:44:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998693 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1TK03jkz9s1x for ; Fri, 16 Nov 2018 12:52:52 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B8314C22230; Fri, 16 Nov 2018 01:50:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9D5D0C2224F; Fri, 16 Nov 2018 01:46:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8A08FC224AA; Fri, 16 Nov 2018 01:44:47 +0000 (UTC) Received: from mail-oi1-f202.google.com (mail-oi1-f202.google.com [209.85.167.202]) by lists.denx.de (Postfix) with ESMTPS id 939D4C2222D for ; Fri, 16 Nov 2018 01:44:43 +0000 (UTC) Received: by mail-oi1-f202.google.com with SMTP id s67-v6so9238341oib.20 for ; Thu, 15 Nov 2018 17:44:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=U1nfzcx3qZFuL1Uy5l0SvKDdyntz/5Ed47vbajWm6Eg=; b=GptzVx11T67FRul8Ij6PQ7wIVwq+Z641vkgZ+fE7Sg8OYxpY/4rsp5AJ+P9cseyq7N tFFcOiHDJwSA1JTsMj+2Cm7lZAui5R0/MSd1mt6YKnxDJ1YyDLJeWiQayJjT5c0pXXue UsSEhCYRCZpF4H/lO7btGaHQcWD3n5LGcHG2Vgf65V2j7WEpPNE6fc7/qij4HP0YOfUg dOHkHgkyfMnXO0/DWz0eyPcwHAVSt3G7xXXnAj6G8rll0P6a0iUrTikpPVm18+xKId1/ 78JCmKb8cfnm72ueEzjYz/ioJ/hRNPyGPrsOHIgekJIRQHNMtgyWnQ3+qPjDZtRI7Vq9 OX8w== X-Gm-Message-State: AA+aEWYFLkBzFB2ap/9OMWhcVZ3z2P2i2QIEZoyMjGQtGOTqtcIFMPLl bYl2adMHn+//fTMbGEnpyrIIV4o= X-Google-Smtp-Source: AJdET5dc86bm8CwyC54hWLhhwGdc3JwYP+zGRlFuLbeaZegVcaHTb+AL8vq9zQn7yv8OUkQcL1VOo+4= X-Received: by 2002:a9d:c8c:: with SMTP id b12mr1986130otb.16.1542332682520; Thu, 15 Nov 2018 17:44:42 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:01 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-14-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 13/21] sandbox: Add an option to display of-platdata in SPL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present we don't have a test that of-platdata can be accessed in SPL. Add this in as a command-line option to SPL. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: - Drop the wildcard in the .lds file as it is not needed arch/sandbox/cpu/spl.c | 14 ++++++++++++++ arch/sandbox/cpu/start.c | 9 +++++++++ arch/sandbox/cpu/u-boot-spl.lds | 2 +- arch/sandbox/include/asm/state.h | 1 + test/py/tests/test_ofplatdata.py | 31 ++++++++++++++++++++++++++++++- 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 42c149a4981..49f98644c02 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -44,5 +44,19 @@ SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image); void spl_board_init(void) { + struct sandbox_state *state = state_get_current(); + struct udevice *dev; + preloader_console_init(); + if (state->show_of_platdata) { + /* + * Scan all the devices so that we can output their platform + * data. See sandbox_spl_probe(). + */ + printf("Scanning misc devices\n"); + for (uclass_first_device(UCLASS_MISC, &dev); + dev; + uclass_next_device(&dev)) + ; + } } diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 2ee3b485657..28ca35392c9 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -283,6 +283,15 @@ static int sandbox_cmdline_cb_log_level(struct sandbox_state *state, SANDBOX_CMDLINE_OPT_SHORT(log_level, 'L', 1, "Set log level (0=panic, 7=debug)"); +static int sandbox_cmdline_cb_show_of_platdata(struct sandbox_state *state, + const char *arg) +{ + state->show_of_platdata = true; + + return 0; +} +SANDBOX_CMDLINE_OPT(show_of_platdata, 0, "Show of-platdata in SPL"); + int board_run_command(const char *cmdline) { printf("## Commands are disabled. Please enable CONFIG_CMDLINE.\n"); diff --git a/arch/sandbox/cpu/u-boot-spl.lds b/arch/sandbox/cpu/u-boot-spl.lds index f97abdfa050..de65b01b33c 100644 --- a/arch/sandbox/cpu/u-boot-spl.lds +++ b/arch/sandbox/cpu/u-boot-spl.lds @@ -14,7 +14,7 @@ SECTIONS } __u_boot_sandbox_option_start = .; - _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) } + _u_boot_sandbox_getopt : { KEEP(*(.u_boot_sandbox_getopt)) } __u_boot_sandbox_option_end = .; __bss_start = .; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index dcb6d5f5683..0a2e3c41ae3 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -89,6 +89,7 @@ struct sandbox_state { bool skip_delays; /* Ignore any time delays (for test) */ bool show_test_output; /* Don't suppress stdout in tests */ int default_log_level; /* Default log level for sandbox */ + bool show_of_platdata; /* Show of-platdata in SPL */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS] diff --git a/test/py/tests/test_ofplatdata.py b/test/py/tests/test_ofplatdata.py index dd8a09f0324..98103ee71a9 100644 --- a/test/py/tests/test_ofplatdata.py +++ b/test/py/tests/test_ofplatdata.py @@ -3,11 +3,40 @@ import pytest -OF_PLATDATA_OUTPUT = '' +OF_PLATDATA_OUTPUT = ''' +of-platdata probe: +bool 1 +byte 05 +bytearray 06 00 00 +int 1 +intarray 2 3 4 0 +longbytearray 09 0a 0b 0c 0d 0e 0f 10 11 +string message +stringarray "multi-word" "message" "" +of-platdata probe: +bool 0 +byte 08 +bytearray 01 23 34 +int 3 +intarray 5 0 0 0 +longbytearray 09 00 00 00 00 00 00 00 00 +string message2 +stringarray "another" "multi-word" "message" +of-platdata probe: +bool 0 +byte 00 +bytearray 00 00 00 +int 0 +intarray 0 0 0 0 +longbytearray 00 00 00 00 00 00 00 00 00 +string +stringarray "one" "" "" +''' @pytest.mark.buildconfigspec('spl_of_platdata') def test_ofplatdata(u_boot_console): """Test that of-platdata can be generated and used in sandbox""" cons = u_boot_console + cons.restart_uboot_with_flags(['--show_of_platdata']) output = cons.get_spawn_output().replace('\r', '') assert OF_PLATDATA_OUTPUT in output From patchwork Fri Nov 16 01:44:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998688 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1Pc4SrKz9s47 for ; Fri, 16 Nov 2018 12:49:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 444F6C22244; Fri, 16 Nov 2018 01:48:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 30726C22273; Fri, 16 Nov 2018 01:45:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1126BC22214; Fri, 16 Nov 2018 01:44:49 +0000 (UTC) Received: from mail-io1-f74.google.com (mail-io1-f74.google.com [209.85.166.74]) by lists.denx.de (Postfix) with ESMTPS id 1CE35C22251 for ; Fri, 16 Nov 2018 01:44:45 +0000 (UTC) Received: by mail-io1-f74.google.com with SMTP id c25-v6so3246141ioi.18 for ; Thu, 15 Nov 2018 17:44:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=46mQ22k+T2Pd0YxZvVznQve1TPMEAlMYB+5fOoZh8Tw=; b=TdC1GEqAWOsLyxQ8Jv4oi9Slig4U1Scd1kMXKdmJpX8lxrbBa2zQkwe5WFGfNMCix+ oJBQhhg7VkTh0hU4TN8dniSSnnAmKlr3sHRoUXI5ZioxXe5J5ZJfSc565gWBEMkRLUNX p9ekM9ZdtePMJ9M7yCBteFGMSkZbC2GtpbYybYwNDirqssLtg482D3EErGWVSDqKXbzS ECa+fCVD6NKqaN77xPdHp5ThbkTURyhjsHfYURfIvBk4vt9LcACSkRde/Zfu3x0iFQeM 2HJCyJ1rcWYYCycSmsvRdy1z8jtFeAHC5qE45hExsRL0NVL+P/E7mJVUuAmOMY1Ogunj wptA== X-Gm-Message-State: AGRZ1gKpimusH6JoPaDxGgnuNxgRj74MPUWuB5VeOrz6yRnDxFUphg3Q K3tu5JDLT+Pf2ss3mc++JwFuEAc= X-Google-Smtp-Source: AJdET5dHr9lR8DiHUnGv1WBOuXxSWdOWRpxJ1/RzWjxQHzH2TvqjPdV9zoaK1CY4ps7Oph/vVSAeONs= X-Received: by 2002:a24:8903:: with SMTP id s3-v6mr2165025itd.26.1542332684223; Thu, 15 Nov 2018 17:44:44 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:02 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-15-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 14/21] sandbox: Drop the deprecated 'sb' command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The old 'sb' command was deprecated in 2015 and replaced with 'host'. Remove the remaining users and the command, so that the name is available for other purposes. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None cmd/host.c | 5 ----- doc/README.trace | 2 +- test/dm/sf.c | 2 +- test/py/tests/test_fit.py | 12 ++++++------ test/py/tests/test_vboot.py | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cmd/host.c b/cmd/host.c index 645dba4de83..f7d3eae5b1a 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -167,11 +167,6 @@ static int do_host(cmd_tbl_t *cmdtp, int flag, int argc, return CMD_RET_USAGE; } -U_BOOT_CMD( - sb, 8, 1, do_host, - "Deprecated: use 'host' command instead.", "" -); - U_BOOT_CMD( host, 8, 1, do_host, "Miscellaneous host commands", diff --git a/doc/README.trace b/doc/README.trace index 74ba26a5a48..2e7ca3319a9 100644 --- a/doc/README.trace +++ b/doc/README.trace @@ -88,7 +88,7 @@ stdin=serial stdout=serial Environment size: 117/8188 bytes -=>sb save host 0 trace 0 ${profoffset} +=>host save host 0 trace 0 ${profoffset} 11405888 bytes written in 10 ms (1.1 GiB/s) =>reset diff --git a/test/dm/sf.c b/test/dm/sf.c index 35241b9f574..af49d7a2129 100644 --- a/test/dm/sf.c +++ b/test/dm/sf.c @@ -28,7 +28,7 @@ static int dm_test_spi_flash(struct unit_test_state *uts) * benefit is worth the extra complexity. */ ut_asserteq(0, run_command_list( - "sb save hostfs - 0 spi.bin 200000;" + "host save hostfs - 0 spi.bin 200000;" "sf probe;" "sf test 0 10000", -1, 0)); /* diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index 34696e97679..49d6fea5716 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -99,15 +99,15 @@ base_fdt = ''' # then run the 'bootm' command, then save out memory from the places where # we expect 'bootm' to write things. Then quit. base_script = ''' -sb load hostfs 0 %(fit_addr)x %(fit)s +host load hostfs 0 %(fit_addr)x %(fit)s fdt addr %(fit_addr)x bootm start %(fit_addr)x bootm loados -sb save hostfs 0 %(kernel_addr)x %(kernel_out)s %(kernel_size)x -sb save hostfs 0 %(fdt_addr)x %(fdt_out)s %(fdt_size)x -sb save hostfs 0 %(ramdisk_addr)x %(ramdisk_out)s %(ramdisk_size)x -sb save hostfs 0 %(loadables1_addr)x %(loadables1_out)s %(loadables1_size)x -sb save hostfs 0 %(loadables2_addr)x %(loadables2_out)s %(loadables2_size)x +host save hostfs 0 %(kernel_addr)x %(kernel_out)s %(kernel_size)x +host save hostfs 0 %(fdt_addr)x %(fdt_out)s %(fdt_size)x +host save hostfs 0 %(ramdisk_addr)x %(ramdisk_out)s %(ramdisk_size)x +host save hostfs 0 %(loadables1_addr)x %(loadables1_out)s %(loadables1_size)x +host save hostfs 0 %(loadables2_addr)x %(loadables2_out)s %(loadables2_size)x ''' @pytest.mark.boardspec('sandbox') diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py index e9cbd57fbab..92144d4c1e3 100644 --- a/test/py/tests/test_vboot.py +++ b/test/py/tests/test_vboot.py @@ -74,7 +74,7 @@ def test_vboot(u_boot_console): cons.restart_uboot() with cons.log.section('Verified boot %s %s' % (sha_algo, test_type)): output = cons.run_command_list( - ['sb load hostfs - 100 %stest.fit' % tmpdir, + ['host load hostfs - 100 %stest.fit' % tmpdir, 'fdt addr 100', 'bootm 100']) assert(expect_string in ''.join(output)) From patchwork Fri Nov 16 01:44:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998700 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1X83Ycrz9s47 for ; Fri, 16 Nov 2018 12:55:20 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 339E9C22071; Fri, 16 Nov 2018 01:49:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CD19EC22492; Fri, 16 Nov 2018 01:45:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 850ADC2224D; Fri, 16 Nov 2018 01:44:51 +0000 (UTC) Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) by lists.denx.de (Postfix) with ESMTPS id 065A8C22246 for ; Fri, 16 Nov 2018 01:44:47 +0000 (UTC) Received: by mail-io1-f73.google.com with SMTP id o8-v6so21189553iom.6 for ; Thu, 15 Nov 2018 17:44:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pF3SuN5nMrev/FNKk9EpOfOJRdl2LMtNvY/uMDVit+w=; b=GMIww1AiEfBrUrqMB7i6I5+1Q06w4WmZFXaPhczltp40B82vUWNqHOnshzMeGxA45K lq9PGMEoO7lpd8d3rAbIqH5CBiXVdax2dyfWPOledTGTcp8yk8GHTzuPqAYajNNNeYah p9IvWbDo9daRq102OIitshioNgoN+gJEIA9tR24T3IYJmBuGRWWtOL0FQpfJMo8itZf9 +f89rCXeTCEe925UrTJL7n8FSr8D6UVK7qSv0JZw0L2mdtNTW9nsXT9qjtmI90Je2MMO H5SdO1y777x/2+/LOvKL5tJ5uqifs8yUu8e3YFDVBPgsZrCfZAq6RhN0fYpD4X9GW8Ky FSSw== X-Gm-Message-State: AGRZ1gLd/yk7uGKpevJxJBIqOxR4yslvjfIBhYk2BM+4ynymqf4oEbN9 0odwXWp5s48sf5pjOTJKIWhYgDQ= X-Google-Smtp-Source: AJdET5dsVBDKBPrae56E0GI9mNfJPsrqWyh2PAxb0t0kEzfJLUA1yrCSAsFokZua4OsrqL9vKo1FEFs= X-Received: by 2002:a24:4dd2:: with SMTP id l201-v6mr2012806itb.15.1542332686109; Thu, 15 Nov 2018 17:44:46 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:03 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-16-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 15/21] sandbox: Add a new 'sb' command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The old 'sb' command was deprecated in 2015 and replaced with 'host'. It is useful to be able to access some internal sandbox state, particularly for testing. Resurrect the old command and provide a way to print some basic state information (currently just the arguments to sandbox). Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None arch/sandbox/cpu/start.c | 10 +++++++ arch/sandbox/include/asm/state.h | 7 +++++ cmd/Makefile | 1 + cmd/sb.c | 46 ++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 cmd/sb.c diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 28ca35392c9..b1566a81435 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -305,6 +305,16 @@ static void setup_ram_buf(struct sandbox_state *state) gd->ram_size = state->ram_size; } +void state_show(struct sandbox_state *state) +{ + char **p; + + printf("Arguments:\n"); + for (p = state->argv; *p; p++) + printf("%s ", *p); + printf("\n"); +} + int main(int argc, char *argv[]) { struct sandbox_state *state; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 0a2e3c41ae3..8fabe70a86d 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -242,6 +242,13 @@ bool state_get_skip_delays(void); */ void state_reset_for_test(struct sandbox_state *state); +/** + * state_show() - Show information about the sandbox state + * + * @param state Sandbox state to show + */ +void state_show(struct sandbox_state *state); + /** * Initialize the test system state */ diff --git a/cmd/Makefile b/cmd/Makefile index 12a1330b062..68f22f1af91 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -114,6 +114,7 @@ obj-$(CONFIG_CMD_ROCKUSB) += rockusb.o obj-$(CONFIG_SANDBOX) += host.o obj-$(CONFIG_CMD_SATA) += sata.o obj-$(CONFIG_CMD_NVME) += nvme.o +obj-$(CONFIG_SANDBOX) += sb.o obj-$(CONFIG_CMD_SF) += sf.o obj-$(CONFIG_CMD_SCSI) += scsi.o disk.o obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o diff --git a/cmd/sb.c b/cmd/sb.c new file mode 100644 index 00000000000..6ca3361d7e3 --- /dev/null +++ b/cmd/sb.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018, Google Inc. + * Written by Simon Glass + */ + +#include +#include +#include +#include + +static int do_sb_state(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + struct sandbox_state *state; + + state = state_get_current(); + state_show(state); + + return 0; +} + +static cmd_tbl_t cmd_sb_sub[] = { + U_BOOT_CMD_MKENT(state, 1, 0, do_sb_state, "", ""), +}; + +static int do_sb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + cmd_tbl_t *c; + + /* Skip past 'sb' */ + argc--; + argv++; + + c = find_cmd_tbl(argv[0], cmd_sb_sub, ARRAY_SIZE(cmd_sb_sub)); + if (c) + return c->cmd(cmdtp, flag, argc, argv); + else + return CMD_RET_USAGE; +} + +U_BOOT_CMD( + sb, 8, 1, do_sb, + "Sandbox status commands", + "state - Show sandbox state" +); From patchwork Fri Nov 16 01:44:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998695 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1Tm2HW6z9sBQ for ; Fri, 16 Nov 2018 12:53:16 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 0C6EAC221C6; Fri, 16 Nov 2018 01:50:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5B22CC2226F; Fri, 16 Nov 2018 01:46:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 47366C22242; Fri, 16 Nov 2018 01:44:52 +0000 (UTC) Received: from mail-io1-f74.google.com (mail-io1-f74.google.com [209.85.166.74]) by lists.denx.de (Postfix) with ESMTPS id D9D17C2224B for ; Fri, 16 Nov 2018 01:44:48 +0000 (UTC) Received: by mail-io1-f74.google.com with SMTP id n22so8545063iob.9 for ; Thu, 15 Nov 2018 17:44:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wyHDOQdBJaDUPYaoB95NWqoAHekmv5e9Zy70/3FRY3w=; b=e5SktcLWlDfJEvfPXxtU4/u82bbu7yulNp1NAJosnXWlepuYL1TfPVLPiL3bjqF4Y0 r0uNKcUN4IeMBY92eJKGdi5+Keq+TCb7A/X8P3itoqQ3owcwT0cvq+qFAno+GusjBrPl Wy3bdZhsXPmilF9P0BKydEGhutIIqwNMFRBkKaLhGDQyBkGegU7wrKlewPpV5t+CSqGA kIyKwjrj36aKchtRHTJZwkK7OTfFfqYWErlEnvBSFMloW0a+eh7H5ROQvlytweou7RR6 xabzHkl9vQ0fg0hc5PpN6T15P4IYagfCR0JTCZ255x49POKg7MSwINxOtwQPf/O7OP1a +Aeg== X-Gm-Message-State: AGRZ1gJ0JeQMSLH7l24rEmMfYZg0nWz4gKqNGC2npGf+RZoBBTpABWH6 lEPpoN3HSNocjRYt/ynsHyOdQIw= X-Google-Smtp-Source: AJdET5e+7GfliJ6+nRMZykeK5InQ7M7XSKfL+Q1isygBbmZAz61CWu3qsypUv2Lq0LnIhAGra+l+XA0= X-Received: by 2002:a24:7d91:: with SMTP id b139mr2124666itc.6.1542332687952; Thu, 15 Nov 2018 17:44:47 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:04 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-17-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Joe Hershberger Subject: [U-Boot] [PATCH v3 16/21] sandbox: Allow puts() output before global_data is set up X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We support putc() in this case but not puts(), but this is more useful since it is what printf() uses. This particularly affects debugging early in SPL, where currently printf() statements result in no output. Fix this by adding a special case into puts() for sandbox, just like putc(). Signed-off-by: Simon Glass Reviewed-by: Joe Hershberger --- Changes in v3: None Changes in v2: None common/console.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/console.c b/common/console.c index 9a94f321922..0b0dd76256c 100644 --- a/common/console.c +++ b/common/console.c @@ -535,6 +535,13 @@ void putc(const char c) void puts(const char *s) { +#ifdef CONFIG_SANDBOX + /* sandbox can send characters to stdout before it has a console */ + if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) { + os_puts(s); + return; + } +#endif #ifdef CONFIG_DEBUG_UART if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) { while (*s) { From patchwork Fri Nov 16 01:44:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998696 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1Vl4ndHz9s47 for ; Fri, 16 Nov 2018 12:54:07 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6D286C22248; Fri, 16 Nov 2018 01:49:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E8DA4C224A9; Fri, 16 Nov 2018 01:45:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 92E0BC22256; Fri, 16 Nov 2018 01:44:54 +0000 (UTC) Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) by lists.denx.de (Postfix) with ESMTPS id 59FC4C22244 for ; Fri, 16 Nov 2018 01:44:50 +0000 (UTC) Received: by mail-io1-f73.google.com with SMTP id w22-v6so21245112ioc.5 for ; Thu, 15 Nov 2018 17:44:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=y0BsP13loutGLbz9y9o61VJh7rEsevHK5XKCdE2uFyg=; b=RZqoIPExRkrC/qdXxiTrgMD1ofDyQg3ds1KCQYSqLX05o+4drxatmAPUGk+UxA1eHb FdaXTiWKoDw+wVvU/6ZZi9MfnIHE8TSqWp9kUTZOaryn1h9d2o9hsQosDg09P34IezNw BqtFW1LtDuzUyYF0ZOqL2xz0dllGMttHhkM1dzrwfLnAzKfJxXkE1eb8igL7sEdSvwX1 3pHHrWy0tu/QgtsU9loEplQyemKKkImOg2BiYZtFZ11rmTtBbNbDmC/ndCz5k13PW3ry 5InrwAXvm4gDrX9o3B07/r7hAcoF69mNZN6SI+0RBPpmtdPvXX2162E8Q1JtgI/3dtXj 2CPw== X-Gm-Message-State: AGRZ1gI0dSh8YIsaYgj9eO+nMMqXNlBagQ/2AWAajL8yGecq/9ApApBc zJXUooOLKxZxvBYz49PWKodO/Ho= X-Google-Smtp-Source: AJdET5dh5JxMX7hIrZAuHvT6J2Q9kXBIyEXx7LN9y8RNasE5l7sFpCpBERPgijE00v4+3UKpl+UIbV4= X-Received: by 2002:a24:284e:: with SMTP id h75-v6mr2124312ith.1.1542332689469; Thu, 15 Nov 2018 17:44:49 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:05 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-18-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 17/21] sandbox: Refactor code to create os_jump_to_file() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present os_jump_to_image() jumps to a given image, and this is written to a file. But it is useful to be able to jump to a file also. To avoid duplicating code, split out the implementation of os_jump_to_image() into a new function that jumps to a file. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None arch/sandbox/cpu/os.c | 48 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 325ded51d8a..b4d7a252b54 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -525,7 +525,18 @@ static int make_exec(char *fname, const void *data, int size) return 0; } -static int add_args(char ***argvp, const char *add_args[], int count) +/** + * add_args() - Allocate a new argv with the given args + * + * This is used to create a new argv array with all the old arguments and some + * new ones that are passed in + * + * @argvp: Returns newly allocated args list + * @add_args: Arguments to add, each a string + * @count: Number of arguments in @add_args + * @return 0 if OK, -ENOMEM if out of memory + */ +static int add_args(char ***argvp, char *add_args[], int count) { char **argv; int argc; @@ -546,21 +557,26 @@ static int add_args(char ***argvp, const char *add_args[], int count) return 0; } -int os_jump_to_image(const void *dest, int size) +/** + * os_jump_to_file() - Jump to a new program + * + * This saves the memory buffer, sets up arguments to the new process, then + * execs it. + * + * @fname: Filename to exec + * @return does not return on success, any return value is an error + */ +static int os_jump_to_file(const char *fname) { struct sandbox_state *state = state_get_current(); - char fname[30], mem_fname[30]; + char mem_fname[30]; int fd, err; - const char *extra_args[5]; + char *extra_args[5]; char **argv = state->argv; #ifdef DEBUG - int argc, i; + int i; #endif - err = make_exec(fname, dest, size); - if (err) - return err; - strcpy(mem_fname, "/tmp/u-boot.mem.XXXXXX"); fd = mkstemp(mem_fname); if (fd < 0) @@ -573,7 +589,7 @@ int os_jump_to_image(const void *dest, int size) os_fd_restore(); extra_args[0] = "-j"; - extra_args[1] = fname; + extra_args[1] = (char *)fname; extra_args[2] = "-m"; extra_args[3] = mem_fname; extra_args[4] = "--rm_memory"; @@ -598,6 +614,18 @@ int os_jump_to_image(const void *dest, int size) return unlink(fname); } +int os_jump_to_image(const void *dest, int size) +{ + char fname[30]; + int err; + + err = make_exec(fname, dest, size); + if (err) + return err; + + return os_jump_to_file(fname); +} + int os_find_u_boot(char *fname, int maxlen) { struct sandbox_state *state = state_get_current(); From patchwork Fri Nov 16 01:44:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998698 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1X55ZbWz9s47 for ; Fri, 16 Nov 2018 12:55:17 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7716CC2222D; Fri, 16 Nov 2018 01:51:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id AF499C224CF; Fri, 16 Nov 2018 01:46:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B1DB8C221A1; Fri, 16 Nov 2018 01:44:56 +0000 (UTC) Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by lists.denx.de (Postfix) with ESMTPS id 1A666C2220C for ; Fri, 16 Nov 2018 01:44:52 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id 67so48031958qkj.18 for ; Thu, 15 Nov 2018 17:44:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=l0A6JoxUn3+UNfHmSI7f6icLSSbfA4gikAfsXQTzyYA=; b=bluvQnBXO1pCwU5An7TidhTmzwNjSO0u0X6YZAQLDyD0ByMkjCxyHF9sLbR1tQOrzT 4KqcTOGEibsMwE8HopyJB16Zn85SHaqyc0RZLdYRs0oXFw9++w8hWv0DfW7JQggo9I5a FEChUrlW5YzR1jpgpHTfZJLNO2iV0YokSMmENlv6aCdNC3PIrPjvrY+qo9BLjJIhVx8b B5WNmqDFYRvoxUbmYwbWuZMQv3Mp5mrxu8KLN2jqy9slTqvPIO5G9WC/NaAkYs2Yu9do RVYyWm6QxUCF/McCe60mk17U/bvWNsl05/enWDS9cGc9QY7s84PGOIEjqAsTXA1y+BlJ rDJw== X-Gm-Message-State: AGRZ1gLdfN0IIihkiHtJbBCtMVoRz8fN0JNNRl4rOIwo5AmaItciBIF4 Rk+fJ7nQaYqrHB8zVGD/yfR3xgQ= X-Google-Smtp-Source: AFSGD/XxJBiWIZ0sk0WfLFkTwH+0ewHqfU0NpoVD+OoSIbvS+R++BkNIOoqyMQudmMS3NG3GuiihQcs= X-Received: by 2002:aed:3c74:: with SMTP id u49mr2017074qte.19.1542332691246; Thu, 15 Nov 2018 17:44:51 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:06 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-19-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Joe Hershberger Subject: [U-Boot] [PATCH v3 18/21] sandbox: Use malloc() and free() from os layer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present sandbox calls malloc() from various places in the OS layer and this results in calls to U-Boot's malloc() implementation. It is better to use the on in the OS layer, since it does not mix allocations with the main U-Boot code. Fix this by replacing calls with malloc() to os_malloc(), etc. Signed-off-by: Simon Glass Reviewed-by: Joe Hershberger --- Changes in v3: None Changes in v2: None arch/sandbox/cpu/eth-raw-os.c | 9 ++++++--- arch/sandbox/cpu/os.c | 18 +++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c index 75bfaa4c90a..8d05bc2eda0 100644 --- a/arch/sandbox/cpu/eth-raw-os.c +++ b/arch/sandbox/cpu/eth-raw-os.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,8 @@ #include #include +#include + struct sandbox_eth_raw_if_nameindex *sandbox_eth_raw_if_nameindex(void) { return (struct sandbox_eth_raw_if_nameindex *)if_nameindex(); @@ -71,7 +74,7 @@ static int _raw_packet_start(struct eth_sandbox_raw_priv *priv, /* Prepare device struct */ priv->local_bind_sd = -1; - priv->device = malloc(sizeof(struct sockaddr_ll)); + priv->device = os_malloc(sizeof(struct sockaddr_ll)); if (priv->device == NULL) return -ENOMEM; device = priv->device; @@ -144,7 +147,7 @@ static int _local_inet_start(struct eth_sandbox_raw_priv *priv) /* Prepare device struct */ priv->local_bind_sd = -1; priv->local_bind_udp_port = 0; - priv->device = malloc(sizeof(struct sockaddr_in)); + priv->device = os_malloc(sizeof(struct sockaddr_in)); if (priv->device == NULL) return -ENOMEM; device = priv->device; @@ -279,7 +282,7 @@ int sandbox_eth_raw_os_recv(void *packet, int *length, void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv) { - free(priv->device); + os_free(priv->device); priv->device = NULL; close(priv->sd); priv->sd = -1; diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index b4d7a252b54..d3dc74db4b1 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -343,7 +343,7 @@ void os_dirent_free(struct os_dirent_node *node) while (node) { next = node->next; - free(node); + os_free(node); node = next; } } @@ -368,7 +368,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) /* Create a buffer upfront, with typically sufficient size */ dirlen = strlen(dirname) + 2; len = dirlen + 256; - fname = malloc(len); + fname = os_malloc(len); if (!fname) { ret = -ENOMEM; goto done; @@ -381,7 +381,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) ret = errno; break; } - next = malloc(sizeof(*node) + strlen(entry->d_name) + 1); + next = os_malloc(sizeof(*node) + strlen(entry->d_name) + 1); if (!next) { os_dirent_free(head); ret = -ENOMEM; @@ -390,10 +390,10 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) if (dirlen + strlen(entry->d_name) > len) { len = dirlen + strlen(entry->d_name); old_fname = fname; - fname = realloc(fname, len); + fname = os_realloc(fname, len); if (!fname) { - free(old_fname); - free(next); + os_free(old_fname); + os_free(next); os_dirent_free(head); ret = -ENOMEM; goto done; @@ -427,7 +427,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) done: closedir(dir); - free(fname); + os_free(fname); return ret; } @@ -544,7 +544,7 @@ static int add_args(char ***argvp, char *add_args[], int count) for (argv = *argvp, argc = 0; (*argvp)[argc]; argc++) ; - argv = malloc((argc + count + 1) * sizeof(char *)); + argv = os_malloc((argc + count + 1) * sizeof(char *)); if (!argv) { printf("Out of memory for %d argv\n", count); return -ENOMEM; @@ -607,7 +607,7 @@ static int os_jump_to_file(const char *fname) os_exit(2); err = execv(fname, argv); - free(argv); + os_free(argv); if (err) return err; From patchwork Fri Nov 16 01:44:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998697 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1Wj389Fz9s47 for ; Fri, 16 Nov 2018 12:54:57 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 20112C22261; Fri, 16 Nov 2018 01:48:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8A5FCC2225D; Fri, 16 Nov 2018 01:45:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9DA84C22247; Fri, 16 Nov 2018 01:44:58 +0000 (UTC) Received: from mail-io1-f74.google.com (mail-io1-f74.google.com [209.85.166.74]) by lists.denx.de (Postfix) with ESMTPS id 79CB0C2223C for ; Fri, 16 Nov 2018 01:44:54 +0000 (UTC) Received: by mail-io1-f74.google.com with SMTP id e144-v6so21621122iof.13 for ; Thu, 15 Nov 2018 17:44:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+t+7aJnDAofyPzBXZ2ZFDb/StJX2hzQtPGxhc+R5dac=; b=clfOLvwlrRow9jkfhets0Rm4fgxe3KLCF4P2Ev1s2dw63k2VcgJZYQQKkltsV60hHa gf1xKiymHAKqi39c/vShrl/ybf1iB/mw3Et6V/aUo5uaTXnj3m58aUus+exkpK0pkrgz j5MUeG5GwZCHWssMzreIeRRZYyBwFoNI9DUZ9Fj5BHI36ULWc1d6WLhJyOoejhTqLsbC cxa1abQvNIVsZwQamTHZGlpUb+Sq5GyC5KGcK6jECrv4wT9HNOPjrIsIh97AGqqZOBZF TxlBYV4ixaHeqcEzftOUe/uDaDyHslJJ9g0p2uawyEThPTNaCXGDKTR6sCi8sYiFRcj0 enyQ== X-Gm-Message-State: AGRZ1gLFJs/PHd/0nMPaUxCvr0QQ0a4NfmT1UT1t9nOdhU7uLaDz9iyY uwY7qy3uDQcPtjQMwvHUcVaBBl0= X-Google-Smtp-Source: AJdET5fzP/dCUtpqjeFvyo/PcleOOBfTZ1F2WV7K+J9DdukIJTLK4Aj4Rrg/wSJc1J7AaWa7Jdc34bc= X-Received: by 2002:a24:7a4b:: with SMTP id a72-v6mr2076945itc.8.1542332693539; Thu, 15 Nov 2018 17:44:53 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:07 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-20-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 19/21] sandbox: Filter arguments when starting U-Boot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The current method of starting U-Boot from U-Boot adds arguments to pass the memory file through, so that memory is preserved. This is fine for a single call, but if we call from TPL -> SPL -> U-Boot the arguments build up and we have several memory files in the argument list. Adjust the implementation to filter out arguments that we want to replace with new ones. Also print a useful error if the exec() call fails. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None arch/sandbox/cpu/os.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index d3dc74db4b1..5e55d31be9d 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -538,10 +538,10 @@ static int make_exec(char *fname, const void *data, int size) */ static int add_args(char ***argvp, char *add_args[], int count) { - char **argv; + char **argv, **ap; int argc; - for (argv = *argvp, argc = 0; (*argvp)[argc]; argc++) + for (argc = 0; (*argvp)[argc]; argc++) ; argv = os_malloc((argc + count + 1) * sizeof(char *)); @@ -549,7 +549,24 @@ static int add_args(char ***argvp, char *add_args[], int count) printf("Out of memory for %d argv\n", count); return -ENOMEM; } - memcpy(argv, *argvp, argc * sizeof(char *)); + for (ap = *argvp, argc = 0; *ap; ap++) { + char *arg = *ap; + + /* Drop args that we don't want to propagate */ + if (*arg == '-' && strlen(arg) == 2) { + switch (arg[1]) { + case 'j': + case 'm': + ap++; + continue; + } + } else if (!strcmp(arg, "--rm_memory")) { + ap++; + continue; + } + argv[argc++] = arg; + } + memcpy(argv + argc, add_args, count * sizeof(char *)); argv[argc + count] = NULL; @@ -573,6 +590,7 @@ static int os_jump_to_file(const char *fname) int fd, err; char *extra_args[5]; char **argv = state->argv; + int argc; #ifdef DEBUG int i; #endif @@ -592,11 +610,13 @@ static int os_jump_to_file(const char *fname) extra_args[1] = (char *)fname; extra_args[2] = "-m"; extra_args[3] = mem_fname; - extra_args[4] = "--rm_memory"; - err = add_args(&argv, extra_args, - sizeof(extra_args) / sizeof(extra_args[0])); + argc = 4; + if (state->ram_buf_rm) + extra_args[argc++] = "--rm_memory"; + err = add_args(&argv, extra_args, argc); if (err) return err; + argv[0] = (char *)fname; #ifdef DEBUG for (i = 0; argv[i]; i++) From patchwork Fri Nov 16 01:44:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998703 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1Zg393Wz9sBQ for ; Fri, 16 Nov 2018 12:57:31 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3158BC22248; Fri, 16 Nov 2018 01:47:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E205FC22245; Fri, 16 Nov 2018 01:45:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5F47FC22244; Fri, 16 Nov 2018 01:44:58 +0000 (UTC) Received: from mail-it1-f201.google.com (mail-it1-f201.google.com [209.85.166.201]) by lists.denx.de (Postfix) with ESMTPS id 0DD67C21F81 for ; Fri, 16 Nov 2018 01:44:56 +0000 (UTC) Received: by mail-it1-f201.google.com with SMTP id z195-v6so27303428itb.7 for ; Thu, 15 Nov 2018 17:44:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Et2B83lXwuQh5i5TTE517+NEd/H4ROkV6brJEoFoOKI=; b=sDASpgW2Dw9QJJ0JhBZTyKBhEHyPUXqiASejJuR6LiaGqTNrAvV1pRgGSw5VLnUeMi TGL7tBDrpgdewnL6JF9r8/hwfCFghRNbFT9hxnyfL+JCR6lSHDVTJdqHSFDb0Uin8ed3 EoTbJnGPakBUEkcJnWiGEFBT24tbK/ecokWIxXpOBqdMGQzTpVT39sJYE/Sx9NwexV16 jAWoPurKVnxGMpP6dBk61JeSiaWnw9j1D2nPDtv6Dj9EMIWc019VS7qiA2Q1WnsHqTSn pdCitiEBB2YfXtdIGGQDW50sOiBMvtgi2U7hZj+2yLxT1Gw/rMROcT4pfE6WUGRjft2G URbg== X-Gm-Message-State: AGRZ1gKXjSWTvxc4RLX0ZYVsFf6F2QuYZgDngoRwq9KdXeBn38EErFbB dH6x2KW6A3hnS1AadQE/CNQhJ5k= X-Google-Smtp-Source: AJdET5fvS+RSlomuYEt87zk3PVz2RJUTM9a/bDY55OI2+wYUpuaw4+8mAUnOEusVLrTdYj25Zqynvqo= X-Received: by 2002:a05:660c:3cd:: with SMTP id c13mr2202827itl.22.1542332695163; Thu, 15 Nov 2018 17:44:55 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:08 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-21-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH v3 20/21] sandbox: Boot in U-Boot through the standard call X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Most architectures use jump_to_image_no_args() to jump from SPL to U-Boot. At present sandbox is special in that it jumps in its spl_board_load_image() call. This is not strictly correct, and means that sandbox misses out some parts of board_init_r(), just as calling bloblist_finish(), for example. Change spl_board_load_image() to just identify the filename to boot, and implement jump_to_image_no_args() to actually jump to it. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None arch/sandbox/cpu/os.c | 17 +++++------------ arch/sandbox/cpu/spl.c | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 5e55d31be9d..eef4390b294 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -628,8 +628,11 @@ static int os_jump_to_file(const char *fname) err = execv(fname, argv); os_free(argv); - if (err) + if (err) { + perror("Unable to run image"); + printf("Image filename '%s'\n", mem_fname); return err; + } return unlink(fname); } @@ -709,17 +712,7 @@ int os_find_u_boot(char *fname, int maxlen) int os_spl_to_uboot(const char *fname) { - struct sandbox_state *state = state_get_current(); - char *argv[state->argc + 1]; - int ret; - - memcpy(argv, state->argv, sizeof(char *) * (state->argc + 1)); - argv[0] = (char *)fname; - ret = execv(fname, argv); - if (ret) - return ret; - - return unlink(fname); + return os_jump_to_file(fname); } void os_localtime(struct rtc_time *rt) diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 49f98644c02..5005ed2f54a 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -37,8 +37,12 @@ static int spl_board_load_image(struct spl_image_info *spl_image, return ret; } - /* Hopefully this will not return */ - return os_spl_to_uboot(fname); + /* Set up spl_image to boot from jump_to_image_no_args() */ + spl_image->arg = strdup(fname); + if (!spl_image->arg) + return log_msg_ret("Setup exec filename", -ENOMEM); + + return 0; } SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image); @@ -60,3 +64,12 @@ void spl_board_init(void) ; } } + +void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) +{ + const char *fname = spl_image->arg; + + os_fd_restore(); + os_spl_to_uboot(fname); + hang(); +} From patchwork Fri Nov 16 01:44:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 998701 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42x1XF3lXMz9s47 for ; Fri, 16 Nov 2018 12:55:25 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 304C0C22260; Fri, 16 Nov 2018 01:49:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 38479C2223C; Fri, 16 Nov 2018 01:46:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2B759C224AC; Fri, 16 Nov 2018 01:45:02 +0000 (UTC) Received: from mail-vs1-f73.google.com (mail-vs1-f73.google.com [209.85.217.73]) by lists.denx.de (Postfix) with ESMTPS id C1BB2C2225C for ; Fri, 16 Nov 2018 01:44:57 +0000 (UTC) Received: by mail-vs1-f73.google.com with SMTP id v199so4479389vsc.21 for ; Thu, 15 Nov 2018 17:44:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=dVtBNpklhx09i8/LfwgFyU7dwyUMvWgIEaNs4KBIM50=; b=lbnnxFRpG95jPtPcAvvRkgueuoL0ckDgsngJpZNWrxp/t7cSyRwKjOO7rXozu36hQn x/zroSAbKny+MkLyGviQzlH1S1s3Nib+Aebq/0aaRWVYvo+PT75/r1/KrOls69HzuzpW wwvdFkZkdQ9kA58nYsZmavnU2htkqg7qMp4xruIQdwiRYOD2HxabSmfYvdMEThVZmLQb /R4svDLFr6UrKanQqt3lyA18t83+CdtylCxoE9aqdMaeZCBlfRhZAsIPGL1q6br/Pu1W Dr63tU/gK7WLzm/t2bG3SeWt9sn+vCAOkjyGXzlUmJ6r1zIfATtEkNEWMWa54AARhKdC MhAA== X-Gm-Message-State: AA+aEWZzZ2BNamhCNiQwoYnO8xI0uFG2M7aSx+PDKXsJtIX8FHD9tqrE uYLZJ3DGCaV+nINOalt1YjJXxCY= X-Google-Smtp-Source: AJdET5drxvalIojiARiiJWS9gTw9y8HqYsz7rkK4xizGTM7URcnXMoGxxHg9vTlRLL7iY0ugfcM9IBU= X-Received: by 2002:ab0:47c8:: with SMTP id w8mr2458103uac.24.1542332696774; Thu, 15 Nov 2018 17:44:56 -0800 (PST) Date: Thu, 15 Nov 2018 18:44:09 -0700 In-Reply-To: <20181116014409.147279-1-sjg@chromium.org> Message-Id: <20181116014409.147279-22-sjg@chromium.org> Mime-Version: 1.0 References: <20181116014409.147279-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH v3 21/21] spl: Add support for passing handoff info to U-Boot proper X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" There is some basic informaton that SPL normally wants to pass through to U-Boot, such as the SDRAM size and bank information. Mkae use of the new bloblist structure for this. Add a new 'handoff' blob which is set up in SPL and passed to U-Boot proper. Also adda test for sandbox_spl that checks that this works correctly and a new 'sb' command to show the information passed from SPL. Reviewed-by: Tom Rini Signed-off-by: Simon Glass --- Changes in v3: - Drop patch 'spl: Print a message if we are unable to load an image' Changes in v2: None arch/powerpc/include/asm/spl.h | 3 -- arch/sandbox/include/asm/handoff.h | 18 +++++++ cmd/sb.c | 21 +++++++- common/board_f.c | 15 ++++++ common/init/Makefile | 1 + common/init/handoff.c | 47 ++++++++++++++++++ common/spl/Kconfig | 30 ++++++++++++ common/spl/spl.c | 77 +++++++++++++++++++++++++----- configs/sandbox_spl_defconfig | 1 + include/asm-generic/global_data.h | 3 ++ include/handoff.h | 36 ++++++++++++++ include/spl.h | 1 + test/py/tests/test_handoff.py | 14 ++++++ test/run | 2 +- 14 files changed, 252 insertions(+), 17 deletions(-) create mode 100644 arch/sandbox/include/asm/handoff.h create mode 100644 common/init/handoff.c create mode 100644 include/handoff.h create mode 100644 test/py/tests/test_handoff.py diff --git a/arch/powerpc/include/asm/spl.h b/arch/powerpc/include/asm/spl.h index cd6d31c71a7..60a7d37d30b 100644 --- a/arch/powerpc/include/asm/spl.h +++ b/arch/powerpc/include/asm/spl.h @@ -8,7 +8,4 @@ #define BOOT_DEVICE_NOR 1 -/* Linker symbols */ -extern char __bss_start[], __bss_end[]; - #endif diff --git a/arch/sandbox/include/asm/handoff.h b/arch/sandbox/include/asm/handoff.h new file mode 100644 index 00000000000..be4e7b0fae2 --- /dev/null +++ b/arch/sandbox/include/asm/handoff.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Architecture-specific SPL handoff information for sandbox + * + * Copyright 2018 Google, Inc + * Written by Simon Glass + */ + +#ifndef __handoff_h +#define __handoff_h + +#define TEST_HANDOFF_MAGIC 0x14f93c7b + +struct arch_spl_handoff { + ulong magic; /* Used for testing */ +}; + +#endif diff --git a/cmd/sb.c b/cmd/sb.c index 6ca3361d7e3..5701e03797c 100644 --- a/cmd/sb.c +++ b/cmd/sb.c @@ -9,6 +9,23 @@ #include #include +static int do_sb_handoff(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ +#if CONFIG_IS_ENABLED(HANDOFF) + if (gd->spl_handoff) + printf("SPL handoff magic %lx\n", gd->spl_handoff->arch.magic); + else + printf("SPL handoff info not received\n"); + + return 0; +#else + printf("Command not supported\n"); + + return CMD_RET_USAGE; +#endif +} + static int do_sb_state(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -21,6 +38,7 @@ static int do_sb_state(cmd_tbl_t *cmdtp, int flag, int argc, } static cmd_tbl_t cmd_sb_sub[] = { + U_BOOT_CMD_MKENT(handoff, 1, 0, do_sb_handoff, "", ""), U_BOOT_CMD_MKENT(state, 1, 0, do_sb_state, "", ""), }; @@ -42,5 +60,6 @@ static int do_sb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) U_BOOT_CMD( sb, 8, 1, do_sb, "Sandbox status commands", - "state - Show sandbox state" + "handoff - Show handoff data received from SPL\n" + "sb state - Show sandbox state" ); diff --git a/common/board_f.c b/common/board_f.c index 42378537c8d..6516620de6f 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -25,6 +25,9 @@ #include #include #include +#ifdef CONFIG_SPL +#include +#endif #include #include #include @@ -286,6 +289,17 @@ static int setup_mon_len(void) return 0; } +static int setup_spl_handoff(void) +{ +#if CONFIG_IS_ENABLED(HANDOFF) + gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF, + sizeof(struct spl_handoff)); + debug("Found SPL hand-off info %p\n", gd->spl_handoff); +#endif + + return 0; +} + __weak int arch_cpu_init(void) { return 0; @@ -845,6 +859,7 @@ static const init_fnc_t init_sequence_f[] = { #ifdef CONFIG_BLOBLIST bloblist_init, #endif + setup_spl_handoff, initf_console_record, #if defined(CONFIG_HAVE_FSP) arch_fsp_init, diff --git a/common/init/Makefile b/common/init/Makefile index 4902635f535..853b56d1e57 100644 --- a/common/init/Makefile +++ b/common/init/Makefile @@ -5,3 +5,4 @@ # obj-y += board_init.o +obj-$(CONFIG_$(SPL_TPL_)HANDOFF) += handoff.o diff --git a/common/init/handoff.c b/common/init/handoff.c new file mode 100644 index 00000000000..e00b43e6a7b --- /dev/null +++ b/common/init/handoff.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Passing basic information from SPL to U-Boot proper + * + * Copyright 2018 Google, Inc + */ + +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +void handoff_save_dram(struct spl_handoff *ho) +{ + ho->ram_size = gd->ram_size; +#ifdef CONFIG_NR_DRAM_BANKS + { + struct bd_info *bd = gd->bd; + int i; + + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + ho->ram_bank[i].start = bd->bi_dram[i].start; + ho->ram_bank[i].size = bd->bi_dram[i].size; + } + } +#endif +} + +void handoff_load_dram_size(struct spl_handoff *ho) +{ + gd->ram_size = ho->ram_size; +} + +void handoff_load_dram_banks(struct spl_handoff *ho) +{ +#ifdef CONFIG_NR_DRAM_BANKS + { + struct bd_info *bd = gd->bd; + int i; + + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + bd->bi_dram[i].start = ho->ram_bank[i].start; + bd->bi_dram[i].size = ho->ram_bank[i].size; + } + } +#endif +} diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 32fa5758bf6..0ddbffc7d1c 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -25,8 +25,28 @@ config SPL_FRAMEWORK supports MMC, NAND and YMODEM and other methods loading of U-Boot and the Linux Kernel. If unsure, say Y. +config HANDOFF + bool "Pass hand-off information from SPL to U-Boot proper" + depends on BLOBLIST + help + It is useful to be able to pass information from SPL to U-Boot + proper to preserve state that is known in SPL and is needed in U-Boot. + Enable this to locate the handoff information in U-Boot proper, early + in boot. It is available in gd->handoff. The state state is set up + in SPL (or TPL if that is being used). + if SPL +config SPL_HANDOFF + bool "Pass hand-off information from SPL to U-Boot proper" + depends on HANDOFF + default y + help + This option enables SPL to write handoff information. This can be + used to pass information like the size of SDRAM from SPL to U-Boot + proper. Also SPL can receive information from TPL in the same place + if that is enabled. + config SPL_LDSCRIPT string "Linker script for the SPL stage" default "arch/$(ARCH)/cpu/u-boot-spl.lds" @@ -867,6 +887,16 @@ config TPL if TPL +config TPL_HANDOFF + bool "Pass hand-off information from TPL to SPL and U-Boot proper" + depends on HANDOFF + default y + help + This option enables TPL to write handoff information. This can be + used to pass information like the size of SDRAM from TPL to U-Boot + proper. The information is also available to SPL if it is useful + there. + config TPL_BOARD_INIT bool "Call board-specific initialization in TPL" help diff --git a/common/spl/spl.c b/common/spl/spl.c index 43137105bab..35120b6efd1 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,14 @@ static bd_t bdata __attribute__ ((section(".data"))); */ __weak void show_boot_progress(int val) {} +#if defined(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF) +/* weak, default platform-specific function to initialize dram banks */ +__weak int dram_init_banksize(void) +{ + return 0; +} +#endif + /* * Default function to determine if u-boot or the OS should * be started. This implementation always returns 1. @@ -64,14 +73,6 @@ __weak int spl_start_uboot(void) return 1; } -/* weak default platform specific function to initialize - * dram banks - */ -__weak int dram_init_banksize(void) -{ - return 0; -} - /* * Weak default function for arch specific zImage check. Return zero * and fill start and end address if image is recognized. @@ -320,6 +321,44 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) image_entry(); } +#if CONFIG_IS_ENABLED(HANDOFF) +/** + * Set up the SPL hand-off information + * + * This is initially empty (zero) but can be written by + */ +static int setup_spl_handoff(void) +{ + struct spl_handoff *ho; + + ho = bloblist_ensure(BLOBLISTT_SPL_HANDOFF, sizeof(struct spl_handoff)); + if (!ho) + return -ENOENT; + + return 0; +} + +static int write_spl_handoff(void) +{ + struct spl_handoff *ho; + + ho = bloblist_find(BLOBLISTT_SPL_HANDOFF, sizeof(struct spl_handoff)); + if (!ho) + return -ENOENT; + handoff_save_dram(ho); +#ifdef CONFIG_SANDBOX + ho->arch.magic = TEST_HANDOFF_MAGIC; +#endif + debug(SPL_TPL_PROMPT "Wrote SPL handoff\n"); + + return 0; +} +#else +static inline int setup_spl_handoff(void) { return 0; } +static inline int write_spl_handoff(void) { return 0; } + +#endif /* HANDOFF */ + static int spl_common_init(bool setup_malloc) { int ret; @@ -355,6 +394,15 @@ static int spl_common_init(bool setup_malloc) return ret; } } + if (CONFIG_IS_ENABLED(HANDOFF)) { + int ret; + + ret = setup_spl_handoff(); + if (ret) { + puts(SPL_TPL_PROMPT "Cannot set up SPL handoff\n"); + hang(); + } + } if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { ret = fdtdec_setup(); if (ret) { @@ -503,10 +551,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2) spl_set_bd(); -#ifdef CONFIG_SPL_OS_BOOT - dram_init_banksize(); -#endif - #if defined(CONFIG_SYS_SPL_MALLOC_START) mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE); @@ -528,6 +572,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) spl_board_init(); #endif + if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF)) + dram_init_banksize(); + bootcount_inc(); memset(&spl_image, '\0', sizeof(spl_image)); @@ -544,6 +591,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } spl_perform_fixups(&spl_image); + if (CONFIG_IS_ENABLED(HANDOFF)) { + ret = write_spl_handoff(); + if (ret) + printf(SPL_TPL_PROMPT + "SPL hand-off write failed (err=%d)\n", ret); + } if (CONFIG_IS_ENABLED(BLOBLIST)) { ret = bloblist_finish(); if (ret) diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index f44e80e8c33..452a2ef4a50 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -22,6 +22,7 @@ CONFIG_CONSOLE_RECORD=y CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 CONFIG_SILENT_CONSOLE=y CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_HANDOFF=y CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_CMD_CPU=y diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index ccf361ed88a..dffd6b26026 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -125,6 +125,9 @@ typedef struct global_data { #if CONFIG_IS_ENABLED(BLOBLIST) struct bloblist_hdr *bloblist; /* Bloblist information */ struct bloblist_hdr *new_bloblist; /* Relocated blolist info */ +# ifdef CONFIG_SPL + struct spl_handoff *spl_handoff; +# endif #endif } gd_t; #endif diff --git a/include/handoff.h b/include/handoff.h new file mode 100644 index 00000000000..aacb0f5ebf2 --- /dev/null +++ b/include/handoff.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Passing basic information from SPL to U-Boot proper + * + * Copyright 2018 Google, Inc + */ + +#ifndef __HANDOFF_H +#define __HANDOFF_H + +#if CONFIG_IS_ENABLED(HANDOFF) + +#include + +/** + * struct spl_handoff - information passed from SPL to U-Boot proper + * + * @ram_size: Value to use for gd->ram_size + */ +struct spl_handoff { + struct arch_spl_handoff arch; + u64 ram_size; +#ifdef CONFIG_NR_DRAM_BANKS + struct { + u64 start; + u64 size; + } ram_bank[CONFIG_NR_DRAM_BANKS]; +#endif +}; + +void handoff_save_dram(struct spl_handoff *ho); +void handoff_load_dram_size(struct spl_handoff *ho); +void handoff_load_dram_banks(struct spl_handoff *ho); +#endif + +#endif diff --git a/include/spl.h b/include/spl.h index 205aaff4b9d..ee92832f0ae 100644 --- a/include/spl.h +++ b/include/spl.h @@ -11,6 +11,7 @@ /* Platform-specific defines */ #include #include +#include /* Value in r0 indicates we booted from U-Boot */ #define UBOOT_NOT_LOADED_FROM_SPL 0x13578642 diff --git a/test/py/tests/test_handoff.py b/test/py/tests/test_handoff.py new file mode 100644 index 00000000000..4540441fae7 --- /dev/null +++ b/test/py/tests/test_handoff.py @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2016 Google, Inc + +import pytest + +# Magic number to check that SPL handoff is working +TEST_HANDOFF_MAGIC = 0x14f93c7b + +@pytest.mark.buildconfigspec('spl') +def test_handoff(u_boot_console): + """Test that of-platdata can be generated and used in sandbox""" + cons = u_boot_console + response = cons.run_command('sb handoff') + assert ('SPL handoff magic %x' % TEST_HANDOFF_MAGIC) in response diff --git a/test/run b/test/run index fb8ff5da0cb..cd323b0a85e 100755 --- a/test/run +++ b/test/run @@ -19,7 +19,7 @@ run_test "sandbox" ./test/py/test.py --bd sandbox --build # Run tests which require sandbox_spl run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \ - -k test_ofplatdata.py + -k 'test_ofplatdata or test_handoff' # Run tests for the flat-device-tree version of sandbox. This is a special # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can