Re: [edk2] [PATCH v2 12/17] MdeModulePkg: implement NULL instance of HobLib library class
On 2019/1/14 21:27, Ard Biesheuvel wrote: In order to permit MM_STANDALONE modules to be built without relying on StandaloneMmPkg, provide a BASE type NULL implementation of HobLib. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Star Zeng --- MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf | 38 ++ MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c | 542 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni | 20 + 3 files changed, 600 insertions(+) diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf new file mode 100644 index ..c0e927ff14be --- /dev/null +++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf @@ -0,0 +1,38 @@ +## @file +# Null instance of HOB Library. +# +# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. +# Copyright (c) 2018, Linaro, Ltd. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## + +[Defines] + INF_VERSION= 0x0001001B + BASE_NAME = BaseHobLibNull + MODULE_UNI_FILE= BaseHobLibNull.uni + FILE_GUID = a89dea6f-c9a0-40be-903c-7cac2ef8a0e7 + MODULE_TYPE= BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = HobLib + + +# +# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 +# + +[Sources] + BaseHobLibNull.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c new file mode 100644 index ..0ea7d9304e9d --- /dev/null +++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c @@ -0,0 +1,542 @@ +/** @file + Provide Hob Library functions for build testing only. + +Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. +Copyright (c) 2018, Linaro, Ltd. All rights reserved. +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include + +#include +#include + +/** + Returns the pointer to the HOB list. + + This function returns the pointer to first HOB in the list. + For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer + to the HOB list. For the DXE phase, the HOB list pointer can be retrieved through + the EFI System Table by looking up theHOB list GUID in the System Configuration Table. + Since the System Configuration Table does not exist that the time the DXE Core is + launched, the DXE Core uses a global variable from the DXE Core Entry Point Library + to manage the pointer to the HOB list. + + If the pointer to the HOB list is NULL, then ASSERT(). + + @return The pointer to the HOB list. + +**/ +VOID * +EFIAPI +GetHobList ( + VOID + ) +{ + ASSERT (FALSE); + return NULL; +} + +/** + Returns the next instance of a HOB type from the starting HOB. + + This function searches the first instance of a HOB type from the starting HOB pointer. + If there does not exist such HOB type from the starting HOB pointer, it will return NULL. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + + If HobStart is NULL, then ASSERT(). + + @param Type The HOB type to return. + @param HobStart The starting HOB pointer to search from. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextHob ( + IN UINT16 Type, + IN CONST VOID *HobStart + ) +{ + ASSERT (FALSE); + return NULL; +} + +/** + Returns the first instance of a HOB type among the whole HOB list. + + This function searches the first instance of a HOB type among the whole HOB list. + If there does not exist such HOB type in the HOB list, it will return NULL. + + If the pointer to the HOB list is NULL, then ASSERT(). + + @param Type The HOB type to return. + + @return The next instance of a HOB
[edk2] [PATCH v2 12/17] MdeModulePkg: implement NULL instance of HobLib library class
In order to permit MM_STANDALONE modules to be built without relying on StandaloneMmPkg, provide a BASE type NULL implementation of HobLib. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf | 38 ++ MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c | 542 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni | 20 + 3 files changed, 600 insertions(+) diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf new file mode 100644 index ..c0e927ff14be --- /dev/null +++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf @@ -0,0 +1,38 @@ +## @file +# Null instance of HOB Library. +# +# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. +# Copyright (c) 2018, Linaro, Ltd. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## + +[Defines] + INF_VERSION= 0x0001001B + BASE_NAME = BaseHobLibNull + MODULE_UNI_FILE= BaseHobLibNull.uni + FILE_GUID = a89dea6f-c9a0-40be-903c-7cac2ef8a0e7 + MODULE_TYPE= BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = HobLib + + +# +# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 +# + +[Sources] + BaseHobLibNull.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c new file mode 100644 index ..0ea7d9304e9d --- /dev/null +++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c @@ -0,0 +1,542 @@ +/** @file + Provide Hob Library functions for build testing only. + +Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. +Copyright (c) 2018, Linaro, Ltd. All rights reserved. +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include + +#include +#include + +/** + Returns the pointer to the HOB list. + + This function returns the pointer to first HOB in the list. + For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer + to the HOB list. For the DXE phase, the HOB list pointer can be retrieved through + the EFI System Table by looking up theHOB list GUID in the System Configuration Table. + Since the System Configuration Table does not exist that the time the DXE Core is + launched, the DXE Core uses a global variable from the DXE Core Entry Point Library + to manage the pointer to the HOB list. + + If the pointer to the HOB list is NULL, then ASSERT(). + + @return The pointer to the HOB list. + +**/ +VOID * +EFIAPI +GetHobList ( + VOID + ) +{ + ASSERT (FALSE); + return NULL; +} + +/** + Returns the next instance of a HOB type from the starting HOB. + + This function searches the first instance of a HOB type from the starting HOB pointer. + If there does not exist such HOB type from the starting HOB pointer, it will return NULL. + In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer + unconditionally: it returns HobStart back if HobStart itself meets the requirement; + caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart. + + If HobStart is NULL, then ASSERT(). + + @param Type The HOB type to return. + @param HobStart The starting HOB pointer to search from. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetNextHob ( + IN UINT16 Type, + IN CONST VOID *HobStart + ) +{ + ASSERT (FALSE); + return NULL; +} + +/** + Returns the first instance of a HOB type among the whole HOB list. + + This function searches the first instance of a HOB type among the whole HOB list. + If there does not exist such HOB type in the HOB list, it will return NULL. + + If the pointer to the HOB list is NULL, then ASSERT(). + + @param Type The HOB type to return. + + @return The next instance of a HOB type from the starting HOB. + +**/ +VOID * +EFIAPI +GetFirstHob ( + IN UINT16