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