1*f439973dSWarner Losh /** @file 2*f439973dSWarner Losh This file declares EFI IDE Controller Init Protocol 3*f439973dSWarner Losh 4*f439973dSWarner Losh The EFI_IDE_CONTROLLER_INIT_PROTOCOL provides the chipset-specific information 5*f439973dSWarner Losh to the driver entity. This protocol is mandatory for IDE controllers if the 6*f439973dSWarner Losh IDE devices behind the controller are to be enumerated by a driver entity. 7*f439973dSWarner Losh 8*f439973dSWarner Losh There can only be one instance of EFI_IDE_CONTROLLER_INIT_PROTOCOL for each IDE 9*f439973dSWarner Losh controller in a system. It is installed on the handle that corresponds to the 10*f439973dSWarner Losh IDE controller. A driver entity that wishes to manage an IDE bus and possibly 11*f439973dSWarner Losh IDE devices in a system will have to retrieve the EFI_IDE_CONTROLLER_INIT_PROTOCOL 12*f439973dSWarner Losh instance that is associated with the controller to be managed. 13*f439973dSWarner Losh 14*f439973dSWarner Losh A device handle for an IDE controller must contain an EFI_DEVICE_PATH_PROTOCOL. 15*f439973dSWarner Losh 16*f439973dSWarner Losh Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> 17*f439973dSWarner Losh SPDX-License-Identifier: BSD-2-Clause-Patent 18*f439973dSWarner Losh 19*f439973dSWarner Losh @par Revision Reference: 20*f439973dSWarner Losh This Protocol is defined in UEFI Platform Initialization Specification 1.2 21*f439973dSWarner Losh Volume 5: Standards. 22*f439973dSWarner Losh 23*f439973dSWarner Losh **/ 24*f439973dSWarner Losh 25*f439973dSWarner Losh #ifndef _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H_ 26*f439973dSWarner Losh #define _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H_ 27*f439973dSWarner Losh 28*f439973dSWarner Losh #include <IndustryStandard/Atapi.h> 29*f439973dSWarner Losh 30*f439973dSWarner Losh /// 31*f439973dSWarner Losh /// Global ID for the EFI_IDE_CONTROLLER_INIT_PROTOCOL. 32*f439973dSWarner Losh /// 33*f439973dSWarner Losh #define EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID \ 34*f439973dSWarner Losh { \ 35*f439973dSWarner Losh 0xa1e37052, 0x80d9, 0x4e65, {0xa3, 0x17, 0x3e, 0x9a, 0x55, 0xc4, 0x3e, 0xc9 } \ 36*f439973dSWarner Losh } 37*f439973dSWarner Losh 38*f439973dSWarner Losh /// 39*f439973dSWarner Losh /// Forward declaration for EFI_IDE_CONTROLLER_INIT_PROTOCOL. 40*f439973dSWarner Losh /// 41*f439973dSWarner Losh typedef struct _EFI_IDE_CONTROLLER_INIT_PROTOCOL EFI_IDE_CONTROLLER_INIT_PROTOCOL; 42*f439973dSWarner Losh 43*f439973dSWarner Losh /// 44*f439973dSWarner Losh /// The phase of the IDE Controller enumeration. 45*f439973dSWarner Losh /// 46*f439973dSWarner Losh typedef enum { 47*f439973dSWarner Losh /// 48*f439973dSWarner Losh /// The driver entity is about to begin enumerating the devices 49*f439973dSWarner Losh /// behind the specified channel. This notification can be used to 50*f439973dSWarner Losh /// perform any chipset-specific programming. 51*f439973dSWarner Losh /// 52*f439973dSWarner Losh EfiIdeBeforeChannelEnumeration, 53*f439973dSWarner Losh /// 54*f439973dSWarner Losh /// The driver entity has completed enumerating the devices 55*f439973dSWarner Losh /// behind the specified channel. This notification can be used to 56*f439973dSWarner Losh /// perform any chipset-specific programming. 57*f439973dSWarner Losh /// 58*f439973dSWarner Losh EfiIdeAfterChannelEnumeration, 59*f439973dSWarner Losh /// 60*f439973dSWarner Losh /// The driver entity is about to reset the devices behind the 61*f439973dSWarner Losh /// specified channel. This notification can be used to perform any 62*f439973dSWarner Losh /// chipset-specific programming. 63*f439973dSWarner Losh /// 64*f439973dSWarner Losh EfiIdeBeforeChannelReset, 65*f439973dSWarner Losh /// 66*f439973dSWarner Losh /// The driver entity has completed resetting the devices behind 67*f439973dSWarner Losh /// the specified channel. This notification can be used to perform 68*f439973dSWarner Losh /// any chipset-specific programming. 69*f439973dSWarner Losh /// 70*f439973dSWarner Losh EfiIdeAfterChannelReset, 71*f439973dSWarner Losh /// 72*f439973dSWarner Losh /// The driver entity is about to detect the presence of devices 73*f439973dSWarner Losh /// behind the specified channel. This notification can be used to 74*f439973dSWarner Losh /// set up the bus signals to default levels or for implementing 75*f439973dSWarner Losh /// predelays. 76*f439973dSWarner Losh /// 77*f439973dSWarner Losh EfiIdeBusBeforeDevicePresenceDetection, 78*f439973dSWarner Losh /// 79*f439973dSWarner Losh /// The driver entity is done with detecting the presence of 80*f439973dSWarner Losh /// devices behind the specified channel. This notification can be 81*f439973dSWarner Losh /// used to perform any chipset-specific programming. 82*f439973dSWarner Losh /// 83*f439973dSWarner Losh EfiIdeBusAfterDevicePresenceDetection, 84*f439973dSWarner Losh /// 85*f439973dSWarner Losh /// The IDE bus is requesting the IDE controller driver to 86*f439973dSWarner Losh /// reprogram the IDE controller hardware and thereby reset all 87*f439973dSWarner Losh /// the mode and timing settings to default settings. 88*f439973dSWarner Losh /// 89*f439973dSWarner Losh EfiIdeResetMode, 90*f439973dSWarner Losh EfiIdeBusPhaseMaximum 91*f439973dSWarner Losh } EFI_IDE_CONTROLLER_ENUM_PHASE; 92*f439973dSWarner Losh 93*f439973dSWarner Losh /// 94*f439973dSWarner Losh /// This extended mode describes the SATA physical protocol. 95*f439973dSWarner Losh /// SATA physical layers can operate at different speeds. 96*f439973dSWarner Losh /// These speeds are defined below. Various PATA protocols 97*f439973dSWarner Losh /// and associated modes are not applicable to SATA devices. 98*f439973dSWarner Losh /// 99*f439973dSWarner Losh typedef enum { 100*f439973dSWarner Losh EfiAtaSataTransferProtocol 101*f439973dSWarner Losh } EFI_ATA_EXT_TRANSFER_PROTOCOL; 102*f439973dSWarner Losh 103*f439973dSWarner Losh /// 104*f439973dSWarner Losh /// Automatically detects the optimum SATA speed. 105*f439973dSWarner Losh /// 106*f439973dSWarner Losh #define EFI_SATA_AUTO_SPEED 0 107*f439973dSWarner Losh 108*f439973dSWarner Losh /// 109*f439973dSWarner Losh /// Indicates a first-generation (Gen1) SATA speed. 110*f439973dSWarner Losh /// 111*f439973dSWarner Losh #define EFI_SATA_GEN1_SPEED 1 112*f439973dSWarner Losh 113*f439973dSWarner Losh /// 114*f439973dSWarner Losh /// Indicates a second-generation (Gen2) SATA speed. 115*f439973dSWarner Losh /// 116*f439973dSWarner Losh #define EFI_SATA_GEN2_SPEED 2 117*f439973dSWarner Losh 118*f439973dSWarner Losh /// 119*f439973dSWarner Losh /// EFI_ATA_MODE structure. 120*f439973dSWarner Losh /// 121*f439973dSWarner Losh typedef struct { 122*f439973dSWarner Losh BOOLEAN Valid; ///< TRUE if Mode is valid. 123*f439973dSWarner Losh UINT32 Mode; ///< The actual ATA mode. This field is not a bit map. 124*f439973dSWarner Losh } EFI_ATA_MODE; 125*f439973dSWarner Losh 126*f439973dSWarner Losh /// 127*f439973dSWarner Losh /// EFI_ATA_EXTENDED_MODE structure 128*f439973dSWarner Losh /// 129*f439973dSWarner Losh typedef struct { 130*f439973dSWarner Losh /// 131*f439973dSWarner Losh /// An enumeration defining various transfer protocols other than the protocols 132*f439973dSWarner Losh /// that exist at the time this specification was developed (i.e., PIO, single 133*f439973dSWarner Losh /// word DMA, multiword DMA, and UDMA). Each transfer protocol is associated 134*f439973dSWarner Losh /// with a mode. The various transfer protocols are defined by the ATA/ATAPI 135*f439973dSWarner Losh /// specification. This enumeration makes the interface extensible because we 136*f439973dSWarner Losh /// can support new transport protocols beyond UDMA. Type EFI_ATA_EXT_TRANSFER_PROTOCOL 137*f439973dSWarner Losh /// is defined below. 138*f439973dSWarner Losh /// 139*f439973dSWarner Losh EFI_ATA_EXT_TRANSFER_PROTOCOL TransferProtocol; 140*f439973dSWarner Losh /// 141*f439973dSWarner Losh /// The mode for operating the transfer protocol that is identified by TransferProtocol. 142*f439973dSWarner Losh /// 143*f439973dSWarner Losh UINT32 Mode; 144*f439973dSWarner Losh } EFI_ATA_EXTENDED_MODE; 145*f439973dSWarner Losh 146*f439973dSWarner Losh /// 147*f439973dSWarner Losh /// EFI_ATA_COLLECTIVE_MODE structure. 148*f439973dSWarner Losh /// 149*f439973dSWarner Losh typedef struct { 150*f439973dSWarner Losh /// 151*f439973dSWarner Losh /// This field specifies the PIO mode. PIO modes are defined in the ATA/ATAPI 152*f439973dSWarner Losh /// specification. The ATA/ATAPI specification defines the enumeration. In 153*f439973dSWarner Losh /// other words, a value of 1 in this field means PIO mode 1. The actual meaning 154*f439973dSWarner Losh /// of PIO mode 1 is governed by the ATA/ATAPI specification. Type EFI_ATA_MODE 155*f439973dSWarner Losh /// is defined below. 156*f439973dSWarner Losh /// 157*f439973dSWarner Losh EFI_ATA_MODE PioMode; 158*f439973dSWarner Losh /// 159*f439973dSWarner Losh /// This field specifies the single word DMA mode. Single word DMA modes are defined 160*f439973dSWarner Losh /// in the ATA/ATAPI specification, versions 1 and 2. Single word DMA support was 161*f439973dSWarner Losh /// obsoleted in the ATA/ATAPI specification, version 3. Therefore, most devices and 162*f439973dSWarner Losh /// controllers will not support this transfer mode. The ATA/ATAPI specification defines 163*f439973dSWarner Losh /// the enumeration. In other words, a value of 1 in this field means single word DMA 164*f439973dSWarner Losh /// mode 1. The actual meaning of single word DMA mode 1 is governed by the ATA/ 165*f439973dSWarner Losh /// ATAPI specification. 166*f439973dSWarner Losh /// 167*f439973dSWarner Losh EFI_ATA_MODE SingleWordDmaMode; 168*f439973dSWarner Losh /// 169*f439973dSWarner Losh /// This field specifies the multiword DMA mode. Various multiword DMA modes are 170*f439973dSWarner Losh /// defined in the ATA/ATAPI specification. A value of 1 in this field means multiword 171*f439973dSWarner Losh /// DMA mode 1. The actual meaning of multiword DMA mode 1 is governed by the 172*f439973dSWarner Losh /// ATA/ATAPI specification. 173*f439973dSWarner Losh /// 174*f439973dSWarner Losh EFI_ATA_MODE MultiWordDmaMode; 175*f439973dSWarner Losh /// 176*f439973dSWarner Losh /// This field specifies the ultra DMA (UDMA) mode. UDMA modes are defined in the 177*f439973dSWarner Losh /// ATA/ATAPI specification. A value of 1 in this field means UDMA mode 1. The 178*f439973dSWarner Losh /// actual meaning of UDMA mode 1 is governed by the ATA/ATAPI specification. 179*f439973dSWarner Losh /// 180*f439973dSWarner Losh EFI_ATA_MODE UdmaMode; 181*f439973dSWarner Losh /// 182*f439973dSWarner Losh /// The number of extended-mode bitmap entries. Extended modes describe transfer 183*f439973dSWarner Losh /// protocols beyond PIO, single word DMA, multiword DMA, and UDMA. This field 184*f439973dSWarner Losh /// can be zero and provides extensibility. 185*f439973dSWarner Losh /// 186*f439973dSWarner Losh UINT32 ExtModeCount; 187*f439973dSWarner Losh /// 188*f439973dSWarner Losh /// ExtModeCount number of entries. Each entry represents a transfer protocol other 189*f439973dSWarner Losh /// than the ones defined above (i.e., PIO, single word DMA, multiword DMA, and 190*f439973dSWarner Losh /// UDMA). This field is defined for extensibility. At this time, only one extended 191*f439973dSWarner Losh /// transfer protocol is defined to cover SATA transfers. Type 192*f439973dSWarner Losh /// EFI_ATA_EXTENDED_MODE is defined below. 193*f439973dSWarner Losh /// 194*f439973dSWarner Losh EFI_ATA_EXTENDED_MODE ExtMode[1]; 195*f439973dSWarner Losh } EFI_ATA_COLLECTIVE_MODE; 196*f439973dSWarner Losh 197*f439973dSWarner Losh /// 198*f439973dSWarner Losh /// EFI_ATA_IDENTIFY_DATA & EFI_ATAPI_IDENTIFY_DATA structure 199*f439973dSWarner Losh /// 200*f439973dSWarner Losh /// The definition of these two structures is not part of the protocol 201*f439973dSWarner Losh /// definition because the ATA/ATAPI Specification controls the definition 202*f439973dSWarner Losh /// of all the fields. The ATA/ATAPI Specification can obsolete old fields 203*f439973dSWarner Losh /// or redefine existing fields. 204*f439973dSWarner Losh typedef ATA_IDENTIFY_DATA EFI_ATA_IDENTIFY_DATA; 205*f439973dSWarner Losh typedef ATAPI_IDENTIFY_DATA EFI_ATAPI_IDENTIFY_DATA; 206*f439973dSWarner Losh 207*f439973dSWarner Losh /// 208*f439973dSWarner Losh /// This flag indicates whether the IDENTIFY data is a response from an ATA device 209*f439973dSWarner Losh /// (EFI_ATA_IDENTIFY_DATA) or response from an ATAPI device 210*f439973dSWarner Losh /// (EFI_ATAPI_IDENTIFY_DATA). According to the ATA/ATAPI specification, 211*f439973dSWarner Losh /// EFI_IDENTIFY_DATA is for an ATA device if bit 15 of the Config field is zero. 212*f439973dSWarner Losh /// The Config field is common to both EFI_ATA_IDENTIFY_DATA and 213*f439973dSWarner Losh /// EFI_ATAPI_IDENTIFY_DATA. 214*f439973dSWarner Losh /// 215*f439973dSWarner Losh #define EFI_ATAPI_DEVICE_IDENTIFY_DATA 0x8000 216*f439973dSWarner Losh 217*f439973dSWarner Losh /// 218*f439973dSWarner Losh /// EFI_IDENTIFY_DATA structure. 219*f439973dSWarner Losh /// 220*f439973dSWarner Losh typedef union { 221*f439973dSWarner Losh /// 222*f439973dSWarner Losh /// The data that is returned by an ATA device upon successful completion 223*f439973dSWarner Losh /// of the ATA IDENTIFY_DEVICE command. 224*f439973dSWarner Losh /// 225*f439973dSWarner Losh EFI_ATA_IDENTIFY_DATA AtaData; 226*f439973dSWarner Losh /// 227*f439973dSWarner Losh /// The data that is returned by an ATAPI device upon successful completion 228*f439973dSWarner Losh /// of the ATA IDENTIFY_PACKET_DEVICE command. 229*f439973dSWarner Losh /// 230*f439973dSWarner Losh EFI_ATAPI_IDENTIFY_DATA AtapiData; 231*f439973dSWarner Losh } EFI_IDENTIFY_DATA; 232*f439973dSWarner Losh 233*f439973dSWarner Losh /** 234*f439973dSWarner Losh Returns the information about the specified IDE channel. 235*f439973dSWarner Losh 236*f439973dSWarner Losh This function can be used to obtain information about a particular IDE channel. 237*f439973dSWarner Losh The driver entity uses this information during the enumeration process. 238*f439973dSWarner Losh 239*f439973dSWarner Losh If Enabled is set to FALSE, the driver entity will not scan the channel. Note 240*f439973dSWarner Losh that it will not prevent an operating system driver from scanning the channel. 241*f439973dSWarner Losh 242*f439973dSWarner Losh For most of today's controllers, MaxDevices will either be 1 or 2. For SATA 243*f439973dSWarner Losh controllers, this value will always be 1. SATA configurations can contain SATA 244*f439973dSWarner Losh port multipliers. SATA port multipliers behave like SATA bridges and can support 245*f439973dSWarner Losh up to 16 devices on the other side. If a SATA port out of the IDE controller 246*f439973dSWarner Losh is connected to a port multiplier, MaxDevices will be set to the number of SATA 247*f439973dSWarner Losh devices that the port multiplier supports. Because today's port multipliers 248*f439973dSWarner Losh support up to fifteen SATA devices, this number can be as large as fifteen. The IDE 249*f439973dSWarner Losh bus driver is required to scan for the presence of port multipliers behind an SATA 250*f439973dSWarner Losh controller and enumerate up to MaxDevices number of devices behind the port 251*f439973dSWarner Losh multiplier. 252*f439973dSWarner Losh 253*f439973dSWarner Losh In this context, the devices behind a port multiplier constitute a channel. 254*f439973dSWarner Losh 255*f439973dSWarner Losh @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. 256*f439973dSWarner Losh @param[in] Channel Zero-based channel number. 257*f439973dSWarner Losh @param[out] Enabled TRUE if this channel is enabled. Disabled channels 258*f439973dSWarner Losh are not scanned to see if any devices are present. 259*f439973dSWarner Losh @param[out] MaxDevices The maximum number of IDE devices that the bus driver 260*f439973dSWarner Losh can expect on this channel. For the ATA/ATAPI 261*f439973dSWarner Losh specification, version 6, this number will either be 262*f439973dSWarner Losh one or two. For Serial ATA (SATA) configurations with a 263*f439973dSWarner Losh port multiplier, this number can be as large as fifteen. 264*f439973dSWarner Losh 265*f439973dSWarner Losh @retval EFI_SUCCESS Information was returned without any errors. 266*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). 267*f439973dSWarner Losh 268*f439973dSWarner Losh **/ 269*f439973dSWarner Losh typedef 270*f439973dSWarner Losh EFI_STATUS 271*f439973dSWarner Losh (EFIAPI *EFI_IDE_CONTROLLER_GET_CHANNEL_INFO)( 272*f439973dSWarner Losh IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, 273*f439973dSWarner Losh IN UINT8 Channel, 274*f439973dSWarner Losh OUT BOOLEAN *Enabled, 275*f439973dSWarner Losh OUT UINT8 *MaxDevices 276*f439973dSWarner Losh ); 277*f439973dSWarner Losh 278*f439973dSWarner Losh /** 279*f439973dSWarner Losh The notifications from the driver entity that it is about to enter a certain 280*f439973dSWarner Losh phase of the IDE channel enumeration process. 281*f439973dSWarner Losh 282*f439973dSWarner Losh This function can be used to notify the IDE controller driver to perform 283*f439973dSWarner Losh specific actions, including any chipset-specific initialization, so that the 284*f439973dSWarner Losh chipset is ready to enter the next phase. Seven notification points are defined 285*f439973dSWarner Losh at this time. 286*f439973dSWarner Losh 287*f439973dSWarner Losh More synchronization points may be added as required in the future. 288*f439973dSWarner Losh 289*f439973dSWarner Losh @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. 290*f439973dSWarner Losh @param[in] Phase The phase during enumeration. 291*f439973dSWarner Losh @param[in] Channel Zero-based channel number. 292*f439973dSWarner Losh 293*f439973dSWarner Losh @retval EFI_SUCCESS The notification was accepted without any errors. 294*f439973dSWarner Losh @retval EFI_UNSUPPORTED Phase is not supported. 295*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). 296*f439973dSWarner Losh @retval EFI_NOT_READY This phase cannot be entered at this time; for 297*f439973dSWarner Losh example, an attempt was made to enter a Phase 298*f439973dSWarner Losh without having entered one or more previous 299*f439973dSWarner Losh Phase. 300*f439973dSWarner Losh 301*f439973dSWarner Losh **/ 302*f439973dSWarner Losh typedef 303*f439973dSWarner Losh EFI_STATUS 304*f439973dSWarner Losh (EFIAPI *EFI_IDE_CONTROLLER_NOTIFY_PHASE)( 305*f439973dSWarner Losh IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, 306*f439973dSWarner Losh IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase, 307*f439973dSWarner Losh IN UINT8 Channel 308*f439973dSWarner Losh ); 309*f439973dSWarner Losh 310*f439973dSWarner Losh /** 311*f439973dSWarner Losh Submits the device information to the IDE controller driver. 312*f439973dSWarner Losh 313*f439973dSWarner Losh This function is used by the driver entity to pass detailed information about 314*f439973dSWarner Losh a particular device to the IDE controller driver. The driver entity obtains 315*f439973dSWarner Losh this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData 316*f439973dSWarner Losh is the pointer to the response data buffer. The IdentifyData buffer is owned 317*f439973dSWarner Losh by the driver entity, and the IDE controller driver must make a local copy 318*f439973dSWarner Losh of the entire buffer or parts of the buffer as needed. The original IdentifyData 319*f439973dSWarner Losh buffer pointer may not be valid when 320*f439973dSWarner Losh 321*f439973dSWarner Losh - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or 322*f439973dSWarner Losh - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point. 323*f439973dSWarner Losh 324*f439973dSWarner Losh The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to 325*f439973dSWarner Losh compute the optimum mode for the device. These fields are not limited to the 326*f439973dSWarner Losh timing information. For example, an implementation of the IDE controller driver 327*f439973dSWarner Losh may examine the vendor and type/mode field to match known bad drives. 328*f439973dSWarner Losh 329*f439973dSWarner Losh The driver entity may submit drive information in any order, as long as it 330*f439973dSWarner Losh submits information for all the devices belonging to the enumeration group 331*f439973dSWarner Losh before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device 332*f439973dSWarner Losh in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() 333*f439973dSWarner Losh should be called with IdentifyData set to NULL. The IDE controller driver may 334*f439973dSWarner Losh not have any other mechanism to know whether a device is present or not. Therefore, 335*f439973dSWarner Losh setting IdentifyData to NULL does not constitute an error condition. 336*f439973dSWarner Losh EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a 337*f439973dSWarner Losh given (Channel, Device) pair. 338*f439973dSWarner Losh 339*f439973dSWarner Losh @param[in] This A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. 340*f439973dSWarner Losh @param[in] Channel Zero-based channel number. 341*f439973dSWarner Losh @param[in] Device Zero-based device number on the Channel. 342*f439973dSWarner Losh @param[in] IdentifyData The device's response to the ATA IDENTIFY_DEVICE command. 343*f439973dSWarner Losh 344*f439973dSWarner Losh @retval EFI_SUCCESS The information was accepted without any errors. 345*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). 346*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Device is invalid. 347*f439973dSWarner Losh 348*f439973dSWarner Losh **/ 349*f439973dSWarner Losh typedef 350*f439973dSWarner Losh EFI_STATUS 351*f439973dSWarner Losh (EFIAPI *EFI_IDE_CONTROLLER_SUBMIT_DATA)( 352*f439973dSWarner Losh IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, 353*f439973dSWarner Losh IN UINT8 Channel, 354*f439973dSWarner Losh IN UINT8 Device, 355*f439973dSWarner Losh IN EFI_IDENTIFY_DATA *IdentifyData 356*f439973dSWarner Losh ); 357*f439973dSWarner Losh 358*f439973dSWarner Losh /** 359*f439973dSWarner Losh Disqualifies specific modes for an IDE device. 360*f439973dSWarner Losh 361*f439973dSWarner Losh This function allows the driver entity or other drivers (such as platform 362*f439973dSWarner Losh drivers) to reject certain timing modes and request the IDE controller driver 363*f439973dSWarner Losh to recalculate modes. This function allows the driver entity and the IDE 364*f439973dSWarner Losh controller driver to negotiate the timings on a per-device basis. This function 365*f439973dSWarner Losh is useful in the case of drives that lie about their capabilities. An example 366*f439973dSWarner Losh is when the IDE device fails to accept the timing modes that are calculated 367*f439973dSWarner Losh by the IDE controller driver based on the response to the Identify Drive command. 368*f439973dSWarner Losh 369*f439973dSWarner Losh If the driver entity does not want to limit the ATA timing modes and leave that 370*f439973dSWarner Losh decision to the IDE controller driver, it can either not call this function for 371*f439973dSWarner Losh the given device or call this function and set the Valid flag to FALSE for all 372*f439973dSWarner Losh modes that are listed in EFI_ATA_COLLECTIVE_MODE. 373*f439973dSWarner Losh 374*f439973dSWarner Losh The driver entity may disqualify modes for a device in any order and any number 375*f439973dSWarner Losh of times. 376*f439973dSWarner Losh 377*f439973dSWarner Losh This function can be called multiple times to invalidate multiple modes of the 378*f439973dSWarner Losh same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI 379*f439973dSWarner Losh specification for more information on PIO modes. 380*f439973dSWarner Losh 381*f439973dSWarner Losh For Serial ATA (SATA) controllers, this member function can be used to disqualify 382*f439973dSWarner Losh a higher transfer rate mode on a given channel. For example, a platform driver 383*f439973dSWarner Losh may inform the IDE controller driver to not use second-generation (Gen2) speeds 384*f439973dSWarner Losh for a certain SATA drive. 385*f439973dSWarner Losh 386*f439973dSWarner Losh @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. 387*f439973dSWarner Losh @param[in] Channel The zero-based channel number. 388*f439973dSWarner Losh @param[in] Device The zero-based device number on the Channel. 389*f439973dSWarner Losh @param[in] BadModes The modes that the device does not support and that 390*f439973dSWarner Losh should be disqualified. 391*f439973dSWarner Losh 392*f439973dSWarner Losh @retval EFI_SUCCESS The modes were accepted without any errors. 393*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). 394*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Device is invalid. 395*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER IdentifyData is NULL. 396*f439973dSWarner Losh 397*f439973dSWarner Losh **/ 398*f439973dSWarner Losh typedef 399*f439973dSWarner Losh EFI_STATUS 400*f439973dSWarner Losh (EFIAPI *EFI_IDE_CONTROLLER_DISQUALIFY_MODE)( 401*f439973dSWarner Losh IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, 402*f439973dSWarner Losh IN UINT8 Channel, 403*f439973dSWarner Losh IN UINT8 Device, 404*f439973dSWarner Losh IN EFI_ATA_COLLECTIVE_MODE *BadModes 405*f439973dSWarner Losh ); 406*f439973dSWarner Losh 407*f439973dSWarner Losh /** 408*f439973dSWarner Losh Returns the information about the optimum modes for the specified IDE device. 409*f439973dSWarner Losh 410*f439973dSWarner Losh This function is used by the driver entity to obtain the optimum ATA modes for 411*f439973dSWarner Losh a specific device. The IDE controller driver takes into account the following 412*f439973dSWarner Losh while calculating the mode: 413*f439973dSWarner Losh - The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() 414*f439973dSWarner Losh - The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() 415*f439973dSWarner Losh 416*f439973dSWarner Losh The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() 417*f439973dSWarner Losh for all the devices that belong to an enumeration group before calling 418*f439973dSWarner Losh EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group. 419*f439973dSWarner Losh 420*f439973dSWarner Losh The IDE controller driver will use controller- and possibly platform-specific 421*f439973dSWarner Losh algorithms to arrive at SupportedModes. The IDE controller may base its 422*f439973dSWarner Losh decision on user preferences and other considerations as well. This function 423*f439973dSWarner Losh may be called multiple times because the driver entity may renegotiate the mode 424*f439973dSWarner Losh with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode(). 425*f439973dSWarner Losh 426*f439973dSWarner Losh The driver entity may collect timing information for various devices in any 427*f439973dSWarner Losh order. The driver entity is responsible for making sure that all the dependencies 428*f439973dSWarner Losh are satisfied. For example, the SupportedModes information for device A that 429*f439973dSWarner Losh was previously returned may become stale after a call to 430*f439973dSWarner Losh EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B. 431*f439973dSWarner Losh 432*f439973dSWarner Losh The buffer SupportedModes is allocated by the callee because the caller does 433*f439973dSWarner Losh not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE 434*f439973dSWarner Losh is defined in a way that allows for future extensibility and can be of variable 435*f439973dSWarner Losh length. This memory pool should be deallocated by the caller when it is no 436*f439973dSWarner Losh longer necessary. 437*f439973dSWarner Losh 438*f439973dSWarner Losh The IDE controller driver for a Serial ATA (SATA) controller can use this 439*f439973dSWarner Losh member function to force a lower speed (first-generation [Gen1] speeds on a 440*f439973dSWarner Losh second-generation [Gen2]-capable hardware). The IDE controller driver can 441*f439973dSWarner Losh also allow the driver entity to stay with the speed that has been negotiated 442*f439973dSWarner Losh by the physical layer. 443*f439973dSWarner Losh 444*f439973dSWarner Losh @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. 445*f439973dSWarner Losh @param[in] Channel A zero-based channel number. 446*f439973dSWarner Losh @param[in] Device A zero-based device number on the Channel. 447*f439973dSWarner Losh @param[out] SupportedModes The optimum modes for the device. 448*f439973dSWarner Losh 449*f439973dSWarner Losh @retval EFI_SUCCESS SupportedModes was returned. 450*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). 451*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Device is invalid. 452*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER SupportedModes is NULL. 453*f439973dSWarner Losh @retval EFI_NOT_READY Modes cannot be calculated due to a lack of 454*f439973dSWarner Losh data. This error may happen if 455*f439973dSWarner Losh EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() 456*f439973dSWarner Losh and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData() 457*f439973dSWarner Losh were not called for at least one drive in the 458*f439973dSWarner Losh same enumeration group. 459*f439973dSWarner Losh 460*f439973dSWarner Losh **/ 461*f439973dSWarner Losh typedef 462*f439973dSWarner Losh EFI_STATUS 463*f439973dSWarner Losh (EFIAPI *EFI_IDE_CONTROLLER_CALCULATE_MODE)( 464*f439973dSWarner Losh IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, 465*f439973dSWarner Losh IN UINT8 Channel, 466*f439973dSWarner Losh IN UINT8 Device, 467*f439973dSWarner Losh OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes 468*f439973dSWarner Losh ); 469*f439973dSWarner Losh 470*f439973dSWarner Losh /** 471*f439973dSWarner Losh Commands the IDE controller driver to program the IDE controller hardware 472*f439973dSWarner Losh so that the specified device can operate at the specified mode. 473*f439973dSWarner Losh 474*f439973dSWarner Losh This function is used by the driver entity to instruct the IDE controller 475*f439973dSWarner Losh driver to program the IDE controller hardware to the specified modes. This 476*f439973dSWarner Losh function can be called only once for a particular device. For a Serial ATA 477*f439973dSWarner Losh (SATA) Advanced Host Controller Interface (AHCI) controller, no controller- 478*f439973dSWarner Losh specific programming may be required. 479*f439973dSWarner Losh 480*f439973dSWarner Losh @param[in] This Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. 481*f439973dSWarner Losh @param[in] Channel Zero-based channel number. 482*f439973dSWarner Losh @param[in] Device Zero-based device number on the Channel. 483*f439973dSWarner Losh @param[in] Modes The modes to set. 484*f439973dSWarner Losh 485*f439973dSWarner Losh @retval EFI_SUCCESS The command was accepted without any errors. 486*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). 487*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Device is invalid. 488*f439973dSWarner Losh @retval EFI_NOT_READY Modes cannot be set at this time due to lack of data. 489*f439973dSWarner Losh @retval EFI_DEVICE_ERROR Modes cannot be set due to hardware failure. 490*f439973dSWarner Losh The driver entity should not use this device. 491*f439973dSWarner Losh 492*f439973dSWarner Losh **/ 493*f439973dSWarner Losh typedef 494*f439973dSWarner Losh EFI_STATUS 495*f439973dSWarner Losh (EFIAPI *EFI_IDE_CONTROLLER_SET_TIMING)( 496*f439973dSWarner Losh IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, 497*f439973dSWarner Losh IN UINT8 Channel, 498*f439973dSWarner Losh IN UINT8 Device, 499*f439973dSWarner Losh IN EFI_ATA_COLLECTIVE_MODE *Modes 500*f439973dSWarner Losh ); 501*f439973dSWarner Losh 502*f439973dSWarner Losh /// 503*f439973dSWarner Losh /// Provides the basic interfaces to abstract an IDE controller. 504*f439973dSWarner Losh /// 505*f439973dSWarner Losh struct _EFI_IDE_CONTROLLER_INIT_PROTOCOL { 506*f439973dSWarner Losh /// 507*f439973dSWarner Losh /// Returns the information about a specific channel. 508*f439973dSWarner Losh /// 509*f439973dSWarner Losh EFI_IDE_CONTROLLER_GET_CHANNEL_INFO GetChannelInfo; 510*f439973dSWarner Losh 511*f439973dSWarner Losh /// 512*f439973dSWarner Losh /// The notification that the driver entity is about to enter the 513*f439973dSWarner Losh /// specified phase during the enumeration process. 514*f439973dSWarner Losh /// 515*f439973dSWarner Losh EFI_IDE_CONTROLLER_NOTIFY_PHASE NotifyPhase; 516*f439973dSWarner Losh 517*f439973dSWarner Losh /// 518*f439973dSWarner Losh /// Submits the Drive Identify data that was returned by the device. 519*f439973dSWarner Losh /// 520*f439973dSWarner Losh EFI_IDE_CONTROLLER_SUBMIT_DATA SubmitData; 521*f439973dSWarner Losh 522*f439973dSWarner Losh /// 523*f439973dSWarner Losh /// Submits information about modes that should be disqualified. The specified 524*f439973dSWarner Losh /// IDE device does not support these modes and these modes should not be 525*f439973dSWarner Losh /// returned by EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() 526*f439973dSWarner Losh /// 527*f439973dSWarner Losh EFI_IDE_CONTROLLER_DISQUALIFY_MODE DisqualifyMode; 528*f439973dSWarner Losh 529*f439973dSWarner Losh /// 530*f439973dSWarner Losh /// Calculates and returns the optimum mode for a particular IDE device. 531*f439973dSWarner Losh /// 532*f439973dSWarner Losh EFI_IDE_CONTROLLER_CALCULATE_MODE CalculateMode; 533*f439973dSWarner Losh 534*f439973dSWarner Losh /// 535*f439973dSWarner Losh /// Programs the IDE controller hardware to the default timing or per the modes 536*f439973dSWarner Losh /// that were returned by the last call to EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode(). 537*f439973dSWarner Losh /// 538*f439973dSWarner Losh EFI_IDE_CONTROLLER_SET_TIMING SetTiming; 539*f439973dSWarner Losh 540*f439973dSWarner Losh /// 541*f439973dSWarner Losh /// Set to TRUE if the enumeration group includes all the channels that are 542*f439973dSWarner Losh /// produced by this controller. Set to FALSE if an enumeration group consists of 543*f439973dSWarner Losh /// only one channel. 544*f439973dSWarner Losh /// 545*f439973dSWarner Losh BOOLEAN EnumAll; 546*f439973dSWarner Losh 547*f439973dSWarner Losh /// 548*f439973dSWarner Losh /// The number of channels that are produced by this controller. Parallel ATA 549*f439973dSWarner Losh /// (PATA) controllers can support up to two channels. Advanced Host Controller 550*f439973dSWarner Losh /// Interface (AHCI) Serial ATA (SATA) controllers can support up to 32 channels, 551*f439973dSWarner Losh /// each of which can have up to one device. In the presence of a multiplier, 552*f439973dSWarner Losh /// each channel can have fifteen devices. 553*f439973dSWarner Losh /// 554*f439973dSWarner Losh UINT8 ChannelCount; 555*f439973dSWarner Losh }; 556*f439973dSWarner Losh 557*f439973dSWarner Losh extern EFI_GUID gEfiIdeControllerInitProtocolGuid; 558*f439973dSWarner Losh 559*f439973dSWarner Losh #endif 560