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