]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c
Porting WinNtFwhPei and WinNtFlashMapPei to produce FvHob.
[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
37\r
38#include <FlashLayout.h>\r
39\r
40\r
41EFI_STATUS\r
42EFIAPI\r
43PeimInitializeWinNtFwh (\r
44 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
45 IN EFI_PEI_SERVICES **PeiServices\r
46 )\r
47/*++\r
48\r
49Routine Description:\r
50 Perform a call-back into the SEC simulator to get address of the Firmware Hub\r
51\r
52Arguments:\r
53 FfsHeader - Ffs Header availible to every PEIM\r
54 PeiServices - General purpose services available to every PEIM.\r
55 \r
56Returns:\r
57 None\r
58\r
59--*/\r
60{\r
61 EFI_STATUS Status;\r
62 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
63 NT_FWH_PPI *FwhPpi;\r
64 EFI_PHYSICAL_ADDRESS FdBase;\r
65 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
66 UINT64 FdSize;\r
67 UINTN Index;\r
68\r
69 DEBUG ((EFI_D_ERROR, "NT 32 Firmware Volume PEIM Loaded\n"));\r
70\r
71 //\r
72 // Get the Fwh Information PPI\r
73 //\r
74 Status = (**PeiServices).LocatePpi (\r
75 PeiServices,\r
76 &gNtFwhPpiGuid, // GUID\r
77 0, // INSTANCE\r
78 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
79 &FwhPpi // PPI\r
80 );\r
81 ASSERT_EFI_ERROR (Status);\r
82\r
83 Index = 0;\r
84 do {\r
85 //\r
86 // Get information about all the FD's in the system\r
87 //\r
88 Status = FwhPpi->NtFwh (Index, &FdBase, &FdSize);\r
89 if (!EFI_ERROR (Status)) {\r
90 //\r
91 // Assume the FD starts with an FV header\r
92 //\r
93 FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;\r
94\r
95 //\r
96 // Make an FV Hob for the first FV in the FD\r
97 //\r
98 BuildFvHob (FdBase, FvHeader->FvLength);\r
99\r
100 if (Index == 0) {\r
101 //\r
102 // Assume the first FD was produced by the NT32.DSC\r
103 // All these strange offests are needed to keep in\r
104 // sync with the FlashMap and NT32.dsc file\r
105 //\r
106 BuildResourceDescriptorHob (\r
107 EFI_RESOURCE_FIRMWARE_DEVICE,\r
108 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
109 FdBase,\r
110 (FvHeader->FvLength + EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH)\r
111 );\r
112\r
113 //\r
114 // Hard code the address of the spare block and variable services.\r
115 // Assume it's a hard coded offset from FV0 in FD0.\r
116 //\r
117 FdBase = FdBase + EFI_WINNT_RUNTIME_UPDATABLE_OFFSET;\r
118 FdSize = EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH;\r
119\r
120 BuildFvHob (FdBase, FdSize);\r
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