2 Header file for IDE mode of ATA host controller.
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef __OPAL_PASSWORD_IDE_MODE_H__
18 #define __OPAL_PASSWORD_IDE_MODE_H__
48 // Bit definitions in Programming Interface byte of the Class Code field
49 // in PCI IDE controller's Configuration Space
51 #define IDE_PRIMARY_OPERATING_MODE BIT0
52 #define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
53 #define IDE_SECONDARY_OPERATING_MODE BIT2
54 #define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
57 Get IDE i/o port registers' base addresses by mode.
59 In 'Compatibility' mode, use fixed addresses.
60 In Native-PCI mode, get base addresses from BARs in the PCI IDE controller's
63 The steps to get IDE i/o port registers' base addresses for each channel
66 1. Examine the Programming Interface byte of the Class Code fields in PCI IDE
67 controller's Configuration Space to determine the operating mode.
69 2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.
70 ___________________________________________
71 | | Command Block | Control Block |
72 | Channel | Registers | Registers |
73 |___________|_______________|_______________|
74 | Primary | 1F0h - 1F7h | 3F6h - 3F7h |
75 |___________|_______________|_______________|
76 | Secondary | 170h - 177h | 376h - 377h |
77 |___________|_______________|_______________|
79 Table 1. Compatibility resource mappings
81 b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs
82 in IDE controller's PCI Configuration Space, shown in the Table 2 below.
83 ___________________________________________________
84 | | Command Block | Control Block |
85 | Channel | Registers | Registers |
86 |___________|___________________|___________________|
87 | Primary | BAR at offset 0x10| BAR at offset 0x14|
88 |___________|___________________|___________________|
89 | Secondary | BAR at offset 0x18| BAR at offset 0x1C|
90 |___________|___________________|___________________|
92 Table 2. BARs for Register Mapping
94 @param[in] Bus The bus number of ata host controller.
95 @param[in] Device The device number of ata host controller.
96 @param[in] Function The function number of ata host controller.
97 @param[in, out] IdeRegisters Pointer to EFI_IDE_REGISTERS which is used to
98 store the IDE i/o port registers' base addresses
100 @retval EFI_UNSUPPORTED Return this Value when the BARs is not IO type
101 @retval EFI_SUCCESS Get the Base address successfully
102 @retval Other Read the pci configureation Data error
107 GetIdeRegisterIoAddr (
111 IN OUT EFI_IDE_REGISTERS
*IdeRegisters
115 Sends out an ATA Identify Command to the specified device.
117 This function sends out the ATA Identify Command to the
118 specified device. Only ATA device responses to this command. If
119 the command succeeds, it returns the Identify Data structure which
120 contains information about the device. This function extracts the
121 information it needs to fill the IDE_BLK_IO_DEV Data structure,
122 including device type, media block Size, media capacity, and etc.
124 @param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
125 @param Channel The channel number of device.
126 @param Device The device number of device.
127 @param Buffer A pointer to Data Buffer which is used to contain IDENTIFY Data.
129 @retval EFI_SUCCESS Identify ATA device successfully.
130 @retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.
131 @retval EFI_OUT_OF_RESOURCES Allocate memory failed.
136 IN EFI_IDE_REGISTERS
*IdeRegisters
,
139 IN OUT ATA_IDENTIFY_DATA
*Buffer
143 This function is used to send out ATA commands conforms to the PIO Data In Protocol.
145 @param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
146 @param Buffer A pointer to the source Buffer for the Data.
147 @param ByteCount The Length of the Data.
148 @param Read Flag used to determine the Data transfer direction.
149 Read equals 1, means Data transferred from device to host;
150 Read equals 0, means Data transferred from host to device.
151 @param AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK Data structure.
152 @param AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK Data structure.
153 @param Timeout The time to complete the command.
155 @retval EFI_SUCCESS send out the ATA command and device send required Data successfully.
156 @retval EFI_DEVICE_ERROR command sent failed.
162 IN EFI_IDE_REGISTERS
*IdeRegisters
,
166 IN EFI_ATA_COMMAND_BLOCK
*AtaCommandBlock
,
167 IN OUT EFI_ATA_STATUS_BLOCK
*AtaStatusBlock
,