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