From patchwork Mon Oct 19 12:49:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 532292 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 8F1C41402B0 for ; Mon, 19 Oct 2015 23:50:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=RJ8GR7Jo; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF2564B800; Mon, 19 Oct 2015 14:50:40 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zRrb42bK9rAW; Mon, 19 Oct 2015 14:50:40 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 27D4B4B7F0; Mon, 19 Oct 2015 14:50:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A127D4B7DD for ; Mon, 19 Oct 2015 14:50:13 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x5CQZr84hoxF for ; Mon, 19 Oct 2015 14:50:13 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ig0-f181.google.com (mail-ig0-f181.google.com [209.85.213.181]) by theia.denx.de (Postfix) with ESMTPS id 297BD4B7D0 for ; Mon, 19 Oct 2015 14:50:09 +0200 (CEST) Received: by igbdj2 with SMTP id dj2so55874478igb.1 for ; Mon, 19 Oct 2015 05:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ke72waGI1k24xaa1MOPmQwwRBC69Enf43q8RKuA07zU=; b=RJ8GR7JobGtY5SXQ00jGt/Jw0JpGsIn/W7te0dw8vZ7Bc+bjBvWIlLKEnVsxbxPe0M NFDxWE3guyGcyAAa9U1HId5OM6ilJyFx4pRDX75YQDdDLQRjkFlWvP6dZ14K0ZlVT+qd 8UhbU4LSWXSCx9KXt2LpKoU1veGEWxotRy9IpkHzqIgHZPyyY+LOhwfeig0juj7zH8s+ ydUewbOO+IzGIJYPYslLuLdKrS4GXQXMM13jWCyiTv/fUTrmV5fewADXLrVf/Q/KzCSm 7Cmzp+QNG8kACgYLCOqlw6kqe7N8coV7xnS7DO8qJc7nBtRVyH2om3BUrrzUVZRmNbVU glsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Ke72waGI1k24xaa1MOPmQwwRBC69Enf43q8RKuA07zU=; b=Orax/xAWGYE2qOZoEJaPV5Vy+pmc7hSKRGxGeZxDsZwNSjWGJqf6Hs9qQnW5w1Irhk 0HF4R6bdDwjUXOUXvB40xublTGF4SmammUBRkgHTYUCak5Ga2+N6bjimVs8fVEPuzW2l /MOIm5Z/o7r41GOfczSbheN6A9YK4znl2YMtiHY1SQva/E9WtEiKPCYy0UCoMmLwwCJE j4+Z68fEyi6eCqPmw8gpXhuniKgf9Sz77Fzg1kJoWVA6tjM4+1v94WWYzqYBU+LndFzs m2r9PtBRMqyWwh/fGnz7zHrdPMhIerGaFHrebKLtMR5Taj76q3H4XuNmQ0cVoG/vZysy 1G6g== X-Gm-Message-State: ALoCoQllILiJ6QTsu3YSpGBLsIQ6TEEygJT+xB7wBw88ct6iWairYRel9SLvmp5VrHtSUBuH2nFk X-Received: by 10.50.4.42 with SMTP id h10mr19768160igh.37.1445259008739; Mon, 19 Oct 2015 05:50:08 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id u12sm7705716igr.22.2015.10.19.05.50.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 05:50:07 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id F349F220BFC; Mon, 19 Oct 2015 06:50:05 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 19 Oct 2015 06:49:57 -0600 Message-Id: <1445259003-15896-3-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1445259003-15896-1-git-send-email-sjg@chromium.org> References: <1445259003-15896-1-git-send-email-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH v4 2/8] board_init_f_mem(): Don't require memset() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" Unfortunately memset() is not always available, so provide a substitute when needed. Signed-off-by: Simon Glass --- Changes in v4: - Remove the 'end' variable in board_init_f_mem() Changes in v3: None Changes in v2: - Add comments as to why this is needed, deal with arch-specific memset() common/init/board_init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/common/init/board_init.c b/common/init/board_init.c index e7ebca7..1c6126d 100644 --- a/common/init/board_init.c +++ b/common/init/board_init.c @@ -11,6 +11,16 @@ DECLARE_GLOBAL_DATA_PTR; +/* + * It isn't trivial to figure out whether memcpy() exists. The arch-specific + * memcpy() is not normally available in SPL due to code size. + */ +#if !defined(CONFIG_SPL_BUILD) || \ + (defined(CONFIG_SPL_LIBGENERIC_SUPPORT) && \ + !defined(CONFIG_USE_ARCH_MEMSET)) +#define _USE_MEMCPY +#endif + /* Unfortunately x86 can't compile this code as gd cannot be assigned */ #ifndef CONFIG_X86 __weak void arch_setup_gd(struct global_data *gd_ptr) @@ -22,6 +32,9 @@ __weak void arch_setup_gd(struct global_data *gd_ptr) ulong board_init_f_mem(ulong top) { struct global_data *gd_ptr; +#ifndef _USE_MEMCPY + int *ptr; +#endif /* Leave space for the stack we are running with now */ top -= 0x40; @@ -29,7 +42,12 @@ ulong board_init_f_mem(ulong top) top -= sizeof(struct global_data); top = ALIGN(top, 16); gd_ptr = (struct global_data *)top; +#ifdef _USE_MEMCPY memset(gd_ptr, '\0', sizeof(*gd)); +#else + for (ptr = (int *)gd_ptr; ptr < (int *)(gd_ptr + 1); ) + *ptr++ = 0; +#endif arch_setup_gd(gd_ptr); #if defined(CONFIG_SYS_MALLOC_F)