3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 EFI PEI Core HOB services
27 IN EFI_PEI_SERVICES
**PeiServices
,
34 Gets the pointer to the HOB List.
38 PeiServices - The PEI core services table.
39 HobList - Pointer to the HOB List.
43 EFI_SUCCESS - Get the pointer of HOB List
44 EFI_NOT_AVAILABLE_YET - the HOB List is not yet published
45 EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)
49 PEI_CORE_INSTANCE
*PrivateData
;
53 // Only check this parameter in debug mode
57 if (HobList
== NULL
) {
58 return EFI_INVALID_PARAMETER
;
62 PrivateData
= PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices
);
64 *HobList
= PrivateData
->HobList
.Raw
;
74 IN EFI_PEI_SERVICES
**PeiServices
,
83 Add a new HOB to the HOB List.
87 PeiServices - The PEI core services table.
88 Type - Type of the new HOB.
89 Length - Length of the new HOB to allocate.
90 Hob - Pointer to the new HOB.
95 - EFI_INVALID_PARAMETER if Hob is NULL
96 - EFI_NOT_AVAILABLE_YET if HobList is still not available.
97 - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
102 EFI_HOB_HANDOFF_INFO_TABLE
*HandOffHob
;
103 EFI_HOB_GENERIC_HEADER
*HobEnd
;
104 EFI_PHYSICAL_ADDRESS FreeMemory
;
107 Status
= PeiGetHobList (PeiServices
, Hob
);
108 if (EFI_ERROR(Status
)) {
114 Length
= (UINT16
)((Length
+ 0x7) & (~0x7));
116 FreeMemory
= HandOffHob
->EfiFreeMemoryTop
-
117 HandOffHob
->EfiFreeMemoryBottom
;
119 if (FreeMemory
< Length
) {
120 return EFI_OUT_OF_RESOURCES
;
123 *Hob
= (VOID
*) (UINTN
) HandOffHob
->EfiEndOfHobList
;
124 ((EFI_HOB_GENERIC_HEADER
*) *Hob
)->HobType
= Type
;
125 ((EFI_HOB_GENERIC_HEADER
*) *Hob
)->HobLength
= Length
;
126 ((EFI_HOB_GENERIC_HEADER
*) *Hob
)->Reserved
= 0;
128 HobEnd
= (EFI_HOB_GENERIC_HEADER
*) ((UINTN
) *Hob
+ Length
);
129 HandOffHob
->EfiEndOfHobList
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) HobEnd
;
131 HobEnd
->HobType
= EFI_HOB_TYPE_END_OF_HOB_LIST
;
132 HobEnd
->HobLength
= sizeof(EFI_HOB_GENERIC_HEADER
);
133 HobEnd
->Reserved
= 0;
135 HandOffHob
->EfiFreeMemoryBottom
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) HobEnd
;
143 PeiCoreBuildHobHandoffInfoTable (
144 IN EFI_BOOT_MODE BootMode
,
145 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
146 IN UINT64 MemoryLength
152 Builds a Handoff Information Table HOB
156 BootMode - Current Bootmode
157 MemoryBegin - Start Memory Address.
158 MemoryLength - Length of Memory.
166 EFI_HOB_HANDOFF_INFO_TABLE
*Hob
;
167 EFI_HOB_GENERIC_HEADER
*HobEnd
;
169 Hob
= (VOID
*)(UINTN
)MemoryBegin
;
170 HobEnd
= (EFI_HOB_GENERIC_HEADER
*) (Hob
+1);
171 Hob
->Header
.HobType
= EFI_HOB_TYPE_HANDOFF
;
172 Hob
->Header
.HobLength
= sizeof(EFI_HOB_HANDOFF_INFO_TABLE
);
173 Hob
->Header
.Reserved
= 0;
175 HobEnd
->HobType
= EFI_HOB_TYPE_END_OF_HOB_LIST
;
176 HobEnd
->HobLength
= sizeof(EFI_HOB_GENERIC_HEADER
);
177 HobEnd
->Reserved
= 0;
179 Hob
->Version
= EFI_HOB_HANDOFF_TABLE_VERSION
;
180 Hob
->BootMode
= BootMode
;
182 Hob
->EfiMemoryTop
= MemoryBegin
+ MemoryLength
;
183 Hob
->EfiMemoryBottom
= MemoryBegin
;
184 Hob
->EfiFreeMemoryTop
= MemoryBegin
+ MemoryLength
;
185 Hob
->EfiFreeMemoryBottom
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) (HobEnd
+1);
186 Hob
->EfiEndOfHobList
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) HobEnd
;