3 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2011, Apple Inc. All rights reserved.
5 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.
16 #include <Ppi/EmuThunk.h>
17 #include <Library/DebugLib.h>
18 #include <Library/PeimEntryPoint.h>
19 #include <Library/HobLib.h>
20 #include <Library/PeiServicesLib.h>
21 #include <Library/PeiServicesTablePointerLib.h>
22 #include <Library/PcdLib.h>
26 PeimInitializeFirmwareVolumePei (
27 IN EFI_PEI_FILE_HANDLE FileHandle
,
28 IN CONST EFI_PEI_SERVICES
**PeiServices
33 Perform a call-back into the SEC simulator to get address of the Firmware Hub
36 FfsHeader - Ffs Header available to every PEIM
37 PeiServices - General purpose services available to every PEIM.
45 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
47 EFI_PHYSICAL_ADDRESS FdBase
;
48 EFI_PHYSICAL_ADDRESS FdFixUp
;
49 EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
;
53 DEBUG ((EFI_D_ERROR
, "Unix Firmware Volume PEIM Loaded\n"));
56 // Get the Fwh Information PPI
58 Status
= PeiServicesLocatePpi (
59 &gEmuThunkPpiGuid
, // GUID
61 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
62 (VOID
**)&Thunk
// PPI
64 ASSERT_EFI_ERROR (Status
);
69 // Get information about all the FD's in the system
71 Status
= Thunk
->FirmwareDevices (Index
, &FdBase
, &FdSize
, &FdFixUp
);
72 if (!EFI_ERROR (Status
)) {
74 // Assume the FD starts with an FV header
76 FvHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*) (UINTN
) FdBase
;
79 // Make an FV Hob for the first FV in the FD
81 BuildFvHob (FdBase
, FvHeader
->FvLength
);
85 // Assume the first FD was produced by the NT32.DSC
86 // All these strange offests are needed to keep in
87 // sync with the FlashMap and NT32.dsc file
89 BuildResourceDescriptorHob (
90 EFI_RESOURCE_FIRMWARE_DEVICE
,
91 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
95 PcdGet32 (PcdFlashNvStorageVariableSize
) +
96 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
97 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
98 PcdGet32 (PcdEmuFlashNvStorageEventLogSize
)
103 // Hard code the address of the spare block and variable services.
104 // Assume it's a hard coded offset from FV0 in FD0.
107 PcdGet32 (PcdFlashNvStorageVariableSize
) +
108 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
109 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
110 PcdGet32 (PcdEmuFlashNvStorageEventLogSize
);
112 BuildFvHob (FdFixUp
+ PcdGet64 (PcdEmuFlashNvStorageVariableBase
), FdSize
);
115 // For other FD's just map them in.
117 BuildResourceDescriptorHob (
118 EFI_RESOURCE_FIRMWARE_DEVICE
,
119 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
127 } while (!EFI_ERROR (Status
));