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_
16 #include <Ppi/BlockIo.h>
17 #include <Ppi/BlockIo2.h>
18 #include <Guid/RecoveryDevice.h>
19 #include <Ppi/DeviceRecoveryModule.h>
21 #include <Library/DebugLib.h>
22 #include <Library/PcdLib.h>
23 #include <Library/PeimEntryPoint.h>
24 #include <Library/BaseMemoryLib.h>
25 #include <Library/PeiServicesTablePointerLib.h>
26 #include <Library/PeiServicesLib.h>
27 #include <Library/MemoryAllocationLib.h>
32 #define PEI_CD_EXPRESS_MAX_BLOCK_IO_PPI 8
33 #define PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER 16
35 #define PEI_CD_BLOCK_SIZE 0x800
36 #define PEI_MEMMORY_PAGE_SIZE 0x1000
39 // Following are defined according to ISO-9660 specification
41 #define PEI_CD_STANDARD_ID "CD001"
42 #define PEI_CD_EXPRESS_STANDARD_ID_SIZE 5
44 #define PEI_CD_EXPRESS_VOLUME_TYPE_OFFSET 0
45 #define PEI_CD_EXPRESS_STANDARD_ID_OFFSET 1
46 #define PEI_CD_EXPRESS_VOLUME_SPACE_OFFSET 80
47 #define PEI_CD_EXPRESS_ROOT_DIR_RECORD_OFFSET 156
49 #define PEI_CD_EXPRESS_VOLUME_TYPE_PRIMARY 1
50 #define PEI_CD_EXPRESS_VOLUME_TYPE_TERMINATOR 255
52 #define PEI_CD_EXPRESS_DIR_FILE_REC_FLAG_ISDIR 0x02
55 UINTN CapsuleStartLBA
;
57 UINTN CapsuleBlockAlignedSize
;
59 EFI_PEI_RECOVERY_BLOCK_IO_PPI
*BlockIo
;
60 EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*BlockIo2
;
61 } PEI_CD_EXPRESS_CAPSULE_DATA
;
63 #define PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('p', 'c', 'd', 'e')
68 EFI_PEI_DEVICE_RECOVERY_MODULE_PPI DeviceRecoveryPpi
;
69 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor
;
70 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor
;
71 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor2
;
75 PEI_CD_EXPRESS_CAPSULE_DATA CapsuleData
[PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER
];
77 } PEI_CD_EXPRESS_PRIVATE_DATA
;
79 #define PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS(a) \
81 PEI_CD_EXPRESS_PRIVATE_DATA, \
83 PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE \
88 UINT8 ExtendedAttributeRecordLength
;
89 UINT32 LocationOfExtent
[2];
94 UINT8 InterleaveGapSize
;
95 UINT32 VolumeSequenceNumber
;
98 } PEI_CD_EXPRESS_DIR_FILE_RECORD
;
101 BlockIo installation notification function.
103 This function finds out all the current Block IO PPIs in the system and add them
106 @param PeiServices Indirect reference to the PEI Services Table.
107 @param NotifyDescriptor Address of the notification descriptor data structure.
108 @param Ppi Address of the PPI that was installed.
110 @retval EFI_SUCCESS The function completes successfully.
116 IN EFI_PEI_SERVICES
**PeiServices
,
117 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
122 Finds out all the current Block IO PPIs in the system and add them into private data.
124 @param PrivateData The private data structure that contains recovery module information.
125 @param BlockIo2 Boolean to show whether using BlockIo2 or BlockIo.
127 @retval EFI_SUCCESS The blocks and volumes are updated successfully.
131 UpdateBlocksAndVolumes (
132 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA
*PrivateData
,
137 Returns the number of DXE capsules residing on the device.
139 This function searches for DXE capsules from the associated device and returns
140 the number and maximum size in bytes of the capsules discovered. Entry 1 is
141 assumed to be the highest load priority and entry N is assumed to be the lowest
144 @param[in] PeiServices General-purpose services that are available
146 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
148 @param[out] NumberRecoveryCapsules Pointer to a caller-allocated UINTN. On
149 output, *NumberRecoveryCapsules contains
150 the number of recovery capsule images
151 available for retrieval from this PEIM
154 @retval EFI_SUCCESS One or more capsules were discovered.
155 @retval EFI_DEVICE_ERROR A device error occurred.
156 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
161 GetNumberRecoveryCapsules (
162 IN EFI_PEI_SERVICES
**PeiServices
,
163 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
*This
,
164 OUT UINTN
*NumberRecoveryCapsules
168 Returns the size and type of the requested recovery capsule.
170 This function gets the size and type of the capsule specified by CapsuleInstance.
172 @param[in] PeiServices General-purpose services that are available to every PEIM
173 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
175 @param[in] CapsuleInstance Specifies for which capsule instance to retrieve
176 the information. This parameter must be between
177 one and the value returned by GetNumberRecoveryCapsules()
178 in NumberRecoveryCapsules.
179 @param[out] Size A pointer to a caller-allocated UINTN in which
180 the size of the requested recovery module is
182 @param[out] CapsuleType A pointer to a caller-allocated EFI_GUID in which
183 the type of the requested recovery capsule is
184 returned. The semantic meaning of the value
185 returned is defined by the implementation.
187 @retval EFI_SUCCESS One or more capsules were discovered.
188 @retval EFI_DEVICE_ERROR A device error occurred.
189 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
194 GetRecoveryCapsuleInfo (
195 IN EFI_PEI_SERVICES
**PeiServices
,
196 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
*This
,
197 IN UINTN CapsuleInstance
,
199 OUT EFI_GUID
*CapsuleType
203 Loads a DXE capsule from some media into memory.
205 This function, by whatever mechanism, retrieves a DXE capsule from some device
206 and loads it into memory. Note that the published interface is device neutral.
208 @param[in] PeiServices General-purpose services that are available
210 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
212 @param[in] CapsuleInstance Specifies which capsule instance to retrieve.
213 @param[out] Buffer Specifies a caller-allocated buffer in which
214 the requested recovery capsule will be returned.
216 @retval EFI_SUCCESS The capsule was loaded correctly.
217 @retval EFI_DEVICE_ERROR A device error occurred.
218 @retval EFI_NOT_FOUND A requested recovery DXE capsule cannot be found.
223 LoadRecoveryCapsule (
224 IN EFI_PEI_SERVICES
**PeiServices
,
225 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
*This
,
226 IN UINTN CapsuleInstance
,
231 Finds out the recovery capsule in the current volume.
233 @param PrivateData The private data structure that contains recovery module information.
235 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
236 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
241 FindRecoveryCapsules (
242 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA
*PrivateData
246 Retrieves the recovery capsule in root directory of the current volume.
248 @param PrivateData The private data structure that contains recovery module information.
249 @param BlockIoPpi The Block IO PPI used to access the volume.
250 @param BlockIo2Ppi The Block IO 2 PPI used to access the volume.
251 @param IndexBlockDevice The index of current block device.
252 @param Lba The starting logic block address to retrieve capsule.
254 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
255 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
261 RetrieveCapsuleFileFromRoot (
262 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA
*PrivateData
,
263 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*BlockIoPpi
,
264 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*BlockIo2Ppi
,
265 IN UINTN IndexBlockDevice
,
271 This function compares two ASCII strings in case sensitive/insensitive way.
273 @param Source1 The first string.
274 @param Source2 The second string.
275 @param Size The maximum comparison length.
276 @param CaseSensitive Flag to indicate whether the comparison is case sensitive.
278 @retval TRUE The two strings are the same.
279 @retval FALSE The two string are not the same.
287 IN BOOLEAN CaseSensitive