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