2 Header file for IDE controller driver.
4 Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>
5 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.
15 #ifndef _IDE_CONTROLLER_H_
16 #define _IDE_CONTROLLER_H_
19 #include <Protocol/ComponentName.h>
20 #include <Protocol/DriverBinding.h>
21 #include <Protocol/PciIo.h>
22 #include <Protocol/IdeControllerInit.h>
23 #include <Library/UefiDriverEntryPoint.h>
24 #include <Library/DebugLib.h>
25 #include <Library/UefiLib.h>
26 #include <Library/BaseLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/MemoryAllocationLib.h>
29 #include <Library/UefiBootServicesTableLib.h>
30 #include <IndustryStandard/Pci.h>
33 // Global Variables definitions
35 extern EFI_DRIVER_BINDING_PROTOCOL gIdeControllerDriverBinding
;
36 extern EFI_COMPONENT_NAME_PROTOCOL gIdeControllerComponentName
;
37 extern EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerComponentName2
;
40 /// Supports 2 channel max
42 #define ICH_IDE_MAX_CHANNEL 0x02
45 /// Supports 2 devices max
47 #define ICH_IDE_MAX_DEVICES 0x02
48 #define ICH_IDE_ENUMER_ALL FALSE
51 // Driver binding functions declaration
54 Register Driver Binding protocol for this driver.
56 @param This A pointer points to the Binding Protocol instance
57 @param Controller The handle of controller to be tested.
58 @param RemainingDevicePath A pointer to the device path. Ignored by device
59 driver but used by bus driver
61 @retval EFI_SUCCESS Driver loaded.
62 @retval !EFI_SUCESS Driver not loaded.
66 IdeControllerSupported (
67 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
68 IN EFI_HANDLE Controller
,
69 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
74 This routine is called right after the .Supported() called and return
75 EFI_SUCCESS. Notes: The supported protocols are checked but the Protocols
78 @param This A pointer points to the Binding Protocol instance
79 @param Controller The handle of controller to be tested. Parameter
81 @param RemainingDevicePath A pointer to the device path. Should be ignored by
84 @return EFI_STATUS Status of InstallMultipleProtocolInterfaces()
89 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
90 IN EFI_HANDLE Controller
,
91 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
96 Stop this driver on Controller Handle.
98 @param This Protocol instance pointer.
99 @param Controller Handle of device to stop driver on
100 @param NumberOfChildren Not used
101 @param ChildHandleBuffer Not used
103 @retval EFI_SUCESS This driver is removed DeviceHandle
104 @retval !EFI_SUCCESS This driver was not removed from this device
109 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
110 IN EFI_HANDLE Controller
,
111 IN UINTN NumberOfChildren
,
112 IN EFI_HANDLE
*ChildHandleBuffer
117 // IDE controller init functions declaration
120 This function can be used to obtain information about a specified channel.
121 It's usually used by IDE Bus driver during enumeration process.
123 @param This the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
124 @param Channel Channel number (0 based, either 0 or 1)
125 @param Enabled TRUE if the channel is enabled. If the channel is disabled,
126 then it will no be enumerated.
127 @param MaxDevices The Max number of IDE devices that the bus driver can expect
128 on this channel. For ATA/ATAPI, this number is either 1 or 2.
130 @retval EFI_SUCCESS Success to get channel information
131 @retval EFI_INVALID_PARAMETER Invalid channel id.
135 IdeInitGetChannelInfo (
136 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL
*This
,
138 OUT BOOLEAN
*Enabled
,
139 OUT UINT8
*MaxDevices
144 This function is called by IdeBus driver before executing certain actions.
145 This allows IDE Controller Init to prepare for each action.
147 @param This the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
148 @param Phase phase indicator defined by IDE_CONTROLLER_INIT protocol
149 @param Channel Channel number (0 based, either 0 or 1)
151 @return EFI_SUCCESS Success operation.
156 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL
*This
,
157 IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase
,
163 This function is called by IdeBus driver to submit EFI_IDENTIFY_DATA data structure
164 obtained from IDE deivce. This structure is used to set IDE timing
166 @param This The EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
167 @param Channel IDE channel number (0 based, either 0 or 1)
168 @param Device IDE device number
169 @param IdentifyData A pointer to EFI_IDENTIFY_DATA data structure
171 @return EFI_SUCCESS Success operation.
176 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL
*This
,
179 IN EFI_IDENTIFY_DATA
*IdentifyData
184 This function is called by IdeBus driver to disqualify unsupported operation
185 mode on specfic IDE device
187 @param This the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
188 @param Channel IDE channel number (0 based, either 0 or 1)
189 @param Device IDE device number
190 @param BadModes Operation mode indicator
192 @return EFI_SUCCESS Success operation.
196 IdeInitDisqualifyMode (
197 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL
*This
,
200 IN EFI_ATA_COLLECTIVE_MODE
*BadModes
205 This function is called by IdeBus driver to calculate the best operation mode
206 supported by specific IDE device
208 @param This the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
209 @param Channel IDE channel number (0 based, either 0 or 1)
210 @param Device IDE device number
211 @param SupportedModes Modes collection supported by IDE device
213 @retval EFI_OUT_OF_RESOURCES Fail to allocate pool.
214 @retval EFI_INVALID_PARAMETER Invalid channel id and device id.
218 IdeInitCalculateMode (
219 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL
*This
,
222 OUT EFI_ATA_COLLECTIVE_MODE
**SupportedModes
227 This function is called by IdeBus driver to set appropriate timing on IDE
228 controller according supported operation mode.
230 @param This the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.
231 @param Channel IDE channel number (0 based, either 0 or 1)
232 @param Device IDE device number
233 @param Modes IDE device modes
235 @retval EFI_SUCCESS Sucess operation.
240 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL
*This
,
243 IN EFI_ATA_COLLECTIVE_MODE
*Modes
248 // Forward reference declaration
251 Retrieves a Unicode string that is the user readable name of the EFI Driver.
253 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
254 @param Language A pointer to a three character ISO 639-2 language identifier.
255 This is the language of the driver name that that the caller
256 is requesting, and it must match one of the languages specified
257 in SupportedLanguages. The number of languages supported by a
258 driver is up to the driver writer.
259 @param DriverName A pointer to the Unicode string to return. This Unicode string
260 is the name of the driver specified by This in the language
261 specified by Language.
263 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
264 and the language specified by Language was returned
266 @retval EFI_INVALID_PARAMETER Language is NULL.
267 @retval EFI_INVALID_PARAMETER DriverName is NULL.
268 @retval EFI_UNSUPPORTED The driver specified by This does not support the
269 language specified by Language.
273 IdeControllerComponentNameGetDriverName (
274 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
276 OUT CHAR16
**DriverName
281 Retrieves a Unicode string that is the user readable name of the controller
282 that is being managed by an EFI Driver.
284 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
285 @param ControllerHandle The handle of a controller that the driver specified by
286 This is managing. This handle specifies the controller
287 whose name is to be returned.
288 @param OPTIONAL ChildHandle The handle of the child controller to retrieve the name
289 of. This is an optional parameter that may be NULL. It
290 will be NULL for device drivers. It will also be NULL
291 for a bus drivers that wish to retrieve the name of the
292 bus controller. It will not be NULL for a bus driver
293 that wishes to retrieve the name of a child controller.
294 @param Language A pointer to a three character ISO 639-2 language
295 identifier. This is the language of the controller name
296 that that the caller is requesting, and it must match one
297 of the languages specified in SupportedLanguages. The
298 number of languages supported by a driver is up to the
300 @param ControllerName A pointer to the Unicode string to return. This Unicode
301 string is the name of the controller specified by
302 ControllerHandle and ChildHandle in the language
303 specified by Language from the point of view of the
304 driver specified by This.
306 @retval EFI_SUCCESS The Unicode string for the user readable name in the
307 language specified by Language for the driver
308 specified by This was returned in DriverName.
309 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
310 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
312 @retval EFI_INVALID_PARAMETER Language is NULL.
313 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
314 @retval EFI_UNSUPPORTED The driver specified by This is not currently
315 managing the controller specified by
316 ControllerHandle and ChildHandle.
317 @retval EFI_UNSUPPORTED The driver specified by This does not support the
318 language specified by Language.
322 IdeControllerComponentNameGetControllerName (
323 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
324 IN EFI_HANDLE ControllerHandle
,
325 IN EFI_HANDLE ChildHandle OPTIONAL
,
327 OUT CHAR16
**ControllerName