From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kXrSD-0004LJ-7n for mharc-grub-devel@gnu.org; Wed, 28 Oct 2020 15:49:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXrSC-0004KE-8N for Grub-devel@gnu.org; Wed, 28 Oct 2020 15:49:52 -0400 Received: from shcp25.hosting.zen.net.uk ([82.71.204.30]:60678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXrSA-0003jz-9q for Grub-devel@gnu.org; Wed, 28 Oct 2020 15:49:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=monkeyircd.org; s=default; h=Content-Transfer-Encoding:MIME-Version: Content-Type:References:In-Reply-To:Date:Cc:To:Reply-To:From:Subject: Message-ID:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bNAEDmWFkIlVlzVnKLUlCun1sHwvrVR+Q9DwoP2CzMs=; b=uoJ0EfBik2ZNB1HJAklOcZM8bl w0Py1E3qhJPjVwvh2dDqKKttt+Cdv/b1bWD7GbchvDUDgOba0c8vFLAFCwR+4RrJpkUkBEbG+OaZP oYz+4QeYgUi4T7SiCVgY/uEfhVl87ZOj2JulKEpdpBG6qMu1JkMmwA9gKFL9eITIKoTe2049oPJkB mZSP0x3QSDWSQT1z6VDVABsH/pFYtpkl5r36UooD4dNDjptcpCVLCSCdNXQyMotw0hrjYK15lzggA k641aTMm6gjOGMR16QYA2HCkfjpWg9ijyQFbFsTillV3/BktRf5ymtgC5b+h26m1EMesE+EWua1YS KW3tb/CA==; Received: from [82.69.123.44] (port=45068 helo=zoidberg.local.monkeyircd.org) by shcp25.hosting.zen.net.uk with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kXrS8-002iOB-50; Wed, 28 Oct 2020 19:49:48 +0000 Message-ID: <478b5219935dfb9efe06f004b729b59e4567660e.camel@monkeyircd.org> Subject: [PATCH 03/05] Enable multiboot2 support on arm64-efi target From: Chris Plant Reply-To: chris@monkeyircd.org To: Grub-devel@gnu.org Cc: chris@monkeyircd.org Date: Wed, 28 Oct 2020 19:49:47 +0000 In-Reply-To: <4b23bf36d0a833ff038709ae7c443647976dcd8c.camel@monkeyircd.org> References: <4b23bf36d0a833ff038709ae7c443647976dcd8c.camel@monkeyircd.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.4-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - shcp25.hosting.zen.net.uk X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - monkeyircd.org X-Get-Message-Sender-Via: shcp25.hosting.zen.net.uk: authenticated_id: chris@monkeyircd.org X-Authenticated-Sender: shcp25.hosting.zen.net.uk: chris@monkeyircd.org Received-SPF: pass client-ip=82.71.204.30; envelope-from=chris@monkeyircd.org; helo=shcp25.hosting.zen.net.uk X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/28 15:45:20 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2020 19:49:52 -0000 Add ARM64 versions of the mmap functions to generate memory map for multiboot2 Signed-off-by: Chris Plant --- grub-core/mmap/arm64/uppermem.c | 72 +++++++++++++++++++++++++++++++++ include/grub/arm64/memory.h | 60 +++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 grub-core/mmap/arm64/uppermem.c create mode 100644 include/grub/arm64/memory.h diff --git a/grub-core/mmap/arm64/uppermem.c b/grub- core/mmap/arm64/uppermem.c new file mode 100644 index 000000000..a980e0719 --- /dev/null +++ b/grub-core/mmap/arm64/uppermem.c @@ -0,0 +1,72 @@ +/* Compute amount of lower and upper memory till the first hole. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see ;. + */ + +#include +#include +#include +#include + +/* Helper for grub_mmap_get_lower. */ +static int +lower_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, + void *data) +{ + grub_uint64_t *lower = data; + + if (type != GRUB_MEMORY_AVAILABLE) + return 0; + if (addr == 0) + *lower = size; + return 0; +} + +grub_uint64_t +grub_mmap_get_lower (void) +{ + grub_uint64_t lower = 0; + + grub_mmap_iterate (lower_hook, &lower); + if (lower > GRUB_ARCH_LOWMEMMAXSIZE) + lower = GRUB_ARCH_LOWMEMMAXSIZE; + return lower; +} + +/* Helper for grub_mmap_get_upper. */ +static int +upper_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, + void *data) +{ + grub_uint64_t *upper = data; + + if (type != GRUB_MEMORY_AVAILABLE) + return 0; + if (addr <= GRUB_ARCH_HIGHMEMPSTART && addr + size + > GRUB_ARCH_HIGHMEMPSTART) + *upper = addr + size - GRUB_ARCH_HIGHMEMPSTART; + return 0; +} + +grub_uint64_t +grub_mmap_get_upper (void) +{ + grub_uint64_t upper = 0; + + grub_mmap_iterate (upper_hook, &upper); + return upper; +} diff --git a/include/grub/arm64/memory.h b/include/grub/arm64/memory.h new file mode 100644 index 000000000..7811f3449 --- /dev/null +++ b/include/grub/arm64/memory.h @@ -0,0 +1,60 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see ;. + */ + +#ifndef GRUB_MEMORY_CPU_HEADER +#define GRUB_MEMORY_CPU_HEADER 1 + +#ifndef ASM_FILE +#include +#include +#include +#endif + +#define GRUB_ARCH_LOWMEMVSTART 0x80000000 +#define GRUB_ARCH_LOWMEMPSTART 0x00000000 +#define GRUB_ARCH_LOWMEMMAXSIZE 0x10000000 +#define GRUB_ARCH_HIGHMEMPSTART 0x10000000 + +#ifndef ASM_FILE + +typedef grub_addr_t grub_phys_addr_t; + +static inline grub_phys_addr_t +grub_vtop (void *a) +{ + return (grub_phys_addr_t) a; +} + +static inline void * +grub_map_memory (grub_phys_addr_t a, grub_size_t size __attribute__ ((unused))) +{ + return (void *) a; +} + +static inline void +grub_unmap_memory (void *a __attribute__ ((unused)), + grub_size_t size __attribute__ ((unused))) +{ +} + +grub_uint64_t grub_mmap_get_lower (void); +grub_uint64_t grub_mmap_get_upper (void); + +#endif + +#endif -- 2.28.0