From patchwork Tue Feb 28 22:35:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 94670 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp1529538qgi; Tue, 28 Feb 2017 14:41:27 -0800 (PST) X-Received: by 10.200.3.130 with SMTP id t2mr5891089qtg.211.1488321687893; Tue, 28 Feb 2017 14:41:27 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a128si2625864qkd.243.2017.02.28.14.41.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 28 Feb 2017 14:41:27 -0800 (PST) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=grub-devel-bounces+patch=linaro.org@gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciqST-0000lP-9k for patch@linaro.org; Tue, 28 Feb 2017 17:41:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciqMy-0004rW-Gk for grub-devel@gnu.org; Tue, 28 Feb 2017 17:35:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciqMx-0004YP-11 for grub-devel@gnu.org; Tue, 28 Feb 2017 17:35:44 -0500 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:34852) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ciqMw-0004Xu-OB for grub-devel@gnu.org; Tue, 28 Feb 2017 17:35:42 -0500 Received: by mail-wr0-x234.google.com with SMTP id g10so18364335wrg.2 for ; Tue, 28 Feb 2017 14:35:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zYbDCIugu2TG0/MhE1kRglOw/XM5pDU6HGALJzUc4wM=; b=cMv0lv6K4Yob13UHctyuOkJHctWHDqNNKAZW1yN2zFusGRs2MWFcLDEld5ZsrdxvnS 8dsNJ2e2Z0rVImCyQtX5QVq6eqeuGXh4JLFIE0tJJoojZyiGfposj27pCkg9lJkLABcW sL/DT27Bi/jPjuzfT/E2Ws0FhgDQZaPNdxC2s= 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=zYbDCIugu2TG0/MhE1kRglOw/XM5pDU6HGALJzUc4wM=; b=ElNi7/1DWjxVC3wvjDVAVK/RXiKo6FSZdeEYpKl9bWgiAydS0tSG78u1JIfVTYVYTn oJ7iLp7DVC8HEg14kk3WFsw1PtGnlC9K1ozpIOG9ga4u5looB7StkH40fA/CtYWwqqfc rL09j3ccnIOJVyQxbAlnwGfBu1UFh2WWQ9KQbf23Jx0C5v/t55AQb2FoMpDiBM/wuRAT /3XnDVYHwBjMM3Qx2l8DAphb559X32EnLGd8Bt/anFo1M1nYRHKpN12nhUehCUWzQULR chhS+Mfzs1KhapJxXSKxi9JU2KlPqsb32/OO43DkQYXdmunKCAhmTUdI36iGwYulfHB4 Kacw== X-Gm-Message-State: AMke39njK2c2xWOKScQbR3YF48vW2yYsLI7NHrGxd02cIC1OrjYtfLsjibqXhJFo6uNOIs0j X-Received: by 10.223.154.225 with SMTP id a88mr4146542wrc.5.1488321341660; Tue, 28 Feb 2017 14:35:41 -0800 (PST) Received: from mohikan.hemma.eciton.net ([2a01:348:6:8735:e23f:49ff:fe6d:9d26]) by smtp.gmail.com with ESMTPSA id 40sm4043391wry.22.2017.02.28.14.35.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Feb 2017 14:35:41 -0800 (PST) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH 3/7] efi: move fdt helper library Date: Tue, 28 Feb 2017 22:35:33 +0000 Message-Id: <20170228223537.9685-4-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170228223537.9685-1-leif.lindholm@linaro.org> References: <20170228223537.9685-1-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::234 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: Laszlo Ersek , Gerd Hoffmann , Alexander Graf , ard.biesheuvel@linaro.org MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" There is nothing ARM64 (or even ARM) specific about the efi fdt helper library, which is used for locating or overriding a firmware-provided devicetree in a UEFI system - so move it to loader/efi for reuse. Move the fdtload.h include file to grub/efi and move the (at least theoretically) machine dependent page size definitions to grub/machine/memory.h. --- grub-core/Makefile.core.def | 2 +- grub-core/loader/arm64/linux.c | 3 ++- grub-core/loader/arm64/xen_boot.c | 3 ++- grub-core/loader/{arm64 => efi}/fdt.c | 11 ++++++----- include/grub/arm64/efi/memory.h | 3 +++ include/grub/{arm64 => efi}/fdtload.h | 3 --- 6 files changed, 14 insertions(+), 11 deletions(-) rename grub-core/loader/{arm64 => efi}/fdt.c (93%) rename include/grub/{arm64 => efi}/fdtload.h (89%) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2dfa22a92..2d8d8618d 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1677,7 +1677,7 @@ module = { module = { name = fdt; - arm64 = loader/arm64/fdt.c; + arm64 = loader/efi/fdt.c; common = lib/fdt.c; enable = fdt; }; diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 9519d2e4d..02e405460 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -26,11 +26,12 @@ #include #include #include -#include #include +#include #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index a914eb8e2..341805c50 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -27,12 +27,13 @@ #include #include #include -#include #include #include +#include #include /* required by struct xen_hypervisor_header */ #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/efi/fdt.c similarity index 93% rename from grub-core/loader/arm64/fdt.c rename to grub-core/loader/efi/fdt.c index db49cf649..e2899c47b 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -18,12 +18,13 @@ #include #include -#include #include #include #include #include #include +#include +#include static void *loaded_fdt; static void *fdt; @@ -32,12 +33,12 @@ void * grub_fdt_load (grub_size_t additional_size) { void *raw_fdt; - grub_size_t size; + unsigned int size; if (fdt) { size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)); - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size); + grub_efi_free_pages ((grub_addr_t) fdt, size); } if (loaded_fdt) @@ -49,7 +50,7 @@ grub_fdt_load (grub_size_t additional_size) raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; size += additional_size; - grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); + grub_dprintf ("linux", "allocating %d bytes for fdt\n", size); fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size)); if (!fdt) return NULL; @@ -88,7 +89,7 @@ grub_fdt_unload (void) { if (!fdt) { return; } - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, + grub_efi_free_pages ((grub_addr_t) fdt, GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); fdt = NULL; } diff --git a/include/grub/arm64/efi/memory.h b/include/grub/arm64/efi/memory.h index c6cb32417..9414b69e0 100644 --- a/include/grub/arm64/efi/memory.h +++ b/include/grub/arm64/efi/memory.h @@ -3,4 +3,7 @@ #define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL +#define GRUB_EFI_PAGE_SHIFT 12 +#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) + #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/arm64/fdtload.h b/include/grub/efi/fdtload.h similarity index 89% rename from include/grub/arm64/fdtload.h rename to include/grub/efi/fdtload.h index 7b9ddba91..713c9424d 100644 --- a/include/grub/arm64/fdtload.h +++ b/include/grub/efi/fdtload.h @@ -29,7 +29,4 @@ grub_fdt_unload (void); grub_err_t grub_fdt_install (void); -#define GRUB_EFI_PAGE_SHIFT 12 -#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) - #endif