From 8a485e4bb8b5c5a800d6b3e1b8fa80fe27afb274 Mon Sep 17 00:00:00 2001 From: "Liu, Zhiguang" Date: Tue, 6 Dec 2022 13:41:36 +0800 Subject: [PATCH] EmulatorPkg: Record Argc, Argv and Envp in EmuThunk Ppi Record Argc, Argv and Envp in EmuThunk Ppi so that other modules can use these fields to change behavior depends on boot parameters or environment. Cc: Andrew Fish Reviewed-by: Ray Ni Signed-off-by: Zhiguang Liu --- EmulatorPkg/Include/Ppi/EmuThunk.h | 3 +++ EmulatorPkg/Unix/Host/Host.c | 3 +++ EmulatorPkg/Win/Host/WinHost.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/EmulatorPkg/Include/Ppi/EmuThunk.h b/EmulatorPkg/Include/Ppi/EmuThunk.h index cf29cf824c..c78ad692ed 100644 --- a/EmulatorPkg/Include/Ppi/EmuThunk.h +++ b/EmulatorPkg/Include/Ppi/EmuThunk.h @@ -107,6 +107,9 @@ typedef struct { EMU_PEI_AUTOSCAN MemoryAutoScan; EMU_PEI_FD_INFORMATION FirmwareDevices; EMU_PEI_THUNK_INTERFACE Thunk; + INTN Argc; + CHAR8 **Argv; + CHAR8 **Envp; UINTN PersistentMemorySize; UINT8 PersistentMemory[0]; } EMU_THUNK_PPI; diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c index 8d0be5b54b..1f29dd00a3 100644 --- a/EmulatorPkg/Unix/Host/Host.c +++ b/EmulatorPkg/Unix/Host/Host.c @@ -145,6 +145,9 @@ main ( } CopyMem (SecEmuThunkPpi, &mSecEmuThunkPpi, sizeof (EMU_THUNK_PPI)); + SecEmuThunkPpi->Argc = Argc; + SecEmuThunkPpi->Argv = Argv; + SecEmuThunkPpi->Envp = Envp; SecEmuThunkPpi->PersistentMemorySize = FixedPcdGet32 (PcdPersistentMemorySize); AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, SecEmuThunkPpi); diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index 19199c648c..193a947fbd 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -499,6 +499,9 @@ Returns: } CopyMem (SecEmuThunkPpi, &mSecEmuThunkPpi, sizeof (EMU_THUNK_PPI)); + SecEmuThunkPpi->Argc = Argc; + SecEmuThunkPpi->Argv = Argv; + SecEmuThunkPpi->Envp = Envp; SecEmuThunkPpi->PersistentMemorySize = FixedPcdGet32 (PcdPersistentMemorySize); AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, SecEmuThunkPpi); AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEfiPeiReset2PpiGuid, &mEmuReset2Ppi);