iPXE
fdt.h
Go to the documentation of this file.
00001 #ifndef _IPXE_FDT_H
00002 #define _IPXE_FDT_H
00003 
00004 /** @file
00005  *
00006  * Flattened Device Tree
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 
00014 struct net_device;
00015 
00016 /** Device tree header */
00017 struct fdt_header {
00018         /** Magic signature */
00019         uint32_t magic;
00020         /** Total size of device tree */
00021         uint32_t totalsize;
00022         /** Offset to structure block */
00023         uint32_t off_dt_struct;
00024         /** Offset to strings block */
00025         uint32_t off_dt_strings;
00026         /** Offset to memory reservation block */
00027         uint32_t off_mem_rsvmap;
00028         /** Version of this data structure */
00029         uint32_t version;
00030         /** Lowest version to which this structure is compatible */
00031         uint32_t last_comp_version;
00032         /** Physical ID of the boot CPU */
00033         uint32_t boot_cpuid_phys;
00034         /** Length of string block */
00035         uint32_t size_dt_strings;
00036         /** Length of structure block */
00037         uint32_t size_dt_struct;
00038 } __attribute__ (( packed ));
00039 
00040 /** Magic signature */
00041 #define FDT_MAGIC 0xd00dfeed
00042 
00043 /** Expected device tree version */
00044 #define FDT_VERSION 16
00045 
00046 /** Device tree token */
00047 typedef uint32_t fdt_token_t;
00048 
00049 /** Begin node token */
00050 #define FDT_BEGIN_NODE 0x00000001
00051 
00052 /** End node token */
00053 #define FDT_END_NODE 0x00000002
00054 
00055 /** Property token */
00056 #define FDT_PROP 0x00000003
00057 
00058 /** Property fragment */
00059 struct fdt_prop {
00060         /** Data length */
00061         uint32_t len;
00062         /** Name offset */
00063         uint32_t name_off;
00064 } __attribute__ (( packed ));
00065 
00066 /** NOP token */
00067 #define FDT_NOP 0x00000004
00068 
00069 /** End of structure block */
00070 #define FDT_END 0x00000009
00071 
00072 /** Alignment of structure block */
00073 #define FDT_STRUCTURE_ALIGN ( sizeof ( fdt_token_t ) )
00074 
00075 /** A device tree */
00076 struct fdt {
00077         /** Tree data */
00078         union {
00079                 /** Tree header */
00080                 const struct fdt_header *hdr;
00081                 /** Raw data */
00082                 const void *raw;
00083         };
00084         /** Length of tree */
00085         size_t len;
00086         /** Offset to structure block */
00087         unsigned int structure;
00088         /** Length of structure block */
00089         size_t structure_len;
00090         /** Offset to strings block */
00091         unsigned int strings;
00092         /** Length of strings block */
00093         size_t strings_len;
00094 };
00095 
00096 extern int fdt_path ( const char *path, unsigned int *offset );
00097 extern int fdt_alias ( const char *name, unsigned int *offset );
00098 extern const char * fdt_string ( unsigned int offset, const char *name );
00099 extern int fdt_mac ( unsigned int offset, struct net_device *netdev );
00100 extern int register_fdt ( const struct fdt_header *hdr );
00101 
00102 #endif /* _IPXE_FDT_H */