ScsiIo.h revision 1f08a159034549216eccfd533b50b712d944d844
1/** @file 2 EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0. 3 This protocol is used by code, typically drivers, running in the EFI boot 4 services environment to access SCSI devices. In particular, functions for 5 managing devices on SCSI buses are defined here. 6 7 Copyright (c) 2006 - 2008, Intel Corporation 8 All rights reserved. This program and the accompanying materials 9 are licensed and made available under the terms and conditions of the BSD License 10 which accompanies this distribution. The full text of the license may be found at 11 http://opensource.org/licenses/bsd-license.php 12 13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 15 16**/ 17 18#ifndef __EFI_SCSI_IO_PROTOCOL_H__ 19#define __EFI_SCSI_IO_PROTOCOL_H__ 20 21#define EFI_SCSI_IO_PROTOCOL_GUID \ 22 { \ 23 0x932f4736, 0x2362, 0x4002, {0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \ 24 } 25 26/// 27/// Forward reference for pure ANSI compatability 28/// 29typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL; 30 31// 32// SCSI Data Direction definition 33// 34#define EFI_SCSI_IO_DATA_DIRECTION_READ 0 35#define EFI_SCSI_IO_DATA_DIRECTION_WRITE 1 36#define EFI_SCSI_IO_DATA_DIRECTION_BIDIRECTIONAL 2 37 38// 39// SCSI Host Adapter Status definition 40// 41#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OK 0x00 42#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 // timeout when processing the command 43#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT 0x0b // timeout when waiting for the command processing 44#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d // a message reject was received when processing command 45#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_RESET 0x0e // a bus reset was detected 46#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f 47#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 // the adapter failed in issuing request sense command 48#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 // selection timeout 49#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 // data overrun or data underrun 50#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_FREE 0x13 // Unexepected bus free 51#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 // Target bus phase sequence failure 52#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OTHER 0x7f 53 54 55// 56// SCSI Target Status definition 57// 58#define EFI_SCSI_IO_STATUS_TARGET_GOOD 0x00 59#define EFI_SCSI_IO_STATUS_TARGET_CHECK_CONDITION 0x02 // check condition 60#define EFI_SCSI_IO_STATUS_TARGET_CONDITION_MET 0x04 // condition met 61#define EFI_SCSI_IO_STATUS_TARGET_BUSY 0x08 // busy 62#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE 0x10 // intermediate 63#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 // intermediate-condition met 64#define EFI_SCSI_IO_STATUS_TARGET_RESERVATION_CONFLICT 0x18 // reservation conflict 65#define EFI_SCSI_IO_STATUS_TARGET_COMMOND_TERMINATED 0x22 // command terminated 66#define EFI_SCSI_IO_STATUS_TARGET_QUEUE_FULL 0x28 // queue full 67 68typedef struct { 69 UINT64 Timeout; 70 VOID *InDataBuffer; 71 VOID *OutDataBuffer; 72 VOID *SenseData; 73 VOID *Cdb; 74 UINT32 InTransferLength; 75 UINT32 OutTransferLength; 76 UINT8 CdbLength; 77 UINT8 DataDirection; 78 UINT8 HostAdapterStatus; 79 UINT8 TargetStatus; 80 UINT8 SenseDataLength; 81} EFI_SCSI_IO_SCSI_REQUEST_PACKET; 82 83/** 84 Retrieves the device type information of the SCSI Controller. 85 86 @param This Protocol instance pointer. 87 @param DeviceType A pointer to the device type information 88 retrieved from the SCSI Controller. 89 90 @retval EFI_SUCCESS Retrieves the device type information successfully. 91 @retval EFI_INVALID_PARAMETER The DeviceType is NULL. 92 93**/ 94typedef 95EFI_STATUS 96(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE)( 97 IN EFI_SCSI_IO_PROTOCOL *This, 98 OUT UINT8 *DeviceType 99 ); 100 101/** 102 Retrieves the device location in the SCSI channel. 103 104 @param This Protocol instance pointer. 105 @param Target A pointer to the Target ID of a SCSI device 106 on the SCSI channel. 107 @param Lun A pointer to the LUN of the SCSI device on 108 the SCSI channel. 109 110 @retval EFI_SUCCESS Retrieves the device location successfully. 111 @retval EFI_INVALID_PARAMETER The Target or Lun is NULL. 112 113**/ 114typedef 115EFI_STATUS 116(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION)( 117 IN EFI_SCSI_IO_PROTOCOL *This, 118 IN OUT UINT8 **Target, 119 OUT UINT64 *Lun 120 ); 121 122/** 123 Resets the SCSI Bus that the SCSI Controller is attached to. 124 125 @param This Protocol instance pointer. 126 127 @retval EFI_SUCCESS The SCSI bus is reset successfully. 128 @retval EFI_DEVICE_ERROR Errors encountered when resetting the SCSI bus. 129 @retval EFI_UNSUPPORTED The bus reset operation is not supported by the 130 SCSI Host Controller. 131 @retval EFI_TIMEOUT A timeout occurred while attempting to reset 132 the SCSI bus. 133 134**/ 135typedef 136EFI_STATUS 137(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_BUS)( 138 IN EFI_SCSI_IO_PROTOCOL *This 139 ); 140 141/** 142 Resets the SCSI Controller that the device handle specifies. 143 144 @param This Protocol instance pointer. 145 146 @retval EFI_SUCCESS Reset the SCSI controller successfully. 147 @retval EFI_DEVICE_ERROR Errors are encountered when resetting the 148 SCSI Controller. 149 @retval EFI_UNSUPPORTED The SCSI bus does not support a device 150 reset operation. 151 @retval EFI_TIMEOUT A timeout occurred while attempting to 152 reset the SCSI Controller. 153 154**/ 155typedef 156EFI_STATUS 157(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_DEVICE)( 158 IN EFI_SCSI_IO_PROTOCOL *This 159 ); 160 161 162/** 163 Sends a SCSI Request Packet to the SCSI Controller for execution. 164 165 @param This Protocol instance pointer. 166 @param Packet The SCSI request packet to send to the SCSI 167 Controller specified by the device handle. 168 @param Event If the SCSI bus where the SCSI device is attached 169 does not support non-blocking I/O, then Event is 170 ignored, and blocking I/O is performed. 171 If Event is NULL, then blocking I/O is performed. 172 If Event is not NULL and non-blocking I/O is 173 supported, then non-blocking I/O is performed, 174 and Event will be signaled when the SCSI Request 175 Packet completes. 176 177 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host 178 successfully, and TransferLength bytes were 179 transferred to/from DataBuffer.See 180 HostAdapterStatus, TargetStatus, 181 SenseDataLength, and SenseData in that order 182 for additional status information. 183 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, 184 but the entire DataBuffer could not be transferred. 185 The actual number of bytes transferred is returned 186 in TransferLength. See HostAdapterStatus, 187 TargetStatus, SenseDataLength, and SenseData in 188 that order for additional status information. 189 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because 190 there are too many SCSI Command Packets already 191 queued.The caller may retry again later. 192 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send 193 the SCSI Request Packet. See HostAdapterStatus, 194 TargetStatus, SenseDataLength, and SenseData in 195 that order for additional status information. 196 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid. 197 The SCSI Request Packet was not sent, so no 198 additional status information is available. 199 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet 200 is not supported by the SCSI initiator(i.e., SCSI 201 Host Controller). The SCSI Request Packet was not 202 sent, so no additional status information is 203 available. 204 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI 205 Request Packet to execute. See HostAdapterStatus, 206 TargetStatus, SenseDataLength, and SenseData in 207 that order for additional status information. 208 209**/ 210typedef 211EFI_STATUS 212(EFIAPI *EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND)( 213 IN EFI_SCSI_IO_PROTOCOL *This, 214 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet, 215 IN EFI_EVENT Event OPTIONAL 216 ); 217 218/** 219 @par Protocol Description: 220 Provides services to manage and communicate with SCSI devices. 221**/ 222struct _EFI_SCSI_IO_PROTOCOL { 223 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE GetDeviceType; 224 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION GetDeviceLocation; 225 EFI_SCSI_IO_PROTOCOL_RESET_BUS ResetBus; 226 EFI_SCSI_IO_PROTOCOL_RESET_DEVICE ResetDevice; 227 EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND ExecuteScsiCommand; 228 229 /// 230 /// Supplies the alignment requirement for any buffer used in a data transfer. 231 /// IoAlign values of 0 and 1 mean that the buffer can be placed anywhere in memory. 232 /// Otherwise, IoAlign must be a power of 2, and the requirement is that the 233 /// start address of a buffer must be evenly divisible by IoAlign with no remainder. 234 /// 235 UINT32 IoAlign; 236}; 237 238extern EFI_GUID gEfiScsiIoProtocolGuid; 239 240#endif 241