]>
Commit | Line | Data |
---|---|---|
804405e7 | 1 | /*++\r |
2 | \r | |
f9b8ab56 HT |
3 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
804405e7 | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | UnixFwh.c\r | |
14 | \r | |
15 | Abstract:\r | |
16 | PEIM to abstract construction of firmware volume in an Unix environment.\r | |
17 | \r | |
18 | Revision 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 | |
31 | EFI_STATUS\r | |
32 | EFIAPI\r | |
33 | PeimInitializeUnixFwh (\r | |
f053287d | 34 | IN EFI_PEI_FILE_HANDLE FileHandle,\r |
35 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
804405e7 | 36 | )\r |
37 | /*++\r | |
38 | \r | |
39 | Routine Description:\r | |
40 | Perform a call-back into the SEC simulator to get address of the Firmware Hub\r | |
41 | \r | |
42 | Arguments:\r | |
43 | FfsHeader - Ffs Header availible to every PEIM\r | |
44 | PeiServices - General purpose services available to every PEIM.\r | |
45 | \r | |
46 | Returns:\r | |
47 | None\r | |
48 | \r | |
49 | --*/\r | |
50 | {\r | |
51 | EFI_STATUS Status;\r | |
52 | EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r | |
7ee3b613 | 53 | UNIX_FWH_PPI *FwhPpi;\r |
804405e7 | 54 | EFI_PHYSICAL_ADDRESS FdBase;\r |
7ee3b613 | 55 | EFI_PHYSICAL_ADDRESS FdFixUp;\r |
804405e7 | 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 | |
7ee3b613 | 79 | Status = FwhPpi->UnixFwh (Index, &FdBase, &FdSize, &FdFixUp);\r |
804405e7 | 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 | |
b9c8e50e | 120 | BuildFvHob (FdFixUp + PcdGet64 (PcdUnixFlashNvStorageVariableBase), FdSize);\r |
804405e7 | 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 |