Home | History | Annotate | Download | only in ScsiPassThruExt
      1 /*++
      2 
      3   Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
      4   This program and the accompanying materials
      5   are licensed and made available under the terms and conditions of the BSD License
      6   which accompanies this distribution.  The full text of the license may be found at
      7   http://opensource.org/licenses/bsd-license.php
      8 
      9   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     10   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     11 
     12 Module Name:
     13 
     14     ScsiPassThruExt.h
     15 
     16 Abstract:
     17   EFI_EXT_SCSI_PASS_THRU_PROTOCOL as defined in UEFI 2.0.
     18 
     19 Revision History
     20 
     21 --*/
     22 
     23 #ifndef __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__
     24 #define __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__
     25 
     26 #define EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID \
     27   { \
     28     0x143b7632, 0xb81b, 0x4cb7, {0xab, 0xd3, 0xb6, 0x25, 0xa5, 0xb9, 0xbf, 0xfe } \
     29   }
     30 
     31 typedef struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL EFI_EXT_SCSI_PASS_THRU_PROTOCOL;
     32 
     33 #define TARGET_MAX_BYTES                             0x10
     34 
     35 #define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL   0x0001
     36 #define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL    0x0002
     37 #define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004
     38 
     39 //
     40 // DataDirection
     41 //
     42 #define EFI_EXT_SCSI_DATA_DIRECTION_READ             0
     43 #define EFI_EXT_SCSI_DATA_DIRECTION_WRITE            1
     44 #define EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL    2
     45 //
     46 // HostAdapterStatus
     47 //
     48 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK                    0x00
     49 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND       0x09
     50 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT               0x0b
     51 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT        0x0d
     52 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_RESET             0x0e
     53 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR          0x0f
     54 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED  0x10
     55 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT     0x11
     56 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12
     57 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_FREE              0x13
     58 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR           0x14
     59 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER                 0x7f
     60 //
     61 // TargetStatus
     62 //
     63 #define EFI_EXT_SCSI_STATUS_TARGET_GOOD                        0x00
     64 #define EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION             0x02
     65 #define EFI_EXT_SCSI_STATUS_TARGET_CONDITION_MET               0x04
     66 #define EFI_EXT_SCSI_STATUS_TARGET_BUSY                        0x08
     67 #define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE                0x10
     68 #define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET  0x14
     69 #define EFI_EXT_SCSI_STATUS_TARGET_RESERVATION_CONFLICT        0x18
     70 #define EFI_EXT_SCSI_STATUS_TARGET_TASK_SET_FULL               0x28
     71 #define EFI_EXT_SCSI_STATUS_TARGET_ACA_ACTIVE                  0x30
     72 #define EFI_EXT_SCSI_STATUS_TARGET_TASK_ABORTED                0x40
     73 
     74 typedef struct {
     75   UINT32 AdapterId;
     76   UINT32 Attributes;
     77   UINT32 IoAlign;
     78 } EFI_EXT_SCSI_PASS_THRU_MODE;
     79 
     80 typedef struct {
     81   UINT64 Timeout;
     82   VOID   *InDataBuffer;
     83   VOID   *OutDataBuffer;
     84   VOID   *SenseData;
     85   VOID   *Cdb;
     86   UINT32 InTransferLength;
     87   UINT32 OutTransferLength;
     88   UINT8  CdbLength;
     89   UINT8  DataDirection;
     90   UINT8  HostAdapterStatus;
     91   UINT8  TargetStatus;
     92   UINT8  SenseDataLength;
     93 } EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET;
     94 
     95 typedef
     96 EFI_STATUS
     97 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_PASSTHRU) (
     98   IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL                *This,
     99   IN UINT8                                          *Target,
    100   IN UINT64                                         Lun,
    101   IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
    102   IN EFI_EVENT                                      Event     OPTIONAL
    103   )
    104 /*++
    105 
    106   Routine Description:
    107     Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function
    108     supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the
    109     nonblocking I/O functionality is optional.
    110 
    111   Arguments:
    112     This   - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
    113     Target - The Target is an array of size TARGET_MAX_BYTES and it represents
    114              the id of the SCSI device to send the SCSI Request Packet. Each
    115              transport driver may chose to utilize a subset of this size to suit the needs
    116              of transport target representation. For example, a Fibre Channel driver
    117              may use only 8 bytes (WWN) to represent an FC target.
    118     Lun    - The LUN of the SCSI device to send the SCSI Request Packet.
    119     Packet - A pointer to the SCSI Request Packet to send to the SCSI device
    120              specified by Target and Lun.
    121     Event  - If nonblocking I/O is not supported then Event is ignored, and blocking
    122              I/O is performed. If Event is NULL, then blocking I/O is performed. If
    123              Event is not NULL and non blocking I/O is supported, then
    124              nonblocking I/O is performed, and Event will be signaled when the
    125              SCSI Request Packet completes.
    126 
    127   Returns:
    128     EFI_SUCCESS          - The SCSI Request Packet was sent by the host. For bi-directional
    129                            commands, InTransferLength bytes were transferred from
    130                            InDataBuffer. For write and bi-directional commands,
    131                            OutTransferLength bytes were transferred by
    132                            OutDataBuffer.
    133     EFI_BAD_BUFFER_SIZE  - The SCSI Request Packet was not executed. The number of bytes that
    134                            could be transferred is returned in InTransferLength. For write
    135                            and bi-directional commands, OutTransferLength bytes were
    136                            transferred by OutDataBuffer.
    137     EFI_NOT_READY        - The SCSI Request Packet could not be sent because there are too many
    138                            SCSI Request Packets already queued. The caller may retry again later.
    139     EFI_DEVICE_ERROR     - A device error occurred while attempting to send the SCSI Request
    140                            Packet.
    141     EFI_INVALID_PARAMETER- Target, Lun, or the contents of ScsiRequestPacket are invalid.
    142     EFI_UNSUPPORTED      - The command described by the SCSI Request Packet is not supported
    143                            by the host adapter. This includes the case of Bi-directional SCSI
    144                            commands not supported by the implementation. The SCSI Request
    145                            Packet was not sent, so no additional status information is available.
    146     EFI_TIMEOUT          - A timeout occurred while waiting for the SCSI Request Packet to execute.
    147 
    148 --*/
    149 ;
    150 
    151 typedef
    152 EFI_STATUS
    153 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN) (
    154   IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL                *This,
    155   IN OUT UINT8                                      **Target,
    156   IN OUT UINT64                                     *Lun
    157   )
    158 /*++
    159   Routine Description:
    160     Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These
    161     can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal
    162     Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the
    163     Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI
    164     channel.
    165 
    166   Arguments:
    167     This    - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance
    168     Target  - On input, a pointer to the Target ID (an array of size
    169               TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
    170               On output, a pointer to the Target ID (an array of
    171               TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
    172               channel. An input value of 0xF(all bytes in the array are 0xF) in the
    173               Target array retrieves the Target ID of the first SCSI device present on
    174               a SCSI channel.
    175     Lun     - On input, a pointer to the LUN of a SCSI device present on the SCSI
    176               channel. On output, a pointer to the LUN of the next SCSI device present
    177               on a SCSI channel.
    178 
    179   Returns:
    180     EFI_SUCCESS           - The Target ID and LUN of the next SCSI device on the SCSI
    181                             channel was returned in Target and Lun.
    182     EFI_INVALID_PARAMETER - Target array is not all 0xF, and Target and Lun were
    183                             not returned on a previous call to GetNextTargetLun().
    184     EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.
    185 
    186 --*/
    187 ;
    188 
    189 typedef
    190 EFI_STATUS
    191 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH) (
    192   IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This,
    193   IN UINT8                                         *Target,
    194   IN UINT64                                        Lun,
    195   IN OUT EFI_DEVICE_PATH_PROTOCOL                  **DevicePath
    196   )
    197 /*++
    198 
    199   Routine Description:
    200     Used to allocate and build a device path node for a SCSI device on a SCSI channel.
    201 
    202   Arguments:
    203     This       - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
    204     Target     - The Target is an array of size TARGET_MAX_BYTES and it specifies the
    205                  Target ID of the SCSI device for which a device path node is to be
    206                  allocated and built. Transport drivers may chose to utilize a subset of
    207                  this size to suit the representation of targets. For example, a Fibre
    208                  Channel driver may use only 8 bytes (WWN) in the array to represent a
    209                  FC target.
    210     Lun        - The LUN of the SCSI device for which a device path node is to be
    211                  allocated and built.
    212 
    213     DevicePath - A pointer to a single device path node that describes the SCSI device
    214                  specified by Target and Lun. This function is responsible for
    215                  allocating the buffer DevicePath with the boot service
    216                  AllocatePool(). It is the caller's responsibility to free
    217                  DevicePath when the caller is finished with DevicePath.
    218 
    219   Returns:
    220     EFI_SUCCESS           - The device path node that describes the SCSI device specified by
    221                             Target and Lun was allocated and returned in
    222                             DevicePath.
    223     EFI_INVALID_PARAMETER - DevicePath is NULL.
    224     EFI_NOT_FOUND         - The SCSI devices specified by Target and Lun does not exist
    225                             on the SCSI channel.
    226     EFI_OUT_OF_RESOURCES  - There are not enough resources to allocate DevicePath.
    227 
    228 --*/
    229 ;
    230 
    231 typedef
    232 EFI_STATUS
    233 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN) (
    234   IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This,
    235   IN EFI_DEVICE_PATH_PROTOCOL                      *DevicePath,
    236   OUT UINT8                                        **Target,
    237   OUT UINT64                                       *Lun
    238   )
    239 /*++
    240 
    241   Routine Description:
    242     Used to translate a device path node to a Target ID and LUN.
    243 
    244   Arguments:
    245     This       - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
    246     DevicePath - A pointer to a single device path node that describes the SCSI device
    247                  on the SCSI channel.
    248     Target     - A pointer to the Target Array which represents the ID of a SCSI device
    249                  on the SCSI channel.
    250     Lun        - A pointer to the LUN of a SCSI device on the SCSI channel.
    251 
    252   Returns:
    253     EFI_SUCCESS           - DevicePath was successfully translated to a Target ID and
    254                             LUN, and they were returned in Target and Lun.
    255     EFI_INVALID_PARAMETER - DevicePath or Target or Lun is NULL.
    256     EFI_NOT_FOUND         - A valid translation from DevicePath to a Target ID and LUN
    257                             does not exist.
    258     EFI_UNSUPPORTED       - This driver does not support the device path node type in
    259                                     DevicePath.
    260 
    261 --*/
    262 ;
    263 
    264 typedef
    265 EFI_STATUS
    266 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL) (
    267   IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This
    268   )
    269 /*++
    270 
    271   Routine Description:
    272     Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.
    273 
    274   Arguments:
    275     This          - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
    276 
    277   Returns:
    278     EFI_SUCCESS      - The SCSI channel was reset.
    279     EFI_DEVICE_ERROR - A device error occurred while attempting to reset the SCSI channel.
    280     EFI_TIMEOUT      - A timeout occurred while attempting to reset the SCSI channel.
    281     EFI_UNSUPPORTED  - The SCSI channel does not support a channel reset operation.
    282 
    283 --*/
    284 ;
    285 
    286 typedef
    287 EFI_STATUS
    288 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN) (
    289   IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This,
    290   IN UINT8                                         *Target,
    291   IN UINT64                                        Lun
    292   )
    293 /*++
    294 
    295   Routine Description:
    296     Resets a SCSI logical unit that is connected to a SCSI channel.
    297 
    298   Arguments:
    299     This   A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
    300     Target The Target is an array of size TARGET_MAX_BYTE and it represents the
    301            target port ID of the SCSI device containing the SCSI logical unit to
    302            reset. Transport drivers may chose to utilize a subset of this array to suit
    303            the representation of their targets.
    304     Lun    The LUN of the SCSI device to reset.
    305 
    306   Returns:
    307     EFI_SUCCESS           - The SCSI device specified by Target and Lun was reset.
    308     EFI_INVALID_PARAMETER - Target or Lun is NULL.
    309     EFI_TIMEOUT           - A timeout occurred while attempting to reset the SCSI device
    310                             specified by Target and Lun.
    311     EFI_UNSUPPORTED       - The SCSI channel does not support a target reset operation.
    312     EFI_DEVICE_ERROR      - A device error occurred while attempting to reset the SCSI device
    313                             specified by Target and Lun.
    314 
    315 --*/
    316 ;
    317 
    318 typedef
    319 EFI_STATUS
    320 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET) (
    321   IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL               *This,
    322   IN OUT UINT8                                     **Target
    323   )
    324 /*++
    325 
    326   Routine Description:
    327     Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either
    328     be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs
    329     for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to
    330     see if a SCSI device is actually present at that location on the SCSI channel.
    331 
    332   Arguments:
    333     This   - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
    334     Target - (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
    335              On output, a pointer to the Target ID (an array of
    336              TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
    337              channel. An input value of 0xF(all bytes in the array are 0xF) in the
    338              Target array retrieves the Target ID of the first SCSI device present on a
    339              SCSI channel.
    340 
    341   Returns:
    342     EFI_SUCCESS           - The Target ID of the next SCSI device on the SCSI
    343                             channel was returned in Target.
    344     EFI_INVALID_PARAMETER - Target or Lun is NULL.
    345     EFI_TIMEOUT           - Target array is not all 0xF, and Target were not
    346                             returned on a previous call to GetNextTarget().
    347     EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.
    348 
    349 --*/
    350 ;
    351 
    352 struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL {
    353   EFI_EXT_SCSI_PASS_THRU_MODE                *Mode;
    354   EFI_EXT_SCSI_PASS_THRU_PASSTHRU            PassThru;
    355   EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN GetNextTargetLun;
    356   EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH   BuildDevicePath;
    357   EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN      GetTargetLun;
    358   EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL       ResetChannel;
    359   EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN    ResetTargetLun;
    360   EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET     GetNextTarget;
    361 };
    362 
    363 extern EFI_GUID gEfiExtScsiPassThruProtocolGuid;
    364 
    365 #endif
    366