Re: [edk2-devel] [PATCH v2 1/2] MdePkg/BaseFdtLib: Add Fdt function.
Reviewed-by: Benny Lin -Original Message- From: Wang, BruceX Sent: Friday, September 15, 2023 4:58 PM To: devel@edk2.groups.io Cc: Wang, BruceX ; Lin, Benny ; Guo, Gua ; Chiu, Chasel ; Lu, James Subject: [PATCH v2 1/2] MdePkg/BaseFdtLib: Add Fdt function. From: "Brucex.Wang" Add FdtGetName() and FdtNodeDepth() function. Cc: Benny Lin Cc: Gua Guo Cc: Chasel Chiu Cc: James Lu Signed-off-by: BruceX Wang --- MdePkg/Include/Library/FdtLib.h| 34 + MdePkg/Library/BaseFdtLib/FdtLib.c | 40 ++ 2 files changed, 74 insertions(+) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h index cf5ceba9e9..2bd926b5b4 100644 --- a/MdePkg/Include/Library/FdtLib.h +++ b/MdePkg/Include/Library/FdtLib.h @@ -398,4 +398,38 @@ FdtSetProp ( IN UINT32 Length ); +/**+ Returns the name of a given node.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffse Offset of node to check.+ @param[in] Length The pointer to an integer variable (will be overwritten) or NULL.++ @return The pointer to the node's name.++**/+CONST CHAR8 *+EFIAPI+FdtGetName (+ IN VOID*Fdt,+ IN INT32 NodeOffset,+ IN UINT32 *Length+ );++/**+ FdtNodeDepth() finds the depth of a given node. The root node+ has depth 0, its immediate subnodes depth 1 and so forth.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffset Offset of node to check.++ @return Depth of the node at NodeOffset.+ **/+INT32+EFIAPI+FdtNodeDepth (+ IN CONST VOID *Fdt,+ IN INT32 NodeOffset+ );+ #endif /* FDT_LIB_H_ */diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c index 090b0b3fd4..1ef99ea882 100644 --- a/MdePkg/Library/BaseFdtLib/FdtLib.c +++ b/MdePkg/Library/BaseFdtLib/FdtLib.c @@ -402,3 +402,43 @@ FdtSetProp ( { return fdt_setprop (Fdt, NodeOffset, Name, Value, (int)Length); }++/**+ Returns the name of a given node.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffset Offset of node to check.+ @param[in] Length The pointer to an integer variable (will be overwritten) or NULL.++ @return The pointer to the node's name.++**/+CONST CHAR8 *+EFIAPI+FdtGetName (+ IN VOID*Fdt,+ IN INT32 NodeOffset,+ IN UINT32 *Length+ )+{+ return fdt_get_name (Fdt, NodeOffset, (int *)Length);+}++/**+ FdtNodeDepth() finds the depth of a given node. The root node+ has depth 0, its immediate subnodes depth 1 and so forth.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffset Offset of node to check.++ @returns Depth of the node at NodeOffset.+**/+INT32+EFIAPI+FdtNodeDepth (+ IN CONST VOID *Fdt,+ IN INT32 NodeOffset+ )+{+ return fdt_node_depth (Fdt, NodeOffset);+}-- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108703): https://edk2.groups.io/g/devel/message/108703 Mute This Topic: https://groups.io/mt/101375949/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v3 1/2] MdePkg/BaseFdtLib: Add Fdt function.
Hi, Bruce, A redundant space in the function comment of FdtNodeDepth. Please find my comment below. Thanks! QQQ Benny From: Wang, BruceX Sent: Saturday, September 16, 2023 6:53:17 PM To: devel@edk2.groups.io Cc: Wang, BruceX ; Lin, Benny ; Guo, Gua ; Chiu, Chasel ; Lu, James Subject: [PATCH v3 1/2] MdePkg/BaseFdtLib: Add Fdt function. From: "Brucex.Wang" Add FdtGetName() and FdtNodeDepth() function. Cc: Benny Lin Cc: Gua Guo Cc: Chasel Chiu Cc: James Lu Signed-off-by: BruceX Wang --- MdePkg/Include/Library/FdtLib.h| 34 + MdePkg/Library/BaseFdtLib/FdtLib.c | 40 ++ 2 files changed, 74 insertions(+) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h index cf5ceba9e9..2bd926b5b4 100644 --- a/MdePkg/Include/Library/FdtLib.h +++ b/MdePkg/Include/Library/FdtLib.h @@ -398,4 +398,38 @@ FdtSetProp ( IN UINT32 Length ); +/** + Returns the name of a given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] NodeOffse Offset of node to check. + @param[in] Length The pointer to an integer variable (will be overwritten) or NULL. + + @return The pointer to the node's name. + +**/ +CONST CHAR8 * +EFIAPI +FdtGetName ( + IN VOID*Fdt, + IN INT32 NodeOffset, + IN UINT32 *Length + ); + +/** + FdtNodeDepth() finds the depth of a given node. The root node + has depth 0, its immediate subnodes depth 1 and so forth. + + @param[in] FdtThe pointer to FDT blob. + @param[in] NodeOffset Offset of node to check. + + @return Depth of the node at NodeOffset. + **/ > A redundant space. +INT32 +EFIAPI +FdtNodeDepth ( + IN CONST VOID *Fdt, + IN INT32 NodeOffset + ); + #endif /* FDT_LIB_H_ */ diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c index 090b0b3fd4..1ef99ea882 100644 --- a/MdePkg/Library/BaseFdtLib/FdtLib.c +++ b/MdePkg/Library/BaseFdtLib/FdtLib.c @@ -402,3 +402,43 @@ FdtSetProp ( { return fdt_setprop (Fdt, NodeOffset, Name, Value, (int)Length); } + +/** + Returns the name of a given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] NodeOffset Offset of node to check. + @param[in] Length The pointer to an integer variable (will be overwritten) or NULL. + + @return The pointer to the node's name. + +**/ +CONST CHAR8 * +EFIAPI +FdtGetName ( + IN VOID*Fdt, + IN INT32 NodeOffset, + IN UINT32 *Length + ) +{ + return fdt_get_name (Fdt, NodeOffset, (int *)Length); +} + +/** + FdtNodeDepth() finds the depth of a given node. The root node + has depth 0, its immediate subnodes depth 1 and so forth. + + @param[in] FdtThe pointer to FDT blob. + @param[in] NodeOffset Offset of node to check. + + @returns Depth of the node at NodeOffset. +**/ +INT32 +EFIAPI +FdtNodeDepth ( + IN CONST VOID *Fdt, + IN INT32 NodeOffset + ) +{ + return fdt_node_depth (Fdt, NodeOffset); +} -- 2.39.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108766): https://edk2.groups.io/g/devel/message/108766 Mute This Topic: https://groups.io/mt/101398211/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v4 1/2] MdePkg/BaseFdtLib: Add Fdt function.
Reviewed-by: Benny Lin -Original Message- From: Wang, BruceX Sent: Monday, September 18, 2023 3:02 PM To: devel@edk2.groups.io Cc: Wang, BruceX ; Lin, Benny ; Guo, Gua ; Chiu, Chasel ; Lu, James Subject: [PATCH v4 1/2] MdePkg/BaseFdtLib: Add Fdt function. From: "Brucex.Wang" Add FdtGetName() and FdtNodeDepth() function. Cc: Benny Lin Cc: Gua Guo Cc: Chasel Chiu Cc: James Lu Signed-off-by: BruceX Wang --- MdePkg/Include/Library/FdtLib.h| 34 + MdePkg/Library/BaseFdtLib/FdtLib.c | 40 ++ 2 files changed, 74 insertions(+) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h index cf5ceba9e9..d9300a18e3 100644 --- a/MdePkg/Include/Library/FdtLib.h +++ b/MdePkg/Include/Library/FdtLib.h @@ -398,4 +398,38 @@ FdtSetProp ( IN UINT32 Length ); +/**+ Returns the name of a given node.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffse Offset of node to check.+ @param[in] Length The pointer to an integer variable (will be overwritten) or NULL.++ @return The pointer to the node's name.++**/+CONST CHAR8 *+EFIAPI+FdtGetName (+ IN VOID*Fdt,+ IN INT32 NodeOffset,+ IN UINT32 *Length+ );++/**+ FdtNodeDepth() finds the depth of a given node. The root node+ has depth 0, its immediate subnodes depth 1 and so forth.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffset Offset of node to check.++ @return Depth of the node at NodeOffset.+**/+INT32+EFIAPI+FdtNodeDepth (+ IN CONST VOID *Fdt,+ IN INT32 NodeOffset+ );+ #endif /* FDT_LIB_H_ */diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c index 090b0b3fd4..1ef99ea882 100644 --- a/MdePkg/Library/BaseFdtLib/FdtLib.c +++ b/MdePkg/Library/BaseFdtLib/FdtLib.c @@ -402,3 +402,43 @@ FdtSetProp ( { return fdt_setprop (Fdt, NodeOffset, Name, Value, (int)Length); }++/**+ Returns the name of a given node.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffset Offset of node to check.+ @param[in] Length The pointer to an integer variable (will be overwritten) or NULL.++ @return The pointer to the node's name.++**/+CONST CHAR8 *+EFIAPI+FdtGetName (+ IN VOID*Fdt,+ IN INT32 NodeOffset,+ IN UINT32 *Length+ )+{+ return fdt_get_name (Fdt, NodeOffset, (int *)Length);+}++/**+ FdtNodeDepth() finds the depth of a given node. The root node+ has depth 0, its immediate subnodes depth 1 and so forth.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffset Offset of node to check.++ @returns Depth of the node at NodeOffset.+**/+INT32+EFIAPI+FdtNodeDepth (+ IN CONST VOID *Fdt,+ IN INT32 NodeOffset+ )+{+ return fdt_node_depth (Fdt, NodeOffset);+}-- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108770): https://edk2.groups.io/g/devel/message/108770 Mute This Topic: https://groups.io/mt/101429071/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v5 1/2] MdePkg/BaseFdtLib: Add Fdt function.
Reviewed-by: Benny Lin -Original Message- From: Wang, BruceX Sent: Monday, September 25, 2023 10:15 AM To: devel@edk2.groups.io Cc: Wang, BruceX ; Lin, Benny ; Guo, Gua ; Chiu, Chasel ; Lu, James Subject: [PATCH v5 1/2] MdePkg/BaseFdtLib: Add Fdt function. From: "Brucex.Wang" Add FdtGetName() and FdtNodeDepth() function. Cc: Benny Lin Cc: Gua Guo Cc: Chasel Chiu Cc: James Lu Signed-off-by: BruceX Wang --- MdePkg/Include/Library/FdtLib.h| 34 + MdePkg/Library/BaseFdtLib/FdtLib.c | 40 ++ 2 files changed, 74 insertions(+) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h index cf5ceba9e9..d9300a18e3 100644 --- a/MdePkg/Include/Library/FdtLib.h +++ b/MdePkg/Include/Library/FdtLib.h @@ -398,4 +398,38 @@ FdtSetProp ( IN UINT32 Length ); +/**+ Returns the name of a given node.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffse Offset of node to check.+ @param[in] Length The pointer to an integer variable (will be overwritten) or NULL.++ @return The pointer to the node's name.++**/+CONST CHAR8 *+EFIAPI+FdtGetName (+ IN VOID*Fdt,+ IN INT32 NodeOffset,+ IN UINT32 *Length+ );++/**+ FdtNodeDepth() finds the depth of a given node. The root node+ has depth 0, its immediate subnodes depth 1 and so forth.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffset Offset of node to check.++ @return Depth of the node at NodeOffset.+**/+INT32+EFIAPI+FdtNodeDepth (+ IN CONST VOID *Fdt,+ IN INT32 NodeOffset+ );+ #endif /* FDT_LIB_H_ */diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c index 090b0b3fd4..1ef99ea882 100644 --- a/MdePkg/Library/BaseFdtLib/FdtLib.c +++ b/MdePkg/Library/BaseFdtLib/FdtLib.c @@ -402,3 +402,43 @@ FdtSetProp ( { return fdt_setprop (Fdt, NodeOffset, Name, Value, (int)Length); }++/**+ Returns the name of a given node.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffset Offset of node to check.+ @param[in] Length The pointer to an integer variable (will be overwritten) or NULL.++ @return The pointer to the node's name.++**/+CONST CHAR8 *+EFIAPI+FdtGetName (+ IN VOID*Fdt,+ IN INT32 NodeOffset,+ IN UINT32 *Length+ )+{+ return fdt_get_name (Fdt, NodeOffset, (int *)Length);+}++/**+ FdtNodeDepth() finds the depth of a given node. The root node+ has depth 0, its immediate subnodes depth 1 and so forth.++ @param[in] FdtThe pointer to FDT blob.+ @param[in] NodeOffset Offset of node to check.++ @returns Depth of the node at NodeOffset.+**/+INT32+EFIAPI+FdtNodeDepth (+ IN CONST VOID *Fdt,+ IN INT32 NodeOffset+ )+{+ return fdt_node_depth (Fdt, NodeOffset);+}-- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109034): https://edk2.groups.io/g/devel/message/109034 Mute This Topic: https://groups.io/mt/101568108/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v3 2/3] MdePkg: Support FDT library.
Please find my feedback below. We can remove FDT_RESERVE_ENTRY but keep FDT_NODE_HEADER, what do you think? QQQ Benny >-Original Message- >From: Kinney, Michael D >Sent: Wednesday, April 19, 2023 11:54 PM >To: Lin, Benny ; devel@edk2.groups.io >Cc: Gao, Liming ; Liu, Zhiguang >; Pedro Falcato ; Kinney, >Michael D >Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library. > >A few comments below. > >Mike > >> -Original Message- >> From: Lin, Benny >> Sent: Sunday, April 16, 2023 10:35 PM >> To: devel@edk2.groups.io >> Cc: Lin, Benny ; Kinney, Michael D >> ; Gao, Liming ; >> Liu, Zhiguang ; Pedro Falcato >> >> Subject: [PATCH v3 2/3] MdePkg: Support FDT library. >> >> From: Benny Lin >> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 >> Add FDT support in EDK2 by submodule 3rd party libfdt >> (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) >> and refer to LibcLib implementation by Pedro. >> >> Cc: Michael D Kinney >> Cc: Liming Gao >> Cc: Zhiguang Liu >> Acked-by: Pedro Falcato >> Signed-off-by: Benny Lin >> --- >> MdePkg/Include/Library/FdtLib.h | 314 >> MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 >> MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + >> MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++ >> MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 ++ >> MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++ >> MdePkg/Library/BaseFdtLib/limits.h| 10 + >> MdePkg/Library/BaseFdtLib/stdbool.h | 10 + >> MdePkg/Library/BaseFdtLib/stddef.h| 10 + >> MdePkg/Library/BaseFdtLib/stdint.h| 10 + >> MdePkg/Library/BaseFdtLib/stdlib.h| 10 + >> MdePkg/Library/BaseFdtLib/string.h| 10 + >> MdePkg/MdePkg.ci.yaml | 17 +- >> MdePkg/MdePkg.dec | 4 + >> MdePkg/MdePkg.dsc | 1 + >> 15 files changed, 1043 insertions(+), 2 deletions(-) >> >> diff --git a/MdePkg/Include/Library/FdtLib.h >> b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index >> 00..d59b749c25 >> --- /dev/null >> +++ b/MdePkg/Include/Library/FdtLib.h >> @@ -0,0 +1,314 @@ >> +/** @file >> >> + Flattened Device Tree Library. >> >> + >> >> + Copyright (c) 2023, Intel Corporation. All rights reserved. >> >> + SPDX-License-Identifier: BSD-2-Clause-Patent >> >> + >> >> +**/ >> >> + >> >> +#ifndef FDT_LIB_H_ >> >> +#define FDT_LIB_H_ >> >> + >> >> +/// >> >> +/// Flattened Device Tree definition >> >> +/// >> >> +typedef struct { >> >> + UINT32Magic; /* magic word FDT_MAGIC */ >> >> + UINT32TotalSize; /* total size of DT block */ >> >> + UINT32OffsetDtStruct; /* offset to structure */ >> >> + UINT32OffsetDtStrings; /* offset to strings */ >> >> + UINT32OffsetMemRsvmap; /* offset to memory reserve map */ >> >> + UINT32Version; /* format version */ >> >> + UINT32LastCompVersion; /* last compatible version */ >> >> + >> >> + /* version 2 fields below */ >> >> + UINT32BootCpuidPhys; /* Which physical CPU id we're >> >> +booting on */ >> >> + /* version 3 fields below */ >> >> + UINT32SizeDtStrings; /* size of the strings block */ >> >> + >> >> + /* version 17 fields below */ >> >> + UINT32SizeDtStruct;/* size of the structure block */ >> >> +} FDT_HEADER; > >I see the macros below use SwapBytes32() on all the fields from this >structure. Does this mean this structure is big >endian? If that is the >case, then the description of this structure and all individual fields must >make that very clear >so any consumer of the structure knows it does not >follow the default endianness of UEFI/PI and that consumers >must either use >the macros or consumers must use SwapBytes32() on their own when using this >structure directly. Yes, it's big endian. I will complete more descriptions in patch v4. >> >> + >> >> +typedef struct { >> >> + UINT64Address; >> >> + UINT64Size; >> >> +} FDT_RESERVE_ENTRY; >
Re: [edk2-devel] [PATCH v3 2/3] MdePkg: Support FDT library.
>-Original Message- >From: Kinney, Michael D >Sent: Thursday, April 20, 2023 5:04 AM >To: Lin, Benny ; devel@edk2.groups.io >Cc: Gao, Liming ; Liu, Zhiguang >; Pedro Falcato ; Kinney, >Michael D >Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library. > >Responses below > >Mike > >> -Original Message- >> From: Lin, Benny >> Sent: Wednesday, April 19, 2023 10:12 AM >> To: Kinney, Michael D ; >> devel@edk2.groups.io >> Cc: Gao, Liming ; Liu, Zhiguang >> ; Pedro Falcato >> Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library. >> >> Please find my feedback below. >> We can remove FDT_RESERVE_ENTRY but keep FDT_NODE_HEADER, what do you think? >> >> QQQ >> Benny >> >> >-Original Message- >> >From: Kinney, Michael D >> >Sent: Wednesday, April 19, 2023 11:54 PM >> >To: Lin, Benny ; devel@edk2.groups.io >> >Cc: Gao, Liming ; Liu, Zhiguang >> >; Pedro Falcato ; >> >Kinney, >> Michael D >> >Subject: RE: [PATCH v3 2/3] MdePkg: Support FDT library. >> > >> >A few comments below. >> > >> >Mike >> > >> >> -Original Message- >> >> From: Lin, Benny >> >> Sent: Sunday, April 16, 2023 10:35 PM >> >> To: devel@edk2.groups.io >> >> Cc: Lin, Benny ; Kinney, Michael D >> >> ; Gao, Liming >> >> ; Liu, Zhiguang ; >> >> Pedro Falcato >> >> Subject: [PATCH v3 2/3] MdePkg: Support FDT library. >> >> >> >> From: Benny Lin >> >> >> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 >> >> Add FDT support in EDK2 by submodule 3rd party libfdt >> >> (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) >> >> and refer to LibcLib implementation by Pedro. >> >> >> >> Cc: Michael D Kinney >> >> Cc: Liming Gao >> >> Cc: Zhiguang Liu >> >> Acked-by: Pedro Falcato >> >> Signed-off-by: Benny Lin >> >> --- >> >> MdePkg/Include/Library/FdtLib.h | 314 >> >> MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 >> >> MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + >> >> MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++ >> >> MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 ++ >> >> MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++ >> >> MdePkg/Library/BaseFdtLib/limits.h| 10 + >> >> MdePkg/Library/BaseFdtLib/stdbool.h | 10 + >> >> MdePkg/Library/BaseFdtLib/stddef.h| 10 + >> >> MdePkg/Library/BaseFdtLib/stdint.h| 10 + >> >> MdePkg/Library/BaseFdtLib/stdlib.h| 10 + >> >> MdePkg/Library/BaseFdtLib/string.h| 10 + >> >> MdePkg/MdePkg.ci.yaml | 17 +- >> >> MdePkg/MdePkg.dec | 4 + >> >> MdePkg/MdePkg.dsc | 1 + >> >> 15 files changed, 1043 insertions(+), 2 deletions(-) >> >> >> >> diff --git a/MdePkg/Include/Library/FdtLib.h >> >> b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index >> >> 00..d59b749c25 >> >> --- /dev/null >> >> +++ b/MdePkg/Include/Library/FdtLib.h >> >> @@ -0,0 +1,314 @@ >> >> +/** @file >> >> >> >> + Flattened Device Tree Library. >> >> >> >> + >> >> >> >> + Copyright (c) 2023, Intel Corporation. All rights reserved. >> >> >> >> + SPDX-License-Identifier: BSD-2-Clause-Patent >> >> >> >> + >> >> >> >> +**/ >> >> >> >> + >> >> >> >> +#ifndef FDT_LIB_H_ >> >> >> >> +#define FDT_LIB_H_ >> >> >> >> + >> >> >> >> +/// >> >> >> >> +/// Flattened Device Tree definition >> >> >> >> +/// >> >> >> >> +typedef struct { >> >> >> >> + UINT32Magic; /* magic word FDT_MAGIC */ >> >> >> >> + UINT32TotalSize; /* total size of DT block */ >> >> >> >> + UINT32OffsetDtStruct; /* offset to structure */ >> >> >> >> + UINT32OffsetDtStrings; /* offset to strings */ >>
[edk2-devel] [PATCH v4 0/3] Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) and refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Sean Brogan Cc: Michael Kubacki Acked-by: Pedro Falcato Signed-off-by: Benny Lin Benny Lin (3): Tianocore: Support FDT library. MdePkg: Support FDT library. .pytool: Support FDT library. .gitmodules | 3 + .pytool/CISettings.py | 2 + MdePkg/Include/Library/FdtLib.h | 305 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++ MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 +++ MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++ MdePkg/Library/BaseFdtLib/libfdt | 1 + MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 15 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + ReadMe.rst| 1 + 19 files changed, 1040 insertions(+), 1 deletion(-) create mode 100644 MdePkg/Include/Library/FdtLib.h create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni create mode 100644 MdePkg/Library/BaseFdtLib/FdtLib.c create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtSupport.h create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c create mode 16 MdePkg/Library/BaseFdtLib/libfdt create mode 100644 MdePkg/Library/BaseFdtLib/limits.h create mode 100644 MdePkg/Library/BaseFdtLib/stdbool.h create mode 100644 MdePkg/Library/BaseFdtLib/stddef.h create mode 100644 MdePkg/Library/BaseFdtLib/stdint.h create mode 100644 MdePkg/Library/BaseFdtLib/stdlib.h create mode 100644 MdePkg/Library/BaseFdtLib/string.h -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103483): https://edk2.groups.io/g/devel/message/103483 Mute This Topic: https://groups.io/mt/98471366/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v4 1/3] Tianocore: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add submodule libfdt and update ReadMe for the licence. Reviewed-by: Leif Lindholm Reviewed-by: Michael D Kinney Cc: Andrew Fish Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Benny Lin --- .gitmodules | 3 +++ MdePkg/Library/BaseFdtLib/libfdt | 1 + ReadMe.rst | 1 + 3 files changed, 5 insertions(+) diff --git a/.gitmodules b/.gitmodules index fe8a43be93..b1888c3488 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,6 @@ [submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"] path = UnitTestFrameworkPkg/Library/SubhookLib/subhook url = https://github.com/Zeex/subhook.git +[submodule "MdePkg/Library/BaseFdtLib/libfdt"] + path = MdePkg/Library/BaseFdtLib/libfdt + url = https://github.com/devicetree-org/pylibfdt.git diff --git a/MdePkg/Library/BaseFdtLib/libfdt b/MdePkg/Library/BaseFdtLib/libfdt new file mode 16 index 00..cfff805481 --- /dev/null +++ b/MdePkg/Library/BaseFdtLib/libfdt @@ -0,0 +1 @@ +Subproject commit cfff805481bdea27f900c32698171286542b8d3c diff --git a/ReadMe.rst b/ReadMe.rst index 91b9cf3c5e..d46c534229 100644 --- a/ReadMe.rst +++ b/ReadMe.rst @@ -96,6 +96,7 @@ that are covered by additional licenses. - `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest <https://github.com/google/googletest/blob/86add13493e5c881d7e4ba77fb91c1f57752b3a4/LICENSE>`__ - `UnitTestFrameworkPkg/Library/SubhookLib/subhook <https://github.com/Zeex/subhook/blob/83d4e1ebef3588fae48b69a7352cc21801cb70bc/LICENSE.txt>`__ - `RedfishPkg/Library/JsonLib/jansson <https://github.com/akheron/jansson/blob/2882ead5bb90cf12a01b07b2c2361e24960fae02/LICENSE>`__ +- `MdePkg/Library/BaseFdtLib/libfdt <https://github.com/devicetree-org/pylibfdt/blob/f39368a217496d32c4091a2dba4045b60649e3a5/BSD-2-Clause>`__ The EDK II Project is composed of packages. The maintainers for each package are listed in `Maintainers.txt `__. -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103484): https://edk2.groups.io/g/devel/message/103484 Mute This Topic: https://groups.io/mt/98471367/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v4 2/3] MdePkg: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) and refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Acked-by: Pedro Falcato Signed-off-by: Benny Lin --- MdePkg/Include/Library/FdtLib.h | 305 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++ MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 +++ MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++ MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 15 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + 15 files changed, 1033 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index 00..8c540b2b1d --- /dev/null +++ b/MdePkg/Include/Library/FdtLib.h @@ -0,0 +1,305 @@ +/** @file + Flattened Device Tree Library. + + Copyright (c) 2023, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FDT_LIB_H_ +#define FDT_LIB_H_ + +/** + Flattened Device Tree definition + + The Devicetree Blob (DTB) format is a binary encoding with big-endian. + When producing or consuming the blob data, must translate with SwapBytesXX + provided by edk2 BaseLib between big-endian and little-endian. +**/ +typedef struct { + UINT32Magic; /* magic word FDT_MAGIC */ + UINT32TotalSize; /* total size of DT block */ + UINT32OffsetDtStruct; /* offset to structure */ + UINT32OffsetDtStrings; /* offset to strings */ + UINT32OffsetMemRsvmap; /* offset to memory reserve map */ + UINT32Version; /* format version */ + UINT32LastCompVersion; /* last compatible version */ + + /* version 2 fields below */ + UINT32BootCpuidPhys; /* Which physical CPU id we're +booting on */ + /* version 3 fields below */ + UINT32SizeDtStrings; /* size of the strings block */ + + /* version 17 fields below */ + UINT32SizeDtStruct;/* size of the structure block */ +} FDT_HEADER; + +typedef struct { + UINT64Address; + UINT64Size; +} FDT_RESERVE_ENTRY; + +typedef struct { + UINT32Tag; + CHAR8 Name[]; +} FDT_NODE_HEADER; + +typedef struct { + UINT32Tag; + UINT32Length; + UINT32NameOffset; + CHAR8 Data[]; +} FDT_PROPERTY; + +/** + Verify the header of the Flattened Device Tree + + @param[in] FdtThe pointer to FDT blob. + + @return Zero for successfully, otherwise failed. + +**/ +INT32 +EFIAPI +FdtCheckHeader ( + IN CONST VOID *Fdt + ); + +/** + Create a empty Flattened Device Tree. + + @param[in] Buffer The pointer to allocate a pool for FDT blob. + @param[in] BufferSize The BufferSize to the pool size. + + @return Zero for successfully, otherwise failed. + +**/ +RETURN_STATUS +EFIAPI +FdtCreateEmptyTree ( + IN VOID *Buffer, + IN UINTN BufferSize + ); + +/** + Returns a offset of next node from the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + @param[in] Depth The depth to the level of tree hierarchy. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtNextNode ( + IN CONST VOID *Fdt, + IN INT32 Offset, + IN INT32 *Depth + ); + +/** + Returns a offset of first node under the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtFirstSubnode ( + IN CONST VOID *Fdt, + IN INT32 Offset + ); + +/** + Returns a offset of next node from the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtNextSubnode ( + IN CONST VOID *Fdt, + IN INT32 Offset + ); + +/** + Returns a offset of first node which includes the given name. + + @param[in] Fdt The pointer to FDT blob. + @param[in] ParentOffsetThe offset to the node which start find under. + @param[in] NameThe name to search the node with the name. + @param[in] NameLength The length of the name to check only. + + @return The offset to
[edk2-devel] [PATCH v4 3/3] .pytool: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add RequiredSubmodule object for CI setting. Reviewed-by: Michael D Kinney Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Benny Lin --- .pytool/CISettings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index e3f44add58..2fb99f2a17 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -195,6 +195,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag "RedfishPkg/Library/JsonLib/jansson", False)) rs.append(RequiredSubmodule( "UnitTestFrameworkPkg/Library/SubhookLib/subhook", False)) +rs.append(RequiredSubmodule( +"MdePkg/Library/BaseFdtLib/libfdt", False)) return rs def GetName(self): -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103486): https://edk2.groups.io/g/devel/message/103486 Mute This Topic: https://groups.io/mt/98471369/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v5 0/3] Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) and refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Sean Brogan Cc: Michael Kubacki Acked-by: Pedro Falcato Signed-off-by: Benny Lin Benny Lin (3): Tianocore: Support FDT library. MdePkg: Support FDT library. .pytool: Support FDT library. .gitmodules | 3 + .pytool/CISettings.py | 2 + MdePkg/Include/Library/FdtLib.h | 311 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++ MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 +++ MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++ MdePkg/Library/BaseFdtLib/libfdt | 1 + MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 15 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + ReadMe.rst| 1 + 19 files changed, 1046 insertions(+), 1 deletion(-) create mode 100644 MdePkg/Include/Library/FdtLib.h create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni create mode 100644 MdePkg/Library/BaseFdtLib/FdtLib.c create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtSupport.h create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c create mode 16 MdePkg/Library/BaseFdtLib/libfdt create mode 100644 MdePkg/Library/BaseFdtLib/limits.h create mode 100644 MdePkg/Library/BaseFdtLib/stdbool.h create mode 100644 MdePkg/Library/BaseFdtLib/stddef.h create mode 100644 MdePkg/Library/BaseFdtLib/stdint.h create mode 100644 MdePkg/Library/BaseFdtLib/stdlib.h create mode 100644 MdePkg/Library/BaseFdtLib/string.h -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103760): https://edk2.groups.io/g/devel/message/103760 Mute This Topic: https://groups.io/mt/98553640/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v5 1/3] Tianocore: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add submodule libfdt and update ReadMe for the licence. Reviewed-by: Leif Lindholm Reviewed-by: Michael D Kinney Cc: Andrew Fish Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Benny Lin --- .gitmodules | 3 +++ MdePkg/Library/BaseFdtLib/libfdt | 1 + ReadMe.rst | 1 + 3 files changed, 5 insertions(+) diff --git a/.gitmodules b/.gitmodules index fe8a43be93..b1888c3488 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,6 @@ [submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"] path = UnitTestFrameworkPkg/Library/SubhookLib/subhook url = https://github.com/Zeex/subhook.git +[submodule "MdePkg/Library/BaseFdtLib/libfdt"] + path = MdePkg/Library/BaseFdtLib/libfdt + url = https://github.com/devicetree-org/pylibfdt.git diff --git a/MdePkg/Library/BaseFdtLib/libfdt b/MdePkg/Library/BaseFdtLib/libfdt new file mode 16 index 00..cfff805481 --- /dev/null +++ b/MdePkg/Library/BaseFdtLib/libfdt @@ -0,0 +1 @@ +Subproject commit cfff805481bdea27f900c32698171286542b8d3c diff --git a/ReadMe.rst b/ReadMe.rst index 91b9cf3c5e..d46c534229 100644 --- a/ReadMe.rst +++ b/ReadMe.rst @@ -96,6 +96,7 @@ that are covered by additional licenses. - `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest <https://github.com/google/googletest/blob/86add13493e5c881d7e4ba77fb91c1f57752b3a4/LICENSE>`__ - `UnitTestFrameworkPkg/Library/SubhookLib/subhook <https://github.com/Zeex/subhook/blob/83d4e1ebef3588fae48b69a7352cc21801cb70bc/LICENSE.txt>`__ - `RedfishPkg/Library/JsonLib/jansson <https://github.com/akheron/jansson/blob/2882ead5bb90cf12a01b07b2c2361e24960fae02/LICENSE>`__ +- `MdePkg/Library/BaseFdtLib/libfdt <https://github.com/devicetree-org/pylibfdt/blob/f39368a217496d32c4091a2dba4045b60649e3a5/BSD-2-Clause>`__ The EDK II Project is composed of packages. The maintainers for each package are listed in `Maintainers.txt `__. -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103761): https://edk2.groups.io/g/devel/message/103761 Mute This Topic: https://groups.io/mt/98553641/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v5 3/3] .pytool: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add RequiredSubmodule object for CI setting. Reviewed-by: Michael D Kinney Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Benny Lin --- .pytool/CISettings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index e3f44add58..2fb99f2a17 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -195,6 +195,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag "RedfishPkg/Library/JsonLib/jansson", False)) rs.append(RequiredSubmodule( "UnitTestFrameworkPkg/Library/SubhookLib/subhook", False)) +rs.append(RequiredSubmodule( +"MdePkg/Library/BaseFdtLib/libfdt", False)) return rs def GetName(self): -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103763): https://edk2.groups.io/g/devel/message/103763 Mute This Topic: https://groups.io/mt/98553643/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v5 2/3] MdePkg: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) and refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Acked-by: Pedro Falcato Signed-off-by: Benny Lin --- MdePkg/Include/Library/FdtLib.h | 311 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++ MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 +++ MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++ MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 15 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + 15 files changed, 1039 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index 00..1894de6dc3 --- /dev/null +++ b/MdePkg/Include/Library/FdtLib.h @@ -0,0 +1,311 @@ +/** @file + Flattened Device Tree Library. + + All structure data are in big-endian format. Need to call SwapBytes** + function to convert between little-endia and big-endian. + For example, pushing data to FDT blob need convert to big-endian with SwapByte**. + For retrieving data from FDT blob need translate to little-endian with SwapByte**. + Refer to FDT specification: https://www.devicetree.org/specifications/ + + Copyright (c) 2023, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FDT_LIB_H_ +#define FDT_LIB_H_ + +/** + Flattened Device Tree definition + + The Devicetree Blob (DTB) format is a binary encoding with big-endian. + When producing or consuming the blob data, must translate with SwapBytesXX + provided by edk2 BaseLib between big-endian and little-endian. +**/ +typedef struct { + UINT32Magic; /* magic word FDT_MAGIC */ + UINT32TotalSize; /* total size of DT block */ + UINT32OffsetDtStruct; /* offset to structure */ + UINT32OffsetDtStrings; /* offset to strings */ + UINT32OffsetMemRsvmap; /* offset to memory reserve map */ + UINT32Version; /* format version */ + UINT32LastCompVersion; /* last compatible version */ + + /* version 2 fields below */ + UINT32BootCpuidPhys; /* Which physical CPU id we're +booting on */ + /* version 3 fields below */ + UINT32SizeDtStrings; /* size of the strings block */ + + /* version 17 fields below */ + UINT32SizeDtStruct;/* size of the structure block */ +} FDT_HEADER; + +typedef struct { + UINT64Address; + UINT64Size; +} FDT_RESERVE_ENTRY; + +typedef struct { + UINT32Tag; + CHAR8 Name[]; +} FDT_NODE_HEADER; + +typedef struct { + UINT32Tag; + UINT32Length; + UINT32NameOffset; + CHAR8 Data[]; +} FDT_PROPERTY; + +/** + Verify the header of the Flattened Device Tree + + @param[in] FdtThe pointer to FDT blob. + + @return Zero for successfully, otherwise failed. + +**/ +INT32 +EFIAPI +FdtCheckHeader ( + IN CONST VOID *Fdt + ); + +/** + Create a empty Flattened Device Tree. + + @param[in] Buffer The pointer to allocate a pool for FDT blob. + @param[in] BufferSize The BufferSize to the pool size. + + @return Zero for successfully, otherwise failed. + +**/ +RETURN_STATUS +EFIAPI +FdtCreateEmptyTree ( + IN VOID *Buffer, + IN UINTN BufferSize + ); + +/** + Returns a offset of next node from the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + @param[in] Depth The depth to the level of tree hierarchy. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtNextNode ( + IN CONST VOID *Fdt, + IN INT32 Offset, + IN INT32 *Depth + ); + +/** + Returns a offset of first node under the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtFirstSubnode ( + IN CONST VOID *Fdt, + IN INT32 Offset + ); + +/** + Returns a offset of next node from the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtNextSubnode ( + IN CONST VOID *Fdt, + IN INT32 O
[edk2-devel] [PATCH v6 0/3] Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) and refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Sean Brogan Cc: Michael Kubacki Acked-by: Pedro Falcato Signed-off-by: Benny Lin Benny Lin (3): Tianocore: Support FDT library. MdePkg: Support FDT library. .pytool: Support FDT library. .gitmodules | 3 + .pytool/CISettings.py | 2 + MdePkg/Include/Library/FdtLib.h | 396 +++ MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 +++ MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 404 MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 + MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 + MdePkg/Library/BaseFdtLib/libfdt | 1 + MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 15 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + ReadMe.rst| 1 + 19 files changed, 1234 insertions(+), 1 deletion(-) create mode 100644 MdePkg/Include/Library/FdtLib.h create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni create mode 100644 MdePkg/Library/BaseFdtLib/FdtLib.c create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtSupport.h create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c create mode 16 MdePkg/Library/BaseFdtLib/libfdt create mode 100644 MdePkg/Library/BaseFdtLib/limits.h create mode 100644 MdePkg/Library/BaseFdtLib/stdbool.h create mode 100644 MdePkg/Library/BaseFdtLib/stddef.h create mode 100644 MdePkg/Library/BaseFdtLib/stdint.h create mode 100644 MdePkg/Library/BaseFdtLib/stdlib.h create mode 100644 MdePkg/Library/BaseFdtLib/string.h -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103955): https://edk2.groups.io/g/devel/message/103955 Mute This Topic: https://groups.io/mt/98678641/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v6 1/3] Tianocore: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add submodule libfdt and update ReadMe for the licence. Reviewed-by: Leif Lindholm Reviewed-by: Michael D Kinney Cc: Andrew Fish Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Benny Lin --- .gitmodules | 3 +++ MdePkg/Library/BaseFdtLib/libfdt | 1 + ReadMe.rst | 1 + 3 files changed, 5 insertions(+) diff --git a/.gitmodules b/.gitmodules index fe8a43be93..b1888c3488 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,6 @@ [submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"] path = UnitTestFrameworkPkg/Library/SubhookLib/subhook url = https://github.com/Zeex/subhook.git +[submodule "MdePkg/Library/BaseFdtLib/libfdt"] + path = MdePkg/Library/BaseFdtLib/libfdt + url = https://github.com/devicetree-org/pylibfdt.git diff --git a/MdePkg/Library/BaseFdtLib/libfdt b/MdePkg/Library/BaseFdtLib/libfdt new file mode 16 index 00..cfff805481 --- /dev/null +++ b/MdePkg/Library/BaseFdtLib/libfdt @@ -0,0 +1 @@ +Subproject commit cfff805481bdea27f900c32698171286542b8d3c diff --git a/ReadMe.rst b/ReadMe.rst index 91b9cf3c5e..d46c534229 100644 --- a/ReadMe.rst +++ b/ReadMe.rst @@ -96,6 +96,7 @@ that are covered by additional licenses. - `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest <https://github.com/google/googletest/blob/86add13493e5c881d7e4ba77fb91c1f57752b3a4/LICENSE>`__ - `UnitTestFrameworkPkg/Library/SubhookLib/subhook <https://github.com/Zeex/subhook/blob/83d4e1ebef3588fae48b69a7352cc21801cb70bc/LICENSE.txt>`__ - `RedfishPkg/Library/JsonLib/jansson <https://github.com/akheron/jansson/blob/2882ead5bb90cf12a01b07b2c2361e24960fae02/LICENSE>`__ +- `MdePkg/Library/BaseFdtLib/libfdt <https://github.com/devicetree-org/pylibfdt/blob/f39368a217496d32c4091a2dba4045b60649e3a5/BSD-2-Clause>`__ The EDK II Project is composed of packages. The maintainers for each package are listed in `Maintainers.txt `__. -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103956): https://edk2.groups.io/g/devel/message/103956 Mute This Topic: https://groups.io/mt/98678642/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v6 3/3] .pytool: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add RequiredSubmodule object for CI setting. Reviewed-by: Michael D Kinney Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Benny Lin --- .pytool/CISettings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index e3f44add58..2fb99f2a17 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -195,6 +195,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag "RedfishPkg/Library/JsonLib/jansson", False)) rs.append(RequiredSubmodule( "UnitTestFrameworkPkg/Library/SubhookLib/subhook", False)) +rs.append(RequiredSubmodule( +"MdePkg/Library/BaseFdtLib/libfdt", False)) return rs def GetName(self): -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103958): https://edk2.groups.io/g/devel/message/103958 Mute This Topic: https://groups.io/mt/98678644/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v6 2/3] MdePkg: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) and refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Acked-by: Pedro Falcato Signed-off-by: Benny Lin --- MdePkg/Include/Library/FdtLib.h | 396 +++ MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 +++ MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 404 MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 + MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 + MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 15 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + 15 files changed, 1227 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index 00..4b428eb5d1 --- /dev/null +++ b/MdePkg/Include/Library/FdtLib.h @@ -0,0 +1,396 @@ +/** @file + Flattened Device Tree Library. + + All structure data are in big-endian format. Need to call SwapBytes** + function to convert between little-endia and big-endian. + For example, pushing data to FDT blob need convert to big-endian with SwapByte**. + For retrieving data from FDT blob need convert to little-endian with SwapByte**. + Refer to FDT specification: https://www.devicetree.org/specifications/ + + Copyright (c) 2023, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FDT_LIB_H_ +#define FDT_LIB_H_ + +/** + Flattened Device Tree definition + + The Devicetree Blob (DTB) format is a binary encoding with big-endian. + When producing or consuming the blob data, must convert with SwapBytesXX + provided by edk2 BaseLib between big-endian and little-endian. +**/ +typedef struct { + UINT32Magic; /* magic word FDT_MAGIC */ + UINT32TotalSize; /* total size of DT block */ + UINT32OffsetDtStruct; /* offset to structure */ + UINT32OffsetDtStrings; /* offset to strings */ + UINT32OffsetMemRsvmap; /* offset to memory reserve map */ + UINT32Version; /* format version */ + UINT32LastCompVersion; /* last compatible version */ + + /* version 2 fields below */ + UINT32BootCpuidPhys; /* Which physical CPU id we're +booting on */ + /* version 3 fields below */ + UINT32SizeDtStrings; /* size of the strings block */ + + /* version 17 fields below */ + UINT32SizeDtStruct;/* size of the structure block */ +} FDT_HEADER; + +typedef struct { + UINT64Address; + UINT64Size; +} FDT_RESERVE_ENTRY; + +typedef struct { + UINT32Tag; + CHAR8 Name[]; +} FDT_NODE_HEADER; + +typedef struct { + UINT32Tag; + UINT32Length; + UINT32NameOffset; + CHAR8 Data[]; +} FDT_PROPERTY; + +/** + Convert UINT16 data of the FDT blob to little-endian + + @param[in] ValueThe value to the blob data. + + @return The value to be converted to little-endian. + +**/ +UINT16 +EFIAPI +Fdt16ToCpu ( + IN UINT16 Value + ); + +/** + Convert UINT16 data to big-endian for aligned with the FDT blob + + @param[in] ValueThe value to align with the FDT blob. + + @return The value to be converted to big-endian. + +**/ +UINT16 +EFIAPI +CpuToFdt16 ( + IN UINT16 Value + ); + +/** + Convert UINT32 data of the FDT blob to little-endian + + @param[in] ValueThe value to the blob data. + + @return The value to be converted to little-endian. + +**/ +UINT32 +EFIAPI +Fdt32ToCpu ( + IN UINT32 Value + ); + +/** + Convert UINT32 data to big-endian for aligned with the FDT blob + + @param[in] ValueThe value to align with the FDT blob. + + @return The value to be converted to big-endian. + +**/ +UINT32 +EFIAPI +CpuToFdt32 ( + IN UINT32 Value + ); + +/** + Convert UINT64 data of the FDT blob to little-endian + + @param[in] ValueThe value to the blob data. + + @return The value to be converted to little-endian. + +**/ +UINT64 +EFIAPI +Fdt64ToCpu ( + IN UINT64 Value + ); + +/** + Convert UINT64 data to big-endian for aligned with the FDT blob + + @param[in] ValueThe value to align with the FDT blob. + + @return The value to be converted to big-endian. + +**/ +UINT64 +EFIAPI +CpuToFdt64 ( + IN UINT64 Value + ); + +/** + Verify the header of the Flattened Device Tree + + @param[in] FdtThe pointer t
Re: [edk2-devel] [PATCH v1 1/1] Maintainers.txt: Update reviewers and maintainers for FdtLib. Update reviewers and maintainers for FdtLib.
Series Reviewed-by : Benny Lin -Original Message- From: Guo, Gua Sent: Friday, May 12, 2023 10:11 AM To: devel@edk2.groups.io Cc: Guo, Gua ; Kinney, Michael D ; Andrew Fish ; Leif Lindholm ; Lin, Benny ; Chiu, Chasel ; Lu, James Subject: [PATCH v1 1/1] Maintainers.txt: Update reviewers and maintainers for FdtLib. Update reviewers and maintainers for FdtLib. From: Gua Guo Cc: Michael D Kinney Cc: Andrew Fish Cc: Leif Lindholm Cc: Benny Lin Cc: Gua Guo Cc: Chasel Chiu Cc: James Lu Signed-off-by: Guo Gua --- Maintainers.txt | 8 1 file changed, 8 insertions(+) diff --git a/Maintainers.txt b/Maintainers.txt index 30e2d2686d..97886accd5 100644 --- a/Maintainers.txt +++ b/Maintainers.txt @@ -462,6 +462,14 @@ M: Prakashan Krishnadas Veliyathuparambil [lauracha] R: K N Karthik [karthikkabbigere1] +MdePkg: FDT related library instance+F: MdePkg/Library/BaseFdtLib/FdtLib.c+F: MdePkg/Include/Library/FdtLib.h+M: Benny Lin [Benny3345678]+R: Gua Guo [gguo11837463]+R: Chasel Chiu [ChaselChiu]+R: James Lu [jameslu8]+ NetworkPkg F: NetworkPkg/ W: https://github.com/tianocore/tianocore.github.io/wiki/NetworkPkg-- 2.39.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#104734): https://edk2.groups.io/g/devel/message/104734 Mute This Topic: https://groups.io/mt/98841641/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH 0/2] Support FDT library.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Sean Brogan Cc: Michael Kubacki Signed-off-by: Benny Lin Benny Lin (2): MdePkg: Support FDT library. .pytool: Support FDT library. .gitmodules | 3 + .pytool/CISettings.py | 2 + MdePkg/Include/Library/FdtLib.h | 300 ++ MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 + MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 284 MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++ MdePkg/Library/BaseFdtLib/libfdt | 1 + MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 17 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 2 + ReadMe.rst| 1 + 19 files changed, 988 insertions(+), 2 deletions(-) create mode 100644 MdePkg/Include/Library/FdtLib.h create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni create mode 100644 MdePkg/Library/BaseFdtLib/FdtLib.c create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtSupport.h create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c create mode 16 MdePkg/Library/BaseFdtLib/libfdt create mode 100644 MdePkg/Library/BaseFdtLib/limits.h create mode 100644 MdePkg/Library/BaseFdtLib/stdbool.h create mode 100644 MdePkg/Library/BaseFdtLib/stddef.h create mode 100644 MdePkg/Library/BaseFdtLib/stdint.h create mode 100644 MdePkg/Library/BaseFdtLib/stdlib.h create mode 100644 MdePkg/Library/BaseFdtLib/string.h -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102200): https://edk2.groups.io/g/devel/message/102200 Mute This Topic: https://groups.io/mt/97955736/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH 2/2] .pytool: Support FDT library.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add RequiredSubmodule object for CI setting. Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Benny Lin --- .pytool/CISettings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index d87c8e838e..126c9f0164 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -193,6 +193,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag "BaseTools/Source/C/BrotliCompress/brotli", False)) rs.append(RequiredSubmodule( "RedfishPkg/Library/JsonLib/jansson", False)) +rs.append(RequiredSubmodule( +"MdePkg/Library/BaseFdtLib/libfdt", False)) return rs def GetName(self): -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102202): https://edk2.groups.io/g/devel/message/102202 Mute This Topic: https://groups.io/mt/97955740/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH 1/2] MdePkg: Support FDT library.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Benny Lin --- .gitmodules | 3 + MdePkg/Include/Library/FdtLib.h | 300 ++ MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 + MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 284 MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++ MdePkg/Library/BaseFdtLib/libfdt | 1 + MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 17 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 2 + ReadMe.rst| 1 + 18 files changed, 986 insertions(+), 2 deletions(-) create mode 100644 MdePkg/Include/Library/FdtLib.h create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni create mode 100644 MdePkg/Library/BaseFdtLib/FdtLib.c create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtSupport.h create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c create mode 16 MdePkg/Library/BaseFdtLib/libfdt create mode 100644 MdePkg/Library/BaseFdtLib/limits.h create mode 100644 MdePkg/Library/BaseFdtLib/stdbool.h create mode 100644 MdePkg/Library/BaseFdtLib/stddef.h create mode 100644 MdePkg/Library/BaseFdtLib/stdint.h create mode 100644 MdePkg/Library/BaseFdtLib/stdlib.h create mode 100644 MdePkg/Library/BaseFdtLib/string.h diff --git a/.gitmodules b/.gitmodules index 8011a88d9d..5da342e90c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,3 +23,6 @@ [submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"] path = UnitTestFrameworkPkg/Library/GoogleTestLib/googletest url = https://github.com/google/googletest.git +[submodule "MdePkg/Library/BaseFdtLib/libfdt"] + path = MdePkg/Library/BaseFdtLib/libfdt + url = https://github.com/devicetree-org/pylibfdt.git diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index 00..bcb097b77e --- /dev/null +++ b/MdePkg/Include/Library/FdtLib.h @@ -0,0 +1,300 @@ +/** @file + Flattened Device Tree Library. + + Copyright (c) 2023, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FDT_LIB_H_ +#define FDT_LIB_H_ + +/// +/// Flattened Device Tree definition +/// +typedef struct { + UINT32Magic; /* magic word FDT_MAGIC */ + UINT32TotalSize; /* total size of DT block */ + UINT32OffsetDtStruct; /* offset to structure */ + UINT32OffsetDtStrings; /* offset to strings */ + UINT32OffsetMemRsvmap; /* offset to memory reserve map */ + UINT32Version; /* format version */ + UINT32LastCompVersion; /* last compatible version */ + + /* version 2 fields below */ + UINT32BootCpuidPhys; /* Which physical CPU id we're +booting on */ + /* version 3 fields below */ + UINT32SizeDtStrings; /* size of the strings block */ + + /* version 17 fields below */ + UINT32SizeDtStruct;/* size of the structure block */ +} FDT_HEADER; + +typedef struct { + UINT64Address; + UINT64Size; +} FDT_RESERVE_ENTRY; + +typedef struct { + UINT32Tag; + CHAR8 Name[]; +} FDT_NODE_HEADER; + +typedef struct { + UINT32Tag; + UINT32Length; + UINT32NameOffset; + CHAR8 Data[]; +} FDT_PROPERTY; + +#define FDT_GET_HEADER(Fdt, Field) FDT32_TO_CPU(((CONST FDT_HEADER *)(Fdt))->Field) + +#define FDT_MAGIC(Fdt) (FDT_GET_HEADER(Fdt, Magic)) +#define FDT_TOTAL_SIZE(Fdt) (FDT_GET_HEADER(Fdt, TotalSize)) +#define FDT_OFFSET_DT_STRUCT(Fdt) (FDT_GET_HEADER(Fdt, OffsetDtStruct)) +#define FDT_OFFSET_DT_STRINGS(Fdt) (FDT_GET_HEADER(Fdt, OffsetDtStrings)) +#define FDT_OFFSET_MEM_RSVMAP(Fdt) (FDT_GET_HEADER(Fdt, OffsetMemRsvmap)) +#define FDT_VERSION(Fdt)(FDT_GET_HEADER(Fdt, Version)) +#define FDT_LAST_COMP_VERSION(Fdt) (FDT_GET_HEADER(Fdt, LastCompVersion)) +#define FDT_BOOT_CPUID_PHYS(Fdt)(FDT_GET_HEADER(Fdt, BootCpuidPhys)) +#define FDT_SIZE_DT_STRINGS(Fdt)(FDT_GET_HEADER(Fdt, SizeDtStrings)) +#define FDT_SIZE_DT_STRUCT(Fdt) (FDT_GET_HEADER(Fdt, SizeDtStruct)) + +/** + Create a empty Flattened Device Tree. + + @param[in] Buffer The po
[edk2-devel] [PATCH v2] MdePkg: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) 1. Correct the typo. 2. Remove no use definitions from LibFdtSupport.h. 3. Refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Chasel Chiu Cc: James Lu Cc: Gua Guo Cc: Pedro Falcato Signed-off-by: Benny Lin --- MdePkg/Include/Library/FdtLib.h | 2 +- MdePkg/Library/BaseFdtLib/FdtLib.c| 2 +- MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 6 +- MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 215 +++- 4 files changed, 125 insertions(+), 100 deletions(-) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h index bcb097b77e..d1e67c773f 100644 --- a/MdePkg/Include/Library/FdtLib.h +++ b/MdePkg/Include/Library/FdtLib.h @@ -276,7 +276,7 @@ FdtAddSubnode ( ); /** - Add or modify a porperty in the given node. + Add or modify a property in the given node. @param[in] FdtThe pointer to FDT blob. @param[in] NodeOffset The offset to the node offset which want to add in. diff --git a/MdePkg/Library/BaseFdtLib/FdtLib.c b/MdePkg/Library/BaseFdtLib/FdtLib.c index ba9a284e58..877c832c50 100644 --- a/MdePkg/Library/BaseFdtLib/FdtLib.c +++ b/MdePkg/Library/BaseFdtLib/FdtLib.c @@ -259,7 +259,7 @@ FdtAddSubnode ( } /** - Add or modify a porperty in the given node. + Add or modify a property in the given node. @param[in] FdtThe pointer to FDT blob. @param[in] NodeOffset The offset to the node offset which want to add in. diff --git a/MdePkg/Library/BaseFdtLib/LibFdtSupport.h b/MdePkg/Library/BaseFdtLib/LibFdtSupport.h index 58b0bb403e..92d7bf0946 100644 --- a/MdePkg/Library/BaseFdtLib/LibFdtSupport.h +++ b/MdePkg/Library/BaseFdtLib/LibFdtSupport.h @@ -29,12 +29,10 @@ typedef BOOLEAN bool; // // Definitions for global constants used by libfdt library routines // -#ifndef INT_MAX -#define INT_MAX 0x7FFF /* Maximum (signed) int value */ -#endif +#define INT_MAX 0x7FFF /* Maximum (signed) int value */ #define INT32_MAX0x7FFF /* Maximum (signed) int32 value */ #define UINT32_MAX 0x /* Maximum unsigned int32 value */ -#define MAX_STRING_SIZE 0x1000 +#define ULONG_MAX0x /* Maximum unsigned long value */ // // Function prototypes of libfdt Library routines diff --git a/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c b/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c index 3f1cc69dc6..50b533a2b0 100644 --- a/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c +++ b/MdePkg/Library/BaseFdtLib/LibFdtWrapper.c @@ -8,131 +8,158 @@ **/ #include "LibFdtSupport.h" -#include -/** - Returns the first occurrence of a Null-terminated ASCII character - in a Null-terminated ASCII string. +char * +strchr ( + const char *Str, + int Char + ) +{ + char *S; - This function scans the contents of the ASCII string specified by s - and returns the first occurrence of c. If c is not found in s, - then NULL is returned. If the length of c is zero, then s is returned. + S = (char *)Str; - @param s The pointer to a Null-terminated ASCII string. - @param c The pointer to a Null-terminated ASCII character to search for. + for ( ; ; S++) { +if (*S == Char) { + return S; +} - @retval NULLIf the c does not appear in s. - @retval others If there is a match return the first occurrence of c. - If the length of c is zero,return s. +if (*S == '\0') { + return NULL; +} + } +} -**/ char * -strchr ( - const char *s, - int c +strrchr ( + const char *Str, + int Char ) { - char pattern[2]; + char *S, *last; - pattern[0] = (CHAR8)c; - pattern[1] = 0; - return AsciiStrStr (s, pattern); -} + S= (char *)Str; + last = NULL; -/** - Returns the last occurrence of a Null-terminated ASCII character - in a Null-terminated ASCII string. - - This function scans the contents of the ASCII string specified by s - and returns the last occurrence of c. If c is not found in s, - then NULL is returned. If the length of c is zero, then s is returned. + for ( ; ; S++) { +if (*S == Char) { + last = S; +} - @param s The pointer to a Null-terminated ASCII string. - @param c The pointer to a Null-terminated ASCII character to search for. +if (*S == '\0') { + return last; +} + } +} - @retval NULLIf the c does not appear in s. - @retval others If there is a match return the last occurrence of c. - If the length of c is zero,return s. +STATIC +int +__isspace ( + int ch + ) +{ + // basic ASCII ctype.h:isspace(). Not effici
Re: [edk2-devel] [PATCH 1/2] MdePkg: Support FDT library.
Hi, Pedro, Thanks for your feedback. Sorry for the late response. Please find below my comment. -Original Message- From: Pedro Falcato Sent: Friday, March 31, 2023 7:19 AM To: devel@edk2.groups.io; Lin, Benny Cc: Kinney, Michael D ; Gao, Liming ; Liu, Zhiguang Subject: Re: [edk2-devel] [PATCH 1/2] MdePkg: Support FDT library. On Thu, Mar 30, 2023 at 6:13 PM Benny Lin wrote: >> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 >> Add FDT support in EDK2 by submodule 3rd party libfdt >> (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) >> >> Cc: Michael D Kinney >> Cc: Liming Gao >> Cc: Zhiguang Liu >> Signed-off-by: Benny Lin >> --- >> .gitmodules | 3 + >> MdePkg/Include/Library/FdtLib.h | 300 ++ >> MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 + >> MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + >> MdePkg/Library/BaseFdtLib/FdtLib.c| 284 >> MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 102 >> MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 138 ++ >> MdePkg/Library/BaseFdtLib/libfdt | 1 + >> MdePkg/Library/BaseFdtLib/limits.h| 10 + >> MdePkg/Library/BaseFdtLib/stdbool.h | 10 + >> MdePkg/Library/BaseFdtLib/stddef.h| 10 + >> MdePkg/Library/BaseFdtLib/stdint.h| 10 + >> MdePkg/Library/BaseFdtLib/stdlib.h| 10 + >> MdePkg/Library/BaseFdtLib/string.h| 10 + >> MdePkg/MdePkg.ci.yaml | 17 +- >> MdePkg/MdePkg.dec | 4 + >> MdePkg/MdePkg.dsc | 2 + >> ReadMe.rst| 1 + >> 18 files changed, 986 insertions(+), 2 deletions(-) create mode >> 100644 MdePkg/Include/Library/FdtLib.h create mode 100644 >> MdePkg/Library/BaseFdtLib/BaseFdtLib.inf >> create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni >> create mode 100644 MdePkg/Library/BaseFdtLib/FdtLib.c >> create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtSupport.h >> create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c >> create mode 16 MdePkg/Library/BaseFdtLib/libfdt create mode >> 100644 MdePkg/Library/BaseFdtLib/limits.h >> create mode 100644 MdePkg/Library/BaseFdtLib/stdbool.h >> create mode 100644 MdePkg/Library/BaseFdtLib/stddef.h >> create mode 100644 MdePkg/Library/BaseFdtLib/stdint.h >> create mode 100644 MdePkg/Library/BaseFdtLib/stdlib.h >> create mode 100644 MdePkg/Library/BaseFdtLib/string.h >> >> diff --git a/.gitmodules b/.gitmodules index 8011a88d9d..5da342e90c >> 100644 >> --- a/.gitmodules >> +++ b/.gitmodules >> @@ -23,3 +23,6 @@ >> [submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"] >> path = UnitTestFrameworkPkg/Library/GoogleTestLib/googletest >> url = https://github.com/google/googletest.git >> +[submodule "MdePkg/Library/BaseFdtLib/libfdt"] >> + path = MdePkg/Library/BaseFdtLib/libfdt >> + url = https://github.com/devicetree-org/pylibfdt.git >> diff --git a/MdePkg/Include/Library/FdtLib.h >> b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index >> 00..bcb097b77e >> --- /dev/null >> +++ b/MdePkg/Include/Library/FdtLib.h >> @@ -0,0 +1,300 @@ >> +/** @file >> + Flattened Device Tree Library. >> + >> + Copyright (c) 2023, Intel Corporation. All rights reserved. >> + SPDX-License-Identifier: BSD-2-Clause-Patent >> + >> +**/ >> + >> +#ifndef FDT_LIB_H_ >> +#define FDT_LIB_H_ >> + >> +/// >> +/// Flattened Device Tree definition >> +/// >> +typedef struct { >> + UINT32Magic; /* magic word FDT_MAGIC */ >> + UINT32TotalSize; /* total size of DT block */ >> + UINT32OffsetDtStruct; /* offset to structure */ >> + UINT32OffsetDtStrings; /* offset to strings */ >> + UINT32OffsetMemRsvmap; /* offset to memory reserve map */ >> + UINT32Version; /* format version */ >> + UINT32LastCompVersion; /* last compatible version */ >> + >> + /* version 2 fields below */ >> + UINT32BootCpuidPhys; /* Which physical CPU id we're >> +booting on */ >> + /* version 3 fields below */ >> + UINT32SizeDtStrings; /* size of the strings block */ >> + >> + /* version 17 fields below */ >> + UINT32SizeDtStruct;/* size of the stru
[edk2-devel] [PATCH v2 1/3] Tianocore: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add submodule libfdt and update ReadMe for the licence. Cc: Andrew Fish Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Benny Lin --- .gitmodules | 3 +++ MdePkg/Library/BaseFdtLib/libfdt | 1 + ReadMe.rst | 1 + 3 files changed, 5 insertions(+) diff --git a/.gitmodules b/.gitmodules index fe8a43be93..b1888c3488 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,6 @@ [submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"] path = UnitTestFrameworkPkg/Library/SubhookLib/subhook url = https://github.com/Zeex/subhook.git +[submodule "MdePkg/Library/BaseFdtLib/libfdt"] + path = MdePkg/Library/BaseFdtLib/libfdt + url = https://github.com/devicetree-org/pylibfdt.git diff --git a/MdePkg/Library/BaseFdtLib/libfdt b/MdePkg/Library/BaseFdtLib/libfdt new file mode 16 index 00..cfff805481 --- /dev/null +++ b/MdePkg/Library/BaseFdtLib/libfdt @@ -0,0 +1 @@ +Subproject commit cfff805481bdea27f900c32698171286542b8d3c diff --git a/ReadMe.rst b/ReadMe.rst index 91b9cf3c5e..d46c534229 100644 --- a/ReadMe.rst +++ b/ReadMe.rst @@ -96,6 +96,7 @@ that are covered by additional licenses. - `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest <https://github.com/google/googletest/blob/86add13493e5c881d7e4ba77fb91c1f57752b3a4/LICENSE>`__ - `UnitTestFrameworkPkg/Library/SubhookLib/subhook <https://github.com/Zeex/subhook/blob/83d4e1ebef3588fae48b69a7352cc21801cb70bc/LICENSE.txt>`__ - `RedfishPkg/Library/JsonLib/jansson <https://github.com/akheron/jansson/blob/2882ead5bb90cf12a01b07b2c2361e24960fae02/LICENSE>`__ +- `MdePkg/Library/BaseFdtLib/libfdt <https://github.com/devicetree-org/pylibfdt/blob/f39368a217496d32c4091a2dba4045b60649e3a5/BSD-2-Clause>`__ The EDK II Project is composed of packages. The maintainers for each package are listed in `Maintainers.txt `__. -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102912): https://edk2.groups.io/g/devel/message/102912 Mute This Topic: https://groups.io/mt/98225692/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v2 0/3] Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Sean Brogan Cc: Michael Kubacki Signed-off-by: Benny Lin Benny Lin (3): Tianocore: Support FDT library. MdePkg: Support FDT library. .pytool: Support FDT library. .gitmodules | 3 + .pytool/CISettings.py | 2 + MdePkg/Include/Library/FdtLib.h | 300 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 284 ++ MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 100 +++ MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 165 +++ MdePkg/Library/BaseFdtLib/libfdt | 1 + MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 17 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + ReadMe.rst| 1 + 19 files changed, 1012 insertions(+), 2 deletions(-) create mode 100644 MdePkg/Include/Library/FdtLib.h create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni create mode 100644 MdePkg/Library/BaseFdtLib/FdtLib.c create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtSupport.h create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c create mode 16 MdePkg/Library/BaseFdtLib/libfdt create mode 100644 MdePkg/Library/BaseFdtLib/limits.h create mode 100644 MdePkg/Library/BaseFdtLib/stdbool.h create mode 100644 MdePkg/Library/BaseFdtLib/stddef.h create mode 100644 MdePkg/Library/BaseFdtLib/stdint.h create mode 100644 MdePkg/Library/BaseFdtLib/stdlib.h create mode 100644 MdePkg/Library/BaseFdtLib/string.h -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102911): https://edk2.groups.io/g/devel/message/102911 Mute This Topic: https://groups.io/mt/98225691/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v2 2/3] MdePkg: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) 1. Correct the typo. 2. Remove no use definitions from LibFdtSupport.h. 3. Refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Benny Lin --- MdePkg/Include/Library/FdtLib.h | 300 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 284 ++ MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 100 +++ MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 165 +++ MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 17 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + 15 files changed, 1005 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index 00..d1e67c773f --- /dev/null +++ b/MdePkg/Include/Library/FdtLib.h @@ -0,0 +1,300 @@ +/** @file + Flattened Device Tree Library. + + Copyright (c) 2023, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FDT_LIB_H_ +#define FDT_LIB_H_ + +/// +/// Flattened Device Tree definition +/// +typedef struct { + UINT32Magic; /* magic word FDT_MAGIC */ + UINT32TotalSize; /* total size of DT block */ + UINT32OffsetDtStruct; /* offset to structure */ + UINT32OffsetDtStrings; /* offset to strings */ + UINT32OffsetMemRsvmap; /* offset to memory reserve map */ + UINT32Version; /* format version */ + UINT32LastCompVersion; /* last compatible version */ + + /* version 2 fields below */ + UINT32BootCpuidPhys; /* Which physical CPU id we're +booting on */ + /* version 3 fields below */ + UINT32SizeDtStrings; /* size of the strings block */ + + /* version 17 fields below */ + UINT32SizeDtStruct;/* size of the structure block */ +} FDT_HEADER; + +typedef struct { + UINT64Address; + UINT64Size; +} FDT_RESERVE_ENTRY; + +typedef struct { + UINT32Tag; + CHAR8 Name[]; +} FDT_NODE_HEADER; + +typedef struct { + UINT32Tag; + UINT32Length; + UINT32NameOffset; + CHAR8 Data[]; +} FDT_PROPERTY; + +#define FDT_GET_HEADER(Fdt, Field) FDT32_TO_CPU(((CONST FDT_HEADER *)(Fdt))->Field) + +#define FDT_MAGIC(Fdt) (FDT_GET_HEADER(Fdt, Magic)) +#define FDT_TOTAL_SIZE(Fdt) (FDT_GET_HEADER(Fdt, TotalSize)) +#define FDT_OFFSET_DT_STRUCT(Fdt) (FDT_GET_HEADER(Fdt, OffsetDtStruct)) +#define FDT_OFFSET_DT_STRINGS(Fdt) (FDT_GET_HEADER(Fdt, OffsetDtStrings)) +#define FDT_OFFSET_MEM_RSVMAP(Fdt) (FDT_GET_HEADER(Fdt, OffsetMemRsvmap)) +#define FDT_VERSION(Fdt)(FDT_GET_HEADER(Fdt, Version)) +#define FDT_LAST_COMP_VERSION(Fdt) (FDT_GET_HEADER(Fdt, LastCompVersion)) +#define FDT_BOOT_CPUID_PHYS(Fdt)(FDT_GET_HEADER(Fdt, BootCpuidPhys)) +#define FDT_SIZE_DT_STRINGS(Fdt)(FDT_GET_HEADER(Fdt, SizeDtStrings)) +#define FDT_SIZE_DT_STRUCT(Fdt) (FDT_GET_HEADER(Fdt, SizeDtStruct)) + +/** + Create a empty Flattened Device Tree. + + @param[in] Buffer The pointer to allocate a pool for FDT blob. + @param[in] BufferSize The BufferSize to the pool size. + + @return Zero for successfully, otherwise failed. + +**/ +RETURN_STATUS +EFIAPI +FdtCreateEmptyTree ( + IN VOID *Buffer, + IN UINTN BufferSize + ); + +/** + Returns a offset of next node from the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + @param[in] Depth The depth to the level of tree hierarchy. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtNextNode ( + IN CONST VOID *Fdt, + IN INT32 Offset, + IN INT32 *Depth + ); + +/** + Returns a offset of first node under the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtFirstSubnode ( + IN CONST VOID *Fdt, + IN INT32 Offset + ); + +/** + Returns a offset of next node from the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtNextSubnode ( + IN CONST VO
[edk2-devel] [PATCH v2 3/3] .pytool: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add RequiredSubmodule object for CI setting. Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Benny Lin --- .pytool/CISettings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index e3f44add58..2fb99f2a17 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -195,6 +195,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag "RedfishPkg/Library/JsonLib/jansson", False)) rs.append(RequiredSubmodule( "UnitTestFrameworkPkg/Library/SubhookLib/subhook", False)) +rs.append(RequiredSubmodule( +"MdePkg/Library/BaseFdtLib/libfdt", False)) return rs def GetName(self): -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102914): https://edk2.groups.io/g/devel/message/102914 Mute This Topic: https://groups.io/mt/98225695/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] FW: [PATCH v2 2/3] MdePkg: Support FDT library.
Hi, Pedro, Sorry. I will update copyright in Patch v3. In my opinion for edk2 style, a implementation of library is required a header file and LibraryClass name for reference by others externally. Since libfdt is a third-party and we cannot include header files under the library immediately, we have to implement a header file for that. Also, we follow up edk2 style to make wrappers. Thanks a lot, Pedro. QQQ Benny -Original Message- From: devel@edk2.groups.io On Behalf Of Pedro Falcato Sent: Friday, April 14, 2023 2:32 AM To: Kinney, Michael D Cc: edk2-devel-groups-io Subject: Re: [edk2-devel] FW: [PATCH v2 2/3] MdePkg: Support FDT library. +CC edk2-devel, It seems that you dropped it accidentally. On Thu, Apr 13, 2023 at 7:30 PM Pedro Falcato wrote: > > On Thu, Apr 13, 2023 at 5:53 PM Kinney, Michael D > wrote: > > > > Hi Pedro, > > > > Any comments in this new version? Have your concerns been addressed, > > especially libc conformance. > > > > Mike > > Mike, > > I'm really sorry but I'm dealing with serious personal issues so I > can't give you much feedback > > However I skimmed through the patch and it looks okay to me, if you > add my copyright to the file with the libc implementations (as those > were taken from LibcLib's patch). And possibly my signed-off-by but > I'll leave that to your criteria. > > I still don't see much point in the libfdt wrapping code. Benny says > it's due to EDK2 style, you say it's for stability/modularity reasons. > I personally don't see much point in writing whole wrappers due to > style, and libfdt is AIUI very much something that has been mostly > stable over time. In any case, do what you think is best. I'll trust > your judgement and I won't block this patch for it. > > So with all that addressed, Acked-by: Pedro Falcato > > > Thank you, > Pedro -- Pedro -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103002): https://edk2.groups.io/g/devel/message/103002 Mute This Topic: https://groups.io/mt/98246918/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 0/3] Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) and refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Sean Brogan Cc: Michael Kubacki Acked-by: Pedro Falcato Signed-off-by: Benny Lin Benny Lin (3): Tianocore: Support FDT library. MdePkg: Support FDT library. .pytool: Support FDT library. .gitmodules | 3 + .pytool/CISettings.py | 2 + MdePkg/Include/Library/FdtLib.h | 314 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++ MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 ++ MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++ MdePkg/Library/BaseFdtLib/libfdt | 1 + MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 17 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + ReadMe.rst| 1 + 19 files changed, 1050 insertions(+), 2 deletions(-) create mode 100644 MdePkg/Include/Library/FdtLib.h create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf create mode 100644 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni create mode 100644 MdePkg/Library/BaseFdtLib/FdtLib.c create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtSupport.h create mode 100644 MdePkg/Library/BaseFdtLib/LibFdtWrapper.c create mode 16 MdePkg/Library/BaseFdtLib/libfdt create mode 100644 MdePkg/Library/BaseFdtLib/limits.h create mode 100644 MdePkg/Library/BaseFdtLib/stdbool.h create mode 100644 MdePkg/Library/BaseFdtLib/stddef.h create mode 100644 MdePkg/Library/BaseFdtLib/stdint.h create mode 100644 MdePkg/Library/BaseFdtLib/stdlib.h create mode 100644 MdePkg/Library/BaseFdtLib/string.h -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103070): https://edk2.groups.io/g/devel/message/103070 Mute This Topic: https://groups.io/mt/98313201/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 1/3] Tianocore: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add submodule libfdt and update ReadMe for the licence. Cc: Andrew Fish Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Benny Lin --- .gitmodules | 3 +++ MdePkg/Library/BaseFdtLib/libfdt | 1 + ReadMe.rst | 1 + 3 files changed, 5 insertions(+) diff --git a/.gitmodules b/.gitmodules index fe8a43be93..b1888c3488 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,6 @@ [submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"] path = UnitTestFrameworkPkg/Library/SubhookLib/subhook url = https://github.com/Zeex/subhook.git +[submodule "MdePkg/Library/BaseFdtLib/libfdt"] + path = MdePkg/Library/BaseFdtLib/libfdt + url = https://github.com/devicetree-org/pylibfdt.git diff --git a/MdePkg/Library/BaseFdtLib/libfdt b/MdePkg/Library/BaseFdtLib/libfdt new file mode 16 index 00..cfff805481 --- /dev/null +++ b/MdePkg/Library/BaseFdtLib/libfdt @@ -0,0 +1 @@ +Subproject commit cfff805481bdea27f900c32698171286542b8d3c diff --git a/ReadMe.rst b/ReadMe.rst index 91b9cf3c5e..d46c534229 100644 --- a/ReadMe.rst +++ b/ReadMe.rst @@ -96,6 +96,7 @@ that are covered by additional licenses. - `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest <https://github.com/google/googletest/blob/86add13493e5c881d7e4ba77fb91c1f57752b3a4/LICENSE>`__ - `UnitTestFrameworkPkg/Library/SubhookLib/subhook <https://github.com/Zeex/subhook/blob/83d4e1ebef3588fae48b69a7352cc21801cb70bc/LICENSE.txt>`__ - `RedfishPkg/Library/JsonLib/jansson <https://github.com/akheron/jansson/blob/2882ead5bb90cf12a01b07b2c2361e24960fae02/LICENSE>`__ +- `MdePkg/Library/BaseFdtLib/libfdt <https://github.com/devicetree-org/pylibfdt/blob/f39368a217496d32c4091a2dba4045b60649e3a5/BSD-2-Clause>`__ The EDK II Project is composed of packages. The maintainers for each package are listed in `Maintainers.txt `__. -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103071): https://edk2.groups.io/g/devel/message/103071 Mute This Topic: https://groups.io/mt/98313202/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 2/3] MdePkg: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) and refer to LibcLib implementation by Pedro. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Acked-by: Pedro Falcato Signed-off-by: Benny Lin --- MdePkg/Include/Library/FdtLib.h | 314 MdePkg/Library/BaseFdtLib/BaseFdtLib.inf | 62 MdePkg/Library/BaseFdtLib/BaseFdtLib.uni | 14 + MdePkg/Library/BaseFdtLib/FdtLib.c| 301 +++ MdePkg/Library/BaseFdtLib/LibFdtSupport.h | 99 ++ MdePkg/Library/BaseFdtLib/LibFdtWrapper.c | 173 +++ MdePkg/Library/BaseFdtLib/limits.h| 10 + MdePkg/Library/BaseFdtLib/stdbool.h | 10 + MdePkg/Library/BaseFdtLib/stddef.h| 10 + MdePkg/Library/BaseFdtLib/stdint.h| 10 + MdePkg/Library/BaseFdtLib/stdlib.h| 10 + MdePkg/Library/BaseFdtLib/string.h| 10 + MdePkg/MdePkg.ci.yaml | 17 +- MdePkg/MdePkg.dec | 4 + MdePkg/MdePkg.dsc | 1 + 15 files changed, 1043 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/Library/FdtLib.h b/MdePkg/Include/Library/FdtLib.h new file mode 100644 index 00..d59b749c25 --- /dev/null +++ b/MdePkg/Include/Library/FdtLib.h @@ -0,0 +1,314 @@ +/** @file + Flattened Device Tree Library. + + Copyright (c) 2023, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FDT_LIB_H_ +#define FDT_LIB_H_ + +/// +/// Flattened Device Tree definition +/// +typedef struct { + UINT32Magic; /* magic word FDT_MAGIC */ + UINT32TotalSize; /* total size of DT block */ + UINT32OffsetDtStruct; /* offset to structure */ + UINT32OffsetDtStrings; /* offset to strings */ + UINT32OffsetMemRsvmap; /* offset to memory reserve map */ + UINT32Version; /* format version */ + UINT32LastCompVersion; /* last compatible version */ + + /* version 2 fields below */ + UINT32BootCpuidPhys; /* Which physical CPU id we're +booting on */ + /* version 3 fields below */ + UINT32SizeDtStrings; /* size of the strings block */ + + /* version 17 fields below */ + UINT32SizeDtStruct;/* size of the structure block */ +} FDT_HEADER; + +typedef struct { + UINT64Address; + UINT64Size; +} FDT_RESERVE_ENTRY; + +typedef struct { + UINT32Tag; + CHAR8 Name[]; +} FDT_NODE_HEADER; + +typedef struct { + UINT32Tag; + UINT32Length; + UINT32NameOffset; + CHAR8 Data[]; +} FDT_PROPERTY; + +#define FDT_GET_HEADER(Fdt, Field) SwapBytes32(((CONST FDT_HEADER *)(Fdt))->Field) + +#define FDT_MAGIC(Fdt) (FDT_GET_HEADER(Fdt, Magic)) +#define FDT_TOTAL_SIZE(Fdt) (FDT_GET_HEADER(Fdt, TotalSize)) +#define FDT_OFFSET_DT_STRUCT(Fdt) (FDT_GET_HEADER(Fdt, OffsetDtStruct)) +#define FDT_OFFSET_DT_STRINGS(Fdt) (FDT_GET_HEADER(Fdt, OffsetDtStrings)) +#define FDT_OFFSET_MEM_RSVMAP(Fdt) (FDT_GET_HEADER(Fdt, OffsetMemRsvmap)) +#define FDT_VERSION(Fdt)(FDT_GET_HEADER(Fdt, Version)) +#define FDT_LAST_COMP_VERSION(Fdt) (FDT_GET_HEADER(Fdt, LastCompVersion)) +#define FDT_BOOT_CPUID_PHYS(Fdt)(FDT_GET_HEADER(Fdt, BootCpuidPhys)) +#define FDT_SIZE_DT_STRINGS(Fdt)(FDT_GET_HEADER(Fdt, SizeDtStrings)) +#define FDT_SIZE_DT_STRUCT(Fdt) (FDT_GET_HEADER(Fdt, SizeDtStruct)) + +/** + Verify the header of the Flattened Device Tree + + @param[in] FdtThe pointer to FDT blob. + + @return Zero for successfully, otherwise failed. + +**/ +INT32 +EFIAPI +FdtCheckHeader ( + IN CONST VOID *Fdt + ); + +/** + Create a empty Flattened Device Tree. + + @param[in] Buffer The pointer to allocate a pool for FDT blob. + @param[in] BufferSize The BufferSize to the pool size. + + @return Zero for successfully, otherwise failed. + +**/ +RETURN_STATUS +EFIAPI +FdtCreateEmptyTree ( + IN VOID *Buffer, + IN UINTN BufferSize + ); + +/** + Returns a offset of next node from the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + @param[in] Depth The depth to the level of tree hierarchy. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtNextNode ( + IN CONST VOID *Fdt, + IN INT32 Offset, + IN INT32 *Depth + ); + +/** + Returns a offset of first node under the given node. + + @param[in] FdtThe pointer to FDT blob. + @param[in] Offset The offset to previous node. + + @return The offset to next node offset. + +**/ +INT32 +EFIAPI +FdtFirstSubnode ( + IN CONST VOID *Fdt, + IN INT32 Offset + ); + +/** + Returns a offset of next node from the given node. + + @param
[edk2-devel] [PATCH v3 3/3] .pytool: Support FDT library.
From: Benny Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4392 Add FDT support in EDK2 by submodule 3rd party libfdt (https://github.com/devicetree-org/pylibfdt/tree/main/libfdt) Add RequiredSubmodule object for CI setting. Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Benny Lin --- .pytool/CISettings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index e3f44add58..2fb99f2a17 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -195,6 +195,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag "RedfishPkg/Library/JsonLib/jansson", False)) rs.append(RequiredSubmodule( "UnitTestFrameworkPkg/Library/SubhookLib/subhook", False)) +rs.append(RequiredSubmodule( +"MdePkg/Library/BaseFdtLib/libfdt", False)) return rs def GetName(self): -- 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103073): https://edk2.groups.io/g/devel/message/103073 Mute This Topic: https://groups.io/mt/98313205/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-