commands/file: Use definitions from arm64/linux.h

Clean up code for matching IS_ARM64 slightly by making use of struct
linux_arm64_kernel_header and GRUB_LINUX_ARM64_MAGIC_SIGNATURE.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Leif Lindholm 2018-06-25 18:01:29 +01:00 committed by Daniel Kiper
parent 40dc61ed75
commit 9b37229f01

View file

@ -28,6 +28,7 @@
#include <grub/xen_file.h> #include <grub/xen_file.h>
#include <grub/efi/pe32.h> #include <grub/efi/pe32.h>
#include <grub/arm/linux.h> #include <grub/arm/linux.h>
#include <grub/arm64/linux.h>
#include <grub/i386/linux.h> #include <grub/i386/linux.h>
#include <grub/xnu.h> #include <grub/xnu.h>
#include <grub/machoload.h> #include <grub/machoload.h>
@ -405,13 +406,13 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
} }
case IS_ARM64_LINUX: case IS_ARM64_LINUX:
{ {
grub_uint32_t sig; struct linux_arm64_kernel_header lh;
if (grub_file_seek (file, 0x38) == (grub_size_t) -1) if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
break; break;
if (grub_file_read (file, &sig, 4) != 4)
break; if (lh.magic ==
if (sig == grub_cpu_to_le32_compile_time (0x644d5241)) grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM64_MAGIC_SIGNATURE))
{ {
ret = 1; ret = 1;
break; break;