3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
10 PEIM to abstract construction of firmware volume in a Windows NT environment.
17 // The package level header files this module uses
20 #include <WinNtPeim.h>
22 // The protocols, PPI and GUID defintions for this module
24 #include <Ppi/NtFwh.h>
26 // The Library classes this module consumes
28 #include <Library/DebugLib.h>
29 #include <Library/PeimEntryPoint.h>
30 #include <Library/HobLib.h>
31 #include <Library/PcdLib.h>
35 PeimInitializeWinNtFwh (
36 IN EFI_FFS_FILE_HEADER
*FfsHeader
,
37 IN EFI_PEI_SERVICES
**PeiServices
42 Perform a call-back into the SEC simulator to get address of the Firmware Hub
45 FfsHeader - Ffs Header available to every PEIM
46 PeiServices - General purpose services available to every PEIM.
54 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
56 EFI_PHYSICAL_ADDRESS FdBase
;
57 EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
;
61 DEBUG ((EFI_D_ERROR
, "NT 32 Firmware Volume PEIM Loaded\n"));
64 // Get the Fwh Information PPI
66 Status
= (**PeiServices
).LocatePpi (
67 (const EFI_PEI_SERVICES
**)PeiServices
,
68 &gNtFwhPpiGuid
, // GUID
70 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
71 (VOID
**)&FwhPpi
// PPI
73 ASSERT_EFI_ERROR (Status
);
78 // Get information about all the FD's in the system
80 Status
= FwhPpi
->NtFwh (Index
, &FdBase
, &FdSize
);
81 if (!EFI_ERROR (Status
)) {
83 // Assume the FD starts with an FV header
85 FvHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*) (UINTN
) FdBase
;
88 // Make an FV Hob for the first FV in the FD
90 BuildFvHob (FdBase
, FvHeader
->FvLength
);
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
98 BuildResourceDescriptorHob (
99 EFI_RESOURCE_FIRMWARE_DEVICE
,
100 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
104 PcdGet32 (PcdFlashNvStorageVariableSize
) +
105 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
106 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
107 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize
)
111 // Hard code the address of the spare block and variable services.
112 // Assume it's a hard coded offset from FV0 in FD0.
115 PcdGet32 (PcdFlashNvStorageVariableSize
) +
116 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
117 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
118 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize
);
120 BuildFvHob (FdBase
+ PcdGet32 (PcdWinNtFlashNvStorageVariableBase
), FdSize
);
123 // For other FD's just map them in.
125 BuildResourceDescriptorHob (
126 EFI_RESOURCE_FIRMWARE_DEVICE
,
127 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
135 } while (!EFI_ERROR (Status
));