StandaloneMmPkg/HobLib: Add HOB Library for management mode.
[mirror_edk2.git] / StandaloneMmPkg / Library / StandaloneMmCoreHobLib / AArch64 / StandaloneMmCoreHobLibInternal.c
1 /** @file
2 HOB Library implementation for Standalone MM Core.
3
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.<BR>
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include <PiMm.h>
18
19 #include <Library/HobLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/BaseMemoryLib.h>
22
23 #include <Guid/MemoryAllocationHob.h>
24
25 //
26 // Cache copy of HobList pointer.
27 //
28 extern VOID *gHobList;
29
30 EFI_HOB_HANDOFF_INFO_TABLE*
31 HobConstructor (
32 IN VOID *EfiMemoryBegin,
33 IN UINTN EfiMemoryLength,
34 IN VOID *EfiFreeMemoryBottom,
35 IN VOID *EfiFreeMemoryTop
36 )
37 {
38 EFI_HOB_HANDOFF_INFO_TABLE *Hob;
39 EFI_HOB_GENERIC_HEADER *HobEnd;
40
41 Hob = EfiFreeMemoryBottom;
42 HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1);
43
44 Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
45 Hob->Header.HobLength = sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
46 Hob->Header.Reserved = 0;
47
48 HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
49 HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
50 HobEnd->Reserved = 0;
51
52 Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
53 Hob->BootMode = BOOT_WITH_FULL_CONFIGURATION;
54
55 Hob->EfiMemoryTop = (UINTN)EfiMemoryBegin + EfiMemoryLength;
56 Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
57 Hob->EfiFreeMemoryTop = (UINTN)EfiFreeMemoryTop;
58 Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
59 Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
60
61 gHobList = Hob;
62
63 return Hob;
64 }