From: Leif Lindholm <leif.lindholm@linaro.org>
To: grub-devel@gnu.org
Cc: Leif Lindholm <leif.lindholm@linaro.org>, patches@linaro.org
Subject: [PATCH v2 1/2] fdt: additions required for arm64 Linux loader
Date: Thu, 19 Dec 2013 20:58:54 +0000 [thread overview]
Message-ID: <1387486735-13461-1-git-send-email-leif.lindholm@linaro.org> (raw)
- Add grub_fdt_create_empty_tree() function.
- Add 64-bit setprop.
---
grub-core/lib/fdt.c | 29 +++++++++++++++++++++++++++++
include/grub/fdt.h | 20 ++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c
index 9f34dc7..57d6f30 100644
--- a/grub-core/lib/fdt.c
+++ b/grub-core/lib/fdt.c
@@ -423,3 +423,32 @@ 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.tree_end = grub_cpu_to_be32_compile_time (FDT_END);
+ et->empty_node.node_end = grub_cpu_to_be32_compile_time (FDT_END_NODE);
+ et->empty_node.node_start = grub_cpu_to_be32_compile_time (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 (et->header) + sizeof (et->empty_rsvmap));
+ 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..fae322e 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 node_start;
+ grub_uint8_t name[1];
+ grub_uint32_t node_end;
+ grub_uint32_t tree_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); \
+})
+
#endif /* ! GRUB_FDT_HEADER */
--
1.7.10.4
next reply other threads:[~2013-12-19 20:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 20:58 Leif Lindholm [this message]
2013-12-19 20:58 ` [PATCH v2 2/2] arm64: add EFI Linux loader 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=1387486735-13461-1-git-send-email-leif.lindholm@linaro.org \
--to=leif.lindholm@linaro.org \
--cc=grub-devel@gnu.org \
--cc=patches@linaro.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).