iPXE
Data Structures | Functions | Variables
fdt.c File Reference

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_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...
 

Detailed Description

Flattened Device Tree.

Definition in file fdt.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ fdt_exists()

static int fdt_exists ( void  )
inlinestatic

Check if device tree exists.

Parameters
has_fdtDevice tree exists

Definition at line 65 of file fdt.c.

65  {
66 
67  return ( fdt.hdr != NULL );
68 }
const struct fdt_header * hdr
Tree header.
Definition: fdt.h:80
A device tree.
Definition: fdt.h:76
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References fdt::hdr, and NULL.

◆ fdt_traverse()

static int fdt_traverse ( struct fdt_cursor pos,
struct fdt_descriptor desc 
)
static

Traverse device tree.

Parameters
posPosition within device tree
descLexical descriptor to fill in
Return values
rcReturn status code

Definition at line 77 of file fdt.c.

78  {
79  const fdt_token_t *token;
80  const void *data;
81  const struct fdt_prop *prop;
82  unsigned int name_off;
83  size_t remaining;
84  size_t len;
85 
86  /* Sanity checks */
87  assert ( pos->offset < fdt.len );
88  assert ( ( pos->offset & ( FDT_STRUCTURE_ALIGN - 1 ) ) == 0 );
89 
90  /* Clear descriptor */
91  memset ( desc, 0, sizeof ( *desc ) );
92 
93  /* Locate token and calculate remaining space */
94  token = ( fdt.raw + fdt.structure + pos->offset );
95  remaining = ( fdt.len - pos->offset );
96  if ( remaining < sizeof ( *token ) ) {
97  DBGC ( &fdt, "FDT truncated tree at +%#04x\n", pos->offset );
98  return -EINVAL;
99  }
100  remaining -= sizeof ( *token );
101  data = ( ( ( const void * ) token ) + sizeof ( *token ) );
102  len = 0;
103 
104  /* Handle token */
105  switch ( *token ) {
106 
107  case cpu_to_be32 ( FDT_BEGIN_NODE ):
108 
109  /* Start of node */
110  desc->name = data;
111  len = ( strnlen ( desc->name, remaining ) + 1 /* NUL */ );
112  if ( remaining < len ) {
113  DBGC ( &fdt, "FDT unterminated node name at +%#04x\n",
114  pos->offset );
115  return -EINVAL;
116  }
117  pos->depth++;
118  break;
119 
120  case cpu_to_be32 ( FDT_END_NODE ):
121 
122  /* End of node */
123  if ( pos->depth < 0 ) {
124  DBGC ( &fdt, "FDT spurious node end at +%#04x\n",
125  pos->offset );
126  return -EINVAL;
127  }
128  pos->depth--;
129  if ( pos->depth < 0 ) {
130  /* End of (sub)tree */
131  return -ENOENT;
132  }
133  break;
134 
135  case cpu_to_be32 ( FDT_PROP ):
136 
137  /* Property */
138  prop = data;
139  if ( remaining < sizeof ( *prop ) ) {
140  DBGC ( &fdt, "FDT truncated property at +%#04x\n",
141  pos->offset );
142  return -EINVAL;
143  }
144  desc->data = ( ( ( const void * ) prop ) + sizeof ( *prop ) );
145  desc->len = be32_to_cpu ( prop->len );
146  len = ( sizeof ( *prop ) + desc->len );
147  if ( remaining < len ) {
148  DBGC ( &fdt, "FDT overlength property at +%#04x\n",
149  pos->offset );
150  return -EINVAL;
151  }
152  name_off = be32_to_cpu ( prop->name_off );
153  if ( name_off > fdt.strings_len ) {
154  DBGC ( &fdt, "FDT property name outside strings "
155  "block at +%#04x\n", pos->offset );
156  return -EINVAL;
157  }
158  desc->name = ( fdt.raw + fdt.strings + name_off );
159  break;
160 
161  case cpu_to_be32 ( FDT_NOP ):
162 
163  /* Do nothing */
164  break;
165 
166  default:
167 
168  /* Unrecognised or unexpected token */
169  DBGC ( &fdt, "FDT unexpected token %#08x at +%#04x\n",
170  be32_to_cpu ( *token ), pos->offset );
171  return -EINVAL;
172  }
173 
174  /* Update cursor */
175  len = ( ( len + FDT_STRUCTURE_ALIGN - 1 ) &
176  ~( FDT_STRUCTURE_ALIGN - 1 ) );
177  pos->offset += ( sizeof ( *token ) + len );
178 
179  /* Sanity checks */
180  assert ( pos->offset <= fdt.len );
181 
182  return 0;
183 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
uint32_t name_off
Name offset.
Definition: fdt.h:51
const char * name
Definition: ath9k_hw.c:1984
const char * name
Node or property name (if applicable)
Definition: fdt.c:53
#define FDT_STRUCTURE_ALIGN
Alignment of structure block.
Definition: fdt.h:73
unsigned int offset
Offset within structure block.
Definition: fdt.c:45
#define FDT_NOP
NOP token.
Definition: fdt.h:67
size_t len
Length of tree.
Definition: fdt.h:85
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
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 len
Data length.
Definition: fdt.h:61
#define be32_to_cpu(value)
Definition: byteswap.h:116
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
size_t len
Length of property data (if applicable)
Definition: fdt.c:57
unsigned int structure
Offset to structure block.
Definition: fdt.h:87
Property fragment.
Definition: fdt.h:59
size_t strnlen(const char *src, size_t max)
Get length of string.
Definition: string.c:240
u8 token
Definition: CIB_PRM.h:42
#define FDT_PROP
Property token.
Definition: fdt.h:56
int depth
Tree depth.
Definition: fdt.c:47
#define cpu_to_be32(value)
Definition: byteswap.h:110
A device tree.
Definition: fdt.h:76
uint32_t len
Length.
Definition: ena.h:14
uint32_t name_off
Name offset.
Definition: fdt.h:63
const void * raw
Raw data.
Definition: fdt.h:82
#define FDT_END_NODE
End node token.
Definition: fdt.h:53
#define FDT_BEGIN_NODE
Begin node token.
Definition: fdt.h:50
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
const void * data
Property data (if applicable)
Definition: fdt.c:55
unsigned int strings
Offset to strings block.
Definition: fdt.h:91
if(natsemi->flags &NATSEMI_64BIT) return 1
void * memset(void *dest, int character, size_t len) __nonnull

References assert(), be32_to_cpu, cpu_to_be32, data, fdt_descriptor::data, DBGC, fdt_cursor::depth, EINVAL, ENOENT, FDT_BEGIN_NODE, FDT_END_NODE, FDT_NOP, FDT_PROP, FDT_STRUCTURE_ALIGN, len, fdt_descriptor::len, fdt_prop::len, fdt::len, memset(), fdt_descriptor::name, 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().

◆ fdt_child()

static int fdt_child ( unsigned int  offset,
const char *  name,
unsigned int *  child 
)
static

Find child node.

Parameters
offsetStarting node offset
nameNode name
childChild node offset to fill in
Return values
rcReturn status code

Definition at line 193 of file fdt.c.

194  {
195  struct fdt_cursor pos;
196  struct fdt_descriptor desc;
197  unsigned int orig_offset;
198  int rc;
199 
200  /* Record original offset (for debugging) */
201  orig_offset = offset;
202 
203  /* Initialise cursor */
204  pos.offset = offset;
205  pos.depth = -1;
206 
207  /* Find child node */
208  while ( 1 ) {
209 
210  /* Record current offset */
211  *child = pos.offset;
212 
213  /* Traverse tree */
214  if ( ( rc = fdt_traverse ( &pos, &desc ) ) != 0 ) {
215  DBGC ( &fdt, "FDT +%#04x has no child node \"%s\": "
216  "%s\n", orig_offset, name, strerror ( rc ) );
217  return rc;
218  }
219 
220  /* Check for matching immediate child node */
221  if ( ( pos.depth == 1 ) && desc.name && ( ! desc.data ) ) {
222  DBGC2 ( &fdt, "FDT +%#04x has child node \"%s\"\n",
223  orig_offset, desc.name );
224  if ( strcmp ( name, desc.name ) == 0 ) {
225  DBGC2 ( &fdt, "FDT +%#04x found child node "
226  "\"%s\" at +%#04x\n", orig_offset,
227  desc.name, *child );
228  return 0;
229  }
230  }
231  }
232 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
#define DBGC(...)
Definition: compiler.h:505
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A position within a device tree.
Definition: fdt.c:43
static int fdt_traverse(struct fdt_cursor *pos, struct fdt_descriptor *desc)
Traverse device tree.
Definition: fdt.c:77
A device tree.
Definition: fdt.h:76
#define DBGC2(...)
Definition: compiler.h:522
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:172
A lexical descriptor.
Definition: fdt.c:51

References fdt_descriptor::data, DBGC, DBGC2, fdt_cursor::depth, fdt_traverse(), fdt_descriptor::name, name, fdt_cursor::offset, offset, rc, strcmp(), and strerror().

Referenced by fdt_alias(), and fdt_path().

◆ fdt_path()

int fdt_path ( const char *  path,
unsigned int *  offset 
)

Find node by path.

Parameters
pathNode path
offsetOffset to fill in
Return values
rcReturn status code

Definition at line 241 of file fdt.c.

241  {
242  char *tmp = ( ( char * ) path );
243  char *del;
244  int rc;
245 
246  /* Initialise offset */
247  *offset = 0;
248 
249  /* Traverse tree one path segment at a time */
250  while ( *tmp ) {
251 
252  /* Skip any leading '/' */
253  while ( *tmp == '/' )
254  tmp++;
255 
256  /* Find next '/' delimiter and convert to NUL */
257  del = strchr ( tmp, '/' );
258  if ( del )
259  *del = '\0';
260 
261  /* Find child and restore delimiter */
262  rc = fdt_child ( *offset, tmp, offset );
263  if ( del )
264  *del = '/';
265  if ( rc != 0 )
266  return rc;
267 
268  /* Move to next path component, if any */
269  while ( *tmp && ( *tmp != '/' ) )
270  tmp++;
271  }
272 
273  DBGC2 ( &fdt, "FDT found path \"%s\" at +%#04x\n", path, *offset );
274  return 0;
275 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
char * strchr(const char *src, int character)
Find character within a string.
Definition: string.c:256
uint8_t * tmp
Definition: entropy.h:156
static int fdt_child(unsigned int offset, const char *name, unsigned int *child)
Find child node.
Definition: fdt.c:193
A device tree.
Definition: fdt.h:76
#define DBGC2(...)
Definition: compiler.h:522

References DBGC2, fdt_child(), offset, rc, strchr(), and tmp.

Referenced by fdt_alias().

◆ fdt_alias()

int fdt_alias ( const char *  name,
unsigned int *  offset 
)

Find node by alias.

Parameters
nameAlias name
offsetOffset to fill in
Return values
rcReturn status code

Definition at line 284 of file fdt.c.

284  {
285  const char *alias;
286  int rc;
287 
288  /* Locate "/aliases" node */
289  if ( ( rc = fdt_child ( 0, "aliases", offset ) ) != 0 )
290  return rc;
291 
292  /* Locate alias property */
293  if ( ( alias = fdt_string ( *offset, name ) ) == NULL )
294  return -ENOENT;
295  DBGC ( &fdt, "FDT alias \"%s\" is \"%s\"\n", name, alias );
296 
297  /* Locate aliased node */
298  if ( ( rc = fdt_path ( alias, offset ) ) != 0 )
299  return rc;
300 
301  return 0;
302 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
int fdt_path(const char *path, unsigned int *offset)
Find node by path.
Definition: fdt.c:241
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
const char * fdt_string(unsigned int offset, const char *name)
Find string property.
Definition: fdt.c:352
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
static int fdt_child(unsigned int offset, const char *name, unsigned int *child)
Find child node.
Definition: fdt.c:193
A device tree.
Definition: fdt.h:76
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References DBGC, ENOENT, fdt_child(), fdt_path(), fdt_string(), name, NULL, offset, and rc.

Referenced by smscusb_fdt_fetch_mac().

◆ fdt_property()

static int fdt_property ( unsigned int  offset,
const char *  name,
struct fdt_descriptor desc 
)
static

Find property.

Parameters
offsetStarting node offset
nameProperty name
descLexical descriptor to fill in
Return values
rcReturn status code

Definition at line 312 of file fdt.c.

313  {
314  struct fdt_cursor pos;
315  int rc;
316 
317  /* Initialise cursor */
318  pos.offset = offset;
319  pos.depth = -1;
320 
321  /* Find property */
322  while ( 1 ) {
323 
324  /* Traverse tree */
325  if ( ( rc = fdt_traverse ( &pos, desc ) ) != 0 ) {
326  DBGC ( &fdt, "FDT +%#04x has no property \"%s\": %s\n",
327  offset, name, strerror ( rc ) );
328  return rc;
329  }
330 
331  /* Check for matching immediate child property */
332  if ( ( pos.depth == 0 ) && desc->data ) {
333  DBGC2 ( &fdt, "FDT +%#04x has property \"%s\" len "
334  "%#zx\n", offset, desc->name, desc->len );
335  if ( strcmp ( name, desc->name ) == 0 ) {
336  DBGC2 ( &fdt, "FDT +%#04x found property "
337  "\"%s\"\n", offset, desc->name );
338  DBGC2_HDA ( &fdt, 0, desc->data, desc->len );
339  return 0;
340  }
341  }
342  }
343 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
const char * name
Node or property name (if applicable)
Definition: fdt.c:53
#define DBGC(...)
Definition: compiler.h:505
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
size_t len
Length of property data (if applicable)
Definition: fdt.c:57
#define DBGC2_HDA(...)
Definition: compiler.h:523
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A position within a device tree.
Definition: fdt.c:43
static int fdt_traverse(struct fdt_cursor *pos, struct fdt_descriptor *desc)
Traverse device tree.
Definition: fdt.c:77
A device tree.
Definition: fdt.h:76
#define DBGC2(...)
Definition: compiler.h:522
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:172
const void * data
Property data (if applicable)
Definition: fdt.c:55

References fdt_descriptor::data, DBGC, DBGC2, DBGC2_HDA, fdt_cursor::depth, fdt_traverse(), fdt_descriptor::len, fdt_descriptor::name, name, fdt_cursor::offset, offset, rc, strcmp(), and strerror().

Referenced by fdt_mac(), and fdt_string().

◆ fdt_string()

const char* fdt_string ( unsigned int  offset,
const char *  name 
)

Find string property.

Parameters
offsetStarting node offset
nameProperty name
Return values
stringString property, or NULL on error

Definition at line 352 of file fdt.c.

352  {
353  struct fdt_descriptor desc;
354  int rc;
355 
356  /* Find property */
357  if ( ( rc = fdt_property ( offset, name, &desc ) ) != 0 )
358  return NULL;
359 
360  /* Check NUL termination */
361  if ( strnlen ( desc.data, desc.len ) == desc.len ) {
362  DBGC ( &fdt, "FDT unterminated string property \"%s\"\n",
363  name );
364  return NULL;
365  }
366 
367  return desc.data;
368 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
#define DBGC(...)
Definition: compiler.h:505
static int fdt_property(unsigned int offset, const char *name, struct fdt_descriptor *desc)
Find property.
Definition: fdt.c:312
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
size_t strnlen(const char *src, size_t max)
Get length of string.
Definition: string.c:240
A device tree.
Definition: fdt.h:76
A lexical descriptor.
Definition: fdt.c:51
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References fdt_descriptor::data, DBGC, fdt_property(), fdt_descriptor::len, name, NULL, offset, rc, and strnlen().

Referenced by fdt_alias(), and register_fdt().

◆ fdt_mac()

int fdt_mac ( unsigned int  offset,
struct net_device netdev 
)

Get MAC address from property.

Parameters
offsetStarting node offset
netdevNetwork device
Return values
rcReturn status code

Definition at line 377 of file fdt.c.

377  {
378  struct fdt_descriptor desc;
379  size_t len;
380  int rc;
381 
382  /* Find applicable MAC address property */
383  if ( ( ( rc = fdt_property ( offset, "mac-address", &desc ) ) != 0 ) &&
384  ( ( rc = fdt_property ( offset, "local-mac-address",
385  &desc ) ) != 0 ) ) {
386  return rc;
387  }
388 
389  /* Check length */
391  if ( len != desc.len ) {
392  DBGC ( &fdt, "FDT malformed MAC address \"%s\":\n",
393  desc.name );
394  DBGC_HDA ( &fdt, 0, desc.data, desc.len );
395  return -ERANGE;
396  }
397 
398  /* Fill in MAC address */
399  memcpy ( netdev->hw_addr, desc.data, len );
400 
401  return 0;
402 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
size_t len
Length of tree.
Definition: fdt.h:85
#define DBGC(...)
Definition: compiler.h:505
static int fdt_property(unsigned int offset, const char *name, struct fdt_descriptor *desc)
Find property.
Definition: fdt.c:312
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t hw_addr_len
Hardware address length.
Definition: netdevice.h:196
#define DBGC_HDA(...)
Definition: compiler.h:506
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
#define ERANGE
Result too large.
Definition: errno.h:639
A device tree.
Definition: fdt.h:76
uint32_t len
Length.
Definition: ena.h:14
A lexical descriptor.
Definition: fdt.c:51
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366

References fdt_descriptor::data, DBGC, DBGC_HDA, ERANGE, fdt_property(), net_device::hw_addr, ll_protocol::hw_addr_len, len, fdt_descriptor::len, net_device::ll_protocol, memcpy(), fdt_descriptor::name, netdev, offset, and rc.

Referenced by smscusb_fdt_fetch_mac().

◆ register_fdt()

int register_fdt ( const struct fdt_header hdr)

Register device tree.

Parameters
fdtDevice tree header
Return values
rcReturn status code

Definition at line 410 of file fdt.c.

410  {
411  const uint8_t *end;
412 
413  /* Record device tree location */
414  fdt.hdr = hdr;
415  fdt.len = be32_to_cpu ( hdr->totalsize );
416  DBGC ( &fdt, "FDT version %d at %p+%#04zx\n",
417  be32_to_cpu ( hdr->version ), fdt.hdr, fdt.len );
418 
419  /* Check signature */
420  if ( hdr->magic != cpu_to_be32 ( FDT_MAGIC ) ) {
421  DBGC ( &fdt, "FDT has invalid magic value %#08x\n",
422  be32_to_cpu ( hdr->magic ) );
423  goto err;
424  }
425 
426  /* Check version */
427  if ( hdr->last_comp_version != cpu_to_be32 ( FDT_VERSION ) ) {
428  DBGC ( &fdt, "FDT unsupported version %d\n",
429  be32_to_cpu ( hdr->last_comp_version ) );
430  goto err;
431  }
432 
433  /* Record structure block location */
434  fdt.structure = be32_to_cpu ( hdr->off_dt_struct );
435  fdt.structure_len = be32_to_cpu ( hdr->size_dt_struct );
436  DBGC ( &fdt, "FDT structure block at +[%#04x,%#04zx)\n",
438  if ( ( fdt.structure > fdt.len ) ||
439  ( fdt.structure_len > ( fdt.len - fdt.structure ) ) ) {
440  DBGC ( &fdt, "FDT structure block exceeds table\n" );
441  goto err;
442  }
443  if ( ( fdt.structure | fdt.structure_len ) &
444  ( FDT_STRUCTURE_ALIGN - 1 ) ) {
445  DBGC ( &fdt, "FDT structure block is misaligned\n" );
446  goto err;
447  }
448 
449  /* Record strings block location */
450  fdt.strings = be32_to_cpu ( hdr->off_dt_strings );
451  fdt.strings_len = be32_to_cpu ( hdr->size_dt_strings );
452  DBGC ( &fdt, "FDT strings block at +[%#04x,%#04zx)\n",
454  if ( ( fdt.strings > fdt.len ) ||
455  ( fdt.strings_len > ( fdt.len - fdt.strings ) ) ) {
456  DBGC ( &fdt, "FDT strings block exceeds table\n" );
457  goto err;
458  }
459 
460  /* Shrink strings block to ensure NUL termination safety */
461  end = ( fdt.raw + fdt.strings + fdt.strings_len );
462  for ( ; fdt.strings_len ; fdt.strings_len-- ) {
463  if ( *(--end) == '\0' )
464  break;
465  }
466  if ( fdt.strings_len != be32_to_cpu ( hdr->size_dt_strings ) ) {
467  DBGC ( &fdt, "FDT strings block shrunk to +[%#04x,%#04zx)\n",
469  }
470 
471  /* Print model name (for debugging) */
472  DBGC ( &fdt, "FDT model is \"%s\"\n", fdt_string ( 0, "model" ) );
473 
474  return 0;
475 
476  err:
477  DBGC_HDA ( &fdt, 0, hdr, sizeof ( *hdr ) );
478  fdt.hdr = NULL;
479  return -EINVAL;
480 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define FDT_STRUCTURE_ALIGN
Alignment of structure block.
Definition: fdt.h:73
size_t len
Length of tree.
Definition: fdt.h:85
#define DBGC(...)
Definition: compiler.h:505
const struct fdt_header * hdr
Tree header.
Definition: fdt.h:80
size_t strings_len
Length of strings block.
Definition: fdt.h:93
const char * fdt_string(unsigned int offset, const char *name)
Find string property.
Definition: fdt.c:352
#define be32_to_cpu(value)
Definition: byteswap.h:116
#define FDT_MAGIC
Magic signature.
Definition: fdt.h:41
#define DBGC_HDA(...)
Definition: compiler.h:506
unsigned int structure
Offset to structure block.
Definition: fdt.h:87
#define FDT_VERSION
Expected device tree version.
Definition: fdt.h:44
unsigned char uint8_t
Definition: stdint.h:10
uint32_t hdr
Message header.
Definition: intelvf.h:12
size_t structure_len
Length of structure block.
Definition: fdt.h:89
#define cpu_to_be32(value)
Definition: byteswap.h:110
A device tree.
Definition: fdt.h:76
const void * raw
Raw data.
Definition: fdt.h:82
uint32_t end
Ending offset.
Definition: netvsc.h:18
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
unsigned int strings
Offset to strings block.
Definition: fdt.h:91

References be32_to_cpu, cpu_to_be32, DBGC, DBGC_HDA, EINVAL, end, FDT_MAGIC, fdt_string(), FDT_STRUCTURE_ALIGN, FDT_VERSION, hdr, fdt::hdr, fdt::len, NULL, fdt::raw, fdt::strings, fdt::strings_len, fdt::structure, and fdt::structure_len.

Referenced by efi_fdt_init().

◆ REQUIRING_SYMBOL()

REQUIRING_SYMBOL ( register_fdt  )

◆ REQUIRE_OBJECT()

REQUIRE_OBJECT ( config_fdt  )

Variable Documentation

◆ fdt

struct fdt fdt
static

The system flattened device tree (if present)

Definition at line 40 of file fdt.c.