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 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
141 TODO: Add function description
143 @param This TODO: add argument description
144 @param Controller TODO: add argument description
145 @param RemainingDevicePath TODO: add argument description
147 TODO: add return values.
152 IDEBusDriverBindingSupported (
153 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
154 IN EFI_HANDLE Controller
,
155 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
159 TODO: Add function description
161 @param This TODO: add argument description
162 @param Controller TODO: add argument description
163 @param RemainingDevicePath TODO: add argument description
165 TODO: add return values.
170 IDEBusDriverBindingStart (
171 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
172 IN EFI_HANDLE Controller
,
173 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
177 TODO: Add function description
179 @param This TODO: add argument description
180 @param Controller TODO: add argument description
181 @param NumberOfChildren TODO: add argument description
182 @param ChildHandleBuffer TODO: add argument description
184 TODO: add return values.
189 IDEBusDriverBindingStop (
190 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
191 IN EFI_HANDLE Controller
,
192 IN UINTN NumberOfChildren
,
193 IN EFI_HANDLE
*ChildHandleBuffer
197 // EFI Driver Configuration Functions
200 IDEBusDriverConfigurationSetOptions (
201 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
202 IN EFI_HANDLE ControllerHandle
,
203 IN EFI_HANDLE ChildHandle OPTIONAL
,
205 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
209 IDEBusDriverConfigurationOptionsValid (
210 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
211 IN EFI_HANDLE ControllerHandle
,
212 IN EFI_HANDLE ChildHandle OPTIONAL
216 IDEBusDriverConfigurationForceDefaults (
217 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
218 IN EFI_HANDLE ControllerHandle
,
219 IN EFI_HANDLE ChildHandle OPTIONAL
,
220 IN UINT32 DefaultType
,
221 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
225 // EFI Driver Diagnostics Functions
228 IDEBusDriverDiagnosticsRunDiagnostics (
229 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*This
,
230 IN EFI_HANDLE ControllerHandle
,
231 IN EFI_HANDLE ChildHandle OPTIONAL
,
232 IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType
,
234 OUT EFI_GUID
**ErrorType
,
235 OUT UINTN
*BufferSize
,
240 // Block I/O Protocol Interface
243 TODO: Add function description
245 @param This TODO: add argument description
246 @param ExtendedVerification TODO: add argument description
248 TODO: add return values.
254 IN EFI_BLOCK_IO_PROTOCOL
*This
,
255 IN BOOLEAN ExtendedVerification
259 TODO: Add function description
261 @param This TODO: add argument description
262 @param MediaId TODO: add argument description
263 @param LBA TODO: add argument description
264 @param BufferSize TODO: add argument description
265 @param Buffer TODO: add argument description
267 TODO: add return values
273 IN EFI_BLOCK_IO_PROTOCOL
*This
,
281 TODO: Add function description
283 @param This TODO: add argument description
284 @param MediaId TODO: add argument description
285 @param LBA TODO: add argument description
286 @param BufferSize TODO: add argument description
287 @param Buffer TODO: add argument description
289 TODO: add return values.
294 IDEBlkIoWriteBlocks (
295 IN EFI_BLOCK_IO_PROTOCOL
*This
,
303 TODO: Add function description
305 @param This TODO: add argument description
307 TODO: add return values.
312 IDEBlkIoFlushBlocks (
313 IN EFI_BLOCK_IO_PROTOCOL
*This
317 TODO: Add function description
319 @param PciIo TODO: add argument description
320 @param Enable TODO: add argument description
322 TODO: add return values.
326 IDERegisterDecodeEnableorDisable (
327 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
332 TODO: Add function description
334 @param This TODO: add argument description
335 @param InquiryData TODO: add argument description
336 @param IntquiryDataSize TODO: add argument description
338 TODO: add return values.
344 IN EFI_DISK_INFO_PROTOCOL
*This
,
345 IN OUT VOID
*InquiryData
,
346 IN OUT UINT32
*IntquiryDataSize
350 TODO: Add function description
352 @param This TODO: add argument description
353 @param IdentifyData TODO: add argument description
354 @param IdentifyDataSize TODO: add argument description
356 TODO: add return values.
361 IDEDiskInfoIdentify (
362 IN EFI_DISK_INFO_PROTOCOL
*This
,
363 IN OUT VOID
*IdentifyData
,
364 IN OUT UINT32
*IdentifyDataSize
368 TODO: Add function description
370 @param This TODO: add argument description
371 @param SenseData TODO: add argument description
372 @param SenseDataSize TODO: add argument description
373 @param SenseDataNumber TODO: add argument description
375 TODO: add return values.
380 IDEDiskInfoSenseData (
381 IN EFI_DISK_INFO_PROTOCOL
*This
,
382 IN OUT VOID
*SenseData
,
383 IN OUT UINT32
*SenseDataSize
,
384 OUT UINT8
*SenseDataNumber
388 TODO: Add function description
390 @param This TODO: add argument description
391 @param IdeChannel TODO: add argument description
392 @param IdeDevice TODO: add argument description
394 TODO: add return values.
399 IDEDiskInfoWhichIde (
400 IN EFI_DISK_INFO_PROTOCOL
*This
,
401 OUT UINT32
*IdeChannel
,
402 OUT UINT32
*IdeDevice