[PATCH] UefiPayloadPkg: Add macro to support selective driver in UPL


Lu, James
 

From: James Lu <james.lu@...>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3967

Add macros to decide modules built into UPL.elf.

Macro list:
- GENERIC_MEMORY_TEST_ENABLE: GenericMemoryTestDxe
- NULL_MEMORY_TEST_ENABLE: NullMemoryTestDxe
- ATA_ENABLE: SataControllerDxe, AtaBusDxe, AtaAtapiPassThruDxe
- SD_ENABLE: SdMmcPciDxe, EmmcDxe, SdDxe
- PS2_MOUSE_ENABLE: Ps2MouseDxe

Cc: Guo Dong <guo.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Gua Guo <gua.guo@...>
Signed-off-by: James Lu <james.lu@...>
---
UefiPayloadPkg/UefiPayloadPkg.dsc | 18 ++++++++++++++++++
UefiPayloadPkg/UefiPayloadPkg.fdf | 15 ++++++++++++++-
2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload=
Pkg.dsc
index cfcf38578d..9e94a40d72 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -36,6 +36,11 @@
DEFINE PLATFORM_BOOT_TIMEOUT =3D 3=0D
DEFINE ABOVE_4G_MEMORY =3D TRUE=0D
DEFINE BOOT_MANAGER_ESCAPE =3D FALSE=0D
+ DEFINE GENERIC_MEMORY_TEST_ENABLE =3D FALSE=0D
+ DEFINE NULL_MEMORY_TEST_ENABLE =3D TRUE=0D
+ DEFINE ATA_ENABLE =3D TRUE=0D
+ DEFINE SD_ENABLE =3D TRUE=0D
+ DEFINE PS2_MOUSE_ENABLE =3D TRUE=0D
DEFINE SD_MMC_TIMEOUT =3D 1000000=0D
#=0D
# SBL: UEFI payload for Slim Bootloader=0D
@@ -596,7 +601,12 @@
MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRun=
timeDxe.inf=0D
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf=0D
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf=0D
+!if $(GENERIC_MEMORY_TEST_ENABLE) =3D=3D TRUE=0D
+ MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/GenericMemoryTest=
Dxe.inf=0D
+!endif=0D
+!if $(NULL_MEMORY_TEST_ENABLE) =3D=3D TRUE=0D
MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.in=
f=0D
+!endif=0D
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf=0D
MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf=0D
MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf=0D
@@ -631,9 +641,11 @@
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf=0D
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf=0D
FatPkg/EnhancedFatDxe/Fat.inf=0D
+!if $(ATA_ENABLE) =3D=3D TRUE=0D
MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf=0D
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf=0D
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf=0D
+!endif=0D
MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf=0D
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf=0D
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf=0D
@@ -644,9 +656,11 @@
#=0D
# SD/eMMC Support=0D
#=0D
+!if $(SD_ENABLE) =3D=3D TRUE=0D
MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf=0D
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf=0D
MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf=0D
+!endif=0D
=0D
#=0D
# Usb Support=0D
@@ -671,7 +685,9 @@
!if $(PS2_KEYBOARD_ENABLE) =3D=3D TRUE=0D
MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf=0D
!endif=0D
+!if $(PS2_MOUSE_ENABLE) =3D=3D TRUE=0D
MdeModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf=0D
+!endif=0D
=0D
#=0D
# Console Support=0D
@@ -742,12 +758,14 @@
# This should be FALSE for compiling the dynamic command.=0D
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE=0D
}=0D
+!if $(PERFORMANCE_MEASUREMENT_ENABLE) =3D=3D TRUE=0D
ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {=0D
<PcdsFixedAtBuild>=0D
## This flag is used to control initialization of the shell library=
=0D
# This should be FALSE for compiling the dynamic command.=0D
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE=0D
}=0D
+!endif=0D
ShellPkg/Application/Shell/Shell.inf {=0D
<PcdsFixedAtBuild>=0D
## This flag is used to control initialization of the shell library=
=0D
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayload=
Pkg.fdf
index c7b04978ad..5aa228e828 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -149,7 +149,12 @@ INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRea=
lTimeClockRuntimeDxe.inf
=0D
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf=0D
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf=0D
-INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.=
inf=0D
+!if $(GENERIC_MEMORY_TEST_ENABLE) =3D=3D TRUE=0D
+INF MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/GenericMemoryT=
estDxe.inf=0D
+!endif=0D
+!if $(NULL_MEMORY_TEST_ENABLE) =3D=3D TRUE=0D
+INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe=
.inf=0D
+!endif=0D
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf=0D
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf=0D
INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf=0D
@@ -176,7 +181,9 @@ INF OvmfPkg/SioBusDxe/SioBusDxe.inf
!if $(PS2_KEYBOARD_ENABLE) =3D=3D TRUE=0D
INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf=0D
!endif=0D
+!if $(PS2_MOUSE_ENABLE) =3D=3D TRUE=0D
INF MdeModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf=0D
+!endif=0D
=0D
#=0D
# Console Support=0D
@@ -195,9 +202,11 @@ INF UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe=
.inf
INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf=0D
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf=0D
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf=
=0D
+!if $(ATA_ENABLE) =3D=3D TRUE=0D
INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf=0D
INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf=0D
INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf=0D
+!endif=0D
INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf=0D
INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf=0D
INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf=0D
@@ -209,9 +218,11 @@ INF FatPkg/EnhancedFatDxe/Fat.inf
#=0D
# SD/eMMC Support=0D
#=0D
+!if $(SD_ENABLE) =3D=3D TRUE=0D
INF MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.inf=0D
INF MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf=0D
INF MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf=0D
+!endif=0D
=0D
#=0D
# Usb Support=0D
@@ -241,7 +252,9 @@ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable=
Dxe.inf
#=0D
!if $(SHELL_TYPE) =3D=3D BUILD_SHELL=0D
INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf=0D
+!if $(PERFORMANCE_MEASUREMENT_ENABLE) =3D=3D TRUE=0D
INF ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf=0D
+!endif=0D
INF ShellPkg/Application/Shell/Shell.inf=0D
!endif=0D
=0D
--=20
2.26.2.windows.1


Ni, Ray
 


+!if $(GENERIC_MEMORY_TEST_ENABLE) == TRUE

+
MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/Generic
MemoryTestDxe.inf

+!endif

+!if $(NULL_MEMORY_TEST_ENABLE) == TRUE


MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryT
estDxe.inf

+!endif
1. Is there a configuration that both GENERIC and NULL memory test is FALSE?
If no, can we add a macro like "MEMORY_TEST" and its value could be
"GENERIC" or "NULL"?



+!if $(ATA_ENABLE) == TRUE

MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf

MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf

MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
2. AtaAtapiPassThru also produces "gEfiExtScsiPassThruProtocolGuid" which is used by ScsiBusDxe.
So, maybe we need to always include AtaAtapiPassThru driver.

#

# Usb Support

@@ -671,7 +685,9 @@
!if $(PS2_KEYBOARD_ENABLE) == TRUE

MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf

!endif

+!if $(PS2_MOUSE_ENABLE) == TRUE

MdeModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf

+!endif



#

# Console Support

@@ -742,12 +758,14 @@
# This should be FALSE for compiling the dynamic command.

gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE

}

