2 PEIM to build GUIDed HOBs for platform specific flash map
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2011, Apple Inc. All rights reserved.
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Guid/SystemNvDataGuid.h>
20 #include <Ppi/EmuThunk.h>
22 #include <Library/DebugLib.h>
23 #include <Library/PeimEntryPoint.h>
24 #include <Library/HobLib.h>
25 #include <Library/PeiServicesLib.h>
26 #include <Library/PeiServicesTablePointerLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/PcdLib.h>
32 PeimInitializeFlashMap (
33 IN EFI_PEI_FILE_HANDLE FileHandle
,
34 IN CONST EFI_PEI_SERVICES
**PeiServices
39 Build GUIDed HOBs for platform specific flash map
42 FfsHeader - A pointer to the EFI_FFS_FILE_HEADER structure.
43 PeiServices - General purpose services available to every PEIM.
52 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
53 EFI_PHYSICAL_ADDRESS FdBase
;
54 EFI_PHYSICAL_ADDRESS FdFixUp
;
57 DEBUG ((EFI_D_ERROR
, "EmulatorPkg Flash Map PEIM Loaded\n"));
60 // Get the Fwh Information PPI
62 Status
= PeiServicesLocatePpi (
63 &gEmuThunkPpiGuid
, // GUID
65 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
66 (VOID
**)&Thunk
// PPI
68 ASSERT_EFI_ERROR (Status
);
71 // Assume that FD0 contains the Flash map.
73 Status
= Thunk
->FirmwareDevices (0, &FdBase
, &FdSize
, &FdFixUp
);
74 if (EFI_ERROR (Status
)) {
78 PcdSet64 (PcdFlashNvStorageVariableBase64
, PcdGet64 (PcdEmuFlashNvStorageVariableBase
) + FdFixUp
);
79 PcdSet64 (PcdFlashNvStorageFtwWorkingBase64
, PcdGet64 (PcdEmuFlashNvStorageFtwWorkingBase
) + FdFixUp
);
80 PcdSet64 (PcdFlashNvStorageFtwSpareBase64
, PcdGet64 (PcdEmuFlashNvStorageFtwSpareBase
) + FdFixUp
);