2 Header file for IDE Bus Driver.
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
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.
20 #include <FrameworkDxe.h>
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>
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>
40 #include <IndustryStandard/pci22.h>
44 // Extra Definition to porting
46 #define MAX_IDE_DEVICE 4
47 #define MAX_IDE_CHANNELS 2
48 #define MAX_IDE_DRIVES 2
50 #define INVALID_DEVICE_TYPE 0xff
51 #define ATA_DEVICE_TYPE 0x00
52 #define ATAPI_DEVICE_TYPE 0x01
54 #define EFI_IOB_ATA_BUS_SMART_ENABLE (EFI_SUBCLASS_SPECIFIC | 0x00000000)
55 #define EFI_IOB_ATA_BUS_SMART_DISABLE (EFI_SUBCLASS_SPECIFIC | 0x00000001)
56 #define EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD (EFI_SUBCLASS_SPECIFIC | 0x00000002)
57 #define EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD (EFI_SUBCLASS_SPECIFIC | 0x00000003)
60 BOOLEAN HaveScannedDevice
[MAX_IDE_DEVICE
];
61 BOOLEAN DeviceFound
[MAX_IDE_DEVICE
];
62 BOOLEAN DeviceProcessed
[MAX_IDE_DEVICE
];
63 } IDE_BUS_DRIVER_PRIVATE_DATA
;
65 #define IDE_BLK_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('i', 'b', 'i', 'd')
71 EFI_BLOCK_IO_PROTOCOL BlkIo
;
72 EFI_BLOCK_IO_MEDIA BlkMedia
;
73 EFI_DISK_INFO_PROTOCOL DiskInfo
;
74 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
75 EFI_PCI_IO_PROTOCOL
*PciIo
;
76 IDE_BUS_DRIVER_PRIVATE_DATA
*IdeBusDriverPrivateData
;
79 // Local Data for IDE interface goes here
81 EFI_IDE_CHANNEL Channel
;
82 EFI_IDE_DEVICE Device
;
86 IDE_BASE_REGISTERS
*IoPort
;
89 ATAPI_INQUIRY_DATA
*pInquiryData
;
90 EFI_IDENTIFY_DATA
*pIdData
;
92 EFI_ATA_MODE UdmaMode
;
94 ATAPI_REQUEST_SENSE_DATA
*SenseData
;
95 UINT8 SenseDataNumber
;
99 // ExitBootService Event, it is used to clear pending IDE interrupt
101 EFI_EVENT ExitBootServiceEvent
;
103 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
106 #include "ComponentName.h"
108 #define IDE_BLOCK_IO_DEV_FROM_THIS(a) CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)
109 #define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)
114 extern EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding
;
115 extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gIDEBusDriverDiagnostics
;
116 extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2
;
122 // Driver model protocol interface
125 TODO: Add function description
127 @param ImageHandle TODO: add argument description
128 @param SystemTable TODO: add argument description
130 TODO: add return values
135 IDEBusControllerDriverEntryPoint (
136 IN EFI_HANDLE ImageHandle
,
137 IN EFI_SYSTEM_TABLE
*SystemTable
142 TODO: Add function description
144 @param This TODO: add argument description
145 @param Controller TODO: add argument description
146 @param RemainingDevicePath TODO: add argument description
148 TODO: add return values
153 IDEBusDriverBindingSupported (
154 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
155 IN EFI_HANDLE Controller
,
156 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
161 TODO: Add function description
163 @param This TODO: add argument description
164 @param Controller TODO: add argument description
165 @param RemainingDevicePath TODO: add argument description
167 TODO: add return values
172 IDEBusDriverBindingStart (
173 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
174 IN EFI_HANDLE Controller
,
175 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
180 TODO: Add function description
182 @param This TODO: add argument description
183 @param Controller TODO: add argument description
184 @param NumberOfChildren TODO: add argument description
185 @param ChildHandleBuffer TODO: add argument description
187 TODO: add return values
192 IDEBusDriverBindingStop (
193 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
194 IN EFI_HANDLE Controller
,
195 IN UINTN NumberOfChildren
,
196 IN EFI_HANDLE
*ChildHandleBuffer
201 // EFI Driver Configuration Functions
204 IDEBusDriverConfigurationSetOptions (
205 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
206 IN EFI_HANDLE ControllerHandle
,
207 IN EFI_HANDLE ChildHandle OPTIONAL
,
209 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
213 IDEBusDriverConfigurationOptionsValid (
214 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
215 IN EFI_HANDLE ControllerHandle
,
216 IN EFI_HANDLE ChildHandle OPTIONAL
220 IDEBusDriverConfigurationForceDefaults (
221 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
222 IN EFI_HANDLE ControllerHandle
,
223 IN EFI_HANDLE ChildHandle OPTIONAL
,
224 IN UINT32 DefaultType
,
225 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
229 // EFI Driver Diagnostics Functions
232 IDEBusDriverDiagnosticsRunDiagnostics (
233 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*This
,
234 IN EFI_HANDLE ControllerHandle
,
235 IN EFI_HANDLE ChildHandle OPTIONAL
,
236 IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType
,
238 OUT EFI_GUID
**ErrorType
,
239 OUT UINTN
*BufferSize
,
244 // Block I/O Protocol Interface
247 TODO: Add function description
249 @param This TODO: add argument description
250 @param ExtendedVerification TODO: add argument description
252 TODO: add return values
258 IN EFI_BLOCK_IO_PROTOCOL
*This
,
259 IN BOOLEAN ExtendedVerification
264 TODO: Add function description
266 @param This TODO: add argument description
267 @param MediaId TODO: add argument description
268 @param LBA TODO: add argument description
269 @param BufferSize TODO: add argument description
270 @param Buffer TODO: add argument description
272 TODO: add return values
278 IN EFI_BLOCK_IO_PROTOCOL
*This
,
287 TODO: Add function description
289 @param This TODO: add argument description
290 @param MediaId TODO: add argument description
291 @param LBA TODO: add argument description
292 @param BufferSize TODO: add argument description
293 @param Buffer TODO: add argument description
295 TODO: add return values
300 IDEBlkIoWriteBlocks (
301 IN EFI_BLOCK_IO_PROTOCOL
*This
,
310 TODO: Add function description
312 @param This TODO: add argument description
314 TODO: add return values
319 IDEBlkIoFlushBlocks (
320 IN EFI_BLOCK_IO_PROTOCOL
*This
325 TODO: Add function description
327 @param PciIo TODO: add argument description
328 @param Enable TODO: add argument description
330 TODO: add return values
334 IDERegisterDecodeEnableorDisable (
335 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
341 TODO: Add function description
343 @param This TODO: add argument description
344 @param InquiryData TODO: add argument description
345 @param IntquiryDataSize TODO: add argument description
347 TODO: add return values
353 IN EFI_DISK_INFO_PROTOCOL
*This
,
354 IN OUT VOID
*InquiryData
,
355 IN OUT UINT32
*IntquiryDataSize
360 TODO: Add function description
362 @param This TODO: add argument description
363 @param IdentifyData TODO: add argument description
364 @param IdentifyDataSize TODO: add argument description
366 TODO: add return values
371 IDEDiskInfoIdentify (
372 IN EFI_DISK_INFO_PROTOCOL
*This
,
373 IN OUT VOID
*IdentifyData
,
374 IN OUT UINT32
*IdentifyDataSize
379 TODO: Add function description
381 @param This TODO: add argument description
382 @param SenseData TODO: add argument description
383 @param SenseDataSize TODO: add argument description
384 @param SenseDataNumber TODO: add argument description
386 TODO: add return values
391 IDEDiskInfoSenseData (
392 IN EFI_DISK_INFO_PROTOCOL
*This
,
393 IN OUT VOID
*SenseData
,
394 IN OUT UINT32
*SenseDataSize
,
395 OUT UINT8
*SenseDataNumber
400 TODO: Add function description
402 @param This TODO: add argument description
403 @param IdeChannel TODO: add argument description
404 @param IdeDevice TODO: add argument description
406 TODO: add return values
411 IDEDiskInfoWhichIde (
412 IN EFI_DISK_INFO_PROTOCOL
*This
,
413 OUT UINT32
*IdeChannel
,
414 OUT UINT32
*IdeDevice