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