]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
Clean up to update the reference of the these macros:
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ScsiDisk.h
CommitLineData
3b2dbece 1/** @file\r
2 Header file for SCSI Disk Driver.\r
6ad55b15 3\r
3b2dbece 4Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
6ad55b15 9\r
3b2dbece 10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
6ad55b15 12\r
3b2dbece 13**/\r
6ad55b15 14\r
9beb888e 15#ifndef _SCSI_DISK_H_\r
16#define _SCSI_DISK_H_\r
6ad55b15 17\r
18\r
9beb888e 19#include <Uefi.h>\r
20\r
21\r
22#include <Protocol/ScsiIo.h>\r
23#include <Protocol/ComponentName.h>\r
24#include <Protocol/BlockIo.h>\r
25#include <Protocol/DriverBinding.h>\r
26#include <Protocol/ScsiPassThruExt.h>\r
27\r
28#include <Library/DebugLib.h>\r
29#include <Library/UefiDriverEntryPoint.h>\r
30#include <Library/UefiLib.h>\r
31#include <Library/BaseMemoryLib.h>\r
ae50ee26 32#include <Library/UefiScsiLib.h>\r
9beb888e 33#include <Library/UefiBootServicesTableLib.h>\r
34\r
9cb8724d 35#include <IndustryStandard/Scsi.h>\r
6ad55b15 36\r
9beb888e 37#define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0\r
6ad55b15 38\r
f3f2e05d 39#define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')\r
6ad55b15 40\r
41typedef struct {\r
42 UINT32 Signature;\r
43\r
44 EFI_HANDLE Handle;\r
45\r
46 EFI_BLOCK_IO_PROTOCOL BlkIo;\r
47 EFI_BLOCK_IO_MEDIA BlkIoMedia;\r
48 EFI_SCSI_IO_PROTOCOL *ScsiIo;\r
49 UINT8 DeviceType;\r
50 BOOLEAN FixedDevice;\r
51 UINT16 Reserved;\r
52\r
53 EFI_SCSI_SENSE_DATA *SenseData;\r
54 UINTN SenseDataNumber;\r
55 EFI_SCSI_INQUIRY_DATA InquiryData;\r
56\r
57 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
58\r
59} SCSI_DISK_DEV;\r
60\r
61#define SCSI_DISK_DEV_FROM_THIS(a) CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)\r
62\r
63//\r
64// Global Variables\r
65//\r
70da5bc2 66extern EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding;\r
67extern EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName;\r
68extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2;\r
6ad55b15 69//\r
70// action code used in detect media process\r
71//\r
72#define ACTION_NO_ACTION 0x00\r
73#define ACTION_READ_CAPACITY 0x01\r
74#define ACTION_RETRY_COMMAND_LATER 0x02\r
75\r
9beb888e 76/**\r
77 Test to see if this driver supports ControllerHandle.\r
78\r
79 This service is called by the EFI boot service ConnectController(). In order\r
80 to make drivers as small as possible, there are a few calling restrictions for\r
81 this service. ConnectController() must follow these calling restrictions.\r
82 If any other agent wishes to call Supported() it must also follow these\r
83 calling restrictions.\r
84\r
85 @param This Protocol instance pointer.\r
86 @param ControllerHandle Handle of device to test\r
87 @param RemainingDevicePath Optional parameter use to pick a specific child\r
88 device to start.\r
89\r
90 @retval EFI_SUCCESS This driver supports this device\r
91 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
92 @retval other This driver does not support this device\r
93\r
94**/\r
6ad55b15 95EFI_STATUS\r
96EFIAPI\r
97ScsiDiskDriverBindingSupported (\r
98 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
99 IN EFI_HANDLE Controller,\r
9beb888e 100 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
6ad55b15 101 );\r
102\r
9beb888e 103/**\r
104 Start this driver on ControllerHandle.\r
105\r
106 This service is called by the EFI boot service ConnectController(). In order\r
107 to make drivers as small as possible, there are a few calling restrictions for\r
108 this service. ConnectController() must follow these calling restrictions. If\r
109 any other agent wishes to call Start() it must also follow these calling\r
110 restrictions.\r
111\r
112 @param This Protocol instance pointer.\r
113 @param ControllerHandle Handle of device to bind driver to\r
114 @param RemainingDevicePath Optional parameter use to pick a specific child\r
115 device to start.\r
116\r
117 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
118 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
119 @retval other This driver does not support this device\r
120\r
121**/\r
6ad55b15 122EFI_STATUS\r
123EFIAPI\r
124ScsiDiskDriverBindingStart (\r
125 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
126 IN EFI_HANDLE Controller,\r
9beb888e 127 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
6ad55b15 128 );\r
129\r
9beb888e 130/**\r
131 Stop this driver on ControllerHandle.\r
132\r
133 This service is called by the EFI boot service DisconnectController().\r
134 In order to make drivers as small as possible, there are a few calling\r
135 restrictions for this service. DisconnectController() must follow these\r
136 calling restrictions. If any other agent wishes to call Stop() it must\r
137 also follow these calling restrictions.\r
138 \r
139 @param This Protocol instance pointer.\r
140 @param ControllerHandle Handle of device to stop driver on\r
141 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
142 children is zero stop the entire bus driver.\r
143 @param ChildHandleBuffer List of Child Handles to Stop.\r
144\r
145 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
146 @retval other This driver was not removed from this device\r
147\r
148**/\r
6ad55b15 149EFI_STATUS\r
150EFIAPI\r
151ScsiDiskDriverBindingStop (\r
152 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
153 IN EFI_HANDLE Controller,\r
154 IN UINTN NumberOfChildren,\r
9beb888e 155 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
6ad55b15 156 );\r
157\r
158//\r
159// EFI Component Name Functions\r
160//\r
70da5bc2 161/**\r
162 Retrieves a Unicode string that is the user readable name of the driver.\r
163\r
164 This function retrieves the user readable name of a driver in the form of a\r
165 Unicode string. If the driver specified by This has a user readable name in\r
166 the language specified by Language, then a pointer to the driver name is\r
167 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
168 by This does not support the language specified by Language,\r
169 then EFI_UNSUPPORTED is returned.\r
170\r
9beb888e 171 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 172 EFI_COMPONENT_NAME_PROTOCOL instance.\r
173\r
9beb888e 174 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 175 array indicating the language. This is the\r
176 language of the driver name that the caller is\r
177 requesting, and it must match one of the\r
178 languages specified in SupportedLanguages. The\r
179 number of languages supported by a driver is up\r
180 to the driver writer. Language is specified\r
181 in RFC 3066 or ISO 639-2 language code format.\r
182\r
9beb888e 183 @param DriverName A pointer to the Unicode string to return.\r
70da5bc2 184 This Unicode string is the name of the\r
185 driver specified by This in the language\r
186 specified by Language.\r
187\r
188 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
189 This and the language specified by Language was\r
190 returned in DriverName.\r
191\r
192 @retval EFI_INVALID_PARAMETER Language is NULL.\r
193\r
194 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
195\r
196 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
197 the language specified by Language.\r
198\r
199**/\r
6ad55b15 200EFI_STATUS\r
201EFIAPI\r
202ScsiDiskComponentNameGetDriverName (\r
203 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
204 IN CHAR8 *Language,\r
205 OUT CHAR16 **DriverName\r
206 );\r
207\r
70da5bc2 208\r
209/**\r
210 Retrieves a Unicode string that is the user readable name of the controller\r
211 that is being managed by a driver.\r
212\r
213 This function retrieves the user readable name of the controller specified by\r
214 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
215 driver specified by This has a user readable name in the language specified by\r
216 Language, then a pointer to the controller name is returned in ControllerName,\r
217 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
218 managing the controller specified by ControllerHandle and ChildHandle,\r
219 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
220 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
221\r
9beb888e 222 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 223 EFI_COMPONENT_NAME_PROTOCOL instance.\r
224\r
9beb888e 225 @param ControllerHandle The handle of a controller that the driver\r
70da5bc2 226 specified by This is managing. This handle\r
227 specifies the controller whose name is to be\r
228 returned.\r
229\r
9beb888e 230 @param ChildHandle The handle of the child controller to retrieve\r
70da5bc2 231 the name of. This is an optional parameter that\r
232 may be NULL. It will be NULL for device\r
233 drivers. It will also be NULL for a bus drivers\r
234 that wish to retrieve the name of the bus\r
235 controller. It will not be NULL for a bus\r
236 driver that wishes to retrieve the name of a\r
237 child controller.\r
238\r
9beb888e 239 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 240 array indicating the language. This is the\r
241 language of the driver name that the caller is\r
242 requesting, and it must match one of the\r
243 languages specified in SupportedLanguages. The\r
244 number of languages supported by a driver is up\r
245 to the driver writer. Language is specified in\r
246 RFC 3066 or ISO 639-2 language code format.\r
247\r
9beb888e 248 @param ControllerName A pointer to the Unicode string to return.\r
70da5bc2 249 This Unicode string is the name of the\r
250 controller specified by ControllerHandle and\r
251 ChildHandle in the language specified by\r
252 Language from the point of view of the driver\r
253 specified by This.\r
254\r
255 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
256 the language specified by Language for the\r
257 driver specified by This was returned in\r
258 DriverName.\r
259\r
260 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
261\r
262 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
263 EFI_HANDLE.\r
264\r
265 @retval EFI_INVALID_PARAMETER Language is NULL.\r
266\r
267 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
268\r
269 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
270 managing the controller specified by\r
271 ControllerHandle and ChildHandle.\r
272\r
273 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
274 the language specified by Language.\r
275\r
276**/\r
6ad55b15 277EFI_STATUS\r
278EFIAPI\r
279ScsiDiskComponentNameGetControllerName (\r
280 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
281 IN EFI_HANDLE ControllerHandle,\r
282 IN EFI_HANDLE ChildHandle OPTIONAL,\r
283 IN CHAR8 *Language,\r
284 OUT CHAR16 **ControllerName\r
285 );\r
286\r
9beb888e 287/**\r
288 Reset SCSI Disk.\r
289\r
290\r
291 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
292 @param ExtendedVerification The flag about if extend verificate\r
70da5bc2 293\r
9beb888e 294 @retval EFI_SUCCESS The device was reset.\r
295 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
296 not be reset.\r
297 @return EFI_STATUS is retured from EFI_SCSI_IO_PROTOCOL.ResetDevice().\r
298\r
299**/\r
6ad55b15 300EFI_STATUS\r
301EFIAPI\r
302ScsiDiskReset (\r
303 IN EFI_BLOCK_IO_PROTOCOL *This,\r
304 IN BOOLEAN ExtendedVerification\r
9beb888e 305 );\r
6ad55b15 306\r
6ad55b15 307\r
9beb888e 308/**\r
309 The function is to Read Block from SCSI Disk.\r
6ad55b15 310\r
9beb888e 311 @param This The pointer of EFI_BLOCK_IO_PROTOCOL.\r
312 @param MediaId The Id of Media detected\r
313 @param Lba The logic block address\r
314 @param BufferSize The size of Buffer\r
315 @param Buffer The buffer to fill the read out data\r
6ad55b15 316\r
9beb888e 317 @retval EFI_SUCCESS Successfully to read out block.\r
318 @retval EFI_DEVICE_ERROR Fail to detect media.\r
319 @retval EFI_NO_MEDIA Media is not present.\r
320 @retval EFI_MEDIA_CHANGED Media has changed.\r
321 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
322 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
6ad55b15 323\r
9beb888e 324**/\r
6ad55b15 325EFI_STATUS\r
326EFIAPI\r
327ScsiDiskReadBlocks (\r
328 IN EFI_BLOCK_IO_PROTOCOL *This,\r
329 IN UINT32 MediaId,\r
9beb888e 330 IN EFI_LBA Lba,\r
6ad55b15 331 IN UINTN BufferSize,\r
332 OUT VOID *Buffer\r
9beb888e 333 );\r
6ad55b15 334\r
6ad55b15 335\r
9beb888e 336/**\r
337 The function is to Write Block to SCSI Disk.\r
338\r
339 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
340 @param MediaId The Id of Media detected\r
341 @param Lba The logic block address\r
342 @param BufferSize The size of Buffer\r
343 @param Buffer The buffer to fill the read out data\r
344\r
345 @retval EFI_SUCCESS Successfully to read out block.\r
346 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
347 @retval EFI_DEVICE_ERROR Fail to detect media.\r
348 @retval EFI_NO_MEDIA Media is not present.\r
349 @retval EFI_MEDIA_CHNAGED Media has changed.\r
350 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
351 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
6ad55b15 352\r
9beb888e 353**/\r
6ad55b15 354EFI_STATUS\r
355EFIAPI\r
356ScsiDiskWriteBlocks (\r
357 IN EFI_BLOCK_IO_PROTOCOL *This,\r
358 IN UINT32 MediaId,\r
9beb888e 359 IN EFI_LBA Lba,\r
6ad55b15 360 IN UINTN BufferSize,\r
361 IN VOID *Buffer\r
9beb888e 362 );\r
6ad55b15 363\r
6ad55b15 364\r
9beb888e 365/**\r
366 Flush Block to Disk.\r
6ad55b15 367\r
9beb888e 368 EFI_SUCCESS is returned directly.\r
6ad55b15 369\r
9beb888e 370 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
6ad55b15 371\r
9beb888e 372 @retval EFI_SUCCESS All outstanding data was written to the device\r
6ad55b15 373\r
9beb888e 374**/\r
6ad55b15 375EFI_STATUS\r
376EFIAPI\r
377ScsiDiskFlushBlocks (\r
378 IN EFI_BLOCK_IO_PROTOCOL *This\r
9beb888e 379 );\r
6ad55b15 380\r
9beb888e 381/**\r
382 Dectect Device and read out capacity ,if error occurs, parse the sense key.\r
6ad55b15 383\r
9beb888e 384 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
385 @param MustReadCapacity The flag about reading device capacity\r
386 @param MediaChange The pointer of flag indicates if media has changed \r
6ad55b15 387\r
9beb888e 388 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
389 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 390\r
9beb888e 391**/\r
6ad55b15 392EFI_STATUS\r
393ScsiDiskDetectMedia (\r
9beb888e 394 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
395 IN BOOLEAN MustReadCapacity,\r
396 OUT BOOLEAN *MediaChange\r
397 );\r
6ad55b15 398\r
9beb888e 399/**\r
400 To test deivice.\r
6ad55b15 401\r
9beb888e 402 When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;\r
403 When Test Unit Ready command encounters any error caused by host adapter or\r
404 target, return error without retrieving Sense Keys.\r
6ad55b15 405\r
9beb888e 406 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
407 @param NeedRetry The pointer of flag indicates try again\r
408 @param SenseDataArray The pointer of an array of sense data\r
409 @param NumberOfSenseKeys The pointer of the number of sense data array\r
6ad55b15 410\r
9beb888e 411 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
412 @retval EFI_SUCCESS Successfully to test unit\r
f36d6e66 413\r
9beb888e 414**/\r
6ad55b15 415EFI_STATUS\r
416ScsiDiskTestUnitReady (\r
9beb888e 417 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
418 OUT BOOLEAN *NeedRetry,\r
419 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
420 OUT UINTN *NumberOfSenseKeys\r
421 );\r
6ad55b15 422\r
6ad55b15 423\r
9beb888e 424/**\r
425 Parsing Sense Keys which got from request sense command.\r
6ad55b15 426\r
9beb888e 427 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
428 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
429 @param NumberOfSenseKeys The number of sense key \r
430 @param Action The pointer of action which indicates what is need to do next\r
6ad55b15 431\r
9beb888e 432 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
433 @retval EFI_SUCCESS Successfully to complete the parsing\r
6ad55b15 434\r
9beb888e 435**/\r
6ad55b15 436EFI_STATUS\r
437DetectMediaParsingSenseKeys (\r
9beb888e 438 OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
439 IN EFI_SCSI_SENSE_DATA *SenseData,\r
440 IN UINTN NumberOfSenseKeys,\r
441 OUT UINTN *Action\r
442 );\r
6ad55b15 443\r
6ad55b15 444\r
9beb888e 445/**\r
446 Send read capacity command to device and get the device parameter.\r
6ad55b15 447\r
9beb888e 448 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
449 @param NeedRetry The pointer of flag indicates if need a retry\r
450 @param SenseDataArray The pointer of an array of sense data\r
451 @param NumberOfSenseKeys The number of sense key\r
6ad55b15 452\r
9beb888e 453 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
454 @retval EFI_SUCCESS Successfully to read capacity\r
6ad55b15 455\r
9beb888e 456**/\r
6ad55b15 457EFI_STATUS\r
458ScsiDiskReadCapacity (\r
9beb888e 459 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
460 OUT BOOLEAN *NeedRetry,\r
461 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
462 OUT UINTN *NumberOfSenseKeys\r
463 );\r
6ad55b15 464\r
9beb888e 465/**\r
466 Check the HostAdapter status and re-interpret it in EFI_STATUS.\r
6ad55b15 467\r
9beb888e 468 @param HostAdapterStatus Host Adapter status\r
6ad55b15 469\r
9beb888e 470 @retval EFI_SUCCESS Host adapter is OK.\r
471 @retval EFI_TIMEOUT Timeout.\r
472 @retval EFI_NOT_READY Adapter NOT ready.\r
473 @retval EFI_DEVICE_ERROR Adapter device error.\r
6ad55b15 474\r
9beb888e 475**/\r
6ad55b15 476EFI_STATUS\r
477CheckHostAdapterStatus (\r
9beb888e 478 IN UINT8 HostAdapterStatus\r
479 );\r
6ad55b15 480\r
6ad55b15 481\r
9beb888e 482/**\r
483 Check the target status and re-interpret it in EFI_STATUS.\r
6ad55b15 484\r
9beb888e 485 @param TargetStatus Target status\r
6ad55b15 486\r
9beb888e 487 @retval EFI_NOT_READY Device is NOT ready.\r
488 @retval EFI_DEVICE_ERROR \r
489 @retval EFI_SUCCESS\r
6ad55b15 490\r
9beb888e 491**/\r
6ad55b15 492EFI_STATUS\r
493CheckTargetStatus (\r
9beb888e 494 IN UINT8 TargetStatus\r
495 );\r
6ad55b15 496\r
9beb888e 497/**\r
498 Retrieve all sense keys from the device.\r
6ad55b15 499\r
9beb888e 500 When encountering error during the process, if retrieve sense keys before\r
501 error encounterred, it returns the sense keys with return status set to EFI_SUCCESS,\r
502 and NeedRetry set to FALSE; otherwize, return the proper return status.\r
6ad55b15 503\r
9beb888e 504 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
505 @param NeedRetry The pointer of flag indicates if need a retry\r
506 @param SenseDataArray The pointer of an array of sense data\r
507 @param NumberOfSenseKeys The number of sense key\r
508 @param AskResetIfError The flag indicates if need reset when error occurs\r
6ad55b15 509\r
9beb888e 510 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
511 @retval EFI_SUCCESS Successfully to request sense key\r
6ad55b15 512\r
9beb888e 513**/\r
6ad55b15 514EFI_STATUS\r
515ScsiDiskRequestSenseKeys (\r
9beb888e 516 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
517 OUT BOOLEAN *NeedRetry,\r
518 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
519 OUT UINTN *NumberOfSenseKeys,\r
520 IN BOOLEAN AskResetIfError\r
521 );\r
6ad55b15 522\r
9beb888e 523/**\r
524 Send out Inquiry command to Device.\r
6ad55b15 525\r
9beb888e 526 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
527 @param NeedRetry Indicates if needs try again when error happens\r
6ad55b15 528\r
9beb888e 529 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
530 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 531\r
9beb888e 532**/\r
6ad55b15 533EFI_STATUS\r
534ScsiDiskInquiryDevice (\r
9beb888e 535 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
536 OUT BOOLEAN *NeedRetry\r
537 );\r
6ad55b15 538\r
9beb888e 539/**\r
540 Parse Inquiry data.\r
6ad55b15 541\r
9beb888e 542 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 543\r
9beb888e 544**/\r
6ad55b15 545VOID\r
546ParseInquiryData (\r
9beb888e 547 IN OUT SCSI_DISK_DEV *ScsiDiskDevice\r
548 );\r
6ad55b15 549\r
9beb888e 550/**\r
551 Read sector from SCSI Disk.\r
6ad55b15 552\r
9beb888e 553 @param ScsiDiskDevice The poiniter of SCSI_DISK_DEV\r
554 @param Buffer The buffer to fill in the read out data\r
555 @param Lba Logic block address\r
556 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 557\r
9beb888e 558 @retval EFI_DEVICE_ERROR Indicates a device error.\r
559 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 560\r
9beb888e 561**/\r
6ad55b15 562EFI_STATUS\r
563ScsiDiskReadSectors (\r
9beb888e 564 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
565 OUT VOID *Buffer,\r
566 IN EFI_LBA Lba,\r
567 IN UINTN NumberOfBlocks\r
568 );\r
6ad55b15 569\r
9beb888e 570/**\r
571 Write sector to SCSI Disk.\r
6ad55b15 572\r
9beb888e 573 @param ScsiDiskDevice The poiniter of SCSI_DISK_DEV\r
574 @param Buffer The buffer of data to be written into SCSI Disk\r
575 @param Lba Logic block address\r
576 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 577\r
9beb888e 578 @retval EFI_DEVICE_ERROR Indicates a device error.\r
579 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 580\r
9beb888e 581**/\r
6ad55b15 582EFI_STATUS\r
583ScsiDiskWriteSectors (\r
9beb888e 584 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
585 IN VOID *Buffer,\r
586 IN EFI_LBA Lba,\r
587 IN UINTN NumberOfBlocks\r
588 );\r
6ad55b15 589\r
9beb888e 590/**\r
591 Sumbmit Read command.\r
592\r
593 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
594 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
595 @param SenseDataArray NOT used yet in this function\r
596 @param NumberOfSenseKeys The number of sense key\r
597 @param Timeout The time to complete the command\r
598 @param DataBuffer The buffer to fill with the read out data\r
599 @param DataLength The length of buffer\r
600 @param StartLba The start logic block address\r
601 @param SectorSize The size of sector\r
602\r
603 @return EFI_STATUS is returned by calling ScsiRead10Command().\r
604**/\r
6ad55b15 605EFI_STATUS\r
606ScsiDiskRead10 (\r
9beb888e 607 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
608 OUT BOOLEAN *NeedRetry,\r
609 OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OPTIONAL\r
610 OUT UINTN *NumberOfSenseKeys,\r
611 IN UINT64 Timeout,\r
612 OUT UINT8 *DataBuffer,\r
613 IN OUT UINT32 *DataLength,\r
614 IN UINT32 StartLba,\r
615 IN UINT32 SectorSize\r
616 );\r
6ad55b15 617\r
9beb888e 618/**\r
619 Submit Write Command.\r
6ad55b15 620\r
9beb888e 621 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
622 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
623 @param SenseDataArray NOT used yet in this function\r
624 @param NumberOfSenseKeys The number of sense key\r
625 @param Timeout The time to complete the command\r
626 @param DataBuffer The buffer to fill with the read out data\r
627 @param DataLength The length of buffer\r
628 @param StartLba The start logic block address\r
629 @param SectorSize The size of sector\r
6ad55b15 630\r
9beb888e 631 @return EFI_STATUS is returned by calling ScsiWrite10Command().\r
6ad55b15 632\r
9beb888e 633**/\r
6ad55b15 634EFI_STATUS\r
635ScsiDiskWrite10 (\r
9beb888e 636 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
637 OUT BOOLEAN *NeedRetry,\r
638 OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OPTIONAL\r
639 OUT UINTN *NumberOfSenseKeys,\r
640 IN UINT64 Timeout,\r
641 IN UINT8 *DataBuffer,\r
642 IN OUT UINT32 *DataLength,\r
643 IN UINT32 StartLba,\r
644 IN UINT32 SectorSize\r
645 );\r
6ad55b15 646\r
9beb888e 647/**\r
648 Get information from media read capacity command.\r
6ad55b15 649\r
9beb888e 650 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
651 @param Capacity The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
6ad55b15 652\r
9beb888e 653**/\r
6ad55b15 654VOID\r
655GetMediaInfo (\r
9beb888e 656 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
657 IN EFI_SCSI_DISK_CAPACITY_DATA *Capacity\r
658 );\r
6ad55b15 659\r
9beb888e 660/**\r
661 Check sense key to find if media presents.\r
6ad55b15 662\r
9beb888e 663 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
664 @param SenseCounts The number of sense key\r
6ad55b15 665\r
9beb888e 666 @retval TRUE NOT any media\r
667 @retval FALSE Media presents\r
668**/\r
6ad55b15 669BOOLEAN\r
670ScsiDiskIsNoMedia (\r
671 IN EFI_SCSI_SENSE_DATA *SenseData,\r
672 IN UINTN SenseCounts\r
9beb888e 673 );\r
6ad55b15 674\r
9beb888e 675/**\r
676 Parse sense key.\r
6ad55b15 677\r
9beb888e 678 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
679 @param SenseCounts The number of sense key\r
6ad55b15 680\r
9beb888e 681 @retval TRUE Error\r
682 @retval FALSE NOT error\r
6ad55b15 683\r
9beb888e 684**/\r
6ad55b15 685BOOLEAN\r
686ScsiDiskIsMediaError (\r
687 IN EFI_SCSI_SENSE_DATA *SenseData,\r
688 IN UINTN SenseCounts\r
9beb888e 689 );\r
6ad55b15 690\r
9beb888e 691/**\r
692 Check sense key to find if hardware error happens.\r
6ad55b15 693\r
9beb888e 694 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
695 @param SenseCounts The number of sense key\r
6ad55b15 696\r
9beb888e 697 @retval TRUE Hardware error exits.\r
698 @retval FALSE NO error.\r
6ad55b15 699\r
9beb888e 700**/\r
6ad55b15 701BOOLEAN\r
702ScsiDiskIsHardwareError (\r
703 IN EFI_SCSI_SENSE_DATA *SenseData,\r
704 IN UINTN SenseCounts\r
9beb888e 705 );\r
6ad55b15 706\r
9beb888e 707/**\r
708 Check sense key to find if media has changed.\r
6ad55b15 709\r
9beb888e 710 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
711 @param SenseCounts The number of sense key\r
6ad55b15 712\r
9beb888e 713 @retval TRUE Media is changed.\r
714 @retval FALSE Medit is NOT changed.\r
715**/\r
6ad55b15 716BOOLEAN\r
717ScsiDiskIsMediaChange (\r
718 IN EFI_SCSI_SENSE_DATA *SenseData,\r
719 IN UINTN SenseCounts\r
9beb888e 720 );\r
6ad55b15 721\r
9beb888e 722/**\r
723 Check sense key to find if reset happens.\r
6ad55b15 724\r
9beb888e 725 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
726 @param SenseCounts The number of sense key\r
6ad55b15 727\r
9beb888e 728 @retval TRUE It is reset before.\r
729 @retval FALSE It is NOT reset before.\r
6ad55b15 730\r
9beb888e 731**/\r
6ad55b15 732BOOLEAN\r
733ScsiDiskIsResetBefore (\r
734 IN EFI_SCSI_SENSE_DATA *SenseData,\r
735 IN UINTN SenseCounts\r
9beb888e 736 );\r
6ad55b15 737\r
9beb888e 738/**\r
739 Check sense key to find if the drive is ready.\r
6ad55b15 740\r
9beb888e 741 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
742 @param SenseCounts The number of sense key\r
743 @param RetryLater The flag means if need a retry \r
6ad55b15 744\r
9beb888e 745 @retval TRUE Drive is ready.\r
746 @retval FALSE Drive is NOT ready.\r
6ad55b15 747\r
9beb888e 748**/\r
6ad55b15 749BOOLEAN\r
750ScsiDiskIsDriveReady (\r
751 IN EFI_SCSI_SENSE_DATA *SenseData,\r
752 IN UINTN SenseCounts,\r
9beb888e 753 OUT BOOLEAN *RetryLater\r
754 );\r
6ad55b15 755\r
9beb888e 756/**\r
757 Check sense key to find if it has sense key.\r
6ad55b15 758\r
9beb888e 759 @param SenseData - The pointer of EFI_SCSI_SENSE_DATA\r
760 @param SenseCounts - The number of sense key\r
6ad55b15 761\r
9beb888e 762 @retval TRUE It has sense key.\r
763 @retval FALSE It has NOT any sense key.\r
6ad55b15 764\r
9beb888e 765**/\r
6ad55b15 766BOOLEAN\r
767ScsiDiskHaveSenseKey (\r
768 IN EFI_SCSI_SENSE_DATA *SenseData,\r
769 IN UINTN SenseCounts\r
9beb888e 770 );\r
6ad55b15 771\r
9beb888e 772/**\r
773 Release resource about disk device.\r
6ad55b15 774\r
9beb888e 775 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 776\r
9beb888e 777**/\r
6ad55b15 778VOID\r
779ReleaseScsiDiskDeviceResources (\r
780 IN SCSI_DISK_DEV *ScsiDiskDevice\r
9beb888e 781 );\r
6ad55b15 782\r
783#endif\r