]>
Commit | Line | Data |
---|---|---|
0591696e FT |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r | |
4 | This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | **/\r | |
13 | \r | |
14 | #ifndef _UFS_BLOCK_IO_PEI_H_\r | |
15 | #define _UFS_BLOCK_IO_PEI_H_\r | |
16 | \r | |
17 | #include <PiPei.h>\r | |
18 | \r | |
19 | #include <Ppi/UfsHostController.h>\r | |
20 | #include <Ppi/BlockIo.h>\r | |
9d02f824 | 21 | #include <Ppi/BlockIo2.h>\r |
0591696e FT |
22 | \r |
23 | #include <Library/DebugLib.h>\r | |
24 | #include <Library/BaseLib.h>\r | |
25 | #include <Library/BaseMemoryLib.h>\r | |
26 | #include <Library/MemoryAllocationLib.h>\r | |
27 | #include <Library/IoLib.h>\r | |
28 | #include <Library/TimerLib.h>\r | |
29 | #include <Library/PeiServicesLib.h>\r | |
30 | \r | |
31 | #include <IndustryStandard/Scsi.h>\r | |
32 | \r | |
33 | #include "UfsHci.h"\r | |
34 | #include "UfsHcMem.h"\r | |
35 | \r | |
36 | #define UFS_PEIM_HC_SIG SIGNATURE_32 ('U', 'F', 'S', 'H')\r | |
37 | \r | |
38 | #define UFS_PEIM_MAX_LUNS 8\r | |
39 | \r | |
40 | typedef struct {\r | |
41 | UINT8 Lun[UFS_PEIM_MAX_LUNS];\r | |
42 | UINT16 BitMask:12; // Bit 0~7 is for common luns. Bit 8~11 is reserved for those well known luns\r | |
43 | UINT16 Rsvd:4;\r | |
44 | } UFS_PEIM_EXPOSED_LUNS;\r | |
45 | \r | |
46 | typedef struct {\r | |
47 | ///\r | |
48 | /// The timeout, in 100 ns units, to use for the execution of this SCSI\r | |
49 | /// Request Packet. A Timeout value of 0 means that this function\r | |
50 | /// will wait indefinitely for the SCSI Request Packet to execute. If\r | |
51 | /// Timeout is greater than zero, then this function will return\r | |
52 | /// EFI_TIMEOUT if the time required to execute the SCSI\r | |
53 | /// Request Packet is greater than Timeout.\r | |
54 | ///\r | |
55 | UINT64 Timeout;\r | |
56 | ///\r | |
57 | /// A pointer to the data buffer to transfer between the SCSI\r | |
58 | /// controller and the SCSI device for read and bidirectional commands.\r | |
59 | ///\r | |
60 | VOID *InDataBuffer;\r | |
61 | ///\r | |
62 | /// A pointer to the data buffer to transfer between the SCSI\r | |
63 | /// controller and the SCSI device for write or bidirectional commands.\r | |
64 | ///\r | |
65 | VOID *OutDataBuffer;\r | |
66 | ///\r | |
67 | /// A pointer to the sense data that was generated by the execution of\r | |
68 | /// the SCSI Request Packet.\r | |
69 | ///\r | |
70 | VOID *SenseData;\r | |
71 | ///\r | |
72 | /// A pointer to buffer that contains the Command Data Block to\r | |
73 | /// send to the SCSI device specified by Target and Lun.\r | |
74 | ///\r | |
75 | VOID *Cdb;\r | |
76 | ///\r | |
77 | /// On Input, the size, in bytes, of InDataBuffer. On output, the\r | |
78 | /// number of bytes transferred between the SCSI controller and the SCSI device.\r | |
79 | ///\r | |
80 | UINT32 InTransferLength;\r | |
81 | ///\r | |
82 | /// On Input, the size, in bytes of OutDataBuffer. On Output, the\r | |
83 | /// Number of bytes transferred between SCSI Controller and the SCSI device.\r | |
84 | ///\r | |
85 | UINT32 OutTransferLength;\r | |
86 | ///\r | |
87 | /// The length, in bytes, of the buffer Cdb. The standard values are 6,\r | |
88 | /// 10, 12, and 16, but other values are possible if a variable length CDB is used.\r | |
89 | ///\r | |
90 | UINT8 CdbLength;\r | |
91 | ///\r | |
92 | /// The direction of the data transfer. 0 for reads, 1 for writes. A\r | |
93 | /// value of 2 is Reserved for Bi-Directional SCSI commands.\r | |
94 | ///\r | |
95 | UINT8 DataDirection;\r | |
96 | ///\r | |
97 | /// On input, the length in bytes of the SenseData buffer. On\r | |
98 | /// output, the number of bytes written to the SenseData buffer.\r | |
99 | ///\r | |
100 | UINT8 SenseDataLength;\r | |
101 | } UFS_SCSI_REQUEST_PACKET;\r | |
102 | \r | |
103 | typedef struct _UFS_PEIM_HC_PRIVATE_DATA { \r | |
104 | UINT32 Signature;\r | |
105 | EFI_HANDLE Controller;\r | |
106 | \r | |
107 | UFS_PEIM_MEM_POOL *Pool;\r | |
108 | \r | |
109 | EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi;\r | |
9d02f824 | 110 | EFI_PEI_RECOVERY_BLOCK_IO2_PPI BlkIo2Ppi;\r |
0591696e | 111 | EFI_PEI_PPI_DESCRIPTOR BlkIoPpiList;\r |
9d02f824 FT |
112 | EFI_PEI_PPI_DESCRIPTOR BlkIo2PpiList;\r |
113 | EFI_PEI_BLOCK_IO2_MEDIA Media[UFS_PEIM_MAX_LUNS];\r | |
0591696e FT |
114 | \r |
115 | UINTN UfsHcBase;\r | |
116 | UINT32 Capabilities;\r | |
117 | \r | |
118 | UINT8 TaskTag;\r | |
119 | \r | |
120 | VOID *UtpTrlBase;\r | |
121 | UINT8 Nutrs;\r | |
122 | VOID *UtpTmrlBase;\r | |
123 | UINT8 Nutmrs;\r | |
124 | \r | |
125 | UFS_PEIM_EXPOSED_LUNS Luns;\r | |
126 | } UFS_PEIM_HC_PRIVATE_DATA;\r | |
127 | \r | |
128 | #define UFS_TIMEOUT MultU64x32((UINT64)(3), 10000000)\r | |
129 | \r | |
130 | #define ROUNDUP8(x) (((x) % 8 == 0) ? (x) : ((x) / 8 + 1) * 8)\r | |
131 | \r | |
132 | #define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)\r | |
133 | \r | |
134 | #define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, BlkIoPpi, UFS_PEIM_HC_SIG)\r | |
9d02f824 | 135 | #define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, BlkIo2Ppi, UFS_PEIM_HC_SIG)\r |
0591696e FT |
136 | \r |
137 | #define UFS_SCSI_OP_LENGTH_SIX 0x6\r | |
138 | #define UFS_SCSI_OP_LENGTH_TEN 0xa\r | |
139 | #define UFS_SCSI_OP_LENGTH_SIXTEEN 0x10\r | |
140 | \r | |
141 | typedef struct _UFS_DEVICE_MANAGEMENT_REQUEST_PACKET {\r | |
142 | UINT64 Timeout;\r | |
143 | VOID *InDataBuffer;\r | |
144 | VOID *OutDataBuffer;\r | |
145 | UINT8 Opcode;\r | |
146 | UINT8 DescId;\r | |
147 | UINT8 Index;\r | |
148 | UINT8 Selector;\r | |
149 | UINT32 InTransferLength;\r | |
150 | UINT32 OutTransferLength;\r | |
151 | UINT8 DataDirection;\r | |
152 | UINT8 Ocs;\r | |
153 | } UFS_DEVICE_MANAGEMENT_REQUEST_PACKET;\r | |
154 | \r | |
155 | /**\r | |
156 | Sends a UFS-supported SCSI Request Packet to a UFS device that is attached to the UFS host controller.\r | |
157 | \r | |
158 | @param[in] Private The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.\r | |
159 | @param[in] Lun The LUN of the UFS device to send the SCSI Request Packet.\r | |
160 | @param[in, out] Packet A pointer to the SCSI Request Packet to send to a specified Lun of the\r | |
161 | UFS device.\r | |
162 | \r | |
163 | @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional\r | |
164 | commands, InTransferLength bytes were transferred from\r | |
165 | InDataBuffer. For write and bi-directional commands,\r | |
166 | OutTransferLength bytes were transferred by\r | |
167 | OutDataBuffer.\r | |
168 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request\r | |
169 | Packet.\r | |
170 | @retval EFI_OUT_OF_RESOURCES The resource for transfer is not available.\r | |
171 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
172 | \r | |
173 | **/\r | |
174 | EFI_STATUS\r | |
175 | UfsExecScsiCmds (\r | |
176 | IN UFS_PEIM_HC_PRIVATE_DATA *Private,\r | |
177 | IN UINT8 Lun,\r | |
178 | IN OUT UFS_SCSI_REQUEST_PACKET *Packet\r | |
179 | );\r | |
180 | \r | |
181 | /**\r | |
182 | Initialize the UFS host controller.\r | |
183 | \r | |
184 | @param[in] Private The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.\r | |
185 | \r | |
186 | @retval EFI_SUCCESS The Ufs Host Controller is initialized successfully.\r | |
187 | @retval Others A device error occurred while initializing the controller.\r | |
188 | \r | |
189 | **/\r | |
190 | EFI_STATUS\r | |
191 | UfsControllerInit (\r | |
192 | IN UFS_PEIM_HC_PRIVATE_DATA *Private\r | |
193 | );\r | |
194 | \r | |
195 | /**\r | |
196 | Stop the UFS host controller.\r | |
197 | \r | |
198 | @param[in] Private The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.\r | |
199 | \r | |
200 | @retval EFI_SUCCESS The Ufs Host Controller is stopped successfully.\r | |
201 | @retval Others A device error occurred while stopping the controller.\r | |
202 | \r | |
203 | **/\r | |
204 | EFI_STATUS\r | |
205 | UfsControllerStop (\r | |
206 | IN UFS_PEIM_HC_PRIVATE_DATA *Private\r | |
207 | );\r | |
208 | \r | |
209 | /**\r | |
210 | Set specified flag to 1 on a UFS device.\r | |
211 | \r | |
212 | @param[in] Private The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.\r | |
213 | @param[in] FlagId The ID of flag to be set.\r | |
214 | \r | |
215 | @retval EFI_SUCCESS The flag was set successfully.\r | |
216 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to set the flag.\r | |
217 | @retval EFI_TIMEOUT A timeout occurred while waiting for the completion of setting the flag.\r | |
218 | \r | |
219 | **/\r | |
220 | EFI_STATUS\r | |
221 | UfsSetFlag (\r | |
222 | IN UFS_PEIM_HC_PRIVATE_DATA *Private,\r | |
223 | IN UINT8 FlagId\r | |
224 | );\r | |
225 | \r | |
226 | /**\r | |
227 | Read or write specified device descriptor of a UFS device.\r | |
228 | \r | |
229 | @param[in] Private The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.\r | |
230 | @param[in] Read The boolean variable to show r/w direction.\r | |
231 | @param[in] DescId The ID of device descriptor.\r | |
232 | @param[in] Index The Index of device descriptor.\r | |
233 | @param[in] Selector The Selector of device descriptor.\r | |
234 | @param[in, out] Descriptor The buffer of device descriptor to be read or written.\r | |
235 | @param[in] DescSize The size of device descriptor buffer.\r | |
236 | \r | |
237 | @retval EFI_SUCCESS The device descriptor was read/written successfully.\r | |
238 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to r/w the device descriptor.\r | |
239 | @retval EFI_TIMEOUT A timeout occurred while waiting for the completion of r/w the device descriptor.\r | |
240 | \r | |
241 | **/\r | |
242 | EFI_STATUS\r | |
243 | UfsRwDeviceDesc (\r | |
244 | IN UFS_PEIM_HC_PRIVATE_DATA *Private,\r | |
245 | IN BOOLEAN Read,\r | |
246 | IN UINT8 DescId,\r | |
247 | IN UINT8 Index,\r | |
248 | IN UINT8 Selector,\r | |
249 | IN OUT VOID *Descriptor,\r | |
250 | IN UINT32 DescSize\r | |
251 | );\r | |
252 | \r | |
253 | /**\r | |
254 | Sends NOP IN cmd to a UFS device for initialization process request.\r | |
255 | For more details, please refer to UFS 2.0 spec Figure 13.3.\r | |
256 | \r | |
257 | @param[in] Private The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.\r | |
258 | \r | |
259 | @retval EFI_SUCCESS The NOP IN command was sent by the host. The NOP OUT response was\r | |
260 | received successfully.\r | |
261 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to execute NOP IN command.\r | |
262 | @retval EFI_OUT_OF_RESOURCES The resource for transfer is not available.\r | |
263 | @retval EFI_TIMEOUT A timeout occurred while waiting for the NOP IN command to execute.\r | |
264 | \r | |
265 | **/\r | |
266 | EFI_STATUS\r | |
267 | UfsExecNopCmds (\r | |
268 | IN UFS_PEIM_HC_PRIVATE_DATA *Private\r | |
269 | );\r | |
270 | \r | |
271 | /**\r | |
272 | Gets the count of block I/O devices that one specific block driver detects.\r | |
273 | \r | |
274 | This function is used for getting the count of block I/O devices that one \r | |
275 | specific block driver detects. To the PEI ATAPI driver, it returns the number\r | |
276 | of all the detected ATAPI devices it detects during the enumeration process. \r | |
277 | To the PEI legacy floppy driver, it returns the number of all the legacy \r | |
278 | devices it finds during its enumeration process. If no device is detected, \r | |
279 | then the function will return zero. \r | |
280 | \r | |
281 | @param[in] PeiServices General-purpose services that are available \r | |
282 | to every PEIM.\r | |
283 | @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI \r | |
284 | instance.\r | |
285 | @param[out] NumberBlockDevices The number of block I/O devices discovered.\r | |
286 | \r | |
287 | @retval EFI_SUCCESS The operation performed successfully.\r | |
288 | \r | |
289 | **/\r | |
290 | EFI_STATUS\r | |
291 | EFIAPI\r | |
292 | UfsBlockIoPeimGetDeviceNo (\r | |
293 | IN EFI_PEI_SERVICES **PeiServices,\r | |
294 | IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r | |
295 | OUT UINTN *NumberBlockDevices\r | |
296 | );\r | |
297 | \r | |
298 | /**\r | |
299 | Gets a block device's media information.\r | |
300 | \r | |
301 | This function will provide the caller with the specified block device's media \r | |
302 | information. If the media changes, calling this function will update the media \r | |
303 | information accordingly.\r | |
304 | \r | |
305 | @param[in] PeiServices General-purpose services that are available to every\r | |
306 | PEIM\r | |
307 | @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r | |
308 | @param[in] DeviceIndex Specifies the block device to which the function wants \r | |
309 | to talk. Because the driver that implements Block I/O \r | |
310 | PPIs will manage multiple block devices, the PPIs that \r | |
311 | want to talk to a single device must specify the \r | |
312 | device index that was assigned during the enumeration\r | |
313 | process. This index is a number from one to \r | |
314 | NumberBlockDevices.\r | |
315 | @param[out] MediaInfo The media information of the specified block media. \r | |
316 | The caller is responsible for the ownership of this \r | |
317 | data structure.\r | |
318 | \r | |
319 | @par Note: \r | |
320 | The MediaInfo structure describes an enumeration of possible block device \r | |
321 | types. This enumeration exists because no device paths are actually passed \r | |
322 | across interfaces that describe the type or class of hardware that is publishing \r | |
323 | the block I/O interface. This enumeration will allow for policy decisions\r | |
324 | in the Recovery PEIM, such as "Try to recover from legacy floppy first, \r | |
325 | LS-120 second, CD-ROM third." If there are multiple partitions abstracted \r | |
326 | by a given device type, they should be reported in ascending order; this \r | |
327 | order also applies to nested partitions, such as legacy MBR, where the \r | |
328 | outermost partitions would have precedence in the reporting order. The \r | |
329 | same logic applies to systems such as IDE that have precedence relationships \r | |
330 | like "Master/Slave" or "Primary/Secondary". The master device should be \r | |
331 | reported first, the slave second.\r | |
332 | \r | |
333 | @retval EFI_SUCCESS Media information about the specified block device \r | |
334 | was obtained successfully.\r | |
335 | @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware \r | |
336 | error.\r | |
337 | \r | |
338 | **/\r | |
339 | EFI_STATUS\r | |
340 | EFIAPI\r | |
341 | UfsBlockIoPeimGetMediaInfo (\r | |
342 | IN EFI_PEI_SERVICES **PeiServices,\r | |
343 | IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r | |
344 | IN UINTN DeviceIndex,\r | |
345 | OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r | |
346 | );\r | |
347 | \r | |
348 | /**\r | |
349 | Reads the requested number of blocks from the specified block device.\r | |
350 | \r | |
351 | The function reads the requested number of blocks from the device. All the \r | |
352 | blocks are read, or an error is returned. If there is no media in the device,\r | |
353 | the function returns EFI_NO_MEDIA.\r | |
354 | \r | |
355 | @param[in] PeiServices General-purpose services that are available to \r | |
356 | every PEIM.\r | |
357 | @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r | |
358 | @param[in] DeviceIndex Specifies the block device to which the function wants \r | |
359 | to talk. Because the driver that implements Block I/O \r | |
360 | PPIs will manage multiple block devices, PPIs that \r | |
361 | want to talk to a single device must specify the device \r | |
362 | index that was assigned during the enumeration process. \r | |
363 | This index is a number from one to NumberBlockDevices.\r | |
364 | @param[in] StartLBA The starting logical block address (LBA) to read from\r | |
365 | on the device\r | |
366 | @param[in] BufferSize The size of the Buffer in bytes. This number must be\r | |
367 | a multiple of the intrinsic block size of the device.\r | |
368 | @param[out] Buffer A pointer to the destination buffer for the data.\r | |
369 | The caller is responsible for the ownership of the \r | |
370 | buffer.\r | |
371 | \r | |
372 | @retval EFI_SUCCESS The data was read correctly from the device.\r | |
373 | @retval EFI_DEVICE_ERROR The device reported an error while attempting \r | |
374 | to perform the read operation.\r | |
375 | @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not \r | |
376 | valid, or the buffer is not properly aligned.\r | |
377 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
378 | @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r | |
379 | the intrinsic block size of the device.\r | |
380 | \r | |
381 | **/\r | |
382 | EFI_STATUS\r | |
383 | EFIAPI\r | |
384 | UfsBlockIoPeimReadBlocks (\r | |
385 | IN EFI_PEI_SERVICES **PeiServices,\r | |
386 | IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r | |
387 | IN UINTN DeviceIndex,\r | |
388 | IN EFI_PEI_LBA StartLBA,\r | |
389 | IN UINTN BufferSize,\r | |
390 | OUT VOID *Buffer\r | |
391 | );\r | |
392 | \r | |
9d02f824 FT |
393 | /**\r |
394 | Gets the count of block I/O devices that one specific block driver detects.\r | |
395 | \r | |
396 | This function is used for getting the count of block I/O devices that one \r | |
397 | specific block driver detects. To the PEI ATAPI driver, it returns the number\r | |
398 | of all the detected ATAPI devices it detects during the enumeration process. \r | |
399 | To the PEI legacy floppy driver, it returns the number of all the legacy \r | |
400 | devices it finds during its enumeration process. If no device is detected, \r | |
401 | then the function will return zero. \r | |
402 | \r | |
403 | @param[in] PeiServices General-purpose services that are available \r | |
404 | to every PEIM.\r | |
405 | @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI \r | |
406 | instance.\r | |
407 | @param[out] NumberBlockDevices The number of block I/O devices discovered.\r | |
408 | \r | |
409 | @retval EFI_SUCCESS The operation performed successfully.\r | |
410 | \r | |
411 | **/\r | |
412 | EFI_STATUS\r | |
413 | EFIAPI\r | |
414 | UfsBlockIoPeimGetDeviceNo2 (\r | |
415 | IN EFI_PEI_SERVICES **PeiServices,\r | |
416 | IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r | |
417 | OUT UINTN *NumberBlockDevices\r | |
418 | );\r | |
419 | \r | |
420 | /**\r | |
421 | Gets a block device's media information.\r | |
422 | \r | |
423 | This function will provide the caller with the specified block device's media \r | |
424 | information. If the media changes, calling this function will update the media \r | |
425 | information accordingly.\r | |
426 | \r | |
427 | @param[in] PeiServices General-purpose services that are available to every\r | |
428 | PEIM\r | |
429 | @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r | |
430 | @param[in] DeviceIndex Specifies the block device to which the function wants \r | |
431 | to talk. Because the driver that implements Block I/O \r | |
432 | PPIs will manage multiple block devices, the PPIs that \r | |
433 | want to talk to a single device must specify the \r | |
434 | device index that was assigned during the enumeration\r | |
435 | process. This index is a number from one to \r | |
436 | NumberBlockDevices.\r | |
437 | @param[out] MediaInfo The media information of the specified block media. \r | |
438 | The caller is responsible for the ownership of this \r | |
439 | data structure.\r | |
440 | \r | |
441 | @par Note: \r | |
442 | The MediaInfo structure describes an enumeration of possible block device \r | |
443 | types. This enumeration exists because no device paths are actually passed \r | |
444 | across interfaces that describe the type or class of hardware that is publishing \r | |
445 | the block I/O interface. This enumeration will allow for policy decisions\r | |
446 | in the Recovery PEIM, such as "Try to recover from legacy floppy first, \r | |
447 | LS-120 second, CD-ROM third." If there are multiple partitions abstracted \r | |
448 | by a given device type, they should be reported in ascending order; this \r | |
449 | order also applies to nested partitions, such as legacy MBR, where the \r | |
450 | outermost partitions would have precedence in the reporting order. The \r | |
451 | same logic applies to systems such as IDE that have precedence relationships \r | |
452 | like "Master/Slave" or "Primary/Secondary". The master device should be \r | |
453 | reported first, the slave second.\r | |
454 | \r | |
455 | @retval EFI_SUCCESS Media information about the specified block device \r | |
456 | was obtained successfully.\r | |
457 | @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware \r | |
458 | error.\r | |
459 | \r | |
460 | **/\r | |
461 | EFI_STATUS\r | |
462 | EFIAPI\r | |
463 | UfsBlockIoPeimGetMediaInfo2 (\r | |
464 | IN EFI_PEI_SERVICES **PeiServices,\r | |
465 | IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r | |
466 | IN UINTN DeviceIndex,\r | |
467 | OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo\r | |
468 | );\r | |
469 | \r | |
470 | /**\r | |
471 | Reads the requested number of blocks from the specified block device.\r | |
472 | \r | |
473 | The function reads the requested number of blocks from the device. All the \r | |
474 | blocks are read, or an error is returned. If there is no media in the device,\r | |
475 | the function returns EFI_NO_MEDIA.\r | |
476 | \r | |
477 | @param[in] PeiServices General-purpose services that are available to \r | |
478 | every PEIM.\r | |
479 | @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r | |
480 | @param[in] DeviceIndex Specifies the block device to which the function wants \r | |
481 | to talk. Because the driver that implements Block I/O \r | |
482 | PPIs will manage multiple block devices, PPIs that \r | |
483 | want to talk to a single device must specify the device \r | |
484 | index that was assigned during the enumeration process. \r | |
485 | This index is a number from one to NumberBlockDevices.\r | |
486 | @param[in] StartLBA The starting logical block address (LBA) to read from\r | |
487 | on the device\r | |
488 | @param[in] BufferSize The size of the Buffer in bytes. This number must be\r | |
489 | a multiple of the intrinsic block size of the device.\r | |
490 | @param[out] Buffer A pointer to the destination buffer for the data.\r | |
491 | The caller is responsible for the ownership of the \r | |
492 | buffer.\r | |
493 | \r | |
494 | @retval EFI_SUCCESS The data was read correctly from the device.\r | |
495 | @retval EFI_DEVICE_ERROR The device reported an error while attempting \r | |
496 | to perform the read operation.\r | |
497 | @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not \r | |
498 | valid, or the buffer is not properly aligned.\r | |
499 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
500 | @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r | |
501 | the intrinsic block size of the device.\r | |
502 | \r | |
503 | **/\r | |
504 | EFI_STATUS\r | |
505 | EFIAPI\r | |
506 | UfsBlockIoPeimReadBlocks2 (\r | |
507 | IN EFI_PEI_SERVICES **PeiServices,\r | |
508 | IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r | |
509 | IN UINTN DeviceIndex,\r | |
510 | IN EFI_PEI_LBA StartLBA,\r | |
511 | IN UINTN BufferSize,\r | |
512 | OUT VOID *Buffer\r | |
513 | );\r | |
514 | \r | |
0591696e FT |
515 | /**\r |
516 | Initialize the memory management pool for the host controller.\r | |
517 | \r | |
518 | @param Private The Ufs Peim driver private data.\r | |
519 | \r | |
520 | @retval EFI_SUCCESS The memory pool is initialized.\r | |
521 | @retval Others Fail to init the memory pool.\r | |
522 | \r | |
523 | **/\r | |
524 | EFI_STATUS\r | |
525 | UfsPeimInitMemPool (\r | |
526 | IN UFS_PEIM_HC_PRIVATE_DATA *Private\r | |
527 | );\r | |
528 | \r | |
529 | /**\r | |
530 | Allocate some memory from the host controller's memory pool\r | |
531 | which can be used to communicate with host controller.\r | |
532 | \r | |
533 | @param Pool The host controller's memory pool.\r | |
534 | @param Size Size of the memory to allocate.\r | |
535 | \r | |
536 | @return The allocated memory or NULL.\r | |
537 | \r | |
538 | **/\r | |
539 | VOID *\r | |
540 | UfsPeimAllocateMem (\r | |
541 | IN UFS_PEIM_MEM_POOL *Pool,\r | |
542 | IN UINTN Size\r | |
543 | );\r | |
544 | \r | |
545 | /**\r | |
546 | Free the allocated memory back to the memory pool.\r | |
547 | \r | |
548 | @param Pool The memory pool of the host controller.\r | |
549 | @param Mem The memory to free.\r | |
550 | @param Size The size of the memory to free.\r | |
551 | \r | |
552 | **/\r | |
553 | VOID\r | |
554 | UfsPeimFreeMem (\r | |
555 | IN UFS_PEIM_MEM_POOL *Pool,\r | |
556 | IN VOID *Mem,\r | |
557 | IN UINTN Size\r | |
558 | );\r | |
559 | \r | |
560 | #endif\r |