]>
Commit | Line | Data |
---|---|---|
3cbfba02 DW |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
4 | \r\r | |
5 | This program and the accompanying materials are licensed and made available under\r\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution. \r\r | |
7 | The full text of the license may be found at \r\r | |
8 | http://opensource.org/licenses/bsd-license.php. \r\r | |
9 | \r\r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r\r | |
12 | \r\r | |
13 | \r | |
14 | \r | |
15 | \r | |
16 | Module Name:\r | |
17 | \r | |
18 | FlashMap.c\r | |
19 | \r | |
20 | Abstract:\r | |
21 | \r | |
22 | Build GUIDed HOBs for platform specific flash map.\r | |
23 | \r | |
24 | --*/\r | |
25 | \r | |
26 | #include "Efi.h"\r | |
27 | #include "Pei.h"\r | |
28 | #include "PeiLib.h"\r | |
29 | #include "PeiLib.h"\r | |
30 | #include "EfiFlashMap.h"\r | |
31 | #include EFI_PROTOCOL_CONSUMER (FirmwareVolumeBlock)\r | |
32 | #include EFI_GUID_DEFINITION (FlashMapHob)\r | |
33 | #include EFI_GUID_DEFINITION (SystemNvDataGuid)\r | |
34 | #include EFI_GUID_DEFINITION (FirmwareFileSystem)\r | |
35 | \r | |
36 | EFI_GUID mFvBlockGuid = EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID;\r | |
37 | EFI_GUID mFfsGuid = EFI_FIRMWARE_FILE_SYSTEM_GUID;\r | |
38 | EFI_GUID mSystemDataGuid = EFI_SYSTEM_NV_DATA_HOB_GUID;\r | |
39 | \r | |
40 | static EFI_FLASH_AREA_DATA mFlashAreaData[] = {\r | |
41 | //\r | |
42 | // Variable area\r | |
43 | //\r | |
44 | { FixedPcdGet32 (PcdFlashNvStorageVariableBase),\r | |
45 | FixedPcdGet32 (PcdFlashNvStorageVariableSize),\r | |
46 | EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV,\r | |
47 | EFI_FLASH_AREA_EFI_VARIABLES },\r | |
48 | \r | |
49 | //\r | |
50 | // Boot block 2nd part\r | |
51 | //\r | |
52 | { FixedPcdGet32 (PcdFlashFvRecovery2Base),\r | |
53 | FixedPcdGet32 (PcdFlashFvRecovery2Size),\r | |
54 | EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV,\r | |
55 | EFI_FLASH_AREA_FTW_BACKUP },\r | |
56 | \r | |
57 | //\r | |
58 | // Recovery FV\r | |
59 | //\r | |
60 | { FixedPcdGet32 (PcdFlashFvRecoveryBase),\r | |
61 | FixedPcdGet32 (PcdFlashFvRecoverySize),\r | |
62 | EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV,\r | |
63 | EFI_FLASH_AREA_RECOVERY_BIOS },\r | |
64 | \r | |
65 | //\r | |
66 | // Main FV\r | |
67 | //\r | |
68 | { FixedPcdGet32 (PcdFlashFvMainBase),\r | |
69 | FixedPcdGet32 (PcdFlashFvMainSize),\r | |
70 | EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV,\r | |
71 | EFI_FLASH_AREA_MAIN_BIOS }\r | |
72 | \r | |
73 | };\r | |
74 | \r | |
800355c4 | 75 | #define NUM_FLASH_AREA_DATA (ARRAY_SIZE (mFlashAreaData))\r |
3cbfba02 DW |
76 | \r |
77 | /**\r | |
78 | Build GUID HOBs for platform specific flash map.\r | |
79 | \r | |
80 | @param FfsHeader Pointer this FFS file header.\r | |
81 | @param PeiServices General purpose services available to every PEIM.\r | |
82 | \r | |
83 | @retval EFI_SUCCESS Guid HOBs for platform flash map is built.\r | |
84 | @retval Otherwise Failed to build the Guid HOB data.\r | |
85 | \r | |
86 | **/\r | |
87 | EFI_STATUS\r | |
88 | PeimInitializeFlashMap (\r | |
89 | IN EFI_FFS_FILE_HEADER *FfsHeader,\r | |
90 | IN EFI_PEI_SERVICES **PeiServices\r | |
91 | )\r | |
92 | {\r | |
93 | UINTN Index;\r | |
94 | EFI_FLASH_AREA_HOB_DATA FlashHobData;\r | |
95 | \r | |
96 | //\r | |
97 | // Build flash area entries as GUIDed HOBs.\r | |
98 | //\r | |
99 | for (Index = 0; Index < NUM_FLASH_AREA_DATA; Index++) {\r | |
100 | ZeroMem(&FlashHobData, sizeof (EFI_FLASH_AREA_HOB_DATA));\r | |
101 | \r | |
102 | FlashHobData.AreaType = mFlashAreaData[Index].AreaType;\r | |
103 | FlashHobData.NumberOfEntries = 1;\r | |
104 | FlashHobData.SubAreaData.Attributes = mFlashAreaData[Index].Attributes;\r | |
105 | FlashHobData.SubAreaData.Base = (EFI_PHYSICAL_ADDRESS) (UINTN) mFlashAreaData[Index].Base;\r | |
106 | FlashHobData.SubAreaData.Length = (EFI_PHYSICAL_ADDRESS) (UINTN) mFlashAreaData[Index].Length;\r | |
107 | \r | |
108 | switch (FlashHobData.AreaType) {\r | |
109 | case EFI_FLASH_AREA_RECOVERY_BIOS:\r | |
110 | case EFI_FLASH_AREA_MAIN_BIOS:\r | |
111 | CopyMem (\r | |
112 | &FlashHobData.AreaTypeGuid,\r | |
113 | &mFfsGuid,\r | |
114 | sizeof (EFI_GUID)\r | |
115 | );\r | |
116 | CopyMem (\r | |
117 | &FlashHobData.SubAreaData.FileSystem,\r | |
118 | &mFvBlockGuid,\r | |
119 | sizeof (EFI_GUID)\r | |
120 | );\r | |
121 | break;\r | |
122 | \r | |
123 | case EFI_FLASH_AREA_GUID_DEFINED:\r | |
124 | CopyMem (\r | |
125 | &FlashHobData.AreaTypeGuid,\r | |
126 | &mSystemDataGuid,\r | |
127 | sizeof (EFI_GUID)\r | |
128 | );\r | |
129 | CopyMem (\r | |
130 | &FlashHobData.SubAreaData.FileSystem,\r | |
131 | &mFvBlockGuid,\r | |
132 | sizeof (EFI_GUID)\r | |
133 | );\r | |
134 | break;\r | |
135 | \r | |
136 | default:\r | |
137 | break;\r | |
138 | }\r | |
139 | \r | |
140 | PeiBuildHobGuidData(PeiServices,\r | |
141 | &gEfiFlashMapHobGuid,\r | |
142 | &FlashHobData,\r | |
143 | sizeof (EFI_FLASH_AREA_HOB_DATA)\r | |
144 | );\r | |
145 | }\r | |
146 | return EFI_SUCCESS;\r | |
147 | }\r | |
148 | \r |