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