You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fdt.h 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef _IPXE_FDT_H
  2. #define _IPXE_FDT_H
  3. /** @file
  4. *
  5. * Flattened Device Tree
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. struct net_device;
  11. /** Device tree header */
  12. struct fdt_header {
  13. /** Magic signature */
  14. uint32_t magic;
  15. /** Total size of device tree */
  16. uint32_t totalsize;
  17. /** Offset to structure block */
  18. uint32_t off_dt_struct;
  19. /** Offset to strings block */
  20. uint32_t off_dt_strings;
  21. /** Offset to memory reservation block */
  22. uint32_t off_mem_rsvmap;
  23. /** Version of this data structure */
  24. uint32_t version;
  25. /** Lowest version to which this structure is compatible */
  26. uint32_t last_comp_version;
  27. /** Physical ID of the boot CPU */
  28. uint32_t boot_cpuid_phys;
  29. /** Length of string block */
  30. uint32_t size_dt_strings;
  31. /** Length of structure block */
  32. uint32_t size_dt_struct;
  33. } __attribute__ (( packed ));
  34. /** Magic signature */
  35. #define FDT_MAGIC 0xd00dfeed
  36. /** Expected device tree version */
  37. #define FDT_VERSION 16
  38. /** Device tree token */
  39. typedef uint32_t fdt_token_t;
  40. /** Begin node token */
  41. #define FDT_BEGIN_NODE 0x00000001
  42. /** End node token */
  43. #define FDT_END_NODE 0x00000002
  44. /** Property token */
  45. #define FDT_PROP 0x00000003
  46. /** Property fragment */
  47. struct fdt_prop {
  48. /** Data length */
  49. uint32_t len;
  50. /** Name offset */
  51. uint32_t name_off;
  52. } __attribute__ (( packed ));
  53. /** NOP token */
  54. #define FDT_NOP 0x00000004
  55. /** End of structure block */
  56. #define FDT_END 0x00000009
  57. /** Alignment of structure block */
  58. #define FDT_STRUCTURE_ALIGN ( sizeof ( fdt_token_t ) )
  59. /** A device tree */
  60. struct fdt {
  61. /** Tree data */
  62. union {
  63. /** Tree header */
  64. const struct fdt_header *hdr;
  65. /** Raw data */
  66. const void *raw;
  67. };
  68. /** Length of tree */
  69. size_t len;
  70. /** Offset to structure block */
  71. unsigned int structure;
  72. /** Length of structure block */
  73. size_t structure_len;
  74. /** Offset to strings block */
  75. unsigned int strings;
  76. /** Length of strings block */
  77. size_t strings_len;
  78. };
  79. extern int fdt_path ( const char *path, unsigned int *offset );
  80. extern int fdt_alias ( const char *name, unsigned int *offset );
  81. extern const char * fdt_string ( unsigned int offset, const char *name );
  82. extern int fdt_mac ( unsigned int offset, struct net_device *netdev );
  83. extern int register_fdt ( const struct fdt_header *hdr );
  84. #endif /* _IPXE_FDT_H */