Home | History | Annotate | Line # | Download | only in dist
libfdt_internal.h revision 1.1.1.2.8.1
      1      1.1.1.2     skrll /*	$NetBSD: libfdt_internal.h,v 1.1.1.2.8.1 2020/04/08 14:08:28 martin Exp $	*/
      2      1.1.1.2     skrll 
      3  1.1.1.2.8.1    martin /* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
      4  1.1.1.2.8.1    martin #ifndef LIBFDT_INTERNAL_H
      5  1.1.1.2.8.1    martin #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.2.8.1    martin int fdt_ro_probe_(const void *fdt);
     16  1.1.1.2.8.1    martin #define FDT_RO_PROBE(fdt)					\
     17  1.1.1.2.8.1    martin 	{							\
     18  1.1.1.2.8.1    martin 		int totalsize_;					\
     19  1.1.1.2.8.1    martin 		if ((totalsize_ = fdt_ro_probe_(fdt)) < 0)	\
     20  1.1.1.2.8.1    martin 			return totalsize_;			\
     21          1.1  macallan 	}
     22          1.1  macallan 
     23  1.1.1.2.8.1    martin int fdt_check_node_offset_(const void *fdt, int offset);
     24  1.1.1.2.8.1    martin int fdt_check_prop_offset_(const void *fdt, int offset);
     25  1.1.1.2.8.1    martin const char *fdt_find_string_(const char *strtab, int tabsize, const char *s);
     26  1.1.1.2.8.1    martin int fdt_node_end_offset_(void *fdt, int nodeoffset);
     27          1.1  macallan 
     28  1.1.1.2.8.1    martin 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.2.8.1    martin static inline void *fdt_offset_ptr_w_(void *fdt, int offset)
     34          1.1  macallan {
     35  1.1.1.2.8.1    martin 	return (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset);
     36          1.1  macallan }
     37          1.1  macallan 
     38  1.1.1.2.8.1    martin 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.2.8.1    martin static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n)
     47          1.1  macallan {
     48  1.1.1.2.8.1    martin 	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.2.8.1    martin #endif /* LIBFDT_INTERNAL_H */
     54