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