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