]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/UnixFirmwareVolumePei/UnixFwh.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / UnixPkg / UnixFirmwareVolumePei / UnixFwh.c
CommitLineData
804405e7 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_FFS_FILE_HEADER *FfsHeader,\r
35 IN 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_FIRMWARE_VOLUME_HEADER *FvHeader;\r
56 UINT64 FdSize;\r
57 UINTN Index;\r
58\r
59 DEBUG ((EFI_D_ERROR, "Unix Firmware Volume PEIM Loaded\n"));\r
60\r
61 //\r
62 // Get the Fwh Information PPI\r
63 //\r
64 Status = (**PeiServices).LocatePpi (\r
65 PeiServices,\r
66 &gUnixFwhPpiGuid, // GUID\r
67 0, // INSTANCE\r
68 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
69 (VOID **)&FwhPpi // PPI\r
70 );\r
71 ASSERT_EFI_ERROR (Status);\r
72\r
73 Index = 0;\r
74 do {\r
75 //\r
76 // Get information about all the FD's in the system\r
77 //\r
78 Status = FwhPpi->UnixFwh (Index, &FdBase, &FdSize);\r
79 if (!EFI_ERROR (Status)) {\r
80 //\r
81 // Assume the FD starts with an FV header\r
82 //\r
83 FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;\r
84\r
85 //\r
86 // Make an FV Hob for the first FV in the FD\r
87 //\r
88 BuildFvHob (FdBase, FvHeader->FvLength);\r
89\r
90 if (Index == 0) {\r
91 //\r
92 // Assume the first FD was produced by the NT32.DSC\r
93 // All these strange offests are needed to keep in\r
94 // sync with the FlashMap and NT32.dsc file\r
95 //\r
96 BuildResourceDescriptorHob (\r
97 EFI_RESOURCE_FIRMWARE_DEVICE,\r
98 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
99 FdBase,\r
100 ( \r
101 FvHeader->FvLength + \r
102 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
103 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
104 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
105 PcdGet32 (PcdUnixFlashNvStorageEventLogSize)\r
106 )\r
107 );\r
108\r
109 //\r
110 // Hard code the address of the spare block and variable services.\r
111 // Assume it's a hard coded offset from FV0 in FD0.\r
112 //\r
113 FdSize = \r
114 PcdGet32 (PcdFlashNvStorageVariableSize) +\r
115 PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
116 PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
117 PcdGet32 (PcdUnixFlashNvStorageEventLogSize);\r
118\r
119 BuildFvHob (FdBase + PcdGet32 (PcdUnixFlashNvStorageVariableBase), FdSize);\r
120 } else {\r
121 //\r
122 // For other FD's just map them in.\r
123 //\r
124 BuildResourceDescriptorHob (\r
125 EFI_RESOURCE_FIRMWARE_DEVICE,\r
126 (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
127 FdBase,\r
128 FdSize\r
129 );\r
130 }\r
131 }\r
132\r
133 Index++;\r
134 } while (!EFI_ERROR (Status));\r
135\r
136 return Status;\r
137}\r