]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - UnixPkg/UnixFirmwareVolumePei/UnixFwh.c
Added support for Xcode on Snow Leopard. Upaded with bug fixes for Snow Leopard.
[mirror_edk2.git] / UnixPkg / UnixFirmwareVolumePei / UnixFwh.c
... / ...
CommitLineData
1/*++\r
2\r
3Copyright (c) 2006 - 2008, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13 UnixFwh.c\r
14 \r
15Abstract:\r
16 PEIM to abstract construction of firmware volume in an Unix environment.\r
17\r
18Revision History\r
19\r
20--*/\r
21\r
22#include "PiPei.h"\r
23#include <Ppi/UnixFwh.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/PeimEntryPoint.h>\r
26#include <Library/HobLib.h>\r
27#include <Library/PeiServicesLib.h>\r
28#include <Library/PeiServicesTablePointerLib.h>\r
29#include <Library/PcdLib.h>\r
30\r
31EFI_STATUS\r
32EFIAPI\r
33PeimInitializeUnixFwh (\r
34 IN EFI_PEI_FILE_HANDLE FileHandle,\r
35 IN CONST EFI_PEI_SERVICES **PeiServices\r
36 )\r
37/*++\r
38\r
39Routine Description:\r
40 Perform a call-back into the SEC simulator to get address of the Firmware Hub\r
41\r
42Arguments:\r
43 FfsHeader - Ffs Header availible to every PEIM\r
44 PeiServices - General purpose services available to every PEIM.\r
45 \r
46Returns:\r
47 None\r
48\r
49--*/\r
50{\r
51 EFI_STATUS Status;\r
52 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
53 UNIX_FWH_PPI *FwhPpi;\r
54 EFI_PHYSICAL_ADDRESS FdBase;\r
55 EFI_PHYSICAL_ADDRESS FdFixUp;\r
56 EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
57 UINT64 FdSize;\r
58 UINTN Index;\r
59\r
60 DEBUG ((EFI_D_ERROR, "Unix Firmware Volume PEIM Loaded\n"));\r
61\r
62 //\r
63 // Get the Fwh Information PPI\r
64 //\r
65 Status = (**PeiServices).LocatePpi (\r
66 PeiServices,\r
67 &gUnixFwhPpiGuid, // GUID\r
68 0, // INSTANCE\r
69 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
70 (VOID **)&FwhPpi // PPI\r
71 );\r
72 ASSERT_EFI_ERROR (Status);\r
73\r
74 Index = 0;\r
75 do {\r
76 //\r
77 // Get information about all the FD's in the system\r
78 //\r
79 Status = FwhPpi->UnixFwh (Index, &FdBase, &FdSize, &FdFixUp);\r
80 if (!EFI_ERROR (Status)) {\r
81 //\r
82 // Assume the FD starts with an FV header\r
83 //\r
84 FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;\r
85\r
86 //\r
87 // Make an FV Hob for the first FV in the FD\r
88 //\r
89 BuildFvHob (FdBase, FvHeader->FvLength);\r
90\r
91 if (Index == 0) {\r
92 //\r
93 // Assume the first FD was produced by the NT32.DSC\r
94 // All these strange offests are needed to keep in\r
95 // sync with the FlashMap and NT32.dsc file\r
96 //\r
97 BuildResourceDescriptorHob (\r
98 EFI_RESOURCE_FIRMWARE_DEVICE,\r
99 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
100 FdBase,\r
101 ( \r
102 FvHeader->FvLength + \r
103 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
104 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
105 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
106 PcdGet32 (PcdUnixFlashNvStorageEventLogSize)\r
107 )\r
108 );\r
109\r
110 //\r
111 // Hard code the address of the spare block and variable services.\r
112 // Assume it's a hard coded offset from FV0 in FD0.\r
113 //\r
114 FdSize = \r
115 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
116 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
117 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
118 PcdGet32 (PcdUnixFlashNvStorageEventLogSize);\r
119\r
120 BuildFvHob (FdFixUp + PcdGet32 (PcdUnixFlashNvStorageVariableBase), FdSize);\r
121 } else {\r
122 //\r
123 // For other FD's just map them in.\r
124 //\r
125 BuildResourceDescriptorHob (\r
126 EFI_RESOURCE_FIRMWARE_DEVICE,\r
127 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
128 FdBase,\r
129 FdSize\r
130 );\r
131 }\r
132 }\r
133\r
134 Index++;\r
135 } while (!EFI_ERROR (Status));\r
136\r
137 return Status;\r
138}\r