4 Copyright (c) 2004, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
26 #include EFI_GUID_DEFINITION (MemoryAllocationHob)
31 IN EFI_PEI_SERVICES
**PeiServices
,
32 IN EFI_GUID
*ModuleName
,
33 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
34 IN UINT64 ModuleLength
,
35 IN EFI_PHYSICAL_ADDRESS EntryPoint
41 Builds a HOB for a loaded PE32 module
45 PeiServices - The PEI core services table.
46 ModuleName - The GUID File Name of the module
47 MemoryAllocationModule - The 64 bit physical address of the module
48 ModuleLength - The length of the module in bytes
49 EntryPoint - The 64 bit physical address of the entry point
54 EFI_SUCCESS - Hob is successfully built.
55 Others - Errors occur while creating new Hob
60 EFI_HOB_MEMORY_ALLOCATION_MODULE
*Hob
;
62 Status
= (*PeiServices
)->CreateHob (
64 EFI_HOB_TYPE_GUID_EXTENSION
,
65 sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE
),
68 if (EFI_ERROR (Status
)) {
72 Hob
->MemoryAllocationHeader
.Name
= gEfiHobMemeryAllocModuleGuid
;
73 Hob
->MemoryAllocationHeader
.MemoryBaseAddress
= MemoryAllocationModule
;
74 Hob
->MemoryAllocationHeader
.MemoryLength
= ModuleLength
;
75 Hob
->MemoryAllocationHeader
.MemoryType
= EfiBootServicesCode
;
77 Hob
->ModuleName
= *ModuleName
;
78 Hob
->EntryPoint
= EntryPoint
;
85 PeiBuildHobResourceDescriptor (
86 IN EFI_PEI_SERVICES
**PeiServices
,
87 IN EFI_RESOURCE_TYPE ResourceType
,
88 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
89 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
90 IN UINT64 NumberOfBytes
96 Builds a HOB that describes a chunck of system memory
100 PeiServices - The PEI core services table.
102 ResourceType - The type of resource described by this HOB
104 ResourceAttribute - The resource attributes of the memory described by this HOB
106 PhysicalStart - The 64 bit physical address of memory described by this HOB
108 NumberOfBytes - The length of the memoty described by this HOB in bytes
112 EFI_SUCCESS - Hob is successfully built.
113 Others - Errors occur while creating new Hob
118 EFI_HOB_RESOURCE_DESCRIPTOR
*Hob
;
120 Status
= (*PeiServices
)->CreateHob (
122 EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
,
123 sizeof (EFI_HOB_RESOURCE_DESCRIPTOR
),
126 if (EFI_ERROR (Status
)) {
130 Hob
->ResourceType
= ResourceType
;
131 Hob
->ResourceAttribute
= ResourceAttribute
;
132 Hob
->PhysicalStart
= PhysicalStart
;
133 Hob
->ResourceLength
= NumberOfBytes
;
141 IN EFI_PEI_SERVICES
**PeiServices
,
150 Builds a custom HOB that is tagged with a GUID for identification
154 PeiServices - The PEI core services table.
156 Guid - The GUID of the custome HOB type
158 DataLength - The size of the data payload for the GUIDed HOB
160 Hob - Pointer to the Hob
164 EFI_SUCCESS - Hob is successfully built.
165 Others - Errors occur while creating new Hob
171 Status
= (*PeiServices
)->CreateHob (
173 EFI_HOB_TYPE_GUID_EXTENSION
,
174 (UINT16
) (sizeof (EFI_HOB_GUID_TYPE
) + DataLength
),
177 if (EFI_ERROR (Status
)) {
181 ((EFI_HOB_GUID_TYPE
*)(*Hob
))->Name
= *Guid
;
188 PeiBuildHobGuidData (
189 IN EFI_PEI_SERVICES
**PeiServices
,
198 Builds a custom HOB that is tagged with a GUID for identification
202 PeiServices - The PEI core services table.
204 Guid - The GUID of the custome HOB type
206 Data - The data to be copied into the GUIDed HOB data field.
208 DataLength - The data field length.
212 EFI_SUCCESS - Hob is successfully built.
213 Others - Errors occur while creating new Hob
219 EFI_HOB_GUID_TYPE
*Hob
;
221 Status
= PeiBuildHobGuid (
228 if (EFI_ERROR (Status
)) {
233 (*PeiServices
)->CopyMem (Hob
, Data
, DataLength
);
241 IN EFI_PEI_SERVICES
**PeiServices
,
242 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
249 Builds a Firmware Volume HOB
253 PeiServices - The PEI core services table.
255 BaseAddress - The base address of the Firmware Volume
257 Length - The size of the Firmware Volume in bytes
261 EFI_SUCCESS - Hob is successfully built.
262 Others - Errors occur while creating new Hob
267 EFI_HOB_FIRMWARE_VOLUME
*Hob
;
269 Status
= (*PeiServices
)->CreateHob (
272 sizeof (EFI_HOB_FIRMWARE_VOLUME
),
275 if (EFI_ERROR (Status
)) {
279 Hob
->BaseAddress
= BaseAddress
;
280 Hob
->Length
= Length
;
288 IN EFI_PEI_SERVICES
**PeiServices
,
289 IN UINT8 SizeOfMemorySpace
,
290 IN UINT8 SizeOfIoSpace
296 Builds a HOB for the CPU
300 PeiServices - The PEI core services table.
302 SizeOfMemorySpace - Identifies the maximum
303 physical memory addressibility of the processor.
305 SizeOfIoSpace - Identifies the maximum physical I/O addressibility
310 EFI_SUCCESS - Hob is successfully built.
311 Others - Errors occur while creating new Hob
318 Status
= (*PeiServices
)->CreateHob (
321 sizeof (EFI_HOB_CPU
),
324 if (EFI_ERROR (Status
)) {
328 Hob
->SizeOfMemorySpace
= SizeOfMemorySpace
;
329 Hob
->SizeOfIoSpace
= SizeOfIoSpace
;
338 IN EFI_PEI_SERVICES
**PeiServices
,
339 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
346 Builds a HOB for the Stack
350 PeiServices - The PEI core services table.
352 BaseAddress - The 64 bit physical address of the Stack
354 Length - The length of the stack in bytes
358 EFI_SUCCESS - Hob is successfully built.
359 Others - Errors occur while creating new Hob
364 EFI_HOB_MEMORY_ALLOCATION_STACK
*Hob
;
366 Status
= (*PeiServices
)->CreateHob (
368 EFI_HOB_TYPE_MEMORY_ALLOCATION
,
369 sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK
),
372 if (EFI_ERROR (Status
)) {
376 Hob
->AllocDescriptor
.Name
= gEfiHobMemeryAllocStackGuid
;
377 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
378 Hob
->AllocDescriptor
.MemoryLength
= Length
;
379 Hob
->AllocDescriptor
.MemoryType
= EfiConventionalMemory
;
387 PeiBuildHobBspStore (
388 IN EFI_PEI_SERVICES
**PeiServices
,
389 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
391 IN EFI_MEMORY_TYPE MemoryType
397 Builds a HOB for the bsp store
401 PeiServices - The PEI core services table.
403 BaseAddress - The 64 bit physical address of the bsp
405 Length - The length of the bsp store in bytes
407 MemoryType - Memory type
411 EFI_SUCCESS - Hob is successfully built.
412 Others - Errors occur while creating new Hob
417 EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
*Hob
;
419 Status
= (*PeiServices
)->CreateHob (
421 EFI_HOB_TYPE_MEMORY_ALLOCATION
,
422 sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
),
425 if (EFI_ERROR (Status
)) {
429 Hob
->AllocDescriptor
.Name
= gEfiHobMemeryAllocBspStoreGuid
;
430 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
431 Hob
->AllocDescriptor
.MemoryLength
= Length
;
432 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;
439 PeiBuildHobMemoryAllocation (
440 IN EFI_PEI_SERVICES
**PeiServices
,
441 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
444 IN EFI_MEMORY_TYPE MemoryType
450 Builds a HOB for the memory allocation.
454 PeiServices - The PEI core services table.
456 BaseAddress - The 64 bit physical address of the memory
458 Length - The length of the memory allocation in bytes
462 MemoryType - Memory type
466 EFI_SUCCESS - Hob is successfully built.
467 Others - Errors occur while creating new Hob
472 EFI_HOB_MEMORY_ALLOCATION
*Hob
;
474 Status
= (*PeiServices
)->CreateHob (
476 EFI_HOB_TYPE_MEMORY_ALLOCATION
,
477 sizeof (EFI_HOB_MEMORY_ALLOCATION
),
480 if (EFI_ERROR (Status
)) {
485 Hob
->AllocDescriptor
.Name
= *Name
;
487 (*PeiServices
)->SetMem(&(Hob
->AllocDescriptor
.Name
), sizeof (EFI_GUID
), 0);
490 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
491 Hob
->AllocDescriptor
.MemoryLength
= Length
;
492 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;