From patchwork Thu Aug 3 10:04:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109306 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp571198qge; Thu, 3 Aug 2017 03:08:16 -0700 (PDT) X-Received: by 10.200.1.204 with SMTP id b12mr1290155qtg.2.1501754896066; Thu, 03 Aug 2017 03:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501754896; cv=none; d=google.com; s=arc-20160816; b=sxmEHgYhmN0LMe18Uax4l4GxWUMxfT5Pf4BHqlROna17qrf5edcO0LHQze+p3yjxB7 baAj2Owh226LEV1gs1W7vBGWjFDbtN80kflah4H6Boh6Bee4ZdPHGq4qbfnz0sIyghRX RlgOqCSlXcpT7mm2xkdPGaYOCH0wmal/8PckWxfLYoau5tqIsXy1vWKevIj3T7ZCVUDX Vppf6iJmcYBa/VXOK/U4JBzu3oCMASOFj1gTbxwQSdLyqkUyurrvvvw6GafU/rwoxtQ0 ADLpSXK0c1Dm85jrKIpGEmKBA06CYlxO9bfsZLnQBsVS1X/2OHkE9e5s5gfQoDOIHL4r +7rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:arc-authentication-results; bh=7aGB6YKBTk+KUGi0/gZBenNVn5/HApydUkfOauulcCI=; b=nCOPBYdWg7VMwMVMK0ENBpWhQzRwjDm+NENDmGYmlBSwNWHcbxJ+/LQYOCgDa/jwtV oEx7HJ2dyY40tHhmv2T20hUvlmeroBQNngMCSrlbLrJeLJLcF1xxS54QhO952i/ozUoE gIvSiHkC9rIuspjRUhIB9tCUWbvvGx/ZGsFuEX5emaeklGu8Abz/mZe59gmIu0T/J4ws DAqvUvqofgFm/ILUOhAkIqkJOktEYGLd+Y2f/yIKmsrUVpoZwhDtnGSg05kT5FnV8WHO cxjD7Md0xsUYNQ+Wz0uQZhl8j1eyn7d9UXcCl5uWqjBkySCb1UxLRday98TKTpZEfg5G po1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=ZozJPsYB; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n93si24518899qtd.151.2017.08.03.03.08.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:08:16 -0700 (PDT) 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 header.b=ZozJPsYB; 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]:53202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD37-0001KR-9m for patch@linaro.org; Thu, 03 Aug 2017 06:08:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1d-0000FF-2i for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1b-00047S-QC for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:40 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:33438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1b-00046j-KG for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:39 -0400 Received: by mail-wr0-x233.google.com with SMTP id v105so3748750wrb.0 for ; Thu, 03 Aug 2017 03:06:39 -0700 (PDT) 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=gHrAVhoJcXWnrRg4XXG++v9gSFD3iK9RZ/niy8QpZDA=; b=ZozJPsYB1NpYalgtzIuJJXMrEnlZGTPG4nli5iPNGaNoMABQaLL8/clGZzc+Qhk0k6 xajifSmPkfKJMGwBs9hIcCNBj4Gkfj9hgRNEPEQ7hvoQIz380wS+CqO6u/AEYc1ZAITH e136j4qHk/bRHQLkN5zBiNuF2rVidjCt33Qqs= 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=gHrAVhoJcXWnrRg4XXG++v9gSFD3iK9RZ/niy8QpZDA=; b=mKNAUmKvSsC1fy+JD6Hg2OkaJWWos6HQd+KDsNm1ghaSTR9yeZLcFkpASvgIShprfX wP99p+u7MUpauw3wFzdWhq3IPBsotZXiVGMTgHSduT+8P7JUwvbuyihqjCxH44Rf+yOa A2n3rFv+XrL8CUqjZdIdFNQjLEJTyhBsQpgaMpLZJttOnreyPHaG+L4fmUhXMTuYcFia D0GGYN21QAnM4tMR8X/NzocG9sOu6D7IZpsNYEQ/aBp2m8cqPZYrxAUAI7I8ITgNS9BX Ct84w4X0b9u/f30kR+vN5tVJolT/UUNDktgZVlwYZfcGkfz04GjRK18tHSR65n9cF6oE RlwQ== X-Gm-Message-State: AIVw1131bqrD1EP2rLOwI3XGy+8shfwoKr43os634yHPptKN59AO8kM5 0RMHVhDtasN5K8ZMemgS0A== X-Received: by 10.223.153.179 with SMTP id y48mr906591wrb.168.1501754798489; Thu, 03 Aug 2017 03:06:38 -0700 (PDT) Received: from vanye.hemma.eciton.net (cpc92316-cmbg19-2-0-cust118.5-4.cable.virginm.net. [82.12.0.119]) by smtp.gmail.com with ESMTPSA id e5sm2274543wre.24.2017.08.03.03.06.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:37 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm* Date: Thu, 3 Aug 2017 11:04:22 +0100 Message-Id: <20170803100432.29913-5-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803100432.29913-1-leif.lindholm@linaro.org> References: <20170803100432.29913-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::233 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: Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Since ARM platforms do not have a common memory map, add a helper function that finds the lowest address region with the EFI_MEMORY_WB attribute set in the UEFI memory map. Required for the arm/arm64 linux loader to restrict the initrd location to where it will be accessible by the kernel at runtime. Signed-off-by: Leif Lindholm --- grub-core/kern/efi/mm.c | 36 ++++++++++++++++++++++++++++++++++++ include/grub/efi/efi.h | 3 +++ 2 files changed, 39 insertions(+) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index 31ca703ec..8413c19e5 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -569,3 +569,39 @@ grub_efi_mm_init (void) grub_efi_free_pages ((grub_addr_t) memory_map, 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); } + +#if defined (__aarch64__) +grub_err_t +grub_efi_get_ram_base(grub_addr_t *base_addr) +{ + grub_efi_memory_descriptor_t *memory_map; + grub_efi_memory_descriptor_t *desc; + grub_efi_uintn_t mmap_size; + grub_efi_uintn_t desc_size; + int ret; + + mmap_size = grub_efi_find_mmap_size(); + + memory_map = grub_malloc (mmap_size); + if (! memory_map) + return GRUB_ERR_OUT_OF_MEMORY; + ret = grub_efi_get_memory_map (&mmap_size, memory_map, NULL, + &desc_size, NULL); + + if (ret < 1) + return GRUB_ERR_BUG; + + for (desc = memory_map, *base_addr = GRUB_UINT_MAX; + (grub_addr_t) desc < ((grub_addr_t) memory_map + mmap_size); + desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) + { + if (desc->attribute & GRUB_EFI_MEMORY_WB) + if (desc->physical_start < *base_addr) + *base_addr = desc->physical_start; + } + + grub_free(memory_map); + + return GRUB_ERR_NONE; +} +#endif diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 3984de083..80ab56795 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -85,6 +85,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, #if defined(__arm__) || defined(__aarch64__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); #endif +#if defined(__aarch64__) +grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); +#endif grub_addr_t grub_efi_modules_addr (void);