]>
Commit | Line | Data |
---|---|---|
7cd5da0f GVB |
1 | #ifndef _LIBFDT_INTERNAL_H |
2 | #define _LIBFDT_INTERNAL_H | |
3 | /* | |
4 | * libfdt - Flat Device Tree manipulation | |
5 | * Copyright (C) 2006 David Gibson, IBM Corporation. | |
35084760 | 6 | * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause |
7cd5da0f GVB |
7 | */ |
8 | #include <fdt.h> | |
9 | ||
fc7758ee DG |
10 | #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) |
11 | #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) | |
7cd5da0f | 12 | |
fc7758ee | 13 | #define FDT_CHECK_HEADER(fdt) \ |
d0ccb9b1 | 14 | { \ |
0596d35d SG |
15 | int __err; \ |
16 | if ((__err = fdt_check_header(fdt)) != 0) \ | |
17 | return __err; \ | |
d0ccb9b1 DG |
18 | } |
19 | ||
2f08bfa9 | 20 | int _fdt_check_node_offset(const void *fdt, int offset); |
d1c63148 | 21 | int _fdt_check_prop_offset(const void *fdt, int offset); |
7cd5da0f GVB |
22 | const char *_fdt_find_string(const char *strtab, int tabsize, const char *s); |
23 | int _fdt_node_end_offset(void *fdt, int nodeoffset); | |
24 | ||
8d04f02f KG |
25 | static inline const void *_fdt_offset_ptr(const void *fdt, int offset) |
26 | { | |
ef4e8ce1 | 27 | return (const char *)fdt + fdt_off_dt_struct(fdt) + offset; |
8d04f02f KG |
28 | } |
29 | ||
30 | static inline void *_fdt_offset_ptr_w(void *fdt, int offset) | |
31 | { | |
c6683026 | 32 | return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset); |
8d04f02f KG |
33 | } |
34 | ||
35 | static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n) | |
36 | { | |
c6683026 DG |
37 | const struct fdt_reserve_entry *rsv_table = |
38 | (const struct fdt_reserve_entry *) | |
ef4e8ce1 | 39 | ((const char *)fdt + fdt_off_mem_rsvmap(fdt)); |
8d04f02f KG |
40 | |
41 | return rsv_table + n; | |
42 | } | |
43 | static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n) | |
7cd5da0f | 44 | { |
c6683026 | 45 | return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n); |
7cd5da0f GVB |
46 | } |
47 | ||
fc7758ee | 48 | #define FDT_SW_MAGIC (~FDT_MAGIC) |
7cd5da0f GVB |
49 | |
50 | #endif /* _LIBFDT_INTERNAL_H */ |