From patchwork Thu Aug 3 10:04:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 109313 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp681951obm; Thu, 3 Aug 2017 03:14:40 -0700 (PDT) X-Received: by 10.200.34.100 with SMTP id p33mr1451639qtp.87.1501755280340; Thu, 03 Aug 2017 03:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501755280; cv=none; d=google.com; s=arc-20160816; b=tQVGWsHoyMwowds8QsTUVaDMwwvlkZqYRffvnOnhvZkxg4MxkAJ7Gw5U1ixrRXQt0l TQxNjravcsqct8jwuODTdXf0nNPa/zdtexweAuvjSiJawwsLuMSse3Z8nP/rYhJfSQsm jKkbvz0MwoMfZQo/ovQp2QCb0kmZMelfm3ANOfrtVx92j0+1xXzUqOK4Lsz4RcYNiIth T4ECh1PBLCwSc2VRw56sOOcV5gI+Ejhbqdl2yNpRFKlwwixy9cDM4Vl6jh38RrguJT64 WbNtvrBjj2C4saUAVVcElK9I6dLypox4MN7FLXGYxcLgG/45m79OnT9+TlYGATHDx1M4 UaTw== 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=TwFpKIfLCA24XyuU1RWHY0ZdRxJPvIxPmMQSlSZDCi4=; b=ftFmmBSz5/SGpG/HvfuKgX9Aw1K0Wq3GkfEjfjhO/+5bs9ETPK0+Dnz9Bx+Qbt34GD +j1Xm4LyJEfYk5PglZb4zU2WL63v68JFan5Ku527ESCnTodmXwIQSJuYC9l9WLXQmW1d dfMu3Fg0LfgGRp77eBoieOmPfdCQMYH8n4qtxAaOne+43+IrOqJb3Y4g9Pxl4QMOMuQb 40Omnxg7RdlJP+83qhp6GIl9NbnZE+zEuC0eKmGMFjw7ddy18EMUc798qC9vkFr6xIXk dbq6wMKz6gw/KH8hz54zoWwdrTPp3yAQR6eE2ltfm/hrb+eHGH/esB8aacs0eFdArIsO qDYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=jiEX8RuP; 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 a58si15582004qte.299.2017.08.03.03.14.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 03:14:40 -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=jiEX8RuP; 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]:53649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD9J-00068U-Nq for patch@linaro.org; Thu, 03 Aug 2017 06:14:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddD1h-0000Io-NF for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddD1g-0004Cw-Ax for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:45 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:37148) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddD1g-0004Bw-1J for grub-devel@gnu.org; Thu, 03 Aug 2017 06:06:44 -0400 Received: by mail-wm0-x233.google.com with SMTP id t201so10938146wmt.0 for ; Thu, 03 Aug 2017 03:06:43 -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=wrfXdUy48J8ogmQZW+8/snGy1D8l1O7lkTgB+WS0ryw=; b=jiEX8RuPz0srAToLUkcBJ2JutK5mZEW8ufhrm6GQLS7sZMDNslbaIRtYLe1gHvqUwA 1snRXiEO6wdYRJQmNBRdmp+d3po9li5CE+c8XW45bVXBrenycjP2Fwa6qgXqOHojWlBO qmnMw4UeZwqTiWKOgCQI2avaXwoH3K0OgI31s= 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=wrfXdUy48J8ogmQZW+8/snGy1D8l1O7lkTgB+WS0ryw=; b=jUdmUF5oS1kPanFCd2kluZBGM7PKLglH0XTkGUflF7D8ZLBDVLF+RlKWJdVe7S56+s B0+Wh8Tltd+3ulUFC/3kgwbb17MNabkskW/lXfEf8tcIAnvTcxJV0e1GKpKAMmWPMiyG uISekcf9/oUGW1G9cuz6iDzlgwgl/AjbZO5DV5hsx4xJPaNNe+FS+eGztguCk8QIwKHJ yplqKO206croEJHVgwpTMcXEs8yCrKg0K/yXWoLOUNC+LXseTrG+jyx2S0FGFdiiqc5Y +Zzg6g7Dp8e6axYYpx9q/zNLyDyQ/U2BqHuYcK6+f48+hJ4iOGDmAvNrS9bWfh1nJv/T AxSA== X-Gm-Message-State: AIVw113I+Dspd70m6ZBU0FSa9KDWnUUMVnDRoK0aCDElLlM08lWm+QpM 1/rV47qpeCaxPBsu1bK16g== X-Received: by 10.28.60.11 with SMTP id j11mr812720wma.47.1501754802703; Thu, 03 Aug 2017 03:06:42 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 03:06:42 -0700 (PDT) From: Leif Lindholm To: grub-devel@gnu.org Subject: [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers Date: Thu, 3 Aug 2017 11:04:27 +0100 Message-Id: <20170803100432.29913-10-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:c09::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" In preparation for using the linux loader for 32-bit and 64-bit platforms, rename grub_arm64*/GRUB_ARM64* to grub_efi*/GRUB_EFI*. Move prototypes for now-common functions to efi/efi.h. Signed-off-by: Leif Lindholm --- grub-core/loader/arm64/linux.c | 14 +++++++------- grub-core/loader/arm64/xen_boot.c | 12 ++++++------ include/grub/arm64/linux.h | 11 ++--------- include/grub/efi/efi.h | 4 ++++ 4 files changed, 19 insertions(+), 22 deletions(-) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index c60469e53..8cd44230d 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -48,9 +48,9 @@ static grub_addr_t initrd_start; static grub_addr_t initrd_end; grub_err_t -grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) +grub_efi_linux_check_image (struct grub_linux_kernel_header * lh) { - if (lh->magic != GRUB_ARM64_LINUX_MAGIC) + if (lh->magic != GRUB_LINUX_MAGIC_SIGNATURE) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) @@ -109,7 +109,7 @@ failure: } grub_err_t -grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) +grub_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) { grub_efi_memory_mapped_device_path_t *mempath; grub_efi_handle_t image_handle; @@ -173,8 +173,8 @@ grub_linux_boot (void) if (finalize_params_linux () != GRUB_ERR_NONE) return grub_errno; - return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr, - kernel_size, linux_args)); + return (grub_efi_linux_boot_image((grub_addr_t)kernel_addr, + kernel_size, linux_args)); } static grub_err_t @@ -250,7 +250,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; - struct grub_arm64_linux_kernel_header lh; + struct grub_linux_kernel_header lh; grub_dl_ref (my_mod); @@ -269,7 +269,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh)) return grub_errno; - if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE) + if (grub_efi_linux_check_image (&lh) != GRUB_ERR_NONE) goto fail; grub_loader_unset(); diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index d092a53ed..e8720584b 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -67,7 +67,7 @@ typedef enum module_type module_type_t; struct xen_hypervisor_header { - struct grub_arm64_linux_kernel_header efi_head; + struct grub_linux_kernel_header efi_head; /* This is always PE\0\0. */ grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE]; @@ -254,9 +254,9 @@ xen_boot (void) if (err) return err; - return grub_arm64_uefi_boot_image (xen_hypervisor->start, - xen_hypervisor->size, - xen_hypervisor->cmdline); + return grub_efi_linux_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); } static void @@ -458,8 +458,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh)) goto fail; - if (grub_arm64_uefi_check_image - ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE) + if (grub_efi_linux_check_image + ((struct grub_linux_kernel_header *) &sh) != GRUB_ERR_NONE) goto fail; grub_file_seek (file, 0); diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index a981df5d1..e53be83b1 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -19,12 +19,10 @@ #ifndef GRUB_LINUX_CPU_HEADER #define GRUB_LINUX_CPU_HEADER 1 -#include - -#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ +#define GRUB_LINUX_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */ /* From linux/Documentation/arm64/booting.txt */ -struct grub_arm64_linux_kernel_header +struct grub_linux_kernel_header { grub_uint32_t code0; /* Executable code */ grub_uint32_t code1; /* Executable code */ @@ -38,9 +36,4 @@ struct grub_arm64_linux_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; -grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header - *lh); -grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, - char *args); - #endif /* ! GRUB_LINUX_CPU_HEADER */ diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index a58774efc..149969941 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -92,6 +92,10 @@ 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 *); +#include +grub_err_t grub_efi_linux_check_image(struct grub_linux_kernel_header *lh); +grub_err_t grub_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, + char *args); #endif grub_addr_t grub_efi_modules_addr (void);