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