2 Header file for CD recovery PEIM
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef _PEI_CD_EXPRESS_H_
11 #define _PEI_CD_EXPRESS_H_
15 #include <Ppi/BlockIo.h>
16 #include <Ppi/BlockIo2.h>
17 #include <Guid/RecoveryDevice.h>
18 #include <Ppi/DeviceRecoveryModule.h>
20 #include <Library/DebugLib.h>
21 #include <Library/PcdLib.h>
22 #include <Library/PeimEntryPoint.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/PeiServicesTablePointerLib.h>
25 #include <Library/PeiServicesLib.h>
26 #include <Library/MemoryAllocationLib.h>
30 #define PEI_CD_EXPRESS_MAX_BLOCK_IO_PPI 8
31 #define PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER 16
33 #define PEI_CD_BLOCK_SIZE 0x800
34 #define PEI_MEMMORY_PAGE_SIZE 0x1000
37 // Following are defined according to ISO-9660 specification
39 #define PEI_CD_STANDARD_ID "CD001"
40 #define PEI_CD_EXPRESS_STANDARD_ID_SIZE 5
42 #define PEI_CD_EXPRESS_VOLUME_TYPE_OFFSET 0
43 #define PEI_CD_EXPRESS_STANDARD_ID_OFFSET 1
44 #define PEI_CD_EXPRESS_VOLUME_SPACE_OFFSET 80
45 #define PEI_CD_EXPRESS_ROOT_DIR_RECORD_OFFSET 156
47 #define PEI_CD_EXPRESS_VOLUME_TYPE_PRIMARY 1
48 #define PEI_CD_EXPRESS_VOLUME_TYPE_TERMINATOR 255
50 #define PEI_CD_EXPRESS_DIR_FILE_REC_FLAG_ISDIR 0x02
53 UINTN CapsuleStartLBA
;
55 UINTN CapsuleBlockAlignedSize
;
57 EFI_PEI_RECOVERY_BLOCK_IO_PPI
*BlockIo
;
58 EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*BlockIo2
;
59 } PEI_CD_EXPRESS_CAPSULE_DATA
;
61 #define PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('p', 'c', 'd', 'e')
65 EFI_PEI_DEVICE_RECOVERY_MODULE_PPI DeviceRecoveryPpi
;
66 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor
;
67 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor
;
68 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor2
;
72 PEI_CD_EXPRESS_CAPSULE_DATA CapsuleData
[PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER
];
73 } PEI_CD_EXPRESS_PRIVATE_DATA
;
75 #define PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS(a) \
77 PEI_CD_EXPRESS_PRIVATE_DATA, \
79 PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE \
84 UINT8 ExtendedAttributeRecordLength
;
85 UINT32 LocationOfExtent
[2];
90 UINT8 InterleaveGapSize
;
91 UINT32 VolumeSequenceNumber
;
94 } PEI_CD_EXPRESS_DIR_FILE_RECORD
;
97 BlockIo installation notification function.
99 This function finds out all the current Block IO PPIs in the system and add them
102 @param PeiServices Indirect reference to the PEI Services Table.
103 @param NotifyDescriptor Address of the notification descriptor data structure.
104 @param Ppi Address of the PPI that was installed.
106 @retval EFI_SUCCESS The function completes successfully.
112 IN EFI_PEI_SERVICES
**PeiServices
,
113 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
118 Finds out all the current Block IO PPIs in the system and add them into private data.
120 @param PrivateData The private data structure that contains recovery module information.
121 @param BlockIo2 Boolean to show whether using BlockIo2 or BlockIo.
123 @retval EFI_SUCCESS The blocks and volumes are updated successfully.
127 UpdateBlocksAndVolumes (
128 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA
*PrivateData
,
133 Returns the number of DXE capsules residing on the device.
135 This function searches for DXE capsules from the associated device and returns
136 the number and maximum size in bytes of the capsules discovered. Entry 1 is
137 assumed to be the highest load priority and entry N is assumed to be the lowest
140 @param[in] PeiServices General-purpose services that are available
142 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
144 @param[out] NumberRecoveryCapsules Pointer to a caller-allocated UINTN. On
145 output, *NumberRecoveryCapsules contains
146 the number of recovery capsule images
147 available for retrieval from this PEIM
150 @retval EFI_SUCCESS One or more capsules were discovered.
151 @retval EFI_DEVICE_ERROR A device error occurred.
152 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
157 GetNumberRecoveryCapsules (
158 IN EFI_PEI_SERVICES
**PeiServices
,
159 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
*This
,
160 OUT UINTN
*NumberRecoveryCapsules
164 Returns the size and type of the requested recovery capsule.
166 This function gets the size and type of the capsule specified by CapsuleInstance.
168 @param[in] PeiServices General-purpose services that are available to every PEIM
169 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
171 @param[in] CapsuleInstance Specifies for which capsule instance to retrieve
172 the information. This parameter must be between
173 one and the value returned by GetNumberRecoveryCapsules()
174 in NumberRecoveryCapsules.
175 @param[out] Size A pointer to a caller-allocated UINTN in which
176 the size of the requested recovery module is
178 @param[out] CapsuleType A pointer to a caller-allocated EFI_GUID in which
179 the type of the requested recovery capsule is
180 returned. The semantic meaning of the value
181 returned is defined by the implementation.
183 @retval EFI_SUCCESS One or more capsules were discovered.
184 @retval EFI_DEVICE_ERROR A device error occurred.
185 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
190 GetRecoveryCapsuleInfo (
191 IN EFI_PEI_SERVICES
**PeiServices
,
192 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
*This
,
193 IN UINTN CapsuleInstance
,
195 OUT EFI_GUID
*CapsuleType
199 Loads a DXE capsule from some media into memory.
201 This function, by whatever mechanism, retrieves a DXE capsule from some device
202 and loads it into memory. Note that the published interface is device neutral.
204 @param[in] PeiServices General-purpose services that are available
206 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
208 @param[in] CapsuleInstance Specifies which capsule instance to retrieve.
209 @param[out] Buffer Specifies a caller-allocated buffer in which
210 the requested recovery capsule will be returned.
212 @retval EFI_SUCCESS The capsule was loaded correctly.
213 @retval EFI_DEVICE_ERROR A device error occurred.
214 @retval EFI_NOT_FOUND A requested recovery DXE capsule cannot be found.
219 LoadRecoveryCapsule (
220 IN EFI_PEI_SERVICES
**PeiServices
,
221 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
*This
,
222 IN UINTN CapsuleInstance
,
227 Finds out the recovery capsule in the current volume.
229 @param PrivateData The private data structure that contains recovery module information.
231 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
232 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
237 FindRecoveryCapsules (
238 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA
*PrivateData
242 Retrieves the recovery capsule in root directory of the current volume.
244 @param PrivateData The private data structure that contains recovery module information.
245 @param BlockIoPpi The Block IO PPI used to access the volume.
246 @param BlockIo2Ppi The Block IO 2 PPI used to access the volume.
247 @param IndexBlockDevice The index of current block device.
248 @param Lba The starting logic block address to retrieve capsule.
250 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
251 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
257 RetrieveCapsuleFileFromRoot (
258 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA
*PrivateData
,
259 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*BlockIoPpi
,
260 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*BlockIo2Ppi
,
261 IN UINTN IndexBlockDevice
,
266 This function compares two ASCII strings in case sensitive/insensitive way.
268 @param Source1 The first string.
269 @param Source2 The second string.
270 @param Size The maximum comparison length.
271 @param CaseSensitive Flag to indicate whether the comparison is case sensitive.
273 @retval TRUE The two strings are the same.
274 @retval FALSE The two string are not the same.
282 IN BOOLEAN CaseSensitive