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>
38 #include <FlashLayout.h>
43 PeimInitializeWinNtFwh (
44 IN EFI_FFS_FILE_HEADER
*FfsHeader
,
45 IN EFI_PEI_SERVICES
**PeiServices
50 Perform a call-back into the SEC simulator to get address of the Firmware Hub
53 FfsHeader - Ffs Header availible to every PEIM
54 PeiServices - General purpose services available to every PEIM.
62 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
64 EFI_PHYSICAL_ADDRESS FdBase
;
65 EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
;
69 DEBUG ((EFI_D_ERROR
, "NT 32 Firmware Volume PEIM Loaded\n"));
72 // Get the Fwh Information PPI
74 Status
= (**PeiServices
).LocatePpi (
76 &gNtFwhPpiGuid
, // GUID
78 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
81 ASSERT_EFI_ERROR (Status
);
86 // Get information about all the FD's in the system
88 Status
= FwhPpi
->NtFwh (Index
, &FdBase
, &FdSize
);
89 if (!EFI_ERROR (Status
)) {
91 // Assume the FD starts with an FV header
93 FvHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*) (UINTN
) FdBase
;
96 // Make an FV Hob for the first FV in the FD
98 BuildFvHob (FdBase
, FvHeader
->FvLength
);
102 // Assume the first FD was produced by the NT32.DSC
103 // All these strange offests are needed to keep in
104 // sync with the FlashMap and NT32.dsc file
106 BuildResourceDescriptorHob (
107 EFI_RESOURCE_FIRMWARE_DEVICE
,
108 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
110 (FvHeader
->FvLength
+ EFI_WINNT_RUNTIME_UPDATABLE_LENGTH
+ EFI_WINNT_FTW_SPARE_BLOCK_LENGTH
)
114 // Hard code the address of the spare block and variable services.
115 // Assume it's a hard coded offset from FV0 in FD0.
117 FdBase
= FdBase
+ EFI_WINNT_RUNTIME_UPDATABLE_OFFSET
;
118 FdSize
= EFI_WINNT_RUNTIME_UPDATABLE_LENGTH
+ EFI_WINNT_FTW_SPARE_BLOCK_LENGTH
;
120 BuildFvHob (FdBase
, 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
));