Path: blob/main/sys/contrib/edk2/Include/Protocol/IdeControllerInit.h
96339 views
/** @file1This file declares EFI IDE Controller Init Protocol23The EFI_IDE_CONTROLLER_INIT_PROTOCOL provides the chipset-specific information4to the driver entity. This protocol is mandatory for IDE controllers if the5IDE devices behind the controller are to be enumerated by a driver entity.67There can only be one instance of EFI_IDE_CONTROLLER_INIT_PROTOCOL for each IDE8controller in a system. It is installed on the handle that corresponds to the9IDE controller. A driver entity that wishes to manage an IDE bus and possibly10IDE devices in a system will have to retrieve the EFI_IDE_CONTROLLER_INIT_PROTOCOL11instance that is associated with the controller to be managed.1213A device handle for an IDE controller must contain an EFI_DEVICE_PATH_PROTOCOL.1415Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>16SPDX-License-Identifier: BSD-2-Clause-Patent1718@par Revision Reference:19This Protocol is defined in UEFI Platform Initialization Specification 1.220Volume 5: Standards.2122**/2324#ifndef _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H_25#define _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H_2627#include <IndustryStandard/Atapi.h>2829///30/// Global ID for the EFI_IDE_CONTROLLER_INIT_PROTOCOL.31///32#define EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID \33{ \340xa1e37052, 0x80d9, 0x4e65, {0xa3, 0x17, 0x3e, 0x9a, 0x55, 0xc4, 0x3e, 0xc9 } \35}3637///38/// Forward declaration for EFI_IDE_CONTROLLER_INIT_PROTOCOL.39///40typedef struct _EFI_IDE_CONTROLLER_INIT_PROTOCOL EFI_IDE_CONTROLLER_INIT_PROTOCOL;4142///43/// The phase of the IDE Controller enumeration.44///45typedef enum {46///47/// The driver entity is about to begin enumerating the devices48/// behind the specified channel. This notification can be used to49/// perform any chipset-specific programming.50///51EfiIdeBeforeChannelEnumeration,52///53/// The driver entity has completed enumerating the devices54/// behind the specified channel. This notification can be used to55/// perform any chipset-specific programming.56///57EfiIdeAfterChannelEnumeration,58///59/// The driver entity is about to reset the devices behind the60/// specified channel. This notification can be used to perform any61/// chipset-specific programming.62///63EfiIdeBeforeChannelReset,64///65/// The driver entity has completed resetting the devices behind66/// the specified channel. This notification can be used to perform67/// any chipset-specific programming.68///69EfiIdeAfterChannelReset,70///71/// The driver entity is about to detect the presence of devices72/// behind the specified channel. This notification can be used to73/// set up the bus signals to default levels or for implementing74/// predelays.75///76EfiIdeBusBeforeDevicePresenceDetection,77///78/// The driver entity is done with detecting the presence of79/// devices behind the specified channel. This notification can be80/// used to perform any chipset-specific programming.81///82EfiIdeBusAfterDevicePresenceDetection,83///84/// The IDE bus is requesting the IDE controller driver to85/// reprogram the IDE controller hardware and thereby reset all86/// the mode and timing settings to default settings.87///88EfiIdeResetMode,89EfiIdeBusPhaseMaximum90} EFI_IDE_CONTROLLER_ENUM_PHASE;9192///93/// This extended mode describes the SATA physical protocol.94/// SATA physical layers can operate at different speeds.95/// These speeds are defined below. Various PATA protocols96/// and associated modes are not applicable to SATA devices.97///98typedef enum {99EfiAtaSataTransferProtocol100} EFI_ATA_EXT_TRANSFER_PROTOCOL;101102///103/// Automatically detects the optimum SATA speed.104///105#define EFI_SATA_AUTO_SPEED 0106107///108/// Indicates a first-generation (Gen1) SATA speed.109///110#define EFI_SATA_GEN1_SPEED 1111112///113/// Indicates a second-generation (Gen2) SATA speed.114///115#define EFI_SATA_GEN2_SPEED 2116117///118/// EFI_ATA_MODE structure.119///120typedef struct {121BOOLEAN Valid; ///< TRUE if Mode is valid.122UINT32 Mode; ///< The actual ATA mode. This field is not a bit map.123} EFI_ATA_MODE;124125///126/// EFI_ATA_EXTENDED_MODE structure127///128typedef struct {129///130/// An enumeration defining various transfer protocols other than the protocols131/// that exist at the time this specification was developed (i.e., PIO, single132/// word DMA, multiword DMA, and UDMA). Each transfer protocol is associated133/// with a mode. The various transfer protocols are defined by the ATA/ATAPI134/// specification. This enumeration makes the interface extensible because we135/// can support new transport protocols beyond UDMA. Type EFI_ATA_EXT_TRANSFER_PROTOCOL136/// is defined below.137///138EFI_ATA_EXT_TRANSFER_PROTOCOL TransferProtocol;139///140/// The mode for operating the transfer protocol that is identified by TransferProtocol.141///142UINT32 Mode;143} EFI_ATA_EXTENDED_MODE;144145///146/// EFI_ATA_COLLECTIVE_MODE structure.147///148typedef struct {149///150/// This field specifies the PIO mode. PIO modes are defined in the ATA/ATAPI151/// specification. The ATA/ATAPI specification defines the enumeration. In152/// other words, a value of 1 in this field means PIO mode 1. The actual meaning153/// of PIO mode 1 is governed by the ATA/ATAPI specification. Type EFI_ATA_MODE154/// is defined below.155///156EFI_ATA_MODE PioMode;157///158/// This field specifies the single word DMA mode. Single word DMA modes are defined159/// in the ATA/ATAPI specification, versions 1 and 2. Single word DMA support was160/// obsoleted in the ATA/ATAPI specification, version 3. Therefore, most devices and161/// controllers will not support this transfer mode. The ATA/ATAPI specification defines162/// the enumeration. In other words, a value of 1 in this field means single word DMA163/// mode 1. The actual meaning of single word DMA mode 1 is governed by the ATA/164/// ATAPI specification.165///166EFI_ATA_MODE SingleWordDmaMode;167///168/// This field specifies the multiword DMA mode. Various multiword DMA modes are169/// defined in the ATA/ATAPI specification. A value of 1 in this field means multiword170/// DMA mode 1. The actual meaning of multiword DMA mode 1 is governed by the171/// ATA/ATAPI specification.172///173EFI_ATA_MODE MultiWordDmaMode;174///175/// This field specifies the ultra DMA (UDMA) mode. UDMA modes are defined in the176/// ATA/ATAPI specification. A value of 1 in this field means UDMA mode 1. The177/// actual meaning of UDMA mode 1 is governed by the ATA/ATAPI specification.178///179EFI_ATA_MODE UdmaMode;180///181/// The number of extended-mode bitmap entries. Extended modes describe transfer182/// protocols beyond PIO, single word DMA, multiword DMA, and UDMA. This field183/// can be zero and provides extensibility.184///185UINT32 ExtModeCount;186///187/// ExtModeCount number of entries. Each entry represents a transfer protocol other188/// than the ones defined above (i.e., PIO, single word DMA, multiword DMA, and189/// UDMA). This field is defined for extensibility. At this time, only one extended190/// transfer protocol is defined to cover SATA transfers. Type191/// EFI_ATA_EXTENDED_MODE is defined below.192///193EFI_ATA_EXTENDED_MODE ExtMode[1];194} EFI_ATA_COLLECTIVE_MODE;195196///197/// EFI_ATA_IDENTIFY_DATA & EFI_ATAPI_IDENTIFY_DATA structure198///199/// The definition of these two structures is not part of the protocol200/// definition because the ATA/ATAPI Specification controls the definition201/// of all the fields. The ATA/ATAPI Specification can obsolete old fields202/// or redefine existing fields.203typedef ATA_IDENTIFY_DATA EFI_ATA_IDENTIFY_DATA;204typedef ATAPI_IDENTIFY_DATA EFI_ATAPI_IDENTIFY_DATA;205206///207/// This flag indicates whether the IDENTIFY data is a response from an ATA device208/// (EFI_ATA_IDENTIFY_DATA) or response from an ATAPI device209/// (EFI_ATAPI_IDENTIFY_DATA). According to the ATA/ATAPI specification,210/// EFI_IDENTIFY_DATA is for an ATA device if bit 15 of the Config field is zero.211/// The Config field is common to both EFI_ATA_IDENTIFY_DATA and212/// EFI_ATAPI_IDENTIFY_DATA.213///214#define EFI_ATAPI_DEVICE_IDENTIFY_DATA 0x8000215216///217/// EFI_IDENTIFY_DATA structure.218///219typedef union {220///221/// The data that is returned by an ATA device upon successful completion222/// of the ATA IDENTIFY_DEVICE command.223///224EFI_ATA_IDENTIFY_DATA AtaData;225///226/// The data that is returned by an ATAPI device upon successful completion227/// of the ATA IDENTIFY_PACKET_DEVICE command.228///229EFI_ATAPI_IDENTIFY_DATA AtapiData;230} EFI_IDENTIFY_DATA;231232/**233Returns the information about the specified IDE channel.234235This function can be used to obtain information about a particular IDE channel.236The driver entity uses this information during the enumeration process.237238If Enabled is set to FALSE, the driver entity will not scan the channel. Note239that it will not prevent an operating system driver from scanning the channel.240241For most of today's controllers, MaxDevices will either be 1 or 2. For SATA242controllers, this value will always be 1. SATA configurations can contain SATA243port multipliers. SATA port multipliers behave like SATA bridges and can support244up to 16 devices on the other side. If a SATA port out of the IDE controller245is connected to a port multiplier, MaxDevices will be set to the number of SATA246devices that the port multiplier supports. Because today's port multipliers247support up to fifteen SATA devices, this number can be as large as fifteen. The IDE248bus driver is required to scan for the presence of port multipliers behind an SATA249controller and enumerate up to MaxDevices number of devices behind the port250multiplier.251252In this context, the devices behind a port multiplier constitute a channel.253254@param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.255@param[in] Channel Zero-based channel number.256@param[out] Enabled TRUE if this channel is enabled. Disabled channels257are not scanned to see if any devices are present.258@param[out] MaxDevices The maximum number of IDE devices that the bus driver259can expect on this channel. For the ATA/ATAPI260specification, version 6, this number will either be261one or two. For Serial ATA (SATA) configurations with a262port multiplier, this number can be as large as fifteen.263264@retval EFI_SUCCESS Information was returned without any errors.265@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).266267**/268typedef269EFI_STATUS270(EFIAPI *EFI_IDE_CONTROLLER_GET_CHANNEL_INFO)(271IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,272IN UINT8 Channel,273OUT BOOLEAN *Enabled,274OUT UINT8 *MaxDevices275);276277/**278The notifications from the driver entity that it is about to enter a certain279phase of the IDE channel enumeration process.280281This function can be used to notify the IDE controller driver to perform282specific actions, including any chipset-specific initialization, so that the283chipset is ready to enter the next phase. Seven notification points are defined284at this time.285286More synchronization points may be added as required in the future.287288@param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.289@param[in] Phase The phase during enumeration.290@param[in] Channel Zero-based channel number.291292@retval EFI_SUCCESS The notification was accepted without any errors.293@retval EFI_UNSUPPORTED Phase is not supported.294@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).295@retval EFI_NOT_READY This phase cannot be entered at this time; for296example, an attempt was made to enter a Phase297without having entered one or more previous298Phase.299300**/301typedef302EFI_STATUS303(EFIAPI *EFI_IDE_CONTROLLER_NOTIFY_PHASE)(304IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,305IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,306IN UINT8 Channel307);308309/**310Submits the device information to the IDE controller driver.311312This function is used by the driver entity to pass detailed information about313a particular device to the IDE controller driver. The driver entity obtains314this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData315is the pointer to the response data buffer. The IdentifyData buffer is owned316by the driver entity, and the IDE controller driver must make a local copy317of the entire buffer or parts of the buffer as needed. The original IdentifyData318buffer pointer may not be valid when319320- EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or321- EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point.322323The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to324compute the optimum mode for the device. These fields are not limited to the325timing information. For example, an implementation of the IDE controller driver326may examine the vendor and type/mode field to match known bad drives.327328The driver entity may submit drive information in any order, as long as it329submits information for all the devices belonging to the enumeration group330before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device331in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()332should be called with IdentifyData set to NULL. The IDE controller driver may333not have any other mechanism to know whether a device is present or not. Therefore,334setting IdentifyData to NULL does not constitute an error condition.335EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a336given (Channel, Device) pair.337338@param[in] This A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.339@param[in] Channel Zero-based channel number.340@param[in] Device Zero-based device number on the Channel.341@param[in] IdentifyData The device's response to the ATA IDENTIFY_DEVICE command.342343@retval EFI_SUCCESS The information was accepted without any errors.344@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).345@retval EFI_INVALID_PARAMETER Device is invalid.346347**/348typedef349EFI_STATUS350(EFIAPI *EFI_IDE_CONTROLLER_SUBMIT_DATA)(351IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,352IN UINT8 Channel,353IN UINT8 Device,354IN EFI_IDENTIFY_DATA *IdentifyData355);356357/**358Disqualifies specific modes for an IDE device.359360This function allows the driver entity or other drivers (such as platform361drivers) to reject certain timing modes and request the IDE controller driver362to recalculate modes. This function allows the driver entity and the IDE363controller driver to negotiate the timings on a per-device basis. This function364is useful in the case of drives that lie about their capabilities. An example365is when the IDE device fails to accept the timing modes that are calculated366by the IDE controller driver based on the response to the Identify Drive command.367368If the driver entity does not want to limit the ATA timing modes and leave that369decision to the IDE controller driver, it can either not call this function for370the given device or call this function and set the Valid flag to FALSE for all371modes that are listed in EFI_ATA_COLLECTIVE_MODE.372373The driver entity may disqualify modes for a device in any order and any number374of times.375376This function can be called multiple times to invalidate multiple modes of the377same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI378specification for more information on PIO modes.379380For Serial ATA (SATA) controllers, this member function can be used to disqualify381a higher transfer rate mode on a given channel. For example, a platform driver382may inform the IDE controller driver to not use second-generation (Gen2) speeds383for a certain SATA drive.384385@param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.386@param[in] Channel The zero-based channel number.387@param[in] Device The zero-based device number on the Channel.388@param[in] BadModes The modes that the device does not support and that389should be disqualified.390391@retval EFI_SUCCESS The modes were accepted without any errors.392@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).393@retval EFI_INVALID_PARAMETER Device is invalid.394@retval EFI_INVALID_PARAMETER IdentifyData is NULL.395396**/397typedef398EFI_STATUS399(EFIAPI *EFI_IDE_CONTROLLER_DISQUALIFY_MODE)(400IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,401IN UINT8 Channel,402IN UINT8 Device,403IN EFI_ATA_COLLECTIVE_MODE *BadModes404);405406/**407Returns the information about the optimum modes for the specified IDE device.408409This function is used by the driver entity to obtain the optimum ATA modes for410a specific device. The IDE controller driver takes into account the following411while calculating the mode:412- The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()413- The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode()414415The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()416for all the devices that belong to an enumeration group before calling417EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group.418419The IDE controller driver will use controller- and possibly platform-specific420algorithms to arrive at SupportedModes. The IDE controller may base its421decision on user preferences and other considerations as well. This function422may be called multiple times because the driver entity may renegotiate the mode423with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode().424425The driver entity may collect timing information for various devices in any426order. The driver entity is responsible for making sure that all the dependencies427are satisfied. For example, the SupportedModes information for device A that428was previously returned may become stale after a call to429EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B.430431The buffer SupportedModes is allocated by the callee because the caller does432not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE433is defined in a way that allows for future extensibility and can be of variable434length. This memory pool should be deallocated by the caller when it is no435longer necessary.436437The IDE controller driver for a Serial ATA (SATA) controller can use this438member function to force a lower speed (first-generation [Gen1] speeds on a439second-generation [Gen2]-capable hardware). The IDE controller driver can440also allow the driver entity to stay with the speed that has been negotiated441by the physical layer.442443@param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.444@param[in] Channel A zero-based channel number.445@param[in] Device A zero-based device number on the Channel.446@param[out] SupportedModes The optimum modes for the device.447448@retval EFI_SUCCESS SupportedModes was returned.449@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).450@retval EFI_INVALID_PARAMETER Device is invalid.451@retval EFI_INVALID_PARAMETER SupportedModes is NULL.452@retval EFI_NOT_READY Modes cannot be calculated due to a lack of453data. This error may happen if454EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData()455and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData()456were not called for at least one drive in the457same enumeration group.458459**/460typedef461EFI_STATUS462(EFIAPI *EFI_IDE_CONTROLLER_CALCULATE_MODE)(463IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,464IN UINT8 Channel,465IN UINT8 Device,466OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes467);468469/**470Commands the IDE controller driver to program the IDE controller hardware471so that the specified device can operate at the specified mode.472473This function is used by the driver entity to instruct the IDE controller474driver to program the IDE controller hardware to the specified modes. This475function can be called only once for a particular device. For a Serial ATA476(SATA) Advanced Host Controller Interface (AHCI) controller, no controller-477specific programming may be required.478479@param[in] This Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance.480@param[in] Channel Zero-based channel number.481@param[in] Device Zero-based device number on the Channel.482@param[in] Modes The modes to set.483484@retval EFI_SUCCESS The command was accepted without any errors.485@retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount).486@retval EFI_INVALID_PARAMETER Device is invalid.487@retval EFI_NOT_READY Modes cannot be set at this time due to lack of data.488@retval EFI_DEVICE_ERROR Modes cannot be set due to hardware failure.489The driver entity should not use this device.490491**/492typedef493EFI_STATUS494(EFIAPI *EFI_IDE_CONTROLLER_SET_TIMING)(495IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,496IN UINT8 Channel,497IN UINT8 Device,498IN EFI_ATA_COLLECTIVE_MODE *Modes499);500501///502/// Provides the basic interfaces to abstract an IDE controller.503///504struct _EFI_IDE_CONTROLLER_INIT_PROTOCOL {505///506/// Returns the information about a specific channel.507///508EFI_IDE_CONTROLLER_GET_CHANNEL_INFO GetChannelInfo;509510///511/// The notification that the driver entity is about to enter the512/// specified phase during the enumeration process.513///514EFI_IDE_CONTROLLER_NOTIFY_PHASE NotifyPhase;515516///517/// Submits the Drive Identify data that was returned by the device.518///519EFI_IDE_CONTROLLER_SUBMIT_DATA SubmitData;520521///522/// Submits information about modes that should be disqualified. The specified523/// IDE device does not support these modes and these modes should not be524/// returned by EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode()525///526EFI_IDE_CONTROLLER_DISQUALIFY_MODE DisqualifyMode;527528///529/// Calculates and returns the optimum mode for a particular IDE device.530///531EFI_IDE_CONTROLLER_CALCULATE_MODE CalculateMode;532533///534/// Programs the IDE controller hardware to the default timing or per the modes535/// that were returned by the last call to EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode().536///537EFI_IDE_CONTROLLER_SET_TIMING SetTiming;538539///540/// Set to TRUE if the enumeration group includes all the channels that are541/// produced by this controller. Set to FALSE if an enumeration group consists of542/// only one channel.543///544BOOLEAN EnumAll;545546///547/// The number of channels that are produced by this controller. Parallel ATA548/// (PATA) controllers can support up to two channels. Advanced Host Controller549/// Interface (AHCI) Serial ATA (SATA) controllers can support up to 32 channels,550/// each of which can have up to one device. In the presence of a multiplier,551/// each channel can have fifteen devices.552///553UINT8 ChannelCount;554};555556extern EFI_GUID gEfiIdeControllerInitProtocolGuid;557558#endif559560561