From patchwork Sat Nov 24 04:29:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002574 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZDAoJY3T"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320bp4sdhz9s7W for ; Sat, 24 Nov 2018 15:30:46 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 0A724C22464; Sat, 24 Nov 2018 04:30: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, T_DKIM_INVALID 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 D331FC22472; Sat, 24 Nov 2018 04:30:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id ECD95C2247D; Sat, 24 Nov 2018 04:30:07 +0000 (UTC) Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) by lists.denx.de (Postfix) with ESMTPS id EB968C2247B for ; Sat, 24 Nov 2018 04:30:02 +0000 (UTC) Received: by mail-it1-f200.google.com with SMTP id g7so6246247itg.7 for ; Fri, 23 Nov 2018 20:30:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=LbsaG9QpPVxwzXsqCqaXsNiRHWyjeETQf2ftXa2y6hQ=; b=ZDAoJY3TU9IyTFVCpi7qMP3bBopR/QCyGCnv1M42kRztd2dvuyW0QnEchomFQ3uim8 NN4aDLI9BRCM5eqpEPBumh5+y/xFzJmKdX9PySMHb4yyv1rbUsH3Weut22ViRfbpzz2p YMbqud3AP6mpBKpzQjsSy5HCbyJvqmY/Xkm88= 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=LbsaG9QpPVxwzXsqCqaXsNiRHWyjeETQf2ftXa2y6hQ=; b=q5iEBY1Y7LJ16YOITPLFdJ6vIiWimRHxgRKGBgyO6e1U//0v7up46d8UZFR4y4PYnn 7suDJQ4LLS6PD6ujjdmPQfPoYX3E7KEA2nRvwk/aDk4U/UyxLProLVJQmwdoCbV9pzc8 gNOEmDqc3aavEZ7MQRD3FJylEZEU0pqvXl7yPIMwDiPIFPCwp0oYxkVcZkNAtskBWch0 tdxvMI4aUZpCLow7x4M+VtJFp6qlexdiNOhxiswHdWlAywfbNZYrnkIWBivI6bZptEOe KT/HfXkLwpBG+enRS75azfYLjzrZE/jNi+oqNgJO+mdigPfqBunOnRX8kWfWn0JERC69 yv/A== X-Gm-Message-State: AGRZ1gLkqMlVhhO0Bh3hPI4Z4xc9PkgwEXjWu8x1RqjHrVZx3CqZL4GO JPf2/741yc6FZSEVfQmAgJV5Ly2mb43eZ9Mo X-Google-Smtp-Source: AFSGD/XeEVlC8w2H5HZMtea54ycqw+Bt41Df6oPExPNzM7uYRFZDFkhSln3eG/YtChGqeD2oL0ik+/mabvBw5ZKi X-Received: by 2002:a24:42cb:: with SMTP id i194-v6mr12147033itb.2.1543033801832; Fri, 23 Nov 2018 20:30:01 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:24 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-2-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Joe Hershberger , Alexander Graf Subject: [U-Boot] [PATCH 01/21] sandbox: Fix up the debug message for the image filename 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" This currently prints out the wrong filename. Fix it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index aa926943427..58d9a46263e 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -668,7 +668,7 @@ static int os_jump_to_file(const char *fname) os_free(argv); if (err) { perror("Unable to run image"); - printf("Image filename '%s'\n", mem_fname); + printf("Image filename '%s'\n", fname); return err; } From patchwork Sat Nov 24 04:29:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002575 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ea68bAlN"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320d560T4z9s7W for ; Sat, 24 Nov 2018 15:31:53 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 72781C2245F; Sat, 24 Nov 2018 04:31:00 +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, T_DKIM_INVALID 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 1EBE5C22450; Sat, 24 Nov 2018 04:30:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C697CC2245F; Sat, 24 Nov 2018 04:30:08 +0000 (UTC) Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by lists.denx.de (Postfix) with ESMTPS id 858F8C22478 for ; Sat, 24 Nov 2018 04:30:04 +0000 (UTC) Received: by mail-qk1-f199.google.com with SMTP id j125so13331749qke.12 for ; Fri, 23 Nov 2018 20:30:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=SaHcWVGVdQOTmkRl4ieIhMUccdwmE4is5WMRZw+Oseo=; b=ea68bAlN8NX3DSPGf5QRdn0tlDaeNgZutlbroiCx398mp9+qeSWNEC6/3+amt6tVGE haJEsvJGpvyGtNMlXv1kHvtb5ZHPf18bug/wT75VIb+974x5/8dzk6U3Vimel0QsdivW fR5RYvlcxh3UkGWCHBjxYzpcfqTSSXjiB1BzI= 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=SaHcWVGVdQOTmkRl4ieIhMUccdwmE4is5WMRZw+Oseo=; b=awd7srxhqI4IytbfV1V8KOyO/0FkMN3VAC1St0RTzDWIBNrMY/ZoMv9m5ft6AYK0AO oqhVqPS1R2pdzCJkYFDYShlbJ4rKDeZ8ESO1xKdHJkzsb4QqPrxuecDT/EpBZcLsFrlM g3eUB8C+zmBS+hS5vwlOfhdYj+YI9UmtxJkeRB67eGVzSiXnl7TQ1K3lQVp4AX+VOp0v 2ZwRtyxrmMVaM3/iHCMngGCF8x0VqUkbEThk/hsDvh0tkTYXNJe1B4tonGnXbu7a5wnc 6B8rLyrseywbyJe2+fzZixkgSiaBJs5dsxw+ShAvLgkgSLI+X3L3UxEJPgwZTgiNacuC s4XQ== X-Gm-Message-State: AA+aEWZBdoGfIzOQWTG6p6HBOROCB6iO0Wk7enWEcvBZ/gjReU/FLzqj C+qZgoIc2/DPyZAav3DvcIbkzawOAR2RwJI6 X-Google-Smtp-Source: AFSGD/V+L4E3n1NZFRBXZE+UnB8KE2SHoNS70z6X/T8qR8y3hOQo3MVvPGO8QPLWCc4n463AfEAzlzx57i9F+n2D X-Received: by 2002:a37:12e1:: with SMTP id 94mr10892314qks.25.1543033803294; Fri, 23 Nov 2018 20:30:03 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:25 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-3-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 02/21] sandbox: Check the filename in jump_to_image_no_args() 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" If the filename is NULL this function currently crashes. Update it to fail gracefully. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- arch/sandbox/cpu/spl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c index 5005ed2f54a..2ca4cd6e35e 100644 --- a/arch/sandbox/cpu/spl.c +++ b/arch/sandbox/cpu/spl.c @@ -69,7 +69,11 @@ 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); + if (fname) { + os_fd_restore(); + os_spl_to_uboot(fname); + } else { + printf("No filename provided for U-Boot\n"); + } hang(); } From patchwork Sat Nov 24 04:29:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002576 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="du5WqiAS"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320ds5SnRz9s7W for ; Sat, 24 Nov 2018 15:32:33 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 68B2BC22460; Sat, 24 Nov 2018 04:31:17 +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, T_DKIM_INVALID 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 58C90C2244A; Sat, 24 Nov 2018 04:30:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3CFD2C22469; Sat, 24 Nov 2018 04:30:09 +0000 (UTC) Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by lists.denx.de (Postfix) with ESMTPS id E121FC22462 for ; Sat, 24 Nov 2018 04:30:05 +0000 (UTC) Received: by mail-oi1-f199.google.com with SMTP id r131so1666831oia.7 for ; Fri, 23 Nov 2018 20:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=FB0YuxatEYWiZHZUSP6EOKTF1/a/rhMZEDuPqClxmNY=; b=du5WqiAS2c4sgVGTUXFJp7I7rzuNXzEz9e7JIsA9jcWJtsvJH5yvGDZgpCbf5YTbh/ 57QLsHhI6QehnoARMhef7QClBTi4sxvqzZEBh0XPClmLvL93RocxVSmyj6fIO0e/Q/Xg KwrTqS/fRLddzS47eTevHFXWLbtqLQtrw2atI= 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=FB0YuxatEYWiZHZUSP6EOKTF1/a/rhMZEDuPqClxmNY=; b=biZ2l6tSD1lHueoNPG4GfKFfn0+eVRIGFt1KQJTPTPavkT/4FX4lBRF/d8lO4pwFVH cK5qxfClunAnOZtqM4tjh7977VmC76xiWUzgrPjtOgAlxXC/9TP8v3gS+nJPLsAh+j9r dn4k0r7xexpC31fRLDcVmZnX3S5sJDlP9Xv3QZX9i/ghrqxq0q6jRvUCeF0db0iQKgp0 OucrnPdkcq3ksgjGFEae76dLwJMvW/6hVuNNk+cAqn9l5XV1mV5J+8fZEtFXHSJv2//P NhYqXb7weRSGW+jlSzN4FGHbZR3Xa3csa1k829hz6GjInNqtkDaudv94M5baNcWAgRR/ QMaA== X-Gm-Message-State: AGRZ1gJGaj86BZs9nXtbesRkozzZZFhw+TGigv9tWP7kod+E/FCPm8LS IV+RQ6EhtkUQZ6vwv3ff6o83Mn20dpk5yKg8 X-Google-Smtp-Source: AJdET5fXYDBVTNbXG2UWW/8kZly1lWngBOFWevmfgq7E32E/WQSCasHWs/Nq5DIETj2J+fJ8qeYmmo0qSC/yKcIx X-Received: by 2002:aca:3106:: with SMTP id x6mr12286155oix.42.1543033804602; Fri, 23 Nov 2018 20:30:04 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:26 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-4-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 03/21] sandbox: physmem: Use mapping to support 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" Replace the raw cast with a map_sysmem() call so this code works with sandbox. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- lib/physmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/physmem.c b/lib/physmem.c index f21ac243edc..84b191dae3e 100644 --- a/lib/physmem.c +++ b/lib/physmem.c @@ -9,14 +9,16 @@ */ #include +#include #include #include phys_addr_t __weak arch_phys_memset(phys_addr_t s, int c, phys_size_t n) { - void *s_ptr = (void *)(uintptr_t)s; + void *s_ptr = map_sysmem(s, n); assert(((phys_addr_t)(uintptr_t)s) == s); assert(((phys_addr_t)(uintptr_t)(s + n)) == s + n); + return (phys_addr_t)(uintptr_t)memset(s_ptr, c, n); } From patchwork Sat Nov 24 04:29:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002584 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gSVLDWuF"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320l55GBhz9s7W for ; Sat, 24 Nov 2018 15:37:05 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6B2D9C22451; Sat, 24 Nov 2018 04:31:34 +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=T_DKIM_INVALID 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 73B41C2243B; Sat, 24 Nov 2018 04:30:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DC371C22468; Sat, 24 Nov 2018 04:30:10 +0000 (UTC) Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by lists.denx.de (Postfix) with ESMTPS id 4E66BC22469 for ; Sat, 24 Nov 2018 04:30:07 +0000 (UTC) Received: by mail-qt1-f200.google.com with SMTP id q3so10673261qtq.15 for ; Fri, 23 Nov 2018 20:30:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=aiLVf6DZWMCBMwrlKcC38t7MTQySMk2y70w4Kbvjeg0=; b=gSVLDWuFKHTgOz3J8qd/76dYX2m+MUx+Kby3kQKqpndz5snUQB+QwA2ExCGIl+C+gI zGoH41mPagdqXDHwZXqpQYO5NeR5kTLxj89oRW+wfOoib3y4jd7ezF+v9/1CufJGe72S mE9ZbqvGCPA6NUdYGVdhvtfjZI47fGcEuKtmY= 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=aiLVf6DZWMCBMwrlKcC38t7MTQySMk2y70w4Kbvjeg0=; b=Z/qT81fEXfzvaVI7S6PCuZ65IeOMiOk2B4ZX7FiuO/syt9aJOjBmyXx3GOq8PdH3jB tvAvXNs0Mm4ccjJxGF8GqxCb2V21391GD72IMsGOXK4am0+iMzWcGuS0GV3IEf3nzf2G wuZP26DBUVAafiNyC+LCV3MEyjKs+gSNl86oeIGQC3YVGvSeHcoJ3GH/cF4jhhVrI/Mw r9s2yKNnzJl23yW66BrMGsPbAr4YaRQwOI9xqZFcO+k+c3QyEVqsMMhvWfnUCqKQaHNY FRsQoa4Xm1K7wMZeKGlTtvaKNovwFMj6DlCNVg/85y++i8QRp1I/+FAdIefIYJ0T65sh 6jTw== X-Gm-Message-State: AGRZ1gKUaC3e4gCVyhF8DX2UIx+vNUJhg/mbz+XQTnk4I+RixZxSGYVS LiTo5FqpO/lzc2hs9Wh9rz4L4daEd6FiwhAU X-Google-Smtp-Source: AJdET5cqQaoB55jGEIH84ecTLI8T+N0gHPJS5D18x/6tGitlgDHq8djQff51ARRo5nef5pglNvX9ndLArKF1Wo6d X-Received: by 2002:aed:3c74:: with SMTP id u49mr11625099qte.19.1543033806357; Fri, 23 Nov 2018 20:30:06 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:27 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-5-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Joe Hershberger Subject: [U-Boot] [PATCH 04/21] sandbox: net: Correct name copy in eth_raw_bus_post_bind() 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 cannot be sure that the interface name takes up the full length of the space available to it. Use strcpy() instead of memcpy() in this case. This corrects a valgrind warning. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/net/sandbox-raw-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/sandbox-raw-bus.c b/drivers/net/sandbox-raw-bus.c index 76d65afe6c8..0086f25fc1f 100644 --- a/drivers/net/sandbox-raw-bus.c +++ b/drivers/net/sandbox-raw-bus.c @@ -42,7 +42,7 @@ static int eth_raw_bus_post_bind(struct udevice *dev) device_probe(child); priv = dev_get_priv(child); if (priv) { - memcpy(priv->host_ifname, i->if_name, IFNAMSIZ); + strcpy(priv->host_ifname, i->if_name); priv->host_ifindex = i->if_index; priv->local = local; } From patchwork Sat Nov 24 04:29:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002586 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="NZxAQAlq"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320lv4zSJz9s7W for ; Sat, 24 Nov 2018 15:37:47 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 62C92C2243B; Sat, 24 Nov 2018 04:32: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=T_DKIM_INVALID 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 A3831C2248B; Sat, 24 Nov 2018 04:30:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 86473C2245F; Sat, 24 Nov 2018 04:30:11 +0000 (UTC) Received: from mail-vs1-f69.google.com (mail-vs1-f69.google.com [209.85.217.69]) by lists.denx.de (Postfix) with ESMTPS id 6CC7FC22475 for ; Sat, 24 Nov 2018 04:30:09 +0000 (UTC) Received: by mail-vs1-f69.google.com with SMTP id f203so5357730vsd.17 for ; Fri, 23 Nov 2018 20:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7PMRlUGMtQCCY6lEIkeQD3inWzR8OaKk2T3fEh0Jd6U=; b=NZxAQAlqLg3gVVOXoqxwBELdZfp8D7+cuzPMvSrx0DbGhqnfmhyL44neUUnu5T+Ng2 L46FiJjKn/IbS6b/yOYGS2Slit8Wz3W1W+8+qaMqMJckVwVmLxgOu0JvsweNhfasa8E4 huURA2tAn5sGjsj1crYCelGyFZzNsfjm3j5Ug= 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=7PMRlUGMtQCCY6lEIkeQD3inWzR8OaKk2T3fEh0Jd6U=; b=q4teRLlfc2J1kjlWVkVHj6TJ4yzG98bbl0bm/wEKs26HPyYfvqkYWmcdX9DgY453PN i765HKkfnINhckmkhipmYmY5Ur/ha6OanWghVzQf2U2u3Qf4CLIREbNeYNGX2wdw2ypt /vbq6oywgKaa1FqfC2O5ZKOsFMYjs1gmAEf61Ie7fQHymFyH9LT2xZDt0N1SmGq9lB1r iWIT5dahAwvFSJfRlOXRQsVE0OsE65l1NCaVUSZDtSXFF2PKFgxNJVXhs9yLSMem5c9e HFxhvd9XKlEGEE4Z5lBrCDPqTe2GxiHh7vPHDpKgwDFNx8z3rad/8J1OId/2ANXIbunz r/yw== X-Gm-Message-State: AGRZ1gI8gNZi7PlHyEPCp3TG6hHkzOFizKu+LmFJCYGGhbBp3KM/T0pJ Ek2LBLDii6GG5PDTWLySCQYd5TUH7ikBVKT6 X-Google-Smtp-Source: AJdET5fyBZDLhBxlus9D3IUI5vfHrqqCJgSXdEZRE8k/wvG/JU//K8uUG2rMJSRxxIj9ZtLRYv9LQatj6LaP4tAf X-Received: by 2002:a67:35ca:: with SMTP id x71mr13777194vsh.38.1543033808238; Fri, 23 Nov 2018 20:30:08 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:28 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-6-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 05/21] sandbox: sysreset: Update to support power-on reset 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" If U-Boot is started from SPL or TPL, then those earlier phases deal with the reset cause. On real hardware this cause may be lost once it is read. Emulate that behaviour in sandbox by reporting a warm reset when a previous phase has run since start-up. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/sysreset/sysreset_sandbox.c | 8 +++++++- test/dm/sysreset.c | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c index 7f6d4186e16..38e2a7e241d 100644 --- a/drivers/sysreset/sysreset_sandbox.c +++ b/drivers/sysreset/sysreset_sandbox.c @@ -84,7 +84,13 @@ int sandbox_sysreset_get_status(struct udevice *dev, char *buf, int size) int sandbox_sysreset_get_last(struct udevice *dev) { - return SYSRESET_COLD; + struct sandbox_state *state = state_get_current(); + + /* + * The first phase is a power reset, after that we assume we don't + * know. + */ + return state->jumped_fname ? SYSRESET_WARM : SYSRESET_POWER; } static struct sysreset_ops sandbox_sysreset_ops = { diff --git a/test/dm/sysreset.c b/test/dm/sysreset.c index e1b7bf5277d..5b2358ef674 100644 --- a/test/dm/sysreset.c +++ b/test/dm/sysreset.c @@ -102,10 +102,10 @@ static int dm_test_sysreset_get_last(struct unit_test_state *uts) /* Device 2 is the cold sysreset device */ ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev)); - ut_asserteq(SYSRESET_COLD, sysreset_get_last(dev)); + ut_asserteq(SYSRESET_POWER, sysreset_get_last(dev)); /* This is device 0, the non-DT one */ - ut_asserteq(SYSRESET_COLD, sysreset_get_last_walk()); + ut_asserteq(SYSRESET_POWER, sysreset_get_last_walk()); return 0; } From patchwork Sat Nov 24 04:29:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002577 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Vj3j1jto"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320gZ0kPhz9s8F for ; Sat, 24 Nov 2018 15:34:02 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C67FDC2246E; Sat, 24 Nov 2018 04:32:54 +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, T_DKIM_INVALID 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 26073C2247B; Sat, 24 Nov 2018 04:30:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 71CC6C22486; Sat, 24 Nov 2018 04:30:11 +0000 (UTC) Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by lists.denx.de (Postfix) with ESMTPS id 835B9C22471 for ; Sat, 24 Nov 2018 04:30:10 +0000 (UTC) Received: by mail-io1-f69.google.com with SMTP id y14-v6so12631061ioa.22 for ; Fri, 23 Nov 2018 20:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ERIedwLAs2XOVOuAEzu1IXVQQTVkK0mveVf2pTPqO4o=; b=Vj3j1jtopUWrLLAZtHA9W9LfxjqSMp23DlcYfO53YccwRz6pX4ZoBR4Jg95U6sNhf3 hp0Bg2BhaS2dyo269igYmC5y4D004fYnHayOxXP3vUTOx66F9gjA3wmQzym/fee5E2Vf Te2QcrjHtKAyVoK9VgakP91R8H1TzQz4E9nRw= 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=ERIedwLAs2XOVOuAEzu1IXVQQTVkK0mveVf2pTPqO4o=; b=Cy23yKrO3s6XMQbYleroyvxz+TOxrIP4e+a9IxHL6Gx1Sw5FX/BEZEOiFNr3KlWGon 90Uxd0rE2QVQSewqo3hXm0J0nf2SWn8aMaotzKlF2eBj8+G5HhowJCX34fOCIr5rDaMr CEJ5Wv6H+zWgjS8el40uw6/xEoNdHOcpxN3cA7eFMS0YRCX+xXayz0y0P2QgkcSn+Vsg c/86qNHzS07zs0fnltytwbNc7uMe8GX4Qt/dJS4oA4YoRXgI7i4zYXC65RwE3lt1/IZh peE/vMpSnRK0mTJVLDXKBQMyTaD3Bl5NHhv1lw8gofTUWEIgGmzLOipBOuf5BxdNVe+a pSbg== X-Gm-Message-State: AA+aEWZD4350MbBe+wNlUIYLNUkwwvCW99Uo9H08fFIh27CfCczebqEv kubB1SvMBqFDYnVCbK0JQyGSeTcQCEim7zjn X-Google-Smtp-Source: AJdET5flEuEeygU9/QN/bsTzk7qvJttnzrdMR/R67cIflQDOtu5M+LvxlKsV2r3Uv/l/6UIkgYiiN7bwnuQe4mf/ X-Received: by 2002:a24:4652:: with SMTP id j79mr12145029itb.36.1543033809553; Fri, 23 Nov 2018 20:30:09 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:29 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-7-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Alexander Graf Subject: [U-Boot] [PATCH 06/21] sandbox: Zero the ram buffer on startup 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 the RAM buffer is not inited unless it is read from a file, likely produced by an earlier phase of U-Boot. This causes valgrind warnings whenever the RAM buffer is used. Correct this by initing it if needed. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- arch/sandbox/cpu/start.c | 7 +++++++ arch/sandbox/include/asm/state.h | 1 + 2 files changed, 8 insertions(+) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index b1566a81435..2f5e6e95182 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -180,6 +180,7 @@ static int sandbox_cmdline_cb_memory(struct sandbox_state *state, printf("Failed to read RAM buffer '%s': %d\n", arg, err); return err; } + state->ram_buf_read = true; return 0; } @@ -301,6 +302,12 @@ int board_run_command(const char *cmdline) static void setup_ram_buf(struct sandbox_state *state) { + /* Zero the RAM buffer if we didn't read it, to keep valgrind happy */ + if (!state->ram_buf_read) { + memset(state->ram_buf, '\0', state->ram_size); + printf("clear %p %x\n", state->ram_buf, state->ram_size); + } + gd->arch.ram_buf = state->ram_buf; gd->ram_size = state->ram_size; } diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 8fabe70a86d..5a144851025 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -90,6 +90,7 @@ struct sandbox_state { 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 */ + bool ram_buf_read; /* true if we read the RAM buffer */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS] From patchwork Sat Nov 24 04:29:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002578 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LSCTGQ1Q"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320gg36Hlz9s8F for ; Sat, 24 Nov 2018 15:34:07 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 2885FC2246D; Sat, 24 Nov 2018 04:33:11 +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, T_DKIM_INVALID 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 A69A8C2246A; Sat, 24 Nov 2018 04:30:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3A1CEC22442; Sat, 24 Nov 2018 04:30:13 +0000 (UTC) Received: from mail-yw1-f70.google.com (mail-yw1-f70.google.com [209.85.161.70]) by lists.denx.de (Postfix) with ESMTPS id CF342C22481 for ; Sat, 24 Nov 2018 04:30:12 +0000 (UTC) Received: by mail-yw1-f70.google.com with SMTP id w190-v6so8173037ywf.14 for ; Fri, 23 Nov 2018 20:30:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=blD1iZo83ogQtT/YphimcYljtjWL5HZkkMFRFmYedCs=; b=LSCTGQ1QqfFFDOfFr3kowSZ16oDZlEA3z9IYQCv3qUQo1OYvyHEEUejDf0+SSHeqMS zBq/l6rXE3SkwFKzM7AX8fI7w60KEi3yTOi2DVJmFMxEzJEJTMbjpfzw6KCDLPHrdObi F3887l/Mmem5iQlaMbD7DHexzveya17IYH30w= 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=blD1iZo83ogQtT/YphimcYljtjWL5HZkkMFRFmYedCs=; b=ollfRyv7E1yNdYGK6av+YGsXMrxVE9JAED4pXEzLVmfXiSSXFD2kqLSSOsZRGLdwWH irPQhVNQCiQlSaf6/TrdhYOVm2tb+g403N4ivTVwu984BSj6vGm09u6995OuDdYVkJRJ SrbE562Q9DNmatzSVEEdoHgV0xNtGraveTTWFmqHqCZ1XSEaE7GTMncs2JPWDjEd81ds 05Gf4PMGUL32p0mluKYhAuU9/0C028bVMCAfLyvtBnIBR6ukDyJOfIM5WeNikm4TASYc 3zn8JVPidtnuLoDsHyzcX2bLFncAcNvkpp2pGOxibtmw4tiFxQ9Ix83T3cJIlpU8PQI7 DC3g== X-Gm-Message-State: AA+aEWZilDUMd7laEdT8Phv38Px0gr1sPGv9mGXdDiPhdqLCv8mF1OZb 4OfWk3+E4GIGY0rpDvPsbj5PYf2r8MQUT/I/ X-Google-Smtp-Source: AFSGD/VTXHyT8Uasc2xBI1XZ0cUehbqiymFm8GV6mJo1KmQWNRyWbQUHxTaYEv0HfPg847OB0UaATnZ0t8OCHtnC X-Received: by 2002:a25:9192:: with SMTP id w18-v6mr8059486ybl.56.1543033811490; Fri, 23 Nov 2018 20:30:11 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:30 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-8-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 07/21] sandbox: Use 'extras' to specify 'head' files 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 has a start.o in the 'start' target but also includes it in the normal target list. This is not how this is normally handled. It is needed because sandbox does not include the u-boot-init variable in its link rule. Update the rule and move start.o from the normal target list to the 'extras' list. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- arch/sandbox/Makefile | 4 ++-- arch/sandbox/config.mk | 3 ++- arch/sandbox/cpu/Makefile | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile index 261079441cf..f6cf859f249 100644 --- a/arch/sandbox/Makefile +++ b/arch/sandbox/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0+ -head-y := arch/sandbox/cpu/start.o - +head-y := arch/sandbox/cpu/start.o arch/sandbox/cpu/os.o +head-$(CONFIG_SANDBOX_SDL) += arch/sandbox/cpu/sdl.o libs-y += arch/sandbox/cpu/ libs-y += arch/sandbox/lib/ diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 95f9e3ff63f..7226b7be428 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -17,11 +17,12 @@ PLATFORM_CPPFLAGS += $(shell sdl-config --cflags) endif endif -cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds \ +cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \ -Wl,--start-group $(u-boot-main) -Wl,--end-group \ $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \ + $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ -Wl,--start-group $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \ $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) -Wl,--end-group \ $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections) diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile index 8fe681844d9..bac96447d51 100644 --- a/arch/sandbox/cpu/Makefile +++ b/arch/sandbox/cpu/Makefile @@ -5,10 +5,11 @@ # (C) Copyright 2000-2003 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. -obj-y := cpu.o os.o start.o state.o +obj-y := cpu.o state.o +extra-y := start.o os.o +extra-$(CONFIG_SANDBOX_SDL) += sdl.o obj-$(CONFIG_SPL_BUILD) += spl.o obj-$(CONFIG_ETH_SANDBOX_RAW) += eth-raw-os.o -obj-$(CONFIG_SANDBOX_SDL) += sdl.o # os.c is build in the system environment, so needs standard includes # CFLAGS_REMOVE_os.o cannot be used to drop header include path From patchwork Sat Nov 24 04:29:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002583 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Xi7hlqc2"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320kD2fLsz9s7W for ; Sat, 24 Nov 2018 15:36:20 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 08CC9C2246A; Sat, 24 Nov 2018 04:30: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=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID 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 100D8C22469; Sat, 24 Nov 2018 04:30:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E1814C22450; Sat, 24 Nov 2018 04:30:14 +0000 (UTC) Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by lists.denx.de (Postfix) with ESMTPS id E430BC22460 for ; Sat, 24 Nov 2018 04:30:13 +0000 (UTC) Received: by mail-io1-f69.google.com with SMTP id h7so13035252iof.19 for ; Fri, 23 Nov 2018 20:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=PGPhIwRBPugHAMaHA2spmoqSa3KsuxpOLGZ4pOJs/xc=; b=Xi7hlqc2rW44sQpj8kBCL8wOdTbFMDBLERpY2za3bIuZ4q6iFGlE8OAHXqnWRmGeNf ITYpVtONtBMu03sHqIRhQsaD6Ltd6R2dv/DKJVhcFHbCnsHYaWmr9AX4O1AMJF191EHl Q5HvSyY9JpWstYKSX/OYkkt8K0QQpK3dp93ME= 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=PGPhIwRBPugHAMaHA2spmoqSa3KsuxpOLGZ4pOJs/xc=; b=gLKK+cTk5NCWNkkBO1jaUqQS9HoxgdbJnVo6JmB+y2rOJyfNtPa+l5wnwanQm1Ppc/ 9hfKvGibnD/FVKv4OGWPCONJ1XlQxlYpmPDpkrfl92KC0o4K+uRZnHde1atd5Gp7ALmv /RZzjOcWxnxG8Qs+98wM9YmLCLU0Cr1uH+YXcZUwjV5WHoLEO/qLZG3gjCIq/DPH9Tel 8nShBnywElw8CnaTx+RKu8iUaQP1ErMTCl8jJWR7/G4Wgn6CQEAcj58DI348r3PzeQ53 MC/u63wxv+uAGzPIpNDVna1wyPH9rNxW0FjX9AG7cE5PnFhYRvfCmG84qL0ci6iPFdL3 i8ZA== X-Gm-Message-State: AGRZ1gLp9yZtjCmcMPR3YNcLEf74s/DfufMOiN6ESzuIDmhJQn8gy7lT Fcj9SaSZnSLrcn+9lGNPGZyH1dzSSquSIkAN X-Google-Smtp-Source: AJdET5eV/NGyeQD2D7IWjRh3S1YIhm56nxLXVeegO7lW0prmK4d4Tz6cAPd2ZuEGf0ii1sLdIuHQ0U6eieq/xtda X-Received: by 2002:a24:1002:: with SMTP id 2-v6mr11710544ity.4.1543033812940; Fri, 23 Nov 2018 20:30:12 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:31 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-9-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Joe Hershberger , Alexander Graf Subject: [U-Boot] [PATCH 08/21] sandbox: Allow running from valgrind 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 useful to run sandbox from valgrind to find memory errors, etc. At present this works OK until U-Boot jumps into the next phase (e.g. from SPL to U-Boot). Update os_jump_to_file() to use valgrind for each subsequent phase also. Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 58d9a46263e..fd0c688edfb 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -572,9 +572,11 @@ static int make_exec(char *fname, const void *data, int size) * @argvp: Returns newly allocated args list * @add_args: Arguments to add, each a string * @count: Number of arguments in @add_args + * @use_valgrind: Run the program with valgrind * @return 0 if OK, -ENOMEM if out of memory */ -static int add_args(char ***argvp, char *add_args[], int count) +static int add_args(char ***argvp, char *add_args[], int count, + bool use_valgrind) { char **argv, **ap; int argc; @@ -582,12 +584,15 @@ static int add_args(char ***argvp, char *add_args[], int count) for (argc = 0; (*argvp)[argc]; argc++) ; - argv = os_malloc((argc + count + 1) * sizeof(char *)); + argv = os_malloc((argc + count + 2) * sizeof(char *)); if (!argv) { printf("Out of memory for %d argv\n", count); return -ENOMEM; } - for (ap = *argvp, argc = 0; *ap; ap++) { + argc = 0; + if (use_valgrind) + argv[argc++] = "valgrind"; + for (ap = *argvp; *ap; ap++) { char *arg = *ap; /* Drop args that we don't want to propagate */ @@ -624,15 +629,18 @@ static int add_args(char ***argvp, char *add_args[], int count) static int os_jump_to_file(const char *fname) { struct sandbox_state *state = state_get_current(); + bool use_valgrind; char mem_fname[30]; int fd, err; - char *extra_args[5]; + char *extra_args[6]; char **argv = state->argv; int argc; #ifdef DEBUG int i; #endif + use_valgrind = strlen(argv[0]) >= 8 && + !strcmp(argv[0] + strlen(argv[0]) - 8, "valgrind"); strcpy(mem_fname, "/tmp/u-boot.mem.XXXXXX"); fd = mkstemp(mem_fname); if (fd < 0) @@ -644,17 +652,22 @@ static int os_jump_to_file(const char *fname) os_fd_restore(); - extra_args[0] = "-j"; - extra_args[1] = (char *)fname; - extra_args[2] = "-m"; - extra_args[3] = mem_fname; - argc = 4; + argc = 0; + extra_args[argc++] = "-j"; + extra_args[argc++] = (char *)fname; + extra_args[argc++] = "-m"; + extra_args[argc++] = mem_fname; if (state->ram_buf_rm) extra_args[argc++] = "--rm_memory"; - err = add_args(&argv, extra_args, argc); + err = add_args(&argv, extra_args, argc, use_valgrind); if (err) return err; - argv[0] = (char *)fname; + if (use_valgrind) { + argv[0] = "/usr/bin/valgrind"; + argv[1] = (char *)fname; + } else { + argv[0] = (char *)fname; + } #ifdef DEBUG for (i = 0; argv[i]; i++) @@ -664,7 +677,7 @@ static int os_jump_to_file(const char *fname) if (state_uninit()) os_exit(2); - err = execv(fname, argv); + err = execv(argv[0], argv); os_free(argv); if (err) { perror("Unable to run image"); From patchwork Sat Nov 24 04:29:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002579 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="hiYfCm1z"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320hL3wPfz9s7W for ; Sat, 24 Nov 2018 15:34:42 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 324A5C2244F; Sat, 24 Nov 2018 04:32:06 +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, T_DKIM_INVALID 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 48781C22485; Sat, 24 Nov 2018 04:30:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C8F88C2245D; Sat, 24 Nov 2018 04:30:16 +0000 (UTC) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by lists.denx.de (Postfix) with ESMTPS id 84173C22459 for ; Sat, 24 Nov 2018 04:30:15 +0000 (UTC) Received: by mail-io1-f70.google.com with SMTP id e144-v6so13059450iof.13 for ; Fri, 23 Nov 2018 20:30:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=R9Jah6ncfcln0Q+e1QMXXxQhfjRuN6ytJdAWuYK4iHk=; b=hiYfCm1zMxJamU+3F6dGZzE1LENT47GEhA/2yDE5GOBrpW2G9oDmJEpudMsM7lqwcp neNy3TnHs76PDYPWB9ucTFisWWGV10bHC706OJKerqoDF/SHUHzI0p7CahrPskGF9neB SYJzNu4v/uOSv1yoaeNxA1Rhseq49j2QL0GNU= 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=R9Jah6ncfcln0Q+e1QMXXxQhfjRuN6ytJdAWuYK4iHk=; b=ApOf/ga48gTV+tjqy30c3aQmiIF9W9dIRUyFkj5cu0gQ9ErZIuUFE1Eb1ful958P75 JmirF2rV2XmG8FLHXP4WXEVZD9/qanbfQorw56hsks5FUAbBuXMZMNcZZTKzyrSzf4Ja yc/3cRTHTSjsr2d8TVZbIiCNx5wGSeIVpXqKjblYFuTHE0c11R0VZ5dYofWHIU7CK8do 1TXE8xmCqw5o24GgtF96IB74evX8IuvhM9JjFu/8lyXKXKChBGIq/FPPRu2Nufi78ezi kPaUFfsnyLj9i4BA+BAX0t2QaGVohpbytDP+9f6rQ4NhJWRasx0JDW4w6OiDQSvjbhtT xDRA== X-Gm-Message-State: AGRZ1gInm7Yl1I2jDaDdRdDPZjUbGsz/Ma1BFitKB+k3FJ9Ekj9f4/Kv 4+UbtVw22WYJ+rBJCIw76CRmf7iJhJgKvQsY X-Google-Smtp-Source: AFSGD/V3Kk42vFx2PfTa3qxPh4Vn87GVltU+ZqmQxvvQ881ISpFVMrpNsrr7AI4x8jv/k3FFXHlEhI5EDsn4IE/L X-Received: by 2002:a24:4e51:: with SMTP id r78mr12003265ita.2.1543033814483; Fri, 23 Nov 2018 20:30:14 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:32 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-10-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Miquel Raynal Subject: [U-Boot] [PATCH 09/21] tpm: Remove use of build-time TPM versions 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 only one place in the code which assumes at build-time that we are using either a v1 or a v2 TPM. Fix this up and add a new function to return the version of a TPM. Supported TPM versions (v1 and v2) can be enabled independently and it is possible to use both versions at once. This is useful for sandbox when running tests. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- include/tpm-common.h | 11 +++++++++++ lib/tpm-common.c | 7 +++++++ lib/tpm-v1.c | 22 +++++++++++----------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/tpm-common.h b/include/tpm-common.h index 3d88b44db7a..91a1484b3d6 100644 --- a/include/tpm-common.h +++ b/include/tpm-common.h @@ -274,4 +274,15 @@ static inline cmd_tbl_t *get_tpm2_commands(unsigned int *size) } #endif +/** + * tpm_get_version() - Find the version of a TPM + * + * This checks the uclass data for a TPM device and returns the version number + * it supports. + * + * @dev: TPM device + * @return version number (TPM_V1 or TPMV2) + */ +enum tpm_version tpm_get_version(struct udevice *dev); + #endif /* __TPM_COMMON_H */ diff --git a/lib/tpm-common.c b/lib/tpm-common.c index 6afe59b1fec..2bf0b41e26f 100644 --- a/lib/tpm-common.c +++ b/lib/tpm-common.c @@ -12,6 +12,13 @@ #include #include "tpm-utils.h" +enum tpm_version tpm_get_version(struct udevice *dev) +{ + struct tpm_chip_priv *priv = dev_get_uclass_priv(dev); + + return priv->version; +} + int pack_byte_string(u8 *str, size_t size, const char *format, ...) { va_list args; diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c index f29e62ff7b2..3e89f845441 100644 --- a/lib/tpm-v1.c +++ b/lib/tpm-v1.c @@ -79,19 +79,19 @@ u32 tpm_clear_and_reenable(struct udevice *dev) return ret; } -#if IS_ENABLED(CONFIG_TPM_V1) - ret = tpm_physical_enable(dev); - if (ret != TPM_SUCCESS) { - log_err("TPM: Can't set enabled state\n"); - return ret; - } + if (tpm_get_version(dev) == TPM_V1) { + ret = tpm_physical_enable(dev); + if (ret != TPM_SUCCESS) { + log_err("TPM: Can't set enabled state\n"); + return ret; + } - ret = tpm_physical_set_deactivated(dev, 0); - if (ret != TPM_SUCCESS) { - log_err("TPM: Can't set deactivated state\n"); - return ret; + ret = tpm_physical_set_deactivated(dev, 0); + if (ret != TPM_SUCCESS) { + log_err("TPM: Can't set deactivated state\n"); + return ret; + } } -#endif return TPM_SUCCESS; } From patchwork Sat Nov 24 04:29:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002581 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="MTgEO/c7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320jj110Hz9s8F for ; Sat, 24 Nov 2018 15:35:52 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 8D156C22452; Sat, 24 Nov 2018 04:31:49 +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, T_DKIM_INVALID 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 828DCC2247C; Sat, 24 Nov 2018 04:30:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3A1E3C22471; Sat, 24 Nov 2018 04:30:17 +0000 (UTC) Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) by lists.denx.de (Postfix) with ESMTPS id 4A8A4C2245F for ; Sat, 24 Nov 2018 04:30:17 +0000 (UTC) Received: by mail-it1-f200.google.com with SMTP id b137-v6so16240802iti.8 for ; Fri, 23 Nov 2018 20:30:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Wq9XLEhBsJKtirOZjsJKbRtJTvl36ejiwyBxqad23fg=; b=MTgEO/c7K1AWfGRVqYWW6MmH1qNcvRmiRZv75AX7p20h2lmgcU+XxOr1+Nrg7ksJ4q IFwxKsOIkD4Yy0n8Fx5JnToseB5FqvBEovcr7FiMe1VxHb7clLHX7Svf16I3p59JW4vC ejr3js0gfFJR9SHz+tmsszylwLzPqG5/haTYw= 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=Wq9XLEhBsJKtirOZjsJKbRtJTvl36ejiwyBxqad23fg=; b=HfYZRD423SyR6k6emOb3dhSWMfJfg/BKSltKI8sWUjTNxD9vBoTgj8dpNb3eqyiUbo 4NFrH9NqTz5Ct2FxGVnkPGzco3OPQNxhhKsVmOSOP1XUVS/ZrjQMPc9hjgwH20pgYhQH C9H8bfJoCjndlliZcmHclVtTkdD3L3B2NPjjEScJhDFNyfRBh1ijo11sx2qtXhB6h8n9 JAn97hEJwpJl/y0og0F9GjcgnLyoHJ6j/EnqpBm1b3lY3FOJxWxetYCiQeEvf6E0uMPc bP+B3GhrDIhpPvqkQWTwWbFM/ruc7nqOcWi73hdGaPv9SkQlQbxkeIKi25KcEIVXG9rT NOkw== X-Gm-Message-State: AGRZ1gJMjCArYTO8pJoWMuFy2slEV7kZ0Q1Rz/nn8qrjSLFeJetE+WDm vK28Przqrpy/m5/gWmSWRaDbCko42gnB102R X-Google-Smtp-Source: AFSGD/WtpFvS7hcz5sN9kO4Zmsp9YGfC1FrkyfXxzv1WnbRTcqGx5804E9QdwcrChynz7ZIK84O1B8O9yW0TlklG X-Received: by 2002:a24:5948:: with SMTP id p69mr11393796itb.21.1543033816240; Fri, 23 Nov 2018 20:30:16 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:33 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-11-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Miquel Raynal Subject: [U-Boot] [PATCH 10/21] tpm: Export tpm_clear_and_reenable() 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" This function is intended to be exported but is not. Add it to the header file. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- include/tpm-common.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/tpm-common.h b/include/tpm-common.h index 91a1484b3d6..f9c2ca20539 100644 --- a/include/tpm-common.h +++ b/include/tpm-common.h @@ -209,6 +209,14 @@ int tpm_open(struct udevice *dev); */ int tpm_close(struct udevice *dev); +/** + * tpm_clear_and_reenable() - Force clear the TPM and reenable it + * + * @dev: TPM device + * @return 0 on success, -ve on failure + */ +u32 tpm_clear_and_reenable(struct udevice *dev); + /** * tpm_get_desc() - Get a text description of the TPM * From patchwork Sat Nov 24 04:29:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002592 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="J0FA1uX2"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320qQ2x4Nz9s7W for ; Sat, 24 Nov 2018 15:40:50 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1E102C2244D; Sat, 24 Nov 2018 04:32: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.8 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID, UPPERCASE_50_75 autolearn=no autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id AC88AC22491; Sat, 24 Nov 2018 04:30:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A2A0EC22461; Sat, 24 Nov 2018 04:30:19 +0000 (UTC) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by lists.denx.de (Postfix) with ESMTPS id E6244C22465 for ; Sat, 24 Nov 2018 04:30:18 +0000 (UTC) Received: by mail-io1-f70.google.com with SMTP id t133so12741464iof.20 for ; Fri, 23 Nov 2018 20:30:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=sNIVYphtWqun+M5O7rkZxpIFIEOST5l5UbntIn1yEAY=; b=J0FA1uX21dhK5WNa3uNjrbu6+9HY/a2PWambluJMMW6Kg+B4/dK2kBGBkgEpC57fDk lpw273ShnUWUmce4Y6rIM7p5aTQ4afnTVf07j234BZDBae7e4PcbICiJZvUP1eYM52ta 70ke662WOTp5NJYSak9ButjEjTTFlj8htyRlM= 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=sNIVYphtWqun+M5O7rkZxpIFIEOST5l5UbntIn1yEAY=; b=saIXw85lJ1zFlIDVusricIus1TWdSCaj3+o6/ORdiLRddpr7Rw9gc83VAIxfiwPT4t sYoDWlmjtnakeYkXNzzHR/c1Xgok3WbmbtQR3h5BQpjqL9v9r/gro0AqmUmNfc1bxx2C +5fFLiJL293FPNlBcv0yubKB+yi8/tw7XZmGzkEyxiVwOyYHKkxgviwt0g6hiC80Yfhr QXx+Updxk+jh6smhtaS4aVC5lmRfAMsexI5GGyW/LyL/7gOHjrh4D9P63duyhaGJp9Bx GATzm5DnNBpQtnaNmWPVDFYD86y6RH91ekZm/Uy68gUFINQSf/zlFgRpTU9B+mG4TDMJ fiQw== X-Gm-Message-State: AA+aEWZSQhYglU/OG9WhpM/LqoSe8Ua/RGKw3HPb77akeSXvL2SX0ZvA mTYnkbeBpXgOwKc36S/+V+3fe2hXfpVeGQYf X-Google-Smtp-Source: AJdET5c8ZbW1RQ8jPq/iptCap/0y1qJBzQpC7d2W+ktEOLbdkSjU76IYk9xeFjKHa3WSA1Gk/WUFQOQOrGDx1Sw+ X-Received: by 2002:a24:5650:: with SMTP id o77-v6mr11912910itb.23.1543033817988; Fri, 23 Nov 2018 20:30:17 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:34 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-12-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Miquel Raynal Subject: [U-Boot] [PATCH 11/21] tpm: Add non-volatile index attributes needed for v2 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" Version-2 TPMs support attributes for nvdata. Add definitions to the header file so that clients can use it. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- include/tpm-v2.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/include/tpm-v2.h b/include/tpm-v2.h index 2f2e66de195..ae00803f6d9 100644 --- a/include/tpm-v2.h +++ b/include/tpm-v2.h @@ -128,6 +128,39 @@ enum tpm2_algorithms { TPM2_ALG_NULL = 0x10, }; +/* NV index attributes */ +enum tpm_index_attrs { + TPMA_NV_PPWRITE = 1UL << 0, + TPMA_NV_OWNERWRITE = 1UL << 1, + TPMA_NV_AUTHWRITE = 1UL << 2, + TPMA_NV_POLICYWRITE = 1UL << 3, + TPMA_NV_COUNTER = 1UL << 4, + TPMA_NV_BITS = 1UL << 5, + TPMA_NV_EXTEND = 1UL << 6, + TPMA_NV_POLICY_DELETE = 1UL << 10, + TPMA_NV_WRITELOCKED = 1UL << 11, + TPMA_NV_WRITEALL = 1UL << 12, + TPMA_NV_WRITEDEFINE = 1UL << 13, + TPMA_NV_WRITE_STCLEAR = 1UL << 14, + TPMA_NV_GLOBALLOCK = 1UL << 15, + TPMA_NV_PPREAD = 1UL << 16, + TPMA_NV_OWNERREAD = 1UL << 17, + TPMA_NV_AUTHREAD = 1UL << 18, + TPMA_NV_POLICYREAD = 1UL << 19, + TPMA_NV_NO_DA = 1UL << 25, + TPMA_NV_ORDERLY = 1UL << 26, + TPMA_NV_CLEAR_STCLEAR = 1UL << 27, + TPMA_NV_READLOCKED = 1UL << 28, + TPMA_NV_WRITTEN = 1UL << 29, + TPMA_NV_PLATFORMCREATE = 1UL << 30, + TPMA_NV_READ_STCLEAR = 1UL << 31, + + TPMA_NV_MASK_READ = TPMA_NV_PPREAD | TPMA_NV_OWNERREAD | + TPMA_NV_AUTHREAD | TPMA_NV_POLICYREAD, + TPMA_NV_MASK_WRITE = TPMA_NV_PPWRITE | TPMA_NV_OWNERWRITE | + TPMA_NV_AUTHWRITE | TPMA_NV_POLICYWRITE, +}; + /** * Issue a TPM2_Startup command. * From patchwork Sat Nov 24 04:29:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002593 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="KmudJhLu"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320rD43cBz9s7W for ; Sat, 24 Nov 2018 15:41:32 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3E1D3C22472; Sat, 24 Nov 2018 04:34: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=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID 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 AF3FAC22480; Sat, 24 Nov 2018 04:31:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AC61CC2244D; Sat, 24 Nov 2018 04:30:24 +0000 (UTC) Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by lists.denx.de (Postfix) with ESMTPS id 1A6F8C22476 for ; Sat, 24 Nov 2018 04:30:21 +0000 (UTC) Received: by mail-ot1-f72.google.com with SMTP id a19so2830566otq.1 for ; Fri, 23 Nov 2018 20:30:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=o1MBkY0ZkjrsoR8+ksI3rAAc9zxKIE8c1Ly0u2m9IlY=; b=KmudJhLuZcjpoGNQ5i62r/lglF1Sad+0qSPzRhu+org/C5VdsPcOfDZYvyLEUiKmQ3 2t5EWM83j5oHlmBsK8X66biWtz6GyeuYESyAblDUCI6rvdH7gQ2LB14AKTZkrrE6fDlm 6lY5tF88xI7wIq7mszAGS7mQdr4Je4qhhbRd4= 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=o1MBkY0ZkjrsoR8+ksI3rAAc9zxKIE8c1Ly0u2m9IlY=; b=WtAZ+UZCOAozjrG5Y+87HsfxlLegr9KSX8KBwBxK0b/F7zsvW8cU/ZiRnWMCkuck/x sggfbqIpVEt+DIMzobIBL04yrtZrqfSMBjX71L9RnBtiIXnVYHcUHCuXrd0zJYGpzKzF IOl9rBNnA/UgihDII+mrEOH4eH82WTHakgBaPrGDEzUkxI/Dcqjv/xVBQ6BbhJsWD9ZX 0XilDesRrhhzqjTk7u9bVKilhKLXobYwzHawJmP16+vnOaEngCEQyXMAbQizskkhgCFn eE0OUcsDhdOtsIrC4qzkmDi4mFiYadzKiGzuWTMSY2sSBAw5YCk3R1M+PiFH2YjaSLVu L2mg== X-Gm-Message-State: AGRZ1gJEPB2JSjbiYBzL+C8YTh0YVntKOPobZIUhmrdHP5U5eB43YfIy CXH1IOKy6keyDrQoqmnSKKks9bf8YPz/4s2N X-Google-Smtp-Source: AJdET5dHdUQwCwEAyXXSj246h+vt5r6WOCYJwJz08Ev55xNX7tpTuLcUZ5MY5fptg4Ok5L3AkyQA3ll5wF8/gmvc X-Received: by 2002:aca:580a:: with SMTP id m10-v6mr12170158oib.19.1543033819710; Fri, 23 Nov 2018 20:30:19 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:35 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-13-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Miquel Raynal Subject: [U-Boot] [PATCH 12/21] tpm: Fix a logging warning in unpack_byte_string() 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" Fix the printf() string to avoid a warning. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- lib/tpm-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tpm-common.c b/lib/tpm-common.c index 2bf0b41e26f..86b4f413c2e 100644 --- a/lib/tpm-common.c +++ b/lib/tpm-common.c @@ -119,7 +119,7 @@ int unpack_byte_string(const u8 *str, size_t size, const char *format, ...) if (offset + length > size) { va_end(args); - log_err("Failed to read: size=%d, offset=%x, len=%x\n", + log_err("Failed to read: size=%zd, offset=%zx, len=%zx\n", size, offset, length); return -1; } From patchwork Sat Nov 24 04:29:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002585 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UYJsvgyc"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320lM1RD8z9s7W for ; Sat, 24 Nov 2018 15:37:19 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id E9E0CC2245D; Sat, 24 Nov 2018 04:35: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, T_DKIM_INVALID 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 D5ADEC22463; Sat, 24 Nov 2018 04:31:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 18E99C2249D; Sat, 24 Nov 2018 04:30:25 +0000 (UTC) Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) by lists.denx.de (Postfix) with ESMTPS id 3D26FC22457 for ; Sat, 24 Nov 2018 04:30:22 +0000 (UTC) Received: by mail-it1-f197.google.com with SMTP id v3so16264748itf.4 for ; Fri, 23 Nov 2018 20:30:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=OyU2A3xeHCAViRcHk9ahKQFQJ9v1JSmhMkXdjR9rnLw=; b=UYJsvgycA+2V/Iy2LmYdet9eU9fB6t5HGECjk8nSlXox5UZaiXj9cDtxvblMs2556C uszGNGYgxKtSfngHQQEoCELGeHQfL9viHLx+o87QUtqoh6jyPlGc8KLGefTNkU/Exlw1 qKja71eJPfTiOf3hgF5HfYgQKtfm8amJVecOE= 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=OyU2A3xeHCAViRcHk9ahKQFQJ9v1JSmhMkXdjR9rnLw=; b=rCqx8KfxvYCVb4jcZKpm7mHL/M3f+Ey5+xxr9hjdAvTGFeU3g2pXkXGWQ5CJXVM2mo xT+/5FZ7diluQK9wXG9ApEXp9lyP1Qnp95KTaRddZh5vptbMBnAngH1NNehJlzreiL1m ds1eYPjOfvxEc+N9kTXrTW4BfAKsYt1dQnr6L072zVGlE29VIQb32iSkuTWSI1bJ3vJV r0xTMOeDtTWhBdSw+FsZhPLG/3daDEeZitqlUfrdmKmSdh1uFdaKtAPR1H9H2/nRd9ZU /EXgH8bDbzHL9bdxZGn2ojVdFgFvABxP9qiVjD9dOlB1DSwAzo3K05joW9elhG45fL++ XC3g== X-Gm-Message-State: AGRZ1gIezlWWdVilTkyMIqbajmN2oslcaegKJRvSS7CNTyFklpisxB+I izeRso8QGIWZ7gWfCKL5acLEA5MWsRoi8k8D X-Google-Smtp-Source: AJdET5fRvjpY2wUXMJ9yCIp0pzVwMPO1XY/sUNDprQVwyh/DSerzKpFtIBvV1xK+tXhUHcuOQYoSpFSQC5eeixx7 X-Received: by 2002:a24:76d4:: with SMTP id z203-v6mr11528524itb.24.1543033821268; Fri, 23 Nov 2018 20:30:21 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:36 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-14-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 13/21] cros: Correct a printf() string and comment 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" Correct a warning that occurs on sandbox. Also fix the comment style in cros_ec_set_lid_shutdown_mask(). Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/misc/cros_ec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 2dcdb3d8d61..565de040fe9 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -420,7 +420,7 @@ int cros_ec_read_id(struct udevice *dev, char *id, int maxlen) ret = ec_command_inptr(dev, EC_CMD_GET_VERSION, 0, NULL, 0, (uint8_t **)&r, sizeof(*r)); if (ret != sizeof(*r)) { - log_err("Got rc %d, expected %d\n", ret, sizeof(*r)); + log_err("Got rc %d, expected %u\n", ret, (uint)sizeof(*r)); return -1; } @@ -1466,7 +1466,7 @@ int cros_ec_set_lid_shutdown_mask(struct udevice *dev, int enable) if (ret < 0) return ret; - // Set lid close event state in the EC SMI event mask + /* Set lid close event state in the EC SMI event mask */ if (enable) mask |= EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED); else From patchwork Sat Nov 24 04:29:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002580 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mg2iNAHH"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320jg69GBz9s7W for ; Sat, 24 Nov 2018 15:35:51 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 67FD9C223D9; Sat, 24 Nov 2018 04:33: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, T_DKIM_INVALID 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 DE228C22482; Sat, 24 Nov 2018 04:30:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 14006C22452; Sat, 24 Nov 2018 04:30:27 +0000 (UTC) Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by lists.denx.de (Postfix) with ESMTPS id 3424DC2246E for ; Sat, 24 Nov 2018 04:30:24 +0000 (UTC) Received: by mail-ua1-f69.google.com with SMTP id h13so2332858uao.21 for ; Fri, 23 Nov 2018 20:30:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=njn+SOtb/yIN0j98IaX74nDqQ/vkAcpbPso5yGRFDVA=; b=mg2iNAHHq2Gy0NAmr6ZGnSdl2gxYK4zd7UuWEUv2vt3dc/hYopENhaIrjZkIuHxYlK ejzcwiaY9cemVC96PcVGlSB45rjIg4XJ2joo9I8FUzde1Tj60WZFFtlfVgS+uB/eCE2R geTgGFDzitmuxuT4QnlxiS4ZPJ2/TQiJCKVh4= 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=njn+SOtb/yIN0j98IaX74nDqQ/vkAcpbPso5yGRFDVA=; b=uZIhXWxAVmieaC8WqBqXJU1ZCDiw8uQNdtdAzekuNERpz/bvAQ2DCKWWvgPxakLim3 kj/BhUbmSce2+Qxk9RJg2c/d2zwVHc0UQfV0mHTaM9RvFgFCLBYH9vBu8PSzvSbppQbL iv894mT2AsPdlBy0CASyx1tqQ7cuM634NOxKRcZQJ2t+UdPEJwvctkreODjJoRCefGIS wW9hlQsjJ6cuDHt8yrud+M1Dlo7AgZyj8vAG++JZvw847bjnx58+QVKfrmwWQemAEo4z ox4T1jlTaYl6tgq5CDYCIK8MsFDITalUoyNU9wCyNOq1siskEKOmeNIL0jkO2QXUpOBU HW9g== X-Gm-Message-State: AGRZ1gKA4zLq3iY/RjYHgADfUFsHAaZXy+tmUlTUuvB2ipT3nHtA2D7q LHuOLca3tf+lNlT4xHjmgHEJ8q/yxdp/2kh5 X-Google-Smtp-Source: AJdET5d06v8wNWcdCMaKpE39zsUZi/39DGL3UMcATgw6Xa/gq7fwFJo0OHDyOkytT1t2AtprX1h1aCT/JQvcVFQC X-Received: by 2002:a67:6948:: with SMTP id e69mr13916137vsc.25.1543033823012; Fri, 23 Nov 2018 20:30:23 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:37 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-15-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 14/21] cros_ec: Adjust to use v1 vboot context only 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 are no users of the 64-byte v2 context. The v1 context is only 16 bytes long and currently an error is raised if too much data is returned from the EC. Update the code to limit the size to 16 bytes. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/misc/cros_ec_sandbox.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c index 429f1a9b269..4fcb2d96f51 100644 --- a/drivers/misc/cros_ec_sandbox.c +++ b/drivers/misc/cros_ec_sandbox.c @@ -313,13 +313,15 @@ static int process_cmd(struct ec_state *ec, switch (req->op) { case EC_VBNV_CONTEXT_OP_READ: + /* TODO(sjg@chromium.org): Support full-size context */ memcpy(resp->block, ec->vbnv_context, - sizeof(resp->block)); - len = sizeof(*resp); + EC_VBNV_BLOCK_SIZE); + len = 16; break; case EC_VBNV_CONTEXT_OP_WRITE: - memcpy(ec->vbnv_context, resp->block, - sizeof(resp->block)); + /* TODO(sjg@chromium.org): Support full-size context */ + memcpy(ec->vbnv_context, req->block, + EC_VBNV_BLOCK_SIZE); len = 0; break; default: From patchwork Sat Nov 24 04:29:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002587 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="EOXrPTMW"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320mM0gzkz9s7W for ; Sat, 24 Nov 2018 15:38:11 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C977FC22459; Sat, 24 Nov 2018 04:34: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=T_DKIM_INVALID 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 D302FC22464; Sat, 24 Nov 2018 04:31:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 258F9C2245D; Sat, 24 Nov 2018 04:30:29 +0000 (UTC) Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by lists.denx.de (Postfix) with ESMTPS id D124AC22462 for ; Sat, 24 Nov 2018 04:30:25 +0000 (UTC) Received: by mail-vs1-f72.google.com with SMTP id u29so5521287vsj.1 for ; Fri, 23 Nov 2018 20:30:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=2zvea5rhmg4bv25hEML4W4bzT8IuBdvNDiOMXXcle0o=; b=EOXrPTMW21d4sWszU2ZDQ69JWfhdfneJtkdDzNjdhhnR7IY3zoUdups4JbJ1jRGd66 AUocslAiTMWISsyuNoWaZj5EDOKvMQpOvAJ76WKgziaP8AyKe4p3yxT6n4+WhBLHWKM/ Nh1ejlgvk6Q5n066nlTv0gq1ZZH5tkj4nlong= 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=2zvea5rhmg4bv25hEML4W4bzT8IuBdvNDiOMXXcle0o=; b=rUtF4WO13hbj60RcuwHA2uZ5luSZNxf9OJnia02C+ozp9vf8SQI0B+xkXslFdjznAr q/T7SDcDdNMhyxNq2/nPSfugJMl7+9Uu99sFV/xm25MeM3uNhCECXlqJ1MFSHGlgyERq qRV5KFDrv7k9iXjRSlrXhKNDFjSUGL+gtbrbO3spxWlp90uNIeCGED+NVPRr6QsV8bYw UeytQeH4tWLkH4oUiE24Yhmsas5jzeTUPe1EhUludscafVqMJ+yZH47UlBRQqtHzOH07 nPJ5rSV+zp+9N404Rvqz2S9Km6qzaqdDt/wWL+SiRw3n7l0X9CWnxtoHQMfzJYh9z3gQ YCKw== X-Gm-Message-State: AA+aEWZF7oWVBoEnVKl11Di6co7hkfg9MSyGH45b2pPV3s0pbbShdy4J noPTbOPAYlsiOSRVdv4DCMJFwLM7VvUEVCOV X-Google-Smtp-Source: AFSGD/U5kWm1spWEdCbNBL84KwnQrPPMBA7rTVjtTn510h4+kbWBPl2Rialo2JkV3BG+X7rrSkafhyv+mEk6RfCs X-Received: by 2002:a1f:29d3:: with SMTP id p202mr13093388vkp.0.1543033824834; Fri, 23 Nov 2018 20:30:24 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:38 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-16-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 15/21] input: i8042: Use remove() instead of exported functions 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 not have exported functions in a driver. The i8042_disable() function is used to disable the keyboard. Provide a remove() method instead, which is the standard way of disabling a device. We could potentially add a method to flush input but that does not seem necessary. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/input/i8042.c | 35 ++++++++++++++++++++--------------- include/i8042.h | 15 --------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c index 5678f8e3cfb..9a5dc46207c 100644 --- a/drivers/input/i8042.c +++ b/drivers/input/i8042.c @@ -167,19 +167,8 @@ static int kbd_controller_present(void) return in8(I8042_STS_REG) != 0xff; } -/* - * Implement a weak default function for boards that optionally - * need to skip the i8042 initialization. - * - * TODO(sjg@chromium.org): Use device tree for this? - */ -int __weak board_i8042_skip(void) -{ - /* As default, don't skip */ - return 0; -} - -void i8042_flush(void) +/** Flush all buffer from keyboard controller to host*/ +static void i8042_flush(void) { int timeout; @@ -202,7 +191,13 @@ void i8042_flush(void) } } -int i8042_disable(void) +/** + * Disables the keyboard so that key strokes no longer generate scancodes to + * the host. + * + * @return 0 if ok, -1 if keyboard input was found while disabling + */ +static int i8042_disable(void) { if (kbd_input_empty() == 0) return -1; @@ -266,7 +261,7 @@ static int i8042_start(struct udevice *dev) char *penv; int ret; - if (!kbd_controller_present() || board_i8042_skip()) { + if (!kbd_controller_present()) { debug("i8042 keyboard controller is not present\n"); return -ENOENT; } @@ -294,6 +289,15 @@ static int i8042_start(struct udevice *dev) return 0; } +static int i8042_kbd_remove(struct udevice *dev) +{ + if (i8042_disable()) + log_debug("i8042_disable() failed. fine, continue.\n"); + i8042_flush(); + + return 0; +} + /** * Set up the i8042 keyboard. This is called by the stdio device handler * @@ -348,6 +352,7 @@ U_BOOT_DRIVER(i8042_kbd) = { .id = UCLASS_KEYBOARD, .of_match = i8042_kbd_ids, .probe = i8042_kbd_probe, + .remove = i8042_kbd_remove, .ops = &i8042_kbd_ops, .priv_auto_alloc_size = sizeof(struct i8042_kbd_priv), }; diff --git a/include/i8042.h b/include/i8042.h index 2b9e5c4d371..8d69fa13bc2 100644 --- a/include/i8042.h +++ b/include/i8042.h @@ -72,19 +72,4 @@ #define BRK 0x0100 /* make break flag for keyboard */ #define ALT 0x0200 /* right alt */ -/* exports */ - -/** - * Flush all buffer from keyboard controller to host. - */ -void i8042_flush(void); - -/** - * Disables the keyboard so that key strokes no longer generate scancodes to - * the host. - * - * @return 0 if ok, -1 if keyboard input was found while disabling - */ -int i8042_disable(void); - #endif /* _I8042_H_ */ From patchwork Sat Nov 24 04:29:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002589 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="SNldipCt"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320mx4Kfnz9s7W for ; Sat, 24 Nov 2018 15:38:41 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 51F19C22469; Sat, 24 Nov 2018 04:34: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=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID 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 D4577C2248E; Sat, 24 Nov 2018 04:31:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8C676C22457; Sat, 24 Nov 2018 04:30:30 +0000 (UTC) Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by lists.denx.de (Postfix) with ESMTPS id 2E24CC22478 for ; Sat, 24 Nov 2018 04:30:27 +0000 (UTC) Received: by mail-qk1-f199.google.com with SMTP id k203so13645166qke.2 for ; Fri, 23 Nov 2018 20:30:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Y6FdbhUW5ONR/SKUGylfoEC78OFfY5Xk55ScOeEfMMg=; b=SNldipCtW+Vw3oRirGQ9L18CYIYXyJL92lgln65ZcocL7UdnAf7ZxDV4knMYCzeoBI KlMCI1ALI1Y2u8weuEBTTrzwKciVGJQdpbZaMgZZnrkG5qOpPbh1eBYwTne7IX9EGzQr sbBvizGJl3hNZilyGvF5RLvALN8Cbs0htdK28= 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=Y6FdbhUW5ONR/SKUGylfoEC78OFfY5Xk55ScOeEfMMg=; b=KCxf592zHv5TFzgkCuzVmAGOYDwRsO86OLM8OuDuIu76d1TQggoNXmfuuNFD5Ea0Bh R7Xk02zrcsygJXvqrjdO3be0IsXH2Nx3B7OWkJI57s8hlzHUXAJP2uhFryWdI1C/yWiI jhm6QGEQI3cRM3w5y4Klt0WL0ggY8uCcqBpmeDVdoRcA0BYlWNfqFZ5oN89qot6jYLiv GpWT6xclo9GBEHvblxg5He8L6PJqcCg7OzZQ6zWuMEPZf0lssIUyM/M7DlDJqglQ7bkl ++0lZthLuUQbJdqO0bctg/1Oz1eoWiDE6G8iYmHx8z7Ec7dOWNeY28bf78f+LdeIsX85 rVfg== X-Gm-Message-State: AGRZ1gIiu10i+Uyr39iNbXId081guVLOFO794iKJTuG7GhpfDdYj1M0V sVQfIdmJERsWSAJrpvl0DKsf9jGmg8vFQN6y X-Google-Smtp-Source: AJdET5cwEK9ljKKHEyQiUHjCVcU6Pj9WiOk/Flfw/9DMZwQ5ygzxX62JWif3B6w2K4iq7A/chWbkWePTDrgQW+E7 X-Received: by 2002:ac8:21e1:: with SMTP id 30mr11442210qtz.55.1543033826317; Fri, 23 Nov 2018 20:30:26 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:39 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-17-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 16/21] video: backlight: Fix log message in enable_sequence() 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" This has an extra argument. Remove it. Signed-off-by: Simon Glass Acked-by: Anatolij Gustschin Acked-by: Anatolij Gustschin --- drivers/video/pwm_backlight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/pwm_backlight.c b/drivers/video/pwm_backlight.c index c13a9077090..bd733f5f1ca 100644 --- a/drivers/video/pwm_backlight.c +++ b/drivers/video/pwm_backlight.c @@ -78,7 +78,7 @@ static int enable_sequence(struct udevice *dev, int seq) ret = regulator_set_enable(priv->reg, true); if (ret) { log_debug("Cannot enable regulator for PWM '%s'\n", - __func__, dev->name); + dev->name); return log_ret(ret); } mdelay(120); From patchwork Sat Nov 24 04:29:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002582 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Vxh8HTil"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320k94vTfz9s8F for ; Sat, 24 Nov 2018 15:36:17 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4FBAAC22469; Sat, 24 Nov 2018 04:33:28 +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, T_DKIM_INVALID 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 C99F2C22490; Sat, 24 Nov 2018 04:30:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E4027C2245E; Sat, 24 Nov 2018 04:30:32 +0000 (UTC) Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by lists.denx.de (Postfix) with ESMTPS id DE4B7C2244F for ; Sat, 24 Nov 2018 04:30:28 +0000 (UTC) Received: by mail-qk1-f197.google.com with SMTP id k203so13645240qke.2 for ; Fri, 23 Nov 2018 20:30:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=N2CMDTm91v7hJrZaO/2B6oX8aJOBEsZDQlUSL96Lf+0=; b=Vxh8HTilXelY6gNChOzfpBPiuwiksw5M49MEYEgtl0sBR1ZDQrHjj93/upM4fuOnqL HNpPFmSWxqSXkLbz/cRm3OGbq3j9+uEuL9XakjM8FcRuosrvCpWF96oP9AbMSZT56QFP dUvxx7Se8lAFPRITKcR+RvC3vhiBcmSEHRUuU= 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=N2CMDTm91v7hJrZaO/2B6oX8aJOBEsZDQlUSL96Lf+0=; b=DazcGWtj6pslVcMu1yKBtOw0sIMztThsvrTCmDCs+ogbCbNquUUVRqn8ihMQhNjowV NQOH8u44ODVR59iGUQyB6GUgrqteL8gqI5FWG/dGIQ8lT1r+lIlz46SiK4ZRahaniJ5+ MGEA8r4yOlD13UXaahYzOvnhnLPuDJUO3rik1YVjbB0Rrr5ZR+FSR4qRSjHTQvee/1aj 4t59ZNIC2Mr5t9LtkuJQ8WijRQVIiwoHkSoFSfiHqv0Yr0WtRjNzT0jfbsDcaSIkl00o juwCDmape4tMD/tlM8At9usLoR3815tu6DZeDpTCwsfbUQpLj/X8Yiodvuw17SPcdrkS RUOg== X-Gm-Message-State: AA+aEWZTWPVgv47yoWRSpbxrcGuTgAltr7CtLqClH3+Hhq7LT+/xYhfI swHEReqwoh+3w9d3lxGgILiM5SxuKI6m2c6O X-Google-Smtp-Source: AFSGD/UjStuQT8ePQQuBB1e116osFUAVKkEj3s32mqppw1FK58iuSou/4vxjJ2UQnaVEDbHHvTFpxvy84/lwW+Vo X-Received: by 2002:a37:4f0e:: with SMTP id d14mr10736910qkb.45.1543033827984; Fri, 23 Nov 2018 20:30:27 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:40 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-18-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 17/21] time: Update mdelay() to delay in one large chunk 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 function delays in one millisecond at a time. This does not work well on sandbox since it results in lots of calls to usleep(1000) in a tight loop. This makes the sleep duration quite variable since each call results in a sleep of *at least* 1000us, but possibly more. Depending on how busy the machine is, the sleep time can change quite a bit. We cannot fix this in general, but we can reduce the effect by doing a single sleep. The multiplication works fine with an unsigned long argument up until a sleep time of about 4m milliseconds. This is over an hour and we can be sure that delays of that length are not useful. Update the mdelay() function to call udelay() only once with the calculated delay value. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- include/linux/delay.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/delay.h b/include/linux/delay.h index 193603451a7..71a38e15fbd 100644 --- a/include/linux/delay.h +++ b/include/linux/delay.h @@ -10,8 +10,7 @@ void udelay(unsigned long usec); static inline void mdelay(unsigned long msec) { - while (msec--) - udelay(1000); + udelay(1000 * msec); } static inline void ndelay(unsigned long nsec) From patchwork Sat Nov 24 04:29:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002595 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="KzUw418Z"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320t706jlz9s7W for ; Sat, 24 Nov 2018 15:43:10 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9F5B6C22481; Sat, 24 Nov 2018 04:33: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=T_DKIM_INVALID 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 B36F6C2246C; Sat, 24 Nov 2018 04:30:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DE247C2249F; Sat, 24 Nov 2018 04:30:35 +0000 (UTC) Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by lists.denx.de (Postfix) with ESMTPS id 8734FC2247D for ; Sat, 24 Nov 2018 04:30:30 +0000 (UTC) Received: by mail-qt1-f197.google.com with SMTP id w18so10439038qts.8 for ; Fri, 23 Nov 2018 20:30:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xjdSqKf25K7nzJXuUlPzFzcclbFV6CuiYAfJfHhNAs8=; b=KzUw418ZLe4gVac8/hQV3qNBuQT4vcnV7cjypMeE1yxMOLhqtkH/2Xwca5/kOu3p5p zBmXuBNi/fjvOBNXMc4h17mgprcS9Lv8khYCmEApq4h4q5Nz4exaRCY5/PuHSqQF8aoS GhifIzUKucthvQMgn595CwFncNNXQsVE/5h/k= 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=xjdSqKf25K7nzJXuUlPzFzcclbFV6CuiYAfJfHhNAs8=; b=kHmtjwfO2fvn0AyJbI/ydlBMLF2yd/6CT/nVoNoG3MNUVQqme2jRNUN2ANUs7PeGYw uOlUaZe0T43BE/tP5+PieAhYxL7pfz2FSiGWfYuodPR8d5yHcIelxwcfbx1sUFZIVw4H mZwQODHm4P4gp0ChQUA2QigV3yWAn2KVTH/C9ElkHum1qdnbNesTr1I7C2kd1k0V3XlT s4SHrb1DkqEzNwu5wpb20FLB5jJQcGO1CkDJr0cXjAp3Y54vW+obK5bgpjL9wCcR4Daj 0LiDS+VLRzAw3NorOYKTTXvh1rlh4umpWmaeTbfr0BbpBa13gkOYVTvuvnOugUa4Ld9M W4Cg== X-Gm-Message-State: AA+aEWaLKGRlDFfGULB2iJ1VI9vBvqmUHaTX9r+fna1relBLWlEifrzk 7kSQBTy5WgCvXrosDk5n02Ev9795bsXOsubh X-Google-Smtp-Source: AJdET5dHcBUZQPvCIprMoJqHBI3llENboClnkVMjPbr8pu3XIsctf7HlSSS+jt0NmLt2gue8207CwJs/2a6RjoXh X-Received: by 2002:aed:35a4:: with SMTP id c33mr11356997qte.40.1543033829614; Fri, 23 Nov 2018 20:30:29 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:41 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-19-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH 18/21] log: Check printf() arguments 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 logging does not check printf() arguments. Now that all users have been corrected, enable this to prevent further problems. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- include/log.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/log.h b/include/log.h index 4f14937b7a2..310b2cf7ce5 100644 --- a/include/log.h +++ b/include/log.h @@ -73,7 +73,8 @@ static inline int log_uc_cat(enum uclass_id id) * @return 0 if log record was emitted, -ve on error */ int _log(enum log_category_t cat, enum log_level_t level, const char *file, - int line, const char *func, const char *fmt, ...); + int line, const char *func, const char *fmt, ...) + __attribute__ ((format (__printf__, 6, 7))); /* Define this at the top of a file to add a prefix to debug messages */ #ifndef pr_fmt From patchwork Sat Nov 24 04:29:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002588 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="fcKCYBOl"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320mb47tRz9s7W for ; Sat, 24 Nov 2018 15:38:23 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 42DC3C2247C; Sat, 24 Nov 2018 04:35:55 +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, T_DKIM_INVALID 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 368BDC2245D; Sat, 24 Nov 2018 04:33:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5C78EC22461; Sat, 24 Nov 2018 04:30:38 +0000 (UTC) Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by lists.denx.de (Postfix) with ESMTPS id 6B293C2246A for ; Sat, 24 Nov 2018 04:30:32 +0000 (UTC) Received: by mail-io1-f72.google.com with SMTP id x5so10554362ion.1 for ; Fri, 23 Nov 2018 20:30:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=MfsS+D3farW3hgBpYosBbOhM/Eqr8aRSe61kICuTZoo=; b=fcKCYBOlbmzthQI6iHtHpBCDyIp8VLRQssFH8VGjezSgVW8UORfHDAhvYsp4SBrwdn xL0lWliyx/NMOQvUgagZiMhi/rLJLTz+VcRCODptyB1fwNYK+DtEBejtImzVI+kom6za aGQuIcXbnvu7v4/A0qOwRGrz655yGxSIXTMdA= 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=MfsS+D3farW3hgBpYosBbOhM/Eqr8aRSe61kICuTZoo=; b=pkKqD7WvJcwjFsewkCyPeSLywcgCJdE5Q/x/KwO9XadtoOC5O6A68Ky5tMTB6yaKO/ DLVTrUMvHOi83p0dbSE4HrBOR45n/lGf3R3UcjYwJRh7Hpmd2w+zXZ3IRhT+YPRoel55 yM2R/6l5ZyNkvBCJ0QwGOwuBehe6rx77DncVZej2MMTuAzgF4KyIz5H8+54oz5bJpu7q RyVxacMqG+6Wd8IXm3zAul0Wcwu7csXWyv3bVzonFHY30r3F6QY9hCW7119rp11k+JTu dLa+SpqOuzMw/JjwWpn76lJ1qhqr3HbcNizDrfysKvzohmn01NGESbyS4OpgHWI7l0WY OSMQ== X-Gm-Message-State: AGRZ1gI9HM9rgoNFD9TxZ2bixuQcIzajP+xt6+3gi5FCRB9waYrJvL+2 nBGihwpfeCrDW6Ia86IeCcYUswT2hrEpqZqs X-Google-Smtp-Source: AFSGD/WDIMZc7XYper1Ene2kq1+DVIBx33anc7c1PGfosOA4wJmpMn9BWCvuFSEl5GYLCQJQ5ByUUmE93BpEWKli X-Received: by 2002:a24:153:: with SMTP id 80-v6mr11224575itk.19.1543033831426; Fri, 23 Nov 2018 20:30:31 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:42 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-20-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 19/21] Add UINT32_MAX and UINT64_MAX 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" These constants are defined by stdint.h but not by kernel.h, which is its stand-in in U-Boot. Add the definitions so that libraries which expect stdint.h constants can work. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- include/linux/kernel.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 04a09eb4f64..bd88483b9f6 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -33,6 +33,10 @@ #define S64_MAX ((s64)(U64_MAX>>1)) #define S64_MIN ((s64)(-S64_MAX - 1)) +/* Aliases defined by stdint.h */ +#define UINT32_MAX U32_MAX +#define UINT64_MAX U64_MAX + #define STACK_MAGIC 0xdeadbeef #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) From patchwork Sat Nov 24 04:29:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002590 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="HYZTAoxO"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320nc1BDrz9s7W for ; Sat, 24 Nov 2018 15:39:16 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D1A21C22460; Sat, 24 Nov 2018 04:35:18 +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, T_DKIM_INVALID 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 0A6E2C22479; Sat, 24 Nov 2018 04:32:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0E218C2245A; Sat, 24 Nov 2018 04:30:38 +0000 (UTC) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by lists.denx.de (Postfix) with ESMTPS id 065CAC22448 for ; Sat, 24 Nov 2018 04:30:34 +0000 (UTC) Received: by mail-it1-f199.google.com with SMTP id i12so16285616ita.3 for ; Fri, 23 Nov 2018 20:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=8fEderlM9s1zk44Oycod9Pnei5+eSuwlMglOldjWP98=; b=HYZTAoxO2zPA57O3z2V60E64y8QLWr9VF71genepEcaGxBpj+bKxs6AMWaYz9A6ASQ lT4ImzSG7mB8SwEXa+WkcJ0MCq0rPl9wNfxiyw85ogw91stqPlnftrrWbnBDLHkSBepJ wE34ZuVQQnSLOE5ZX6myvyG0iYM1QuUp2tsPw= 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=8fEderlM9s1zk44Oycod9Pnei5+eSuwlMglOldjWP98=; b=CYnXqnU7ur6Ys1jnp05FEDhsJt76liYLMeATUKaXWS37Ppp59gQE3Z719FRcD6vBbt OpFM/d9o4ZljdkNmzReS5Y58RmNE+tAzcllq/Rsn8sIO/ruDVVPsfoeIfvkBgw2CHAG0 FK4R0Q0a536RGWV4YVCLpjA95fFmIUFM48R8frmudsHQ47kP3aXp+whRlRH8ysuIPhPb P/3b9zjwnNCBJ5qxd2itTq1C0LuTGvEdRb0H2P/b+wNS63uaLoc3FUdeQwZZUyH2L+Zb mHJprb4zOBdIYgrx/AnLjr8Ka3ED5JG7XVOkvAfggZPXO6izcVG2HsfDE0IaGjPVEFx2 Fo8w== X-Gm-Message-State: AA+aEWY+P06YLzfRWtYv/0DXZIKfsyKjJJWc+ohcuVoEbqJ1qqoWTYOQ tiZ2Sm8I2Ty3zCH7HW4+kknq8Fa7vRJKhWSm X-Google-Smtp-Source: AFSGD/XD2ccfcphd3mZYfocTnawYdTmDJayrjxjGppT2z+/6ekDpAd6HQ5tuPVB2MmqsiNn52BxQ6hM19njIJisM X-Received: by 2002:a05:660c:70b:: with SMTP id l11mr11505510itk.5.1543033832999; Fri, 23 Nov 2018 20:30:32 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:43 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-21-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 20/21] Add inttypes.h 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" Even if U-Boot does not use this, some libraries do. Add back this header file so that the build does not fall back to using the host version, which may include stdint.h and break the build due to conflicts with uint64_t, etc. This partially reverts commit dee37fc99d94 ("Remove includes and PRI* usages in printf() entirely") The only change from the file that was in U-Boot until recently is that it now comes twice as close to passing checkpatch. The remaining warnings pertain to the typedefs, which checkpatch does not like. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- include/inttypes.h | 271 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 include/inttypes.h diff --git a/include/inttypes.h b/include/inttypes.h new file mode 100644 index 00000000000..dcb6785228c --- /dev/null +++ b/include/inttypes.h @@ -0,0 +1,271 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 1997-2001, 2004, 2007 Free Software Foundation, Inc. + * + * This file is taken from the GNU C Library v2.15, with the unimplemented + * functions removed and a few style fixes. + */ + +/* + * ISO C99: 7.8 Format conversion of integer types + */ + +#ifndef _INTTYPES_H +#define _INTTYPES_H 1 + +#include + +/* Get a definition for wchar_t. But we must not define wchar_t itself. */ +#ifndef ____gwchar_t_defined +# ifdef __cplusplus +# define __gwchar_t wchar_t +# elif defined __WCHAR_TYPE__ +typedef __WCHAR_TYPE__ __gwchar_t; +# else +# define __need_wchar_t +# include +typedef wchar_t __gwchar_t; +# endif +# define ____gwchar_t_defined 1 +#endif + +/* + * The ISO C99 standard specifies that these macros must only be defined if + * explicitly requested + */ +#if !defined __cplusplus || defined __STDC_FORMAT_MACROS + +/* linux/types.h always uses long long for 64-bit and long for uintptr_t */ +# define __PRI64_PREFIX "ll" +# define __PRIPTR_PREFIX "l" + +/* Macros for printing format specifiers. */ + +/* Decimal notation. */ +# define PRId8 "d" +# define PRId16 "d" +# define PRId32 "d" +# define PRId64 __PRI64_PREFIX "d" + +# define PRIdLEAST8 "d" +# define PRIdLEAST16 "d" +# define PRIdLEAST32 "d" +# define PRIdLEAST64 __PRI64_PREFIX "d" + +# define PRIdFAST8 "d" +# define PRIdFAST16 __PRIPTR_PREFIX "d" +# define PRIdFAST32 __PRIPTR_PREFIX "d" +# define PRIdFAST64 __PRI64_PREFIX "d" + +# define PRIi8 "i" +# define PRIi16 "i" +# define PRIi32 "i" +# define PRIi64 __PRI64_PREFIX "i" + +# define PRIiLEAST8 "i" +# define PRIiLEAST16 "i" +# define PRIiLEAST32 "i" +# define PRIiLEAST64 __PRI64_PREFIX "i" + +# define PRIiFAST8 "i" +# define PRIiFAST16 __PRIPTR_PREFIX "i" +# define PRIiFAST32 __PRIPTR_PREFIX "i" +# define PRIiFAST64 __PRI64_PREFIX "i" + +/* Octal notation. */ +# define PRIo8 "o" +# define PRIo16 "o" +# define PRIo32 "o" +# define PRIo64 __PRI64_PREFIX "o" + +# define PRIoLEAST8 "o" +# define PRIoLEAST16 "o" +# define PRIoLEAST32 "o" +# define PRIoLEAST64 __PRI64_PREFIX "o" + +# define PRIoFAST8 "o" +# define PRIoFAST16 __PRIPTR_PREFIX "o" +# define PRIoFAST32 __PRIPTR_PREFIX "o" +# define PRIoFAST64 __PRI64_PREFIX "o" + +/* Unsigned integers. */ +# define PRIu8 "u" +# define PRIu16 "u" +# define PRIu32 "u" +# define PRIu64 __PRI64_PREFIX "u" + +# define PRIuLEAST8 "u" +# define PRIuLEAST16 "u" +# define PRIuLEAST32 "u" +# define PRIuLEAST64 __PRI64_PREFIX "u" + +# define PRIuFAST8 "u" +# define PRIuFAST16 __PRIPTR_PREFIX "u" +# define PRIuFAST32 __PRIPTR_PREFIX "u" +# define PRIuFAST64 __PRI64_PREFIX "u" + +/* lowercase hexadecimal notation. */ +# define PRIx8 "x" +# define PRIx16 "x" +# define PRIx32 "x" +# define PRIx64 __PRI64_PREFIX "x" + +# define PRIxLEAST8 "x" +# define PRIxLEAST16 "x" +# define PRIxLEAST32 "x" +# define PRIxLEAST64 __PRI64_PREFIX "x" + +# define PRIxFAST8 "x" +# define PRIxFAST16 __PRIPTR_PREFIX "x" +# define PRIxFAST32 __PRIPTR_PREFIX "x" +# define PRIxFAST64 __PRI64_PREFIX "x" + +/* UPPERCASE hexadecimal notation. */ +# define PRIX8 "X" +# define PRIX16 "X" +# define PRIX32 "X" +# define PRIX64 __PRI64_PREFIX "X" + +# define PRIXLEAST8 "X" +# define PRIXLEAST16 "X" +# define PRIXLEAST32 "X" +# define PRIXLEAST64 __PRI64_PREFIX "X" + +# define PRIXFAST8 "X" +# define PRIXFAST16 __PRIPTR_PREFIX "X" +# define PRIXFAST32 __PRIPTR_PREFIX "X" +# define PRIXFAST64 __PRI64_PREFIX "X" + +/* Macros for printing `intmax_t' and `uintmax_t'. */ +# define PRIdMAX __PRI64_PREFIX "d" +# define PRIiMAX __PRI64_PREFIX "i" +# define PRIoMAX __PRI64_PREFIX "o" +# define PRIuMAX __PRI64_PREFIX "u" +# define PRIxMAX __PRI64_PREFIX "x" +# define PRIXMAX __PRI64_PREFIX "X" + +/* Macros for printing `intptr_t' and `uintptr_t'. */ +# define PRIdPTR __PRIPTR_PREFIX "d" +# define PRIiPTR __PRIPTR_PREFIX "i" +# define PRIoPTR __PRIPTR_PREFIX "o" +# define PRIuPTR __PRIPTR_PREFIX "u" +# define PRIxPTR __PRIPTR_PREFIX "x" +# define PRIXPTR __PRIPTR_PREFIX "X" + +/* Macros for scanning format specifiers. */ + +/* Signed decimal notation. */ +# define SCNd8 "hhd" +# define SCNd16 "hd" +# define SCNd32 "d" +# define SCNd64 __PRI64_PREFIX "d" + +# define SCNdLEAST8 "hhd" +# define SCNdLEAST16 "hd" +# define SCNdLEAST32 "d" +# define SCNdLEAST64 __PRI64_PREFIX "d" + +# define SCNdFAST8 "hhd" +# define SCNdFAST16 __PRIPTR_PREFIX "d" +# define SCNdFAST32 __PRIPTR_PREFIX "d" +# define SCNdFAST64 __PRI64_PREFIX "d" + +/* Signed decimal notation. */ +# define SCNi8 "hhi" +# define SCNi16 "hi" +# define SCNi32 "i" +# define SCNi64 __PRI64_PREFIX "i" + +# define SCNiLEAST8 "hhi" +# define SCNiLEAST16 "hi" +# define SCNiLEAST32 "i" +# define SCNiLEAST64 __PRI64_PREFIX "i" + +# define SCNiFAST8 "hhi" +# define SCNiFAST16 __PRIPTR_PREFIX "i" +# define SCNiFAST32 __PRIPTR_PREFIX "i" +# define SCNiFAST64 __PRI64_PREFIX "i" + +/* Unsigned decimal notation. */ +# define SCNu8 "hhu" +# define SCNu16 "hu" +# define SCNu32 "u" +# define SCNu64 __PRI64_PREFIX "u" + +# define SCNuLEAST8 "hhu" +# define SCNuLEAST16 "hu" +# define SCNuLEAST32 "u" +# define SCNuLEAST64 __PRI64_PREFIX "u" + +# define SCNuFAST8 "hhu" +# define SCNuFAST16 __PRIPTR_PREFIX "u" +# define SCNuFAST32 __PRIPTR_PREFIX "u" +# define SCNuFAST64 __PRI64_PREFIX "u" + +/* Octal notation. */ +# define SCNo8 "hho" +# define SCNo16 "ho" +# define SCNo32 "o" +# define SCNo64 __PRI64_PREFIX "o" + +# define SCNoLEAST8 "hho" +# define SCNoLEAST16 "ho" +# define SCNoLEAST32 "o" +# define SCNoLEAST64 __PRI64_PREFIX "o" + +# define SCNoFAST8 "hho" +# define SCNoFAST16 __PRIPTR_PREFIX "o" +# define SCNoFAST32 __PRIPTR_PREFIX "o" +# define SCNoFAST64 __PRI64_PREFIX "o" + +/* Hexadecimal notation. */ +# define SCNx8 "hhx" +# define SCNx16 "hx" +# define SCNx32 "x" +# define SCNx64 __PRI64_PREFIX "x" + +# define SCNxLEAST8 "hhx" +# define SCNxLEAST16 "hx" +# define SCNxLEAST32 "x" +# define SCNxLEAST64 __PRI64_PREFIX "x" + +# define SCNxFAST8 "hhx" +# define SCNxFAST16 __PRIPTR_PREFIX "x" +# define SCNxFAST32 __PRIPTR_PREFIX "x" +# define SCNxFAST64 __PRI64_PREFIX "x" + +/* Macros for scanning `intmax_t' and `uintmax_t'. */ +# define SCNdMAX __PRI64_PREFIX "d" +# define SCNiMAX __PRI64_PREFIX "i" +# define SCNoMAX __PRI64_PREFIX "o" +# define SCNuMAX __PRI64_PREFIX "u" +# define SCNxMAX __PRI64_PREFIX "x" + +/* Macros for scanning `intptr_t' and `uintptr_t'. */ +# define SCNdPTR __PRIPTR_PREFIX "d" +# define SCNiPTR __PRIPTR_PREFIX "i" +# define SCNoPTR __PRIPTR_PREFIX "o" +# define SCNuPTR __PRIPTR_PREFIX "u" +# define SCNxPTR __PRIPTR_PREFIX "x" + +#endif /* C++ && format macros */ + +#if __WORDSIZE == 64 + +/* We have to define the `uintmax_t' type using `ldiv_t'. */ +typedef struct { + long int quot; /* Quotient. */ + long int rem; /* Remainder. */ +} imaxdiv_t; + +#else + +/* We have to define the `uintmax_t' type using `lldiv_t'. */ +typedef struct { + long long int quot; /* Quotient. */ + long long int rem; /* Remainder. */ +} imaxdiv_t; + +#endif + +#endif /* inttypes.h */ From patchwork Sat Nov 24 04:29:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002591 X-Patchwork-Delegate: sjg@chromium.org 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="NmJ4K5dk"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320nm1CHrz9s7W for ; Sat, 24 Nov 2018 15:39:24 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D238BC22472; Sat, 24 Nov 2018 04:35: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, T_DKIM_INVALID 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 18988C22477; Sat, 24 Nov 2018 04:32:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 52C37C22458; Sat, 24 Nov 2018 04:30:39 +0000 (UTC) Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by lists.denx.de (Postfix) with ESMTPS id 6D0DFC2245D for ; Sat, 24 Nov 2018 04:30:35 +0000 (UTC) Received: by mail-io1-f69.google.com with SMTP id d63so12877073iog.4 for ; Fri, 23 Nov 2018 20:30:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=EePvsD2wgRnIIYX7PDP3IcrMavDU+KuWoex2ZPXW3b0=; b=NmJ4K5dkmkksP4DKCMOi27HJtnj+lG1xLKGot/iHU75HwkLxW7yVOfOBdigyPg/Xbd 8vgQ9wROhhS5VjRQqjMJtTFvph1jrMs1SfOeeD4y+tjm5HF0IYYKc0+R1q0c2FCOQjvP J2Oo+EyJjX67sFVIlObV+1bH4jqSDoQsFtVXg= 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=EePvsD2wgRnIIYX7PDP3IcrMavDU+KuWoex2ZPXW3b0=; b=IXsr06q9xnQnPSR4RSop5ExrxNAV3bC/7rd2WzNqWvnw/apj16lSLM/opnueLf0cEG dxaj8Z9gxsEGjXU53jRuRAhkPSrbH23alQZku9Ox0WafB3aMz7yHDE/+BCCOSwv+JV2Y bW0t1ixe4b3Du5teyqhu/SL7oP5q0iFz1kTBvyxRuZYnROMfDvfV7WRoo6JBpEHa02/h LT8S0Qxmto5d8k3l57+BxlmNZD3PNhYWwM90giAvjWozVUleVXUhHcJFh2oXjXv195r2 EOMoUIZrNNe60xAP1MxaJFnQNPdIihsTSOShHHoZbncZdvT3nwX0uItCabE6RKdaMNIL mDTA== X-Gm-Message-State: AGRZ1gIJ6AJzcRTgUo7dBtHMtFWwWU5Keo2hjn2iM7wzpWkKpPkmLW9t TdP8phOym1NxZ1J1jQDXrCrDEea5CGGs+F1a X-Google-Smtp-Source: AJdET5c/T5dJr5/ftog4MzVDSKaYHHG+QBT2vRVXcDX6yB5fwUBzIR1h2p3ofKKEY3sDRZRJ+mnRm3yTV+0U+8uW X-Received: by 2002:a24:3d88:: with SMTP id n130mr12247442itn.6.1543033834474; Fri, 23 Nov 2018 20:30:34 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:44 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-22-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Cc: Baruch Siach , Stephen Warren , Vagrant Cascadian , Michal Simek , Luca Ceresoli , Marek Vasut Subject: [U-Boot] [PATCH 21/21] RFC: Makefile: Build U-Boot as a library 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" As an experiment, build U-Boot as a library, u-boot.o, so it can be used by other open-source software. Update the sandbox build rules to suit. This has not been tested in any meaningful way. It breaks sandbox_spl and all x86 boards. I am interested in feedback as to how useful this might be. Signed-off-by: Simon Glass --- Makefile | 9 ++++++++- arch/sandbox/config.mk | 10 ++++------ scripts/Makefile.spl | 17 +++++++++++++++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index d82772e7786..c8236de1463 100644 --- a/Makefile +++ b/Makefile @@ -1379,7 +1379,14 @@ cmd_smap = \ $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \ -c $(srctree)/common/system_map.c -o common/system_map.o -u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds FORCE +quiet_cmd_u-boot-lib ?= LIB $@ + cmd_u-boot-lib ?= $(LD) -r --exclude-libs ALL \ + --start-group $(u-boot-main) --end-group -o $@ + +u-boot.o: $(u-boot-init) $(u-boot-main) u-boot.lds FORCE + +$(call if_changed,u-boot-lib) + +u-boot: u-boot.o FORCE +$(call if_changed,u-boot__) ifeq ($(CONFIG_KALLSYMS),y) $(call cmd,smap) diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 7226b7be428..0f30f9db0b2 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -17,14 +17,12 @@ PLATFORM_CPPFLAGS += $(shell sdl-config --cflags) endif endif -cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \ - -Wl,--start-group $(u-boot-main) -Wl,--end-group \ - $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map +cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds \ + u-boot.o $(u-boot-init) \ + $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map \ cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \ - $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ - -Wl,--start-group $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \ - $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) -Wl,--end-group \ + u-boot-spl.o $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections) CONFIG_ARCH_DEVICE_TREE := sandbox diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 7416abec62e..17c44424ceb 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -349,6 +349,20 @@ cmd_sunxi_spl_image_builder = $(objtree)/tools/sunxi-spl-image-builder \ $(obj)/sunxi-spl-with-ecc.bin: $(obj)/sunxi-spl.bin $(call if_changed,sunxi_spl_image_builder) +quiet_cmd_u-boot-spl-lib ?= LIB $@ + cmd_u-boot-spl-lib ?= $(LD) -r --start-group $(u-boot-spl-main) \ + --end-group -o $@ + +$(obj)/u-boot-spl.o: $(u-boot-spl-platdata) $(u-boot-spl-init) \ + $(u-boot-spl-main) FORCE + (cd $(obj) && $(LD) -r $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ + --start-group \ + $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \ + $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \ + --end-group \ + -o $(patsubst $(obj)/%,%,$@)) + +$(call if_changed,u-boot-spl-lib) + # Rule to link u-boot-spl # May be overridden by arch/$(ARCH)/config.mk quiet_cmd_u-boot-spl ?= LD $@ @@ -359,8 +373,7 @@ quiet_cmd_u-boot-spl ?= LD $@ --end-group \ $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN)) -$(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \ - $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE +$(obj)/$(SPL_BIN): $(obj)/u-boot-spl.o $(obj)/u-boot-spl.lds FORCE $(call if_changed,u-boot-spl) $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;