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