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 DEBUG ((EFI_D_ERROR
, "PeiCreateHob fail: Length - 0x%08x\n", (UINTN
)Length
));
121 DEBUG ((EFI_D_ERROR
, " FreeMemoryTop - 0x%08x\n", (UINTN
)HandOffHob
->EfiFreeMemoryTop
));
122 DEBUG ((EFI_D_ERROR
, " FreeMemoryBottom - 0x%08x\n", (UINTN
)HandOffHob
->EfiFreeMemoryBottom
));
123 return EFI_OUT_OF_RESOURCES
;
126 *Hob
= (VOID
*) (UINTN
) HandOffHob
->EfiEndOfHobList
;
127 ((EFI_HOB_GENERIC_HEADER
*) *Hob
)->HobType
= Type
;
128 ((EFI_HOB_GENERIC_HEADER
*) *Hob
)->HobLength
= Length
;
129 ((EFI_HOB_GENERIC_HEADER
*) *Hob
)->Reserved
= 0;
131 HobEnd
= (EFI_HOB_GENERIC_HEADER
*) ((UINTN
) *Hob
+ Length
);
132 HandOffHob
->EfiEndOfHobList
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) HobEnd
;
134 HobEnd
->HobType
= EFI_HOB_TYPE_END_OF_HOB_LIST
;
135 HobEnd
->HobLength
= sizeof(EFI_HOB_GENERIC_HEADER
);
136 HobEnd
->Reserved
= 0;
138 HandOffHob
->EfiFreeMemoryBottom
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) HobEnd
;
146 PeiCoreBuildHobHandoffInfoTable (
147 IN EFI_BOOT_MODE BootMode
,
148 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
149 IN UINT64 MemoryLength
155 Builds a Handoff Information Table HOB
159 BootMode - Current Bootmode
160 MemoryBegin - Start Memory Address.
161 MemoryLength - Length of Memory.
169 EFI_HOB_HANDOFF_INFO_TABLE
*Hob
;
170 EFI_HOB_GENERIC_HEADER
*HobEnd
;
172 Hob
= (VOID
*)(UINTN
)MemoryBegin
;
173 HobEnd
= (EFI_HOB_GENERIC_HEADER
*) (Hob
+1);
174 Hob
->Header
.HobType
= EFI_HOB_TYPE_HANDOFF
;
175 Hob
->Header
.HobLength
= sizeof(EFI_HOB_HANDOFF_INFO_TABLE
);
176 Hob
->Header
.Reserved
= 0;
178 HobEnd
->HobType
= EFI_HOB_TYPE_END_OF_HOB_LIST
;
179 HobEnd
->HobLength
= sizeof(EFI_HOB_GENERIC_HEADER
);
180 HobEnd
->Reserved
= 0;
182 Hob
->Version
= EFI_HOB_HANDOFF_TABLE_VERSION
;
183 Hob
->BootMode
= BootMode
;
185 Hob
->EfiMemoryTop
= MemoryBegin
+ MemoryLength
;
186 Hob
->EfiMemoryBottom
= MemoryBegin
;
187 Hob
->EfiFreeMemoryTop
= MemoryBegin
+ MemoryLength
;
188 Hob
->EfiFreeMemoryBottom
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) (HobEnd
+1);
189 Hob
->EfiEndOfHobList
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) HobEnd
;