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
22 #include <FrameworkDxe.h>
24 // The protocols, PPI and GUID defintions for this module
26 #include <Protocol/IdeControllerInit.h>
27 #include <Protocol/BlockIo.h>
28 #include <Protocol/PciIo.h>
29 #include <Protocol/DiskInfo.h>
30 #include <Protocol/DevicePath.h>
32 // The Library classes this module consumes
34 #include <Library/DebugLib.h>
35 #include <Library/UefiDriverEntryPoint.h>
36 #include <Library/BaseLib.h>
37 #include <Library/UefiLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/ReportStatusCodeLib.h>
40 #include <Library/MemoryAllocationLib.h>
41 #include <Library/PerformanceLib.h>
42 #include <Library/UefiBootServicesTableLib.h>
43 #include <Library/UefiRuntimeServicesTableLib.h>
44 #include <Library/DevicePathLib.h>
46 #include <IndustryStandard/pci22.h>
50 // Extra Definition to porting
52 #define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b))
54 #define MAX_IDE_DEVICE 4
55 #define MAX_IDE_CHANNELS 2
56 #define MAX_IDE_DRIVES 2
58 #define INVALID_DEVICE_TYPE 0xff
59 #define ATA_DEVICE_TYPE 0x00
60 #define ATAPI_DEVICE_TYPE 0x01
63 BOOLEAN HaveScannedDevice
[MAX_IDE_DEVICE
];
64 BOOLEAN DeviceFound
[MAX_IDE_DEVICE
];
65 BOOLEAN DeviceProcessed
[MAX_IDE_DEVICE
];
66 } IDE_BUS_DRIVER_PRIVATE_DATA
;
68 #define IDE_BLK_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('i', 'b', 'i', 'd')
74 EFI_BLOCK_IO_PROTOCOL BlkIo
;
75 EFI_BLOCK_IO_MEDIA BlkMedia
;
76 EFI_DISK_INFO_PROTOCOL DiskInfo
;
77 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
78 EFI_PCI_IO_PROTOCOL
*PciIo
;
79 IDE_BUS_DRIVER_PRIVATE_DATA
*IdeBusDriverPrivateData
;
82 // Local Data for IDE interface goes here
84 EFI_IDE_CHANNEL Channel
;
85 EFI_IDE_DEVICE Device
;
89 IDE_BASE_REGISTERS
*IoPort
;
92 INQUIRY_DATA
*pInquiryData
;
93 EFI_IDENTIFY_DATA
*pIdData
;
95 EFI_ATA_MODE UdmaMode
;
97 REQUEST_SENSE_DATA
*SenseData
;
98 UINT8 SenseDataNumber
;
102 // ExitBootService Event, it is used to clear pending IDE interrupt
104 EFI_EVENT ExitBootServiceEvent
;
106 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
109 #include "ComponentName.h"
111 #define IDE_BLOCK_IO_DEV_FROM_THIS(a) CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)
112 #define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)
117 extern EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding
;
123 // Driver model protocol interface
126 TODO: Add function description
128 @param ImageHandle TODO: add argument description
129 @param SystemTable TODO: add argument description
131 TODO: add return values
136 IDEBusControllerDriverEntryPoint (
137 IN EFI_HANDLE ImageHandle
,
138 IN EFI_SYSTEM_TABLE
*SystemTable
143 TODO: Add function description
145 @param This TODO: add argument description
146 @param Controller TODO: add argument description
147 @param RemainingDevicePath TODO: add argument description
149 TODO: add return values
154 IDEBusDriverBindingSupported (
155 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
156 IN EFI_HANDLE Controller
,
157 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
162 TODO: Add function description
164 @param This TODO: add argument description
165 @param Controller TODO: add argument description
166 @param RemainingDevicePath TODO: add argument description
168 TODO: add return values
173 IDEBusDriverBindingStart (
174 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
175 IN EFI_HANDLE Controller
,
176 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
181 TODO: Add function description
183 @param This TODO: add argument description
184 @param Controller TODO: add argument description
185 @param NumberOfChildren TODO: add argument description
186 @param ChildHandleBuffer TODO: add argument description
188 TODO: add return values
193 IDEBusDriverBindingStop (
194 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
195 IN EFI_HANDLE Controller
,
196 IN UINTN NumberOfChildren
,
197 IN EFI_HANDLE
*ChildHandleBuffer
202 // EFI Driver Configuration Functions
205 IDEBusDriverConfigurationSetOptions (
206 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
207 IN EFI_HANDLE ControllerHandle
,
208 IN EFI_HANDLE ChildHandle OPTIONAL
,
210 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
214 IDEBusDriverConfigurationOptionsValid (
215 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
216 IN EFI_HANDLE ControllerHandle
,
217 IN EFI_HANDLE ChildHandle OPTIONAL
221 IDEBusDriverConfigurationForceDefaults (
222 IN EFI_DRIVER_CONFIGURATION_PROTOCOL
*This
,
223 IN EFI_HANDLE ControllerHandle
,
224 IN EFI_HANDLE ChildHandle OPTIONAL
,
225 IN UINT32 DefaultType
,
226 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
*ActionRequired
230 // EFI Driver Diagnostics Functions
233 IDEBusDriverDiagnosticsRunDiagnostics (
234 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL
*This
,
235 IN EFI_HANDLE ControllerHandle
,
236 IN EFI_HANDLE ChildHandle OPTIONAL
,
237 IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType
,
239 OUT EFI_GUID
**ErrorType
,
240 OUT UINTN
*BufferSize
,
245 // Block I/O Protocol Interface
248 TODO: Add function description
250 @param This TODO: add argument description
251 @param ExtendedVerification TODO: add argument description
253 TODO: add return values
259 IN EFI_BLOCK_IO_PROTOCOL
*This
,
260 IN BOOLEAN ExtendedVerification
265 TODO: Add function description
267 @param This TODO: add argument description
268 @param MediaId TODO: add argument description
269 @param LBA TODO: add argument description
270 @param BufferSize TODO: add argument description
271 @param Buffer TODO: add argument description
273 TODO: add return values
279 IN EFI_BLOCK_IO_PROTOCOL
*This
,
288 TODO: Add function description
290 @param This TODO: add argument description
291 @param MediaId TODO: add argument description
292 @param LBA TODO: add argument description
293 @param BufferSize TODO: add argument description
294 @param Buffer TODO: add argument description
296 TODO: add return values
301 IDEBlkIoWriteBlocks (
302 IN EFI_BLOCK_IO_PROTOCOL
*This
,
311 TODO: Add function description
313 @param This TODO: add argument description
315 TODO: add return values
320 IDEBlkIoFlushBlocks (
321 IN EFI_BLOCK_IO_PROTOCOL
*This
326 TODO: Add function description
328 @param PciIo TODO: add argument description
329 @param Enable TODO: add argument description
331 TODO: add return values
335 IDERegisterDecodeEnableorDisable (
336 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
342 TODO: Add function description
344 @param This TODO: add argument description
345 @param InquiryData TODO: add argument description
346 @param IntquiryDataSize TODO: add argument description
348 TODO: add return values
354 IN EFI_DISK_INFO_PROTOCOL
*This
,
355 IN OUT VOID
*InquiryData
,
356 IN OUT UINT32
*IntquiryDataSize
361 TODO: Add function description
363 @param This TODO: add argument description
364 @param IdentifyData TODO: add argument description
365 @param IdentifyDataSize TODO: add argument description
367 TODO: add return values
372 IDEDiskInfoIdentify (
373 IN EFI_DISK_INFO_PROTOCOL
*This
,
374 IN OUT VOID
*IdentifyData
,
375 IN OUT UINT32
*IdentifyDataSize
380 TODO: Add function description
382 @param This TODO: add argument description
383 @param SenseData TODO: add argument description
384 @param SenseDataSize TODO: add argument description
385 @param SenseDataNumber TODO: add argument description
387 TODO: add return values
392 IDEDiskInfoSenseData (
393 IN EFI_DISK_INFO_PROTOCOL
*This
,
394 IN OUT VOID
*SenseData
,
395 IN OUT UINT32
*SenseDataSize
,
396 OUT UINT8
*SenseDataNumber
401 TODO: Add function description
403 @param This TODO: add argument description
404 @param IdeChannel TODO: add argument description
405 @param IdeDevice TODO: add argument description
407 TODO: add return values
412 IDEDiskInfoWhichIde (
413 IN EFI_DISK_INFO_PROTOCOL
*This
,
414 OUT UINT32
*IdeChannel
,
415 OUT UINT32
*IdeDevice