3 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 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.
16 PEIM to abstract construction of firmware volume in an Unix environment.
23 #include <Ppi/UnixFwh.h>
24 #include <Library/DebugLib.h>
25 #include <Library/PeimEntryPoint.h>
26 #include <Library/HobLib.h>
27 #include <Library/PeiServicesLib.h>
28 #include <Library/PeiServicesTablePointerLib.h>
29 #include <Library/PcdLib.h>
33 PeimInitializeUnixFwh (
34 IN EFI_PEI_FILE_HANDLE FileHandle
,
35 IN CONST EFI_PEI_SERVICES
**PeiServices
40 Perform a call-back into the SEC simulator to get address of the Firmware Hub
43 FfsHeader - Ffs Header availible to every PEIM
44 PeiServices - General purpose services available to every PEIM.
52 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
54 EFI_PHYSICAL_ADDRESS FdBase
;
55 EFI_PHYSICAL_ADDRESS FdFixUp
;
56 EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
;
60 DEBUG ((EFI_D_ERROR
, "Unix Firmware Volume PEIM Loaded\n"));
63 // Get the Fwh Information PPI
65 Status
= (**PeiServices
).LocatePpi (
67 &gUnixFwhPpiGuid
, // GUID
69 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
70 (VOID
**)&FwhPpi
// PPI
72 ASSERT_EFI_ERROR (Status
);
77 // Get information about all the FD's in the system
79 Status
= FwhPpi
->UnixFwh (Index
, &FdBase
, &FdSize
, &FdFixUp
);
80 if (!EFI_ERROR (Status
)) {
82 // Assume the FD starts with an FV header
84 FvHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*) (UINTN
) FdBase
;
87 // Make an FV Hob for the first FV in the FD
89 BuildFvHob (FdBase
, FvHeader
->FvLength
);
93 // Assume the first FD was produced by the NT32.DSC
94 // All these strange offests are needed to keep in
95 // sync with the FlashMap and NT32.dsc file
97 BuildResourceDescriptorHob (
98 EFI_RESOURCE_FIRMWARE_DEVICE
,
99 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
103 PcdGet32 (PcdFlashNvStorageVariableSize
) +
104 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
105 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
106 PcdGet32 (PcdUnixFlashNvStorageEventLogSize
)
111 // Hard code the address of the spare block and variable services.
112 // Assume it's a hard coded offset from FV0 in FD0.
115 PcdGet32 (PcdFlashNvStorageVariableSize
) +
116 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
117 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
118 PcdGet32 (PcdUnixFlashNvStorageEventLogSize
);
120 BuildFvHob (FdFixUp
+ PcdGet32 (PcdUnixFlashNvStorageVariableBase
), FdSize
);
123 // For other FD's just map them in.
125 BuildResourceDescriptorHob (
126 EFI_RESOURCE_FIRMWARE_DEVICE
,
127 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
135 } while (!EFI_ERROR (Status
));