]>
Commit | Line | Data |
---|---|---|
3a10d471 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | ScsiBus.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Header file for SCSI Bus Driver.\r | |
19 | \r | |
20 | Revision History\r | |
f36d6e66 | 21 | --*/\r |
3a10d471 | 22 | \r |
3a10d471 | 23 | #ifndef _SCSI_BUS_H\r |
24 | #define _SCSI_BUS_H\r | |
25 | \r | |
26 | \r | |
27 | #include <IndustryStandard/scsi.h>\r | |
28 | //\r | |
29 | // 1000 * 1000 * 10\r | |
30 | //\r | |
31 | #define ONE_SECOND_TIMER 10000000 \r | |
32 | \r | |
33 | #define SCSI_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'i', 'o')\r | |
34 | \r | |
70c94b3b | 35 | typedef struct _SCSI_TARGET_ID {\r |
36 | union {\r | |
37 | UINT32 Scsi;\r | |
38 | UINT8 ExtScsi[4]; \r | |
39 | } ScsiId;\r | |
40 | UINT8 ExtScsiId[12];\r | |
41 | }SCSI_TARGET_ID;\r | |
42 | \r | |
43 | \r | |
44 | typedef struct {\r | |
45 | VOID *Data1;\r | |
46 | VOID *Data2;\r | |
47 | } SCSI_EVENT_DATA;\r | |
48 | \r | |
49 | \r | |
3a10d471 | 50 | typedef struct {\r |
70c94b3b | 51 | UINT32 Signature;\r |
52 | EFI_HANDLE Handle;\r | |
53 | EFI_SCSI_IO_PROTOCOL ScsiIo;\r | |
54 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
55 | BOOLEAN ExtScsiSupport; \r | |
56 | EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;\r | |
57 | EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;\r | |
58 | SCSI_TARGET_ID Pun;\r | |
59 | UINT64 Lun;\r | |
60 | UINT8 ScsiDeviceType;\r | |
61 | UINT8 ScsiVersion;\r | |
62 | BOOLEAN RemovableDevice;\r | |
3a10d471 | 63 | } SCSI_IO_DEV;\r |
64 | \r | |
65 | #define SCSI_IO_DEV_FROM_THIS(a) CR (a, SCSI_IO_DEV, ScsiIo, SCSI_IO_DEV_SIGNATURE)\r | |
66 | \r | |
70c94b3b | 67 | //\r |
68 | // SCSI Bus Controller device strcuture\r | |
69 | //\r | |
70 | #define EFI_SCSI_BUS_PROTOCOL_GUID \\r | |
71 | { \\r | |
84b5c78e | 72 | 0x5261213D, 0x3A3D, 0x441E, {0xB3, 0xAF, 0x21, 0xD3, 0xF7, 0xA4, 0xCA, 0x17} \\r |
70c94b3b | 73 | }\r |
74 | \r | |
75 | typedef struct _EFI_SCSI_BUS_PROTOCOL {\r | |
76 | UINT64 Reserved;\r | |
77 | } EFI_SCSI_BUS_PROTOCOL;\r | |
78 | \r | |
79 | #define SCSI_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 's', 'i')\r | |
80 | \r | |
81 | \r | |
82 | typedef struct _SCSI_BUS_DEVICE {\r | |
83 | UINTN Signature;\r | |
84 | EFI_SCSI_BUS_PROTOCOL BusIdentify;\r | |
85 | BOOLEAN ExtScsiSupport; \r | |
86 | EFI_SCSI_PASS_THRU_PROTOCOL *ScsiInterface;\r | |
87 | EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiInterface;\r | |
88 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
89 | } SCSI_BUS_DEVICE;\r | |
90 | \r | |
91 | #define SCSI_BUS_CONTROLLER_DEVICE_FROM_THIS(a) CR (a, SCSI_BUS_DEVICE, BusIdentify, SCSI_BUS_DEVICE_SIGNATURE)\r | |
92 | \r | |
3a10d471 | 93 | //\r |
94 | // Global Variables\r | |
95 | //\r | |
96 | extern EFI_DRIVER_BINDING_PROTOCOL gScsiBusDriverBinding;\r | |
97 | extern EFI_COMPONENT_NAME_PROTOCOL gScsiBusComponentName;\r | |
98 | \r | |
99 | EFI_STATUS\r | |
100 | EFIAPI\r | |
101 | SCSIBusDriverBindingSupported (\r | |
102 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
103 | IN EFI_HANDLE Controller,\r | |
104 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
105 | );\r | |
106 | \r | |
107 | EFI_STATUS\r | |
108 | EFIAPI\r | |
109 | SCSIBusDriverBindingStart (\r | |
110 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
111 | IN EFI_HANDLE Controller,\r | |
112 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
113 | );\r | |
114 | \r | |
115 | EFI_STATUS\r | |
116 | EFIAPI\r | |
117 | SCSIBusDriverBindingStop (\r | |
118 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
119 | IN EFI_HANDLE Controller,\r | |
120 | IN UINTN NumberOfChildren,\r | |
121 | IN EFI_HANDLE *ChildHandleBuffer\r | |
122 | );\r | |
123 | \r | |
124 | //\r | |
125 | // EFI Component Name Functions\r | |
126 | //\r | |
127 | EFI_STATUS\r | |
128 | EFIAPI\r | |
129 | ScsiBusComponentNameGetDriverName (\r | |
130 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
131 | IN CHAR8 *Language,\r | |
132 | OUT CHAR16 **DriverName\r | |
133 | );\r | |
134 | \r | |
135 | EFI_STATUS\r | |
136 | EFIAPI\r | |
137 | ScsiBusComponentNameGetControllerName (\r | |
138 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
139 | IN EFI_HANDLE ControllerHandle,\r | |
140 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
141 | IN CHAR8 *Language,\r | |
142 | OUT CHAR16 **ControllerName\r | |
143 | );\r | |
144 | \r | |
145 | EFI_STATUS\r | |
146 | EFIAPI\r | |
147 | ScsiGetDeviceType (\r | |
148 | IN EFI_SCSI_IO_PROTOCOL *This,\r | |
149 | OUT UINT8 *DeviceType\r | |
150 | )\r | |
151 | /*++\r | |
152 | \r | |
153 | Routine Description:\r | |
154 | \r | |
70c94b3b | 155 | Retrieves the device type information of the SCSI Controller.\r |
156 | \r | |
3a10d471 | 157 | Arguments:\r |
158 | \r | |
70c94b3b | 159 | This - Protocol instance pointer.\r |
160 | DeviceType - A pointer to the device type information\r | |
161 | retrieved from the SCSI Controller. \r | |
3a10d471 | 162 | \r |
163 | Returns:\r | |
164 | \r | |
70c94b3b | 165 | EFI_SUCCESS - Retrieves the device type information successfully.\r |
166 | EFI_INVALID_PARAMETER - The DeviceType is NULL.\r | |
3a10d471 | 167 | \r |
168 | --*/\r | |
169 | ;\r | |
170 | \r | |
171 | EFI_STATUS\r | |
172 | EFIAPI\r | |
173 | ScsiResetBus (\r | |
174 | IN EFI_SCSI_IO_PROTOCOL *This\r | |
175 | )\r | |
176 | /*++\r | |
177 | \r | |
178 | Routine Description:\r | |
179 | \r | |
70c94b3b | 180 | Resets the SCSI Bus that the SCSI Controller is attached to.\r |
181 | \r | |
3a10d471 | 182 | Arguments:\r |
183 | \r | |
70c94b3b | 184 | This - Protocol instance pointer.\r |
3a10d471 | 185 | \r |
186 | Returns:\r | |
187 | \r | |
70c94b3b | 188 | EFI_SUCCESS - The SCSI bus is reset successfully.\r |
189 | EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.\r | |
190 | EFI_UNSUPPORTED - The bus reset operation is not supported by the\r | |
191 | SCSI Host Controller.\r | |
192 | EFI_TIMEOUT - A timeout occurred while attempting to reset \r | |
193 | the SCSI bus.\r | |
3a10d471 | 194 | \r |
195 | --*/\r | |
196 | ;\r | |
197 | \r | |
198 | EFI_STATUS\r | |
199 | EFIAPI\r | |
200 | ScsiResetDevice (\r | |
201 | IN EFI_SCSI_IO_PROTOCOL *This\r | |
202 | )\r | |
203 | /*++\r | |
204 | \r | |
205 | Routine Description:\r | |
206 | \r | |
70c94b3b | 207 | Resets the SCSI Controller that the device handle specifies.\r |
208 | \r | |
3a10d471 | 209 | Arguments:\r |
210 | \r | |
70c94b3b | 211 | This - Protocol instance pointer.\r |
212 | \r | |
3a10d471 | 213 | Returns:\r |
214 | \r | |
70c94b3b | 215 | EFI_SUCCESS - Reset the SCSI controller successfully.\r |
216 | EFI_DEVICE_ERROR - Errors are encountered when resetting the\r | |
217 | SCSI Controller.\r | |
218 | EFI_UNSUPPORTED - The SCSI bus does not support a device \r | |
219 | reset operation.\r | |
220 | EFI_TIMEOUT - A timeout occurred while attempting to \r | |
221 | reset the SCSI Controller.\r | |
3a10d471 | 222 | \r |
223 | --*/\r | |
224 | ;\r | |
225 | \r | |
226 | EFI_STATUS\r | |
227 | EFIAPI\r | |
228 | ScsiExecuteSCSICommand (\r | |
229 | IN EFI_SCSI_IO_PROTOCOL *This,\r | |
230 | IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket,\r | |
231 | IN EFI_EVENT Event\r | |
232 | )\r | |
233 | /*++\r | |
234 | \r | |
235 | Routine Description:\r | |
236 | \r | |
70c94b3b | 237 | Sends a SCSI Request Packet to the SCSI Controller for execution.\r |
238 | \r | |
3a10d471 | 239 | Arguments:\r |
240 | \r | |
70c94b3b | 241 | This - Protocol instance pointer.\r |
242 | Packet - The SCSI request packet to send to the SCSI \r | |
243 | Controller specified by the device handle.\r | |
244 | Event - If the SCSI bus where the SCSI device is attached\r | |
245 | does not support non-blocking I/O, then Event is \r | |
246 | ignored, and blocking I/O is performed. \r | |
247 | If Event is NULL, then blocking I/O is performed.\r | |
248 | If Event is not NULL and non-blocking I/O is \r | |
249 | supported, then non-blocking I/O is performed,\r | |
250 | and Event will be signaled when the SCSI Request\r | |
251 | Packet completes.\r | |
3a10d471 | 252 | Returns:\r |
253 | \r | |
70c94b3b | 254 | EFI_SUCCESS - The SCSI Request Packet was sent by the host \r |
255 | successfully, and TransferLength bytes were \r | |
256 | transferred to/from DataBuffer.See \r | |
257 | HostAdapterStatus, TargetStatus, \r | |
258 | SenseDataLength, and SenseData in that order\r | |
259 | for additional status information.\r | |
260 | EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed, \r | |
261 | but the entire DataBuffer could not be transferred.\r | |
262 | The actual number of bytes transferred is returned\r | |
263 | in TransferLength. See HostAdapterStatus, \r | |
264 | TargetStatus, SenseDataLength, and SenseData in \r | |
265 | that order for additional status information.\r | |
266 | EFI_NOT_READY - The SCSI Request Packet could not be sent because \r | |
267 | there are too many SCSI Command Packets already \r | |
268 | queued.The caller may retry again later.\r | |
269 | EFI_DEVICE_ERROR - A device error occurred while attempting to send \r | |
270 | the SCSI Request Packet. See HostAdapterStatus, \r | |
271 | TargetStatus, SenseDataLength, and SenseData in \r | |
272 | that order for additional status information.\r | |
273 | EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid. \r | |
274 | The SCSI Request Packet was not sent, so no \r | |
275 | additional status information is available.\r | |
276 | EFI_UNSUPPORTED - The command described by the SCSI Request Packet\r | |
277 | is not supported by the SCSI initiator(i.e., SCSI \r | |
278 | Host Controller). The SCSI Request Packet was not\r | |
279 | sent, so no additional status information is \r | |
280 | available.\r | |
281 | EFI_TIMEOUT - A timeout occurred while waiting for the SCSI \r | |
282 | Request Packet to execute. See HostAdapterStatus,\r | |
283 | TargetStatus, SenseDataLength, and SenseData in \r | |
284 | that order for additional status information.\r | |
3a10d471 | 285 | \r |
286 | --*/\r | |
287 | ;\r | |
288 | \r | |
289 | EFI_STATUS\r | |
290 | ScsiScanCreateDevice (\r | |
291 | EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
292 | EFI_HANDLE Controller,\r | |
70c94b3b | 293 | SCSI_TARGET_ID *TargetId,\r |
3a10d471 | 294 | UINT64 Lun,\r |
70c94b3b | 295 | SCSI_BUS_DEVICE *ScsiBusDev\r |
3a10d471 | 296 | )\r |
297 | /*++\r | |
298 | \r | |
299 | Routine Description:\r | |
300 | \r | |
70c94b3b | 301 | Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.\r |
3a10d471 | 302 | \r |
303 | Arguments:\r | |
304 | \r | |
70c94b3b | 305 | This - Protocol instance pointer\r |
306 | Controller - Controller handle\r | |
307 | Pun - The Pun of the SCSI device on the SCSI channel.\r | |
308 | Lun - The Lun of the SCSI device on the SCSI channel.\r | |
309 | ScsiBusDev - The pointer of SCSI_BUS_DEVICE\r | |
3a10d471 | 310 | \r |
311 | Returns:\r | |
312 | \r | |
70c94b3b | 313 | EFI_SUCCESS - Successfully to discover the device and attach ScsiIoProtocol to it.\r |
314 | EFI_OUT_OF_RESOURCES - Fail to discover the device.\r | |
3a10d471 | 315 | \r |
316 | --*/\r | |
317 | ;\r | |
318 | \r | |
319 | BOOLEAN\r | |
320 | DiscoverScsiDevice (\r | |
321 | SCSI_IO_DEV *ScsiIoDevice\r | |
322 | )\r | |
323 | /*++\r | |
324 | \r | |
325 | Routine Description:\r | |
326 | \r | |
f36d6e66 | 327 | Discovery SCSI Device\r |
3a10d471 | 328 | \r |
329 | Arguments:\r | |
330 | \r | |
f36d6e66 | 331 | ScsiIoDevice - The pointer of SCSI_IO_DEV\r |
3a10d471 | 332 | \r |
333 | Returns:\r | |
334 | \r | |
f36d6e66 | 335 | TRUE - Find SCSI Device and verify it.\r |
336 | FALSE - Unable to find SCSI Device. \r | |
3a10d471 | 337 | \r |
338 | --*/\r | |
339 | ;\r | |
340 | #endif\r |