]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/FlashMapPei/FlashMapPei.c
InOsEmuPkg: Rename package to EmulatorPkg & Sec to Host
[mirror_edk2.git] / EmulatorPkg / FlashMapPei / FlashMapPei.c
CommitLineData
949f388f 1/*++ @file\r
2 PEIM to build GUIDed HOBs for platform specific flash map\r
3\r
4Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
5Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
6This program and the accompanying materials \r
7are licensed and made available under the terms and conditions of the BSD License \r
8which accompanies this distribution. The full text of the license may be found at \r
9http://opensource.org/licenses/bsd-license.php \r
10 \r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
13\r
14**/\r
15\r
16\r
17#include "PiPei.h"\r
18\r
19#include <Guid/SystemNvDataGuid.h>\r
20#include <Ppi/EmuThunk.h>\r
21\r
22#include <Library/DebugLib.h>\r
23#include <Library/PeimEntryPoint.h>\r
24#include <Library/HobLib.h>\r
25#include <Library/PeiServicesLib.h>\r
26#include <Library/PeiServicesTablePointerLib.h>\r
27#include <Library/BaseMemoryLib.h>\r
28#include <Library/PcdLib.h>\r
29\r
30EFI_STATUS\r
31EFIAPI\r
32PeimInitializeFlashMap (\r
33 IN EFI_PEI_FILE_HANDLE FileHandle,\r
34 IN CONST EFI_PEI_SERVICES **PeiServices\r
35 )\r
36/*++\r
37\r
38Routine Description:\r
39 Build GUIDed HOBs for platform specific flash map\r
40 \r
41Arguments:\r
42 FfsHeader - A pointer to the EFI_FFS_FILE_HEADER structure.\r
43 PeiServices - General purpose services available to every PEIM.\r
44 \r
45Returns:\r
46 EFI_STATUS\r
47\r
48**/\r
49{\r
50 EFI_STATUS Status;\r
51 EMU_THUNK_PPI *Thunk;\r
52 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
53 EFI_PHYSICAL_ADDRESS FdBase;\r
54 EFI_PHYSICAL_ADDRESS FdFixUp;\r
55 UINT64 FdSize;\r
56\r
bb89ec1a 57 DEBUG ((EFI_D_ERROR, "EmulatorPkg Flash Map PEIM Loaded\n"));\r
949f388f 58\r
59 //\r
60 // Get the Fwh Information PPI\r
61 //\r
62 Status = PeiServicesLocatePpi (\r
63 &gEmuThunkPpiGuid, // GUID\r
64 0, // INSTANCE\r
65 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
66 (VOID **)&Thunk // PPI\r
67 );\r
68 ASSERT_EFI_ERROR (Status);\r
69\r
70 //\r
71 // Assume that FD0 contains the Flash map.\r
72 //\r
73 Status = Thunk->FirmwareDevices (0, &FdBase, &FdSize, &FdFixUp);\r
74 if (EFI_ERROR (Status)) {\r
75 return Status;\r
76 }\r
77 \r
78 PcdSet64 (PcdFlashNvStorageVariableBase64, PcdGet64 (PcdEmuFlashNvStorageVariableBase) + FdFixUp);\r
79 PcdSet64 (PcdFlashNvStorageFtwWorkingBase64, PcdGet64 (PcdEmuFlashNvStorageFtwWorkingBase) + FdFixUp);\r
80 PcdSet64 (PcdFlashNvStorageFtwSpareBase64, PcdGet64 (PcdEmuFlashNvStorageFtwSpareBase) + FdFixUp);\r
81\r
82 return EFI_SUCCESS;\r
83}\r