]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Csm/BiosThunk/BlockIoDxe/BiosBlkIo.h
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Csm / BiosThunk / BlockIoDxe / BiosBlkIo.h
CommitLineData
bcecde14 1/** @file\r
2\r
0a6f4824 3Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
bcecde14 4\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions\r
7of the BSD License which accompanies this distribution. The\r
8full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _BIOS_BLOCK_IO_H_\r
17#define _BIOS_BLOCK_IO_H_\r
18\r
19#include <Uefi.h>\r
20\r
21#include <Protocol/BlockIo.h>\r
22#include <Protocol/PciIo.h>\r
23#include <Protocol/LegacyBios.h>\r
24#include <Protocol/DevicePath.h>\r
25#include <Guid/LegacyBios.h>\r
e24fc103 26#include <Guid/BlockIoVendor.h>\r
bcecde14 27\r
28#include <Library/UefiDriverEntryPoint.h>\r
29#include <Library/DebugLib.h>\r
30#include <Library/BaseMemoryLib.h>\r
31#include <Library/UefiBootServicesTableLib.h>\r
32#include <Library/UefiLib.h>\r
33#include <Library/DevicePathLib.h>\r
34#include <Library/MemoryAllocationLib.h>\r
35\r
36#include <IndustryStandard/Pci.h>\r
37\r
38#include "Edd.h"\r
39\r
bcecde14 40//\r
41// Global Variables\r
42//\r
43extern EFI_COMPONENT_NAME_PROTOCOL gBiosBlockIoComponentName;\r
44extern EFI_COMPONENT_NAME2_PROTOCOL gBiosBlockIoComponentName2;\r
45\r
46\r
47//\r
48// Define the I2O class code\r
49//\r
50#define PCI_BASE_CLASS_INTELLIGENT 0x0e\r
51#define PCI_SUB_CLASS_INTELLIGENT 0x00\r
52\r
53//\r
54// Number of pages needed for our buffer under 1MB\r
55//\r
56#define BLOCK_IO_BUFFER_PAGE_SIZE (((sizeof (EDD_DEVICE_ADDRESS_PACKET) + sizeof (BIOS_LEGACY_DRIVE) + MAX_EDD11_XFER) / EFI_PAGE_SIZE) + 1 \\r
57 )\r
58\r
59//\r
60// Driver Binding Protocol functions\r
61//\r
62\r
63/**\r
64 Check whether the driver supports this device.\r
65\r
66 @param This The Udriver binding protocol.\r
67 @param Controller The controller handle to check.\r
68 @param RemainingDevicePath The remaining device path.\r
69\r
70 @retval EFI_SUCCESS The driver supports this controller.\r
71 @retval other This device isn't supported.\r
72\r
73**/\r
74EFI_STATUS\r
75EFIAPI\r
76BiosBlockIoDriverBindingSupported (\r
77 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
78 IN EFI_HANDLE Controller,\r
79 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
80 );\r
81\r
82\r
83/**\r
84 Starts the device with this driver.\r
85\r
86 @param This The driver binding instance.\r
87 @param Controller Handle of device to bind driver to.\r
88 @param RemainingDevicePath Optional parameter use to pick a specific child\r
89 device to start.\r
90\r
91 @retval EFI_SUCCESS The controller is controlled by the driver.\r
92 @retval Other This controller cannot be started.\r
93\r
94**/\r
95EFI_STATUS\r
96EFIAPI\r
97BiosBlockIoDriverBindingStart (\r
98 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
99 IN EFI_HANDLE Controller,\r
100 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
101 );\r
102\r
103/**\r
104 Stop the device handled by this driver.\r
105\r
106 @param This The driver binding protocol.\r
107 @param Controller The controller to release.\r
108 @param NumberOfChildren The number of handles in ChildHandleBuffer.\r
109 @param ChildHandleBuffer The array of child handle.\r
110\r
111 @retval EFI_SUCCESS The device was stopped.\r
112 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
113 @retval Others Fail to uninstall protocols attached on the device.\r
114\r
115**/\r
116EFI_STATUS\r
117EFIAPI\r
118BiosBlockIoDriverBindingStop (\r
119 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
120 IN EFI_HANDLE Controller,\r
121 IN UINTN NumberOfChildren,\r
122 IN EFI_HANDLE *ChildHandleBuffer\r
123 );\r
124\r
125//\r
126// Other internal functions\r
127//\r
128\r
129/**\r
130 Build device path for EDD 3.0.\r
131\r
132 @param BaseDevicePath Base device path.\r
133 @param Drive Legacy drive.\r
134 @param DevicePath Device path for output.\r
135\r
136 @retval EFI_SUCCESS The device path is built successfully.\r
137 @retval EFI_UNSUPPORTED It is failed to built device path.\r
138\r
139**/\r
140EFI_STATUS\r
141BuildEdd30DevicePath (\r
142 IN EFI_DEVICE_PATH_PROTOCOL *BaseDevicePath,\r
143 IN BIOS_LEGACY_DRIVE *Drive,\r
144 IN EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
145 );\r
146\r
147/**\r
148 Initialize block I/O device instance\r
149\r
150 @param Dev Instance of block I/O device instance\r
151\r
152 @retval TRUE Initialization succeeds.\r
153 @retval FALSE Initialization fails.\r
154\r
155**/\r
156BOOLEAN\r
157BiosInitBlockIo (\r
158 IN BIOS_BLOCK_IO_DEV *Dev\r
159 );\r
160\r
161/**\r
162 Read BufferSize bytes from Lba into Buffer.\r
163\r
164 @param This Indicates a pointer to the calling context.\r
165 @param MediaId Id of the media, changes every time the media is replaced.\r
166 @param Lba The starting Logical Block Address to read from\r
167 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
168 @param Buffer A pointer to the destination buffer for the data. The caller is\r
169 responsible for either having implicit or explicit ownership of the buffer.\r
170\r
171 @retval EFI_SUCCESS The data was read correctly from the device.\r
172 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
173 @retval EFI_NO_MEDIA There is no media in the device.\r
174 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
175 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
0a6f4824 176 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
bcecde14 177 or the buffer is not on proper alignment.\r
178\r
179**/\r
180EFI_STATUS\r
181EFIAPI\r
182Edd30BiosReadBlocks (\r
183 IN EFI_BLOCK_IO_PROTOCOL *This,\r
184 IN UINT32 MediaId,\r
185 IN EFI_LBA Lba,\r
186 IN UINTN BufferSize,\r
187 OUT VOID *Buffer\r
188 );\r
189\r
190/**\r
191 Write BufferSize bytes from Lba into Buffer.\r
192\r
193 @param This Indicates a pointer to the calling context.\r
194 @param MediaId The media ID that the write request is for.\r
195 @param Lba The starting logical block address to be written. The caller is\r
196 responsible for writing to only legitimate locations.\r
197 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
198 @param Buffer A pointer to the source buffer for the data.\r
199\r
200 @retval EFI_SUCCESS The data was written correctly to the device.\r
201 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
202 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
203 @retval EFI_NO_MEDIA There is no media in the device.\r
204 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
205 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
0a6f4824 206 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
bcecde14 207 or the buffer is not on proper alignment.\r
208\r
209**/\r
210EFI_STATUS\r
211EFIAPI\r
212Edd30BiosWriteBlocks (\r
213 IN EFI_BLOCK_IO_PROTOCOL *This,\r
214 IN UINT32 MediaId,\r
215 IN EFI_LBA Lba,\r
216 IN UINTN BufferSize,\r
217 OUT VOID *Buffer\r
218 );\r
219\r
220/**\r
221 Flush the Block Device.\r
222\r
223 @param This Indicates a pointer to the calling context.\r
224\r
225 @retval EFI_SUCCESS All outstanding data was written to the device\r
226 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data\r
227 @retval EFI_NO_MEDIA There is no media in the device.\r
228\r
229**/\r
230EFI_STATUS\r
231EFIAPI\r
232BiosBlockIoFlushBlocks (\r
233 IN EFI_BLOCK_IO_PROTOCOL *This\r
234 );\r
235\r
236/**\r
237 Reset the Block Device.\r
238\r
239 @param This Indicates a pointer to the calling context.\r
240 @param ExtendedVerification Driver may perform diagnostics on reset.\r
241\r
242 @retval EFI_SUCCESS The device was reset.\r
243 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
244 not be reset.\r
245\r
246**/\r
247EFI_STATUS\r
248EFIAPI\r
249BiosBlockIoReset (\r
250 IN EFI_BLOCK_IO_PROTOCOL *This,\r
251 IN BOOLEAN ExtendedVerification\r
252 );\r
253\r
254/**\r
255 Read BufferSize bytes from Lba into Buffer.\r
256\r
257 @param This Indicates a pointer to the calling context.\r
258 @param MediaId Id of the media, changes every time the media is replaced.\r
259 @param Lba The starting Logical Block Address to read from\r
260 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
261 @param Buffer A pointer to the destination buffer for the data. The caller is\r
262 responsible for either having implicit or explicit ownership of the buffer.\r
263\r
264 @retval EFI_SUCCESS The data was read correctly from the device.\r
265 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
266 @retval EFI_NO_MEDIA There is no media in the device.\r
267 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
268 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
0a6f4824 269 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
bcecde14 270 or the buffer is not on proper alignment.\r
271\r
272**/\r
273EFI_STATUS\r
274EFIAPI\r
275Edd11BiosReadBlocks (\r
276 IN EFI_BLOCK_IO_PROTOCOL *This,\r
277 IN UINT32 MediaId,\r
278 IN EFI_LBA Lba,\r
279 IN UINTN BufferSize,\r
280 OUT VOID *Buffer\r
281 );\r
282\r
283/**\r
284 Write BufferSize bytes from Lba into Buffer.\r
285\r
286 @param This Indicates a pointer to the calling context.\r
287 @param MediaId The media ID that the write request is for.\r
288 @param Lba The starting logical block address to be written. The caller is\r
289 responsible for writing to only legitimate locations.\r
290 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
291 @param Buffer A pointer to the source buffer for the data.\r
292\r
293 @retval EFI_SUCCESS The data was written correctly to the device.\r
294 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
295 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
296 @retval EFI_NO_MEDIA There is no media in the device.\r
297 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
298 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
0a6f4824 299 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
bcecde14 300 or the buffer is not on proper alignment.\r
301\r
302**/\r
303EFI_STATUS\r
304EFIAPI\r
305Edd11BiosWriteBlocks (\r
306 IN EFI_BLOCK_IO_PROTOCOL *This,\r
307 IN UINT32 MediaId,\r
308 IN EFI_LBA Lba,\r
309 IN UINTN BufferSize,\r
310 OUT VOID *Buffer\r
311 );\r
312\r
313/**\r
314 Read BufferSize bytes from Lba into Buffer.\r
315\r
316 @param This Indicates a pointer to the calling context.\r
317 @param MediaId Id of the media, changes every time the media is replaced.\r
318 @param Lba The starting Logical Block Address to read from\r
319 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
320 @param Buffer A pointer to the destination buffer for the data. The caller is\r
321 responsible for either having implicit or explicit ownership of the buffer.\r
322\r
323 @retval EFI_SUCCESS The data was read correctly from the device.\r
324 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
325 @retval EFI_NO_MEDIA There is no media in the device.\r
326 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
327 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
0a6f4824 328 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
bcecde14 329 or the buffer is not on proper alignment.\r
330\r
331**/\r
332EFI_STATUS\r
333EFIAPI\r
334BiosReadLegacyDrive (\r
335 IN EFI_BLOCK_IO_PROTOCOL *This,\r
336 IN UINT32 MediaId,\r
337 IN EFI_LBA Lba,\r
338 IN UINTN BufferSize,\r
339 OUT VOID *Buffer\r
340 );\r
341\r
342/**\r
343 Write BufferSize bytes from Lba into Buffer.\r
344\r
345 @param This Indicates a pointer to the calling context.\r
346 @param MediaId The media ID that the write request is for.\r
347 @param Lba The starting logical block address to be written. The caller is\r
348 responsible for writing to only legitimate locations.\r
349 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
350 @param Buffer A pointer to the source buffer for the data.\r
351\r
352 @retval EFI_SUCCESS The data was written correctly to the device.\r
353 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
354 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
355 @retval EFI_NO_MEDIA There is no media in the device.\r
356 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
357 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
0a6f4824 358 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
bcecde14 359 or the buffer is not on proper alignment.\r
360\r
361**/\r
362EFI_STATUS\r
363EFIAPI\r
364BiosWriteLegacyDrive (\r
365 IN EFI_BLOCK_IO_PROTOCOL *This,\r
366 IN UINT32 MediaId,\r
367 IN EFI_LBA Lba,\r
368 IN UINTN BufferSize,\r
369 OUT VOID *Buffer\r
370 );\r
371\r
372/**\r
373 Gets parameters of block I/O device.\r
374\r
375 @param BiosBlockIoDev Instance of block I/O device.\r
376 @param Drive Legacy drive.\r
377\r
378 @return Result of device parameter retrieval.\r
0a6f4824 379\r
bcecde14 380**/\r
381UINTN\r
382Int13GetDeviceParameters (\r
383 IN BIOS_BLOCK_IO_DEV *BiosBlockIoDev,\r
384 IN BIOS_LEGACY_DRIVE *Drive\r
385 );\r
386\r
387/**\r
388 Extension of INT13 call.\r
389\r
390 @param BiosBlockIoDev Instance of block I/O device.\r
391 @param Drive Legacy drive.\r
392\r
393 @return Result of this extension.\r
0a6f4824 394\r
bcecde14 395**/\r
396UINTN\r
397Int13Extensions (\r
398 IN BIOS_BLOCK_IO_DEV *BiosBlockIoDev,\r
399 IN BIOS_LEGACY_DRIVE *Drive\r
400 );\r
401\r
402/**\r
403 Gets parameters of legacy drive.\r
404\r
405 @param BiosBlockIoDev Instance of block I/O device.\r
406 @param Drive Legacy drive.\r
407\r
408 @return Result of drive parameter retrieval.\r
0a6f4824 409\r
bcecde14 410**/\r
411UINTN\r
412GetDriveParameters (\r
413 IN BIOS_BLOCK_IO_DEV *BiosBlockIoDev,\r
414 IN BIOS_LEGACY_DRIVE *Drive\r
415 );\r
416\r
417/**\r
418 Build device path for device.\r
419\r
420 @param BaseDevicePath Base device path.\r
421 @param Drive Legacy drive.\r
422 @param DevicePath Device path for output.\r
423\r
424**/\r
425VOID\r
426SetBiosInitBlockIoDevicePath (\r
427 IN EFI_DEVICE_PATH_PROTOCOL *BaseDevicePath,\r
428 IN BIOS_LEGACY_DRIVE *Drive,\r
429 OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
430 );\r
431\r
432#endif\r