]> git.proxmox.com Git - mirror_edk2.git/blame - PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeController.h
According to PI errata 0000690, word "Ide Bus driver" has been replaced with "Driver...
[mirror_edk2.git] / PcAtChipsetPkg / Bus / Pci / IdeControllerDxe / IdeController.h
CommitLineData
a1f11f75 1/** @file\r
2 Header file for IDE controller driver.\r
3\r
69cb32fc 4 Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
3ea80ba2 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
a1f11f75 9\r
3ea80ba2 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
a1f11f75 12\r
13**/\r
14\r
24115e44
ED
15#ifndef _IDE_CONTROLLER_H_\r
16#define _IDE_CONTROLLER_H_\r
a1f11f75 17\r
18#include <Uefi.h>\r
19#include <Protocol/ComponentName.h>\r
20#include <Protocol/DriverBinding.h>\r
21#include <Protocol/PciIo.h>\r
22#include <Protocol/IdeControllerInit.h>\r
23#include <Library/UefiDriverEntryPoint.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/UefiLib.h>\r
26#include <Library/BaseLib.h>\r
27#include <Library/BaseMemoryLib.h>\r
28#include <Library/MemoryAllocationLib.h>\r
29#include <Library/UefiBootServicesTableLib.h>\r
30#include <IndustryStandard/Pci.h>\r
31\r
32//\r
33// Global Variables definitions\r
34//\r
35extern EFI_DRIVER_BINDING_PROTOCOL gIdeControllerDriverBinding;\r
36extern EFI_COMPONENT_NAME_PROTOCOL gIdeControllerComponentName;\r
37extern EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerComponentName2;\r
38\r
3ea80ba2 39///\r
40/// Supports 2 channel max\r
41///\r
a1f11f75 42#define ICH_IDE_MAX_CHANNEL 0x02\r
3ea80ba2 43\r
44///\r
45/// Supports 2 devices max\r
46///\r
a1f11f75 47#define ICH_IDE_MAX_DEVICES 0x02\r
48#define ICH_IDE_ENUMER_ALL FALSE\r
49\r
50//\r
51// Driver binding functions declaration\r
52//\r
20c1e33f 53/**\r
54 Register Driver Binding protocol for this driver.\r
55\r
56 @param This A pointer points to the Binding Protocol instance\r
3ea80ba2 57 @param Controller The handle of controller to be tested.\r
20c1e33f 58 @param RemainingDevicePath A pointer to the device path. Ignored by device\r
59 driver but used by bus driver\r
3ea80ba2 60\r
61 @retval EFI_SUCCESS Driver loaded.\r
62 @retval !EFI_SUCESS Driver not loaded.\r
20c1e33f 63**/\r
a1f11f75 64EFI_STATUS\r
65EFIAPI\r
66IdeControllerSupported (\r
67 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
68 IN EFI_HANDLE Controller,\r
69 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
70 )\r
a1f11f75 71;\r
72\r
20c1e33f 73/**\r
3ea80ba2 74 This routine is called right after the .Supported() called and return\r
20c1e33f 75 EFI_SUCCESS. Notes: The supported protocols are checked but the Protocols\r
3ea80ba2 76 are closed.\r
20c1e33f 77\r
78 @param This A pointer points to the Binding Protocol instance\r
79 @param Controller The handle of controller to be tested. Parameter\r
80 passed by the caller\r
81 @param RemainingDevicePath A pointer to the device path. Should be ignored by\r
82 device driver\r
3ea80ba2 83\r
20c1e33f 84 @return EFI_STATUS Status of InstallMultipleProtocolInterfaces()\r
85**/\r
a1f11f75 86EFI_STATUS\r
87EFIAPI\r
88IdeControllerStart (\r
89 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
90 IN EFI_HANDLE Controller,\r
91 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
92 )\r
a1f11f75 93;\r
94\r
20c1e33f 95/**\r
3ea80ba2 96 Stop this driver on Controller Handle.\r
20c1e33f 97\r
98 @param This Protocol instance pointer.\r
3ea80ba2 99 @param Controller Handle of device to stop driver on\r
20c1e33f 100 @param NumberOfChildren Not used\r
101 @param ChildHandleBuffer Not used\r
3ea80ba2 102\r
103 @retval EFI_SUCESS This driver is removed DeviceHandle\r
104 @retval !EFI_SUCCESS This driver was not removed from this device\r
20c1e33f 105**/\r
a1f11f75 106EFI_STATUS\r
107EFIAPI\r
108IdeControllerStop (\r
109 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
110 IN EFI_HANDLE Controller,\r
111 IN UINTN NumberOfChildren,\r
112 IN EFI_HANDLE *ChildHandleBuffer\r
113 )\r
a1f11f75 114;\r
115\r
116//\r
117// IDE controller init functions declaration\r
118//\r
20c1e33f 119/**\r
95717b94 120 Returns the information about the specified IDE channel.\r
121 \r
122 This function can be used to obtain information about a particular IDE channel.\r
123 The driver entity uses this information during the enumeration process. \r
124 \r
125 If Enabled is set to FALSE, the driver entity will not scan the channel. Note \r
126 that it will not prevent an operating system driver from scanning the channel.\r
127 \r
128 For most of today's controllers, MaxDevices will either be 1 or 2. For SATA \r
129 controllers, this value will always be 1. SATA configurations can contain SATA \r
130 port multipliers. SATA port multipliers behave like SATA bridges and can support\r
131 up to 16 devices on the other side. If a SATA port out of the IDE controller \r
132 is connected to a port multiplier, MaxDevices will be set to the number of SATA \r
133 devices that the port multiplier supports. Because today's port multipliers \r
134 support up to fifteen SATA devices, this number can be as large as fifteen. The IDE \r
135 bus driver is required to scan for the presence of port multipliers behind an SATA \r
136 controller and enumerate up to MaxDevices number of devices behind the port \r
137 multiplier. \r
138 \r
139 In this context, the devices behind a port multiplier constitute a channel. \r
140 \r
141 @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
142 @param[in] Channel Zero-based channel number.\r
143 @param[out] Enabled TRUE if this channel is enabled. Disabled channels \r
144 are not scanned to see if any devices are present.\r
145 @param[out] MaxDevices The maximum number of IDE devices that the bus driver\r
146 can expect on this channel. For the ATA/ATAPI \r
147 specification, version 6, this number will either be \r
148 one or two. For Serial ATA (SATA) configurations with a \r
149 port multiplier, this number can be as large as fifteen.\r
150\r
151 @retval EFI_SUCCESS Information was returned without any errors.\r
152 @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r
153\r
20c1e33f 154**/\r
a1f11f75 155EFI_STATUS\r
156EFIAPI\r
157IdeInitGetChannelInfo (\r
158 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
159 IN UINT8 Channel,\r
160 OUT BOOLEAN *Enabled,\r
161 OUT UINT8 *MaxDevices\r
162 )\r
a1f11f75 163;\r
164\r
20c1e33f 165/**\r
95717b94 166 The notifications from the driver entity that it is about to enter a certain\r
167 phase of the IDE channel enumeration process.\r
168 \r
169 This function can be used to notify the IDE controller driver to perform \r
170 specific actions, including any chipset-specific initialization, so that the \r
171 chipset is ready to enter the next phase. Seven notification points are defined \r
172 at this time. \r
173 \r
174 More synchronization points may be added as required in the future. \r
175\r
176 @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
177 @param[in] Phase The phase during enumeration.\r
178 @param[in] Channel Zero-based channel number.\r
179\r
180 @retval EFI_SUCCESS The notification was accepted without any errors.\r
181 @retval EFI_UNSUPPORTED Phase is not supported.\r
182 @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r
183 @retval EFI_NOT_READY This phase cannot be entered at this time; for \r
184 example, an attempt was made to enter a Phase \r
185 without having entered one or more previous \r
186 Phase.\r
3ea80ba2 187\r
20c1e33f 188**/\r
a1f11f75 189EFI_STATUS\r
190EFIAPI\r
191IdeInitNotifyPhase (\r
192 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
193 IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,\r
24115e44 194 IN UINT8 Channel\r
a1f11f75 195 )\r
a1f11f75 196;\r
197\r
20c1e33f 198/**\r
95717b94 199 Submits the device information to the IDE controller driver.\r
200\r
201 This function is used by the driver entity to pass detailed information about \r
202 a particular device to the IDE controller driver. The driver entity obtains \r
203 this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData\r
204 is the pointer to the response data buffer. The IdentifyData buffer is owned \r
205 by the driver entity, and the IDE controller driver must make a local copy \r
206 of the entire buffer or parts of the buffer as needed. The original IdentifyData \r
207 buffer pointer may not be valid when\r
208 \r
209 - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or\r
210 - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point.\r
211 \r
212 The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to \r
213 compute the optimum mode for the device. These fields are not limited to the \r
214 timing information. For example, an implementation of the IDE controller driver \r
215 may examine the vendor and type/mode field to match known bad drives. \r
216 \r
217 The driver entity may submit drive information in any order, as long as it \r
218 submits information for all the devices belonging to the enumeration group \r
219 before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device\r
220 in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r
221 should be called with IdentifyData set to NULL. The IDE controller driver may \r
222 not have any other mechanism to know whether a device is present or not. Therefore, \r
223 setting IdentifyData to NULL does not constitute an error condition. \r
224 EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a \r
225 given (Channel, Device) pair. \r
226 \r
227 @param[in] This A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
228 @param[in] Channel Zero-based channel number.\r
229 @param[in] Device Zero-based device number on the Channel.\r
230 @param[in] IdentifyData The device's response to the ATA IDENTIFY_DEVICE command.\r
231\r
232 @retval EFI_SUCCESS The information was accepted without any errors.\r
233 @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r
234 @retval EFI_INVALID_PARAMETER Device is invalid.\r
20c1e33f 235\r
20c1e33f 236**/\r
a1f11f75 237EFI_STATUS\r
238EFIAPI\r
239IdeInitSubmitData (\r
240 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
241 IN UINT8 Channel,\r
242 IN UINT8 Device,\r
243 IN EFI_IDENTIFY_DATA *IdentifyData\r
244 )\r
a1f11f75 245;\r
246\r
20c1e33f 247/**\r
95717b94 248 Disqualifies specific modes for an IDE device.\r
249\r
250 This function allows the driver entity or other drivers (such as platform \r
251 drivers) to reject certain timing modes and request the IDE controller driver\r
252 to recalculate modes. This function allows the driver entity and the IDE \r
253 controller driver to negotiate the timings on a per-device basis. This function \r
254 is useful in the case of drives that lie about their capabilities. An example \r
255 is when the IDE device fails to accept the timing modes that are calculated \r
256 by the IDE controller driver based on the response to the Identify Drive command.\r
257\r
258 If the driver entity does not want to limit the ATA timing modes and leave that \r
259 decision to the IDE controller driver, it can either not call this function for \r
260 the given device or call this function and set the Valid flag to FALSE for all \r
261 modes that are listed in EFI_ATA_COLLECTIVE_MODE.\r
262 \r
263 The driver entity may disqualify modes for a device in any order and any number \r
264 of times.\r
265 \r
266 This function can be called multiple times to invalidate multiple modes of the \r
267 same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI \r
268 specification for more information on PIO modes. \r
269 \r
270 For Serial ATA (SATA) controllers, this member function can be used to disqualify\r
271 a higher transfer rate mode on a given channel. For example, a platform driver\r
272 may inform the IDE controller driver to not use second-generation (Gen2) speeds \r
273 for a certain SATA drive.\r
274 \r
275 @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
276 @param[in] Channel The zero-based channel number.\r
277 @param[in] Device The zero-based device number on the Channel.\r
278 @param[in] BadModes The modes that the device does not support and that\r
279 should be disqualified.\r
280\r
281 @retval EFI_SUCCESS The modes were accepted without any errors.\r
282 @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r
283 @retval EFI_INVALID_PARAMETER Device is invalid.\r
284 @retval EFI_INVALID_PARAMETER IdentifyData is NULL.\r
285 \r
20c1e33f 286**/\r
a1f11f75 287EFI_STATUS\r
288EFIAPI\r
289IdeInitDisqualifyMode (\r
290 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
291 IN UINT8 Channel,\r
292 IN UINT8 Device,\r
293 IN EFI_ATA_COLLECTIVE_MODE *BadModes\r
294 )\r
a1f11f75 295;\r
296\r
20c1e33f 297/**\r
95717b94 298 Returns the information about the optimum modes for the specified IDE device.\r
299\r
300 This function is used by the driver entity to obtain the optimum ATA modes for\r
301 a specific device. The IDE controller driver takes into account the following \r
302 while calculating the mode:\r
303 - The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r
304 - The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode()\r
305\r
306 The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() \r
307 for all the devices that belong to an enumeration group before calling \r
308 EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group. \r
309 \r
310 The IDE controller driver will use controller- and possibly platform-specific \r
311 algorithms to arrive at SupportedModes. The IDE controller may base its \r
312 decision on user preferences and other considerations as well. This function \r
313 may be called multiple times because the driver entity may renegotiate the mode \r
314 with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode().\r
315 \r
316 The driver entity may collect timing information for various devices in any \r
317 order. The driver entity is responsible for making sure that all the dependencies\r
318 are satisfied. For example, the SupportedModes information for device A that \r
319 was previously returned may become stale after a call to \r
320 EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B.\r
321 \r
322 The buffer SupportedModes is allocated by the callee because the caller does \r
323 not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE \r
324 is defined in a way that allows for future extensibility and can be of variable \r
325 length. This memory pool should be deallocated by the caller when it is no \r
326 longer necessary. \r
327 \r
328 The IDE controller driver for a Serial ATA (SATA) controller can use this \r
329 member function to force a lower speed (first-generation [Gen1] speeds on a \r
330 second-generation [Gen2]-capable hardware). The IDE controller driver can \r
331 also allow the driver entity to stay with the speed that has been negotiated \r
332 by the physical layer.\r
333 \r
334 @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
335 @param[in] Channel A zero-based channel number.\r
336 @param[in] Device A zero-based device number on the Channel.\r
337 @param[out] SupportedModes The optimum modes for the device.\r
338\r
339 @retval EFI_SUCCESS SupportedModes was returned.\r
340 @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r
341 @retval EFI_INVALID_PARAMETER Device is invalid. \r
342 @retval EFI_INVALID_PARAMETER SupportedModes is NULL.\r
343 @retval EFI_NOT_READY Modes cannot be calculated due to a lack of \r
344 data. This error may happen if \r
345 EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() \r
346 and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData() \r
347 were not called for at least one drive in the \r
348 same enumeration group.\r
3ea80ba2 349\r
20c1e33f 350**/\r
a1f11f75 351EFI_STATUS\r
352EFIAPI\r
353IdeInitCalculateMode (\r
354 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
355 IN UINT8 Channel,\r
356 IN UINT8 Device,\r
24115e44 357 OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes\r
a1f11f75 358 )\r
a1f11f75 359;\r
360\r
20c1e33f 361/**\r
95717b94 362 Commands the IDE controller driver to program the IDE controller hardware\r
363 so that the specified device can operate at the specified mode.\r
364\r
365 This function is used by the driver entity to instruct the IDE controller \r
366 driver to program the IDE controller hardware to the specified modes. This \r
367 function can be called only once for a particular device. For a Serial ATA \r
368 (SATA) Advanced Host Controller Interface (AHCI) controller, no controller-\r
369 specific programming may be required.\r
370\r
371 @param[in] This Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r
372 @param[in] Channel Zero-based channel number.\r
373 @param[in] Device Zero-based device number on the Channel.\r
374 @param[in] Modes The modes to set.\r
375\r
376 @retval EFI_SUCCESS The command was accepted without any errors.\r
377 @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r
378 @retval EFI_INVALID_PARAMETER Device is invalid.\r
379 @retval EFI_NOT_READY Modes cannot be set at this time due to lack of data.\r
380 @retval EFI_DEVICE_ERROR Modes cannot be set due to hardware failure.\r
381 The driver entity should not use this device.\r
3ea80ba2 382\r
20c1e33f 383**/\r
a1f11f75 384EFI_STATUS\r
385EFIAPI\r
386IdeInitSetTiming (\r
387 IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r
388 IN UINT8 Channel,\r
389 IN UINT8 Device,\r
390 IN EFI_ATA_COLLECTIVE_MODE *Modes\r
391 )\r
a1f11f75 392;\r
393\r
394//\r
395// Forward reference declaration\r
396//\r
20c1e33f 397/**\r
398 Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
399\r
400 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
401 @param Language A pointer to a three character ISO 639-2 language identifier.\r
402 This is the language of the driver name that that the caller\r
403 is requesting, and it must match one of the languages specified\r
404 in SupportedLanguages. The number of languages supported by a\r
405 driver is up to the driver writer.\r
406 @param DriverName A pointer to the Unicode string to return. This Unicode string\r
407 is the name of the driver specified by This in the language\r
408 specified by Language.\r
3ea80ba2 409\r
20c1e33f 410 @retval EFI_SUCCESS The Unicode string for the Driver specified by This\r
411 and the language specified by Language was returned\r
412 in DriverName.\r
413 @retval EFI_INVALID_PARAMETER Language is NULL.\r
414 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
415 @retval EFI_UNSUPPORTED The driver specified by This does not support the\r
416 language specified by Language.\r
417**/\r
a1f11f75 418EFI_STATUS\r
419EFIAPI\r
420IdeControllerComponentNameGetDriverName (\r
421 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
422 IN CHAR8 *Language,\r
423 OUT CHAR16 **DriverName\r
424 )\r
a1f11f75 425;\r
426\r
20c1e33f 427/**\r
428 Retrieves a Unicode string that is the user readable name of the controller\r
3ea80ba2 429 that is being managed by an EFI Driver.\r
20c1e33f 430\r
431 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
432 @param ControllerHandle The handle of a controller that the driver specified by\r
433 This is managing. This handle specifies the controller\r
434 whose name is to be returned.\r
24115e44 435 @param OPTIONAL ChildHandle The handle of the child controller to retrieve the name\r
20c1e33f 436 of. This is an optional parameter that may be NULL. It\r
437 will be NULL for device drivers. It will also be NULL\r
438 for a bus drivers that wish to retrieve the name of the\r
439 bus controller. It will not be NULL for a bus driver\r
440 that wishes to retrieve the name of a child controller.\r
441 @param Language A pointer to a three character ISO 639-2 language\r
442 identifier. This is the language of the controller name\r
443 that that the caller is requesting, and it must match one\r
444 of the languages specified in SupportedLanguages. The\r
445 number of languages supported by a driver is up to the\r
446 driver writer.\r
447 @param ControllerName A pointer to the Unicode string to return. This Unicode\r
448 string is the name of the controller specified by\r
449 ControllerHandle and ChildHandle in the language\r
450 specified by Language from the point of view of the\r
451 driver specified by This.\r
3ea80ba2 452\r
20c1e33f 453 @retval EFI_SUCCESS The Unicode string for the user readable name in the\r
454 language specified by Language for the driver\r
455 specified by This was returned in DriverName.\r
69cb32fc 456 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
20c1e33f 457 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
458 EFI_HANDLE.\r
459 @retval EFI_INVALID_PARAMETER Language is NULL.\r
460 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
461 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
462 managing the controller specified by\r
463 ControllerHandle and ChildHandle.\r
464 @retval EFI_UNSUPPORTED The driver specified by This does not support the\r
465 language specified by Language.\r
466**/\r
a1f11f75 467EFI_STATUS\r
468EFIAPI\r
469IdeControllerComponentNameGetControllerName (\r
470 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
471 IN EFI_HANDLE ControllerHandle,\r
472 IN EFI_HANDLE ChildHandle OPTIONAL,\r
473 IN CHAR8 *Language,\r
474 OUT CHAR16 **ControllerName\r
475 )\r
a1f11f75 476;\r
477\r
478#endif\r