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