iPXE
|
Flattened Device Tree. More...
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/fdt.h>
Go to the source code of this file.
Data Structures | |
struct | fdt_cursor |
A position within a device tree. More... | |
struct | fdt_descriptor |
A lexical descriptor. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | fdt_exists (void) |
Check if device tree exists. More... | |
static int | fdt_traverse (struct fdt_cursor *pos, struct fdt_descriptor *desc) |
Traverse device tree. More... | |
static int | fdt_child (unsigned int offset, const char *name, unsigned int *child) |
Find child node. More... | |
int | fdt_path (const char *path, unsigned int *offset) |
Find node by path. More... | |
int | fdt_alias (const char *name, unsigned int *offset) |
Find node by alias. More... | |
static int | fdt_property (unsigned int offset, const char *name, struct fdt_descriptor *desc) |
Find property. More... | |
const char * | fdt_string (unsigned int offset, const char *name) |
Find string property. More... | |
int | fdt_u64 (unsigned int offset, const char *name, uint64_t *value) |
Find integer property. More... | |
int | fdt_mac (unsigned int offset, struct net_device *netdev) |
Get MAC address from property. More... | |
int | register_fdt (const struct fdt_header *hdr) |
Register device tree. More... | |
REQUIRING_SYMBOL (register_fdt) | |
REQUIRE_OBJECT (config_fdt) | |
Variables | |
static struct fdt | fdt |
The system flattened device tree (if present) More... | |
Flattened Device Tree.
Definition in file fdt.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
|
static |
Traverse device tree.
pos | Position within device tree |
desc | Lexical descriptor to fill in |
rc | Return status code |
Definition at line 77 of file fdt.c.
References assert(), be32_to_cpu, cpu_to_be32, data, DBGC, fdt_cursor::depth, desc, EINVAL, ENOENT, FDT_BEGIN_NODE, FDT_END_NODE, FDT_NOP, FDT_PROP, FDT_STRUCTURE_ALIGN, len, fdt_prop::len, fdt::len, memset(), name_off, fdt_prop::name_off, fdt_cursor::offset, fdt::raw, fdt::strings, fdt::strings_len, strnlen(), fdt::structure, and token.
Referenced by fdt_child(), and fdt_property().
|
static |
Find child node.
offset | Starting node offset |
name | Node name |
child | Child node offset to fill in |
rc | Return status code |
Definition at line 193 of file fdt.c.
References DBGC, DBGC2, fdt_cursor::depth, desc, fdt_traverse(), name, offset, fdt_cursor::offset, rc, strcmp(), and strerror().
Referenced by fdt_alias(), and fdt_path().
int fdt_path | ( | const char * | path, |
unsigned int * | offset | ||
) |
Find node by path.
path | Node path |
offset | Offset to fill in |
rc | Return status code |
Definition at line 241 of file fdt.c.
References DBGC2, fdt_child(), offset, rc, strchr(), and tmp.
Referenced by fdt_alias().
int fdt_alias | ( | const char * | name, |
unsigned int * | offset | ||
) |
Find node by alias.
name | Alias name |
offset | Offset to fill in |
rc | Return status code |
Definition at line 284 of file fdt.c.
References DBGC, ENOENT, fdt_child(), fdt_path(), fdt_string(), name, NULL, offset, and rc.
Referenced by smscusb_fdt_fetch_mac().
|
static |
Find property.
offset | Starting node offset |
name | Property name |
desc | Lexical descriptor to fill in |
rc | Return status code |
Definition at line 312 of file fdt.c.
References DBGC, DBGC2, DBGC2_HDA, fdt_cursor::depth, desc, fdt_traverse(), name, offset, fdt_cursor::offset, rc, strcmp(), and strerror().
Referenced by fdt_mac(), fdt_string(), and fdt_u64().
const char* fdt_string | ( | unsigned int | offset, |
const char * | name | ||
) |
Find string property.
offset | Starting node offset |
name | Property name |
string | String property, or NULL on error |
Definition at line 352 of file fdt.c.
References DBGC, desc, fdt_property(), name, NULL, offset, rc, and strnlen().
Referenced by fdt_alias(), and register_fdt().
int fdt_u64 | ( | unsigned int | offset, |
const char * | name, | ||
uint64_t * | value | ||
) |
Find integer property.
offset | Starting node offset |
name | Property name |
value | Integer value to fill in |
rc | Return status code |
Definition at line 378 of file fdt.c.
References data, DBGC, desc, ERANGE, fdt_property(), name, offset, rc, and value.
int fdt_mac | ( | unsigned int | offset, |
struct net_device * | netdev | ||
) |
Get MAC address from property.
offset | Starting node offset |
netdev | Network device |
rc | Return status code |
Definition at line 415 of file fdt.c.
References DBGC, DBGC_HDA, desc, ERANGE, fdt_property(), net_device::hw_addr, ll_protocol::hw_addr_len, len, net_device::ll_protocol, memcpy(), netdev, offset, and rc.
Referenced by smscusb_fdt_fetch_mac().
int register_fdt | ( | const struct fdt_header * | hdr | ) |
Register device tree.
fdt | Device tree header |
rc | Return status code |
Definition at line 448 of file fdt.c.
References be32_to_cpu, cpu_to_be32, DBGC, DBGC_HDA, EINVAL, end, FDT_MAGIC, fdt_string(), FDT_STRUCTURE_ALIGN, FDT_VERSION, fdt::hdr, hdr, fdt::len, NULL, fdt::raw, fdt::strings, fdt::strings_len, fdt::structure, and fdt::structure_len.
Referenced by efi_fdt_init().
REQUIRING_SYMBOL | ( | register_fdt | ) |
REQUIRE_OBJECT | ( | config_fdt | ) |