]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
Code Scrub:
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ScsiDisk.h
... / ...
CommitLineData
1/** @file\r
2 Header file for SCSI Disk Driver.\r
3\r
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
9\r
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
12\r
13**/\r
14\r
15#ifndef _SCSI_DISK_H_\r
16#define _SCSI_DISK_H_\r
17\r
18\r
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
32#include <Library/ScsiLib.h>\r
33#include <Library/UefiBootServicesTableLib.h>\r
34\r
35#include <IndustryStandard/Scsi.h>\r
36\r
37#define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0\r
38\r
39#define SCSI_DISK_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'd', 'k')\r
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
66extern EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding;\r
67extern EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName;\r
68extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2;\r
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
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
95EFI_STATUS\r
96EFIAPI\r
97ScsiDiskDriverBindingSupported (\r
98 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
99 IN EFI_HANDLE Controller,\r
100 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
101 );\r
102\r
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
122EFI_STATUS\r
123EFIAPI\r
124ScsiDiskDriverBindingStart (\r
125 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
126 IN EFI_HANDLE Controller,\r
127 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
128 );\r
129\r
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
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
155 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
156 );\r
157\r
158//\r
159// EFI Component Name Functions\r
160//\r
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
171 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
172 EFI_COMPONENT_NAME_PROTOCOL instance.\r
173\r
174 @param Language A pointer to a Null-terminated ASCII string\r
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
183 @param DriverName A pointer to the Unicode string to return.\r
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
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
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
222 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
223 EFI_COMPONENT_NAME_PROTOCOL instance.\r
224\r
225 @param ControllerHandle The handle of a controller that the driver\r
226 specified by This is managing. This handle\r
227 specifies the controller whose name is to be\r
228 returned.\r
229\r
230 @param ChildHandle The handle of the child controller to retrieve\r
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
239 @param Language A pointer to a Null-terminated ASCII string\r
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
248 @param ControllerName A pointer to the Unicode string to return.\r
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
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
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
293\r
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
300EFI_STATUS\r
301EFIAPI\r
302ScsiDiskReset (\r
303 IN EFI_BLOCK_IO_PROTOCOL *This,\r
304 IN BOOLEAN ExtendedVerification\r
305 );\r
306\r
307\r
308/**\r
309 The function is to Read Block from SCSI Disk.\r
310\r
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
316\r
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
323\r
324**/\r
325EFI_STATUS\r
326EFIAPI\r
327ScsiDiskReadBlocks (\r
328 IN EFI_BLOCK_IO_PROTOCOL *This,\r
329 IN UINT32 MediaId,\r
330 IN EFI_LBA Lba,\r
331 IN UINTN BufferSize,\r
332 OUT VOID *Buffer\r
333 );\r
334\r
335\r
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
352\r
353**/\r
354EFI_STATUS\r
355EFIAPI\r
356ScsiDiskWriteBlocks (\r
357 IN EFI_BLOCK_IO_PROTOCOL *This,\r
358 IN UINT32 MediaId,\r
359 IN EFI_LBA Lba,\r
360 IN UINTN BufferSize,\r
361 IN VOID *Buffer\r
362 );\r
363\r
364\r
365/**\r
366 Flush Block to Disk.\r
367\r
368 EFI_SUCCESS is returned directly.\r
369\r
370 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
371\r
372 @retval EFI_SUCCESS All outstanding data was written to the device\r
373\r
374**/\r
375EFI_STATUS\r
376EFIAPI\r
377ScsiDiskFlushBlocks (\r
378 IN EFI_BLOCK_IO_PROTOCOL *This\r
379 );\r
380\r
381/**\r
382 Dectect Device and read out capacity ,if error occurs, parse the sense key.\r
383\r
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
387\r
388 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
389 @retval EFI_SUCCESS Successfully to detect media\r
390\r
391**/\r
392EFI_STATUS\r
393ScsiDiskDetectMedia (\r
394 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
395 IN BOOLEAN MustReadCapacity,\r
396 OUT BOOLEAN *MediaChange\r
397 );\r
398\r
399/**\r
400 To test deivice.\r
401\r
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
405\r
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
410\r
411 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
412 @retval EFI_SUCCESS Successfully to test unit\r
413\r
414**/\r
415EFI_STATUS\r
416ScsiDiskTestUnitReady (\r
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
422\r
423\r
424/**\r
425 Parsing Sense Keys which got from request sense command.\r
426\r
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
431\r
432 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
433 @retval EFI_SUCCESS Successfully to complete the parsing\r
434\r
435**/\r
436EFI_STATUS\r
437DetectMediaParsingSenseKeys (\r
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
443\r
444\r
445/**\r
446 Send read capacity command to device and get the device parameter.\r
447\r
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
452\r
453 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
454 @retval EFI_SUCCESS Successfully to read capacity\r
455\r
456**/\r
457EFI_STATUS\r
458ScsiDiskReadCapacity (\r
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
464\r
465/**\r
466 Check the HostAdapter status and re-interpret it in EFI_STATUS.\r
467\r
468 @param HostAdapterStatus Host Adapter status\r
469\r
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
474\r
475**/\r
476EFI_STATUS\r
477CheckHostAdapterStatus (\r
478 IN UINT8 HostAdapterStatus\r
479 );\r
480\r
481\r
482/**\r
483 Check the target status and re-interpret it in EFI_STATUS.\r
484\r
485 @param TargetStatus Target status\r
486\r
487 @retval EFI_NOT_READY Device is NOT ready.\r
488 @retval EFI_DEVICE_ERROR \r
489 @retval EFI_SUCCESS\r
490\r
491**/\r
492EFI_STATUS\r
493CheckTargetStatus (\r
494 IN UINT8 TargetStatus\r
495 );\r
496\r
497/**\r
498 Retrieve all sense keys from the device.\r
499\r
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
503\r
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
509\r
510 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
511 @retval EFI_SUCCESS Successfully to request sense key\r
512\r
513**/\r
514EFI_STATUS\r
515ScsiDiskRequestSenseKeys (\r
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
522\r
523/**\r
524 Send out Inquiry command to Device.\r
525\r
526 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
527 @param NeedRetry Indicates if needs try again when error happens\r
528\r
529 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
530 @retval EFI_SUCCESS Successfully to detect media\r
531\r
532**/\r
533EFI_STATUS\r
534ScsiDiskInquiryDevice (\r
535 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
536 OUT BOOLEAN *NeedRetry\r
537 );\r
538\r
539/**\r
540 Parse Inquiry data.\r
541\r
542 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
543\r
544**/\r
545VOID\r
546ParseInquiryData (\r
547 IN OUT SCSI_DISK_DEV *ScsiDiskDevice\r
548 );\r
549\r
550/**\r
551 Read sector from SCSI Disk.\r
552\r
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
557\r
558 @retval EFI_DEVICE_ERROR Indicates a device error.\r
559 @retval EFI_SUCCESS Operation is successful.\r
560\r
561**/\r
562EFI_STATUS\r
563ScsiDiskReadSectors (\r
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
569\r
570/**\r
571 Write sector to SCSI Disk.\r
572\r
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
577\r
578 @retval EFI_DEVICE_ERROR Indicates a device error.\r
579 @retval EFI_SUCCESS Operation is successful.\r
580\r
581**/\r
582EFI_STATUS\r
583ScsiDiskWriteSectors (\r
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
589\r
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
605EFI_STATUS\r
606ScsiDiskRead10 (\r
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
617\r
618/**\r
619 Submit Write Command.\r
620\r
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
630\r
631 @return EFI_STATUS is returned by calling ScsiWrite10Command().\r
632\r
633**/\r
634EFI_STATUS\r
635ScsiDiskWrite10 (\r
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
646\r
647/**\r
648 Get information from media read capacity command.\r
649\r
650 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
651 @param Capacity The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
652\r
653**/\r
654VOID\r
655GetMediaInfo (\r
656 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
657 IN EFI_SCSI_DISK_CAPACITY_DATA *Capacity\r
658 );\r
659\r
660/**\r
661 Check sense key to find if media presents.\r
662\r
663 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
664 @param SenseCounts The number of sense key\r
665\r
666 @retval TRUE NOT any media\r
667 @retval FALSE Media presents\r
668**/\r
669BOOLEAN\r
670ScsiDiskIsNoMedia (\r
671 IN EFI_SCSI_SENSE_DATA *SenseData,\r
672 IN UINTN SenseCounts\r
673 );\r
674\r
675/**\r
676 Parse sense key.\r
677\r
678 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
679 @param SenseCounts The number of sense key\r
680\r
681 @retval TRUE Error\r
682 @retval FALSE NOT error\r
683\r
684**/\r
685BOOLEAN\r
686ScsiDiskIsMediaError (\r
687 IN EFI_SCSI_SENSE_DATA *SenseData,\r
688 IN UINTN SenseCounts\r
689 );\r
690\r
691/**\r
692 Check sense key to find if hardware error happens.\r
693\r
694 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
695 @param SenseCounts The number of sense key\r
696\r
697 @retval TRUE Hardware error exits.\r
698 @retval FALSE NO error.\r
699\r
700**/\r
701BOOLEAN\r
702ScsiDiskIsHardwareError (\r
703 IN EFI_SCSI_SENSE_DATA *SenseData,\r
704 IN UINTN SenseCounts\r
705 );\r
706\r
707/**\r
708 Check sense key to find if media has changed.\r
709\r
710 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
711 @param SenseCounts The number of sense key\r
712\r
713 @retval TRUE Media is changed.\r
714 @retval FALSE Medit is NOT changed.\r
715**/\r
716BOOLEAN\r
717ScsiDiskIsMediaChange (\r
718 IN EFI_SCSI_SENSE_DATA *SenseData,\r
719 IN UINTN SenseCounts\r
720 );\r
721\r
722/**\r
723 Check sense key to find if reset happens.\r
724\r
725 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
726 @param SenseCounts The number of sense key\r
727\r
728 @retval TRUE It is reset before.\r
729 @retval FALSE It is NOT reset before.\r
730\r
731**/\r
732BOOLEAN\r
733ScsiDiskIsResetBefore (\r
734 IN EFI_SCSI_SENSE_DATA *SenseData,\r
735 IN UINTN SenseCounts\r
736 );\r
737\r
738/**\r
739 Check sense key to find if the drive is ready.\r
740\r
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
744\r
745 @retval TRUE Drive is ready.\r
746 @retval FALSE Drive is NOT ready.\r
747\r
748**/\r
749BOOLEAN\r
750ScsiDiskIsDriveReady (\r
751 IN EFI_SCSI_SENSE_DATA *SenseData,\r
752 IN UINTN SenseCounts,\r
753 OUT BOOLEAN *RetryLater\r
754 );\r
755\r
756/**\r
757 Check sense key to find if it has sense key.\r
758\r
759 @param SenseData - The pointer of EFI_SCSI_SENSE_DATA\r
760 @param SenseCounts - The number of sense key\r
761\r
762 @retval TRUE It has sense key.\r
763 @retval FALSE It has NOT any sense key.\r
764\r
765**/\r
766BOOLEAN\r
767ScsiDiskHaveSenseKey (\r
768 IN EFI_SCSI_SENSE_DATA *SenseData,\r
769 IN UINTN SenseCounts\r
770 );\r
771\r
772/**\r
773 Release resource about disk device.\r
774\r
775 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
776\r
777**/\r
778VOID\r
779ReleaseScsiDiskDeviceResources (\r
780 IN SCSI_DISK_DEV *ScsiDiskDevice\r
781 );\r
782\r
783#endif\r