bbc6a8
From 91212e0aa07e704a61e4540c18a27f149f5e51c3 Mon Sep 17 00:00:00 2001
bbc6a8
From: Leif Lindholm <leif.lindholm@linaro.org>
bbc6a8
Date: Thu, 3 Aug 2017 11:04:26 +0100
31cddd
Subject: [PATCH] arm64 linux loader: improve type portability
bbc6a8
bbc6a8
In preparation for turning this into a common loader for 32-bit and 64-bit
bbc6a8
platforms, ensure the code will compile cleanly for either.
bbc6a8
bbc6a8
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
bbc6a8
---
bbc6a8
 grub-core/loader/arm64/linux.c | 15 ++++++---------
bbc6a8
 grub-core/loader/efi/fdt.c     |  8 ++++----
bbc6a8
 2 files changed, 10 insertions(+), 13 deletions(-)
bbc6a8
bbc6a8
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
ec4acb
index a652ee9088e..746edd10415 100644
bbc6a8
--- a/grub-core/loader/arm64/linux.c
bbc6a8
+++ b/grub-core/loader/arm64/linux.c
bbc6a8
@@ -57,8 +57,6 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh)
bbc6a8
 		       N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled"));
bbc6a8
 
bbc6a8
   grub_dprintf ("linux", "UEFI stub kernel:\n");
bbc6a8
-  grub_dprintf ("linux", "text_offset = 0x%012llx\n",
bbc6a8
-		(long long unsigned) lh->text_offset);
bbc6a8
   grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset);
bbc6a8
 
bbc6a8
   return GRUB_ERR_NONE;
bbc6a8
@@ -86,8 +84,8 @@ finalize_params_linux (void)
bbc6a8
   /* Set initrd info */
bbc6a8
   if (initrd_start && initrd_end > initrd_start)
bbc6a8
     {
bbc6a8
-      grub_dprintf ("linux", "Initrd @ 0x%012lx-0x%012lx\n",
bbc6a8
-		    initrd_start, initrd_end);
bbc6a8
+      grub_dprintf ("linux", "Initrd @ %p-%p\n",
bbc6a8
+		    (void *) initrd_start, (void *) initrd_end);
bbc6a8
 
bbc6a8
       retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start",
bbc6a8
 				    initrd_start);
bbc6a8
@@ -161,7 +159,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args)
bbc6a8
 
bbc6a8
   /* When successful, not reached */
bbc6a8
   b->unload_image (image_handle);
bbc6a8
-  grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options,
bbc6a8
+  grub_efi_free_pages ((grub_addr_t) loaded_image->load_options,
bbc6a8
 		       GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size));
bbc6a8
 
bbc6a8
   return grub_errno;
bbc6a8
@@ -188,7 +186,7 @@ grub_linux_unload (void)
bbc6a8
   initrd_start = initrd_end = 0;
bbc6a8
   grub_free (linux_args);
bbc6a8
   if (kernel_addr)
bbc6a8
-    grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
bbc6a8
+    grub_efi_free_pages ((grub_addr_t) kernel_addr,
bbc6a8
 			 GRUB_EFI_BYTES_TO_PAGES (kernel_size));
bbc6a8
   grub_fdt_unload ();
bbc6a8
   return GRUB_ERR_NONE;
bbc6a8
@@ -240,8 +238,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
bbc6a8
  fail:
bbc6a8
   grub_initrd_close (&initrd_ctx);
bbc6a8
   if (initrd_mem && !initrd_start)
bbc6a8
-    grub_efi_free_pages ((grub_efi_physical_address_t) initrd_mem,
bbc6a8
-			 initrd_pages);
bbc6a8
+    grub_efi_free_pages ((grub_addr_t) initrd_mem, initrd_pages);
bbc6a8
 
bbc6a8
   return grub_errno;
bbc6a8
 }
bbc6a8
@@ -328,7 +325,7 @@ fail:
bbc6a8
     grub_free (linux_args);
bbc6a8
 
bbc6a8
   if (kernel_addr && !loaded)
bbc6a8
-    grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
bbc6a8
+    grub_efi_free_pages ((grub_addr_t) kernel_addr,
bbc6a8
 			 GRUB_EFI_BYTES_TO_PAGES (kernel_size));
bbc6a8
 
bbc6a8
   return grub_errno;
bbc6a8
diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
ec4acb
index 091e9ddf43d..17212c38d0b 100644
bbc6a8
--- a/grub-core/loader/efi/fdt.c
bbc6a8
+++ b/grub-core/loader/efi/fdt.c
bbc6a8
@@ -32,12 +32,12 @@ void *
bbc6a8
 grub_fdt_load (grub_size_t additional_size)
bbc6a8
 {
bbc6a8
   void *raw_fdt;
bbc6a8
-  grub_size_t size;
bbc6a8
+  unsigned int size;
bbc6a8
 
bbc6a8
   if (fdt)
bbc6a8
     {
bbc6a8
       size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt));
bbc6a8
-      grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size);
bbc6a8
+      grub_efi_free_pages ((grub_addr_t) fdt, size);
bbc6a8
     }
bbc6a8
 
bbc6a8
   if (loaded_fdt)
bbc6a8
@@ -49,7 +49,7 @@ grub_fdt_load (grub_size_t additional_size)
bbc6a8
     raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ;
bbc6a8
   size += additional_size;
bbc6a8
 
bbc6a8
-  grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size);
bbc6a8
+  grub_dprintf ("linux", "allocating %d bytes for fdt\n", size);
bbc6a8
   fdt = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (size));
bbc6a8
   if (!fdt)
bbc6a8
     return NULL;
bbc6a8
@@ -88,7 +88,7 @@ grub_fdt_unload (void) {
bbc6a8
   if (!fdt) {
bbc6a8
     return;
bbc6a8
   }
bbc6a8
-  grub_efi_free_pages ((grub_efi_physical_address_t) fdt,
bbc6a8
+  grub_efi_free_pages ((grub_addr_t) fdt,
bbc6a8
 		       GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)));
bbc6a8
   fdt = NULL;
bbc6a8
 }