]>
Commit | Line | Data |
---|---|---|
1e57a462 | 1 | #ifndef _LIBFDT_INTERNAL_H\r |
2 | #define _LIBFDT_INTERNAL_H\r | |
e7108d0e | 3 | \r |
1e57a462 | 4 | /*\r |
5 | * libfdt - Flat Device Tree manipulation\r | |
6 | * Copyright (C) 2006 David Gibson, IBM Corporation.\r | |
7 | *\r | |
8 | * libfdt is dual licensed: you can use it either under the terms of\r | |
9 | * the GPL, or the BSD license, at your option.\r | |
10 | *\r | |
11 | * a) This library is free software; you can redistribute it and/or\r | |
12 | * modify it under the terms of the GNU General Public License as\r | |
13 | * published by the Free Software Foundation; either version 2 of the\r | |
14 | * License, or (at your option) any later version.\r | |
15 | *\r | |
16 | * This library is distributed in the hope that it will be useful,\r | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of\r | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r | |
19 | * GNU General Public License for more details.\r | |
20 | *\r | |
21 | * You should have received a copy of the GNU General Public\r | |
22 | * License along with this library; if not, write to the Free\r | |
23 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\r | |
24 | * MA 02110-1301 USA\r | |
25 | *\r | |
26 | * Alternatively,\r | |
27 | *\r | |
28 | * b) Redistribution and use in source and binary forms, with or\r | |
29 | * without modification, are permitted provided that the following\r | |
30 | * conditions are met:\r | |
31 | *\r | |
32 | * 1. Redistributions of source code must retain the above\r | |
33 | * copyright notice, this list of conditions and the following\r | |
34 | * disclaimer.\r | |
35 | * 2. Redistributions in binary form must reproduce the above\r | |
36 | * copyright notice, this list of conditions and the following\r | |
37 | * disclaimer in the documentation and/or other materials\r | |
38 | * provided with the distribution.\r | |
39 | *\r | |
40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\r | |
41 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,\r | |
42 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r | |
43 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r | |
44 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r | |
45 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r | |
46 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r | |
47 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r | |
48 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
49 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r | |
50 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r | |
51 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r | |
52 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r | |
53 | */\r | |
54 | #include <fdt.h>\r | |
55 | \r | |
e7108d0e MK |
56 | #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))\r |
57 | #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))\r | |
1e57a462 | 58 | \r |
59 | #define FDT_CHECK_HEADER(fdt) \\r | |
e7108d0e MK |
60 | { \\r |
61 | int __err; \\r | |
62 | if ((__err = fdt_check_header(fdt)) != 0) \\r | |
63 | return __err; \\r | |
64 | }\r | |
65 | \r | |
66 | int\r | |
67 | _fdt_check_node_offset (\r | |
68 | const void *fdt,\r | |
69 | int offset\r | |
70 | );\r | |
71 | \r | |
72 | int\r | |
73 | _fdt_check_prop_offset (\r | |
74 | const void *fdt,\r | |
75 | int offset\r | |
76 | );\r | |
1e57a462 | 77 | \r |
e7108d0e MK |
78 | const char *\r |
79 | _fdt_find_string (\r | |
80 | const char *strtab,\r | |
81 | int tabsize,\r | |
82 | const char *s\r | |
83 | );\r | |
1e57a462 | 84 | \r |
e7108d0e MK |
85 | int\r |
86 | _fdt_node_end_offset (\r | |
87 | void *fdt,\r | |
88 | int nodeoffset\r | |
89 | );\r | |
90 | \r | |
91 | static inline const void *\r | |
92 | _fdt_offset_ptr (\r | |
93 | const void *fdt,\r | |
94 | int offset\r | |
95 | )\r | |
1e57a462 | 96 | {\r |
e7108d0e | 97 | return (const char *)fdt + fdt_off_dt_struct (fdt) + offset;\r |
1e57a462 | 98 | }\r |
99 | \r | |
e7108d0e MK |
100 | static inline void *\r |
101 | _fdt_offset_ptr_w (\r | |
102 | void *fdt,\r | |
103 | int offset\r | |
104 | )\r | |
1e57a462 | 105 | {\r |
e7108d0e | 106 | return (void *)(uintptr_t)_fdt_offset_ptr (fdt, offset);\r |
1e57a462 | 107 | }\r |
108 | \r | |
e7108d0e MK |
109 | static inline const struct fdt_reserve_entry *\r |
110 | _fdt_mem_rsv (\r | |
111 | const void *fdt,\r | |
112 | int n\r | |
113 | )\r | |
1e57a462 | 114 | {\r |
e7108d0e MK |
115 | const struct fdt_reserve_entry *rsv_table =\r |
116 | (const struct fdt_reserve_entry *)\r | |
117 | ((const char *)fdt + fdt_off_mem_rsvmap (fdt));\r | |
1e57a462 | 118 | \r |
e7108d0e | 119 | return rsv_table + n;\r |
1e57a462 | 120 | }\r |
e7108d0e MK |
121 | \r |
122 | static inline struct fdt_reserve_entry *\r | |
123 | _fdt_mem_rsv_w (\r | |
124 | void *fdt,\r | |
125 | int n\r | |
126 | )\r | |
1e57a462 | 127 | {\r |
e7108d0e | 128 | return (void *)(uintptr_t)_fdt_mem_rsv (fdt, n);\r |
1e57a462 | 129 | }\r |
130 | \r | |
e7108d0e | 131 | #define FDT_SW_MAGIC (~FDT_MAGIC)\r |
1e57a462 | 132 | \r |
133 | #endif /* _LIBFDT_INTERNAL_H */\r |