]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.h
update the function header comment to comply with PI1.2 volume 5
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / IdeBusDxe / IdeBus.h
1 /** @file
2 Header file for IDE Bus Driver.
3
4 Copyright (c) 2006 - 2007 Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _IDE_BUS_H_
16 #define _IDE_BUS_H_
17
18
19
20 #include <FrameworkDxe.h>
21
22 #include <Protocol/IdeControllerInit.h>
23 #include <Protocol/BlockIo.h>
24 #include <Protocol/PciIo.h>
25 #include <Protocol/DiskInfo.h>
26 #include <Protocol/DevicePath.h>
27
28 #include <Library/DebugLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/BaseLib.h>
31 #include <Library/UefiLib.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/ReportStatusCodeLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/PerformanceLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UefiRuntimeServicesTableLib.h>
38 #include <Library/DevicePathLib.h>
39
40 #include <Guid/EventGroup.h>
41
42 #include <IndustryStandard/Pci22.h>
43 #include "IdeData.h"
44
45 //
46 // Global Variables
47 //
48 extern EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding;
49 extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gIDEBusDriverDiagnostics;
50 extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2;
51
52 //
53 // Extra Definition to porting
54 //
55 #define MAX_IDE_DEVICE 4
56 #define MAX_IDE_CHANNELS 2
57 #define MAX_IDE_DRIVES 2
58
59 #define INVALID_DEVICE_TYPE 0xff
60 #define ATA_DEVICE_TYPE 0x00
61 #define ATAPI_DEVICE_TYPE 0x01
62
63 #define EFI_IOB_ATA_BUS_SMART_ENABLE (EFI_SUBCLASS_SPECIFIC | 0x00000000)
64 #define EFI_IOB_ATA_BUS_SMART_DISABLE (EFI_SUBCLASS_SPECIFIC | 0x00000001)
65 #define EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD (EFI_SUBCLASS_SPECIFIC | 0x00000002)
66 #define EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD (EFI_SUBCLASS_SPECIFIC | 0x00000003)
67
68 typedef struct {
69 BOOLEAN HaveScannedDevice[MAX_IDE_DEVICE];
70 BOOLEAN DeviceFound[MAX_IDE_DEVICE];
71 BOOLEAN DeviceProcessed[MAX_IDE_DEVICE];
72 } IDE_BUS_DRIVER_PRIVATE_DATA;
73
74 #define IDE_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('i', 'b', 'i', 'd')
75
76 typedef struct {
77 UINT32 Signature;
78
79 EFI_HANDLE Handle;
80 EFI_BLOCK_IO_PROTOCOL BlkIo;
81 EFI_BLOCK_IO_MEDIA BlkMedia;
82 EFI_DISK_INFO_PROTOCOL DiskInfo;
83 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
84 EFI_PCI_IO_PROTOCOL *PciIo;
85 IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
86
87 //
88 // Local Data for IDE interface goes here
89 //
90 EFI_IDE_CHANNEL Channel;
91 EFI_IDE_DEVICE Device;
92 UINT16 Lun;
93 IDE_DEVICE_TYPE Type;
94
95 IDE_BASE_REGISTERS *IoPort;
96 UINT16 AtapiError;
97
98 ATAPI_INQUIRY_DATA *InquiryData;
99 EFI_IDENTIFY_DATA *IdData;
100 ATA_PIO_MODE PioMode;
101 EFI_ATA_MODE UdmaMode;
102 CHAR8 ModelName[41];
103 ATAPI_REQUEST_SENSE_DATA *SenseData;
104 UINT8 SenseDataNumber;
105 UINT8 *Cache;
106
107 //
108 // ExitBootService Event, it is used to clear pending IDE interrupt
109 //
110 EFI_EVENT ExitBootServiceEvent;
111
112 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
113 } IDE_BLK_IO_DEV;
114
115 #include "ComponentName.h"
116
117 #define IDE_BLOCK_IO_DEV_FROM_THIS(a) CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)
118 #define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)
119
120 #include "Ide.h"
121
122
123 /**
124 Supported function of Driver Binding protocol for this driver.
125
126 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
127 @param ControllerHandle The handle of the controller to test.
128 @param RemainingDevicePath A pointer to the remaining portion of a device path.
129
130 @retval EFI_SUCCESS Driver loaded.
131 @retval other Driver not loaded.
132
133 **/
134 EFI_STATUS
135 EFIAPI
136 IDEBusDriverBindingSupported (
137 IN EFI_DRIVER_BINDING_PROTOCOL *This,
138 IN EFI_HANDLE Controller,
139 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
140 );
141
142 /**
143 Start function of Driver binding protocol which start this driver on Controller
144 by detecting all disks and installing BlockIo protocol on them.
145
146 @param This Protocol instance pointer.
147 @param Controller Handle of device to bind driver to.
148 @param RemainingDevicePath produce all possible children.
149
150 @retval EFI_SUCCESS This driver is added to ControllerHandle.
151 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
152 @retval other This driver does not support this device.
153
154 **/
155 EFI_STATUS
156 EFIAPI
157 IDEBusDriverBindingStart (
158 IN EFI_DRIVER_BINDING_PROTOCOL *This,
159 IN EFI_HANDLE Controller,
160 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
161 );
162
163 /**
164 Stop function of Driver Binding Protocol which is to stop the driver on Controller Handle and all
165 child handle attached to the controller handle if there are.
166
167 @param This Protocol instance pointer.
168 @param Controller Handle of device to stop driver on
169 @param NumberOfChildren Not used
170 @param ChildHandleBuffer Not used
171
172 @retval EFI_SUCCESS This driver is removed DeviceHandle
173 @retval other This driver was not removed from this device
174
175 **/
176 EFI_STATUS
177 EFIAPI
178 IDEBusDriverBindingStop (
179 IN EFI_DRIVER_BINDING_PROTOCOL *This,
180 IN EFI_HANDLE Controller,
181 IN UINTN NumberOfChildren,
182 IN EFI_HANDLE *ChildHandleBuffer
183 );
184
185 //
186 // EFI Driver Configuration Functions
187 //
188 /**
189 Allows the user to set controller specific options for a controller that a
190 driver is currently managing.
191
192 @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
193 @param ControllerHandle The handle of the controller to set options on.
194 @param ChildHandle The handle of the child controller to set options on.
195 This is an optional parameter that may be NULL.
196 It will be NULL for device drivers, and for a bus drivers
197 that wish to set options for the bus controller.
198 It will not be NULL for a bus driver that wishes to set
199 options for one of its child controllers.
200 @param Language A pointer to a three character ISO 639-2 language identifier.
201 This is the language of the user interface that should be presented
202 to the user, and it must match one of the languages specified in
203 SupportedLanguages. The number of languages supported by a driver is up to
204 the driver writer.
205 @param ActionRequired A pointer to the action that the calling agent is required
206 to perform when this function returns.
207
208
209 @retval EFI_SUCCESS The driver specified by This successfully set the configuration
210 options for the controller specified by ControllerHandle..
211 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
212 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
213 @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
214 @retval EFI_UNSUPPORTED The driver specified by This does not support setting configuration options for
215 the controller specified by ControllerHandle and ChildHandle.
216 @retval EFI_UNSUPPORTED The driver specified by This does not support the language specified by Language.
217 @retval EFI_DEVICE_ERROR A device error occurred while attempt to set the configuration options for the
218 controller specified by ControllerHandle and ChildHandle.
219 @retval EFI_OUT_RESOURCES There are not enough resources available to set the configuration options for the
220 controller specified by ControllerHandle and ChildHandle
221 **/
222 EFI_STATUS
223 EFIAPI
224 IDEBusDriverConfigurationSetOptions (
225 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
226 IN EFI_HANDLE ControllerHandle,
227 IN EFI_HANDLE ChildHandle OPTIONAL,
228 IN CHAR8 *Language,
229 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
230 );
231
232 /**
233 Tests to see if a controller's current configuration options are valid.
234
235 @param This A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
236 @param ControllerHandle The handle of the controller to test if it's current configuration options
237 are valid.
238 @param ChildHandle The handle of the child controller to test if it's current configuration
239 options are valid. This is an optional parameter that may be NULL. It will
240 be NULL for device drivers. It will also be NULL for a bus drivers that
241 wish to test the configuration options for the bus controller. It will
242 not be NULL for a bus driver that wishes to test configuration options for
243 one of its child controllers.
244 @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle that is being
245 managed by the driver specified by This has a valid set of configuration
246 options.
247 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
248 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
249 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing the controller
250 specified by ControllerHandle and ChildHandle.
251 @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle that is being
252 managed by the driver specified by This has an invalid set of configuration
253 options.
254 **/
255 EFI_STATUS
256 EFIAPI
257 IDEBusDriverConfigurationOptionsValid (
258 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
259 IN EFI_HANDLE ControllerHandle,
260 IN EFI_HANDLE ChildHandle OPTIONAL
261 );
262
263 /**
264 Forces a driver to set the default configuration options for a controller.
265
266 @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
267 @param ControllerHandle The handle of the controller to force default configuration options on.
268 @param ChildHandle The handle of the child controller to force default configuration
269 options on This is an optional parameter that may be NULL. It
270 will be NULL for device drivers. It will also be NULL for a bus
271 drivers that wish to force default configuration options for the bus
272 controller. It will not be NULL for a bus driver that wishes to force
273 default configuration options for one of its child controllers.
274 @param DefaultType The type of default configuration options to force on the controller
275 specified by ControllerHandle and ChildHandle.
276 @param ActionRequired A pointer to the action that the calling agent is required to perform
277 when this function returns.
278
279 @retval EFI_SUCCESS The driver specified by This successfully forced the
280 default configuration options on the controller specified by
281 ControllerHandle and ChildHandle.
282 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
283 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
284 @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
285 @retval EFI_UNSUPPORTED The driver specified by This does not support forcing the default
286 configuration options on the controller specified by ControllerHandle
287 and ChildHandle.
288 @retval EFI_UNSUPPORTED The driver specified by This does not support the configuration type
289 specified by DefaultType.
290 @retval EFI_DEVICE_ERROR A device error occurred while attempt to force the default configuration
291 options on the controller specified by ControllerHandle and ChildHandle.
292 @retval EFI_OUT_RESOURCES There are not enough resources available to force the default configuration
293 options on the controller specified by ControllerHandle and ChildHandle.
294 **/
295 EFI_STATUS
296 EFIAPI
297 IDEBusDriverConfigurationForceDefaults (
298 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
299 IN EFI_HANDLE ControllerHandle,
300 IN EFI_HANDLE ChildHandle OPTIONAL,
301 IN UINT32 DefaultType,
302 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
303 );
304
305 //
306 // EFI Driver Diagnostics Functions
307 //
308 /**
309 Runs diagnostics on a controller.
310
311 @param This A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOLinstance.
312 @param ControllerHandle The handle of the controller to run diagnostics on.
313 @param ChildHandle The handle of the child controller to run diagnostics on
314 This is an optional parameter that may be NULL. It will
315 be NULL for device drivers. It will also be NULL for a
316 bus drivers that wish to run diagnostics on the bus controller.
317 It will not be NULL for a bus driver that wishes to run
318 diagnostics on one of its child controllers.
319 @param DiagnosticType Indicates type of diagnostics to perform on the controller
320 specified by ControllerHandle and ChildHandle.
321 @param Language A pointer to a three character ISO 639-2 language identifier.
322 This is the language in which the optional error message should
323 be returned in Buffer, and it must match one of the languages
324 specified in SupportedLanguages. The number of languages supported by
325 a driver is up to the driver writer.
326 @param ErrorType A GUID that defines the format of the data returned in Buffer.
327 @param BufferSize The size, in bytes, of the data returned in Buffer.
328 @param Buffer A buffer that contains a Null-terminated Unicode string
329 plus some additional data whose format is defined by ErrorType.
330 Buffer is allocated by this function with AllocatePool(), and
331 it is the caller's responsibility to free it with a call to FreePool().
332
333 @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle passed
334 the diagnostic.
335 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
336 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
337 @retval EFI_INVALID_PARAMETER Language is NULL.
338 @retval EFI_INVALID_PARAMETER ErrorType is NULL.
339 @retval EFI_INVALID_PARAMETER BufferType is NULL.
340 @retval EFI_INVALID_PARAMETER Buffer is NULL.
341 @retval EFI_UNSUPPORTED The driver specified by This does not support running
342 diagnostics for the controller specified by ControllerHandle
343 and ChildHandle.
344 @retval EFI_UNSUPPORTED The driver specified by This does not support the
345 type of diagnostic specified by DiagnosticType.
346 @retval EFI_UNSUPPORTED The driver specified by This does not support the language
347 specified by Language.
348 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to complete the
349 diagnostics.
350 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to return the
351 status information in ErrorType, BufferSize,and Buffer.
352 @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle
353 did not pass the diagnostic.
354 **/
355 EFI_STATUS
356 EFIAPI
357 IDEBusDriverDiagnosticsRunDiagnostics (
358 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
359 IN EFI_HANDLE ControllerHandle,
360 IN EFI_HANDLE ChildHandle OPTIONAL,
361 IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
362 IN CHAR8 *Language,
363 OUT EFI_GUID **ErrorType,
364 OUT UINTN *BufferSize,
365 OUT CHAR16 **Buffer
366 );
367
368 /**
369 issue ATA or ATAPI command to reset a block IO device.
370 @param This Block IO protocol instance pointer.
371 @param ExtendedVerification If FALSE,for ATAPI device, driver will only invoke ATAPI reset method
372 If TRUE, for ATAPI device, driver need invoke ATA reset method after
373 invoke ATAPI reset method
374
375 @retval EFI_DEVICE_ERROR When the device is neighther ATA device or ATAPI device.
376 @retval EFI_SUCCESS The device reset successfully
377
378 **/
379 EFI_STATUS
380 EFIAPI
381 IDEBlkIoReset (
382 IN EFI_BLOCK_IO_PROTOCOL *This,
383 IN BOOLEAN ExtendedVerification
384 );
385
386 /**
387 Read data from a block IO device.
388
389 @param This Block IO protocol instance pointer.
390 @param MediaId The media ID of the device
391 @param Lba Starting LBA address to read data
392 @param BufferSize The size of data to be read
393 @param Buffer Caller supplied buffer to save data
394
395 @retval EFI_DEVICE_ERROR unknown device type
396 @retval EFI_SUCCESS read the data successfully.
397
398 **/
399 EFI_STATUS
400 EFIAPI
401 IDEBlkIoReadBlocks (
402 IN EFI_BLOCK_IO_PROTOCOL *This,
403 IN UINT32 MediaId,
404 IN EFI_LBA Lba,
405 IN UINTN BufferSize,
406 OUT VOID *Buffer
407 );
408
409 /**
410 Write data to block io device
411
412 @param This Protocol instance pointer.
413 @param MediaId The media ID of the device
414 @param Lba Starting LBA address to write data
415 @param BufferSize The size of data to be written
416 @param Buffer Caller supplied buffer to save data
417
418 @retval EFI_DEVICE_ERROR unknown device type
419 @retval other write data status
420
421 **/
422 EFI_STATUS
423 EFIAPI
424 IDEBlkIoWriteBlocks (
425 IN EFI_BLOCK_IO_PROTOCOL *This,
426 IN UINT32 MediaId,
427 IN EFI_LBA Lba,
428 IN UINTN BufferSize,
429 IN VOID *Buffer
430 );
431
432 /**
433 Flushes all modified data to a physical block devices
434
435 @param This Indicates a pointer to the calling context which to sepcify a
436 sepcific block device
437
438 @retval EFI_SUCCESS Always return success.
439 **/
440 EFI_STATUS
441 EFIAPI
442 IDEBlkIoFlushBlocks (
443 IN EFI_BLOCK_IO_PROTOCOL *This
444 );
445 /**
446 This function is used by the IDE bus driver to get inquiry data.
447 Data format of Identify data is defined by the Interface GUID.
448
449 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
450 @param InquiryData Pointer to a buffer for the inquiry data.
451 @param InquiryDataSize Pointer to the value for the inquiry data size.
452
453 @retval EFI_SUCCESS The command was accepted without any errors.
454 @retval EFI_NOT_FOUND Device does not support this data class
455 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
456 @retval EFI_BUFFER_TOO_SMALL IntquiryDataSize not big enough
457
458 **/
459 EFI_STATUS
460 EFIAPI
461 IDEDiskInfoInquiry (
462 IN EFI_DISK_INFO_PROTOCOL *This,
463 IN OUT VOID *InquiryData,
464 IN OUT UINT32 *InquiryDataSize
465 );
466
467 /**
468 This function is used by the IDE bus driver to get identify data.
469 Data format of Identify data is defined by the Interface GUID.
470
471 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
472 @param IdentifyData Pointer to a buffer for the identify data.
473 @param IdentifyDataSize Pointer to the value for the identify data size.
474
475 @retval EFI_SUCCESS The command was accepted without any errors.
476 @retval EFI_NOT_FOUND Device does not support this data class
477 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
478 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
479
480 **/
481 EFI_STATUS
482 EFIAPI
483 IDEDiskInfoIdentify (
484 IN EFI_DISK_INFO_PROTOCOL *This,
485 IN OUT VOID *IdentifyData,
486 IN OUT UINT32 *IdentifyDataSize
487 );
488
489 /**
490 This function is used by the IDE bus driver to get sense data.
491 Data format of Sense data is defined by the Interface GUID.
492
493 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
494 @param SenseData Pointer to the SenseData.
495 @param SenseDataSize Size of SenseData in bytes.
496 @param SenseDataNumber Pointer to the value for the identify data size.
497
498 @retval EFI_SUCCESS The command was accepted without any errors.
499 @retval EFI_NOT_FOUND Device does not support this data class
500 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
501 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough
502
503 **/
504 EFI_STATUS
505 EFIAPI
506 IDEDiskInfoSenseData (
507 IN EFI_DISK_INFO_PROTOCOL *This,
508 IN OUT VOID *SenseData,
509 IN OUT UINT32 *SenseDataSize,
510 OUT UINT8 *SenseDataNumber
511 );
512
513 /**
514 This function is used by the IDE bus driver to get controller information.
515
516 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
517 @param IdeChannel Pointer to the Ide Channel number. Primary or secondary.
518 @param IdeDevice Pointer to the Ide Device number. Master or slave.
519
520 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid
521 @retval EFI_UNSUPPORTED This is not an IDE device
522
523 **/
524 EFI_STATUS
525 EFIAPI
526 IDEDiskInfoWhichIde (
527 IN EFI_DISK_INFO_PROTOCOL *This,
528 OUT UINT32 *IdeChannel,
529 OUT UINT32 *IdeDevice
530 );
531 /**
532 The is an event(generally the event is exitBootService event) call back function.
533 Clear pending IDE interrupt before OS loader/kernel take control of the IDE device.
534
535 @param Event Pointer to this event
536 @param Context Event hanlder private data
537
538 **/
539 VOID
540 EFIAPI
541 ClearInterrupt (
542 IN EFI_EVENT Event,
543 IN VOID *Context
544 );
545 #endif