]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/UnixFirmwareVolumePei/UnixFwh.c
Update the copyright notice format
[mirror_edk2.git] / UnixPkg / UnixFirmwareVolumePei / UnixFwh.c
1 /*++
2
3 Copyright (c) 2006 - 2008, 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
8
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.
11
12 Module Name:
13 UnixFwh.c
14
15 Abstract:
16 PEIM to abstract construction of firmware volume in an Unix environment.
17
18 Revision History
19
20 --*/
21
22 #include "PiPei.h"
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>
30
31 EFI_STATUS
32 EFIAPI
33 PeimInitializeUnixFwh (
34 IN EFI_PEI_FILE_HANDLE FileHandle,
35 IN CONST EFI_PEI_SERVICES **PeiServices
36 )
37 /*++
38
39 Routine Description:
40 Perform a call-back into the SEC simulator to get address of the Firmware Hub
41
42 Arguments:
43 FfsHeader - Ffs Header availible to every PEIM
44 PeiServices - General purpose services available to every PEIM.
45
46 Returns:
47 None
48
49 --*/
50 {
51 EFI_STATUS Status;
52 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
53 UNIX_FWH_PPI *FwhPpi;
54 EFI_PHYSICAL_ADDRESS FdBase;
55 EFI_PHYSICAL_ADDRESS FdFixUp;
56 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
57 UINT64 FdSize;
58 UINTN Index;
59
60 DEBUG ((EFI_D_ERROR, "Unix Firmware Volume PEIM Loaded\n"));
61
62 //
63 // Get the Fwh Information PPI
64 //
65 Status = (**PeiServices).LocatePpi (
66 PeiServices,
67 &gUnixFwhPpiGuid, // GUID
68 0, // INSTANCE
69 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
70 (VOID **)&FwhPpi // PPI
71 );
72 ASSERT_EFI_ERROR (Status);
73
74 Index = 0;
75 do {
76 //
77 // Get information about all the FD's in the system
78 //
79 Status = FwhPpi->UnixFwh (Index, &FdBase, &FdSize, &FdFixUp);
80 if (!EFI_ERROR (Status)) {
81 //
82 // Assume the FD starts with an FV header
83 //
84 FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;
85
86 //
87 // Make an FV Hob for the first FV in the FD
88 //
89 BuildFvHob (FdBase, FvHeader->FvLength);
90
91 if (Index == 0) {
92 //
93 // Assume the first FD was produced by the NT32.DSC
94 // All these strange offests are needed to keep in
95 // sync with the FlashMap and NT32.dsc file
96 //
97 BuildResourceDescriptorHob (
98 EFI_RESOURCE_FIRMWARE_DEVICE,
99 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),
100 FdBase,
101 (
102 FvHeader->FvLength +
103 PcdGet32 (PcdFlashNvStorageVariableSize) +
104 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
105 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +
106 PcdGet32 (PcdUnixFlashNvStorageEventLogSize)
107 )
108 );
109
110 //
111 // Hard code the address of the spare block and variable services.
112 // Assume it's a hard coded offset from FV0 in FD0.
113 //
114 FdSize =
115 PcdGet32 (PcdFlashNvStorageVariableSize) +
116 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
117 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +
118 PcdGet32 (PcdUnixFlashNvStorageEventLogSize);
119
120 BuildFvHob (FdFixUp + PcdGet32 (PcdUnixFlashNvStorageVariableBase), FdSize);
121 } else {
122 //
123 // For other FD's just map them in.
124 //
125 BuildResourceDescriptorHob (
126 EFI_RESOURCE_FIRMWARE_DEVICE,
127 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),
128 FdBase,
129 FdSize
130 );
131 }
132 }
133
134 Index++;
135 } while (!EFI_ERROR (Status));
136
137 return Status;
138 }