From patchwork Fri Mar 22 19:57:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 1061589 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E1HEf3pe"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44QvcH2HwKz9sRW for ; Sat, 23 Mar 2019 06:58:55 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id DF8EBC21D72; Fri, 22 Mar 2019 19:58:10 +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=FREEMAIL_FROM, 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 A2C58C220BE; Fri, 22 Mar 2019 19:58:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 53353C22130; Fri, 22 Mar 2019 19:57:59 +0000 (UTC) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by lists.denx.de (Postfix) with ESMTPS id 6B964C21DCA for ; Fri, 22 Mar 2019 19:57:56 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id y13so3661204wrd.3 for ; Fri, 22 Mar 2019 12:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cMGsnrDlD5+Bq3xhmy6vRl3c31XW2G/wPmpvMaFr7O8=; b=E1HEf3peUcTgX0nPSsnpgL9cm+5Jh7o7NgSeo2+ro8IyWahNPWoTXWtcnn9txTjQ0T bFFeraNZ645ShbvHKuyeYDjZpbvTf5Xbuu0ho02PgrC/3GWbcOMzJkWgPks7NiMKS6PY nIBa8ijKlQOpsoOxgaHEQ6GzeHvc5WGTiY/ZAPpdBSpMcZNnBb2/E2L+XsHPfJycXtQG 28DDGzNlpPkIVCDj9jIhN3Ir4l/p8CE+LdW5aqwkemvFwltD7KlMijiHdSrsrn+ULk1V SMj+y5Fc71d9bXdv5g0I/KHJ0ojxU/AzlM97Iaocdw770qy4YVWd/sbajB1FqSxtN3FR 66TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cMGsnrDlD5+Bq3xhmy6vRl3c31XW2G/wPmpvMaFr7O8=; b=nbirB57neI7dRDccYKStACVdi9ghRICoYrc7YrceZnL2EyKKsgv5Sq0C8PqLaUOoWS R5T1PnrWTYOvrXSrKcW2ExQopPXls0trt1Zx78zmXtktWZ+LMiNs5cM3XdD+wcYGFNGd tpGmHn+Lj1cLpHVsk7Ysfyy7OFo/ET9PECHDCVtomIjbJCaGGQIDQs2kkZgTMBH8AI9/ Z07hLad1XfS4/QgLVN9mykM8Cp5A45SY6FhXXcSKGl/JiAnXvS2S3LVAtcnaNjGz3y9G nb1fAieFTQ8R3LXVstkvhjMbFF8r1jqoQTuQ3dm2zTyYXfDtE+dcsiGZYHNFENVboorp +71g== X-Gm-Message-State: APjAAAXTA+CAv4VBVXODsSvXDKAqHuVJ0Za8I1zeoSpIvhh/HcqvvzQ1 FeVn/p2nqE34JLHHhur/hH/hQUid X-Google-Smtp-Source: APXvYqyzHCQysDwe5a+Gv2YMlsV9palcfC5M9anaLbcOHN4gX0J4a+++syckaZY8ydxlWRS6XpZ+SQ== X-Received: by 2002:a5d:4683:: with SMTP id u3mr7462262wrq.200.1553284675994; Fri, 22 Mar 2019 12:57:55 -0700 (PDT) Received: from ubuntu.home ([2a02:8071:6a3:700:113a:1a5f:8497:9ca8]) by smtp.gmail.com with ESMTPSA id y5sm6919030wrw.23.2019.03.22.12.57.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 12:57:54 -0700 (PDT) From: Simon Goldschmidt To: u-boot@lists.denx.de Date: Fri, 22 Mar 2019 20:57:40 +0100 Message-Id: <20190322195744.26812-3-simon.k.r.goldschmidt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190322195744.26812-1-simon.k.r.goldschmidt@gmail.com> References: <20190322195744.26812-1-simon.k.r.goldschmidt@gmail.com> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 2/6] spl: arm: implement SPL_CLEAR_BSS_F 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This implements the new option to clear BSS early in SPL for standard arm and arm64 crt0. BSS is cleared before calling board_init_f() and thus not cleared before calling board_init_r() as it is not relocated in SPL. Signed-off-by: Simon Goldschmidt --- Changes in v2: - add CONFIG_SPL_CLEAR_BSS_F implementation for arm64 also arch/arm/lib/crt0.S | 22 ++++++++++++++++++++++ arch/arm/lib/crt0_64.S | 14 ++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S index fe312db690..b06e54e144 100644 --- a/arch/arm/lib/crt0.S +++ b/arch/arm/lib/crt0.S @@ -80,6 +80,26 @@ ENTRY(_main) mov r9, r0 bl board_init_f_init_reserve +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_CLEAR_BSS_F) + ldr r0, =__bss_start + +#ifdef CONFIG_USE_ARCH_MEMSET + ldr r3, =__bss_end + mov r1, #0x00000000 /* prepare zero to clear BSS */ + + subs r2, r3, r0 /* r2 = memset len */ + bl memset +#else + ldr r1, =__bss_end + mov r2, #0x00000000 /* prepare zero to clear BSS */ + +clbss_l:cmp r0, r1 /* while not at end of BSS */ + strlo r2, [r0] /* clear 32-bit BSS word */ + addlo r0, r0, #4 /* move to next */ + blo clbss_l +#endif +#endif + mov r0, #0 bl board_init_f @@ -124,6 +144,7 @@ here: movne sp, r0 movne r9, r0 # endif +#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL_CLEAR_BSS_F) ldr r0, =__bss_start /* this is auto-relocated! */ #ifdef CONFIG_USE_ARCH_MEMSET @@ -141,6 +162,7 @@ clbss_l:cmp r0, r1 /* while not at end of BSS */ addlo r0, r0, #4 /* move to next */ blo clbss_l #endif +#endif #if ! defined(CONFIG_SPL_BUILD) bl coloured_LED_init diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S index d6b632aa87..82f643f737 100644 --- a/arch/arm/lib/crt0_64.S +++ b/arch/arm/lib/crt0_64.S @@ -86,6 +86,18 @@ ENTRY(_main) mov x18, x0 bl board_init_f_init_reserve +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_CLEAR_BSS_F) +/* + * Clear BSS section + */ + ldr x0, =__bss_start + ldr x1, =__bss_end +clear_loop: + str xzr, [x0], #8 + cmp x0, x1 + b.lo clear_loop +#endif + mov x0, #0 bl board_init_f @@ -136,6 +148,7 @@ relocation_return: mov sp, x0 #endif +#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL_CLEAR_BSS_F) /* * Clear BSS section */ @@ -145,6 +158,7 @@ clear_loop: str xzr, [x0], #8 cmp x0, x1 b.lo clear_loop +#endif /* call board_init_r(gd_t *id, ulong dest_addr) */ mov x0, x18 /* gd_t */