From patchwork Mon May 3 23:10:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1473547 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=X08RlUDs; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FYzgQ0gYcz9sCD for ; Tue, 4 May 2021 09:28:33 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5906A82CBD; Tue, 4 May 2021 01:27:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="X08RlUDs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43F5982B36; Tue, 4 May 2021 01:27:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6104C82B36 for ; Tue, 4 May 2021 01:11:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2d.google.com with SMTP id z24so3415666ioj.7 for ; Mon, 03 May 2021 16:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H6G/iUvgL3w87vSF73296/5BnEMCbnaIbLKVCHtWk7k=; b=X08RlUDslnfnx4O1bMtU5E2PZi2Q5WjxvDYXIfvYI168AIeiPibwIMXkbS1mO+9cU1 J+uAzgtXnJu9cUe+MI6Hvx4iri820UVWcb6/cEg4oci2refaAeWZcxFTVTelxLFP+icN xr4M4IZygjKAoxODL9K8KDOGL2b4QclsFL4tQ= 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:mime-version:content-transfer-encoding; bh=H6G/iUvgL3w87vSF73296/5BnEMCbnaIbLKVCHtWk7k=; b=CQq55tHVCUQtjmhVKHFzXQTeNVI2IrzGaosf4YYcogSvS9CdIEIoP5M8FUqhycjbqr b6OudvIbcFcUiOvbYcAg4GGhoE70zTKgf/qlMgoIg8zbsNABcn3NPa1ViSgxRvjZZvGe VNPep2OA0fBmOBPf0/68+WWQUsUJ0Ey9QoUe2it4WHr5+GTOqSqdos4RiP+MawGTOjYV i66hZMW639TLVyUZh6xM7xsc7DZofaZR5W0XpoV3nujBEYo1pmUwJDpIzXPijoaTLCCn PzN5BCiSv1E+stduJUpgusXIRRa0HwhK87nbAjxf0xoxzCwPTuwrp24yOAIOmrJ4NjTW NnmA== X-Gm-Message-State: AOAM532xK+11QPV0lVdJb7uuw6Jq1orrH4lRVGPeC9b6tyqi0QV0I2hy VboWKNOsZ3lBVAKTJunAuo/1xZXRyE9nyg== X-Google-Smtp-Source: ABdhPJzRwoc737U93WK0Te3kprID3bOfS/5T6CpGo2NfzMsCtCowe0amG622Zv+AwQUWpVAxjTNqzA== X-Received: by 2002:a5d:9612:: with SMTP id w18mr15992924iol.183.1620083517893; Mon, 03 May 2021 16:11:57 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id o6sm422727ioa.21.2021.05.03.16.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 16:11:57 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Bin Meng , Robert Marko , Andre Przywara , Masahiro Yamada , Simon Glass , AKASHI Takahiro , Alexandru Gagniuc , Frieder Schrempf , Joe Hershberger , Joel Stanley , Marek Vasut , Naoki Hayama , =?utf-8?q?Pali_Roh=C3=A1r?= , Reuben Dowle , Samuel Holland , Stefan Roese , Trevor Woerner Subject: [PATCH 11/49] image: Split host code out into its own file Date: Mon, 3 May 2021 17:10:58 -0600 Message-Id: <20210503171001.11.I11a7579429bf01e00fef3b1d9454f1e102236015@changeid> X-Mailer: git-send-email 2.31.1.527.g47e6f16901-goog In-Reply-To: <20210503231136.744283-1-sjg@chromium.org> References: <20210503231136.744283-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean To avoid having #ifdefs in a few functions which are completely different in the board and host code, create a new image-host.c file. Signed-off-by: Simon Glass --- (no changes since v1) common/image-board.c | 17 +++++++++++++++++ common/image-host.c | 27 +++++++++++++++++++++++++++ common/image.c | 38 +------------------------------------- tools/Makefile | 1 + 4 files changed, 46 insertions(+), 37 deletions(-) create mode 100644 common/image-host.c diff --git a/common/image-board.c b/common/image-board.c index 5d3eafb5245..b46062c86b9 100644 --- a/common/image-board.c +++ b/common/image-board.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -925,3 +926,19 @@ int image_setup_linux(bootm_headers_t *images) return 0; } #endif /* CONFIG_LMB */ + +void genimg_print_size(uint32_t size) +{ + printf("%d Bytes = ", size); + print_size(size, "\n"); +} + +void genimg_print_time(time_t timestamp) +{ + struct rtc_time tm; + + rtc_to_tm(timestamp, &tm); + printf("%4d-%02d-%02d %2d:%02d:%02d UTC\n", + tm.tm_year, tm.tm_mon, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); +} diff --git a/common/image-host.c b/common/image-host.c new file mode 100644 index 00000000000..20a9521948b --- /dev/null +++ b/common/image-host.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Image code used by host tools (and not boards) + * + * (C) Copyright 2008 Semihalf + * + * (C) Copyright 2000-2006 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#include + +void memmove_wd(void *to, void *from, size_t len, ulong chunksz) +{ + memmove(to, from, len); +} + +void genimg_print_size(uint32_t size) +{ + printf("%d Bytes = %.2f KiB = %.2f MiB\n", size, (double)size / 1.024e3, + (double)size / 1.048576e6); +} + +void genimg_print_time(time_t timestamp) +{ + printf("%s", ctime(×tamp)); +} diff --git a/common/image.c b/common/image.c index e9658e3ab1b..0ef8f30fcfa 100644 --- a/common/image.c +++ b/common/image.c @@ -18,8 +18,6 @@ #include #endif -#include - #if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT #include #include @@ -60,6 +58,7 @@ DECLARE_GLOBAL_DATA_PTR; #include #include +#include #include #include #include @@ -526,41 +525,6 @@ int image_decomp(int comp, ulong load, ulong image_start, int type, return 0; } -#ifdef USE_HOSTCC -void memmove_wd(void *to, void *from, size_t len, ulong chunksz) -{ - memmove(to, from, len); -} -#endif /* !USE_HOSTCC */ - -void genimg_print_size(uint32_t size) -{ -#ifndef USE_HOSTCC - printf("%d Bytes = ", size); - print_size(size, "\n"); -#else - printf("%d Bytes = %.2f KiB = %.2f MiB\n", - size, (double)size / 1.024e3, - (double)size / 1.048576e6); -#endif -} - -#if IMAGE_ENABLE_TIMESTAMP -void genimg_print_time(time_t timestamp) -{ -#ifndef USE_HOSTCC - struct rtc_time tm; - - rtc_to_tm(timestamp, &tm); - printf("%4d-%02d-%02d %2d:%02d:%02d UTC\n", - tm.tm_year, tm.tm_mon, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); -#else - printf("%s", ctime(×tamp)); -#endif -} -#endif - const table_entry_t *get_table_entry(const table_entry_t *table, int id) { for (; table->id >= 0; ++table) { diff --git a/tools/Makefile b/tools/Makefile index d020c55d664..2b4bc547abd 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -94,6 +94,7 @@ dumpimage-mkimage-objs := aisimage.o \ lib/fdtdec_common.o \ lib/fdtdec.o \ common/image.o \ + common/image-host.o \ imagetool.o \ imximage.o \ imx8image.o \