+!if $(PERFORMANCE_MEASUREMENT_ENABLE) == TRUE
3. Thanks for catching that.


Lu, James
 

Replied as below

 

 

Thanks,

James

 

-----Original Message-----
From: Ni, Ray <ray.ni@...>
Sent: Monday, July 4, 2022 11:34 AM
To: Lu, James <james.lu@...>; devel@edk2.groups.io
Cc: Dong, Guo <guo.dong@...>; Guo, Gua <gua.guo@...>
Subject: RE: [PATCH] UefiPayloadPkg: Add macro to support selective driver in UPL

 

>

> +!if $(GENERIC_MEMORY_TEST_ENABLE) == TRUE

>

> +

> MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/Generic

> MemoryTestDxe.inf

>

> +!endif

>

> +!if $(NULL_MEMORY_TEST_ENABLE) == TRUE

>

>

> MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryT

> estDxe.inf

>

> +!endif

 

1. Is there a configuration that both GENERIC and NULL memory test is FALSE?

If no, can we add a macro like "MEMORY_TEST" and its value could be "GENERIC" or "NULL"?

[James]

Will resolve in patch v2

 

 

> +!if $(ATA_ENABLE) == TRUE

>

>    MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf

>

>    MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf

>

>    MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf

 

2. AtaAtapiPassThru also produces "gEfiExtScsiPassThruProtocolGuid" which is used by ScsiBusDxe.

So, maybe we need to always include AtaAtapiPassThru driver.

[James]

This is to align client case that AtaAtapiPassThru.inf will not be included while ATA_ENABLE == FALSE

And ScsiBusDxe is taken care the flow while gEfiExtScsiPassThruProtocolGuid not existing

 

>

>    #

>

>    # Usb Support

>

> @@ -671,7 +685,9 @@

>  !if $(PS2_KEYBOARD_ENABLE) == TRUE

>

>    MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf

>

>  !endif

>

> +!if $(PS2_MOUSE_ENABLE) == TRUE

>

>    MdeModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf

>

> +!endif

>

>

>

>    #

>

>    # Console Support

>

> @@ -742,12 +758,14 @@

>        #  This should be FALSE for compiling the dynamic command.

>

>        gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE

>

>    }

>

> +!if $(PERFORMANCE_MEASUREMENT_ENABLE) == TRUE

 

3. Thanks for catching that.