libfdt_internal.h revision 1.1.1.3 1 1.1.1.2 skrll /* $NetBSD: libfdt_internal.h,v 1.1.1.3 2019/12/22 12:30:37 skrll Exp $ */
2 1.1.1.2 skrll
3 1.1.1.3 skrll /* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
4 1.1.1.3 skrll #ifndef LIBFDT_INTERNAL_H
5 1.1.1.3 skrll #define LIBFDT_INTERNAL_H
6 1.1 macallan /*
7 1.1 macallan * libfdt - Flat Device Tree manipulation
8 1.1 macallan * Copyright (C) 2006 David Gibson, IBM Corporation.
9 1.1 macallan */
10 1.1 macallan #include <fdt.h>
11 1.1 macallan
12 1.1 macallan #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
13 1.1 macallan #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
14 1.1 macallan
15 1.1.1.3 skrll int fdt_ro_probe_(const void *fdt);
16 1.1.1.3 skrll #define FDT_RO_PROBE(fdt) \
17 1.1.1.3 skrll { \
18 1.1.1.3 skrll int totalsize_; \
19 1.1.1.3 skrll if ((totalsize_ = fdt_ro_probe_(fdt)) < 0) \
20 1.1.1.3 skrll return totalsize_; \
21 1.1 macallan }
22 1.1 macallan
23 1.1.1.3 skrll int fdt_check_node_offset_(const void *fdt, int offset);
24 1.1.1.3 skrll int fdt_check_prop_offset_(const void *fdt, int offset);
25 1.1.1.3 skrll const char *fdt_find_string_(const char *strtab, int tabsize, const char *s);
26 1.1.1.3 skrll int fdt_node_end_offset_(void *fdt, int nodeoffset);
27 1.1 macallan
28 1.1.1.3 skrll static inline const void *fdt_offset_ptr_(const void *fdt, int offset)
29 1.1 macallan {
30 1.1 macallan return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
31 1.1 macallan }
32 1.1 macallan
33 1.1.1.3 skrll static inline void *fdt_offset_ptr_w_(void *fdt, int offset)
34 1.1 macallan {
35 1.1.1.3 skrll return (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset);
36 1.1 macallan }
37 1.1 macallan
38 1.1.1.3 skrll static inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n)
39 1.1 macallan {
40 1.1 macallan const struct fdt_reserve_entry *rsv_table =
41 1.1 macallan (const struct fdt_reserve_entry *)
42 1.1 macallan ((const char *)fdt + fdt_off_mem_rsvmap(fdt));
43 1.1 macallan
44 1.1 macallan return rsv_table + n;
45 1.1 macallan }
46 1.1.1.3 skrll static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n)
47 1.1 macallan {
48 1.1.1.3 skrll return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n);
49 1.1 macallan }
50 1.1 macallan
51 1.1 macallan #define FDT_SW_MAGIC (~FDT_MAGIC)
52 1.1 macallan
53 1.1.1.3 skrll #endif /* LIBFDT_INTERNAL_H */
54