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