mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-12-01 00:48:18 +00:00
6b2dd0f731
Signed-off-by: Peter Jones <pjones@redhat.com>
79 lines
2.6 KiB
Diff
79 lines
2.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Leif Lindholm <leif.lindholm@linaro.org>
|
|
Date: Thu, 1 Feb 2018 18:18:55 +0000
|
|
Subject: [PATCH] arm: switch linux loader to linux_arm_kernel_header struct
|
|
|
|
Use kernel header struct and magic definition to align (and coexist) with
|
|
i386/arm64 ports.
|
|
|
|
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
grub-core/loader/arm/linux.c | 11 +++++------
|
|
include/grub/arm/linux.h | 15 ++++++++++++---
|
|
2 files changed, 17 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
|
|
index e64c79a9577..9f43e41bb55 100644
|
|
--- a/grub-core/loader/arm/linux.c
|
|
+++ b/grub-core/loader/arm/linux.c
|
|
@@ -46,9 +46,6 @@ static const void *current_fdt;
|
|
|
|
typedef void (*kernel_entry_t) (int, unsigned long, void *);
|
|
|
|
-#define LINUX_ZIMAGE_OFFSET 0x24
|
|
-#define LINUX_ZIMAGE_MAGIC 0x016f2818
|
|
-
|
|
#define LINUX_PHYS_OFFSET (0x00008000)
|
|
#define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
|
|
#define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000)
|
|
@@ -315,6 +312,7 @@ linux_boot (void)
|
|
static grub_err_t
|
|
linux_load (const char *filename, grub_file_t file)
|
|
{
|
|
+ struct linux_arm_kernel_header *lh;
|
|
int size;
|
|
|
|
size = grub_file_size (file);
|
|
@@ -337,9 +335,10 @@ linux_load (const char *filename, grub_file_t file)
|
|
return grub_errno;
|
|
}
|
|
|
|
- if (size > LINUX_ZIMAGE_OFFSET + 4
|
|
- && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET)
|
|
- == LINUX_ZIMAGE_MAGIC)
|
|
+ lh = (void *) linux_addr;
|
|
+
|
|
+ if ((grub_size_t) size > sizeof (*lh) &&
|
|
+ lh->magic == GRUB_LINUX_ARM_MAGIC_SIGNATURE)
|
|
;
|
|
else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006
|
|
&& machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI)
|
|
diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
|
|
index 3706c46c66f..64dd3173cf7 100644
|
|
--- a/include/grub/arm/linux.h
|
|
+++ b/include/grub/arm/linux.h
|
|
@@ -20,11 +20,20 @@
|
|
#ifndef GRUB_ARM_LINUX_HEADER
|
|
#define GRUB_ARM_LINUX_HEADER 1
|
|
|
|
-#define LINUX_ZIMAGE_OFFSET 0x24
|
|
-#define LINUX_ZIMAGE_MAGIC 0x016f2818
|
|
-
|
|
#include "system.h"
|
|
|
|
+#define GRUB_LINUX_ARM_MAGIC_SIGNATURE 0x016f2818
|
|
+
|
|
+struct linux_arm_kernel_header {
|
|
+ grub_uint32_t code0;
|
|
+ grub_uint32_t reserved1[8];
|
|
+ grub_uint32_t magic;
|
|
+ grub_uint32_t start; /* _start */
|
|
+ grub_uint32_t end; /* _edata */
|
|
+ grub_uint32_t reserved2[4];
|
|
+ grub_uint32_t hdr_offset;
|
|
+};
|
|
+
|
|
#if defined GRUB_MACHINE_UBOOT
|
|
# include <grub/uboot/uboot.h>
|
|
# define LINUX_ADDRESS (start_of_ram + 0x8000)
|