1d1f950002362305fcd4c30f108ef7b76679f5843yshang/** @file
24ca9b6c4e7dbbcf94f21b54f41f761cefc6b1086lgao  SCSI Pass Through protocol as defined in EFI 1.1.
34ca9b6c4e7dbbcf94f21b54f41f761cefc6b1086lgao  This protocol allows information about a SCSI channel to be collected,
44ca9b6c4e7dbbcf94f21b54f41f761cefc6b1086lgao  and allows SCSI Request Packets to be sent to any SCSI devices on a SCSI
54ca9b6c4e7dbbcf94f21b54f41f761cefc6b1086lgao  channel even if those devices are not boot devices. This protocol is attached
64ca9b6c4e7dbbcf94f21b54f41f761cefc6b1086lgao  to the device handle of each SCSI channel in a system that the protocol
74ca9b6c4e7dbbcf94f21b54f41f761cefc6b1086lgao  supports, and can be used for diagnostics. It may also be used to build
84ca9b6c4e7dbbcf94f21b54f41f761cefc6b1086lgao  a Block I/O driver for SCSI hard drives and SCSI CD-ROM or DVD drives to
94ca9b6c4e7dbbcf94f21b54f41f761cefc6b1086lgao  allow those devices to become boot devices.
104ca9b6c4e7dbbcf94f21b54f41f761cefc6b1086lgao
119df063a06aef048c042498e2f542fb693e93493ahhtian  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
129df063a06aef048c042498e2f542fb693e93493ahhtian  This program and the accompanying materials
13d1f950002362305fcd4c30f108ef7b76679f5843yshang  are licensed and made available under the terms and conditions of the BSD License
14d1f950002362305fcd4c30f108ef7b76679f5843yshang  which accompanies this distribution.  The full text of the license may be found at
15d1f950002362305fcd4c30f108ef7b76679f5843yshang  http://opensource.org/licenses/bsd-license.php
16d1f950002362305fcd4c30f108ef7b76679f5843yshang
17d1f950002362305fcd4c30f108ef7b76679f5843yshang  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18d1f950002362305fcd4c30f108ef7b76679f5843yshang  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19d1f950002362305fcd4c30f108ef7b76679f5843yshang
20d1f950002362305fcd4c30f108ef7b76679f5843yshang**/
21d1f950002362305fcd4c30f108ef7b76679f5843yshang
22d1f950002362305fcd4c30f108ef7b76679f5843yshang#ifndef __SCSI_PASS_THROUGH_H__
23d1f950002362305fcd4c30f108ef7b76679f5843yshang#define __SCSI_PASS_THROUGH_H__
24d1f950002362305fcd4c30f108ef7b76679f5843yshang
25d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_PASS_THRU_PROTOCOL_GUID \
26d1f950002362305fcd4c30f108ef7b76679f5843yshang  { \
27d1f950002362305fcd4c30f108ef7b76679f5843yshang    0xa59e8fcf, 0xbda0, 0x43bb, {0x90, 0xb1, 0xd3, 0x73, 0x2e, 0xca, 0xa8, 0x77 } \
28d1f950002362305fcd4c30f108ef7b76679f5843yshang  }
29d1f950002362305fcd4c30f108ef7b76679f5843yshang
3099e8ed219f48b82694424e46c9512d4929d9d54eklu///
3199e8ed219f48b82694424e46c9512d4929d9d54eklu/// Forward reference for pure ANSI compatability
3299e8ed219f48b82694424e46c9512d4929d9d54eklu///
33d1f950002362305fcd4c30f108ef7b76679f5843yshangtypedef struct _EFI_SCSI_PASS_THRU_PROTOCOL  EFI_SCSI_PASS_THRU_PROTOCOL;
34d1f950002362305fcd4c30f108ef7b76679f5843yshang
35d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL    0x0001
36d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL     0x0002
37d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO  0x0004
38d1f950002362305fcd4c30f108ef7b76679f5843yshang
39d1f950002362305fcd4c30f108ef7b76679f5843yshang//
40d1f950002362305fcd4c30f108ef7b76679f5843yshang// SCSI Host Adapter Status definition
41d1f950002362305fcd4c30f108ef7b76679f5843yshang//
42d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_OK                     0x00
43d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND        0x09  // timeout when processing the command
44d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT                0x0b  // timeout when waiting for the command processing
45d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT         0x0d  // a message reject was received when processing command
46d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_RESET              0x0e  // a bus reset was detected
47d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR           0x0f
48d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED   0x10  // the adapter failed in issuing request sense command
49d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT      0x11  // selection timeout
50d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN  0x12  // data overrun or data underrun
51d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_FREE               0x13  // Unexepected bus free
52d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR            0x14  // Target bus phase sequence failure
53d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_HOST_ADAPTER_OTHER                  0x7f
54d1f950002362305fcd4c30f108ef7b76679f5843yshang
55d1f950002362305fcd4c30f108ef7b76679f5843yshang//
56d1f950002362305fcd4c30f108ef7b76679f5843yshang// SCSI Target Status definition
57d1f950002362305fcd4c30f108ef7b76679f5843yshang//
58d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_TARGET_GOOD                       0x00
59d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_TARGET_CHECK_CONDITION            0x02  // check condition
60d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_TARGET_CONDITION_MET              0x04  // condition met
61d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_TARGET_BUSY                       0x08  // busy
62d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE               0x10  // intermediate
63d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14  // intermediate-condition met
64d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_TARGET_RESERVATION_CONFLICT       0x18  // reservation conflict
65d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_TARGET_COMMOND_TERMINATED         0x22  // command terminated
66d1f950002362305fcd4c30f108ef7b76679f5843yshang#define EFI_SCSI_STATUS_TARGET_QUEUE_FULL                 0x28  // queue full
67d1f950002362305fcd4c30f108ef7b76679f5843yshang
68d1f950002362305fcd4c30f108ef7b76679f5843yshangtypedef struct {
69992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
70992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// The timeout, in 100 ns units, to use for the execution of this SCSI
71992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// Request Packet. A Timeout value of 0 means that this function
72992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// will wait indefinitely for the SCSI Request Packet to execute. If
73992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// Timeout is greater than zero, then this function will return
74992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// EFI_TIMEOUT if the time required to execute the SCSI Request
75992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// Packet is greater than Timeout.
76992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
77d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT64  Timeout;
78992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
79992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// A pointer to the data buffer to transfer between the SCSI
80992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// controller and the SCSI device. Must be aligned to the boundary
81992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// specified in the IoAlign field of the
82992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// EFI_SCSI_PASS_THRU_MODE structure.
83992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
84d1f950002362305fcd4c30f108ef7b76679f5843yshang  VOID    *DataBuffer;
85992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
86992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// A pointer to the sense data that was generated by the execution of
87992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// the SCSI Request Packet.
88992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
89d1f950002362305fcd4c30f108ef7b76679f5843yshang  VOID    *SenseData;
90992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
91992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// A pointer to buffer that contains the Command Data Block to
92992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// send to the SCSI device.
93992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
94d1f950002362305fcd4c30f108ef7b76679f5843yshang  VOID    *Cdb;
95992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
96992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// On Input, the size, in bytes, of InDataBuffer. On output, the
97992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// number of bytes transferred between the SCSI controller and the SCSI device.
98992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
99d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT32  TransferLength;
100992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
101992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// The length, in bytes, of the buffer Cdb. The standard values are
102992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// 6, 10, 12, and 16, but other values are possible if a variable length CDB is used.
103992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
104d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT8   CdbLength;
105992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
106992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// The direction of the data transfer. 0 for reads, 1 for writes. A
107992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// value of 2 is Reserved for Bi-Directional SCSI commands.
108992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
109d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT8   DataDirection;
110992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
111992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// The status of the SCSI Host Controller that produces the SCSI
112992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// bus where the SCSI device attached when the SCSI Request
113992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// Packet was executed on the SCSI Controller.
114992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
115d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT8   HostAdapterStatus;
116992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
117992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// The status returned by the SCSI device when the SCSI Request
118992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// Packet was executed.
119992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
120d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT8   TargetStatus;
121992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
122992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// On input, the length in bytes of the SenseData buffer. On
123992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// output, the number of bytes written to the SenseData buffer.
124992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
125d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT8   SenseDataLength;
126d1f950002362305fcd4c30f108ef7b76679f5843yshang} EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET;
127d1f950002362305fcd4c30f108ef7b76679f5843yshang
128d1f950002362305fcd4c30f108ef7b76679f5843yshangtypedef struct {
129992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
130992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// A Null-terminated Unicode string that represents the printable name of the SCSI controller.
131992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
132d1f950002362305fcd4c30f108ef7b76679f5843yshang  CHAR16  *ControllerName;
133992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
134992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// A Null-terminated Unicode string that represents the printable name of the SCSI channel.
135992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
136d1f950002362305fcd4c30f108ef7b76679f5843yshang  CHAR16  *ChannelName;
137992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
138992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// The Target ID of the host adapter on the SCSI channel.
139992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
140d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT32  AdapterId;
141992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
142992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// Additional information on the attributes of the SCSI channel.
143992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
144d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT32  Attributes;
145992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
146992f22b99a90d1b217b1e6f702b238f1ff319753lgao  /// Supplies the alignment requirement for any buffer used in a data transfer.
147992f22b99a90d1b217b1e6f702b238f1ff319753lgao  ///
148d1f950002362305fcd4c30f108ef7b76679f5843yshang  UINT32  IoAlign;
149d1f950002362305fcd4c30f108ef7b76679f5843yshang} EFI_SCSI_PASS_THRU_MODE;
150d1f950002362305fcd4c30f108ef7b76679f5843yshang
151d1f950002362305fcd4c30f108ef7b76679f5843yshang/**
152d1f950002362305fcd4c30f108ef7b76679f5843yshang  Sends a SCSI Request Packet to a SCSI device that is attached to
153d1f950002362305fcd4c30f108ef7b76679f5843yshang  the SCSI channel. This function supports both blocking I/O and
154d1f950002362305fcd4c30f108ef7b76679f5843yshang  non-blocking I/O.  The blocking I/O functionality is required,
155d1f950002362305fcd4c30f108ef7b76679f5843yshang  and the non-blocking I/O functionality is optional.
156d1f950002362305fcd4c30f108ef7b76679f5843yshang
157d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  This   Protocol instance pointer.
158d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Target The Target ID of the SCSI device to
159d1f950002362305fcd4c30f108ef7b76679f5843yshang                 send the SCSI Request Packet.
160d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Lun    The LUN of the SCSI device to send the
161d1f950002362305fcd4c30f108ef7b76679f5843yshang                 SCSI Request Packet.
162d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Packet A pointer to the SCSI Request Packet to send
163d1f950002362305fcd4c30f108ef7b76679f5843yshang                 to the SCSI device specified by Target and Lun.
164d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Event  If non-blocking I/O is not supported then Event
165d1f950002362305fcd4c30f108ef7b76679f5843yshang                 is ignored, and blocking I/O is performed.
166d1f950002362305fcd4c30f108ef7b76679f5843yshang                 If Event is NULL, then blocking I/O is performed.
167d1f950002362305fcd4c30f108ef7b76679f5843yshang                 If Event is not NULL and non blocking I/O is
168d1f950002362305fcd4c30f108ef7b76679f5843yshang                 supported, then non-blocking I/O is performed,
169d1f950002362305fcd4c30f108ef7b76679f5843yshang                 and Event will be signaled when the SCSI Request
170d1f950002362305fcd4c30f108ef7b76679f5843yshang                 Packet completes
171d1f950002362305fcd4c30f108ef7b76679f5843yshang
172d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_SUCCESS               The SCSI Request Packet was sent by the host, and
173d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    TransferLength bytes were transferred to/from
174630b41877e9a1afe59d4f8a1c22bc691fe933ff8pkandel                                    DataBuffer. See HostAdapterStatus, TargetStatus,
175630b41877e9a1afe59d4f8a1c22bc691fe933ff8pkandel                                    SenseDataLength, and SenseData in that order
176d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    for additional status information.
177c7a54f2560479abe75b51383940b057cac321d22qhuang  @retval EFI_BAD_BUFFER_SIZE       The SCSI Request Packet was executed, but the
178d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    entire DataBuffer could not be transferred.
179d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    The actual number of bytes transferred is returned
180d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    in TransferLength. See HostAdapterStatus,
181d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    TargetStatus, SenseDataLength, and SenseData in
182d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    that order for additional status information.
183d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_NOT_READY             The SCSI Request Packet could not be sent because
184d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    there are too many SCSI Request Packets already
185d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    queued.  The caller may retry again later.
186d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_DEVICE_ERROR          A device error occurred while attempting to send
187d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    the SCSI Request Packet. See HostAdapterStatus,
188d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    TargetStatus, SenseDataLength, and SenseData in
189d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    that order for additional status information.
190d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_INVALID_PARAMETER     Target, Lun, or the contents of ScsiRequestPacket
191d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    are invalid. The SCSI Request Packet was not sent,
192d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    so no additional status information is available.
193d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_UNSUPPORTED           The command described by the SCSI Request Packet
194d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    is not supported by the host adapter. The SCSI
195d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    Request Packet was not sent, so no additional
196d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    status information is available.
197d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_TIMEOUT               A timeout occurred while waiting for the SCSI
198d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    Request Packet to execute. See HostAdapterStatus,
199d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    TargetStatus, SenseDataLength, and SenseData in
200d1f950002362305fcd4c30f108ef7b76679f5843yshang                                    that order for additional status information.
201d1f950002362305fcd4c30f108ef7b76679f5843yshang
202d1f950002362305fcd4c30f108ef7b76679f5843yshang**/
203d1f950002362305fcd4c30f108ef7b76679f5843yshangtypedef
204d1f950002362305fcd4c30f108ef7b76679f5843yshangEFI_STATUS
2058b13229b469f05ec22d76098b052bd6e943feceeklu(EFIAPI *EFI_SCSI_PASS_THRU_PASSTHRU)(
206d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN EFI_SCSI_PASS_THRU_PROTOCOL                          *This,
207d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN UINT32                                               Target,
208d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN UINT64                                               Lun,
209d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET           *Packet,
210d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN EFI_EVENT                                            Event   OPTIONAL
211ed66e1bc0d2be0a185fc47adab4930c3b7e2767fvanjeff  );
212d1f950002362305fcd4c30f108ef7b76679f5843yshang
213d1f950002362305fcd4c30f108ef7b76679f5843yshang/**
214d1f950002362305fcd4c30f108ef7b76679f5843yshang  Used to retrieve the list of legal Target IDs for SCSI devices
215d1f950002362305fcd4c30f108ef7b76679f5843yshang  on a SCSI channel.
216d1f950002362305fcd4c30f108ef7b76679f5843yshang
217d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  This   Protocol instance pointer.
218d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Target On input, a pointer to the Target ID of a
219d1f950002362305fcd4c30f108ef7b76679f5843yshang                 SCSI device present on the SCSI channel.
220d1f950002362305fcd4c30f108ef7b76679f5843yshang                 On output, a pointer to the Target ID of
221d1f950002362305fcd4c30f108ef7b76679f5843yshang                 the next SCSI device present on a SCSI channel.
222d1f950002362305fcd4c30f108ef7b76679f5843yshang                 An input value of 0xFFFFFFFF retrieves the
223d1f950002362305fcd4c30f108ef7b76679f5843yshang                 Target ID of the first SCSI device present on
224d1f950002362305fcd4c30f108ef7b76679f5843yshang                 a SCSI channel.
225d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Lun    On input, a pointer to the LUN of a SCSI device
226630b41877e9a1afe59d4f8a1c22bc691fe933ff8pkandel                 present on the SCSI channel. On output, a pointer
227d1f950002362305fcd4c30f108ef7b76679f5843yshang                 to the LUN of the next SCSI device present on a
228d1f950002362305fcd4c30f108ef7b76679f5843yshang                 SCSI channel.
229d1f950002362305fcd4c30f108ef7b76679f5843yshang
230d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_SUCCESS           The Target ID of the next SCSI device on the SCSI
231d1f950002362305fcd4c30f108ef7b76679f5843yshang                                channel was returned in Target and Lun.
232d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_NOT_FOUND         There are no more SCSI devices on this SCSI channel.
233d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_INVALID_PARAMETER Target is not 0xFFFFFFFF, and Target and Lun were
234d1f950002362305fcd4c30f108ef7b76679f5843yshang                                 not returned on a previous call to GetNextDevice().
235d1f950002362305fcd4c30f108ef7b76679f5843yshang
236d1f950002362305fcd4c30f108ef7b76679f5843yshang**/
237d1f950002362305fcd4c30f108ef7b76679f5843yshangtypedef
238d1f950002362305fcd4c30f108ef7b76679f5843yshangEFI_STATUS
2398b13229b469f05ec22d76098b052bd6e943feceeklu(EFIAPI *EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE)(
240d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN EFI_SCSI_PASS_THRU_PROTOCOL            *This,
241d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN OUT UINT32                             *Target,
242d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN OUT UINT64                             *Lun
243ed66e1bc0d2be0a185fc47adab4930c3b7e2767fvanjeff  );
244d1f950002362305fcd4c30f108ef7b76679f5843yshang
245d1f950002362305fcd4c30f108ef7b76679f5843yshang/**
246d1f950002362305fcd4c30f108ef7b76679f5843yshang  Used to allocate and build a device path node for a SCSI device
247d1f950002362305fcd4c30f108ef7b76679f5843yshang  on a SCSI channel.
248d1f950002362305fcd4c30f108ef7b76679f5843yshang
249d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  This       Protocol instance pointer.
250d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Target     The Target ID of the SCSI device for which
251d1f950002362305fcd4c30f108ef7b76679f5843yshang                     a device path node is to be allocated and built.
252d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Lun        The LUN of the SCSI device for which a device
253d1f950002362305fcd4c30f108ef7b76679f5843yshang                     path node is to be allocated and built.
254d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  DevicePath A pointer to a single device path node that
255d1f950002362305fcd4c30f108ef7b76679f5843yshang                     describes the SCSI device specified by
256d1f950002362305fcd4c30f108ef7b76679f5843yshang                     Target and Lun. This function is responsible
257d1f950002362305fcd4c30f108ef7b76679f5843yshang                     for allocating the buffer DevicePath with the boot
258d1f950002362305fcd4c30f108ef7b76679f5843yshang                     service AllocatePool().  It is the caller's
259d1f950002362305fcd4c30f108ef7b76679f5843yshang                     responsibility to free DevicePath when the caller
260d1f950002362305fcd4c30f108ef7b76679f5843yshang                     is finished with DevicePath.
261d1f950002362305fcd4c30f108ef7b76679f5843yshang
262d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_SUCCESS           The device path node that describes the SCSI device
263d1f950002362305fcd4c30f108ef7b76679f5843yshang                                specified by Target and Lun was allocated and
264d1f950002362305fcd4c30f108ef7b76679f5843yshang                                returned in DevicePath.
265d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_NOT_FOUND         The SCSI devices specified by Target and Lun does
266d1f950002362305fcd4c30f108ef7b76679f5843yshang                                not exist on the SCSI channel.
267d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_INVALID_PARAMETER DevicePath is NULL.
268d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_OUT_OF_RESOURCES  There are not enough resources to allocate
269d1f950002362305fcd4c30f108ef7b76679f5843yshang                                DevicePath.
270d1f950002362305fcd4c30f108ef7b76679f5843yshang
271d1f950002362305fcd4c30f108ef7b76679f5843yshang**/
272d1f950002362305fcd4c30f108ef7b76679f5843yshangtypedef
273d1f950002362305fcd4c30f108ef7b76679f5843yshangEFI_STATUS
2748b13229b469f05ec22d76098b052bd6e943feceeklu(EFIAPI *EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH)(
275d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN EFI_SCSI_PASS_THRU_PROTOCOL            *This,
276d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN     UINT32                             Target,
277d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN     UINT64                             Lun,
278d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN OUT EFI_DEVICE_PATH_PROTOCOL           **DevicePath
279ed66e1bc0d2be0a185fc47adab4930c3b7e2767fvanjeff  );
280d1f950002362305fcd4c30f108ef7b76679f5843yshang
281d1f950002362305fcd4c30f108ef7b76679f5843yshang/**
282d1f950002362305fcd4c30f108ef7b76679f5843yshang  Used to translate a device path node to a Target ID and LUN.
283d1f950002362305fcd4c30f108ef7b76679f5843yshang
284d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  This       Protocol instance pointer.
285d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  DevicePath A pointer to the device path node that
286d1f950002362305fcd4c30f108ef7b76679f5843yshang                     describes a SCSI device on the SCSI channel.
287d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Target     A pointer to the Target ID of a SCSI device
288d1f950002362305fcd4c30f108ef7b76679f5843yshang                     on the SCSI channel.
289d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Lun        A pointer to the LUN of a SCSI device on
290d1f950002362305fcd4c30f108ef7b76679f5843yshang                     the SCSI channel.
291d1f950002362305fcd4c30f108ef7b76679f5843yshang
292d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_SUCCESS           DevicePath was successfully translated to a
293d1f950002362305fcd4c30f108ef7b76679f5843yshang                                Target ID and LUN, and they were returned
294d1f950002362305fcd4c30f108ef7b76679f5843yshang                                in Target and Lun.
295d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_INVALID_PARAMETER DevicePath is NULL.
296d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_INVALID_PARAMETER Target is NULL.
297d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_INVALID_PARAMETER Lun is NULL.
298d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_UNSUPPORTED       This driver does not support the device path
299d1f950002362305fcd4c30f108ef7b76679f5843yshang                                node type in DevicePath.
300d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_NOT_FOUND         A valid translation from DevicePath to a
301d1f950002362305fcd4c30f108ef7b76679f5843yshang                                Target ID and LUN does not exist.
302d1f950002362305fcd4c30f108ef7b76679f5843yshang
303d1f950002362305fcd4c30f108ef7b76679f5843yshang**/
304d1f950002362305fcd4c30f108ef7b76679f5843yshangtypedef
305d1f950002362305fcd4c30f108ef7b76679f5843yshangEFI_STATUS
3068b13229b469f05ec22d76098b052bd6e943feceeklu(EFIAPI *EFI_SCSI_PASS_THRU_GET_TARGET_LUN)(
307d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN EFI_SCSI_PASS_THRU_PROTOCOL            *This,
308d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN  EFI_DEVICE_PATH_PROTOCOL              *DevicePath,
309d1f950002362305fcd4c30f108ef7b76679f5843yshang  OUT UINT32                                *Target,
310d1f950002362305fcd4c30f108ef7b76679f5843yshang  OUT UINT64                                *Lun
311ed66e1bc0d2be0a185fc47adab4930c3b7e2767fvanjeff  );
312d1f950002362305fcd4c30f108ef7b76679f5843yshang
313d1f950002362305fcd4c30f108ef7b76679f5843yshang/**
314d1f950002362305fcd4c30f108ef7b76679f5843yshang  Resets a SCSI channel.This operation resets all the
315d1f950002362305fcd4c30f108ef7b76679f5843yshang  SCSI devices connected to the SCSI channel.
316d1f950002362305fcd4c30f108ef7b76679f5843yshang
317d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  This Protocol instance pointer.
318d1f950002362305fcd4c30f108ef7b76679f5843yshang
319d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_SUCCESS      The SCSI channel was reset.
320d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_UNSUPPORTED  The SCSI channel does not support
321d1f950002362305fcd4c30f108ef7b76679f5843yshang                           a channel reset operation.
322d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_DEVICE_ERROR A device error occurred while
323d1f950002362305fcd4c30f108ef7b76679f5843yshang                           attempting to reset the SCSI channel.
324d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_TIMEOUT      A timeout occurred while attempting
325d1f950002362305fcd4c30f108ef7b76679f5843yshang                           to reset the SCSI channel.
326d1f950002362305fcd4c30f108ef7b76679f5843yshang
327d1f950002362305fcd4c30f108ef7b76679f5843yshang**/
328d1f950002362305fcd4c30f108ef7b76679f5843yshangtypedef
329d1f950002362305fcd4c30f108ef7b76679f5843yshangEFI_STATUS
3308b13229b469f05ec22d76098b052bd6e943feceeklu(EFIAPI *EFI_SCSI_PASS_THRU_RESET_CHANNEL)(
331d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN EFI_SCSI_PASS_THRU_PROTOCOL             *This
332ed66e1bc0d2be0a185fc47adab4930c3b7e2767fvanjeff  );
333d1f950002362305fcd4c30f108ef7b76679f5843yshang
334d1f950002362305fcd4c30f108ef7b76679f5843yshang/**
335d1f950002362305fcd4c30f108ef7b76679f5843yshang  Resets a SCSI device that is connected to a SCSI channel.
336d1f950002362305fcd4c30f108ef7b76679f5843yshang
337d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  This   Protocol instance pointer.
338d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Target The Target ID of the SCSI device to reset.
339d1f950002362305fcd4c30f108ef7b76679f5843yshang  @param  Lun    The LUN of the SCSI device to reset.
340d1f950002362305fcd4c30f108ef7b76679f5843yshang
341d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_SUCCESS           The SCSI device specified by Target and
342d1f950002362305fcd4c30f108ef7b76679f5843yshang                                Lun was reset.
343d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_UNSUPPORTED       The SCSI channel does not support a target
344d1f950002362305fcd4c30f108ef7b76679f5843yshang                                reset operation.
345d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_INVALID_PARAMETER Target or Lun are invalid.
346d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_DEVICE_ERROR      A device error occurred while attempting
347d1f950002362305fcd4c30f108ef7b76679f5843yshang                                to reset the SCSI device specified by Target
348d1f950002362305fcd4c30f108ef7b76679f5843yshang                                and Lun.
349d1f950002362305fcd4c30f108ef7b76679f5843yshang  @retval EFI_TIMEOUT           A timeout occurred while attempting to reset
350d1f950002362305fcd4c30f108ef7b76679f5843yshang                                the SCSI device specified by Target and Lun.
351d1f950002362305fcd4c30f108ef7b76679f5843yshang
352d1f950002362305fcd4c30f108ef7b76679f5843yshang**/
353d1f950002362305fcd4c30f108ef7b76679f5843yshangtypedef
354d1f950002362305fcd4c30f108ef7b76679f5843yshangEFI_STATUS
3558b13229b469f05ec22d76098b052bd6e943feceeklu(EFIAPI *EFI_SCSI_PASS_THRU_RESET_TARGET)(
356d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN EFI_SCSI_PASS_THRU_PROTOCOL             *This,
357d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN UINT32                                  Target,
358d1f950002362305fcd4c30f108ef7b76679f5843yshang  IN UINT64                                  Lun
359ed66e1bc0d2be0a185fc47adab4930c3b7e2767fvanjeff  );
360d1f950002362305fcd4c30f108ef7b76679f5843yshang
36144717a398fddc4df1f4aeaa70bcd7a043187ed34xli///
36244717a398fddc4df1f4aeaa70bcd7a043187ed34xli/// The EFI_SCSI_PASS_THRU_PROTOCOL provides information about a SCSI channel and
363630b41877e9a1afe59d4f8a1c22bc691fe933ff8pkandel/// the ability to send SCSI Request Packets to any SCSI device attached to that SCSI channel. The
36444717a398fddc4df1f4aeaa70bcd7a043187ed34xli/// information includes the Target ID of the host controller on the SCSI channel, the attributes of
36544717a398fddc4df1f4aeaa70bcd7a043187ed34xli/// the SCSI channel, the printable name for the SCSI controller, and the printable name of the
36644717a398fddc4df1f4aeaa70bcd7a043187ed34xli/// SCSI channel.
36744717a398fddc4df1f4aeaa70bcd7a043187ed34xli///
368d1f950002362305fcd4c30f108ef7b76679f5843yshangstruct _EFI_SCSI_PASS_THRU_PROTOCOL {
36944717a398fddc4df1f4aeaa70bcd7a043187ed34xli  ///
37044717a398fddc4df1f4aeaa70bcd7a043187ed34xli  /// A pointer to the EFI_SCSI_PASS_THRU_MODE data for this SCSI channel.
37144717a398fddc4df1f4aeaa70bcd7a043187ed34xli  ///
372d1f950002362305fcd4c30f108ef7b76679f5843yshang  EFI_SCSI_PASS_THRU_MODE               *Mode;
373d1f950002362305fcd4c30f108ef7b76679f5843yshang  EFI_SCSI_PASS_THRU_PASSTHRU           PassThru;
374d1f950002362305fcd4c30f108ef7b76679f5843yshang  EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE    GetNextDevice;
375d1f950002362305fcd4c30f108ef7b76679f5843yshang  EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH  BuildDevicePath;
376d1f950002362305fcd4c30f108ef7b76679f5843yshang  EFI_SCSI_PASS_THRU_GET_TARGET_LUN     GetTargetLun;
377d1f950002362305fcd4c30f108ef7b76679f5843yshang  EFI_SCSI_PASS_THRU_RESET_CHANNEL      ResetChannel;
378d1f950002362305fcd4c30f108ef7b76679f5843yshang  EFI_SCSI_PASS_THRU_RESET_TARGET       ResetTarget;
379d1f950002362305fcd4c30f108ef7b76679f5843yshang};
380d1f950002362305fcd4c30f108ef7b76679f5843yshang
381d1f950002362305fcd4c30f108ef7b76679f5843yshangextern EFI_GUID gEfiScsiPassThruProtocolGuid;
382d1f950002362305fcd4c30f108ef7b76679f5843yshang
383d1f950002362305fcd4c30f108ef7b76679f5843yshang#endif
384