]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.c
EmulatorPkg: Remove all trailing whitespace
[mirror_edk2.git] / EmulatorPkg / FirmwareVolumePei / FirmwareVolumePei.c
CommitLineData
949f388f 1/*++ @file\r
2\r
3Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
4Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
d18d8a1d 5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
949f388f 12\r
13**/\r
14\r
15#include "PiPei.h"\r
16#include <Ppi/EmuThunk.h>\r
17#include <Library/DebugLib.h>\r
18#include <Library/PeimEntryPoint.h>\r
19#include <Library/HobLib.h>\r
20#include <Library/PeiServicesLib.h>\r
21#include <Library/PeiServicesTablePointerLib.h>\r
22#include <Library/PcdLib.h>\r
23\r
24EFI_STATUS\r
25EFIAPI\r
26PeimInitializeFirmwareVolumePei (\r
27 IN EFI_PEI_FILE_HANDLE FileHandle,\r
28 IN CONST EFI_PEI_SERVICES **PeiServices\r
29 )\r
30/*++\r
31\r
32Routine Description:\r
33 Perform a call-back into the SEC simulator to get address of the Firmware Hub\r
34\r
35Arguments:\r
36 FfsHeader - Ffs Header availible to every PEIM\r
37 PeiServices - General purpose services available to every PEIM.\r
d18d8a1d 38\r
949f388f 39Returns:\r
40 None\r
41\r
42**/\r
43{\r
44 EFI_STATUS Status;\r
45 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
46 EMU_THUNK_PPI *Thunk;\r
47 EFI_PHYSICAL_ADDRESS FdBase;\r
48 EFI_PHYSICAL_ADDRESS FdFixUp;\r
49 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
50 UINT64 FdSize;\r
51 UINTN Index;\r
52\r
53 DEBUG ((EFI_D_ERROR, "Unix Firmware Volume PEIM Loaded\n"));\r
54\r
55 //\r
56 // Get the Fwh Information PPI\r
57 //\r
58 Status = PeiServicesLocatePpi (\r
59 &gEmuThunkPpiGuid, // GUID\r
60 0, // INSTANCE\r
61 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
62 (VOID **)&Thunk // PPI\r
63 );\r
64 ASSERT_EFI_ERROR (Status);\r
65\r
66 Index = 0;\r
67 do {\r
68 //\r
69 // Get information about all the FD's in the system\r
70 //\r
71 Status = Thunk->FirmwareDevices (Index, &FdBase, &FdSize, &FdFixUp);\r
72 if (!EFI_ERROR (Status)) {\r
73 //\r
74 // Assume the FD starts with an FV header\r
75 //\r
76 FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;\r
77\r
78 //\r
79 // Make an FV Hob for the first FV in the FD\r
80 //\r
81 BuildFvHob (FdBase, FvHeader->FvLength);\r
82\r
83 if (Index == 0) {\r
84 //\r
85 // Assume the first FD was produced by the NT32.DSC\r
86 // All these strange offests are needed to keep in\r
87 // sync with the FlashMap and NT32.dsc file\r
88 //\r
89 BuildResourceDescriptorHob (\r
90 EFI_RESOURCE_FIRMWARE_DEVICE,\r
91 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
92 FdBase,\r
d18d8a1d 93 (\r
94 FvHeader->FvLength +\r
949f388f 95 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
96 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
97 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
98 PcdGet32 (PcdEmuFlashNvStorageEventLogSize)\r
99 )\r
100 );\r
101\r
102 //\r
103 // Hard code the address of the spare block and variable services.\r
104 // Assume it's a hard coded offset from FV0 in FD0.\r
105 //\r
d18d8a1d 106 FdSize =\r
949f388f 107 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
108 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
109 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
110 PcdGet32 (PcdEmuFlashNvStorageEventLogSize);\r
111\r
112 BuildFvHob (FdFixUp + PcdGet64 (PcdEmuFlashNvStorageVariableBase), FdSize);\r
113 } else {\r
114 //\r
115 // For other FD's just map them in.\r
116 //\r
117 BuildResourceDescriptorHob (\r
118 EFI_RESOURCE_FIRMWARE_DEVICE,\r
119 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
120 FdBase,\r
121 FdSize\r
122 );\r
123 }\r
124 }\r
125\r
126 Index++;\r
127 } while (!EFI_ERROR (Status));\r
128\r
129 return Status;\r
130}\r