]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c
Nt32Pkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Nt32Pkg / WinNtFirmwareVolumePei / WinntFwh.c
CommitLineData
6ae81428 1/**@file\r
56a71b55 2\r
8f2a5f80 3Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
9d2eedba 4SPDX-License-Identifier: BSD-2-Clause-Patent\r
56a71b55 5\r
6Module Name:\r
7 WinNtFwh.c\r
8 \r
9Abstract:\r
10 PEIM to abstract construction of firmware volume in a Windows NT environment.\r
11\r
12Revision History\r
13\r
6ae81428 14**/\r
56a71b55 15\r
16//\r
17// The package level header files this module uses\r
18//\r
19#include <PiPei.h>\r
20#include <WinNtPeim.h>\r
21//\r
22// The protocols, PPI and GUID defintions for this module\r
23//\r
24#include <Ppi/NtFwh.h>\r
25//\r
26// The Library classes this module consumes\r
27//\r
28#include <Library/DebugLib.h>\r
29#include <Library/PeimEntryPoint.h>\r
30#include <Library/HobLib.h>\r
6d3aa33e 31#include <Library/PcdLib.h>\r
56a71b55 32\r
33EFI_STATUS\r
34EFIAPI\r
35PeimInitializeWinNtFwh (\r
36 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
37 IN EFI_PEI_SERVICES **PeiServices\r
38 )\r
39/*++\r
40\r
41Routine Description:\r
42 Perform a call-back into the SEC simulator to get address of the Firmware Hub\r
43\r
44Arguments:\r
8aa9d680 45 FfsHeader - Ffs Header available to every PEIM\r
56a71b55 46 PeiServices - General purpose services available to every PEIM.\r
47 \r
48Returns:\r
49 None\r
50\r
51--*/\r
52{\r
53 EFI_STATUS Status;\r
54 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
55 NT_FWH_PPI *FwhPpi;\r
56 EFI_PHYSICAL_ADDRESS FdBase;\r
57 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
58 UINT64 FdSize;\r
59 UINTN Index;\r
60\r
61 DEBUG ((EFI_D_ERROR, "NT 32 Firmware Volume PEIM Loaded\n"));\r
62\r
63 //\r
64 // Get the Fwh Information PPI\r
65 //\r
66 Status = (**PeiServices).LocatePpi (\r
0b94e319 67 (const EFI_PEI_SERVICES **)PeiServices,\r
56a71b55 68 &gNtFwhPpiGuid, // GUID\r
69 0, // INSTANCE\r
70 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
0b94e319 71 (VOID**)&FwhPpi // PPI\r
56a71b55 72 );\r
73 ASSERT_EFI_ERROR (Status);\r
74\r
75 Index = 0;\r
76 do {\r
77 //\r
78 // Get information about all the FD's in the system\r
79 //\r
80 Status = FwhPpi->NtFwh (Index, &FdBase, &FdSize);\r
81 if (!EFI_ERROR (Status)) {\r
82 //\r
83 // Assume the FD starts with an FV header\r
84 //\r
85 FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;\r
86\r
87 //\r
88 // Make an FV Hob for the first FV in the FD\r
89 //\r
90 BuildFvHob (FdBase, FvHeader->FvLength);\r
91\r
92 if (Index == 0) {\r
93 //\r
94 // Assume the first FD was produced by the NT32.DSC\r
95 // All these strange offests are needed to keep in\r
96 // sync with the FlashMap and NT32.dsc file\r
97 //\r
98 BuildResourceDescriptorHob (\r
99 EFI_RESOURCE_FIRMWARE_DEVICE,\r
100 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
101 FdBase,\r
6d3aa33e 102 ( \r
103 FvHeader->FvLength + \r
104 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
105 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
106 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
107 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize)\r
108 )\r
56a71b55 109 );\r
56a71b55 110 //\r
111 // Hard code the address of the spare block and variable services.\r
112 // Assume it's a hard coded offset from FV0 in FD0.\r
113 //\r
6d3aa33e 114 FdSize = \r
115 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
116 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
117 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
118 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize);\r
56a71b55 119\r
706e7534 120 BuildFvHob (FdBase + PcdGet32 (PcdWinNtFlashNvStorageVariableBase), FdSize);\r
56a71b55 121 } else {\r
122 //\r
123 // For other FD's just map them in.\r
124 //\r
125 BuildResourceDescriptorHob (\r
126 EFI_RESOURCE_FIRMWARE_DEVICE,\r
127 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
128 FdBase,\r
129 FdSize\r
130 );\r
131 }\r
132 }\r
133\r
134 Index++;\r
135 } while (!EFI_ERROR (Status));\r
136\r
137 return Status;\r
138}\r