libfdt_internal.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.
  6. * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause
  7. */
  8. #include <fdt.h>
  9. #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
  10. #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
  11. #define FDT_CHECK_HEADER(fdt) \
  12. { \
  13. int err; \
  14. if ((err = fdt_check_header(fdt)) != 0) \
  15. return err; \
  16. }
  17. int _fdt_check_node_offset(const void *fdt, int offset);
  18. int _fdt_check_prop_offset(const void *fdt, int offset);
  19. const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
  20. int _fdt_node_end_offset(void *fdt, int nodeoffset);
  21. static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
  22. {
  23. return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
  24. }
  25. static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
  26. {
  27. return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);
  28. }
  29. static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
  30. {
  31. const struct fdt_reserve_entry *rsv_table =
  32. (const struct fdt_reserve_entry *)
  33. ((const char *)fdt + fdt_off_mem_rsvmap(fdt));
  34. return rsv_table + n;
  35. }
  36. static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
  37. {
  38. return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
  39. }
  40. #define FDT_SW_MAGIC (~FDT_MAGIC)
  41. #endif /* _LIBFDT_INTERNAL_H */