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
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.
16 PEIM to abstract construction of firmware volume in a Windows NT environment.
23 // The package level header files this module uses
26 #include <WinNtPeim.h>
28 // The protocols, PPI and GUID defintions for this module
30 #include <Ppi/NtFwh.h>
32 // The Library classes this module consumes
34 #include <Library/DebugLib.h>
35 #include <Library/PeimEntryPoint.h>
36 #include <Library/HobLib.h>
37 #include <Library/PcdLib.h>
41 PeimInitializeWinNtFwh (
42 IN EFI_FFS_FILE_HEADER
*FfsHeader
,
43 IN EFI_PEI_SERVICES
**PeiServices
48 Perform a call-back into the SEC simulator to get address of the Firmware Hub
51 FfsHeader - Ffs Header availible to every PEIM
52 PeiServices - General purpose services available to every PEIM.
60 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
62 EFI_PHYSICAL_ADDRESS FdBase
;
63 EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
;
67 DEBUG ((EFI_D_ERROR
, "NT 32 Firmware Volume PEIM Loaded\n"));
71 // Get the Fwh Information PPI
73 Status
= (**PeiServices
).LocatePpi (
75 &gNtFwhPpiGuid
, // GUID
77 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
80 ASSERT_EFI_ERROR (Status
);
85 // Get information about all the FD's in the system
87 Status
= FwhPpi
->NtFwh (Index
, &FdBase
, &FdSize
);
88 if (!EFI_ERROR (Status
)) {
90 // Assume the FD starts with an FV header
92 FvHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*) (UINTN
) FdBase
;
95 // Make an FV Hob for the first FV in the FD
97 BuildFvHob (FdBase
, FvHeader
->FvLength
);
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
105 BuildResourceDescriptorHob (
106 EFI_RESOURCE_FIRMWARE_DEVICE
,
107 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
111 PcdGet32 (PcdFlashNvStorageVariableSize
) +
112 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
113 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
114 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize
)
118 // Hard code the address of the spare block and variable services.
119 // Assume it's a hard coded offset from FV0 in FD0.
121 FdBase
= FdBase
+ PcdGet32 (PcdWinNtFlashNvStorageVariableBase
);
123 PcdGet32 (PcdFlashNvStorageVariableSize
) +
124 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
125 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
126 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize
);
128 BuildFvHob (FdBase
, FdSize
);
131 // For other FD's just map them in.
133 BuildResourceDescriptorHob (
134 EFI_RESOURCE_FIRMWARE_DEVICE
,
135 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
143 } while (!EFI_ERROR (Status
));