Re: [edk2-devel] [PATCH v4 6/6] UefiPayloadPkg: Update UefiPayload driver for FDT support.
I also believe this code needs to go through crustify etc to ensure it follows all edk2 standards? On Mon, Jun 3, 2024 at 4:57 PM Dhaval Sharma wrote: > BuildFitLoadablesFvHob: > >- Fdt variable is not initialized. >- It ONLY gets initialized if GuidHob is found. What if it is not >found? >- FdtCheckHeader still evaluating it? > > > On Mon, Jun 3, 2024 at 7:49 AM Linus Liu wrote: > >> Add FDT detection and comsume FDT when needed. >> Move some x86 specific function in the x86 folder. >> Create HandOffHob via FDT memory node. >> >> Cc: Benny Lin >> Cc: Gua Guo >> Cc: Chasel Chiu >> Cc: James Lu >> Cc: Dhaval Sharma >> >> Signed-off-by: Linus Liu >> --- >> UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> | 428 +--- >> UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c >> | 12 + >> UefiPayloadPkg/UefiPayloadEntry/Ia32/{DxeLoadFunc.c => DxeLoadFuncFit.c} >> | 32 +- >> UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c >> | 50 +++ >> UefiPayloadPkg/UefiPayloadEntry/PrintHob.c >> | 6 +- >> UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c >> | 6 - >> UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c >> | 12 + >> UefiPayloadPkg/UefiPayloadEntry/X64/{DxeLoadFunc.c => DxeLoadFuncFit.c} >> | 31 +- >> UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf >> | 20 +- >> UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h >> | 68 >> UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf >> | 16 +- >> UefiPayloadPkg/UefiPayloadPkg.dsc >> | 29 +- >> 12 files changed, 443 insertions(+), 267 deletions(-) >> >> diff --git a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> index eb0b325369a0..813d656950d1 100644 >> --- a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> +++ b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c >> @@ -6,6 +6,8 @@ >> #include "UefiPayloadEntry.h" >> #include >> #include >> +#include >> +#include >> >> #define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT >>|\ >> >> EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \ >> @@ -23,6 +25,15 @@ >> >> EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \ >> EFI_RESOURCE_ATTRIBUTE_TESTED >> ) >> >> +EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = { >> + { EfiACPIReclaimMemory, FixedPcdGet32 >> (PcdMemoryTypeEfiACPIReclaimMemory) }, >> + { EfiACPIMemoryNVS, FixedPcdGet32 >> (PcdMemoryTypeEfiACPIMemoryNVS) }, >> + { EfiReservedMemoryType, FixedPcdGet32 >> (PcdMemoryTypeEfiReservedMemoryType) }, >> + { EfiRuntimeServicesData, FixedPcdGet32 >> (PcdMemoryTypeEfiRuntimeServicesData) }, >> + { EfiRuntimeServicesCode, FixedPcdGet32 >> (PcdMemoryTypeEfiRuntimeServicesCode) }, >> + { EfiMaxMemoryType, 0 >>} >> +}; >> + >> extern VOID *mHobList; >> >> CHAR8 *mLineBuffer = NULL; >> @@ -36,6 +47,78 @@ PrintHob ( >>IN CONST VOID *HobStart >>); >> >> +/** >> + Add HOB into HOB list >> + @param[in] HobThe HOB to be added into the HOB list. >> +**/ >> +VOID >> +AddNewHob ( >> + IN EFI_PEI_HOB_POINTERS *Hob >> + ); >> + >> +/** >> + Found the Resource Descriptor HOB that contains a range (Base, Top) >> + @param[in] HobListHob start address >> + @param[in] Base Memory start address >> + @param[in] TopMemory end address. >> + @retval The pointer to the Resource Descriptor HOB. >> +**/ >> +EFI_HOB_RESOURCE_DESCRIPTOR * >> +FindResourceDescriptorByRange ( >> + IN VOID *HobList, >> + IN EFI_PHYSICAL_ADDRESS Base, >> + IN EFI_PHYSICAL_ADDRESS Top >> + ); >> + >> +/** >> + Find the highest below 4G memory resource descriptor, except the input >> Resource Descriptor. >> + @param[in] HobList Hob start address >> + @param[in] MinimalNeededSize Minimal needed size. >> + @param[in] ExceptResourceHob Ignore this Resource Descriptor. >> + @retval The pointer to the Resource Descriptor HOB. >> +**/ >> +EFI_HOB_RESOURCE_DESCRIPTOR * >> +FindAnotherHighestBelow4GResourceDescriptor ( >> + IN VOID *HobList, >> + IN UINTNMinimalNeededSize, >> + IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob >> + ); >> + >> +/** >> + Check the HOB and decide if it is need inside Payload >> + Payload maintainer may make decision which HOB is need or needn't >> + Then add the check logic in the function. >> + @param[in] Hob The HOB to check >> + @retval TRUE If HOB is need inside Payload >> + @retval FALSE If HOB is needn't inside Payload >> +**/ >> +BOOLEAN >> +FitIsHobNeed ( >> + EFI_PEI_HOB_POINTERS Hob >> + ); >> + >> +/** >> + Check the HOB and decide if it is need inside Payload >> + >> + Payload maintainer may make decision which HOB is need or needn't >> + Then add the check logic in the function. >> + >> + @param[in] Hob Th
Re: [edk2-devel] [PATCH v4 6/6] UefiPayloadPkg: Update UefiPayload driver for FDT support.
BuildFitLoadablesFvHob: - Fdt variable is not initialized. - It ONLY gets initialized if GuidHob is found. What if it is not found? - FdtCheckHeader still evaluating it? On Mon, Jun 3, 2024 at 7:49 AM Linus Liu wrote: > Add FDT detection and comsume FDT when needed. > Move some x86 specific function in the x86 folder. > Create HandOffHob via FDT memory node. > > Cc: Benny Lin > Cc: Gua Guo > Cc: Chasel Chiu > Cc: James Lu > Cc: Dhaval Sharma > > Signed-off-by: Linus Liu > --- > UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c > | 428 +--- > UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c > | 12 + > UefiPayloadPkg/UefiPayloadEntry/Ia32/{DxeLoadFunc.c => DxeLoadFuncFit.c} > | 32 +- > UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c > | 50 +++ > UefiPayloadPkg/UefiPayloadEntry/PrintHob.c > | 6 +- > UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c > | 6 - > UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c > | 12 + > UefiPayloadPkg/UefiPayloadEntry/X64/{DxeLoadFunc.c => DxeLoadFuncFit.c} > | 31 +- > UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf > | 20 +- > UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h > | 68 > UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf > | 16 +- > UefiPayloadPkg/UefiPayloadPkg.dsc > | 29 +- > 12 files changed, 443 insertions(+), 267 deletions(-) > > diff --git a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c > b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c > index eb0b325369a0..813d656950d1 100644 > --- a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c > +++ b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c > @@ -6,6 +6,8 @@ > #include "UefiPayloadEntry.h" > #include > #include > +#include > +#include > > #define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT > |\ > > EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \ > @@ -23,6 +25,15 @@ > EFI_RESOURCE_ATTRIBUTE_INITIALIZED > | \ > EFI_RESOURCE_ATTRIBUTE_TESTED > ) > > +EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = { > + { EfiACPIReclaimMemory, FixedPcdGet32 > (PcdMemoryTypeEfiACPIReclaimMemory) }, > + { EfiACPIMemoryNVS, FixedPcdGet32 > (PcdMemoryTypeEfiACPIMemoryNVS) }, > + { EfiReservedMemoryType, FixedPcdGet32 > (PcdMemoryTypeEfiReservedMemoryType) }, > + { EfiRuntimeServicesData, FixedPcdGet32 > (PcdMemoryTypeEfiRuntimeServicesData) }, > + { EfiRuntimeServicesCode, FixedPcdGet32 > (PcdMemoryTypeEfiRuntimeServicesCode) }, > + { EfiMaxMemoryType, 0 >} > +}; > + > extern VOID *mHobList; > > CHAR8 *mLineBuffer = NULL; > @@ -36,6 +47,78 @@ PrintHob ( >IN CONST VOID *HobStart >); > > +/** > + Add HOB into HOB list > + @param[in] HobThe HOB to be added into the HOB list. > +**/ > +VOID > +AddNewHob ( > + IN EFI_PEI_HOB_POINTERS *Hob > + ); > + > +/** > + Found the Resource Descriptor HOB that contains a range (Base, Top) > + @param[in] HobListHob start address > + @param[in] Base Memory start address > + @param[in] TopMemory end address. > + @retval The pointer to the Resource Descriptor HOB. > +**/ > +EFI_HOB_RESOURCE_DESCRIPTOR * > +FindResourceDescriptorByRange ( > + IN VOID *HobList, > + IN EFI_PHYSICAL_ADDRESS Base, > + IN EFI_PHYSICAL_ADDRESS Top > + ); > + > +/** > + Find the highest below 4G memory resource descriptor, except the input > Resource Descriptor. > + @param[in] HobList Hob start address > + @param[in] MinimalNeededSize Minimal needed size. > + @param[in] ExceptResourceHob Ignore this Resource Descriptor. > + @retval The pointer to the Resource Descriptor HOB. > +**/ > +EFI_HOB_RESOURCE_DESCRIPTOR * > +FindAnotherHighestBelow4GResourceDescriptor ( > + IN VOID *HobList, > + IN UINTNMinimalNeededSize, > + IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob > + ); > + > +/** > + Check the HOB and decide if it is need inside Payload > + Payload maintainer may make decision which HOB is need or needn't > + Then add the check logic in the function. > + @param[in] Hob The HOB to check > + @retval TRUE If HOB is need inside Payload > + @retval FALSE If HOB is needn't inside Payload > +**/ > +BOOLEAN > +FitIsHobNeed ( > + EFI_PEI_HOB_POINTERS Hob > + ); > + > +/** > + Check the HOB and decide if it is need inside Payload > + > + Payload maintainer may make decision which HOB is need or needn't > + Then add the check logic in the function. > + > + @param[in] Hob The HOB to check > + > + @retval TRUE If HOB is need inside Payload > + @retval FALSE If HOB is needn't inside Payload > +**/ > +BOOLEAN > +IsHobNeed ( > + EFI_PEI_HOB_POINTERS Hob > + ); > + > +VOID > +EFIAPI > +ProcessLibraryConstructorList ( > + VOID > + ); > + > /**
[edk2-devel] [PATCH v4 6/6] UefiPayloadPkg: Update UefiPayload driver for FDT support.
Add FDT detection and comsume FDT when needed. Move some x86 specific function in the x86 folder. Create HandOffHob via FDT memory node. Cc: Benny Lin Cc: Gua Guo Cc: Chasel Chiu Cc: James Lu Cc: Dhaval Sharma Signed-off-by: Linus Liu --- UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c | 428 +--- UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c | 12 + UefiPayloadPkg/UefiPayloadEntry/Ia32/{DxeLoadFunc.c => DxeLoadFuncFit.c} | 32 +- UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c | 50 +++ UefiPayloadPkg/UefiPayloadEntry/PrintHob.c | 6 +- UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 6 - UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c| 12 + UefiPayloadPkg/UefiPayloadEntry/X64/{DxeLoadFunc.c => DxeLoadFuncFit.c} | 31 +- UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf | 20 +- UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 68 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf| 16 +- UefiPayloadPkg/UefiPayloadPkg.dsc| 29 +- 12 files changed, 443 insertions(+), 267 deletions(-) diff --git a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c index eb0b325369a0..813d656950d1 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.c @@ -6,6 +6,8 @@ #include "UefiPayloadEntry.h" #include #include +#include +#include #define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \ EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \ @@ -23,6 +25,15 @@ EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \ EFI_RESOURCE_ATTRIBUTE_TESTED ) +EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = { + { EfiACPIReclaimMemory, FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory) }, + { EfiACPIMemoryNVS, FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS) }, + { EfiReservedMemoryType, FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType) }, + { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData) }, + { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode) }, + { EfiMaxMemoryType, 0 } +}; + extern VOID *mHobList; CHAR8 *mLineBuffer = NULL; @@ -36,6 +47,78 @@ PrintHob ( IN CONST VOID *HobStart ); +/** + Add HOB into HOB list + @param[in] HobThe HOB to be added into the HOB list. +**/ +VOID +AddNewHob ( + IN EFI_PEI_HOB_POINTERS *Hob + ); + +/** + Found the Resource Descriptor HOB that contains a range (Base, Top) + @param[in] HobListHob start address + @param[in] Base Memory start address + @param[in] TopMemory end address. + @retval The pointer to the Resource Descriptor HOB. +**/ +EFI_HOB_RESOURCE_DESCRIPTOR * +FindResourceDescriptorByRange ( + IN VOID *HobList, + IN EFI_PHYSICAL_ADDRESS Base, + IN EFI_PHYSICAL_ADDRESS Top + ); + +/** + Find the highest below 4G memory resource descriptor, except the input Resource Descriptor. + @param[in] HobList Hob start address + @param[in] MinimalNeededSize Minimal needed size. + @param[in] ExceptResourceHob Ignore this Resource Descriptor. + @retval The pointer to the Resource Descriptor HOB. +**/ +EFI_HOB_RESOURCE_DESCRIPTOR * +FindAnotherHighestBelow4GResourceDescriptor ( + IN VOID *HobList, + IN UINTNMinimalNeededSize, + IN EFI_HOB_RESOURCE_DESCRIPTOR *ExceptResourceHob + ); + +/** + Check the HOB and decide if it is need inside Payload + Payload maintainer may make decision which HOB is need or needn't + Then add the check logic in the function. + @param[in] Hob The HOB to check + @retval TRUE If HOB is need inside Payload + @retval FALSE If HOB is needn't inside Payload +**/ +BOOLEAN +FitIsHobNeed ( + EFI_PEI_HOB_POINTERS Hob + ); + +/** + Check the HOB and decide if it is need inside Payload + + Payload maintainer may make decision which HOB is need or needn't + Then add the check logic in the function. + + @param[in] Hob The HOB to check + + @retval TRUE If HOB is need inside Payload + @retval FALSE If HOB is needn't inside Payload +**/ +BOOLEAN +IsHobNeed ( + EFI_PEI_HOB_POINTERS Hob + ); + +VOID +EFIAPI +ProcessLibraryConstructorList ( + VOID + ); + /** Find the first substring. @param StringPoint to the string where to find the substring. @@ -191,187 +274,6 @@ FixUpPcdDatabase ( return EFI_SUCCESS; } -/** - Add HOB into HOB list -