Skip to content

Commit 44e6186

Browse files
author
Ard Biesheuvel
committed
EmbeddedPkg/FdtLib: incorporate missing overlay support
Commit a099239 ("EmbeddedPkg/FdtLib: Update FdtLib to v1.4.5") updated our FdtLib implementation to a more recent upstream version, but omitted fdt_overlay.c due to its ambiguous licensing situation. This has been resolved now, so take the latest upstream version of the file (which received no other modifications in the mean time) and add it to FdtLib. Note that fdt_overlay.c has a dependency on strtoul() which EDK does not provide natively, so add a private implementation that wraps the BaseLib routines that do roughly the same. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <[email protected]> Reviewed-by: Leif Lindholm <[email protected]>
1 parent 6461344 commit 44e6186

File tree

4 files changed

+989
-0
lines changed

4 files changed

+989
-0
lines changed

EmbeddedPkg/Include/libfdt.h

+31
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,37 @@ int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
18591859
*/
18601860
int fdt_del_node(void *fdt, int nodeoffset);
18611861

1862+
/**
1863+
* fdt_overlay_apply - Applies a DT overlay on a base DT
1864+
* @fdt: pointer to the base device tree blob
1865+
* @fdto: pointer to the device tree overlay blob
1866+
*
1867+
* fdt_overlay_apply() will apply the given device tree overlay on the
1868+
* given base device tree.
1869+
*
1870+
* Expect the base device tree to be modified, even if the function
1871+
* returns an error.
1872+
*
1873+
* returns:
1874+
* 0, on success
1875+
* -FDT_ERR_NOSPACE, there's not enough space in the base device tree
1876+
* -FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
1877+
* properties in the base DT
1878+
* -FDT_ERR_BADPHANDLE,
1879+
* -FDT_ERR_BADOVERLAY,
1880+
* -FDT_ERR_NOPHANDLES,
1881+
* -FDT_ERR_INTERNAL,
1882+
* -FDT_ERR_BADLAYOUT,
1883+
* -FDT_ERR_BADMAGIC,
1884+
* -FDT_ERR_BADOFFSET,
1885+
* -FDT_ERR_BADPATH,
1886+
* -FDT_ERR_BADVERSION,
1887+
* -FDT_ERR_BADSTRUCTURE,
1888+
* -FDT_ERR_BADSTATE,
1889+
* -FDT_ERR_TRUNCATED, standard meanings
1890+
*/
1891+
int fdt_overlay_apply(void *fdt, void *fdto);
1892+
18621893
/**********************************************************************/
18631894
/* Debugging / informational functions */
18641895
/**********************************************************************/

EmbeddedPkg/Library/FdtLib/FdtLib.inf

+6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727

2828
[Sources]
2929
fdt_empty_tree.c
30+
fdt_overlay.c
3031
fdt_ro.c
3132
fdt_rw.c
3233
fdt_strerror.c
34+
fdt_strtoul.c
3335
fdt_sw.c
3436
fdt_wip.c
3537
fdt.c
@@ -38,3 +40,7 @@
3840
[Packages]
3941
MdePkg/MdePkg.dec
4042
EmbeddedPkg/EmbeddedPkg.dec
43+
44+
[LibraryClasses]
45+
BaseLib
46+
DebugLib

0 commit comments

Comments
 (0)