grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: Daniel Kiper <dkiper@net-space.pl>
Subject: Re: [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct
Date: Mon, 07 Aug 2017 14:07:19 +0000	[thread overview]
Message-ID: <CAEaD8JN6SLMwaGMMZuNiB+A+8ZhBCNGOFDkSiP8RAkd_8ugyGQ@mail.gmail.com> (raw)
In-Reply-To: <20170803100432.29913-11-leif.lindholm@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 2969 bytes --]

Le Thu, Aug 3, 2017 à 12:15 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> Use kernel header struct and generic magic definition to align with
> arm64/linux loader.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  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 e64c79a95..067f69894 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 grub_linux_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_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 f217f8281..802090239 100644
> --- a/include/grub/arm/linux.h
> +++ b/include/grub/arm/linux.h
> @@ -20,11 +20,20 @@
>  #ifndef GRUB_LINUX_CPU_HEADER
>  #define GRUB_LINUX_CPU_HEADER 1
>
> -#define LINUX_ZIMAGE_OFFSET 0x24
> -#define LINUX_ZIMAGE_MAGIC  0x016f2818
> -
>  #include "system.h"
>
> +#define GRUB_LINUX_MAGIC_SIGNATURE 0x016f2818
> +
> +struct grub_linux_kernel_header {
>
This maz clash with other architectures preventing including several
architecture files in the same file. We need it to create tools like
grub-file .

> +  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)
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 3867 bytes --]

  reply	other threads:[~2017-08-07 14:07 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
2017-08-03 15:18   ` Vladimir 'phcoder' Serbinenko
2017-08-04  9:11     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size Leif Lindholm
2017-08-03 15:19   ` Vladimir 'phcoder' Serbinenko
2017-08-08 15:56     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 03/14] loader: drop local implementations of find_efi_mmap_size Leif Lindholm
2017-08-03 15:20   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm* Leif Lindholm
2017-08-03 15:30   ` Vladimir 'phcoder' Serbinenko
2017-08-08 16:04     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 05/14] efi: refactor grub_efi_allocate_pages Leif Lindholm
2017-08-03 15:37   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 06/14] efi: move fdt helper library Leif Lindholm
2017-08-03 15:38   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 07/14] efi: Add GRUB_PE32_MAGIC definition Leif Lindholm
2017-08-03 16:35   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 08/14] arm64 linux loader: improve type portability Leif Lindholm
2017-08-03 16:41   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers Leif Lindholm
2017-08-03 16:44   ` Vladimir 'phcoder' Serbinenko
2017-08-03 16:46     ` Vladimir 'phcoder' Serbinenko
2017-09-04 14:29     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct Leif Lindholm
2017-08-07 14:07   ` Vladimir 'phcoder' Serbinenko [this message]
2017-09-04 14:31     ` Leif Lindholm
2017-09-04 14:35       ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 11/14] arm/efi: switch to arm64 linux loader Leif Lindholm
2017-08-07 14:08   ` Vladimir 'phcoder' Serbinenko
2017-09-04 14:35     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 12/14] arm: delete unused efi support from loader/arm Leif Lindholm
2017-08-07 14:09   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 13/14] efi: restrict arm/arm64 linux loader initrd placement Leif Lindholm
2017-08-07 14:10   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE Leif Lindholm
2017-08-07 14:11   ` Vladimir 'phcoder' Serbinenko
2017-08-07 16:18     ` Konrad Rzeszutek Wilk
2017-08-07 16:22       ` Vladimir 'phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEaD8JN6SLMwaGMMZuNiB+A+8ZhBCNGOFDkSiP8RAkd_8ugyGQ@mail.gmail.com \
    --to=phcoder@gmail.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).