/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ #ifndef LIBFDT_INTERNAL_H #define LIBFDT_INTERNAL_H /* * libfdt - Flat Device Tree manipulation * Copyright (C) 2006 David Gibson, IBM Corporation. */ #include <fdt.h> #define FDT_ALIGN(x, a) … #define FDT_TAGALIGN(x) … int32_t fdt_ro_probe_(const void *fdt); #define FDT_RO_PROBE(fdt) … int fdt_check_node_offset_(const void *fdt, int offset); int fdt_check_prop_offset_(const void *fdt, int offset); const char *fdt_find_string_(const char *strtab, int tabsize, const char *s); int fdt_node_end_offset_(void *fdt, int nodeoffset); static inline const void *fdt_offset_ptr_(const void *fdt, int offset) { … } static inline void *fdt_offset_ptr_w_(void *fdt, int offset) { … } static inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n) { … } static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n) { … } /* * Internal helpers to access tructural elements of the device tree * blob (rather than for exaple reading integers from within property * values). We assume that we are either given a naturally aligned * address for the platform or if we are not, we are on a platform * where unaligned memory reads will be handled in a graceful manner. * If not the external helpers fdtXX_ld() from libfdt.h can be used * instead. */ static inline uint32_t fdt32_ld_(const fdt32_t *p) { … } static inline uint64_t fdt64_ld_(const fdt64_t *p) { … } #define FDT_SW_MAGIC … /**********************************************************************/ /* Checking controls */ /**********************************************************************/ #ifndef FDT_ASSUME_MASK #define FDT_ASSUME_MASK … #endif /* * Defines assumptions which can be enabled. Each of these can be enabled * individually. For maximum safety, don't enable any assumptions! * * For minimal code size and no safety, use ASSUME_PERFECT at your own risk. * You should have another method of validating the device tree, such as a * signature or hash check before using libfdt. * * For situations where security is not a concern it may be safe to enable * ASSUME_SANE. */ enum { … }; /** * can_assume_() - check if a particular assumption is enabled * * @mask: Mask to check (ASSUME_...) * @return true if that assumption is enabled, else false */ static inline bool can_assume_(int mask) { … } /** helper macros for checking assumptions */ #define can_assume(_assume) … #endif /* LIBFDT_INTERNAL_H */