1/*
2 * libfdt - Flat Device Tree manipulation
3 * Copyright (C) 2006 David Gibson, IBM Corporation.
4 *
5 *     Redistribution and use in source and binary forms, with or
6 *     without modification, are permitted provided that the following
7 *     conditions are met:
8 *
9 *     1. Redistributions of source code must retain the above
10 *        copyright notice, this list of conditions and the following
11 *        disclaimer.
12 *     2. Redistributions in binary form must reproduce the above
13 *        copyright notice, this list of conditions and the following
14 *        disclaimer in the documentation and/or other materials
15 *        provided with the distribution.
16 *
17 *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
18 *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31#ifndef _FDT_H
32#define _FDT_H
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#ifndef __ASSEMBLY__
39
40#include "libfdt_env.h"
41
42struct fdt_header {
43        fdt32_t magic;			 /* magic word FDT_MAGIC */
44        fdt32_t totalsize;		 /* total size of DT block */
45        fdt32_t off_dt_struct;		 /* offset to structure */
46        fdt32_t off_dt_strings;		 /* offset to strings */
47        fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
48        fdt32_t version;		 /* format version */
49        fdt32_t last_comp_version;	 /* last compatible version */
50
51        /* version 2 fields below */
52        fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
53                                            booting on */
54        /* version 3 fields below */
55        fdt32_t size_dt_strings;	 /* size of the strings block */
56
57        /* version 17 fields below */
58        fdt32_t size_dt_struct;		 /* size of the structure block */
59};
60
61struct fdt_reserve_entry {
62        fdt64_t address;
63        fdt64_t size;
64};
65
66struct fdt_node_header {
67        fdt32_t tag;
68        char name[0];
69};
70
71struct fdt_property {
72        fdt32_t tag;
73        fdt32_t len;
74        fdt32_t nameoff;
75        char data[0];
76};
77
78#endif /* !__ASSEMBLY */
79
80#define FDT_MAGIC	0xd00dfeed	/* 4: version, 4: total size */
81#define FDT_TAGSIZE	sizeof(fdt32_t)
82
83#define FDT_BEGIN_NODE	0x1		/* Start node: full name */
84#define FDT_END_NODE	0x2		/* End node */
85#define FDT_PROP	0x3		/* Property: name off,
86                                           size, content */
87#define FDT_NOP		0x4		/* nop */
88#define FDT_END		0x9
89
90#define FDT_V1_SIZE	(7*sizeof(fdt32_t))
91#define FDT_V2_SIZE	(FDT_V1_SIZE + sizeof(fdt32_t))
92#define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
93#define FDT_V16_SIZE	FDT_V3_SIZE
94#define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif /* _FDT_H */
101