]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.h
MdeModulePkg/AhciPei: Add PEI BlockIO support
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AhciPei / AhciPeiBlockIo.h
CommitLineData
b2b8e872
HW
1/** @file\r
2 The AhciPei driver is used to manage ATA hard disk device working under AHCI\r
3 mode at PEI phase.\r
4\r
5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
6\r
7 SPDX-License-Identifier: BSD-2-Clause-Patent\r
8\r
9**/\r
10\r
11#ifndef _AHCI_PEI_BLOCKIO_H_\r
12#define _AHCI_PEI_BLOCKIO_H_\r
13\r
14//\r
15// ATA hard disk device for EFI_PEI_BLOCK_DEVICE_TYPE\r
16//\r
17#define EDKII_PEI_BLOCK_DEVICE_TYPE_ATA_HARD_DISK 8\r
18\r
19/**\r
20 Gets the count of block I/O devices that one specific block driver detects.\r
21\r
22 This function is used for getting the count of block I/O devices that one\r
23 specific block driver detects. If no device is detected, then the function\r
24 will return zero.\r
25\r
26 @param[in] PeiServices General-purpose services that are available\r
27 to every PEIM.\r
28 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI\r
29 instance.\r
30 @param[out] NumberBlockDevices The number of block I/O devices discovered.\r
31\r
32 @retval EFI_SUCCESS The operation performed successfully.\r
33\r
34**/\r
35EFI_STATUS\r
36EFIAPI\r
37AhciBlockIoGetDeviceNo (\r
38 IN EFI_PEI_SERVICES **PeiServices,\r
39 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
40 OUT UINTN *NumberBlockDevices\r
41 );\r
42\r
43/**\r
44 Gets a block device's media information.\r
45\r
46 This function will provide the caller with the specified block device's media\r
47 information. If the media changes, calling this function will update the media\r
48 information accordingly.\r
49\r
50 @param[in] PeiServices General-purpose services that are available to every\r
51 PEIM\r
52 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
53 @param[in] DeviceIndex Specifies the block device to which the function wants\r
54 to talk. Because the driver that implements Block I/O\r
55 PPIs will manage multiple block devices, the PPIs that\r
56 want to talk to a single device must specify the\r
57 device index that was assigned during the enumeration\r
58 process. This index is a number from one to\r
59 NumberBlockDevices.\r
60 @param[out] MediaInfo The media information of the specified block media.\r
61 The caller is responsible for the ownership of this\r
62 data structure.\r
63\r
64 @par Note:\r
65 The MediaInfo structure describes an enumeration of possible block device\r
66 types. This enumeration exists because no device paths are actually passed\r
67 across interfaces that describe the type or class of hardware that is publishing\r
68 the block I/O interface. This enumeration will allow for policy decisions\r
69 in the Recovery PEIM, such as "Try to recover from legacy floppy first,\r
70 LS-120 second, CD-ROM third." If there are multiple partitions abstracted\r
71 by a given device type, they should be reported in ascending order; this\r
72 order also applies to nested partitions, such as legacy MBR, where the\r
73 outermost partitions would have precedence in the reporting order. The\r
74 same logic applies to systems such as IDE that have precedence relationships\r
75 like "Master/Slave" or "Primary/Secondary". The master device should be\r
76 reported first, the slave second.\r
77\r
78 @retval EFI_SUCCESS Media information about the specified block device\r
79 was obtained successfully.\r
80 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware\r
81 error.\r
82\r
83**/\r
84EFI_STATUS\r
85EFIAPI\r
86AhciBlockIoGetMediaInfo (\r
87 IN EFI_PEI_SERVICES **PeiServices,\r
88 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
89 IN UINTN DeviceIndex,\r
90 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r
91 );\r
92\r
93/**\r
94 Reads the requested number of blocks from the specified block device.\r
95\r
96 The function reads the requested number of blocks from the device. All the\r
97 blocks are read, or an error is returned. If there is no media in the device,\r
98 the function returns EFI_NO_MEDIA.\r
99\r
100 @param[in] PeiServices General-purpose services that are available to\r
101 every PEIM.\r
102 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
103 @param[in] DeviceIndex Specifies the block device to which the function wants\r
104 to talk. Because the driver that implements Block I/O\r
105 PPIs will manage multiple block devices, PPIs that\r
106 want to talk to a single device must specify the device\r
107 index that was assigned during the enumeration process.\r
108 This index is a number from one to NumberBlockDevices.\r
109 @param[in] StartLBA The starting logical block address (LBA) to read from\r
110 on the device\r
111 @param[in] BufferSize The size of the Buffer in bytes. This number must be\r
112 a multiple of the intrinsic block size of the device.\r
113 @param[out] Buffer A pointer to the destination buffer for the data.\r
114 The caller is responsible for the ownership of the\r
115 buffer.\r
116\r
117 @retval EFI_SUCCESS The data was read correctly from the device.\r
118 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
119 to perform the read operation.\r
120 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not\r
121 valid, or the buffer is not properly aligned.\r
122 @retval EFI_NO_MEDIA There is no media in the device.\r
123 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
124 the intrinsic block size of the device.\r
125\r
126**/\r
127EFI_STATUS\r
128EFIAPI\r
129AhciBlockIoReadBlocks (\r
130 IN EFI_PEI_SERVICES **PeiServices,\r
131 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
132 IN UINTN DeviceIndex,\r
133 IN EFI_PEI_LBA StartLBA,\r
134 IN UINTN BufferSize,\r
135 OUT VOID *Buffer\r
136 );\r
137\r
138/**\r
139 Gets the count of block I/O devices that one specific block driver detects.\r
140\r
141 This function is used for getting the count of block I/O devices that one\r
142 specific block driver detects. If no device is detected, then the function\r
143 will return zero.\r
144\r
145 @param[in] PeiServices General-purpose services that are available\r
146 to every PEIM.\r
147 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI\r
148 instance.\r
149 @param[out] NumberBlockDevices The number of block I/O devices discovered.\r
150\r
151 @retval EFI_SUCCESS The operation performed successfully.\r
152\r
153**/\r
154EFI_STATUS\r
155EFIAPI\r
156AhciBlockIoGetDeviceNo2 (\r
157 IN EFI_PEI_SERVICES **PeiServices,\r
158 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r
159 OUT UINTN *NumberBlockDevices\r
160 );\r
161\r
162/**\r
163 Gets a block device's media information.\r
164\r
165 This function will provide the caller with the specified block device's media\r
166 information. If the media changes, calling this function will update the media\r
167 information accordingly.\r
168\r
169 @param[in] PeiServices General-purpose services that are available to every\r
170 PEIM\r
171 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
172 @param[in] DeviceIndex Specifies the block device to which the function wants\r
173 to talk. Because the driver that implements Block I/O\r
174 PPIs will manage multiple block devices, the PPIs that\r
175 want to talk to a single device must specify the\r
176 device index that was assigned during the enumeration\r
177 process. This index is a number from one to\r
178 NumberBlockDevices.\r
179 @param[out] MediaInfo The media information of the specified block media.\r
180 The caller is responsible for the ownership of this\r
181 data structure.\r
182\r
183 @par Note:\r
184 The MediaInfo structure describes an enumeration of possible block device\r
185 types. This enumeration exists because no device paths are actually passed\r
186 across interfaces that describe the type or class of hardware that is publishing\r
187 the block I/O interface. This enumeration will allow for policy decisions\r
188 in the Recovery PEIM, such as "Try to recover from legacy floppy first,\r
189 LS-120 second, CD-ROM third." If there are multiple partitions abstracted\r
190 by a given device type, they should be reported in ascending order; this\r
191 order also applies to nested partitions, such as legacy MBR, where the\r
192 outermost partitions would have precedence in the reporting order. The\r
193 same logic applies to systems such as IDE that have precedence relationships\r
194 like "Master/Slave" or "Primary/Secondary". The master device should be\r
195 reported first, the slave second.\r
196\r
197 @retval EFI_SUCCESS Media information about the specified block device\r
198 was obtained successfully.\r
199 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware\r
200 error.\r
201\r
202**/\r
203EFI_STATUS\r
204EFIAPI\r
205AhciBlockIoGetMediaInfo2 (\r
206 IN EFI_PEI_SERVICES **PeiServices,\r
207 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r
208 IN UINTN DeviceIndex,\r
209 OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo\r
210 );\r
211\r
212/**\r
213 Reads the requested number of blocks from the specified block device.\r
214\r
215 The function reads the requested number of blocks from the device. All the\r
216 blocks are read, or an error is returned. If there is no media in the device,\r
217 the function returns EFI_NO_MEDIA.\r
218\r
219 @param[in] PeiServices General-purpose services that are available to\r
220 every PEIM.\r
221 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
222 @param[in] DeviceIndex Specifies the block device to which the function wants\r
223 to talk. Because the driver that implements Block I/O\r
224 PPIs will manage multiple block devices, PPIs that\r
225 want to talk to a single device must specify the device\r
226 index that was assigned during the enumeration process.\r
227 This index is a number from one to NumberBlockDevices.\r
228 @param[in] StartLBA The starting logical block address (LBA) to read from\r
229 on the device\r
230 @param[in] BufferSize The size of the Buffer in bytes. This number must be\r
231 a multiple of the intrinsic block size of the device.\r
232 @param[out] Buffer A pointer to the destination buffer for the data.\r
233 The caller is responsible for the ownership of the\r
234 buffer.\r
235\r
236 @retval EFI_SUCCESS The data was read correctly from the device.\r
237 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
238 to perform the read operation.\r
239 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not\r
240 valid, or the buffer is not properly aligned.\r
241 @retval EFI_NO_MEDIA There is no media in the device.\r
242 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
243 the intrinsic block size of the device.\r
244\r
245**/\r
246EFI_STATUS\r
247EFIAPI\r
248AhciBlockIoReadBlocks2 (\r
249 IN EFI_PEI_SERVICES **PeiServices,\r
250 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r
251 IN UINTN DeviceIndex,\r
252 IN EFI_PEI_LBA StartLBA,\r
253 IN UINTN BufferSize,\r
254 OUT VOID *Buffer\r
255 );\r
256\r
257#endif\r