2 Header file for IDE mode of ATA host controller.
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 #ifndef __ATA_HC_IDE_MODE_H__
9 #define __ATA_HC_IDE_MODE_H__
24 /// PIO mode definition
34 // Multi word DMA definition
43 // UDMA mode definition
57 #define BMIC_NREAD BIT3
58 #define BMIC_START BIT0
59 #define BMIS_INTERRUPT BIT2
60 #define BMIS_ERROR BIT1
62 #define BMIC_OFFSET 0x00
63 #define BMIS_OFFSET 0x02
64 #define BMID_OFFSET 0x04
69 #define EFI_ATA_MODE_DEFAULT_PIO 0x00
70 #define EFI_ATA_MODE_FLOW_PIO 0x01
71 #define EFI_ATA_MODE_MDMA 0x04
72 #define EFI_ATA_MODE_UDMA 0x08
75 UINT32 RegionBaseAddr
;
82 UINT8 ModeCategory
: 5;
83 } EFI_ATA_TRANSFER_MODE
;
89 } EFI_ATA_DRIVE_PARMS
;
105 UINT16 BusMasterBaseAddr
;
109 // Bit definitions in Programming Interface byte of the Class Code field
110 // in PCI IDE controller's Configuration Space
112 #define IDE_PRIMARY_OPERATING_MODE BIT0
113 #define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
114 #define IDE_SECONDARY_OPERATING_MODE BIT2
115 #define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
118 Get IDE i/o port registers' base addresses by mode.
120 In 'Compatibility' mode, use fixed addresses.
121 In Native-PCI mode, get base addresses from BARs in the PCI IDE controller's
124 The steps to get IDE i/o port registers' base addresses for each channel
127 1. Examine the Programming Interface byte of the Class Code fields in PCI IDE
128 controller's Configuration Space to determine the operating mode.
130 2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.
131 ___________________________________________
132 | | Command Block | Control Block |
133 | Channel | Registers | Registers |
134 |___________|_______________|_______________|
135 | Primary | 1F0h - 1F7h | 3F6h - 3F7h |
136 |___________|_______________|_______________|
137 | Secondary | 170h - 177h | 376h - 377h |
138 |___________|_______________|_______________|
140 Table 1. Compatibility resource mappings
142 b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs
143 in IDE controller's PCI Configuration Space, shown in the Table 2 below.
144 ___________________________________________________
145 | | Command Block | Control Block |
146 | Channel | Registers | Registers |
147 |___________|___________________|___________________|
148 | Primary | BAR at offset 0x10| BAR at offset 0x14|
149 |___________|___________________|___________________|
150 | Secondary | BAR at offset 0x18| BAR at offset 0x1C|
151 |___________|___________________|___________________|
153 Table 2. BARs for Register Mapping
155 @param[in] PciIo Pointer to the EFI_PCI_IO_PROTOCOL instance
156 @param[in, out] IdeRegisters Pointer to EFI_IDE_REGISTERS which is used to
157 store the IDE i/o port registers' base addresses
159 @retval EFI_UNSUPPORTED Return this value when the BARs is not IO type
160 @retval EFI_SUCCESS Get the Base address successfully
161 @retval Other Read the pci configureation data error
166 GetIdeRegisterIoAddr (
167 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
168 IN OUT EFI_IDE_REGISTERS
*IdeRegisters
172 This function is used to send out ATAPI commands conforms to the Packet Command
173 with PIO Data In Protocol.
175 @param[in] PciIo Pointer to the EFI_PCI_IO_PROTOCOL instance
176 @param[in] IdeRegisters Pointer to EFI_IDE_REGISTERS which is used to
177 store the IDE i/o port registers' base addresses
178 @param[in] Channel The channel number of device.
179 @param[in] Device The device number of device.
180 @param[in] Packet A pointer to EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET data structure.
182 @retval EFI_SUCCESS send out the ATAPI packet command successfully
183 and device sends data successfully.
184 @retval EFI_DEVICE_ERROR the device failed to send data.
189 AtaPacketCommandExecute (
190 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
191 IN EFI_IDE_REGISTERS
*IdeRegisters
,
194 IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet