TianoCore EDK2 master
Loading...
Searching...
No Matches
FdtLib.c
Go to the documentation of this file.
1
9#include <libfdt/libfdt/libfdt.h>
10#include <Library/FdtLib.h>
11#include <Uefi/UefiBaseType.h>
12
21UINT16
22EFIAPI
24 IN UINT16 Value
25 )
26{
27 return fdt16_to_cpu (Value);
28}
29
38UINT16
39EFIAPI
41 IN UINT16 Value
42 )
43{
44 return cpu_to_fdt16 (Value);
45}
46
55UINT32
56EFIAPI
58 IN UINT32 Value
59 )
60{
61 return fdt32_to_cpu (Value);
62}
63
72UINT32
73EFIAPI
75 IN UINT32 Value
76 )
77{
78 return cpu_to_fdt32 (Value);
79}
80
89UINT64
90EFIAPI
92 IN UINT64 Value
93 )
94{
95 return fdt64_to_cpu (Value);
96}
97
106UINT64
107EFIAPI
109 IN UINT64 Value
110 )
111{
112 return cpu_to_fdt64 (Value);
113}
114
123INT32
124EFIAPI
126 IN CONST VOID *Fdt
127 )
128{
129 return fdt_check_header (Fdt);
130}
131
141INT32
142EFIAPI
144 IN VOID *Buffer,
145 IN UINT32 BufferSize
146 )
147{
148 return fdt_create_empty_tree (Buffer, (int)BufferSize);
149}
150
161INT32
162EFIAPI
164 IN CONST VOID *Fdt,
165 OUT VOID *Buffer,
166 IN INT32 BufferSize
167 )
168{
169 return fdt_open_into (Fdt, Buffer, BufferSize);
170}
171
179INT32
180EFIAPI
182 IN OUT VOID *Fdt
183 )
184{
185 return fdt_pack (Fdt);
186}
187
197CONST VOID *
198EFIAPI
200 IN CONST VOID *Fdt,
201 IN INT32 Offset,
202 IN UINT32 Length
203 )
204{
205 return fdt_offset_ptr (Fdt, Offset, Length);
206}
207
218INT32
219EFIAPI
221 IN CONST VOID *Fdt,
222 IN INT32 Offset,
223 IN INT32 *Depth
224 )
225{
226 return fdt_next_node (Fdt, Offset, Depth);
227}
228
238INT32
239EFIAPI
241 IN CONST VOID *Fdt,
242 IN INT32 Offset
243 )
244{
245 return fdt_first_subnode (Fdt, Offset);
246}
247
257INT32
258EFIAPI
260 IN CONST VOID *Fdt,
261 IN INT32 Offset
262 )
263{
264 return fdt_next_subnode (Fdt, Offset);
265}
266
275INTN
276EFIAPI
278 IN CONST VOID *Fdt
279 )
280{
281 return fdt_num_mem_rsv (Fdt);
282}
283
295INTN
296EFIAPI
298 IN CONST VOID *Fdt,
299 IN INTN Index,
301 OUT UINT64 *Size
302 )
303{
304 return fdt_get_mem_rsv (Fdt, Index, Addr, Size);
305}
306
318INT32
319EFIAPI
321 IN CONST VOID *Fdt,
322 IN INT32 ParentOffset,
323 IN CONST CHAR8 *Name,
324 IN INT32 NameLength
325 )
326{
327 return fdt_subnode_offset_namelen (Fdt, ParentOffset, Name, NameLength);
328}
329
340INT32
341EFIAPI
343 IN CONST VOID *Fdt,
344 IN INT32 ParentOffset,
345 IN CONST CHAR8 *Name
346 )
347{
348 return fdt_subnode_offset (Fdt, ParentOffset, Name);
349}
350
359INT32
360EFIAPI
362 IN CONST VOID *Fdt,
363 IN INT32 NodeOffset
364 )
365{
366 return fdt_parent_offset (Fdt, NodeOffset);
367}
368
381INT32
382EFIAPI
384 IN CONST VOID *Fdt,
385 IN INT32 StartOffset,
386 IN CONST CHAR8 *PropertyName,
387 IN CONST VOID *PropertyValue,
388 IN INT32 PropertyLength
389 )
390{
391 return fdt_node_offset_by_prop_value (Fdt, StartOffset, PropertyName, PropertyValue, PropertyLength);
392}
393
402INT32
403EFIAPI
405 IN CONST VOID *Fdt,
406 IN UINT32 Phandle
407 )
408{
409 return fdt_node_offset_by_phandle (Fdt, Phandle);
410}
411
421INT32
422EFIAPI
424 IN CONST CHAR8 *StringList,
425 IN INT32 ListLength,
426 IN CONST CHAR8 *String
427 )
428{
429 return fdt_stringlist_contains (StringList, ListLength, String);
430}
431
445EFIAPI
447 IN CONST VOID *Fdt,
448 IN INT32 NodeOffset,
449 IN CONST CHAR8 *Name,
450 IN INT32 *Length
451 )
452{
453 return (FDT_PROPERTY *)fdt_get_property (Fdt, NodeOffset, Name, Length);
454}
455
467CONST CHAR8 *
468EFIAPI
470 IN CONST VOID *Fdt,
471 IN CONST CHAR8 *Name,
472 IN INT32 Length
473 )
474{
475 return fdt_get_alias_namelen (Fdt, Name, Length);
476}
477
487INT32
488EFIAPI
490 IN CONST VOID *Fdt,
491 IN INT32 NodeOffset
492 )
493{
494 return fdt_first_property_offset (Fdt, NodeOffset);
495}
496
506INT32
507EFIAPI
509 IN CONST VOID *Fdt,
510 IN INT32 Offset
511 )
512{
513 return fdt_next_property_offset (Fdt, Offset);
514}
515
527EFIAPI
529 IN CONST VOID *Fdt,
530 IN INT32 Offset,
531 IN INT32 *Length
532 )
533{
534 return (FDT_PROPERTY *)fdt_get_property_by_offset (Fdt, Offset, Length);
535}
536
547CONST CHAR8 *
548EFIAPI
550 IN CONST VOID *Fdt,
551 IN INT32 StrOffset,
552 IN INT32 *Length OPTIONAL
553 )
554{
555 return fdt_get_string (Fdt, StrOffset, Length);
556}
557
568INT32
569EFIAPI
571 IN VOID *Fdt,
572 IN INT32 ParentOffset,
573 IN CONST CHAR8 *Name
574 )
575{
576 return fdt_add_subnode (Fdt, ParentOffset, Name);
577}
578
591INT32
592EFIAPI
594 IN VOID *Fdt,
595 IN INT32 NodeOffset,
596 IN CONST CHAR8 *Name,
597 IN CONST VOID *Value,
598 IN UINT32 Length
599 )
600{
601 return fdt_setprop (Fdt, NodeOffset, Name, Value, (int)Length);
602}
603
615INT32
616EFIAPI
618 IN VOID *Fdt,
619 IN INT32 NodeOffset,
620 IN CONST CHAR8 *Name,
621 IN UINT64 Value
622 )
623{
624 UINT64 Tmp;
625
626 Tmp = cpu_to_fdt64 (Value);
627
628 return fdt_setprop (Fdt, NodeOffset, Name, &Tmp, sizeof (Tmp));
629}
630
643INT32
644EFIAPI
646 IN VOID *Fdt,
647 IN INT32 NodeOffset,
648 IN CONST CHAR8 *Name,
649 IN CONST VOID *Value,
650 IN UINT32 Length
651 )
652{
653 return fdt_appendprop (Fdt, NodeOffset, Name, Value, (int)Length);
654}
655
669INT32
671 IN OUT VOID *Fdt,
672 IN INT32 NodeOffset,
673 IN CONST CHAR8 *Name
674 )
675{
676 return fdt_delprop (Fdt, NodeOffset, Name);
677}
678
688INT32
689EFIAPI
691 IN CONST VOID *Fdt,
692 IN CONST CHAR8 *Path,
693 IN INT32 NameLength
694 )
695{
696 return fdt_path_offset_namelen (Fdt, Path, NameLength);
697}
698
707INT32
708EFIAPI
710 IN CONST VOID *Fdt,
711 IN CONST CHAR8 *Path
712 )
713{
714 return fdt_path_offset (Fdt, Path);
715}
716
727CONST CHAR8 *
728EFIAPI
730 IN VOID *Fdt,
731 IN INT32 NodeOffset,
732 IN INT32 *Length
733 )
734{
735 return fdt_get_name (Fdt, NodeOffset, Length);
736}
737
747INT32
748EFIAPI
750 IN CONST VOID *Fdt,
751 IN INT32 NodeOffset
752 )
753{
754 return fdt_node_depth (Fdt, NodeOffset);
755}
756
766INT32
767EFIAPI
769 IN CONST VOID *Fdt,
770 IN INT32 StartOffset,
771 IN CONST CHAR8 *Compatible
772 )
773{
774 return fdt_node_offset_by_compatible (Fdt, StartOffset, Compatible);
775}
776
785INT32
786EFIAPI
788 IN CONST VOID *Fdt,
789 IN INT32 NodeOffset
790 )
791{
792 return fdt_address_cells (Fdt, NodeOffset);
793}
794
803INT32
804EFIAPI
806 IN CONST VOID *Fdt,
807 IN INT32 NodeOffset
808 )
809{
810 return fdt_size_cells (Fdt, NodeOffset);
811}
812
813/* Debug functions. */
814CONST
815CHAR8
816*
817FdtStrerror (
818 IN INT32 ErrVal
819 )
820{
821 return fdt_strerror (ErrVal);
822}
INT64 INTN
INT32 EFIAPI FdtNodeDepth(IN CONST VOID *Fdt, IN INT32 NodeOffset)
Definition: FdtLib.c:749
INT32 FdtDelProp(IN OUT VOID *Fdt, IN INT32 NodeOffset, IN CONST CHAR8 *Name)
Definition: FdtLib.c:670
INT32 EFIAPI FdtAppendProp(IN VOID *Fdt, IN INT32 NodeOffset, IN CONST CHAR8 *Name, IN CONST VOID *Value, IN UINT32 Length)
Definition: FdtLib.c:645
UINT64 EFIAPI CpuToFdt64(IN UINT64 Value)
Definition: FdtLib.c:108
INT32 EFIAPI FdtStringListContains(IN CONST CHAR8 *StringList, IN INT32 ListLength, IN CONST CHAR8 *String)
Definition: FdtLib.c:423
CONST VOID *EFIAPI FdtOffsetPointer(IN CONST VOID *Fdt, IN INT32 Offset, IN UINT32 Length)
Definition: FdtLib.c:199
INT32 EFIAPI FdtNextPropertyOffset(IN CONST VOID *Fdt, IN INT32 Offset)
Definition: FdtLib.c:508
INT32 EFIAPI FdtNodeOffsetByPropertyValue(IN CONST VOID *Fdt, IN INT32 StartOffset, IN CONST CHAR8 *PropertyName, IN CONST VOID *PropertyValue, IN INT32 PropertyLength)
Definition: FdtLib.c:383
INT32 EFIAPI FdtFirstSubnode(IN CONST VOID *Fdt, IN INT32 Offset)
Definition: FdtLib.c:240
CONST FDT_PROPERTY *EFIAPI FdtGetProperty(IN CONST VOID *Fdt, IN INT32 NodeOffset, IN CONST CHAR8 *Name, IN INT32 *Length)
Definition: FdtLib.c:446
UINT64 EFIAPI Fdt64ToCpu(IN UINT64 Value)
Definition: FdtLib.c:91
INT32 EFIAPI FdtOpenInto(IN CONST VOID *Fdt, OUT VOID *Buffer, IN INT32 BufferSize)
Definition: FdtLib.c:163
CONST CHAR8 *EFIAPI FdtGetAliasNameLen(IN CONST VOID *Fdt, IN CONST CHAR8 *Name, IN INT32 Length)
Definition: FdtLib.c:469
CONST CHAR8 *EFIAPI FdtGetString(IN CONST VOID *Fdt, IN INT32 StrOffset, IN INT32 *Length OPTIONAL)
Definition: FdtLib.c:549
INT32 EFIAPI FdtSetProperty(IN VOID *Fdt, IN INT32 NodeOffset, IN CONST CHAR8 *Name, IN CONST VOID *Value, IN UINT32 Length)
Definition: FdtLib.c:593
INT32 EFIAPI FdtPack(IN OUT VOID *Fdt)
Definition: FdtLib.c:181
UINT16 EFIAPI Fdt16ToCpu(IN UINT16 Value)
Definition: FdtLib.c:23
INT32 EFIAPI FdtSubnodeOffset(IN CONST VOID *Fdt, IN INT32 ParentOffset, IN CONST CHAR8 *Name)
Definition: FdtLib.c:342
INT32 EFIAPI FdtNodeOffsetByCompatible(IN CONST VOID *Fdt, IN INT32 StartOffset, IN CONST CHAR8 *Compatible)
Definition: FdtLib.c:768
INT32 EFIAPI FdtSetPropU64(IN VOID *Fdt, IN INT32 NodeOffset, IN CONST CHAR8 *Name, IN UINT64 Value)
Definition: FdtLib.c:617
INT32 EFIAPI FdtSubnodeOffsetNameLen(IN CONST VOID *Fdt, IN INT32 ParentOffset, IN CONST CHAR8 *Name, IN INT32 NameLength)
Definition: FdtLib.c:320
INT32 EFIAPI FdtAddressCells(IN CONST VOID *Fdt, IN INT32 NodeOffset)
Definition: FdtLib.c:787
INT32 EFIAPI FdtAddSubnode(IN VOID *Fdt, IN INT32 ParentOffset, IN CONST CHAR8 *Name)
Definition: FdtLib.c:570
UINT16 EFIAPI CpuToFdt16(IN UINT16 Value)
Definition: FdtLib.c:40
INT32 EFIAPI FdtNextNode(IN CONST VOID *Fdt, IN INT32 Offset, IN INT32 *Depth)
Definition: FdtLib.c:220
UINT32 EFIAPI CpuToFdt32(IN UINT32 Value)
Definition: FdtLib.c:74
INT32 EFIAPI FdtCheckHeader(IN CONST VOID *Fdt)
Definition: FdtLib.c:125
INT32 EFIAPI FdtParentOffset(IN CONST VOID *Fdt, IN INT32 NodeOffset)
Definition: FdtLib.c:361
INTN EFIAPI FdtGetNumberOfReserveMapEntries(IN CONST VOID *Fdt)
Definition: FdtLib.c:277
UINT32 EFIAPI Fdt32ToCpu(IN UINT32 Value)
Definition: FdtLib.c:57
INT32 EFIAPI FdtSizeCells(IN CONST VOID *Fdt, IN INT32 NodeOffset)
Definition: FdtLib.c:805
INT32 EFIAPI FdtPathOffset(IN CONST VOID *Fdt, IN CONST CHAR8 *Path)
Definition: FdtLib.c:709
INT32 EFIAPI FdtFirstPropertyOffset(IN CONST VOID *Fdt, IN INT32 NodeOffset)
Definition: FdtLib.c:489
INTN EFIAPI FdtGetReserveMapEntry(IN CONST VOID *Fdt, IN INTN Index, OUT EFI_PHYSICAL_ADDRESS *Addr, OUT UINT64 *Size)
Definition: FdtLib.c:297
INT32 EFIAPI FdtPathOffsetNameLen(IN CONST VOID *Fdt, IN CONST CHAR8 *Path, IN INT32 NameLength)
Definition: FdtLib.c:690
CONST CHAR8 *EFIAPI FdtGetName(IN VOID *Fdt, IN INT32 NodeOffset, IN INT32 *Length)
Definition: FdtLib.c:729
INT32 EFIAPI FdtNodeOffsetByPhandle(IN CONST VOID *Fdt, IN UINT32 Phandle)
Definition: FdtLib.c:404
INT32 EFIAPI FdtCreateEmptyTree(IN VOID *Buffer, IN UINT32 BufferSize)
Definition: FdtLib.c:143
INT32 EFIAPI FdtNextSubnode(IN CONST VOID *Fdt, IN INT32 Offset)
Definition: FdtLib.c:259
CONST FDT_PROPERTY *EFIAPI FdtGetPropertyByOffset(IN CONST VOID *Fdt, IN INT32 Offset, IN INT32 *Length)
Definition: FdtLib.c:528
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50