]>
Commit | Line | Data |
---|---|---|
a1f11f75 | 1 | /** @file\r |
3ea80ba2 | 2 | This driver module produces IDE_CONTROLLER_INIT protocol and will be used by\r |
a1f11f75 | 3 | IDE Bus driver to support platform dependent timing information. This driver\r |
4 | is responsible for early initialization of IDE controller.\r | |
5 | \r | |
5a702acd | 6 | Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r |
3ea80ba2 | 7 | This program and the accompanying materials\r |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
a1f11f75 | 11 | \r |
3ea80ba2 | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
a1f11f75 | 14 | \r |
15 | **/\r | |
16 | \r | |
17 | #include "IdeController.h"\r | |
18 | \r | |
3ea80ba2 | 19 | ///\r |
20 | /// EFI_DRIVER_BINDING_PROTOCOL instance\r | |
21 | ///\r | |
a1f11f75 | 22 | EFI_DRIVER_BINDING_PROTOCOL gIdeControllerDriverBinding = {\r |
23 | IdeControllerSupported,\r | |
24 | IdeControllerStart,\r | |
25 | IdeControllerStop,\r | |
26 | 0xa,\r | |
27 | NULL,\r | |
28 | NULL\r | |
29 | };\r | |
30 | \r | |
20c1e33f | 31 | ///\r |
32 | /// EFI_IDE_CONTROLLER_PROVATE_DATA Template\r | |
33 | ///\r | |
a1f11f75 | 34 | EFI_IDE_CONTROLLER_INIT_PROTOCOL gEfiIdeControllerInit = {\r |
35 | IdeInitGetChannelInfo,\r | |
36 | IdeInitNotifyPhase,\r | |
37 | IdeInitSubmitData,\r | |
38 | IdeInitDisqualifyMode,\r | |
39 | IdeInitCalculateMode,\r | |
40 | IdeInitSetTiming,\r | |
41 | ICH_IDE_ENUMER_ALL,\r | |
42 | ICH_IDE_MAX_CHANNEL\r | |
43 | };\r | |
44 | \r | |
20c1e33f | 45 | ///\r |
46 | /// EFI_ATA_COLLECTIVE_MODE Template\r | |
47 | ///\r | |
a1f11f75 | 48 | EFI_ATA_COLLECTIVE_MODE gEfiAtaCollectiveModeTemplate = {\r |
3ea80ba2 | 49 | {\r |
50 | TRUE, ///< PioMode.Valid\r | |
51 | 0 ///< PioMode.Mode\r | |
a1f11f75 | 52 | },\r |
53 | {\r | |
3ea80ba2 | 54 | TRUE, ///< SingleWordDmaMode.Valid\r |
a1f11f75 | 55 | 0\r |
56 | },\r | |
57 | {\r | |
3ea80ba2 | 58 | FALSE, ///< MultiWordDmaMode.Valid\r |
a1f11f75 | 59 | 0\r |
60 | },\r | |
61 | {\r | |
3ea80ba2 | 62 | TRUE, ///< UdmaMode.Valid\r |
63 | 0 ///< UdmaMode.Mode\r | |
a1f11f75 | 64 | }\r |
65 | };\r | |
66 | \r | |
20c1e33f | 67 | /**\r |
3ea80ba2 | 68 | Chipset Ide Driver EntryPoint function. It follows the standard EFI driver model.\r |
20c1e33f | 69 | It's called by StartImage() of DXE Core.\r |
70 | \r | |
3ea80ba2 | 71 | @param ImageHandle While the driver image loaded be the ImageLoader(),\r |
72 | an image handle is assigned to this driver binary,\r | |
20c1e33f | 73 | all activities of the driver is tied to this ImageHandle\r |
74 | @param SystemTable A pointer to the system table, for all BS(Boo Services) and\r | |
75 | RT(Runtime Services)\r | |
3ea80ba2 | 76 | \r |
20c1e33f | 77 | @return EFI_STATUS Status of EfiLibInstallDriverBindingComponentName2().\r |
78 | **/\r | |
a1f11f75 | 79 | EFI_STATUS\r |
80 | EFIAPI\r | |
81 | InitializeIdeControllerDriver (\r | |
82 | IN EFI_HANDLE ImageHandle,\r | |
83 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
84 | )\r | |
a1f11f75 | 85 | {\r |
86 | EFI_STATUS Status;\r | |
87 | \r | |
88 | //\r | |
89 | // Install driver model protocol(s).\r | |
90 | //\r | |
91 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
92 | ImageHandle,\r | |
93 | SystemTable,\r | |
94 | &gIdeControllerDriverBinding,\r | |
95 | ImageHandle,\r | |
96 | &gIdeControllerComponentName,\r | |
97 | &gIdeControllerComponentName2\r | |
98 | );\r | |
99 | ASSERT_EFI_ERROR (Status);\r | |
100 | \r | |
101 | return Status;\r | |
102 | }\r | |
103 | \r | |
20c1e33f | 104 | /**\r |
105 | Register Driver Binding protocol for this driver.\r | |
106 | \r | |
107 | @param This A pointer points to the Binding Protocol instance\r | |
3ea80ba2 | 108 | @param Controller The handle of controller to be tested.\r |
20c1e33f | 109 | @param RemainingDevicePath A pointer to the device path. Ignored by device\r |
110 | driver but used by bus driver\r | |
3ea80ba2 | 111 | \r |
112 | @retval EFI_SUCCESS Driver loaded.\r | |
619ad10f | 113 | @retval !EFI_SUCCESS Driver not loaded.\r |
20c1e33f | 114 | **/\r |
a1f11f75 | 115 | EFI_STATUS\r |
116 | EFIAPI\r | |
117 | IdeControllerSupported (\r | |
118 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
119 | IN EFI_HANDLE Controller,\r | |
120 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
121 | )\r | |
a1f11f75 | 122 | {\r |
123 | EFI_STATUS Status;\r | |
124 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
125 | UINT8 PciClass;\r | |
126 | UINT8 PciSubClass;\r | |
127 | \r | |
128 | //\r | |
129 | // Attempt to Open PCI I/O Protocol\r | |
130 | //\r | |
131 | Status = gBS->OpenProtocol (\r | |
132 | Controller,\r | |
133 | &gEfiPciIoProtocolGuid,\r | |
134 | (VOID **) &PciIo,\r | |
135 | This->DriverBindingHandle,\r | |
136 | Controller,\r | |
137 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
138 | );\r | |
139 | if (EFI_ERROR (Status)) {\r | |
140 | return Status;\r | |
141 | }\r | |
142 | \r | |
143 | //\r | |
144 | // Now further check the PCI header: Base class (offset 0x0B) and\r | |
145 | // Sub Class (offset 0x0A). This controller should be an Ide controller\r | |
146 | //\r | |
147 | Status = PciIo->Pci.Read (\r | |
148 | PciIo,\r | |
149 | EfiPciIoWidthUint8,\r | |
150 | PCI_CLASSCODE_OFFSET + 2,\r | |
151 | 1,\r | |
152 | &PciClass\r | |
153 | );\r | |
154 | if (EFI_ERROR (Status)) {\r | |
155 | goto Done;\r | |
156 | }\r | |
157 | \r | |
158 | Status = PciIo->Pci.Read (\r | |
159 | PciIo,\r | |
160 | EfiPciIoWidthUint8,\r | |
161 | PCI_CLASSCODE_OFFSET + 1,\r | |
162 | 1,\r | |
163 | &PciSubClass\r | |
164 | );\r | |
165 | if (EFI_ERROR (Status)) {\r | |
166 | goto Done;\r | |
167 | }\r | |
168 | \r | |
169 | //\r | |
170 | // Examine Ide PCI Configuration table fields\r | |
171 | //\r | |
172 | if ((PciClass != PCI_CLASS_MASS_STORAGE) || (PciSubClass != PCI_CLASS_MASS_STORAGE_IDE)) {\r | |
173 | Status = EFI_UNSUPPORTED;\r | |
174 | }\r | |
175 | \r | |
176 | Done:\r | |
177 | gBS->CloseProtocol (\r | |
178 | Controller,\r | |
179 | &gEfiPciIoProtocolGuid,\r | |
180 | This->DriverBindingHandle,\r | |
181 | Controller\r | |
182 | );\r | |
183 | \r | |
184 | return Status;\r | |
185 | }\r | |
186 | \r | |
20c1e33f | 187 | /**\r |
3ea80ba2 | 188 | This routine is called right after the .Supported() called and return\r |
20c1e33f | 189 | EFI_SUCCESS. Notes: The supported protocols are checked but the Protocols\r |
3ea80ba2 | 190 | are closed.\r |
20c1e33f | 191 | \r |
192 | @param This A pointer points to the Binding Protocol instance\r | |
193 | @param Controller The handle of controller to be tested. Parameter\r | |
194 | passed by the caller\r | |
195 | @param RemainingDevicePath A pointer to the device path. Should be ignored by\r | |
196 | device driver\r | |
3ea80ba2 | 197 | \r |
20c1e33f | 198 | @return EFI_STATUS Status of InstallMultipleProtocolInterfaces()\r |
199 | **/\r | |
a1f11f75 | 200 | EFI_STATUS\r |
201 | EFIAPI\r | |
202 | IdeControllerStart (\r | |
203 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
204 | IN EFI_HANDLE Controller,\r | |
205 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
206 | )\r | |
a1f11f75 | 207 | {\r |
208 | EFI_STATUS Status;\r | |
209 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
210 | \r | |
211 | //\r | |
212 | // Now test and open the EfiPciIoProtocol\r | |
213 | //\r | |
214 | Status = gBS->OpenProtocol (\r | |
215 | Controller,\r | |
216 | &gEfiPciIoProtocolGuid,\r | |
217 | (VOID **) &PciIo,\r | |
218 | This->DriverBindingHandle,\r | |
219 | Controller,\r | |
220 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
221 | );\r | |
222 | //\r | |
223 | // Status == EFI_SUCCESS - A normal execution flow, SUCCESS and the program proceeds.\r | |
224 | // Status == ALREADY_STARTED - A non-zero Status code returned. It indicates\r | |
225 | // that the protocol has been opened and should be treated as a\r | |
226 | // normal condition and the program proceeds. The Protocol will not\r | |
227 | // opened 'again' by this call.\r | |
228 | // Status != ALREADY_STARTED - Error status, terminate program execution\r | |
229 | //\r | |
230 | if (EFI_ERROR (Status)) {\r | |
231 | return Status;\r | |
232 | }\r | |
233 | \r | |
234 | //\r | |
3ea80ba2 | 235 | // Install IDE_CONTROLLER_INIT protocol\r |
a1f11f75 | 236 | //\r |
237 | return gBS->InstallMultipleProtocolInterfaces (\r | |
238 | &Controller,\r | |
239 | &gEfiIdeControllerInitProtocolGuid, &gEfiIdeControllerInit,\r | |
240 | NULL\r | |
241 | );\r | |
242 | }\r | |
243 | \r | |
20c1e33f | 244 | /**\r |
3ea80ba2 | 245 | Stop this driver on Controller Handle.\r |
20c1e33f | 246 | \r |
247 | @param This Protocol instance pointer.\r | |
3ea80ba2 | 248 | @param Controller Handle of device to stop driver on\r |
20c1e33f | 249 | @param NumberOfChildren Not used\r |
250 | @param ChildHandleBuffer Not used\r | |
3ea80ba2 | 251 | \r |
619ad10f | 252 | @retval EFI_SUCCESS This driver is removed DeviceHandle\r |
3ea80ba2 | 253 | @retval !EFI_SUCCESS This driver was not removed from this device\r |
20c1e33f | 254 | **/\r |
a1f11f75 | 255 | EFI_STATUS\r |
256 | EFIAPI\r | |
257 | IdeControllerStop (\r | |
258 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
259 | IN EFI_HANDLE Controller,\r | |
260 | IN UINTN NumberOfChildren,\r | |
261 | IN EFI_HANDLE *ChildHandleBuffer\r | |
262 | )\r | |
a1f11f75 | 263 | {\r |
264 | EFI_STATUS Status;\r | |
265 | EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;\r | |
266 | \r | |
267 | //\r | |
268 | // Open the produced protocol\r | |
269 | //\r | |
270 | Status = gBS->OpenProtocol (\r | |
271 | Controller,\r | |
272 | &gEfiIdeControllerInitProtocolGuid,\r | |
273 | (VOID **) &IdeControllerInit,\r | |
274 | This->DriverBindingHandle,\r | |
275 | Controller,\r | |
276 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
277 | );\r | |
278 | if (EFI_ERROR (Status)) {\r | |
279 | return EFI_UNSUPPORTED;\r | |
280 | }\r | |
281 | \r | |
282 | //\r | |
283 | // Make sure the protocol was produced by this driver\r | |
284 | //\r | |
285 | if (IdeControllerInit != &gEfiIdeControllerInit) {\r | |
286 | return EFI_UNSUPPORTED;\r | |
287 | }\r | |
288 | \r | |
289 | //\r | |
290 | // Uninstall the IDE Controller Init Protocol\r | |
291 | //\r | |
292 | Status = gBS->UninstallMultipleProtocolInterfaces (\r | |
293 | Controller,\r | |
294 | &gEfiIdeControllerInitProtocolGuid, &gEfiIdeControllerInit,\r | |
295 | NULL\r | |
296 | );\r | |
297 | if (EFI_ERROR (Status)) {\r | |
298 | return Status;\r | |
299 | }\r | |
300 | \r | |
301 | //\r | |
302 | // Close protocols opened by Ide controller driver\r | |
303 | //\r | |
304 | return gBS->CloseProtocol (\r | |
305 | Controller,\r | |
306 | &gEfiPciIoProtocolGuid,\r | |
307 | This->DriverBindingHandle,\r | |
308 | Controller\r | |
309 | );\r | |
310 | }\r | |
311 | \r | |
312 | //\r | |
313 | // Interface functions of IDE_CONTROLLER_INIT protocol\r | |
314 | //\r | |
20c1e33f | 315 | /**\r |
95717b94 | 316 | Returns the information about the specified IDE channel.\r |
5a702acd | 317 | \r |
95717b94 | 318 | This function can be used to obtain information about a particular IDE channel.\r |
5a702acd LG |
319 | The driver entity uses this information during the enumeration process.\r |
320 | \r | |
321 | If Enabled is set to FALSE, the driver entity will not scan the channel. Note\r | |
95717b94 | 322 | that it will not prevent an operating system driver from scanning the channel.\r |
5a702acd LG |
323 | \r |
324 | For most of today's controllers, MaxDevices will either be 1 or 2. For SATA\r | |
325 | controllers, this value will always be 1. SATA configurations can contain SATA\r | |
95717b94 | 326 | port multipliers. SATA port multipliers behave like SATA bridges and can support\r |
5a702acd LG |
327 | up to 16 devices on the other side. If a SATA port out of the IDE controller\r |
328 | is connected to a port multiplier, MaxDevices will be set to the number of SATA\r | |
329 | devices that the port multiplier supports. Because today's port multipliers\r | |
330 | support up to fifteen SATA devices, this number can be as large as fifteen. The IDE\r | |
331 | bus driver is required to scan for the presence of port multipliers behind an SATA\r | |
332 | controller and enumerate up to MaxDevices number of devices behind the port\r | |
333 | multiplier.\r | |
334 | \r | |
335 | In this context, the devices behind a port multiplier constitute a channel.\r | |
336 | \r | |
95717b94 | 337 | @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r |
338 | @param[in] Channel Zero-based channel number.\r | |
5a702acd | 339 | @param[out] Enabled TRUE if this channel is enabled. Disabled channels\r |
95717b94 | 340 | are not scanned to see if any devices are present.\r |
341 | @param[out] MaxDevices The maximum number of IDE devices that the bus driver\r | |
5a702acd LG |
342 | can expect on this channel. For the ATA/ATAPI\r |
343 | specification, version 6, this number will either be\r | |
344 | one or two. For Serial ATA (SATA) configurations with a\r | |
95717b94 | 345 | port multiplier, this number can be as large as fifteen.\r |
346 | \r | |
347 | @retval EFI_SUCCESS Information was returned without any errors.\r | |
348 | @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r | |
349 | \r | |
20c1e33f | 350 | **/\r |
a1f11f75 | 351 | EFI_STATUS\r |
352 | EFIAPI\r | |
353 | IdeInitGetChannelInfo (\r | |
354 | IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r | |
355 | IN UINT8 Channel,\r | |
356 | OUT BOOLEAN *Enabled,\r | |
357 | OUT UINT8 *MaxDevices\r | |
358 | )\r | |
a1f11f75 | 359 | {\r |
360 | //\r | |
361 | // Channel number (0 based, either 0 or 1)\r | |
362 | //\r | |
363 | if (Channel < ICH_IDE_MAX_CHANNEL) {\r | |
364 | *Enabled = TRUE;\r | |
365 | *MaxDevices = ICH_IDE_MAX_DEVICES;\r | |
366 | return EFI_SUCCESS;\r | |
367 | }\r | |
368 | \r | |
369 | *Enabled = FALSE;\r | |
370 | return EFI_INVALID_PARAMETER;\r | |
371 | }\r | |
372 | \r | |
20c1e33f | 373 | /**\r |
95717b94 | 374 | The notifications from the driver entity that it is about to enter a certain\r |
375 | phase of the IDE channel enumeration process.\r | |
5a702acd LG |
376 | \r |
377 | This function can be used to notify the IDE controller driver to perform\r | |
378 | specific actions, including any chipset-specific initialization, so that the\r | |
379 | chipset is ready to enter the next phase. Seven notification points are defined\r | |
380 | at this time.\r | |
381 | \r | |
382 | More synchronization points may be added as required in the future.\r | |
95717b94 | 383 | \r |
384 | @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r | |
385 | @param[in] Phase The phase during enumeration.\r | |
386 | @param[in] Channel Zero-based channel number.\r | |
387 | \r | |
388 | @retval EFI_SUCCESS The notification was accepted without any errors.\r | |
389 | @retval EFI_UNSUPPORTED Phase is not supported.\r | |
390 | @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r | |
5a702acd LG |
391 | @retval EFI_NOT_READY This phase cannot be entered at this time; for\r |
392 | example, an attempt was made to enter a Phase\r | |
393 | without having entered one or more previous\r | |
95717b94 | 394 | Phase.\r |
3ea80ba2 | 395 | \r |
20c1e33f | 396 | **/\r |
a1f11f75 | 397 | EFI_STATUS\r |
398 | EFIAPI\r | |
399 | IdeInitNotifyPhase (\r | |
400 | IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r | |
401 | IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,\r | |
402 | IN UINT8 Channel\r | |
403 | )\r | |
a1f11f75 | 404 | {\r |
405 | return EFI_SUCCESS;\r | |
406 | }\r | |
407 | \r | |
20c1e33f | 408 | /**\r |
95717b94 | 409 | Submits the device information to the IDE controller driver.\r |
410 | \r | |
5a702acd LG |
411 | This function is used by the driver entity to pass detailed information about\r |
412 | a particular device to the IDE controller driver. The driver entity obtains\r | |
95717b94 | 413 | this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData\r |
5a702acd LG |
414 | is the pointer to the response data buffer. The IdentifyData buffer is owned\r |
415 | by the driver entity, and the IDE controller driver must make a local copy\r | |
416 | of the entire buffer or parts of the buffer as needed. The original IdentifyData\r | |
95717b94 | 417 | buffer pointer may not be valid when\r |
5a702acd | 418 | \r |
95717b94 | 419 | - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or\r |
420 | - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point.\r | |
5a702acd LG |
421 | \r |
422 | The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to\r | |
423 | compute the optimum mode for the device. These fields are not limited to the\r | |
424 | timing information. For example, an implementation of the IDE controller driver\r | |
425 | may examine the vendor and type/mode field to match known bad drives.\r | |
426 | \r | |
427 | The driver entity may submit drive information in any order, as long as it\r | |
428 | submits information for all the devices belonging to the enumeration group\r | |
95717b94 | 429 | before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device\r |
430 | in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r | |
5a702acd LG |
431 | should be called with IdentifyData set to NULL. The IDE controller driver may\r |
432 | not have any other mechanism to know whether a device is present or not. Therefore,\r | |
433 | setting IdentifyData to NULL does not constitute an error condition.\r | |
434 | EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a\r | |
435 | given (Channel, Device) pair.\r | |
436 | \r | |
95717b94 | 437 | @param[in] This A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r |
438 | @param[in] Channel Zero-based channel number.\r | |
439 | @param[in] Device Zero-based device number on the Channel.\r | |
440 | @param[in] IdentifyData The device's response to the ATA IDENTIFY_DEVICE command.\r | |
441 | \r | |
442 | @retval EFI_SUCCESS The information was accepted without any errors.\r | |
443 | @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r | |
444 | @retval EFI_INVALID_PARAMETER Device is invalid.\r | |
20c1e33f | 445 | \r |
20c1e33f | 446 | **/\r |
a1f11f75 | 447 | EFI_STATUS\r |
448 | EFIAPI\r | |
449 | IdeInitSubmitData (\r | |
450 | IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r | |
451 | IN UINT8 Channel,\r | |
452 | IN UINT8 Device,\r | |
453 | IN EFI_IDENTIFY_DATA *IdentifyData\r | |
454 | )\r | |
a1f11f75 | 455 | {\r |
456 | return EFI_SUCCESS;\r | |
457 | }\r | |
458 | \r | |
20c1e33f | 459 | /**\r |
95717b94 | 460 | Disqualifies specific modes for an IDE device.\r |
461 | \r | |
5a702acd | 462 | This function allows the driver entity or other drivers (such as platform\r |
95717b94 | 463 | drivers) to reject certain timing modes and request the IDE controller driver\r |
5a702acd LG |
464 | to recalculate modes. This function allows the driver entity and the IDE\r |
465 | controller driver to negotiate the timings on a per-device basis. This function\r | |
466 | is useful in the case of drives that lie about their capabilities. An example\r | |
467 | is when the IDE device fails to accept the timing modes that are calculated\r | |
95717b94 | 468 | by the IDE controller driver based on the response to the Identify Drive command.\r |
469 | \r | |
5a702acd LG |
470 | If the driver entity does not want to limit the ATA timing modes and leave that\r |
471 | decision to the IDE controller driver, it can either not call this function for\r | |
472 | the given device or call this function and set the Valid flag to FALSE for all\r | |
95717b94 | 473 | modes that are listed in EFI_ATA_COLLECTIVE_MODE.\r |
5a702acd LG |
474 | \r |
475 | The driver entity may disqualify modes for a device in any order and any number\r | |
95717b94 | 476 | of times.\r |
5a702acd LG |
477 | \r |
478 | This function can be called multiple times to invalidate multiple modes of the\r | |
479 | same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI\r | |
480 | specification for more information on PIO modes.\r | |
481 | \r | |
95717b94 | 482 | For Serial ATA (SATA) controllers, this member function can be used to disqualify\r |
483 | a higher transfer rate mode on a given channel. For example, a platform driver\r | |
5a702acd | 484 | may inform the IDE controller driver to not use second-generation (Gen2) speeds\r |
95717b94 | 485 | for a certain SATA drive.\r |
5a702acd | 486 | \r |
95717b94 | 487 | @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r |
488 | @param[in] Channel The zero-based channel number.\r | |
489 | @param[in] Device The zero-based device number on the Channel.\r | |
490 | @param[in] BadModes The modes that the device does not support and that\r | |
491 | should be disqualified.\r | |
492 | \r | |
493 | @retval EFI_SUCCESS The modes were accepted without any errors.\r | |
494 | @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r | |
495 | @retval EFI_INVALID_PARAMETER Device is invalid.\r | |
496 | @retval EFI_INVALID_PARAMETER IdentifyData is NULL.\r | |
5a702acd | 497 | \r |
20c1e33f | 498 | **/\r |
a1f11f75 | 499 | EFI_STATUS\r |
500 | EFIAPI\r | |
501 | IdeInitDisqualifyMode (\r | |
502 | IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r | |
503 | IN UINT8 Channel,\r | |
504 | IN UINT8 Device,\r | |
505 | IN EFI_ATA_COLLECTIVE_MODE *BadModes\r | |
506 | )\r | |
a1f11f75 | 507 | {\r |
508 | return EFI_SUCCESS;\r | |
509 | }\r | |
510 | \r | |
20c1e33f | 511 | /**\r |
95717b94 | 512 | Returns the information about the optimum modes for the specified IDE device.\r |
513 | \r | |
514 | This function is used by the driver entity to obtain the optimum ATA modes for\r | |
5a702acd | 515 | a specific device. The IDE controller driver takes into account the following\r |
95717b94 | 516 | while calculating the mode:\r |
517 | - The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r | |
518 | - The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode()\r | |
519 | \r | |
5a702acd LG |
520 | The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r |
521 | for all the devices that belong to an enumeration group before calling\r | |
522 | EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group.\r | |
523 | \r | |
524 | The IDE controller driver will use controller- and possibly platform-specific\r | |
525 | algorithms to arrive at SupportedModes. The IDE controller may base its\r | |
526 | decision on user preferences and other considerations as well. This function\r | |
527 | may be called multiple times because the driver entity may renegotiate the mode\r | |
95717b94 | 528 | with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode().\r |
5a702acd LG |
529 | \r |
530 | The driver entity may collect timing information for various devices in any\r | |
95717b94 | 531 | order. The driver entity is responsible for making sure that all the dependencies\r |
5a702acd LG |
532 | are satisfied. For example, the SupportedModes information for device A that\r |
533 | was previously returned may become stale after a call to\r | |
95717b94 | 534 | EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B.\r |
5a702acd LG |
535 | \r |
536 | The buffer SupportedModes is allocated by the callee because the caller does\r | |
537 | not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE\r | |
538 | is defined in a way that allows for future extensibility and can be of variable\r | |
539 | length. This memory pool should be deallocated by the caller when it is no\r | |
540 | longer necessary.\r | |
541 | \r | |
542 | The IDE controller driver for a Serial ATA (SATA) controller can use this\r | |
543 | member function to force a lower speed (first-generation [Gen1] speeds on a\r | |
544 | second-generation [Gen2]-capable hardware). The IDE controller driver can\r | |
545 | also allow the driver entity to stay with the speed that has been negotiated\r | |
95717b94 | 546 | by the physical layer.\r |
5a702acd | 547 | \r |
95717b94 | 548 | @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r |
549 | @param[in] Channel A zero-based channel number.\r | |
550 | @param[in] Device A zero-based device number on the Channel.\r | |
551 | @param[out] SupportedModes The optimum modes for the device.\r | |
552 | \r | |
553 | @retval EFI_SUCCESS SupportedModes was returned.\r | |
554 | @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r | |
5a702acd | 555 | @retval EFI_INVALID_PARAMETER Device is invalid.\r |
95717b94 | 556 | @retval EFI_INVALID_PARAMETER SupportedModes is NULL.\r |
5a702acd LG |
557 | @retval EFI_NOT_READY Modes cannot be calculated due to a lack of\r |
558 | data. This error may happen if\r | |
559 | EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()\r | |
560 | and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData()\r | |
561 | were not called for at least one drive in the\r | |
95717b94 | 562 | same enumeration group.\r |
3ea80ba2 | 563 | \r |
20c1e33f | 564 | **/\r |
a1f11f75 | 565 | EFI_STATUS\r |
566 | EFIAPI\r | |
567 | IdeInitCalculateMode (\r | |
568 | IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r | |
569 | IN UINT8 Channel,\r | |
570 | IN UINT8 Device,\r | |
571 | OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes\r | |
572 | )\r | |
a1f11f75 | 573 | {\r |
574 | if (Channel >= ICH_IDE_MAX_CHANNEL || Device >= ICH_IDE_MAX_DEVICES) {\r | |
575 | return EFI_INVALID_PARAMETER;\r | |
576 | }\r | |
577 | \r | |
578 | *SupportedModes = AllocateCopyPool (sizeof (EFI_ATA_COLLECTIVE_MODE), &gEfiAtaCollectiveModeTemplate);\r | |
579 | if (*SupportedModes == NULL) {\r | |
580 | return EFI_OUT_OF_RESOURCES;\r | |
581 | }\r | |
582 | \r | |
583 | return EFI_SUCCESS;\r | |
584 | }\r | |
585 | \r | |
20c1e33f | 586 | /**\r |
95717b94 | 587 | Commands the IDE controller driver to program the IDE controller hardware\r |
588 | so that the specified device can operate at the specified mode.\r | |
589 | \r | |
5a702acd LG |
590 | This function is used by the driver entity to instruct the IDE controller\r |
591 | driver to program the IDE controller hardware to the specified modes. This\r | |
592 | function can be called only once for a particular device. For a Serial ATA\r | |
95717b94 | 593 | (SATA) Advanced Host Controller Interface (AHCI) controller, no controller-\r |
594 | specific programming may be required.\r | |
595 | \r | |
596 | @param[in] This Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.\r | |
597 | @param[in] Channel Zero-based channel number.\r | |
598 | @param[in] Device Zero-based device number on the Channel.\r | |
599 | @param[in] Modes The modes to set.\r | |
600 | \r | |
601 | @retval EFI_SUCCESS The command was accepted without any errors.\r | |
602 | @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).\r | |
603 | @retval EFI_INVALID_PARAMETER Device is invalid.\r | |
604 | @retval EFI_NOT_READY Modes cannot be set at this time due to lack of data.\r | |
605 | @retval EFI_DEVICE_ERROR Modes cannot be set due to hardware failure.\r | |
606 | The driver entity should not use this device.\r | |
3ea80ba2 | 607 | \r |
20c1e33f | 608 | **/\r |
a1f11f75 | 609 | EFI_STATUS\r |
610 | EFIAPI\r | |
611 | IdeInitSetTiming (\r | |
612 | IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,\r | |
613 | IN UINT8 Channel,\r | |
614 | IN UINT8 Device,\r | |
615 | IN EFI_ATA_COLLECTIVE_MODE *Modes\r | |
616 | )\r | |
a1f11f75 | 617 | {\r |
618 | return EFI_SUCCESS;\r | |
619 | }\r |