2 Header file for CD recovery PEIM
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
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
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.
17 #ifndef _PEI_CD_EXPRESS_H_
18 #define _PEI_CD_EXPRESS_H_
23 #include <Ppi/BlockIo.h>
24 #include <Guid/RecoveryDevice.h>
25 #include <Ppi/DeviceRecoveryModule.h>
27 #include <Library/DebugLib.h>
28 #include <Library/PcdLib.h>
29 #include <Library/PeimEntryPoint.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/PeiServicesTablePointerLib.h>
32 #include <Library/PeiServicesLib.h>
33 #include <Library/MemoryAllocationLib.h>
38 #define PEI_CD_EXPRESS_MAX_BLOCK_IO_PPI 8
39 #define PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER 16
41 #define PEI_CD_BLOCK_SIZE 0x800
42 #define PEI_MEMMORY_PAGE_SIZE 0x1000
45 // Recovery file name (in root directory)
47 #define PEI_RECOVERY_FILE_NAME "FVMAIN.FV"
50 // Following are defined according to ISO-9660 specification
52 #define PEI_CD_STANDARD_ID "CD001"
53 #define PEI_CD_EXPRESS_STANDARD_ID_SIZE 5
55 #define PEI_CD_EXPRESS_VOLUME_TYPE_OFFSET 0
56 #define PEI_CD_EXPRESS_STANDARD_ID_OFFSET 1
57 #define PEI_CD_EXPRESS_VOLUME_SPACE_OFFSET 80
58 #define PEI_CD_EXPRESS_ROOT_DIR_RECORD_OFFSET 156
60 #define PEI_CD_EXPRESS_VOLUME_TYPE_PRIMARY 1
61 #define PEI_CD_EXPRESS_VOLUME_TYPE_TERMINATOR 255
63 #define PEI_CD_EXPRESS_DIR_FILE_REC_FLAG_ISDIR 0x02
66 UINTN CapsuleStartLBA
;
69 EFI_PEI_RECOVERY_BLOCK_IO_PPI
*BlockIo
;
70 } PEI_CD_EXPRESS_CAPSULE_DATA
;
72 #define PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('p', 'c', 'd', 'e')
77 EFI_PEI_DEVICE_RECOVERY_MODULE_PPI DeviceRecoveryPpi
;
78 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor
;
79 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor
;
83 PEI_CD_EXPRESS_CAPSULE_DATA CapsuleData
[PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER
];
85 } PEI_CD_EXPRESS_PRIVATE_DATA
;
87 #define PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS(a) \
89 PEI_CD_EXPRESS_PRIVATE_DATA, \
91 PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE \
96 UINT8 ExtendedAttributeRecordLength
;
97 UINT32 LocationOfExtent
[2];
102 UINT8 InterleaveGapSize
;
103 UINT32 VolumeSequenceNumber
;
106 } PEI_CD_EXPRESS_DIR_FILE_RECORD
;
109 BlockIo installation notification function.
111 This function finds out all the current Block IO PPIs in the system and add them
114 @param PeiServices Indirect reference to the PEI Services Table.
115 @param NotifyDescriptor Address of the notification descriptor data structure.
116 @param Ppi Address of the PPI that was installed.
118 @retval EFI_SUCCESS The function completes successfully.
124 IN EFI_PEI_SERVICES
**PeiServices
,
125 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
130 Finds out all the current Block IO PPIs in the system and add them into private data.
132 @param PrivateData The private data structure that contains recovery module information.
134 @retval EFI_SUCCESS The blocks and volumes are updated successfully.
138 UpdateBlocksAndVolumes (
139 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA
*PrivateData
143 Returns the number of DXE capsules residing on the device.
145 This function searches for DXE capsules from the associated device and returns
146 the number and maximum size in bytes of the capsules discovered. Entry 1 is
147 assumed to be the highest load priority and entry N is assumed to be the lowest
150 @param[in] PeiServices General-purpose services that are available
152 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
154 @param[out] NumberRecoveryCapsules Pointer to a caller-allocated UINTN. On
155 output, *NumberRecoveryCapsules contains
156 the number of recovery capsule images
157 available for retrieval from this PEIM
160 @retval EFI_SUCCESS One or more capsules were discovered.
161 @retval EFI_DEVICE_ERROR A device error occurred.
162 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
167 GetNumberRecoveryCapsules (
168 IN EFI_PEI_SERVICES
**PeiServices
,
169 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
*This
,
170 OUT UINTN
*NumberRecoveryCapsules
174 Returns the size and type of the requested recovery capsule.
176 This function gets the size and type of the capsule specified by CapsuleInstance.
178 @param[in] PeiServices General-purpose services that are available to every PEIM
179 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
181 @param[in] CapsuleInstance Specifies for which capsule instance to retrieve
182 the information. This parameter must be between
183 one and the value returned by GetNumberRecoveryCapsules()
184 in NumberRecoveryCapsules.
185 @param[out] Size A pointer to a caller-allocated UINTN in which
186 the size of the requested recovery module is
188 @param[out] CapsuleType A pointer to a caller-allocated EFI_GUID in which
189 the type of the requested recovery capsule is
190 returned. The semantic meaning of the value
191 returned is defined by the implementation.
193 @retval EFI_SUCCESS One or more capsules were discovered.
194 @retval EFI_DEVICE_ERROR A device error occurred.
195 @retval EFI_NOT_FOUND A recovery DXE capsule cannot be found.
200 GetRecoveryCapsuleInfo (
201 IN EFI_PEI_SERVICES
**PeiServices
,
202 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
*This
,
203 IN UINTN CapsuleInstance
,
205 OUT EFI_GUID
*CapsuleType
209 Loads a DXE capsule from some media into memory.
211 This function, by whatever mechanism, retrieves a DXE capsule from some device
212 and loads it into memory. Note that the published interface is device neutral.
214 @param[in] PeiServices General-purpose services that are available
216 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
218 @param[in] CapsuleInstance Specifies which capsule instance to retrieve.
219 @param[out] Buffer Specifies a caller-allocated buffer in which
220 the requested recovery capsule will be returned.
222 @retval EFI_SUCCESS The capsule was loaded correctly.
223 @retval EFI_DEVICE_ERROR A device error occurred.
224 @retval EFI_NOT_FOUND A requested recovery DXE capsule cannot be found.
229 LoadRecoveryCapsule (
230 IN EFI_PEI_SERVICES
**PeiServices
,
231 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
*This
,
232 IN UINTN CapsuleInstance
,
237 Finds out the recovery capsule in the current volume.
239 @param PrivateData The private data structure that contains recovery module information.
241 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
242 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
247 FindRecoveryCapsules (
248 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA
*PrivateData
252 Retrieves the recovery capsule in root directory of the current volume.
254 @param PrivateData The private data structure that contains recovery module information.
255 @param BlockIoPpi The Block IO PPI used to access the volume.
256 @param IndexBlockDevice The index of current block device.
257 @param Lba The starting logic block address to retrieve capsule.
259 @retval EFI_SUCCESS The recovery capsule is successfully found in the volume.
260 @retval EFI_NOT_FOUND The recovery capsule is not found in the volume.
266 RetrieveCapsuleFileFromRoot (
267 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA
*PrivateData
,
268 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*BlockIoPpi
,
269 IN UINTN IndexBlockDevice
,
275 This function compares two ASCII strings in case sensitive/insensitive way.
277 @param Source1 The first string.
278 @param Source2 The second string.
279 @param Size The maximum comparison length.
280 @param CaseSensitive Flag to indicate whether the comparison is case sensitive.
282 @retval TRUE The two strings are the same.
283 @retval FALSE The two string are not the same.
291 IN BOOLEAN CaseSensitive