3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 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"));
70 // Get the Fwh Information PPI
72 Status
= (**PeiServices
).LocatePpi (
73 (const EFI_PEI_SERVICES
**)PeiServices
,
74 &gNtFwhPpiGuid
, // GUID
76 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
77 (VOID
**)&FwhPpi
// PPI
79 ASSERT_EFI_ERROR (Status
);
84 // Get information about all the FD's in the system
86 Status
= FwhPpi
->NtFwh (Index
, &FdBase
, &FdSize
);
87 if (!EFI_ERROR (Status
)) {
89 // Assume the FD starts with an FV header
91 FvHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*) (UINTN
) FdBase
;
94 // Make an FV Hob for the first FV in the FD
96 BuildFvHob (FdBase
, FvHeader
->FvLength
);
100 // Assume the first FD was produced by the NT32.DSC
101 // All these strange offests are needed to keep in
102 // sync with the FlashMap and NT32.dsc file
104 BuildResourceDescriptorHob (
105 EFI_RESOURCE_FIRMWARE_DEVICE
,
106 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
110 PcdGet32 (PcdFlashNvStorageVariableSize
) +
111 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
112 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
113 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize
)
117 // Hard code the address of the spare block and variable services.
118 // Assume it's a hard coded offset from FV0 in FD0.
121 PcdGet32 (PcdFlashNvStorageVariableSize
) +
122 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
123 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
124 PcdGet32 (PcdWinNtFlashNvStorageEventLogSize
);
126 BuildFvHob (FdBase
+ PcdGet32 (PcdWinNtFlashNvStorageVariableBase
), FdSize
);
129 // For other FD's just map them in.
131 BuildResourceDescriptorHob (
132 EFI_RESOURCE_FIRMWARE_DEVICE
,
133 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
141 } while (!EFI_ERROR (Status
));