TianoCore EDK2 master
Loading...
Searching...
No Matches
FlashMapPei.c
1/*++ @file
2 PEIM to build GUIDed HOBs for platform specific flash map
3
4Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5Portions copyright (c) 2011, Apple Inc. All rights reserved.
6SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#include "PiPei.h"
11
13#include <Ppi/EmuThunk.h>
14
15#include <Library/DebugLib.h>
17#include <Library/HobLib.h>
21#include <Library/PcdLib.h>
22
24EFIAPI
25PeimInitializeFlashMap (
26 IN EFI_PEI_FILE_HANDLE FileHandle,
27 IN CONST EFI_PEI_SERVICES **PeiServices
28 )
29
30/*++
31
32Routine Description:
33 Build GUIDed HOBs for platform specific flash map
34
35Arguments:
36 FfsHeader - A pointer to the EFI_FFS_FILE_HEADER structure.
37 PeiServices - General purpose services available to every PEIM.
38
39Returns:
40 EFI_STATUS
41
42**/
43{
44 EFI_STATUS Status;
45 EMU_THUNK_PPI *Thunk;
46 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
49 UINT64 FdSize;
50
51 DEBUG ((DEBUG_ERROR, "EmulatorPkg Flash Map PEIM Loaded\n"));
52
53 //
54 // Get the Fwh Information PPI
55 //
56 Status = PeiServicesLocatePpi (
57 &gEmuThunkPpiGuid, // GUID
58 0, // INSTANCE
59 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
60 (VOID **)&Thunk // PPI
61 );
62 ASSERT_EFI_ERROR (Status);
63
64 //
65 // Assume that FD0 contains the Flash map.
66 //
67 Status = Thunk->FirmwareDevices (0, &FdBase, &FdSize, &FdFixUp);
68 if (EFI_ERROR (Status)) {
69 return Status;
70 }
71
72 PcdSet64S (PcdFlashNvStorageVariableBase64, PcdGet64 (PcdEmuFlashNvStorageVariableBase) + FdFixUp);
73 PcdSet64S (PcdFlashNvStorageFtwWorkingBase64, PcdGet64 (PcdEmuFlashNvStorageFtwWorkingBase) + FdFixUp);
74 PcdSet64S (PcdFlashNvStorageFtwSpareBase64, PcdGet64 (PcdEmuFlashNvStorageFtwSpareBase) + FdFixUp);
75
76 return EFI_SUCCESS;
77}
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define PcdGet64(TokenName)
Definition: PcdLib.h:375
#define PcdSet64S(TokenName, Value)
Definition: PcdLib.h:511
VOID * EFI_PEI_FILE_HANDLE
Definition: PiPeiCis.h:26
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112