]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h
MdeModulePkg CdExpressPei: Use correct PeiServices pointer to call low level BlockIoP...
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / CdExpressPei / PeiCdExpress.h
CommitLineData
30c00a1c 1/** @file\r
2 Header file for CD recovery PEIM\r
3\r
56a9e699 4Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
30c00a1c 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
30c00a1c 77 EFI_PEI_DEVICE_RECOVERY_MODULE_PPI DeviceRecoveryPpi;\r
78 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;\r
79 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;\r
80\r
81 UINT8 *BlockBuffer;\r
82 UINTN CapsuleCount;\r
83 PEI_CD_EXPRESS_CAPSULE_DATA CapsuleData[PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER];\r
84\r
85} PEI_CD_EXPRESS_PRIVATE_DATA;\r
86\r
87#define PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS(a) \\r
88 CR (a, \\r
89 PEI_CD_EXPRESS_PRIVATE_DATA, \\r
90 DeviceRecoveryPpi, \\r
91 PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE \\r
92 )\r
93\r
94typedef struct {\r
95 UINT8 Length;\r
96 UINT8 ExtendedAttributeRecordLength;\r
97 UINT32 LocationOfExtent[2];\r
98 UINT32 DataLength[2];\r
99 UINT8 DateTime[7];\r
100 UINT8 Flag;\r
101 UINT8 FileUnitSize;\r
102 UINT8 InterleaveGapSize;\r
103 UINT32 VolumeSequenceNumber;\r
104 UINT8 FileIDLength;\r
105 UINT8 FileID[1];\r
106} PEI_CD_EXPRESS_DIR_FILE_RECORD;\r
107\r
108/**\r
109 BlockIo installation notification function. \r
110 \r
111 This function finds out all the current Block IO PPIs in the system and add them\r
112 into private data.\r
113\r
114 @param PeiServices Indirect reference to the PEI Services Table.\r
115 @param NotifyDescriptor Address of the notification descriptor data structure.\r
116 @param Ppi Address of the PPI that was installed.\r
117\r
118 @retval EFI_SUCCESS The function completes successfully.\r
119\r
120**/\r
121EFI_STATUS\r
122EFIAPI\r
123BlockIoNotifyEntry (\r
124 IN EFI_PEI_SERVICES **PeiServices,\r
125 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
126 IN VOID *Ppi\r
127 );\r
128\r
129/**\r
130 Finds out all the current Block IO PPIs in the system and add them into private data.\r
131\r
132 @param PrivateData The private data structure that contains recovery module information.\r
133\r
134 @retval EFI_SUCCESS The blocks and volumes are updated successfully.\r
135\r
136**/\r
137EFI_STATUS\r
138UpdateBlocksAndVolumes (\r
139 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData\r
140 );\r
141\r
142/**\r
143 Returns the number of DXE capsules residing on the device.\r
144\r
145 This function searches for DXE capsules from the associated device and returns\r
146 the number and maximum size in bytes of the capsules discovered. Entry 1 is \r
147 assumed to be the highest load priority and entry N is assumed to be the lowest \r
148 priority.\r
149\r
150 @param[in] PeiServices General-purpose services that are available \r
151 to every PEIM\r
152 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI\r
153 instance.\r
154 @param[out] NumberRecoveryCapsules Pointer to a caller-allocated UINTN. On \r
155 output, *NumberRecoveryCapsules contains \r
156 the number of recovery capsule images \r
157 available for retrieval from this PEIM \r
158 instance.\r
159\r
160 @retval EFI_SUCCESS One or more capsules were discovered.\r
161 @retval EFI_DEVICE_ERROR A device error occurred.\r
162 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.\r
163\r
164**/\r
165EFI_STATUS\r
166EFIAPI\r
167GetNumberRecoveryCapsules (\r
168 IN EFI_PEI_SERVICES **PeiServices,\r
169 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,\r
170 OUT UINTN *NumberRecoveryCapsules\r
171 );\r
172\r
173/**\r
174 Returns the size and type of the requested recovery capsule.\r
175\r
176 This function gets the size and type of the capsule specified by CapsuleInstance.\r
177\r
178 @param[in] PeiServices General-purpose services that are available to every PEIM\r
179 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI \r
180 instance.\r
181 @param[in] CapsuleInstance Specifies for which capsule instance to retrieve \r
182 the information. This parameter must be between \r
183 one and the value returned by GetNumberRecoveryCapsules() \r
184 in NumberRecoveryCapsules.\r
185 @param[out] Size A pointer to a caller-allocated UINTN in which \r
186 the size of the requested recovery module is \r
187 returned.\r
188 @param[out] CapsuleType A pointer to a caller-allocated EFI_GUID in which \r
189 the type of the requested recovery capsule is \r
190 returned. The semantic meaning of the value \r
191 returned is defined by the implementation.\r
192\r
193 @retval EFI_SUCCESS One or more capsules were discovered.\r
194 @retval EFI_DEVICE_ERROR A device error occurred.\r
195 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.\r
196\r
197**/\r
198EFI_STATUS\r
199EFIAPI\r
200GetRecoveryCapsuleInfo (\r
201 IN EFI_PEI_SERVICES **PeiServices,\r
202 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,\r
203 IN UINTN CapsuleInstance,\r
204 OUT UINTN *Size,\r
205 OUT EFI_GUID *CapsuleType\r
206 );\r
207\r
208/**\r
209 Loads a DXE capsule from some media into memory.\r
210\r
211 This function, by whatever mechanism, retrieves a DXE capsule from some device\r
212 and loads it into memory. Note that the published interface is device neutral.\r
213\r
214 @param[in] PeiServices General-purpose services that are available \r
215 to every PEIM\r
216 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI\r
217 instance.\r
218 @param[in] CapsuleInstance Specifies which capsule instance to retrieve.\r
219 @param[out] Buffer Specifies a caller-allocated buffer in which \r
220 the requested recovery capsule will be returned.\r
221\r
222 @retval EFI_SUCCESS The capsule was loaded correctly.\r
223 @retval EFI_DEVICE_ERROR A device error occurred.\r
224 @retval EFI_NOT_FOUND A requested recovery DXE capsule cannot be found.\r
225\r
226**/\r
227EFI_STATUS\r
228EFIAPI\r
229LoadRecoveryCapsule (\r
230 IN EFI_PEI_SERVICES **PeiServices,\r
231 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,\r
232 IN UINTN CapsuleInstance,\r
233 OUT VOID *Buffer\r
234 );\r
235\r
236/**\r
237 Finds out the recovery capsule in the current volume.\r
238\r
239 @param PrivateData The private data structure that contains recovery module information.\r
240\r
241 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.\r
242 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.\r
243\r
244**/\r
245EFI_STATUS\r
246EFIAPI\r
247FindRecoveryCapsules (\r
248 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData\r
249 );\r
250\r
251/**\r
252 Retrieves the recovery capsule in root directory of the current volume.\r
253\r
254 @param PrivateData The private data structure that contains recovery module information.\r
255 @param BlockIoPpi The Block IO PPI used to access the volume.\r
256 @param IndexBlockDevice The index of current block device.\r
257 @param Lba The starting logic block address to retrieve capsule.\r
258\r
259 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.\r
260 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.\r
261 @retval Others \r
262\r
263**/\r
264EFI_STATUS\r
265EFIAPI\r
266RetrieveCapsuleFileFromRoot (\r
267 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,\r
268 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIoPpi,\r
269 IN UINTN IndexBlockDevice,\r
270 IN UINT32 Lba\r
271 );\r
272\r
273\r
274/**\r
275 This function compares two ASCII strings in case sensitive/insensitive way.\r
276\r
277 @param Source1 The first string.\r
278 @param Source2 The second string.\r
279 @param Size The maximum comparison length.\r
280 @param CaseSensitive Flag to indicate whether the comparison is case sensitive.\r
281\r
282 @retval TRUE The two strings are the same.\r
283 @retval FALSE The two string are not the same.\r
284\r
285**/\r
286BOOLEAN\r
287StringCmp (\r
288 IN UINT8 *Source1,\r
289 IN UINT8 *Source2,\r
290 IN UINTN Size,\r
291 IN BOOLEAN CaseSensitive\r
292 );\r
293\r
294#pragma pack()\r
295\r
296#endif\r