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