3 Copyright (c) 2006 - 2008, 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 an Unix environment.
23 #include <Ppi/UnixFwh.h>
24 #include <Library/DebugLib.h>
25 #include <Library/PeimEntryPoint.h>
26 #include <Library/HobLib.h>
27 #include <Library/PeiServicesLib.h>
28 #include <Library/PeiServicesTablePointerLib.h>
29 #include <Library/PcdLib.h>
33 PeimInitializeUnixFwh (
34 IN EFI_FFS_FILE_HEADER
*FfsHeader
,
35 IN EFI_PEI_SERVICES
**PeiServices
40 Perform a call-back into the SEC simulator to get address of the Firmware Hub
43 FfsHeader - Ffs Header availible to every PEIM
44 PeiServices - General purpose services available to every PEIM.
52 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
54 EFI_PHYSICAL_ADDRESS FdBase
;
55 EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
;
59 DEBUG ((EFI_D_ERROR
, "Unix Firmware Volume PEIM Loaded\n"));
62 // Get the Fwh Information PPI
64 Status
= (**PeiServices
).LocatePpi (
66 &gUnixFwhPpiGuid
, // GUID
68 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
69 (VOID
**)&FwhPpi
// PPI
71 ASSERT_EFI_ERROR (Status
);
76 // Get information about all the FD's in the system
78 Status
= FwhPpi
->UnixFwh (Index
, &FdBase
, &FdSize
);
79 if (!EFI_ERROR (Status
)) {
81 // Assume the FD starts with an FV header
83 FvHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*) (UINTN
) FdBase
;
86 // Make an FV Hob for the first FV in the FD
88 BuildFvHob (FdBase
, FvHeader
->FvLength
);
92 // Assume the first FD was produced by the NT32.DSC
93 // All these strange offests are needed to keep in
94 // sync with the FlashMap and NT32.dsc file
96 BuildResourceDescriptorHob (
97 EFI_RESOURCE_FIRMWARE_DEVICE
,
98 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
102 PcdGet32 (PcdFlashNvStorageVariableSize
) +
103 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
104 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
105 PcdGet32 (PcdUnixFlashNvStorageEventLogSize
)
110 // Hard code the address of the spare block and variable services.
111 // Assume it's a hard coded offset from FV0 in FD0.
114 PcdGet32 (PcdFlashNvStorageVariableSize
) +
115 PcdGet32 (PcdFlashNvStorageFtwWorkingSize
) +
116 PcdGet32 (PcdFlashNvStorageFtwSpareSize
) +
117 PcdGet32 (PcdUnixFlashNvStorageEventLogSize
);
119 BuildFvHob (FdBase
+ PcdGet32 (PcdUnixFlashNvStorageVariableBase
), FdSize
);
122 // For other FD's just map them in.
124 BuildResourceDescriptorHob (
125 EFI_RESOURCE_FIRMWARE_DEVICE
,
126 (EFI_RESOURCE_ATTRIBUTE_PRESENT
| EFI_RESOURCE_ATTRIBUTE_INITIALIZED
| EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
),
134 } while (!EFI_ERROR (Status
));