1 /* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
2 #ifndef LIBFDT_INTERNAL_H
3 #define LIBFDT_INTERNAL_H
5 * libfdt - Flat Device Tree manipulation
6 * Copyright (C) 2006 David Gibson, IBM Corporation.
10 #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
11 #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
13 int fdt_ro_probe_(const void *fdt
);
14 #define FDT_RO_PROBE(fdt) \
17 if ((err_ = fdt_ro_probe_(fdt)) != 0) \
21 int fdt_check_node_offset_(const void *fdt
, int offset
);
22 int fdt_check_prop_offset_(const void *fdt
, int offset
);
23 const char *fdt_find_string_(const char *strtab
, int tabsize
, const char *s
);
24 int fdt_node_end_offset_(void *fdt
, int nodeoffset
);
26 static inline const void *fdt_offset_ptr_(const void *fdt
, int offset
)
28 return (const char *)fdt
+ fdt_off_dt_struct(fdt
) + offset
;
31 static inline void *fdt_offset_ptr_w_(void *fdt
, int offset
)
33 return (void *)(uintptr_t)fdt_offset_ptr_(fdt
, offset
);
36 static inline const struct fdt_reserve_entry
*fdt_mem_rsv_(const void *fdt
, int n
)
38 const struct fdt_reserve_entry
*rsv_table
=
39 (const struct fdt_reserve_entry
*)
40 ((const char *)fdt
+ fdt_off_mem_rsvmap(fdt
));
44 static inline struct fdt_reserve_entry
*fdt_mem_rsv_w_(void *fdt
, int n
)
46 return (void *)(uintptr_t)fdt_mem_rsv_(fdt
, n
);
49 #define FDT_SW_MAGIC (~FDT_MAGIC)
51 #endif /* LIBFDT_INTERNAL_H */