source: grub-pc/trunk/fuentes/include/grub/fdt.h @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 4.2 KB
Line 
1/*
2 *  GRUB  --  GRand Unified Bootloader
3 *  Copyright (C) 2013  Free Software Foundation, Inc.
4 *
5 *  GRUB is free software: you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation, either version 3 of the License, or
8 *  (at your option) any later version.
9 *
10 *  GRUB is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef GRUB_FDT_HEADER
20#define GRUB_FDT_HEADER 1
21
22#include <grub/types.h>
23
24#define FDT_MAGIC 0xD00DFEED
25
26typedef struct {
27        grub_uint32_t magic;
28        grub_uint32_t totalsize;
29        grub_uint32_t off_dt_struct;
30        grub_uint32_t off_dt_strings;
31        grub_uint32_t off_mem_rsvmap;
32        grub_uint32_t version;
33        grub_uint32_t last_comp_version;
34        grub_uint32_t boot_cpuid_phys;
35        grub_uint32_t size_dt_strings;
36        grub_uint32_t size_dt_struct;
37} grub_fdt_header_t;
38
39struct grub_fdt_empty_tree {
40  grub_fdt_header_t header;
41  grub_uint64_t empty_rsvmap[2];
42  struct {
43    grub_uint32_t node_start;
44    grub_uint8_t name[1];
45    grub_uint32_t node_end;
46    grub_uint32_t tree_end;
47  } empty_node;
48};
49
50#define GRUB_FDT_EMPTY_TREE_SZ  sizeof (struct grub_fdt_empty_tree)
51
52#define grub_fdt_get_header(fdt, field) \
53        grub_be_to_cpu32(((const grub_fdt_header_t *)(fdt))->field)
54#define grub_fdt_set_header(fdt, field, value)  \
55        ((grub_fdt_header_t *)(fdt))->field = grub_cpu_to_be32(value)
56
57#define grub_fdt_get_magic(fdt) \
58        grub_fdt_get_header(fdt, magic)
59#define grub_fdt_set_magic(fdt, value)  \
60        grub_fdt_set_header(fdt, magic, value)
61#define grub_fdt_get_totalsize(fdt)     \
62        grub_fdt_get_header(fdt, totalsize)
63#define grub_fdt_set_totalsize(fdt, value)      \
64        grub_fdt_set_header(fdt, totalsize, value)
65#define grub_fdt_get_off_dt_struct(fdt) \
66        grub_fdt_get_header(fdt, off_dt_struct)
67#define grub_fdt_set_off_dt_struct(fdt, value)  \
68        grub_fdt_set_header(fdt, off_dt_struct, value)
69#define grub_fdt_get_off_dt_strings(fdt)        \
70        grub_fdt_get_header(fdt, off_dt_strings)
71#define grub_fdt_set_off_dt_strings(fdt, value) \
72        grub_fdt_set_header(fdt, off_dt_strings, value)
73#define grub_fdt_get_off_mem_rsvmap(fdt)        \
74        grub_fdt_get_header(fdt, off_mem_rsvmap)
75#define grub_fdt_set_off_mem_rsvmap(fdt, value) \
76        grub_fdt_set_header(fdt, off_mem_rsvmap, value)
77#define grub_fdt_get_version(fdt)       \
78        grub_fdt_get_header(fdt, version)
79#define grub_fdt_set_version(fdt, value)        \
80        grub_fdt_set_header(fdt, version, value)
81#define grub_fdt_get_last_comp_version(fdt)     \
82        grub_fdt_get_header(fdt, last_comp_version)
83#define grub_fdt_set_last_comp_version(fdt, value)      \
84        grub_fdt_set_header(fdt, last_comp_version, value)
85#define grub_fdt_get_boot_cpuid_phys(fdt)       \
86        grub_fdt_get_header(fdt, boot_cpuid_phys)
87#define grub_fdt_set_boot_cpuid_phys(fdt, value)        \
88        grub_fdt_set_header(fdt, boot_cpuid_phys, value)
89#define grub_fdt_get_size_dt_strings(fdt)       \
90        grub_fdt_get_header(fdt, size_dt_strings)
91#define grub_fdt_set_size_dt_strings(fdt, value)        \
92        grub_fdt_set_header(fdt, size_dt_strings, value)
93#define grub_fdt_get_size_dt_struct(fdt)        \
94        grub_fdt_get_header(fdt, size_dt_struct)
95#define grub_fdt_set_size_dt_struct(fdt, value) \
96        grub_fdt_set_header(fdt, size_dt_struct, value)
97
98int grub_fdt_create_empty_tree (void *fdt, unsigned int size);
99int grub_fdt_check_header (void *fdt, unsigned int size);
100int grub_fdt_check_header_nosize (void *fdt);
101int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset,
102                           const char *name);
103int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset,
104                          const char *name);
105
106int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
107                      const void *val, grub_uint32_t len);
108#define grub_fdt_set_prop32(fdt, nodeoffset, name, val) \
109({ \
110  grub_uint32_t _val = grub_cpu_to_be32(val); \
111  grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 4);    \
112})
113
114#define grub_fdt_set_prop64(fdt, nodeoffset, name, val)        \
115({ \
116  grub_uint64_t _val = grub_cpu_to_be64(val); \
117  grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 8);   \
118})
119
120#endif  /* ! GRUB_FDT_HEADER */
Note: See TracBrowser for help on using the repository browser.