]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / CdExpressPei / PeiCdExpress.h
1 /** @file
2 Header file for CD recovery PEIM
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _PEI_CD_EXPRESS_H_
11 #define _PEI_CD_EXPRESS_H_
12
13 #include <PiPei.h>
14
15 #include <Ppi/BlockIo.h>
16 #include <Ppi/BlockIo2.h>
17 #include <Guid/RecoveryDevice.h>
18 #include <Ppi/DeviceRecoveryModule.h>
19
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>
27
28 #pragma pack(1)
29
30 #define PEI_CD_EXPRESS_MAX_BLOCK_IO_PPI 8
31 #define PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER 16
32
33 #define PEI_CD_BLOCK_SIZE 0x800
34 #define PEI_MEMMORY_PAGE_SIZE 0x1000
35
36 //
37 // Following are defined according to ISO-9660 specification
38 //
39 #define PEI_CD_STANDARD_ID "CD001"
40 #define PEI_CD_EXPRESS_STANDARD_ID_SIZE 5
41
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
46
47 #define PEI_CD_EXPRESS_VOLUME_TYPE_PRIMARY 1
48 #define PEI_CD_EXPRESS_VOLUME_TYPE_TERMINATOR 255
49
50 #define PEI_CD_EXPRESS_DIR_FILE_REC_FLAG_ISDIR 0x02
51
52 typedef struct {
53 UINTN CapsuleStartLBA;
54 UINTN CapsuleSize;
55 UINTN CapsuleBlockAlignedSize;
56 UINTN IndexBlock;
57 EFI_PEI_RECOVERY_BLOCK_IO_PPI *BlockIo;
58 EFI_PEI_RECOVERY_BLOCK_IO2_PPI *BlockIo2;
59 } PEI_CD_EXPRESS_CAPSULE_DATA;
60
61 #define PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('p', 'c', 'd', 'e')
62
63 typedef struct {
64 UINTN Signature;
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;
69
70 UINT8 *BlockBuffer;
71 UINTN CapsuleCount;
72 PEI_CD_EXPRESS_CAPSULE_DATA CapsuleData[PEI_CD_EXPRESS_MAX_CAPSULE_NUMBER];
73 } PEI_CD_EXPRESS_PRIVATE_DATA;
74
75 #define PEI_CD_EXPRESS_PRIVATE_DATA_FROM_THIS(a) \
76 CR (a, \
77 PEI_CD_EXPRESS_PRIVATE_DATA, \
78 DeviceRecoveryPpi, \
79 PEI_CD_EXPRESS_PRIVATE_DATA_SIGNATURE \
80 )
81
82 typedef struct {
83 UINT8 Length;
84 UINT8 ExtendedAttributeRecordLength;
85 UINT32 LocationOfExtent[2];
86 UINT32 DataLength[2];
87 UINT8 DateTime[7];
88 UINT8 Flag;
89 UINT8 FileUnitSize;
90 UINT8 InterleaveGapSize;
91 UINT32 VolumeSequenceNumber;
92 UINT8 FileIDLength;
93 UINT8 FileID[1];
94 } PEI_CD_EXPRESS_DIR_FILE_RECORD;
95
96 /**
97 BlockIo installation notification function.
98
99 This function finds out all the current Block IO PPIs in the system and add them
100 into private data.
101
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.
105
106 @retval EFI_SUCCESS The function completes successfully.
107
108 **/
109 EFI_STATUS
110 EFIAPI
111 BlockIoNotifyEntry (
112 IN EFI_PEI_SERVICES **PeiServices,
113 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
114 IN VOID *Ppi
115 );
116
117 /**
118 Finds out all the current Block IO PPIs in the system and add them into private data.
119
120 @param PrivateData The private data structure that contains recovery module information.
121 @param BlockIo2 Boolean to show whether using BlockIo2 or BlockIo.
122
123 @retval EFI_SUCCESS The blocks and volumes are updated successfully.
124
125 **/
126 EFI_STATUS
127 UpdateBlocksAndVolumes (
128 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData,
129 IN BOOLEAN BlockIo2
130 );
131
132 /**
133 Returns the number of DXE capsules residing on the device.
134
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
138 priority.
139
140 @param[in] PeiServices General-purpose services that are available
141 to every PEIM
142 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
143 instance.
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
148 instance.
149
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.
153
154 **/
155 EFI_STATUS
156 EFIAPI
157 GetNumberRecoveryCapsules (
158 IN EFI_PEI_SERVICES **PeiServices,
159 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
160 OUT UINTN *NumberRecoveryCapsules
161 );
162
163 /**
164 Returns the size and type of the requested recovery capsule.
165
166 This function gets the size and type of the capsule specified by CapsuleInstance.
167
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
170 instance.
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
177 returned.
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.
182
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.
186
187 **/
188 EFI_STATUS
189 EFIAPI
190 GetRecoveryCapsuleInfo (
191 IN EFI_PEI_SERVICES **PeiServices,
192 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
193 IN UINTN CapsuleInstance,
194 OUT UINTN *Size,
195 OUT EFI_GUID *CapsuleType
196 );
197
198 /**
199 Loads a DXE capsule from some media into memory.
200
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.
203
204 @param[in] PeiServices General-purpose services that are available
205 to every PEIM
206 @param[in] This Indicates the EFI_PEI_DEVICE_RECOVERY_MODULE_PPI
207 instance.
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.
211
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.
215
216 **/
217 EFI_STATUS
218 EFIAPI
219 LoadRecoveryCapsule (
220 IN EFI_PEI_SERVICES **PeiServices,
221 IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This,
222 IN UINTN CapsuleInstance,
223 OUT VOID *Buffer
224 );
225
226 /**
227 Finds out the recovery capsule in the current volume.
228
229 @param PrivateData The private data structure that contains recovery module information.
230
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.
233
234 **/
235 EFI_STATUS
236 EFIAPI
237 FindRecoveryCapsules (
238 IN OUT PEI_CD_EXPRESS_PRIVATE_DATA *PrivateData
239 );
240
241 /**
242 Retrieves the recovery capsule in root directory of the current volume.
243
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.
249
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.
252 @retval Others
253
254 **/
255 EFI_STATUS
256 EFIAPI
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,
262 IN UINT32 Lba
263 );
264
265 /**
266 This function compares two ASCII strings in case sensitive/insensitive way.
267
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.
272
273 @retval TRUE The two strings are the same.
274 @retval FALSE The two string are not the same.
275
276 **/
277 BOOLEAN
278 StringCmp (
279 IN UINT8 *Source1,
280 IN UINT8 *Source2,
281 IN UINTN Size,
282 IN BOOLEAN CaseSensitive
283 );
284
285 #pragma pack()
286
287 #endif