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