]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c
Replace the FlashMapHob with PCD defined in FDF on Nt32 platform. Currently, the...
[mirror_edk2.git] / Nt32Pkg / WinNtFirmwareVolumePei / WinntFwh.c
CommitLineData
56a71b55 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
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
20--*/\r
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
6d3aa33e 69 __asm int 3;\r
56a71b55 70 //\r
71 // Get the Fwh Information PPI\r
72 //\r
73 Status = (**PeiServices).LocatePpi (\r
74 PeiServices,\r
75 &gNtFwhPpiGuid, // GUID\r
76 0, // INSTANCE\r
77 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
78 &FwhPpi // PPI\r
79 );\r
80 ASSERT_EFI_ERROR (Status);\r
81\r
82 Index = 0;\r
83 do {\r
84 //\r
85 // Get information about all the FD's in the system\r
86 //\r
87 Status = FwhPpi->NtFwh (Index, &FdBase, &FdSize);\r
88 if (!EFI_ERROR (Status)) {\r
89 //\r
90 // Assume the FD starts with an FV header\r
91 //\r
92 FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;\r
93\r
94 //\r
95 // Make an FV Hob for the first FV in the FD\r
96 //\r
97 BuildFvHob (FdBase, FvHeader->FvLength);\r
98\r
99 if (Index == 0) {\r
100 //\r
101 // Assume the first FD was produced by the NT32.DSC\r
102 // All these strange offests are needed to keep in\r
103 // sync with the FlashMap and NT32.dsc file\r
104 //\r
105 BuildResourceDescriptorHob (\r
106 EFI_RESOURCE_FIRMWARE_DEVICE,\r
107 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
108 FdBase,\r
6d3aa33e 109 ( \r
110 FvHeader->FvLength + \r
111 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
112 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
113 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
114 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize)\r
115 )\r
56a71b55 116 );\r
56a71b55 117 //\r
118 // Hard code the address of the spare block and variable services.\r
119 // Assume it's a hard coded offset from FV0 in FD0.\r
120 //\r
6d3aa33e 121 FdBase = FdBase + PcdGet32 (PcdWinNtFlashNvStorageVariableBase);\r
122 FdSize = \r
123 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
124 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
125 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
126 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize);\r
56a71b55 127\r
128 BuildFvHob (FdBase, FdSize);\r
129 } else {\r
130 //\r
131 // For other FD's just map them in.\r
132 //\r
133 BuildResourceDescriptorHob (\r
134 EFI_RESOURCE_FIRMWARE_DEVICE,\r
135 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
136 FdBase,\r
137 FdSize\r
138 );\r
139 }\r
140 }\r
141\r
142 Index++;\r
143 } while (!EFI_ERROR (Status));\r
144\r
145 return Status;\r
146}\r