]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h
MdeModulePkg: Add CD Express PEIM
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / CdExpressPei / PeiCdExpress.h
CommitLineData
30c00a1c 1/** @file\r
2 Header file for CD recovery PEIM\r
3\r
4Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
5\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions\r
8of the BSD License which accompanies this distribution. The\r
9full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#ifndef _PEI_CD_EXPRESS_H_\r
18#define _PEI_CD_EXPRESS_H_\r
19\r
20\r
21#include <PiPei.h>\r
22\r
23#include <Ppi/BlockIo.h>\r
24#include <Guid/RecoveryDevice.h>\r
25#include <Ppi/DeviceRecoveryModule.h>\r
26\r
27#include <Library/DebugLib.h>\r
28#include <Library/PcdLib.h>\r
29#include <Library/PeimEntryPoint.h>\r
30#include <Library/BaseMemoryLib.h>\r
31#include <Library/PeiServicesTablePointerLib.h>\r
32#include <Library/PeiServicesLib.h>\r
33#include <Library/MemoryAllocationLib.h>\r
34\r
35\r
36#pragma pack(1)\r
37\r
38#define PEI_CD_EXPRESS_MAX_BLOCK_IO_PPI 8\r
39#define PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER 16\r
40\r
41#define PEI_CD_BLOCK_SIZE 0x800\r
42#define PEI_MEMMORY_PAGE_SIZE 0x1000\r
43\r
44//\r
45// Recovery file name (in root directory)\r
46//\r
47#define PEI_RECOVERY_FILE_NAME "FVMAIN.FV"\r
48\r
49//\r
50// Following are defined according to ISO-9660 specification\r
51//\r
52#define PEI_CD_STANDARD_ID "CD001"\r
53#define PEI_CD_EXPRESS_STANDARD_ID_SIZE 5\r
54\r
55#define PEI_CD_EXPRESS_VOLUME_TYPE_OFFSET 0\r
56#define PEI_CD_EXPRESS_STANDARD_ID_OFFSET 1\r
57#define PEI_CD_EXPRESS_VOLUME_SPACE_OFFSET 80\r
58#define PEI_CD_EXPRESS_ROOT_DIR_RECORD_OFFSET 156\r
59\r
60#define PEI_CD_EXPRESS_VOLUME_TYPE_PRIMARY 1\r
61#define PEI_CD_EXPRESS_VOLUME_TYPE_TERMINATOR 255\r
62\r
63#define PEI_CD_EXPRESS_DIR_FILE_REC_FLAG_ISDIR 0x02\r
64\r
65typedef struct {\r
66 UINTN CapsuleStartLBA;\r
67 UINTN CapsuleSize;\r
68 UINTN IndexBlock;\r
69 EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIo;\r
70} PEI_CD_EXPRESS_CAPSULE_DATA;\r
71\r
72#define PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('p', 'c', 'd', 'e')\r
73\r
74typedef struct {\r
75\r
76 UINTN Signature;\r
77 EFI_PEI_SERVICES **PeiServices;\r
78 EFI_PEI_DEVICE_RECOVERY_MODULE_PPI DeviceRecoveryPpi;\r
79 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;\r
80 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;\r
81\r
82 UINT8 *BlockBuffer;\r
83 UINTN CapsuleCount;\r
84 PEI_CD_EXPRESS_CAPSULE_DATA CapsuleData[PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER];\r
85\r
86} PEI_CD_EXPRESS_PRIVATE_DATA;\r
87\r
88#define PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS(a) \\r
89 CR (a, \\r
90 PEI_CD_EXPRESS_PRIVATE_DATA, \\r
91 DeviceRecoveryPpi, \\r
92 PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE \\r
93 )\r
94\r
95typedef struct {\r
96 UINT8 Length;\r
97 UINT8 ExtendedAttributeRecordLength;\r
98 UINT32 LocationOfExtent[2];\r
99 UINT32 DataLength[2];\r
100 UINT8 DateTime[7];\r
101 UINT8 Flag;\r
102 UINT8 FileUnitSize;\r
103 UINT8 InterleaveGapSize;\r
104 UINT32 VolumeSequenceNumber;\r
105 UINT8 FileIDLength;\r
106 UINT8 FileID[1];\r
107} PEI_CD_EXPRESS_DIR_FILE_RECORD;\r
108\r
109/**\r
110 BlockIo installation notification function. \r
111 \r
112 This function finds out all the current Block IO PPIs in the system and add them\r
113 into private data.\r
114\r
115 @param PeiServices Indirect reference to the PEI Services Table.\r
116 @param NotifyDescriptor Address of the notification descriptor data structure.\r
117 @param Ppi Address of the PPI that was installed.\r
118\r
119 @retval EFI_SUCCESS The function completes successfully.\r
120\r
121**/\r
122EFI_STATUS\r
123EFIAPI\r
124BlockIoNotifyEntry (\r
125 IN EFI_PEI_SERVICES **PeiServices,\r
126 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
127 IN VOID *Ppi\r
128 );\r
129\r
130/**\r
131 Finds out all the current Block IO PPIs in the system and add them into private data.\r
132\r
133 @param PrivateData The private data structure that contains recovery module information.\r
134\r
135 @retval EFI_SUCCESS The blocks and volumes are updated successfully.\r
136\r
137**/\r
138EFI_STATUS\r
139UpdateBlocksAndVolumes (\r
140 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData\r
141 );\r
142\r
143/**\r
144 Returns the number of DXE capsules residing on the device.\r
145\r
146 This function searches for DXE capsules from the associated device and returns\r
147 the number and maximum size in bytes of the capsules discovered. Entry 1 is \r
148 assumed to be the highest load priority and entry N is assumed to be the lowest \r
149 priority.\r
150\r
151 @param[in] PeiServices General-purpose services that are available \r
152 to every PEIM\r
153 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI\r
154 instance.\r
155 @param[out] NumberRecoveryCapsules Pointer to a caller-allocated UINTN. On \r
156 output, *NumberRecoveryCapsules contains \r
157 the number of recovery capsule images \r
158 available for retrieval from this PEIM \r
159 instance.\r
160\r
161 @retval EFI_SUCCESS One or more capsules were discovered.\r
162 @retval EFI_DEVICE_ERROR A device error occurred.\r
163 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.\r
164\r
165**/\r
166EFI_STATUS\r
167EFIAPI\r
168GetNumberRecoveryCapsules (\r
169 IN EFI_PEI_SERVICES **PeiServices,\r
170 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,\r
171 OUT UINTN *NumberRecoveryCapsules\r
172 );\r
173\r
174/**\r
175 Returns the size and type of the requested recovery capsule.\r
176\r
177 This function gets the size and type of the capsule specified by CapsuleInstance.\r
178\r
179 @param[in] PeiServices General-purpose services that are available to every PEIM\r
180 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI \r
181 instance.\r
182 @param[in] CapsuleInstance Specifies for which capsule instance to retrieve \r
183 the information. This parameter must be between \r
184 one and the value returned by GetNumberRecoveryCapsules() \r
185 in NumberRecoveryCapsules.\r
186 @param[out] Size A pointer to a caller-allocated UINTN in which \r
187 the size of the requested recovery module is \r
188 returned.\r
189 @param[out] CapsuleType A pointer to a caller-allocated EFI_GUID in which \r
190 the type of the requested recovery capsule is \r
191 returned. The semantic meaning of the value \r
192 returned is defined by the implementation.\r
193\r
194 @retval EFI_SUCCESS One or more capsules were discovered.\r
195 @retval EFI_DEVICE_ERROR A device error occurred.\r
196 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.\r
197\r
198**/\r
199EFI_STATUS\r
200EFIAPI\r
201GetRecoveryCapsuleInfo (\r
202 IN EFI_PEI_SERVICES **PeiServices,\r
203 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,\r
204 IN UINTN CapsuleInstance,\r
205 OUT UINTN *Size,\r
206 OUT EFI_GUID *CapsuleType\r
207 );\r
208\r
209/**\r
210 Loads a DXE capsule from some media into memory.\r
211\r
212 This function, by whatever mechanism, retrieves a DXE capsule from some device\r
213 and loads it into memory. Note that the published interface is device neutral.\r
214\r
215 @param[in] PeiServices General-purpose services that are available \r
216 to every PEIM\r
217 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI\r
218 instance.\r
219 @param[in] CapsuleInstance Specifies which capsule instance to retrieve.\r
220 @param[out] Buffer Specifies a caller-allocated buffer in which \r
221 the requested recovery capsule will be returned.\r
222\r
223 @retval EFI_SUCCESS The capsule was loaded correctly.\r
224 @retval EFI_DEVICE_ERROR A device error occurred.\r
225 @retval EFI_NOT_FOUND A requested recovery DXE capsule cannot be found.\r
226\r
227**/\r
228EFI_STATUS\r
229EFIAPI\r
230LoadRecoveryCapsule (\r
231 IN EFI_PEI_SERVICES **PeiServices,\r
232 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,\r
233 IN UINTN CapsuleInstance,\r
234 OUT VOID *Buffer\r
235 );\r
236\r
237/**\r
238 Finds out the recovery capsule in the current volume.\r
239\r
240 @param PrivateData The private data structure that contains recovery module information.\r
241\r
242 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.\r
243 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.\r
244\r
245**/\r
246EFI_STATUS\r
247EFIAPI\r
248FindRecoveryCapsules (\r
249 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData\r
250 );\r
251\r
252/**\r
253 Retrieves the recovery capsule in root directory of the current volume.\r
254\r
255 @param PrivateData The private data structure that contains recovery module information.\r
256 @param BlockIoPpi The Block IO PPI used to access the volume.\r
257 @param IndexBlockDevice The index of current block device.\r
258 @param Lba The starting logic block address to retrieve capsule.\r
259\r
260 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.\r
261 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.\r
262 @retval Others \r
263\r
264**/\r
265EFI_STATUS\r
266EFIAPI\r
267RetrieveCapsuleFileFromRoot (\r
268 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,\r
269 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIoPpi,\r
270 IN UINTN IndexBlockDevice,\r
271 IN UINT32 Lba\r
272 );\r
273\r
274\r
275/**\r
276 This function compares two ASCII strings in case sensitive/insensitive way.\r
277\r
278 @param Source1 The first string.\r
279 @param Source2 The second string.\r
280 @param Size The maximum comparison length.\r
281 @param CaseSensitive Flag to indicate whether the comparison is case sensitive.\r
282\r
283 @retval TRUE The two strings are the same.\r
284 @retval FALSE The two string are not the same.\r
285\r
286**/\r
287BOOLEAN\r
288StringCmp (\r
289 IN UINT8 *Source1,\r
290 IN UINT8 *Source2,\r
291 IN UINTN Size,\r
292 IN BOOLEAN CaseSensitive\r
293 );\r
294\r
295#pragma pack()\r
296\r
297#endif\r