ofw_internal.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-08-25 GuEe-GUI first version
  9. */
  10. #ifndef __OFW_INTERNAL_H__
  11. #define __OFW_INTERNAL_H__
  12. #include <rtthread.h>
  13. #include <posix/string.h>
  14. #include <drivers/ofw.h>
  15. #define OFW_PHANDLE_MIN 1
  16. #define OFW_PHANDLE_MAX FDT_MAX_PHANDLE
  17. #define OFW_NODE_MAX_DEPTH 64
  18. #define OFW_NODE_MIN_HASH 128
  19. #define OFW_ROOT_NODE_ADDR_CELLS_DEFAULT 1
  20. #define OFW_ROOT_NODE_SIZE_CELLS_DEFAULT 1
  21. struct fdt_info
  22. {
  23. /* Always "/", because we save "ofw" information in root node. */
  24. char name[sizeof("/")];
  25. /* Information start */
  26. void *fdt;
  27. /* Only root can use */
  28. struct fdt_reserve_entry *rsvmap;
  29. rt_size_t rsvmap_nr;
  30. };
  31. struct alias_info
  32. {
  33. rt_list_t list;
  34. int id;
  35. const char *tag;
  36. rt_size_t tag_len;
  37. struct rt_ofw_node *np;
  38. };
  39. struct bus_ranges
  40. {
  41. rt_size_t nr;
  42. struct rt_ofw_node *np;
  43. rt_uint64_t *child_addr;
  44. rt_uint64_t *parent_addr;
  45. rt_uint64_t *child_size;
  46. };
  47. extern struct rt_ofw_node *ofw_node_root;
  48. extern struct rt_ofw_node *ofw_node_cpus;
  49. extern struct rt_ofw_node *ofw_node_chosen;
  50. extern struct rt_ofw_node *ofw_node_aliases;
  51. extern struct rt_ofw_node *ofw_node_reserved_memory;
  52. extern struct rt_fdt_earlycon fdt_earlycon;
  53. #define ofw_static_cast(to_type, value) \
  54. (to_type)(((value) >> ((sizeof(value) - sizeof(to_type)) * 8)))
  55. rt_err_t ofw_alias_scan(void);
  56. int ofw_alias_node_id(struct rt_ofw_node *np);
  57. rt_err_t ofw_phandle_hash_reset(rt_phandle min, rt_phandle max);
  58. #endif /* __OFW_INTERNAL_H__ */