1 | #ifndef _FDT_H
|
---|
2 | #define _FDT_H
|
---|
3 |
|
---|
4 | /*
|
---|
5 | * libfdt - Flat Device Tree manipulation
|
---|
6 | * Copyright (C) 2006 David Gibson, IBM Corporation.
|
---|
7 | * Copyright 2012 Kim Phillips, Freescale Semiconductor.
|
---|
8 | *
|
---|
9 | * libfdt is dual licensed: you can use it either under the terms of
|
---|
10 | * the GPL, or the BSD license, at your option.
|
---|
11 | *
|
---|
12 | * a) This library is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License as
|
---|
14 | * published by the Free Software Foundation; either version 2 of the
|
---|
15 | * License, or (at your option) any later version.
|
---|
16 | *
|
---|
17 | * This library is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public
|
---|
23 | * License along with this library; if not, write to the Free
|
---|
24 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
---|
25 | * MA 02110-1301 USA
|
---|
26 | *
|
---|
27 | * Alternatively,
|
---|
28 | *
|
---|
29 | * b) Redistribution and use in source and binary forms, with or
|
---|
30 | * without modification, are permitted provided that the following
|
---|
31 | * conditions are met:
|
---|
32 | *
|
---|
33 | * 1. Redistributions of source code must retain the above
|
---|
34 | * copyright notice, this list of conditions and the following
|
---|
35 | * disclaimer.
|
---|
36 | * 2. Redistributions in binary form must reproduce the above
|
---|
37 | * copyright notice, this list of conditions and the following
|
---|
38 | * disclaimer in the documentation and/or other materials
|
---|
39 | * provided with the distribution.
|
---|
40 | *
|
---|
41 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
---|
42 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
---|
43 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
44 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
45 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
---|
46 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
47 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
48 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
49 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
50 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
---|
51 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
---|
52 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
---|
53 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
54 | */
|
---|
55 |
|
---|
56 | #ifndef __ASSEMBLY__
|
---|
57 |
|
---|
58 | struct fdt_header {
|
---|
59 | fdt32_t magic; /* magic word FDT_MAGIC */
|
---|
60 | fdt32_t totalsize; /* total size of DT block */
|
---|
61 | fdt32_t off_dt_struct; /* offset to structure */
|
---|
62 | fdt32_t off_dt_strings; /* offset to strings */
|
---|
63 | fdt32_t off_mem_rsvmap; /* offset to memory reserve map */
|
---|
64 | fdt32_t version; /* format version */
|
---|
65 | fdt32_t last_comp_version; /* last compatible version */
|
---|
66 |
|
---|
67 | /* version 2 fields below */
|
---|
68 | fdt32_t boot_cpuid_phys; /* Which physical CPU id we're
|
---|
69 | booting on */
|
---|
70 | /* version 3 fields below */
|
---|
71 | fdt32_t size_dt_strings; /* size of the strings block */
|
---|
72 |
|
---|
73 | /* version 17 fields below */
|
---|
74 | fdt32_t size_dt_struct; /* size of the structure block */
|
---|
75 | };
|
---|
76 |
|
---|
77 | struct fdt_reserve_entry {
|
---|
78 | fdt64_t address;
|
---|
79 | fdt64_t size;
|
---|
80 | };
|
---|
81 |
|
---|
82 | struct fdt_node_header {
|
---|
83 | fdt32_t tag;
|
---|
84 | char name[0];
|
---|
85 | };
|
---|
86 |
|
---|
87 | struct fdt_property {
|
---|
88 | fdt32_t tag;
|
---|
89 | fdt32_t len;
|
---|
90 | fdt32_t nameoff;
|
---|
91 | char data[0];
|
---|
92 | };
|
---|
93 |
|
---|
94 | #endif /* !__ASSEMBLY */
|
---|
95 |
|
---|
96 | #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
|
---|
97 | #define FDT_TAGSIZE sizeof(fdt32_t)
|
---|
98 |
|
---|
99 | #define FDT_BEGIN_NODE 0x1 /* Start node: full name */
|
---|
100 | #define FDT_END_NODE 0x2 /* End node */
|
---|
101 | #define FDT_PROP 0x3 /* Property: name off,
|
---|
102 | size, content */
|
---|
103 | #define FDT_NOP 0x4 /* nop */
|
---|
104 | #define FDT_END 0x9
|
---|
105 |
|
---|
106 | #define FDT_V1_SIZE (7*sizeof(fdt32_t))
|
---|
107 | #define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t))
|
---|
108 | #define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t))
|
---|
109 | #define FDT_V16_SIZE FDT_V3_SIZE
|
---|
110 | #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))
|
---|
111 |
|
---|
112 | #endif /* _FDT_H */
|
---|