3 Copyright (c) 2004 - 2007, 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.
25 #include EFI_GUID_DEFINITION (MemoryAllocationHob)
30 IN EFI_PEI_SERVICES
**PeiServices
,
31 IN EFI_GUID
*ModuleName
,
32 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
33 IN UINT64 ModuleLength
,
34 IN EFI_PHYSICAL_ADDRESS EntryPoint
40 Builds a HOB for a loaded PE32 module
44 PeiServices - The PEI core services table.
45 ModuleName - The GUID File Name of the module
46 MemoryAllocationModule - The 64 bit physical address of the module
47 ModuleLength - The length of the module in bytes
48 EntryPoint - The 64 bit physical address of the entry point
53 EFI_SUCCESS - Hob is successfully built.
54 Others - Errors occur while creating new Hob
59 EFI_HOB_MEMORY_ALLOCATION_MODULE
*Hob
;
61 Status
= (*PeiServices
)->CreateHob (
63 EFI_HOB_TYPE_MEMORY_ALLOCATION
,
64 sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE
),
67 if (EFI_ERROR (Status
)) {
71 Hob
->MemoryAllocationHeader
.Name
= gEfiHobMemeryAllocModuleGuid
;
72 Hob
->MemoryAllocationHeader
.MemoryBaseAddress
= MemoryAllocationModule
;
73 Hob
->MemoryAllocationHeader
.MemoryLength
= ModuleLength
;
74 Hob
->MemoryAllocationHeader
.MemoryType
= EfiBootServicesCode
;
75 (*PeiServices
)->SetMem (
76 Hob
->MemoryAllocationHeader
.Reserved
,
77 sizeof (Hob
->MemoryAllocationHeader
.Reserved
),
81 Hob
->ModuleName
= *ModuleName
;
82 Hob
->EntryPoint
= EntryPoint
;
89 PeiBuildHobResourceDescriptor (
90 IN EFI_PEI_SERVICES
**PeiServices
,
91 IN EFI_RESOURCE_TYPE ResourceType
,
92 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
93 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
94 IN UINT64 NumberOfBytes
100 Builds a HOB that describes a chunck of system memory
104 PeiServices - The PEI core services table.
106 ResourceType - The type of resource described by this HOB
108 ResourceAttribute - The resource attributes of the memory described by this HOB
110 PhysicalStart - The 64 bit physical address of memory described by this HOB
112 NumberOfBytes - The length of the memoty described by this HOB in bytes
116 EFI_SUCCESS - Hob is successfully built.
117 Others - Errors occur while creating new Hob
122 EFI_HOB_RESOURCE_DESCRIPTOR
*Hob
;
124 Status
= (*PeiServices
)->CreateHob (
126 EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
,
127 sizeof (EFI_HOB_RESOURCE_DESCRIPTOR
),
130 if (EFI_ERROR (Status
)) {
134 Hob
->ResourceType
= ResourceType
;
135 Hob
->ResourceAttribute
= ResourceAttribute
;
136 Hob
->PhysicalStart
= PhysicalStart
;
137 Hob
->ResourceLength
= NumberOfBytes
;
145 IN EFI_PEI_SERVICES
**PeiServices
,
154 Builds a custom HOB that is tagged with a GUID for identification
158 PeiServices - The PEI core services table.
159 Guid - The GUID of the custome HOB type
160 DataLength - The size of the data payload for the GUIDed HOB
161 Hob - Pointer to pointer to the created Hob
165 EFI_SUCCESS - Hob is successfully built.
166 Others - Errors occur while creating new Hob
172 Status
= (*PeiServices
)->CreateHob (
174 EFI_HOB_TYPE_GUID_EXTENSION
,
175 (UINT16
) (sizeof (EFI_HOB_GUID_TYPE
) + DataLength
),
178 if (EFI_ERROR (Status
)) {
182 ((EFI_HOB_GUID_TYPE
*)(*Hob
))->Name
= *Guid
;
189 PeiBuildHobGuidData (
190 IN EFI_PEI_SERVICES
**PeiServices
,
199 Builds a custom HOB that is tagged with a GUID for identification
203 PeiServices - The PEI core services table.
205 Guid - The GUID of the custome HOB type
207 Data - The data to be copied into the GUIDed HOB data field.
209 DataLength - The data field length.
213 EFI_SUCCESS - Hob is successfully built.
214 Others - Errors occur while creating new Hob
220 EFI_HOB_GUID_TYPE
*Hob
;
222 Status
= PeiBuildHobGuid (
229 if (EFI_ERROR (Status
)) {
234 (*PeiServices
)->CopyMem (Hob
, Data
, DataLength
);
242 IN EFI_PEI_SERVICES
**PeiServices
,
243 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
250 Builds a Firmware Volume HOB
254 PeiServices - The PEI core services table.
256 BaseAddress - The base address of the Firmware Volume
258 Length - The size of the Firmware Volume in bytes
262 EFI_SUCCESS - Hob is successfully built.
263 Others - Errors occur while creating new Hob
268 EFI_HOB_FIRMWARE_VOLUME
*Hob
;
271 // Check FV Signature
273 PEI_ASSERT (PeiServices
, ((EFI_FIRMWARE_VOLUME_HEADER
*)((UINTN
)BaseAddress
))->Signature
== EFI_FVH_SIGNATURE
);
275 Status
= (*PeiServices
)->CreateHob (
278 sizeof (EFI_HOB_FIRMWARE_VOLUME
),
281 if (EFI_ERROR (Status
)) {
285 Hob
->BaseAddress
= BaseAddress
;
286 Hob
->Length
= Length
;
294 IN EFI_PEI_SERVICES
**PeiServices
,
295 IN UINT8 SizeOfMemorySpace
,
296 IN UINT8 SizeOfIoSpace
302 Builds a HOB for the CPU
306 PeiServices - The PEI core services table.
308 SizeOfMemorySpace - Identifies the maximum
309 physical memory addressibility of the processor.
311 SizeOfIoSpace - Identifies the maximum physical I/O addressibility
316 EFI_SUCCESS - Hob is successfully built.
317 Others - Errors occur while creating new Hob
324 Status
= (*PeiServices
)->CreateHob (
327 sizeof (EFI_HOB_CPU
),
330 if (EFI_ERROR (Status
)) {
334 Hob
->SizeOfMemorySpace
= SizeOfMemorySpace
;
335 Hob
->SizeOfIoSpace
= SizeOfIoSpace
;
336 (*PeiServices
)->SetMem (
338 sizeof (Hob
->Reserved
),
349 IN EFI_PEI_SERVICES
**PeiServices
,
350 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
357 Builds a HOB for the Stack
361 PeiServices - The PEI core services table.
363 BaseAddress - The 64 bit physical address of the Stack
365 Length - The length of the stack in bytes
369 EFI_SUCCESS - Hob is successfully built.
370 Others - Errors occur while creating new Hob
375 EFI_HOB_MEMORY_ALLOCATION_STACK
*Hob
;
377 Status
= (*PeiServices
)->CreateHob (
379 EFI_HOB_TYPE_MEMORY_ALLOCATION
,
380 sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK
),
383 if (EFI_ERROR (Status
)) {
387 Hob
->AllocDescriptor
.Name
= gEfiHobMemeryAllocStackGuid
;
388 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
389 Hob
->AllocDescriptor
.MemoryLength
= Length
;
390 Hob
->AllocDescriptor
.MemoryType
= EfiBootServicesData
;
391 (*PeiServices
)->SetMem (
392 Hob
->AllocDescriptor
.Reserved
,
393 sizeof (Hob
->AllocDescriptor
.Reserved
),
403 PeiBuildHobBspStore (
404 IN EFI_PEI_SERVICES
**PeiServices
,
405 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
407 IN EFI_MEMORY_TYPE MemoryType
413 Builds a HOB for the bsp store
417 PeiServices - The PEI core services table.
419 BaseAddress - The 64 bit physical address of the bsp
421 Length - The length of the bsp store in bytes
423 MemoryType - Memory type
427 EFI_SUCCESS - Hob is successfully built.
428 Others - Errors occur while creating new Hob
433 EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
*Hob
;
435 Status
= (*PeiServices
)->CreateHob (
437 EFI_HOB_TYPE_MEMORY_ALLOCATION
,
438 sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
),
441 if (EFI_ERROR (Status
)) {
445 Hob
->AllocDescriptor
.Name
= gEfiHobMemeryAllocBspStoreGuid
;
446 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
447 Hob
->AllocDescriptor
.MemoryLength
= Length
;
448 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;
449 (*PeiServices
)->SetMem (
450 Hob
->AllocDescriptor
.Reserved
,
451 sizeof (Hob
->AllocDescriptor
.Reserved
),
460 PeiBuildHobMemoryAllocation (
461 IN EFI_PEI_SERVICES
**PeiServices
,
462 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
465 IN EFI_MEMORY_TYPE MemoryType
471 Builds a HOB for the memory allocation.
475 PeiServices - The PEI core services table.
477 BaseAddress - The 64 bit physical address of the memory
479 Length - The length of the memory allocation in bytes
483 MemoryType - Memory type
487 EFI_SUCCESS - Hob is successfully built.
488 Others - Errors occur while creating new Hob
493 EFI_HOB_MEMORY_ALLOCATION
*Hob
;
495 Status
= (*PeiServices
)->CreateHob (
497 EFI_HOB_TYPE_MEMORY_ALLOCATION
,
498 sizeof (EFI_HOB_MEMORY_ALLOCATION
),
501 if (EFI_ERROR (Status
)) {
506 Hob
->AllocDescriptor
.Name
= *Name
;
508 (*PeiServices
)->SetMem(&(Hob
->AllocDescriptor
.Name
), sizeof (EFI_GUID
), 0);
511 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
512 Hob
->AllocDescriptor
.MemoryLength
= Length
;
513 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;
514 (*PeiServices
)->SetMem (
515 Hob
->AllocDescriptor
.Reserved
,
516 sizeof (Hob
->AllocDescriptor
.Reserved
),