]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
Add Local APIC library mapping.
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ScsiDisk.h
... / ...
CommitLineData
1/** @file\r
2 Header file for SCSI Disk Driver.\r
3\r
4Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _SCSI_DISK_H_\r
16#define _SCSI_DISK_H_\r
17\r
18\r
19#include <Uefi.h>\r
20\r
21\r
22#include <Protocol/ScsiIo.h>\r
23#include <Protocol/ComponentName.h>\r
24#include <Protocol/BlockIo.h>\r
25#include <Protocol/DriverBinding.h>\r
26#include <Protocol/ScsiPassThruExt.h>\r
27#include <Protocol/ScsiPassThru.h>\r
28#include <Protocol/DiskInfo.h>\r
29\r
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
35#include <Library/MemoryAllocationLib.h>\r
36#include <Library/UefiScsiLib.h>\r
37#include <Library/UefiBootServicesTableLib.h>\r
38#include <Library/DevicePathLib.h>\r
39\r
40#include <IndustryStandard/Scsi.h>\r
41#include <IndustryStandard/Atapi.h>\r
42\r
43#define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0\r
44\r
45#define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')\r
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
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
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
77#define SCSI_DISK_DEV_FROM_DISKINFO(a) CR (a, SCSI_DISK_DEV, DiskInfo, SCSI_DISK_DEV_SIGNATURE)\r
78\r
79//\r
80// Global Variables\r
81//\r
82extern EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding;\r
83extern EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName;\r
84extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2;\r
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
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
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
116EFI_STATUS\r
117EFIAPI\r
118ScsiDiskDriverBindingSupported (\r
119 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
120 IN EFI_HANDLE Controller,\r
121 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
122 );\r
123\r
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
143EFI_STATUS\r
144EFIAPI\r
145ScsiDiskDriverBindingStart (\r
146 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
147 IN EFI_HANDLE Controller,\r
148 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
149 );\r
150\r
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
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
176 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
177 );\r
178\r
179//\r
180// EFI Component Name Functions\r
181//\r
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
192 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
193 EFI_COMPONENT_NAME_PROTOCOL instance.\r
194\r
195 @param Language A pointer to a Null-terminated ASCII string\r
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
202 in RFC 4646 or ISO 639-2 language code format.\r
203\r
204 @param DriverName A pointer to the Unicode string to return.\r
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
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
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
243 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
244 EFI_COMPONENT_NAME_PROTOCOL instance.\r
245\r
246 @param ControllerHandle The handle of a controller that the driver\r
247 specified by This is managing. This handle\r
248 specifies the controller whose name is to be\r
249 returned.\r
250\r
251 @param ChildHandle The handle of the child controller to retrieve\r
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
260 @param Language A pointer to a Null-terminated ASCII string\r
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
267 RFC 4646 or ISO 639-2 language code format.\r
268\r
269 @param ControllerName A pointer to the Unicode string to return.\r
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
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
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
314\r
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
321EFI_STATUS\r
322EFIAPI\r
323ScsiDiskReset (\r
324 IN EFI_BLOCK_IO_PROTOCOL *This,\r
325 IN BOOLEAN ExtendedVerification\r
326 );\r
327\r
328\r
329/**\r
330 The function is to Read Block from SCSI Disk.\r
331\r
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
337\r
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
344\r
345**/\r
346EFI_STATUS\r
347EFIAPI\r
348ScsiDiskReadBlocks (\r
349 IN EFI_BLOCK_IO_PROTOCOL *This,\r
350 IN UINT32 MediaId,\r
351 IN EFI_LBA Lba,\r
352 IN UINTN BufferSize,\r
353 OUT VOID *Buffer\r
354 );\r
355\r
356\r
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
373\r
374**/\r
375EFI_STATUS\r
376EFIAPI\r
377ScsiDiskWriteBlocks (\r
378 IN EFI_BLOCK_IO_PROTOCOL *This,\r
379 IN UINT32 MediaId,\r
380 IN EFI_LBA Lba,\r
381 IN UINTN BufferSize,\r
382 IN VOID *Buffer\r
383 );\r
384\r
385\r
386/**\r
387 Flush Block to Disk.\r
388\r
389 EFI_SUCCESS is returned directly.\r
390\r
391 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
392\r
393 @retval EFI_SUCCESS All outstanding data was written to the device\r
394\r
395**/\r
396EFI_STATUS\r
397EFIAPI\r
398ScsiDiskFlushBlocks (\r
399 IN EFI_BLOCK_IO_PROTOCOL *This\r
400 );\r
401\r
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
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
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
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
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
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
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
501/**\r
502 Detect Device and read out capacity ,if error occurs, parse the sense key.\r
503\r
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
507\r
508 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
509 @retval EFI_SUCCESS Successfully to detect media\r
510\r
511**/\r
512EFI_STATUS\r
513ScsiDiskDetectMedia (\r
514 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
515 IN BOOLEAN MustReadCapacity,\r
516 OUT BOOLEAN *MediaChange\r
517 );\r
518\r
519/**\r
520 To test device.\r
521\r
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
525\r
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
530\r
531 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
532 @retval EFI_SUCCESS Successfully to test unit\r
533\r
534**/\r
535EFI_STATUS\r
536ScsiDiskTestUnitReady (\r
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
542\r
543\r
544/**\r
545 Parsing Sense Keys which got from request sense command.\r
546\r
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
551\r
552 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
553 @retval EFI_SUCCESS Successfully to complete the parsing\r
554\r
555**/\r
556EFI_STATUS\r
557DetectMediaParsingSenseKeys (\r
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
563\r
564\r
565/**\r
566 Send read capacity command to device and get the device parameter.\r
567\r
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
572\r
573 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
574 @retval EFI_SUCCESS Successfully to read capacity\r
575\r
576**/\r
577EFI_STATUS\r
578ScsiDiskReadCapacity (\r
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
584\r
585/**\r
586 Check the HostAdapter status and re-interpret it in EFI_STATUS.\r
587\r
588 @param HostAdapterStatus Host Adapter status\r
589\r
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
594\r
595**/\r
596EFI_STATUS\r
597CheckHostAdapterStatus (\r
598 IN UINT8 HostAdapterStatus\r
599 );\r
600\r
601\r
602/**\r
603 Check the target status and re-interpret it in EFI_STATUS.\r
604\r
605 @param TargetStatus Target status\r
606\r
607 @retval EFI_NOT_READY Device is NOT ready.\r
608 @retval EFI_DEVICE_ERROR \r
609 @retval EFI_SUCCESS\r
610\r
611**/\r
612EFI_STATUS\r
613CheckTargetStatus (\r
614 IN UINT8 TargetStatus\r
615 );\r
616\r
617/**\r
618 Retrieve all sense keys from the device.\r
619\r
620 When encountering error during the process, if retrieve sense keys before\r
621 error encountered, it returns the sense keys with return status set to EFI_SUCCESS,\r
622 and NeedRetry set to FALSE; otherwize, return the proper return status.\r
623\r
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
629\r
630 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
631 @retval EFI_SUCCESS Successfully to request sense key\r
632\r
633**/\r
634EFI_STATUS\r
635ScsiDiskRequestSenseKeys (\r
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
642\r
643/**\r
644 Send out Inquiry command to Device.\r
645\r
646 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
647 @param NeedRetry Indicates if needs try again when error happens\r
648\r
649 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
650 @retval EFI_SUCCESS Successfully to detect media\r
651\r
652**/\r
653EFI_STATUS\r
654ScsiDiskInquiryDevice (\r
655 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
656 OUT BOOLEAN *NeedRetry\r
657 );\r
658\r
659/**\r
660 Parse Inquiry data.\r
661\r
662 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
663\r
664**/\r
665VOID\r
666ParseInquiryData (\r
667 IN OUT SCSI_DISK_DEV *ScsiDiskDevice\r
668 );\r
669\r
670/**\r
671 Read sector from SCSI Disk.\r
672\r
673 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
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
677\r
678 @retval EFI_DEVICE_ERROR Indicates a device error.\r
679 @retval EFI_SUCCESS Operation is successful.\r
680\r
681**/\r
682EFI_STATUS\r
683ScsiDiskReadSectors (\r
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
689\r
690/**\r
691 Write sector to SCSI Disk.\r
692\r
693 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
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
697\r
698 @retval EFI_DEVICE_ERROR Indicates a device error.\r
699 @retval EFI_SUCCESS Operation is successful.\r
700\r
701**/\r
702EFI_STATUS\r
703ScsiDiskWriteSectors (\r
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
709\r
710/**\r
711 Submit Read command.\r
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
725EFI_STATUS\r
726ScsiDiskRead10 (\r
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
737\r
738/**\r
739 Submit Write Command.\r
740\r
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
750\r
751 @return EFI_STATUS is returned by calling ScsiWrite10Command().\r
752\r
753**/\r
754EFI_STATUS\r
755ScsiDiskWrite10 (\r
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
766\r
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
824/**\r
825 Get information from media read capacity command.\r
826\r
827 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
828 @param Capacity10 The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
829 @param Capacity16 The pointer of EFI_SCSI_DISK_CAPACITY_DATA16\r
830**/\r
831VOID\r
832GetMediaInfo (\r
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
836 );\r
837\r
838/**\r
839 Check sense key to find if media presents.\r
840\r
841 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
842 @param SenseCounts The number of sense key\r
843\r
844 @retval TRUE NOT any media\r
845 @retval FALSE Media presents\r
846**/\r
847BOOLEAN\r
848ScsiDiskIsNoMedia (\r
849 IN EFI_SCSI_SENSE_DATA *SenseData,\r
850 IN UINTN SenseCounts\r
851 );\r
852\r
853/**\r
854 Parse sense key.\r
855\r
856 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
857 @param SenseCounts The number of sense key\r
858\r
859 @retval TRUE Error\r
860 @retval FALSE NOT error\r
861\r
862**/\r
863BOOLEAN\r
864ScsiDiskIsMediaError (\r
865 IN EFI_SCSI_SENSE_DATA *SenseData,\r
866 IN UINTN SenseCounts\r
867 );\r
868\r
869/**\r
870 Check sense key to find if hardware error happens.\r
871\r
872 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
873 @param SenseCounts The number of sense key\r
874\r
875 @retval TRUE Hardware error exits.\r
876 @retval FALSE NO error.\r
877\r
878**/\r
879BOOLEAN\r
880ScsiDiskIsHardwareError (\r
881 IN EFI_SCSI_SENSE_DATA *SenseData,\r
882 IN UINTN SenseCounts\r
883 );\r
884\r
885/**\r
886 Check sense key to find if media has changed.\r
887\r
888 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
889 @param SenseCounts The number of sense key\r
890\r
891 @retval TRUE Media is changed.\r
892 @retval FALSE Medit is NOT changed.\r
893**/\r
894BOOLEAN\r
895ScsiDiskIsMediaChange (\r
896 IN EFI_SCSI_SENSE_DATA *SenseData,\r
897 IN UINTN SenseCounts\r
898 );\r
899\r
900/**\r
901 Check sense key to find if reset happens.\r
902\r
903 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
904 @param SenseCounts The number of sense key\r
905\r
906 @retval TRUE It is reset before.\r
907 @retval FALSE It is NOT reset before.\r
908\r
909**/\r
910BOOLEAN\r
911ScsiDiskIsResetBefore (\r
912 IN EFI_SCSI_SENSE_DATA *SenseData,\r
913 IN UINTN SenseCounts\r
914 );\r
915\r
916/**\r
917 Check sense key to find if the drive is ready.\r
918\r
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
922\r
923 @retval TRUE Drive is ready.\r
924 @retval FALSE Drive is NOT ready.\r
925\r
926**/\r
927BOOLEAN\r
928ScsiDiskIsDriveReady (\r
929 IN EFI_SCSI_SENSE_DATA *SenseData,\r
930 IN UINTN SenseCounts,\r
931 OUT BOOLEAN *RetryLater\r
932 );\r
933\r
934/**\r
935 Check sense key to find if it has sense key.\r
936\r
937 @param SenseData - The pointer of EFI_SCSI_SENSE_DATA\r
938 @param SenseCounts - The number of sense key\r
939\r
940 @retval TRUE It has sense key.\r
941 @retval FALSE It has NOT any sense key.\r
942\r
943**/\r
944BOOLEAN\r
945ScsiDiskHaveSenseKey (\r
946 IN EFI_SCSI_SENSE_DATA *SenseData,\r
947 IN UINTN SenseCounts\r
948 );\r
949\r
950/**\r
951 Release resource about disk device.\r
952\r
953 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
954\r
955**/\r
956VOID\r
957ReleaseScsiDiskDeviceResources (\r
958 IN SCSI_DISK_DEV *ScsiDiskDevice\r
959 );\r
960\r
961/**\r
962 Determine if Block Io should be produced.\r
963 \r
964\r
965 @param ChildHandle Child Handle to retrieve Parent information.\r
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
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
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
1013#endif\r