grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH] add fdt prerequisites for arm64 UEFI Linux loader
Date: Mon, 16 Dec 2013 22:17:12 +0100	[thread overview]
Message-ID: <52AF6DD8.1050407@gmail.com> (raw)
In-Reply-To: <20131216135210.GU22356@rocoto.smurfnet.nu>

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

On 16.12.2013 14:52, Leif Lindholm wrote:
> 
> 0001-fdt-additions-required-for-arm64-Linux-loader.patch
> 
> 
>>From ac2166a62495381736fa05668035230607d1bb3d Mon Sep 17 00:00:00 2001
> From: Leif Lindholm <leif.lindholm@linaro.org>
> Date: Wed, 4 Dec 2013 13:09:21 +0000
> Subject: [PATCH 1/2] fdt: additions required for arm64 Linux loader
> 
> - Add grub_fdt_create_empty_tree() function.
> - Add 64-bit setprop.
> ---
>  grub-core/lib/fdt.c |   28 ++++++++++++++++++++++++++++
>  include/grub/fdt.h  |   20 ++++++++++++++++++++
>  2 files changed, 48 insertions(+)
> 
> diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c
> index 9f34dc7..fb13672 100644
> --- a/grub-core/lib/fdt.c
> +++ b/grub-core/lib/fdt.c
> @@ -423,3 +423,31 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
>    grub_memcpy (prop + 3, val, len);
>    return 0;
>  }
> +
> +int
> +grub_fdt_create_empty_tree (void *fdt, unsigned int size)
> +{
> +  struct grub_fdt_empty_tree *et;
> +
> +  if (size < GRUB_FDT_EMPTY_TREE_SZ)
> +    return -1;
> +
> +  grub_memset (fdt, 0, size);
> +  et = fdt;
> +
> +  et->empty_node.node_end = grub_cpu_to_be32 (FDT_END);
> +  et->empty_node.prop_end = grub_cpu_to_be32 (FDT_END_NODE);
grub_cpu_to_be32_compile_time is better suited.
> +  et->empty_node.prop_start = grub_cpu_to_be32 (FDT_BEGIN_NODE);
> +  ((struct grub_fdt_empty_tree *) fdt)->header.off_mem_rsvmap =
> +    grub_cpu_to_be32 (ALIGN_UP (sizeof (grub_fdt_header_t), 8));
> +
> +  grub_fdt_set_off_dt_strings (fdt, sizeof (*et));
> +  grub_fdt_set_off_dt_struct (fdt, sizeof (grub_fdt_header_t) + 16);
> +  grub_fdt_set_version (fdt, FDT_SUPPORTED_VERSION);
> +  grub_fdt_set_last_comp_version (fdt, FDT_SUPPORTED_VERSION);
> +  grub_fdt_set_size_dt_struct (fdt, sizeof (et->empty_node));
> +  grub_fdt_set_totalsize (fdt, size);
> +  grub_fdt_set_magic (fdt, FDT_MAGIC);
> +
> +  return 0;
> +}
> diff --git a/include/grub/fdt.h b/include/grub/fdt.h
> index 2ad0536..bbc88ec 100644
> --- a/include/grub/fdt.h
> +++ b/include/grub/fdt.h
> @@ -36,6 +36,19 @@ typedef struct {
>  	grub_uint32_t size_dt_struct;
>  } grub_fdt_header_t;
>  
> +struct grub_fdt_empty_tree {
> +  grub_fdt_header_t header;
> +  grub_uint64_t empty_rsvmap[2];
> +  struct {
> +    grub_uint32_t prop_start;
> +    grub_uint8_t name[1];
> +    grub_uint32_t prop_end;
> +    grub_uint32_t node_end;
> +  } empty_node;
> +};
> +
> +#define GRUB_FDT_EMPTY_TREE_SZ  sizeof (struct grub_fdt_empty_tree)
> +
>  #define grub_fdt_get_header(fdt, field)	\
>  	grub_be_to_cpu32(((const grub_fdt_header_t *)(fdt))->field)
>  #define grub_fdt_set_header(fdt, field, value)	\
> @@ -82,6 +95,7 @@ typedef struct {
>  #define grub_fdt_set_size_dt_struct(fdt, value)	\
>  	grub_fdt_set_header(fdt, size_dt_struct, value)
>  
> +int grub_fdt_create_empty_tree (void *fdt, unsigned int size);
>  int grub_fdt_check_header (void *fdt, unsigned int size);
>  int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset,
>  			   const char *name);
> @@ -96,4 +110,10 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
>    grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 4);	\
>  })
>  
> +#define grub_fdt_set_prop64(fdt, nodeoffset, name, val)        \
> +({ \
> +  grub_uint64_t _val = grub_cpu_to_be64(val); \
> +  grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 8);   \
> +})
> +
Why not make it into inline function?
>  #endif	/* ! GRUB_FDT_HEADER */
> -- 1.7.10.4
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

  reply	other threads:[~2013-12-16 21:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-16 13:52 [PATCH] add fdt prerequisites for arm64 UEFI Linux loader Leif Lindholm
2013-12-16 21:17 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2013-12-18 15:56   ` Leif Lindholm
2013-12-17  9:27 ` Francesco Lavra
2013-12-18 15:53   ` Leif Lindholm

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=52AF6DD8.1050407@gmail.com \
    --to=phcoder@gmail.com \
    --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).