iPXE
fdt.h
Go to the documentation of this file.
1 #ifndef _IPXE_FDT_H
2 #define _IPXE_FDT_H
3 
4 /** @file
5  *
6  * Flattened Device Tree
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 
14 struct net_device;
15 
16 /** Device tree header */
17 struct fdt_header {
18  /** Magic signature */
20  /** Total size of device tree */
22  /** Offset to structure block */
24  /** Offset to strings block */
26  /** Offset to memory reservation block */
28  /** Version of this data structure */
30  /** Lowest version to which this structure is compatible */
32  /** Physical ID of the boot CPU */
34  /** Length of string block */
36  /** Length of structure block */
38 } __attribute__ (( packed ));
39 
40 /** Magic signature */
41 #define FDT_MAGIC 0xd00dfeed
42 
43 /** Expected device tree version */
44 #define FDT_VERSION 16
45 
46 /** Device tree token */
48 
49 /** Begin node token */
50 #define FDT_BEGIN_NODE 0x00000001
51 
52 /** End node token */
53 #define FDT_END_NODE 0x00000002
54 
55 /** Property token */
56 #define FDT_PROP 0x00000003
57 
58 /** Property fragment */
59 struct fdt_prop {
60  /** Data length */
62  /** Name offset */
64 } __attribute__ (( packed ));
65 
66 /** NOP token */
67 #define FDT_NOP 0x00000004
68 
69 /** End of structure block */
70 #define FDT_END 0x00000009
71 
72 /** Alignment of structure block */
73 #define FDT_STRUCTURE_ALIGN ( sizeof ( fdt_token_t ) )
74 
75 /** A device tree */
76 struct fdt {
77  /** Tree data */
78  union {
79  /** Tree header */
80  const struct fdt_header *hdr;
81  /** Raw data */
82  const void *raw;
83  };
84  /** Length of tree */
85  size_t len;
86  /** Offset to structure block */
87  unsigned int structure;
88  /** Length of structure block */
89  size_t structure_len;
90  /** Offset to strings block */
91  unsigned int strings;
92  /** Length of strings block */
93  size_t strings_len;
94 };
95 
96 extern int fdt_path ( const char *path, unsigned int *offset );
97 extern int fdt_alias ( const char *name, unsigned int *offset );
98 extern const char * fdt_string ( unsigned int offset, const char *name );
99 extern int fdt_mac ( unsigned int offset, struct net_device *netdev );
100 extern int register_fdt ( const struct fdt_header *hdr );
101 
102 #endif /* _IPXE_FDT_H */
int fdt_mac(unsigned int offset, struct net_device *netdev)
Get MAC address from property.
Definition: fdt.c:377
const char * name
Definition: ath9k_hw.c:1984
size_t len
Length of tree.
Definition: fdt.h:85
Device tree header.
Definition: fdt.h:17
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
const struct fdt_header * hdr
Tree header.
Definition: fdt.h:80
size_t strings_len
Length of strings block.
Definition: fdt.h:93
uint32_t fdt_token_t
Device tree token.
Definition: fdt.h:47
uint32_t off_dt_struct
Offset to structure block.
Definition: fdt.h:23
uint32_t len
Data length.
Definition: fdt.h:61
uint32_t magic
Magic signature.
Definition: fdt.h:19
uint32_t version
Version of this data structure.
Definition: fdt.h:29
int fdt_alias(const char *name, unsigned int *offset)
Find node by alias.
Definition: fdt.c:284
uint32_t off_dt_strings
Offset to strings block.
Definition: fdt.h:25
struct fdt __attribute__
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
static struct net_device * netdev
Definition: gdbudp.c:52
uint32_t last_comp_version
Lowest version to which this structure is compatible.
Definition: fdt.h:31
unsigned int structure
Offset to structure block.
Definition: fdt.h:87
uint32_t size_dt_strings
Length of string block.
Definition: fdt.h:35
Property fragment.
Definition: fdt.h:59
A network device.
Definition: netdevice.h:348
int fdt_path(const char *path, unsigned int *offset)
Find node by path.
Definition: fdt.c:241
uint32_t off_mem_rsvmap
Offset to memory reservation block.
Definition: fdt.h:27
unsigned int uint32_t
Definition: stdint.h:12
uint32_t hdr
Message header.
Definition: intelvf.h:12
size_t structure_len
Length of structure block.
Definition: fdt.h:89
uint32_t boot_cpuid_phys
Physical ID of the boot CPU.
Definition: fdt.h:33
A device tree.
Definition: fdt.h:76
uint32_t size_dt_struct
Length of structure block.
Definition: fdt.h:37
uint32_t totalsize
Total size of device tree.
Definition: fdt.h:21
uint32_t name_off
Name offset.
Definition: fdt.h:63
const char * fdt_string(unsigned int offset, const char *name)
Find string property.
Definition: fdt.c:352
const void * raw
Raw data.
Definition: fdt.h:82
int register_fdt(const struct fdt_header *hdr)
Register device tree.
Definition: fdt.c:410
unsigned int strings
Offset to strings block.
Definition: fdt.h:91