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 // The package level header files this module uses
23 #include <Common/FrameworkStatusCode.h>
25 // The protocols, PPI and GUID defintions for this module
27 #include <Protocol/IdeControllerInit.h>
28 #include <Protocol/BlockIo.h>
29 #include <Protocol/PciIo.h>
30 #include <Protocol/DiskInfo.h>
31 #include <Protocol/DevicePath.h>
33 // The Library classes this module consumes
35 #include <Library/DebugLib.h>
36 #include <Library/UefiDriverEntryPoint.h>
37 #include <Library/BaseLib.h>
38 #include <Library/UefiLib.h>
39 #include <Library/BaseMemoryLib.h>
40 #include <Library/ReportStatusCodeLib.h>
41 #include <Library/MemoryAllocationLib.h>
42 #include <Library/PerformanceLib.h>
43 #include <Library/UefiBootServicesTableLib.h>
44 #include <Library/UefiRuntimeServicesTableLib.h>
45 #include <Library/DevicePathLib.h>
47 #include <IndustryStandard/pci22.h>
51 // Extra Definition to porting
53 #define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b))
55 #define MAX_IDE_DEVICE 4
56 #define MAX_IDE_CHANNELS 2
57 #define MAX_IDE_DRIVES 2
59 #define INVALID_DEVICE_TYPE 0xff
60 #define ATA_DEVICE_TYPE 0x00
61 #define ATAPI_DEVICE_TYPE 0x01
64 BOOLEAN HaveScannedDevice
[MAX_IDE_DEVICE
];
65 BOOLEAN DeviceFound
[MAX_IDE_DEVICE
];
66 BOOLEAN DeviceProcessed
[MAX_IDE_DEVICE
];
67 } IDE_BUS_DRIVER_PRIVATE_DATA
;
69 #define IDE_BLK_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('i', 'b', 'i', 'd')
75 EFI_BLOCK_IO_PROTOCOL BlkIo
;
76 EFI_BLOCK_IO_MEDIA BlkMedia
;
77 EFI_DISK_INFO_PROTOCOL DiskInfo
;
78 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
79 EFI_PCI_IO_PROTOCOL
*PciIo
;
80 IDE_BUS_DRIVER_PRIVATE_DATA
*IdeBusDriverPrivateData
;
83 // Local Data for IDE interface goes here
85 EFI_IDE_CHANNEL Channel
;
86 EFI_IDE_DEVICE Device
;
90 IDE_BASE_REGISTERS
*IoPort
;
93 INQUIRY_DATA
*pInquiryData
;
94 EFI_IDENTIFY_DATA
*pIdData
;
96 EFI_ATA_MODE UdmaMode
;
98 REQUEST_SENSE_DATA
*SenseData
;
99 UINT8 SenseDataNumber
;
103 // ExitBootService Event, it is used to clear pending IDE interrupt
105 EFI_EVENT ExitBootServiceEvent
;
107 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
110 #include "ComponentName.h"
112 #define IDE_BLOCK_IO_DEV_FROM_THIS(a) CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)
113 #define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)
118 extern EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding
;
124 // Driver model protocol interface
127 TODO: Add function description
129 @param ImageHandle TODO: add argument description
130 @param SystemTable TODO: add argument description
132 TODO: add return values
137 IDEBusControllerDriverEntryPoint (
138 IN EFI_HANDLE ImageHandle
,
139 IN EFI_SYSTEM_TABLE
*SystemTable
144 TODO: Add function description
146 @param This TODO: add argument description
147 @param Controller TODO: add argument description
148 @param RemainingDevicePath TODO: add argument description
150 TODO: add return values
155 IDEBusDriverBindingSupported (
156 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
157 IN EFI_HANDLE Controller
,
158 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
163 TODO: Add function description
165 @param This TODO: add argument description
166 @param Controller TODO: add argument description
167 @param RemainingDevicePath TODO: add argument description
169 TODO: add return values
174 IDEBusDriverBindingStart (
175 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
176 IN EFI_HANDLE Controller
,
177 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
182 TODO: Add function description
184 @param This TODO: add argument description
185 @param Controller TODO: add argument description
186 @param NumberOfChildren TODO: add argument description
187 @param ChildHandleBuffer TODO: add argument description
189 TODO: add return values
194 IDEBusDriverBindingStop (
195 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
196 IN EFI_HANDLE Controller
,
197 IN UINTN NumberOfChildren
,
198 IN EFI_HANDLE
*ChildHandleBuffer
203 // EFI Driver Configuration Functions
206 IDEBusDriverConfigurationSetOptions (
207 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
208 IN EFI_HANDLE ControllerHandle
,
209 IN EFI_HANDLE ChildHandle OPTIONAL
,
211 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
215 IDEBusDriverConfigurationOptionsValid (
216 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
217 IN EFI_HANDLE ControllerHandle
,
218 IN EFI_HANDLE ChildHandle OPTIONAL
222 IDEBusDriverConfigurationForceDefaults (
223 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
224 IN EFI_HANDLE ControllerHandle
,
225 IN EFI_HANDLE ChildHandle OPTIONAL
,
226 IN UINT32 DefaultType
,
227 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
231 // EFI Driver Diagnostics Functions
234 IDEBusDriverDiagnosticsRunDiagnostics (
235 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*This
,
236 IN EFI_HANDLE ControllerHandle
,
237 IN EFI_HANDLE ChildHandle OPTIONAL
,
238 IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType
,
240 OUT EFI_GUID
**ErrorType
,
241 OUT UINTN
*BufferSize
,
246 // Block I/O Protocol Interface
249 TODO: Add function description
251 @param This TODO: add argument description
252 @param ExtendedVerification TODO: add argument description
254 TODO: add return values
260 IN EFI_BLOCK_IO_PROTOCOL
*This
,
261 IN BOOLEAN ExtendedVerification
266 TODO: Add function description
268 @param This TODO: add argument description
269 @param MediaId TODO: add argument description
270 @param LBA TODO: add argument description
271 @param BufferSize TODO: add argument description
272 @param Buffer TODO: add argument description
274 TODO: add return values
280 IN EFI_BLOCK_IO_PROTOCOL
*This
,
289 TODO: Add function description
291 @param This TODO: add argument description
292 @param MediaId TODO: add argument description
293 @param LBA TODO: add argument description
294 @param BufferSize TODO: add argument description
295 @param Buffer TODO: add argument description
297 TODO: add return values
302 IDEBlkIoWriteBlocks (
303 IN EFI_BLOCK_IO_PROTOCOL
*This
,
312 TODO: Add function description
314 @param This TODO: add argument description
316 TODO: add return values
321 IDEBlkIoFlushBlocks (
322 IN EFI_BLOCK_IO_PROTOCOL
*This
327 TODO: Add function description
329 @param PciIo TODO: add argument description
330 @param Enable TODO: add argument description
332 TODO: add return values
336 IDERegisterDecodeEnableorDisable (
337 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
343 TODO: Add function description
345 @param This TODO: add argument description
346 @param InquiryData TODO: add argument description
347 @param IntquiryDataSize TODO: add argument description
349 TODO: add return values
355 IN EFI_DISK_INFO_PROTOCOL
*This
,
356 IN OUT VOID
*InquiryData
,
357 IN OUT UINT32
*IntquiryDataSize
362 TODO: Add function description
364 @param This TODO: add argument description
365 @param IdentifyData TODO: add argument description
366 @param IdentifyDataSize TODO: add argument description
368 TODO: add return values
373 IDEDiskInfoIdentify (
374 IN EFI_DISK_INFO_PROTOCOL
*This
,
375 IN OUT VOID
*IdentifyData
,
376 IN OUT UINT32
*IdentifyDataSize
381 TODO: Add function description
383 @param This TODO: add argument description
384 @param SenseData TODO: add argument description
385 @param SenseDataSize TODO: add argument description
386 @param SenseDataNumber TODO: add argument description
388 TODO: add return values
393 IDEDiskInfoSenseData (
394 IN EFI_DISK_INFO_PROTOCOL
*This
,
395 IN OUT VOID
*SenseData
,
396 IN OUT UINT32
*SenseDataSize
,
397 OUT UINT8
*SenseDataNumber
402 TODO: Add function description
404 @param This TODO: add argument description
405 @param IdeChannel TODO: add argument description
406 @param IdeDevice TODO: add argument description
408 TODO: add return values
413 IDEDiskInfoWhichIde (
414 IN EFI_DISK_INFO_PROTOCOL
*This
,
415 OUT UINT32
*IdeChannel
,
416 OUT UINT32
*IdeDevice