]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
Change Partition/ScsiDxe driver to produce Block IO revision 3.
[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
cd5ebaa0
HT
4Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
3b2dbece 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
d14faa52 27#include <Protocol/ScsiPassThru.h>\r
d716651f 28#include <Protocol/DiskInfo.h>\r
29\r
9beb888e 30\r
31#include <Library/DebugLib.h>\r
32#include <Library/UefiDriverEntryPoint.h>\r
33#include <Library/UefiLib.h>\r
34#include <Library/BaseMemoryLib.h>\r
94e0fd07 35#include <Library/MemoryAllocationLib.h>\r
ae50ee26 36#include <Library/UefiScsiLib.h>\r
9beb888e 37#include <Library/UefiBootServicesTableLib.h>\r
d716651f 38#include <Library/DevicePathLib.h>\r
9beb888e 39\r
9cb8724d 40#include <IndustryStandard/Scsi.h>\r
d716651f 41#include <IndustryStandard/Atapi.h>\r
6ad55b15 42\r
9beb888e 43#define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0\r
6ad55b15 44\r
f3f2e05d 45#define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')\r
6ad55b15 46\r
47typedef struct {\r
48 UINT32 Signature;\r
49\r
50 EFI_HANDLE Handle;\r
51\r
52 EFI_BLOCK_IO_PROTOCOL BlkIo;\r
53 EFI_BLOCK_IO_MEDIA BlkIoMedia;\r
54 EFI_SCSI_IO_PROTOCOL *ScsiIo;\r
55 UINT8 DeviceType;\r
56 BOOLEAN FixedDevice;\r
57 UINT16 Reserved;\r
58\r
59 EFI_SCSI_SENSE_DATA *SenseData;\r
60 UINTN SenseDataNumber;\r
61 EFI_SCSI_INQUIRY_DATA InquiryData;\r
62\r
63 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
64\r
d716651f 65 EFI_DISK_INFO_PROTOCOL DiskInfo;\r
66\r
67 //\r
68 // The following fields are only valid for ATAPI/SATA device\r
69 //\r
70 UINT32 Channel;\r
71 UINT32 Device;\r
72 ATAPI_IDENTIFY_DATA IdentifyData;\r
f95bc048 73 \r
74 //\r
75 // The flag indicates if 16-byte command can be used\r
76 //\r
77 BOOLEAN Cdb16Byte;\r
6ad55b15 78} SCSI_DISK_DEV;\r
79\r
80#define SCSI_DISK_DEV_FROM_THIS(a) CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)\r
81\r
d716651f 82#define SCSI_DISK_DEV_FROM_DISKINFO(a) CR (a, SCSI_DISK_DEV, DiskInfo, SCSI_DISK_DEV_SIGNATURE)\r
83\r
6ad55b15 84//\r
85// Global Variables\r
86//\r
70da5bc2 87extern EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding;\r
88extern EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName;\r
89extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2;\r
6ad55b15 90//\r
91// action code used in detect media process\r
92//\r
93#define ACTION_NO_ACTION 0x00\r
94#define ACTION_READ_CAPACITY 0x01\r
95#define ACTION_RETRY_COMMAND_LATER 0x02\r
96\r
b96cd313 97#define SCSI_COMMAND_VERSION_1 0x01\r
98#define SCSI_COMMAND_VERSION_2 0x02\r
99#define SCSI_COMMAND_VERSION_3 0x03\r
100\r
101\r
9beb888e 102/**\r
103 Test to see if this driver supports ControllerHandle.\r
104\r
105 This service is called by the EFI boot service ConnectController(). In order\r
106 to make drivers as small as possible, there are a few calling restrictions for\r
107 this service. ConnectController() must follow these calling restrictions.\r
108 If any other agent wishes to call Supported() it must also follow these\r
109 calling restrictions.\r
110\r
111 @param This Protocol instance pointer.\r
112 @param ControllerHandle Handle of device to test\r
113 @param RemainingDevicePath Optional parameter use to pick a specific child\r
114 device to start.\r
115\r
116 @retval EFI_SUCCESS This driver supports this device\r
117 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
118 @retval other This driver does not support this device\r
119\r
120**/\r
6ad55b15 121EFI_STATUS\r
122EFIAPI\r
123ScsiDiskDriverBindingSupported (\r
124 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
125 IN EFI_HANDLE Controller,\r
9beb888e 126 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
6ad55b15 127 );\r
128\r
9beb888e 129/**\r
130 Start this driver on ControllerHandle.\r
131\r
132 This service is called by the EFI boot service ConnectController(). In order\r
133 to make drivers as small as possible, there are a few calling restrictions for\r
134 this service. ConnectController() must follow these calling restrictions. If\r
135 any other agent wishes to call Start() it must also follow these calling\r
136 restrictions.\r
137\r
138 @param This Protocol instance pointer.\r
139 @param ControllerHandle Handle of device to bind driver to\r
140 @param RemainingDevicePath Optional parameter use to pick a specific child\r
141 device to start.\r
142\r
143 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
144 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
145 @retval other This driver does not support this device\r
146\r
147**/\r
6ad55b15 148EFI_STATUS\r
149EFIAPI\r
150ScsiDiskDriverBindingStart (\r
151 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
152 IN EFI_HANDLE Controller,\r
9beb888e 153 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
6ad55b15 154 );\r
155\r
9beb888e 156/**\r
157 Stop this driver on ControllerHandle.\r
158\r
159 This service is called by the EFI boot service DisconnectController().\r
160 In order to make drivers as small as possible, there are a few calling\r
161 restrictions for this service. DisconnectController() must follow these\r
162 calling restrictions. If any other agent wishes to call Stop() it must\r
163 also follow these calling restrictions.\r
164 \r
165 @param This Protocol instance pointer.\r
166 @param ControllerHandle Handle of device to stop driver on\r
167 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
168 children is zero stop the entire bus driver.\r
169 @param ChildHandleBuffer List of Child Handles to Stop.\r
170\r
171 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
172 @retval other This driver was not removed from this device\r
173\r
174**/\r
6ad55b15 175EFI_STATUS\r
176EFIAPI\r
177ScsiDiskDriverBindingStop (\r
178 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
179 IN EFI_HANDLE Controller,\r
180 IN UINTN NumberOfChildren,\r
9beb888e 181 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
6ad55b15 182 );\r
183\r
184//\r
185// EFI Component Name Functions\r
186//\r
70da5bc2 187/**\r
188 Retrieves a Unicode string that is the user readable name of the driver.\r
189\r
190 This function retrieves the user readable name of a driver in the form of a\r
191 Unicode string. If the driver specified by This has a user readable name in\r
192 the language specified by Language, then a pointer to the driver name is\r
193 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
194 by This does not support the language specified by Language,\r
195 then EFI_UNSUPPORTED is returned.\r
196\r
9beb888e 197 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 198 EFI_COMPONENT_NAME_PROTOCOL instance.\r
199\r
9beb888e 200 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 201 array indicating the language. This is the\r
202 language of the driver name that the caller is\r
203 requesting, and it must match one of the\r
204 languages specified in SupportedLanguages. The\r
205 number of languages supported by a driver is up\r
206 to the driver writer. Language is specified\r
0254efc0 207 in RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 208\r
9beb888e 209 @param DriverName A pointer to the Unicode string to return.\r
70da5bc2 210 This Unicode string is the name of the\r
211 driver specified by This in the language\r
212 specified by Language.\r
213\r
214 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
215 This and the language specified by Language was\r
216 returned in DriverName.\r
217\r
218 @retval EFI_INVALID_PARAMETER Language is NULL.\r
219\r
220 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
221\r
222 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
223 the language specified by Language.\r
224\r
225**/\r
6ad55b15 226EFI_STATUS\r
227EFIAPI\r
228ScsiDiskComponentNameGetDriverName (\r
229 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
230 IN CHAR8 *Language,\r
231 OUT CHAR16 **DriverName\r
232 );\r
233\r
70da5bc2 234\r
235/**\r
236 Retrieves a Unicode string that is the user readable name of the controller\r
237 that is being managed by a driver.\r
238\r
239 This function retrieves the user readable name of the controller specified by\r
240 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
241 driver specified by This has a user readable name in the language specified by\r
242 Language, then a pointer to the controller name is returned in ControllerName,\r
243 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
244 managing the controller specified by ControllerHandle and ChildHandle,\r
245 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
246 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
247\r
9beb888e 248 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 249 EFI_COMPONENT_NAME_PROTOCOL instance.\r
250\r
9beb888e 251 @param ControllerHandle The handle of a controller that the driver\r
70da5bc2 252 specified by This is managing. This handle\r
253 specifies the controller whose name is to be\r
254 returned.\r
255\r
9beb888e 256 @param ChildHandle The handle of the child controller to retrieve\r
70da5bc2 257 the name of. This is an optional parameter that\r
258 may be NULL. It will be NULL for device\r
259 drivers. It will also be NULL for a bus drivers\r
260 that wish to retrieve the name of the bus\r
261 controller. It will not be NULL for a bus\r
262 driver that wishes to retrieve the name of a\r
263 child controller.\r
264\r
9beb888e 265 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 266 array indicating the language. This is the\r
267 language of the driver name that the caller is\r
268 requesting, and it must match one of the\r
269 languages specified in SupportedLanguages. The\r
270 number of languages supported by a driver is up\r
271 to the driver writer. Language is specified in\r
0254efc0 272 RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 273\r
9beb888e 274 @param ControllerName A pointer to the Unicode string to return.\r
70da5bc2 275 This Unicode string is the name of the\r
276 controller specified by ControllerHandle and\r
277 ChildHandle in the language specified by\r
278 Language from the point of view of the driver\r
279 specified by This.\r
280\r
281 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
282 the language specified by Language for the\r
283 driver specified by This was returned in\r
284 DriverName.\r
285\r
286 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
287\r
288 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
289 EFI_HANDLE.\r
290\r
291 @retval EFI_INVALID_PARAMETER Language is NULL.\r
292\r
293 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
294\r
295 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
296 managing the controller specified by\r
297 ControllerHandle and ChildHandle.\r
298\r
299 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
300 the language specified by Language.\r
301\r
302**/\r
6ad55b15 303EFI_STATUS\r
304EFIAPI\r
305ScsiDiskComponentNameGetControllerName (\r
306 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
307 IN EFI_HANDLE ControllerHandle,\r
308 IN EFI_HANDLE ChildHandle OPTIONAL,\r
309 IN CHAR8 *Language,\r
310 OUT CHAR16 **ControllerName\r
311 );\r
312\r
9beb888e 313/**\r
314 Reset SCSI Disk.\r
315\r
316\r
317 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
318 @param ExtendedVerification The flag about if extend verificate\r
70da5bc2 319\r
9beb888e 320 @retval EFI_SUCCESS The device was reset.\r
321 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
322 not be reset.\r
323 @return EFI_STATUS is retured from EFI_SCSI_IO_PROTOCOL.ResetDevice().\r
324\r
325**/\r
6ad55b15 326EFI_STATUS\r
327EFIAPI\r
328ScsiDiskReset (\r
329 IN EFI_BLOCK_IO_PROTOCOL *This,\r
330 IN BOOLEAN ExtendedVerification\r
9beb888e 331 );\r
6ad55b15 332\r
6ad55b15 333\r
9beb888e 334/**\r
335 The function is to Read Block from SCSI Disk.\r
6ad55b15 336\r
9beb888e 337 @param This The pointer of EFI_BLOCK_IO_PROTOCOL.\r
338 @param MediaId The Id of Media detected\r
339 @param Lba The logic block address\r
340 @param BufferSize The size of Buffer\r
341 @param Buffer The buffer to fill the read out data\r
6ad55b15 342\r
9beb888e 343 @retval EFI_SUCCESS Successfully to read out block.\r
344 @retval EFI_DEVICE_ERROR Fail to detect media.\r
345 @retval EFI_NO_MEDIA Media is not present.\r
346 @retval EFI_MEDIA_CHANGED Media has changed.\r
347 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
348 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
6ad55b15 349\r
9beb888e 350**/\r
6ad55b15 351EFI_STATUS\r
352EFIAPI\r
353ScsiDiskReadBlocks (\r
354 IN EFI_BLOCK_IO_PROTOCOL *This,\r
355 IN UINT32 MediaId,\r
9beb888e 356 IN EFI_LBA Lba,\r
6ad55b15 357 IN UINTN BufferSize,\r
358 OUT VOID *Buffer\r
9beb888e 359 );\r
6ad55b15 360\r
6ad55b15 361\r
9beb888e 362/**\r
363 The function is to Write Block to SCSI Disk.\r
364\r
365 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
366 @param MediaId The Id of Media detected\r
367 @param Lba The logic block address\r
368 @param BufferSize The size of Buffer\r
369 @param Buffer The buffer to fill the read out data\r
370\r
371 @retval EFI_SUCCESS Successfully to read out block.\r
372 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
373 @retval EFI_DEVICE_ERROR Fail to detect media.\r
374 @retval EFI_NO_MEDIA Media is not present.\r
375 @retval EFI_MEDIA_CHNAGED Media has changed.\r
376 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
377 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
6ad55b15 378\r
9beb888e 379**/\r
6ad55b15 380EFI_STATUS\r
381EFIAPI\r
382ScsiDiskWriteBlocks (\r
383 IN EFI_BLOCK_IO_PROTOCOL *This,\r
384 IN UINT32 MediaId,\r
9beb888e 385 IN EFI_LBA Lba,\r
6ad55b15 386 IN UINTN BufferSize,\r
387 IN VOID *Buffer\r
9beb888e 388 );\r
6ad55b15 389\r
6ad55b15 390\r
9beb888e 391/**\r
392 Flush Block to Disk.\r
6ad55b15 393\r
9beb888e 394 EFI_SUCCESS is returned directly.\r
6ad55b15 395\r
9beb888e 396 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
6ad55b15 397\r
9beb888e 398 @retval EFI_SUCCESS All outstanding data was written to the device\r
6ad55b15 399\r
9beb888e 400**/\r
6ad55b15 401EFI_STATUS\r
402EFIAPI\r
403ScsiDiskFlushBlocks (\r
404 IN EFI_BLOCK_IO_PROTOCOL *This\r
9beb888e 405 );\r
6ad55b15 406\r
d716651f 407\r
408/**\r
409 Provides inquiry information for the controller type.\r
410 \r
411 This function is used by the IDE bus driver to get inquiry data. Data format\r
412 of Identify data is defined by the Interface GUID.\r
413\r
4140a663 414 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
415 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.\r
416 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.\r
d716651f 417\r
418 @retval EFI_SUCCESS The command was accepted without any errors.\r
419 @retval EFI_NOT_FOUND Device does not support this data class \r
420 @retval EFI_DEVICE_ERROR Error reading InquiryData from device \r
421 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough \r
422\r
423**/\r
424EFI_STATUS\r
425EFIAPI\r
426ScsiDiskInfoInquiry (\r
427 IN EFI_DISK_INFO_PROTOCOL *This,\r
428 IN OUT VOID *InquiryData,\r
429 IN OUT UINT32 *InquiryDataSize\r
430 );\r
431\r
432\r
433/**\r
434 Provides identify information for the controller type.\r
435\r
436 This function is used by the IDE bus driver to get identify data. Data format\r
437 of Identify data is defined by the Interface GUID.\r
438\r
439 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL \r
440 instance.\r
4140a663 441 @param[in, out] IdentifyData Pointer to a buffer for the identify data.\r
442 @param[in, out] IdentifyDataSize Pointer to the value for the identify data\r
d716651f 443 size.\r
444\r
445 @retval EFI_SUCCESS The command was accepted without any errors.\r
446 @retval EFI_NOT_FOUND Device does not support this data class \r
447 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device \r
448 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough \r
449\r
450**/\r
451EFI_STATUS\r
452EFIAPI\r
453ScsiDiskInfoIdentify (\r
454 IN EFI_DISK_INFO_PROTOCOL *This,\r
455 IN OUT VOID *IdentifyData,\r
456 IN OUT UINT32 *IdentifyDataSize\r
457 );\r
458\r
459\r
460/**\r
461 Provides sense data information for the controller type.\r
462 \r
463 This function is used by the IDE bus driver to get sense data. \r
464 Data format of Sense data is defined by the Interface GUID.\r
465\r
4140a663 466 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
467 @param[in, out] SenseData Pointer to the SenseData.\r
468 @param[in, out] SenseDataSize Size of SenseData in bytes.\r
469 @param[out] SenseDataNumber Pointer to the value for the sense data size.\r
d716651f 470\r
471 @retval EFI_SUCCESS The command was accepted without any errors.\r
472 @retval EFI_NOT_FOUND Device does not support this data class.\r
473 @retval EFI_DEVICE_ERROR Error reading SenseData from device.\r
474 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.\r
475\r
476**/\r
477EFI_STATUS\r
478EFIAPI\r
479ScsiDiskInfoSenseData (\r
480 IN EFI_DISK_INFO_PROTOCOL *This,\r
481 IN OUT VOID *SenseData,\r
482 IN OUT UINT32 *SenseDataSize,\r
483 OUT UINT8 *SenseDataNumber\r
484 );\r
485\r
486/**\r
487 This function is used by the IDE bus driver to get controller information.\r
488\r
489 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance. \r
490 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.\r
491 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.\r
492\r
493 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.\r
494 @retval EFI_UNSUPPORTED This is not an IDE device.\r
495\r
496**/\r
497EFI_STATUS\r
498EFIAPI\r
499ScsiDiskInfoWhichIde (\r
500 IN EFI_DISK_INFO_PROTOCOL *This,\r
501 OUT UINT32 *IdeChannel,\r
502 OUT UINT32 *IdeDevice\r
503 );\r
504\r
505\r
9beb888e 506/**\r
d716651f 507 Detect Device and read out capacity ,if error occurs, parse the sense key.\r
6ad55b15 508\r
9beb888e 509 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
510 @param MustReadCapacity The flag about reading device capacity\r
511 @param MediaChange The pointer of flag indicates if media has changed \r
6ad55b15 512\r
9beb888e 513 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
514 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 515\r
9beb888e 516**/\r
6ad55b15 517EFI_STATUS\r
518ScsiDiskDetectMedia (\r
9beb888e 519 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
520 IN BOOLEAN MustReadCapacity,\r
521 OUT BOOLEAN *MediaChange\r
522 );\r
6ad55b15 523\r
9beb888e 524/**\r
d716651f 525 To test device.\r
6ad55b15 526\r
9beb888e 527 When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;\r
528 When Test Unit Ready command encounters any error caused by host adapter or\r
529 target, return error without retrieving Sense Keys.\r
6ad55b15 530\r
9beb888e 531 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
532 @param NeedRetry The pointer of flag indicates try again\r
533 @param SenseDataArray The pointer of an array of sense data\r
534 @param NumberOfSenseKeys The pointer of the number of sense data array\r
6ad55b15 535\r
9beb888e 536 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
537 @retval EFI_SUCCESS Successfully to test unit\r
f36d6e66 538\r
9beb888e 539**/\r
6ad55b15 540EFI_STATUS\r
541ScsiDiskTestUnitReady (\r
9beb888e 542 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
543 OUT BOOLEAN *NeedRetry,\r
544 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
545 OUT UINTN *NumberOfSenseKeys\r
546 );\r
6ad55b15 547\r
6ad55b15 548\r
9beb888e 549/**\r
550 Parsing Sense Keys which got from request sense command.\r
6ad55b15 551\r
9beb888e 552 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
553 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
554 @param NumberOfSenseKeys The number of sense key \r
555 @param Action The pointer of action which indicates what is need to do next\r
6ad55b15 556\r
9beb888e 557 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
558 @retval EFI_SUCCESS Successfully to complete the parsing\r
6ad55b15 559\r
9beb888e 560**/\r
6ad55b15 561EFI_STATUS\r
562DetectMediaParsingSenseKeys (\r
9beb888e 563 OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
564 IN EFI_SCSI_SENSE_DATA *SenseData,\r
565 IN UINTN NumberOfSenseKeys,\r
566 OUT UINTN *Action\r
567 );\r
6ad55b15 568\r
6ad55b15 569\r
9beb888e 570/**\r
571 Send read capacity command to device and get the device parameter.\r
6ad55b15 572\r
9beb888e 573 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
574 @param NeedRetry The pointer of flag indicates if need a retry\r
575 @param SenseDataArray The pointer of an array of sense data\r
576 @param NumberOfSenseKeys The number of sense key\r
6ad55b15 577\r
9beb888e 578 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
579 @retval EFI_SUCCESS Successfully to read capacity\r
6ad55b15 580\r
9beb888e 581**/\r
6ad55b15 582EFI_STATUS\r
583ScsiDiskReadCapacity (\r
9beb888e 584 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
585 OUT BOOLEAN *NeedRetry,\r
586 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
587 OUT UINTN *NumberOfSenseKeys\r
588 );\r
6ad55b15 589\r
9beb888e 590/**\r
591 Check the HostAdapter status and re-interpret it in EFI_STATUS.\r
6ad55b15 592\r
9beb888e 593 @param HostAdapterStatus Host Adapter status\r
6ad55b15 594\r
9beb888e 595 @retval EFI_SUCCESS Host adapter is OK.\r
596 @retval EFI_TIMEOUT Timeout.\r
597 @retval EFI_NOT_READY Adapter NOT ready.\r
598 @retval EFI_DEVICE_ERROR Adapter device error.\r
6ad55b15 599\r
9beb888e 600**/\r
6ad55b15 601EFI_STATUS\r
602CheckHostAdapterStatus (\r
9beb888e 603 IN UINT8 HostAdapterStatus\r
604 );\r
6ad55b15 605\r
6ad55b15 606\r
9beb888e 607/**\r
608 Check the target status and re-interpret it in EFI_STATUS.\r
6ad55b15 609\r
9beb888e 610 @param TargetStatus Target status\r
6ad55b15 611\r
9beb888e 612 @retval EFI_NOT_READY Device is NOT ready.\r
613 @retval EFI_DEVICE_ERROR \r
614 @retval EFI_SUCCESS\r
6ad55b15 615\r
9beb888e 616**/\r
6ad55b15 617EFI_STATUS\r
618CheckTargetStatus (\r
9beb888e 619 IN UINT8 TargetStatus\r
620 );\r
6ad55b15 621\r
9beb888e 622/**\r
623 Retrieve all sense keys from the device.\r
6ad55b15 624\r
9beb888e 625 When encountering error during the process, if retrieve sense keys before\r
d716651f 626 error encountered, it returns the sense keys with return status set to EFI_SUCCESS,\r
9beb888e 627 and NeedRetry set to FALSE; otherwize, return the proper return status.\r
6ad55b15 628\r
9beb888e 629 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
630 @param NeedRetry The pointer of flag indicates if need a retry\r
631 @param SenseDataArray The pointer of an array of sense data\r
632 @param NumberOfSenseKeys The number of sense key\r
633 @param AskResetIfError The flag indicates if need reset when error occurs\r
6ad55b15 634\r
9beb888e 635 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
636 @retval EFI_SUCCESS Successfully to request sense key\r
6ad55b15 637\r
9beb888e 638**/\r
6ad55b15 639EFI_STATUS\r
640ScsiDiskRequestSenseKeys (\r
9beb888e 641 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
642 OUT BOOLEAN *NeedRetry,\r
643 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
644 OUT UINTN *NumberOfSenseKeys,\r
645 IN BOOLEAN AskResetIfError\r
646 );\r
6ad55b15 647\r
9beb888e 648/**\r
649 Send out Inquiry command to Device.\r
6ad55b15 650\r
9beb888e 651 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
652 @param NeedRetry Indicates if needs try again when error happens\r
6ad55b15 653\r
9beb888e 654 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
655 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 656\r
9beb888e 657**/\r
6ad55b15 658EFI_STATUS\r
659ScsiDiskInquiryDevice (\r
9beb888e 660 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
661 OUT BOOLEAN *NeedRetry\r
662 );\r
6ad55b15 663\r
9beb888e 664/**\r
665 Parse Inquiry data.\r
6ad55b15 666\r
9beb888e 667 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 668\r
9beb888e 669**/\r
6ad55b15 670VOID\r
671ParseInquiryData (\r
9beb888e 672 IN OUT SCSI_DISK_DEV *ScsiDiskDevice\r
673 );\r
6ad55b15 674\r
9beb888e 675/**\r
676 Read sector from SCSI Disk.\r
6ad55b15 677\r
d716651f 678 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
9beb888e 679 @param Buffer The buffer to fill in the read out data\r
680 @param Lba Logic block address\r
681 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 682\r
9beb888e 683 @retval EFI_DEVICE_ERROR Indicates a device error.\r
684 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 685\r
9beb888e 686**/\r
6ad55b15 687EFI_STATUS\r
688ScsiDiskReadSectors (\r
9beb888e 689 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
690 OUT VOID *Buffer,\r
691 IN EFI_LBA Lba,\r
692 IN UINTN NumberOfBlocks\r
693 );\r
6ad55b15 694\r
9beb888e 695/**\r
696 Write sector to SCSI Disk.\r
6ad55b15 697\r
d716651f 698 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
9beb888e 699 @param Buffer The buffer of data to be written into SCSI Disk\r
700 @param Lba Logic block address\r
701 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 702\r
9beb888e 703 @retval EFI_DEVICE_ERROR Indicates a device error.\r
704 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 705\r
9beb888e 706**/\r
6ad55b15 707EFI_STATUS\r
708ScsiDiskWriteSectors (\r
9beb888e 709 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
710 IN VOID *Buffer,\r
711 IN EFI_LBA Lba,\r
712 IN UINTN NumberOfBlocks\r
713 );\r
6ad55b15 714\r
9beb888e 715/**\r
d716651f 716 Submit Read command.\r
9beb888e 717\r
718 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
719 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
720 @param SenseDataArray NOT used yet in this function\r
721 @param NumberOfSenseKeys The number of sense key\r
722 @param Timeout The time to complete the command\r
723 @param DataBuffer The buffer to fill with the read out data\r
724 @param DataLength The length of buffer\r
725 @param StartLba The start logic block address\r
726 @param SectorSize The size of sector\r
727\r
728 @return EFI_STATUS is returned by calling ScsiRead10Command().\r
729**/\r
6ad55b15 730EFI_STATUS\r
731ScsiDiskRead10 (\r
9beb888e 732 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
733 OUT BOOLEAN *NeedRetry,\r
734 OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OPTIONAL\r
735 OUT UINTN *NumberOfSenseKeys,\r
736 IN UINT64 Timeout,\r
737 OUT UINT8 *DataBuffer,\r
738 IN OUT UINT32 *DataLength,\r
739 IN UINT32 StartLba,\r
740 IN UINT32 SectorSize\r
741 );\r
6ad55b15 742\r
9beb888e 743/**\r
744 Submit Write Command.\r
6ad55b15 745\r
9beb888e 746 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
747 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
748 @param SenseDataArray NOT used yet in this function\r
749 @param NumberOfSenseKeys The number of sense key\r
750 @param Timeout The time to complete the command\r
751 @param DataBuffer The buffer to fill with the read out data\r
752 @param DataLength The length of buffer\r
753 @param StartLba The start logic block address\r
754 @param SectorSize The size of sector\r
6ad55b15 755\r
9beb888e 756 @return EFI_STATUS is returned by calling ScsiWrite10Command().\r
6ad55b15 757\r
9beb888e 758**/\r
6ad55b15 759EFI_STATUS\r
760ScsiDiskWrite10 (\r
9beb888e 761 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
762 OUT BOOLEAN *NeedRetry,\r
763 OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OPTIONAL\r
764 OUT UINTN *NumberOfSenseKeys,\r
765 IN UINT64 Timeout,\r
766 IN UINT8 *DataBuffer,\r
767 IN OUT UINT32 *DataLength,\r
768 IN UINT32 StartLba,\r
769 IN UINT32 SectorSize\r
770 );\r
6ad55b15 771\r
a108933e 772/**\r
773 Submit Read(16) command.\r
774\r
775 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
776 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
777 @param SenseDataArray NOT used yet in this function\r
778 @param NumberOfSenseKeys The number of sense key\r
779 @param Timeout The time to complete the command\r
780 @param DataBuffer The buffer to fill with the read out data\r
781 @param DataLength The length of buffer\r
782 @param StartLba The start logic block address\r
783 @param SectorSize The size of sector\r
784\r
785 @return EFI_STATUS is returned by calling ScsiRead10Command().\r
786**/\r
787EFI_STATUS\r
788ScsiDiskRead16 (\r
789 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
790 OUT BOOLEAN *NeedRetry,\r
791 OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OPTIONAL\r
792 OUT UINTN *NumberOfSenseKeys,\r
793 IN UINT64 Timeout,\r
794 OUT UINT8 *DataBuffer,\r
795 IN OUT UINT32 *DataLength,\r
796 IN UINT64 StartLba,\r
797 IN UINT32 SectorSize\r
798 );\r
799 \r
800/**\r
801 Submit Write(16) Command.\r
802\r
803 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
804 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
805 @param SenseDataArray NOT used yet in this function\r
806 @param NumberOfSenseKeys The number of sense key\r
807 @param Timeout The time to complete the command\r
808 @param DataBuffer The buffer to fill with the read out data\r
809 @param DataLength The length of buffer\r
810 @param StartLba The start logic block address\r
811 @param SectorSize The size of sector\r
812\r
813 @return EFI_STATUS is returned by calling ScsiWrite10Command().\r
814\r
815**/\r
816EFI_STATUS\r
817ScsiDiskWrite16 (\r
818 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
819 OUT BOOLEAN *NeedRetry,\r
820 OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OPTIONAL\r
821 OUT UINTN *NumberOfSenseKeys,\r
822 IN UINT64 Timeout,\r
823 IN UINT8 *DataBuffer,\r
824 IN OUT UINT32 *DataLength,\r
825 IN UINT64 StartLba,\r
826 IN UINT32 SectorSize\r
827 ); \r
828\r
9beb888e 829/**\r
830 Get information from media read capacity command.\r
6ad55b15 831\r
9beb888e 832 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
b96cd313 833 @param Capacity10 The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
834 @param Capacity16 The pointer of EFI_SCSI_DISK_CAPACITY_DATA16\r
9beb888e 835**/\r
6ad55b15 836VOID\r
837GetMediaInfo (\r
aa75dfec 838 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
839 IN EFI_SCSI_DISK_CAPACITY_DATA *Capacity10,\r
840 IN EFI_SCSI_DISK_CAPACITY_DATA16 *Capacity16\r
9beb888e 841 );\r
6ad55b15 842\r
9beb888e 843/**\r
844 Check sense key to find if media presents.\r
6ad55b15 845\r
9beb888e 846 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
847 @param SenseCounts The number of sense key\r
6ad55b15 848\r
9beb888e 849 @retval TRUE NOT any media\r
850 @retval FALSE Media presents\r
851**/\r
6ad55b15 852BOOLEAN\r
853ScsiDiskIsNoMedia (\r
854 IN EFI_SCSI_SENSE_DATA *SenseData,\r
855 IN UINTN SenseCounts\r
9beb888e 856 );\r
6ad55b15 857\r
9beb888e 858/**\r
859 Parse sense key.\r
6ad55b15 860\r
9beb888e 861 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
862 @param SenseCounts The number of sense key\r
6ad55b15 863\r
9beb888e 864 @retval TRUE Error\r
865 @retval FALSE NOT error\r
6ad55b15 866\r
9beb888e 867**/\r
6ad55b15 868BOOLEAN\r
869ScsiDiskIsMediaError (\r
870 IN EFI_SCSI_SENSE_DATA *SenseData,\r
871 IN UINTN SenseCounts\r
9beb888e 872 );\r
6ad55b15 873\r
9beb888e 874/**\r
875 Check sense key to find if hardware error happens.\r
6ad55b15 876\r
9beb888e 877 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
878 @param SenseCounts The number of sense key\r
6ad55b15 879\r
9beb888e 880 @retval TRUE Hardware error exits.\r
881 @retval FALSE NO error.\r
6ad55b15 882\r
9beb888e 883**/\r
6ad55b15 884BOOLEAN\r
885ScsiDiskIsHardwareError (\r
886 IN EFI_SCSI_SENSE_DATA *SenseData,\r
887 IN UINTN SenseCounts\r
9beb888e 888 );\r
6ad55b15 889\r
9beb888e 890/**\r
891 Check sense key to find if media has changed.\r
6ad55b15 892\r
9beb888e 893 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
894 @param SenseCounts The number of sense key\r
6ad55b15 895\r
9beb888e 896 @retval TRUE Media is changed.\r
897 @retval FALSE Medit is NOT changed.\r
898**/\r
6ad55b15 899BOOLEAN\r
900ScsiDiskIsMediaChange (\r
901 IN EFI_SCSI_SENSE_DATA *SenseData,\r
902 IN UINTN SenseCounts\r
9beb888e 903 );\r
6ad55b15 904\r
9beb888e 905/**\r
906 Check sense key to find if reset happens.\r
6ad55b15 907\r
9beb888e 908 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
909 @param SenseCounts The number of sense key\r
6ad55b15 910\r
9beb888e 911 @retval TRUE It is reset before.\r
912 @retval FALSE It is NOT reset before.\r
6ad55b15 913\r
9beb888e 914**/\r
6ad55b15 915BOOLEAN\r
916ScsiDiskIsResetBefore (\r
917 IN EFI_SCSI_SENSE_DATA *SenseData,\r
918 IN UINTN SenseCounts\r
9beb888e 919 );\r
6ad55b15 920\r
9beb888e 921/**\r
922 Check sense key to find if the drive is ready.\r
6ad55b15 923\r
9beb888e 924 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
925 @param SenseCounts The number of sense key\r
926 @param RetryLater The flag means if need a retry \r
6ad55b15 927\r
9beb888e 928 @retval TRUE Drive is ready.\r
929 @retval FALSE Drive is NOT ready.\r
6ad55b15 930\r
9beb888e 931**/\r
6ad55b15 932BOOLEAN\r
933ScsiDiskIsDriveReady (\r
934 IN EFI_SCSI_SENSE_DATA *SenseData,\r
935 IN UINTN SenseCounts,\r
9beb888e 936 OUT BOOLEAN *RetryLater\r
937 );\r
6ad55b15 938\r
9beb888e 939/**\r
940 Check sense key to find if it has sense key.\r
6ad55b15 941\r
9beb888e 942 @param SenseData - The pointer of EFI_SCSI_SENSE_DATA\r
943 @param SenseCounts - The number of sense key\r
6ad55b15 944\r
9beb888e 945 @retval TRUE It has sense key.\r
946 @retval FALSE It has NOT any sense key.\r
6ad55b15 947\r
9beb888e 948**/\r
6ad55b15 949BOOLEAN\r
950ScsiDiskHaveSenseKey (\r
951 IN EFI_SCSI_SENSE_DATA *SenseData,\r
952 IN UINTN SenseCounts\r
9beb888e 953 );\r
6ad55b15 954\r
9beb888e 955/**\r
956 Release resource about disk device.\r
6ad55b15 957\r
9beb888e 958 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 959\r
9beb888e 960**/\r
6ad55b15 961VOID\r
962ReleaseScsiDiskDeviceResources (\r
963 IN SCSI_DISK_DEV *ScsiDiskDevice\r
9beb888e 964 );\r
6ad55b15 965\r
d14faa52 966/**\r
967 Determine if Block Io should be produced.\r
968 \r
969\r
d716651f 970 @param ChildHandle Child Handle to retrieve Parent information.\r
d14faa52 971 \r
972 @retval TRUE Should produce Block Io.\r
973 @retval FALSE Should not produce Block Io.\r
974\r
975**/ \r
976BOOLEAN\r
977DetermineInstallBlockIo (\r
978 IN EFI_HANDLE ChildHandle\r
979 );\r
980\r
d716651f 981/**\r
982 Initialize the installation of DiskInfo protocol.\r
983\r
984 This function prepares for the installation of DiskInfo protocol on the child handle.\r
985 By default, it installs DiskInfo protocol with SCSI interface GUID. If it further\r
986 detects that the physical device is an ATAPI/AHCI device, it then updates interface GUID\r
987 to be IDE/AHCI interface GUID.\r
988\r
989 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.\r
990 @param ChildHandle Child handle to install DiskInfo protocol.\r
991 \r
992**/ \r
993VOID\r
994InitializeInstallDiskInfo (\r
995 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
996 IN EFI_HANDLE ChildHandle\r
997 ); \r
998\r
d14faa52 999/**\r
1000 Search protocol database and check to see if the protocol\r
1001 specified by ProtocolGuid is present on a ControllerHandle and opened by\r
1002 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
1003 If the ControllerHandle is found, then the protocol specified by ProtocolGuid\r
1004 will be opened on it. \r
1005 \r
1006\r
1007 @param ProtocolGuid ProtocolGuid pointer.\r
1008 @param ChildHandle Child Handle to retrieve Parent information.\r
1009 \r
1010**/ \r
1011VOID *\r
1012EFIAPI\r
1013GetParentProtocol (\r
1014 IN EFI_GUID *ProtocolGuid,\r
1015 IN EFI_HANDLE ChildHandle\r
1016 );\r
1017\r
6ad55b15 1018#endif\r