]>
Commit | Line | Data |
---|---|---|
a41b5272 | 1 | /** @file\r |
2 | This file implements ATA_PASSTHRU_PROCTOCOL and EXT_SCSI_PASSTHRU_PROTOCOL interfaces\r | |
3 | for managed ATA controllers.\r | |
58727f29 | 4 | \r |
06766c0e | 5 | Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r |
a41b5272 | 6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "AtaAtapiPassThru.h"\r | |
17 | \r | |
18 | //\r | |
19 | // EFI_DRIVER_BINDING_PROTOCOL instance\r | |
20 | //\r | |
21 | EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding = {\r | |
22 | AtaAtapiPassThruSupported,\r | |
23 | AtaAtapiPassThruStart,\r | |
24 | AtaAtapiPassThruStop,\r | |
25 | 0x10,\r | |
26 | NULL,\r | |
27 | NULL\r | |
28 | };\r | |
29 | \r | |
30 | ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = {\r | |
31 | ATA_ATAPI_PASS_THRU_SIGNATURE,\r | |
32 | 0, // Controller Handle\r | |
33 | NULL, // PciIo Protocol\r | |
34 | NULL, // IdeControllerInit Protocol\r | |
35 | { // AtaPassThruMode\r | |
36 | //\r | |
37 | // According to UEFI2.3 spec Section 12.10, Drivers for non-RAID ATA controllers should set\r | |
38 | // both EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL and EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL\r | |
39 | // bits.\r | |
40 | // Note that the driver doesn't support AtaPassThru non blocking I/O.\r | |
41 | //\r | |
490b5ea1 | 42 | EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL | EFI_ATA_PASS_THRU_ATTRIBUTES_NONBLOCKIO,\r |
a41b5272 | 43 | //\r |
44 | // IoAlign\r | |
45 | //\r | |
46 | sizeof (UINTN)\r | |
47 | },\r | |
48 | { // AtaPassThru\r | |
58727f29 | 49 | NULL,\r |
a41b5272 | 50 | AtaPassThruPassThru,\r |
51 | AtaPassThruGetNextPort,\r | |
52 | AtaPassThruGetNextDevice,\r | |
53 | AtaPassThruBuildDevicePath,\r | |
54 | AtaPassThruGetDevice,\r | |
55 | AtaPassThruResetPort,\r | |
58727f29 | 56 | AtaPassThruResetDevice\r |
a41b5272 | 57 | },\r |
58 | { // ExtScsiPassThruMode\r | |
59 | //\r | |
60 | // AdapterId\r | |
61 | //\r | |
62 | 0,\r | |
63 | //\r | |
64 | // According to UEFI2.3 spec Section 14.7, Drivers for non-RAID SCSI controllers should set\r | |
65 | // both EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL and EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL\r | |
66 | // bits.\r | |
67 | // Note that the driver doesn't support ExtScsiPassThru non blocking I/O.\r | |
58727f29 | 68 | //\r |
a41b5272 | 69 | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL,\r |
70 | //\r | |
71 | // IoAlign\r | |
72 | //\r | |
73 | sizeof (UINTN)\r | |
74 | },\r | |
75 | { // ExtScsiPassThru\r | |
76 | NULL,\r | |
77 | ExtScsiPassThruPassThru,\r | |
78 | ExtScsiPassThruGetNextTargetLun,\r | |
79 | ExtScsiPassThruBuildDevicePath,\r | |
80 | ExtScsiPassThruGetTargetLun,\r | |
81 | ExtScsiPassThruResetChannel,\r | |
82 | ExtScsiPassThruResetTargetLun,\r | |
83 | ExtScsiPassThruGetNextTarget\r | |
84 | },\r | |
85 | EfiAtaUnknownMode, // Work Mode\r | |
86 | { // IdeRegisters\r | |
87 | {0},\r | |
88 | {0}\r | |
89 | },\r | |
90 | { // AhciRegisters\r | |
91 | 0\r | |
92 | },\r | |
93 | { // DeviceList\r | |
94 | NULL,\r | |
95 | NULL\r | |
96 | },\r | |
eed3f713 | 97 | 0, // EnabledPciAttributes\r |
a41b5272 | 98 | 0, // OriginalAttributes\r |
99 | 0, // PreviousPort\r | |
100 | 0, // PreviousPortMultiplier\r | |
101 | 0, // PreviousTargetId\r | |
490b5ea1 | 102 | 0, // PreviousLun\r |
103 | NULL, // Timer event\r | |
104 | { // NonBlocking TaskList\r | |
58727f29 | 105 | NULL,\r |
490b5ea1 | 106 | NULL\r |
df076c7b | 107 | }\r |
a41b5272 | 108 | };\r |
109 | \r | |
110 | ATAPI_DEVICE_PATH mAtapiDevicePathTemplate = {\r | |
111 | {\r | |
112 | MESSAGING_DEVICE_PATH,\r | |
113 | MSG_ATAPI_DP,\r | |
ce68d3bc SZ |
114 | {\r |
115 | (UINT8) (sizeof (ATAPI_DEVICE_PATH)),\r | |
116 | (UINT8) ((sizeof (ATAPI_DEVICE_PATH)) >> 8)\r | |
117 | }\r | |
a41b5272 | 118 | },\r |
119 | 0,\r | |
120 | 0,\r | |
121 | 0\r | |
122 | };\r | |
123 | \r | |
124 | SATA_DEVICE_PATH mSataDevicePathTemplate = {\r | |
125 | {\r | |
126 | MESSAGING_DEVICE_PATH,\r | |
127 | MSG_SATA_DP,\r | |
ce68d3bc SZ |
128 | {\r |
129 | (UINT8) (sizeof (SATA_DEVICE_PATH)),\r | |
130 | (UINT8) ((sizeof (SATA_DEVICE_PATH)) >> 8)\r | |
131 | }\r | |
a41b5272 | 132 | },\r |
133 | 0,\r | |
134 | 0,\r | |
135 | 0\r | |
136 | };\r | |
137 | \r | |
138 | UINT8 mScsiId[TARGET_MAX_BYTES] = {\r | |
139 | 0xFF, 0xFF, 0xFF, 0xFF,\r | |
140 | 0xFF, 0xFF, 0xFF, 0xFF,\r | |
141 | 0xFF, 0xFF, 0xFF, 0xFF,\r | |
142 | 0xFF, 0xFF, 0xFF, 0xFF\r | |
143 | };\r | |
144 | \r | |
06766c0e RN |
145 | EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy;\r |
146 | EDKII_ATA_ATAPI_POLICY_PROTOCOL mDefaultAtaAtapiPolicy = {\r | |
147 | EDKII_ATA_ATAPI_POLICY_VERSION,\r | |
148 | 2, // PuisEnable\r | |
149 | 0, // DeviceSleepEnable\r | |
150 | 0, // AggressiveDeviceSleepEnable\r | |
151 | 0 // Reserved\r | |
152 | };\r | |
153 | \r | |
490b5ea1 | 154 | /**\r |
155 | Sends an ATA command to an ATA device that is attached to the ATA controller. This function\r | |
156 | supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required,\r | |
157 | and the non-blocking I/O functionality is optional.\r | |
158 | \r | |
58727f29 | 159 | @param[in] Port The port number of the ATA device to send the command.\r |
490b5ea1 | 160 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.\r |
23a596db | 161 | If there is no port multiplier, then specify 0xFFFF.\r |
490b5ea1 | 162 | @param[in, out] Packet A pointer to the ATA command to send to the ATA device specified by Port\r |
163 | and PortMultiplierPort.\r | |
164 | @param[in] Instance Pointer to the ATA_ATAPI_PASS_THRU_INSTANCE.\r | |
165 | @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK\r | |
166 | used by non-blocking mode.\r | |
167 | \r | |
168 | @retval EFI_SUCCESS The ATA command was sent by the host. For\r | |
169 | bi-directional commands, InTransferLength bytes\r | |
170 | were transferred from InDataBuffer. For\r | |
171 | write and bi-directional commands, OutTransferLength\r | |
172 | bytes were transferred by OutDataBuffer.\r | |
173 | @retval EFI_BAD_BUFFER_SIZE The ATA command was not executed. The number\r | |
174 | of bytes that could be transferred is returned\r | |
175 | in InTransferLength. For write and bi-directional\r | |
176 | commands, OutTransferLength bytes were transferred\r | |
177 | by OutDataBuffer.\r | |
178 | @retval EFI_NOT_READY The ATA command could not be sent because\r | |
179 | there are too many ATA commands already\r | |
180 | queued. The caller may retry again later.\r | |
181 | @retval EFI_DEVICE_ERROR A device error occurred while attempting\r | |
182 | to send the ATA command.\r | |
183 | @retval EFI_INVALID_PARAMETER Port, PortMultiplierPort, or the contents\r | |
184 | of Acb are invalid. The ATA command was\r | |
185 | not sent, so no additional status information\r | |
186 | is available.\r | |
187 | \r | |
188 | **/\r | |
189 | EFI_STATUS\r | |
190 | EFIAPI\r | |
191 | AtaPassThruPassThruExecute (\r | |
192 | IN UINT16 Port,\r | |
193 | IN UINT16 PortMultiplierPort,\r | |
194 | IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,\r | |
58727f29 | 195 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,\r |
490b5ea1 | 196 | IN ATA_NONBLOCK_TASK *Task OPTIONAL\r |
197 | )\r | |
198 | {\r | |
199 | EFI_ATA_PASS_THRU_CMD_PROTOCOL Protocol;\r | |
200 | EFI_ATA_HC_WORK_MODE Mode;\r | |
201 | EFI_STATUS Status;\r | |
58727f29 | 202 | \r |
490b5ea1 | 203 | Protocol = Packet->Protocol;\r |
204 | \r | |
205 | Mode = Instance->Mode;\r | |
206 | switch (Mode) {\r | |
207 | case EfiAtaIdeMode:\r | |
208 | //\r | |
209 | // Reassign IDE mode io port registers' base addresses\r | |
210 | //\r | |
211 | Status = GetIdeRegisterIoAddr (Instance->PciIo, Instance->IdeRegisters);\r | |
58727f29 | 212 | \r |
490b5ea1 | 213 | if (EFI_ERROR (Status)) {\r |
214 | return Status;\r | |
215 | }\r | |
58727f29 | 216 | \r |
490b5ea1 | 217 | switch (Protocol) {\r |
218 | case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:\r | |
219 | Status = AtaNonDataCommandIn (\r | |
220 | Instance->PciIo,\r | |
221 | &Instance->IdeRegisters[Port],\r | |
222 | Packet->Acb,\r | |
223 | Packet->Asb,\r | |
58727f29 | 224 | Packet->Timeout,\r |
490b5ea1 | 225 | Task\r |
226 | );\r | |
227 | break;\r | |
228 | case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN:\r | |
229 | Status = AtaPioDataInOut (\r | |
230 | Instance->PciIo,\r | |
231 | &Instance->IdeRegisters[Port],\r | |
232 | Packet->InDataBuffer,\r | |
233 | Packet->InTransferLength,\r | |
234 | TRUE,\r | |
235 | Packet->Acb,\r | |
236 | Packet->Asb,\r | |
237 | Packet->Timeout,\r | |
238 | Task\r | |
239 | );\r | |
240 | break;\r | |
241 | case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT:\r | |
242 | Status = AtaPioDataInOut (\r | |
243 | Instance->PciIo,\r | |
244 | &Instance->IdeRegisters[Port],\r | |
245 | Packet->OutDataBuffer,\r | |
246 | Packet->OutTransferLength,\r | |
247 | FALSE,\r | |
248 | Packet->Acb,\r | |
249 | Packet->Asb,\r | |
250 | Packet->Timeout,\r | |
251 | Task\r | |
252 | );\r | |
253 | break;\r | |
254 | case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_IN:\r | |
255 | Status = AtaUdmaInOut (\r | |
256 | Instance,\r | |
257 | &Instance->IdeRegisters[Port],\r | |
258 | TRUE,\r | |
259 | Packet->InDataBuffer,\r | |
260 | Packet->InTransferLength,\r | |
261 | Packet->Acb,\r | |
262 | Packet->Asb,\r | |
263 | Packet->Timeout,\r | |
264 | Task\r | |
265 | );\r | |
266 | break;\r | |
267 | case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_OUT:\r | |
268 | Status = AtaUdmaInOut (\r | |
269 | Instance,\r | |
270 | &Instance->IdeRegisters[Port],\r | |
271 | FALSE,\r | |
272 | Packet->OutDataBuffer,\r | |
273 | Packet->OutTransferLength,\r | |
274 | Packet->Acb,\r | |
275 | Packet->Asb,\r | |
276 | Packet->Timeout,\r | |
277 | Task\r | |
278 | );\r | |
279 | break;\r | |
280 | default :\r | |
281 | return EFI_UNSUPPORTED;\r | |
282 | }\r | |
283 | break;\r | |
284 | case EfiAtaAhciMode :\r | |
23a596db HW |
285 | if (PortMultiplierPort == 0xFFFF) {\r |
286 | //\r | |
287 | // If there is no port multiplier, PortMultiplierPort will be 0xFFFF\r | |
288 | // according to UEFI spec. Here, we convert its value to 0 to follow\r | |
289 | // AHCI spec.\r | |
290 | //\r | |
291 | PortMultiplierPort = 0;\r | |
292 | }\r | |
490b5ea1 | 293 | switch (Protocol) {\r |
294 | case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:\r | |
295 | Status = AhciNonDataTransfer (\r | |
296 | Instance->PciIo,\r | |
297 | &Instance->AhciRegisters,\r | |
298 | (UINT8)Port,\r | |
299 | (UINT8)PortMultiplierPort,\r | |
300 | NULL,\r | |
301 | 0,\r | |
302 | Packet->Acb,\r | |
303 | Packet->Asb,\r | |
304 | Packet->Timeout,\r | |
305 | Task\r | |
306 | );\r | |
307 | break;\r | |
308 | case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN:\r | |
309 | Status = AhciPioTransfer (\r | |
310 | Instance->PciIo,\r | |
311 | &Instance->AhciRegisters,\r | |
312 | (UINT8)Port,\r | |
313 | (UINT8)PortMultiplierPort,\r | |
314 | NULL,\r | |
315 | 0,\r | |
316 | TRUE,\r | |
317 | Packet->Acb,\r | |
318 | Packet->Asb,\r | |
319 | Packet->InDataBuffer,\r | |
320 | Packet->InTransferLength,\r | |
321 | Packet->Timeout,\r | |
322 | Task\r | |
323 | );\r | |
324 | break;\r | |
325 | case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT:\r | |
326 | Status = AhciPioTransfer (\r | |
327 | Instance->PciIo,\r | |
328 | &Instance->AhciRegisters,\r | |
329 | (UINT8)Port,\r | |
330 | (UINT8)PortMultiplierPort,\r | |
331 | NULL,\r | |
332 | 0,\r | |
333 | FALSE,\r | |
334 | Packet->Acb,\r | |
335 | Packet->Asb,\r | |
336 | Packet->OutDataBuffer,\r | |
337 | Packet->OutTransferLength,\r | |
58727f29 | 338 | Packet->Timeout,\r |
490b5ea1 | 339 | Task\r |
340 | );\r | |
341 | break;\r | |
342 | case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_IN:\r | |
343 | Status = AhciDmaTransfer (\r | |
344 | Instance,\r | |
345 | &Instance->AhciRegisters,\r | |
346 | (UINT8)Port,\r | |
347 | (UINT8)PortMultiplierPort,\r | |
348 | NULL,\r | |
349 | 0,\r | |
350 | TRUE,\r | |
351 | Packet->Acb,\r | |
352 | Packet->Asb,\r | |
353 | Packet->InDataBuffer,\r | |
354 | Packet->InTransferLength,\r | |
355 | Packet->Timeout,\r | |
356 | Task\r | |
357 | );\r | |
358 | break;\r | |
359 | case EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_OUT:\r | |
360 | Status = AhciDmaTransfer (\r | |
361 | Instance,\r | |
362 | &Instance->AhciRegisters,\r | |
363 | (UINT8)Port,\r | |
364 | (UINT8)PortMultiplierPort,\r | |
365 | NULL,\r | |
366 | 0,\r | |
367 | FALSE,\r | |
368 | Packet->Acb,\r | |
369 | Packet->Asb,\r | |
370 | Packet->OutDataBuffer,\r | |
371 | Packet->OutTransferLength,\r | |
372 | Packet->Timeout,\r | |
373 | Task\r | |
374 | );\r | |
375 | break;\r | |
376 | default :\r | |
377 | return EFI_UNSUPPORTED;\r | |
378 | }\r | |
379 | break;\r | |
380 | \r | |
381 | default:\r | |
382 | Status = EFI_DEVICE_ERROR;\r | |
383 | break;\r | |
384 | }\r | |
58727f29 | 385 | \r |
490b5ea1 | 386 | return Status;\r |
387 | }\r | |
388 | \r | |
389 | /**\r | |
390 | Call back function when the timer event is signaled.\r | |
391 | \r | |
392 | @param[in] Event The Event this notify function registered to.\r | |
393 | @param[in] Context Pointer to the context data registered to the\r | |
58727f29 | 394 | Event.\r |
395 | \r | |
490b5ea1 | 396 | **/\r |
397 | VOID\r | |
58727f29 | 398 | EFIAPI\r |
490b5ea1 | 399 | AsyncNonBlockingTransferRoutine (\r |
400 | EFI_EVENT Event,\r | |
401 | VOID* Context\r | |
402 | )\r | |
403 | {\r | |
404 | LIST_ENTRY *Entry;\r | |
405 | LIST_ENTRY *EntryHeader;\r | |
406 | ATA_NONBLOCK_TASK *Task;\r | |
407 | EFI_STATUS Status;\r | |
408 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
409 | \r | |
410 | Instance = (ATA_ATAPI_PASS_THRU_INSTANCE *) Context;\r | |
411 | EntryHeader = &Instance->NonBlockingTaskList;\r | |
412 | //\r | |
58727f29 | 413 | // Get the Taks from the Taks List and execute it, until there is\r |
490b5ea1 | 414 | // no task in the list or the device is busy with task (EFI_NOT_READY).\r |
415 | //\r | |
416 | while (TRUE) {\r | |
417 | if (!IsListEmpty (EntryHeader)) {\r | |
418 | Entry = GetFirstNode (EntryHeader);\r | |
419 | Task = ATA_NON_BLOCK_TASK_FROM_ENTRY (Entry);\r | |
420 | } else {\r | |
421 | return;\r | |
422 | }\r | |
423 | \r | |
424 | Status = AtaPassThruPassThruExecute (\r | |
425 | Task->Port,\r | |
426 | Task->PortMultiplier,\r | |
427 | Task->Packet,\r | |
428 | Instance,\r | |
429 | Task\r | |
430 | );\r | |
431 | \r | |
432 | //\r | |
58727f29 | 433 | // If the data transfer meet a error, remove all tasks in the list since these tasks are\r |
434 | // associated with one task from Ata Bus and signal the event with error status.\r | |
490b5ea1 | 435 | //\r |
436 | if ((Status != EFI_NOT_READY) && (Status != EFI_SUCCESS)) {\r | |
58727f29 | 437 | DestroyAsynTaskList (Instance, TRUE);\r |
438 | break;\r | |
490b5ea1 | 439 | }\r |
58727f29 | 440 | \r |
490b5ea1 | 441 | //\r |
442 | // For Non blocking mode, the Status of EFI_NOT_READY means the operation\r | |
58727f29 | 443 | // is not finished yet. Otherwise the operation is successful.\r |
490b5ea1 | 444 | //\r |
58727f29 | 445 | if (Status == EFI_NOT_READY) {\r |
446 | break;\r | |
447 | } else {\r | |
490b5ea1 | 448 | RemoveEntryList (&Task->Link);\r |
449 | gBS->SignalEvent (Task->Event);\r | |
450 | FreePool (Task);\r | |
490b5ea1 | 451 | }\r |
452 | }\r | |
453 | }\r | |
454 | \r | |
a41b5272 | 455 | /**\r |
456 | The Entry Point of module.\r | |
457 | \r | |
490b5ea1 | 458 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r |
a41b5272 | 459 | @param[in] SystemTable A pointer to the EFI System Table.\r |
490b5ea1 | 460 | \r |
a41b5272 | 461 | @retval EFI_SUCCESS The entry point is executed successfully.\r |
462 | @retval other Some error occurs when executing this entry point.\r | |
463 | \r | |
464 | **/\r | |
465 | EFI_STATUS\r | |
466 | EFIAPI\r | |
467 | InitializeAtaAtapiPassThru (\r | |
468 | IN EFI_HANDLE ImageHandle,\r | |
469 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
470 | )\r | |
471 | {\r | |
472 | EFI_STATUS Status;\r | |
473 | \r | |
474 | //\r | |
475 | // Install driver model protocol(s).\r | |
476 | //\r | |
477 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
478 | ImageHandle,\r | |
479 | SystemTable,\r | |
480 | &gAtaAtapiPassThruDriverBinding,\r | |
481 | ImageHandle,\r | |
482 | &gAtaAtapiPassThruComponentName,\r | |
483 | &gAtaAtapiPassThruComponentName2\r | |
484 | );\r | |
485 | ASSERT_EFI_ERROR (Status);\r | |
486 | \r | |
487 | return Status;\r | |
488 | }\r | |
489 | \r | |
490 | /**\r | |
58727f29 | 491 | Tests to see if this driver supports a given controller. If a child device is provided,\r |
a41b5272 | 492 | it further tests to see if this driver supports creating a handle for the specified child device.\r |
493 | \r | |
58727f29 | 494 | This function checks to see if the driver specified by This supports the device specified by\r |
495 | ControllerHandle. Drivers will typically use the device path attached to\r | |
496 | ControllerHandle and/or the services from the bus I/O abstraction attached to\r | |
497 | ControllerHandle to determine if the driver supports ControllerHandle. This function\r | |
498 | may be called many times during platform initialization. In order to reduce boot times, the tests\r | |
499 | performed by this function must be very small, and take as little time as possible to execute. This\r | |
500 | function must not change the state of any hardware devices, and this function must be aware that the\r | |
501 | device specified by ControllerHandle may already be managed by the same driver or a\r | |
502 | different driver. This function must match its calls to AllocatePages() with FreePages(),\r | |
503 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r | |
504 | Because ControllerHandle may have been previously started by the same driver, if a protocol is\r | |
505 | already in the opened state, then it must not be closed with CloseProtocol(). This is required\r | |
a41b5272 | 506 | to guarantee the state of ControllerHandle is not modified by this function.\r |
507 | \r | |
508 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
58727f29 | 509 | @param[in] ControllerHandle The handle of the controller to test. This handle\r |
510 | must support a protocol interface that supplies\r | |
a41b5272 | 511 | an I/O abstraction to the driver.\r |
58727f29 | 512 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r |
513 | parameter is ignored by device drivers, and is optional for bus\r | |
514 | drivers. For bus drivers, if this parameter is not NULL, then\r | |
515 | the bus driver must determine if the bus controller specified\r | |
516 | by ControllerHandle and the child controller specified\r | |
517 | by RemainingDevicePath are both supported by this\r | |
a41b5272 | 518 | bus driver.\r |
519 | \r | |
520 | @retval EFI_SUCCESS The device specified by ControllerHandle and\r | |
521 | RemainingDevicePath is supported by the driver specified by This.\r | |
522 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r | |
523 | RemainingDevicePath is already being managed by the driver\r | |
524 | specified by This.\r | |
525 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r | |
526 | RemainingDevicePath is already being managed by a different\r | |
527 | driver or an application that requires exclusive access.\r | |
528 | Currently not implemented.\r | |
529 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r | |
530 | RemainingDevicePath is not supported by the driver specified by This.\r | |
531 | **/\r | |
532 | EFI_STATUS\r | |
533 | EFIAPI\r | |
534 | AtaAtapiPassThruSupported (\r | |
535 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
536 | IN EFI_HANDLE Controller,\r | |
537 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
538 | )\r | |
539 | {\r | |
540 | EFI_STATUS Status;\r | |
541 | EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r | |
542 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
543 | PCI_TYPE00 PciData;\r | |
544 | EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;\r | |
545 | \r | |
546 | //\r | |
547 | // SATA Controller is a device driver, and should ingore the\r | |
548 | // "RemainingDevicePath" according to UEFI spec\r | |
549 | //\r | |
550 | Status = gBS->OpenProtocol (\r | |
551 | Controller,\r | |
552 | &gEfiDevicePathProtocolGuid,\r | |
553 | (VOID *) &ParentDevicePath,\r | |
554 | This->DriverBindingHandle,\r | |
555 | Controller,\r | |
556 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
557 | );\r | |
558 | if (EFI_ERROR (Status)) {\r | |
559 | //\r | |
560 | // EFI_ALREADY_STARTED is also an error\r | |
561 | //\r | |
562 | return Status;\r | |
563 | }\r | |
564 | //\r | |
565 | // Close the protocol because we don't use it here\r | |
566 | //\r | |
567 | gBS->CloseProtocol (\r | |
568 | Controller,\r | |
569 | &gEfiDevicePathProtocolGuid,\r | |
570 | This->DriverBindingHandle,\r | |
571 | Controller\r | |
572 | );\r | |
573 | \r | |
574 | Status = gBS->OpenProtocol (\r | |
575 | Controller,\r | |
576 | &gEfiIdeControllerInitProtocolGuid,\r | |
577 | (VOID **) &IdeControllerInit,\r | |
578 | This->DriverBindingHandle,\r | |
579 | Controller,\r | |
580 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
581 | );\r | |
582 | \r | |
583 | if (EFI_ERROR (Status)) {\r | |
584 | //\r | |
585 | // EFI_ALREADY_STARTED is also an error\r | |
586 | //\r | |
587 | return Status;\r | |
588 | }\r | |
490b5ea1 | 589 | \r |
a41b5272 | 590 | //\r |
591 | // Close the I/O Abstraction(s) used to perform the supported test\r | |
592 | //\r | |
593 | gBS->CloseProtocol (\r | |
594 | Controller,\r | |
595 | &gEfiIdeControllerInitProtocolGuid,\r | |
596 | This->DriverBindingHandle,\r | |
597 | Controller\r | |
598 | );\r | |
599 | \r | |
600 | //\r | |
601 | // Now test the EfiPciIoProtocol\r | |
602 | //\r | |
603 | Status = gBS->OpenProtocol (\r | |
604 | Controller,\r | |
605 | &gEfiPciIoProtocolGuid,\r | |
606 | (VOID **) &PciIo,\r | |
607 | This->DriverBindingHandle,\r | |
608 | Controller,\r | |
609 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
610 | );\r | |
611 | if (EFI_ERROR (Status)) {\r | |
612 | return Status;\r | |
613 | }\r | |
614 | //\r | |
615 | // Now further check the PCI header: Base class (offset 0x0B) and\r | |
616 | // Sub Class (offset 0x0A). This controller should be an ATA controller\r | |
617 | //\r | |
618 | Status = PciIo->Pci.Read (\r | |
619 | PciIo,\r | |
620 | EfiPciIoWidthUint8,\r | |
621 | PCI_CLASSCODE_OFFSET,\r | |
622 | sizeof (PciData.Hdr.ClassCode),\r | |
623 | PciData.Hdr.ClassCode\r | |
624 | );\r | |
625 | if (EFI_ERROR (Status)) {\r | |
a41b5272 | 626 | return EFI_UNSUPPORTED;\r |
627 | }\r | |
a41b5272 | 628 | \r |
629 | if (IS_PCI_IDE (&PciData) || IS_PCI_SATADPA (&PciData)) {\r | |
630 | return EFI_SUCCESS;\r | |
631 | }\r | |
632 | \r | |
633 | return EFI_UNSUPPORTED;\r | |
634 | }\r | |
635 | \r | |
636 | /**\r | |
637 | Starts a device controller or a bus controller.\r | |
638 | \r | |
639 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
58727f29 | 640 | As a result, much of the error checking on the parameters to Start() has been moved into this\r |
641 | common boot service. It is legal to call Start() from other locations,\r | |
a41b5272 | 642 | but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r |
643 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
644 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
645 | EFI_DEVICE_PATH_PROTOCOL.\r | |
646 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
490b5ea1 | 647 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r |
a41b5272 | 648 | \r |
649 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
58727f29 | 650 | @param[in] ControllerHandle The handle of the controller to start. This handle\r |
651 | must support a protocol interface that supplies\r | |
a41b5272 | 652 | an I/O abstraction to the driver.\r |
58727f29 | 653 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r |
654 | parameter is ignored by device drivers, and is optional for bus\r | |
655 | drivers. For a bus driver, if this parameter is NULL, then handles\r | |
490b5ea1 | 656 | for all the children of Controller are created by this driver.\r |
58727f29 | 657 | If this parameter is not NULL and the first Device Path Node is\r |
658 | not the End of Device Path Node, then only the handle for the\r | |
659 | child device specified by the first Device Path Node of\r | |
a41b5272 | 660 | RemainingDevicePath is created by this driver.\r |
58727f29 | 661 | If the first Device Path Node of RemainingDevicePath is\r |
a41b5272 | 662 | the End of Device Path Node, no child handle is created by this\r |
663 | driver.\r | |
664 | \r | |
665 | @retval EFI_SUCCESS The device was started.\r | |
666 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r | |
667 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
668 | @retval Others The driver failded to start the device.\r | |
669 | \r | |
670 | **/\r | |
671 | EFI_STATUS\r | |
672 | EFIAPI\r | |
673 | AtaAtapiPassThruStart (\r | |
674 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
675 | IN EFI_HANDLE Controller,\r | |
676 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
677 | )\r | |
678 | {\r | |
679 | EFI_STATUS Status;\r | |
680 | EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;\r | |
681 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
682 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
eed3f713 | 683 | UINT64 EnabledPciAttributes;\r |
a41b5272 | 684 | UINT64 OriginalPciAttributes;\r |
685 | \r | |
686 | Status = EFI_SUCCESS;\r | |
687 | IdeControllerInit = NULL;\r | |
688 | Instance = NULL;\r | |
a41b5272 | 689 | OriginalPciAttributes = 0;\r |
690 | \r | |
691 | DEBUG ((EFI_D_INFO, "==AtaAtapiPassThru Start== Controller = %x\n", Controller));\r | |
692 | \r | |
693 | Status = gBS->OpenProtocol (\r | |
694 | Controller,\r | |
695 | &gEfiIdeControllerInitProtocolGuid,\r | |
696 | (VOID **) &IdeControllerInit,\r | |
697 | This->DriverBindingHandle,\r | |
698 | Controller,\r | |
699 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
700 | );\r | |
701 | \r | |
702 | if (EFI_ERROR (Status)) {\r | |
703 | DEBUG ((EFI_D_ERROR, "Open Ide_Controller_Init Error, Status=%r", Status));\r | |
704 | goto ErrorExit;\r | |
705 | }\r | |
706 | \r | |
707 | Status = gBS->OpenProtocol (\r | |
708 | Controller,\r | |
709 | &gEfiPciIoProtocolGuid,\r | |
710 | (VOID **) &PciIo,\r | |
711 | This->DriverBindingHandle,\r | |
712 | Controller,\r | |
713 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
714 | );\r | |
715 | if (EFI_ERROR (Status)) {\r | |
716 | DEBUG ((EFI_D_ERROR, "Get Pci_Io Protocol Error, Status=%r", Status));\r | |
717 | goto ErrorExit;\r | |
718 | }\r | |
719 | \r | |
720 | Status = PciIo->Attributes (\r | |
721 | PciIo,\r | |
722 | EfiPciIoAttributeOperationGet,\r | |
723 | 0,\r | |
724 | &OriginalPciAttributes\r | |
725 | );\r | |
726 | \r | |
727 | if (EFI_ERROR (Status)) {\r | |
728 | goto ErrorExit;\r | |
729 | }\r | |
a41b5272 | 730 | \r |
731 | Status = PciIo->Attributes (\r | |
732 | PciIo,\r | |
733 | EfiPciIoAttributeOperationSupported,\r | |
734 | 0,\r | |
eed3f713 | 735 | &EnabledPciAttributes\r |
a41b5272 | 736 | );\r |
737 | if (!EFI_ERROR (Status)) {\r | |
eed3f713 | 738 | EnabledPciAttributes &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r |
a41b5272 | 739 | Status = PciIo->Attributes (\r |
740 | PciIo,\r | |
741 | EfiPciIoAttributeOperationEnable,\r | |
eed3f713 | 742 | EnabledPciAttributes,\r |
a41b5272 | 743 | NULL\r |
744 | );\r | |
745 | }\r | |
746 | \r | |
747 | if (EFI_ERROR (Status)) {\r | |
748 | goto ErrorExit;\r | |
749 | }\r | |
750 | \r | |
06766c0e RN |
751 | Status = gBS->LocateProtocol (&gEdkiiAtaAtapiPolicyProtocolGuid, NULL, (VOID **)&mAtaAtapiPolicy);\r |
752 | if (EFI_ERROR (Status)) {\r | |
753 | //\r | |
754 | // If there is no AtaAtapiPolicy exposed, use the default policy.\r | |
755 | //\r | |
756 | mAtaAtapiPolicy = &mDefaultAtaAtapiPolicy;\r | |
757 | }\r | |
758 | \r | |
a41b5272 | 759 | //\r |
760 | // Allocate a buffer to store the ATA_ATAPI_PASS_THRU_INSTANCE data structure\r | |
761 | //\r | |
762 | Instance = AllocateCopyPool (sizeof (ATA_ATAPI_PASS_THRU_INSTANCE), &gAtaAtapiPassThruInstanceTemplate);\r | |
763 | if (Instance == NULL) {\r | |
764 | goto ErrorExit;\r | |
765 | }\r | |
766 | \r | |
767 | Instance->ControllerHandle = Controller;\r | |
768 | Instance->IdeControllerInit = IdeControllerInit;\r | |
769 | Instance->PciIo = PciIo;\r | |
eed3f713 | 770 | Instance->EnabledPciAttributes = EnabledPciAttributes;\r |
a41b5272 | 771 | Instance->OriginalPciAttributes = OriginalPciAttributes;\r |
772 | Instance->AtaPassThru.Mode = &Instance->AtaPassThruMode;\r | |
773 | Instance->ExtScsiPassThru.Mode = &Instance->ExtScsiPassThruMode;\r | |
774 | InitializeListHead(&Instance->DeviceList);\r | |
490b5ea1 | 775 | InitializeListHead(&Instance->NonBlockingTaskList);\r |
776 | \r | |
777 | Instance->TimerEvent = NULL;\r | |
778 | \r | |
779 | Status = gBS->CreateEvent (\r | |
780 | EVT_TIMER | EVT_NOTIFY_SIGNAL,\r | |
781 | TPL_NOTIFY,\r | |
782 | AsyncNonBlockingTransferRoutine,\r | |
783 | Instance,\r | |
784 | &Instance->TimerEvent\r | |
785 | );\r | |
786 | if (EFI_ERROR (Status)) {\r | |
787 | goto ErrorExit;\r | |
788 | }\r | |
58727f29 | 789 | \r |
490b5ea1 | 790 | //\r |
791 | // Set 1ms timer.\r | |
792 | //\r | |
793 | Status = gBS->SetTimer (Instance->TimerEvent, TimerPeriodic, 10000);\r | |
794 | if (EFI_ERROR (Status)) {\r | |
795 | goto ErrorExit;\r | |
796 | }\r | |
a41b5272 | 797 | \r |
798 | //\r | |
799 | // Enumerate all inserted ATA devices.\r | |
800 | //\r | |
801 | Status = EnumerateAttachedDevice (Instance);\r | |
802 | if (EFI_ERROR (Status)) {\r | |
803 | goto ErrorExit;\r | |
804 | }\r | |
805 | \r | |
806 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
807 | &Controller,\r | |
808 | &gEfiAtaPassThruProtocolGuid, &(Instance->AtaPassThru),\r | |
809 | &gEfiExtScsiPassThruProtocolGuid, &(Instance->ExtScsiPassThru),\r | |
810 | NULL\r | |
811 | );\r | |
812 | ASSERT_EFI_ERROR (Status);\r | |
813 | \r | |
814 | return Status;\r | |
815 | \r | |
816 | ErrorExit:\r | |
817 | if (IdeControllerInit != NULL) {\r | |
818 | gBS->CloseProtocol (\r | |
819 | Controller,\r | |
820 | &gEfiIdeControllerInitProtocolGuid,\r | |
821 | This->DriverBindingHandle,\r | |
822 | Controller\r | |
823 | );\r | |
824 | }\r | |
825 | \r | |
d0844d13 | 826 | if ((Instance != NULL) && (Instance->TimerEvent != NULL)) {\r |
490b5ea1 | 827 | gBS->CloseEvent (Instance->TimerEvent);\r |
828 | }\r | |
829 | \r | |
a41b5272 | 830 | //\r |
831 | // Remove all inserted ATA devices.\r | |
832 | //\r | |
833 | DestroyDeviceInfoList(Instance);\r | |
834 | \r | |
835 | if (Instance != NULL) {\r | |
836 | FreePool (Instance);\r | |
837 | }\r | |
838 | return EFI_UNSUPPORTED;\r | |
839 | }\r | |
840 | \r | |
841 | /**\r | |
842 | Stops a device controller or a bus controller.\r | |
58727f29 | 843 | \r |
844 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
845 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
846 | into this common boot service. It is legal to call Stop() from other locations,\r | |
a41b5272 | 847 | but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r |
848 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
849 | same driver's Start() function.\r | |
850 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
851 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
852 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
853 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
58727f29 | 854 | \r |
a41b5272 | 855 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
58727f29 | 856 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r |
857 | support a bus specific I/O protocol for the driver\r | |
a41b5272 | 858 | to use to stop the device.\r |
859 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
58727f29 | 860 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r |
a41b5272 | 861 | if NumberOfChildren is 0.\r |
862 | \r | |
863 | @retval EFI_SUCCESS The device was stopped.\r | |
864 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
865 | \r | |
866 | **/\r | |
867 | EFI_STATUS\r | |
868 | EFIAPI\r | |
869 | AtaAtapiPassThruStop (\r | |
870 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
871 | IN EFI_HANDLE Controller,\r | |
872 | IN UINTN NumberOfChildren,\r | |
873 | IN EFI_HANDLE *ChildHandleBuffer\r | |
874 | )\r | |
875 | {\r | |
876 | EFI_STATUS Status;\r | |
877 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
878 | EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r | |
879 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
880 | EFI_AHCI_REGISTERS *AhciRegisters;\r | |
a41b5272 | 881 | \r |
882 | DEBUG ((EFI_D_INFO, "==AtaAtapiPassThru Stop== Controller = %x\n", Controller));\r | |
883 | \r | |
884 | Status = gBS->OpenProtocol (\r | |
885 | Controller,\r | |
886 | &gEfiAtaPassThruProtocolGuid,\r | |
887 | (VOID **) &AtaPassThru,\r | |
888 | This->DriverBindingHandle,\r | |
889 | Controller,\r | |
890 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
891 | );\r | |
892 | \r | |
893 | if (EFI_ERROR (Status)) {\r | |
894 | return EFI_DEVICE_ERROR;\r | |
895 | }\r | |
490b5ea1 | 896 | \r |
897 | Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (AtaPassThru);\r | |
898 | \r | |
32e817c9 FT |
899 | Status = gBS->UninstallMultipleProtocolInterfaces (\r |
900 | Controller,\r | |
901 | &gEfiAtaPassThruProtocolGuid, &(Instance->AtaPassThru),\r | |
902 | &gEfiExtScsiPassThruProtocolGuid, &(Instance->ExtScsiPassThru),\r | |
903 | NULL\r | |
904 | );\r | |
a41b5272 | 905 | \r |
32e817c9 FT |
906 | if (EFI_ERROR (Status)) {\r |
907 | return EFI_DEVICE_ERROR;\r | |
a41b5272 | 908 | }\r |
909 | \r | |
a41b5272 | 910 | //\r |
911 | // Close protocols opened by AtaAtapiPassThru controller driver\r | |
912 | //\r | |
913 | gBS->CloseProtocol (\r | |
914 | Controller,\r | |
915 | &gEfiIdeControllerInitProtocolGuid,\r | |
916 | This->DriverBindingHandle,\r | |
917 | Controller\r | |
918 | );\r | |
919 | \r | |
32e817c9 FT |
920 | //\r |
921 | // Close Non-Blocking timer and free Task list.\r | |
922 | //\r | |
923 | if (Instance->TimerEvent != NULL) {\r | |
924 | gBS->CloseEvent (Instance->TimerEvent);\r | |
925 | Instance->TimerEvent = NULL;\r | |
926 | }\r | |
927 | DestroyAsynTaskList (Instance, FALSE);\r | |
a41b5272 | 928 | //\r |
929 | // Free allocated resource\r | |
930 | //\r | |
32e817c9 | 931 | DestroyDeviceInfoList (Instance);\r |
a41b5272 | 932 | \r |
509daa65 LE |
933 | PciIo = Instance->PciIo;\r |
934 | \r | |
935 | //\r | |
936 | // Disable this ATA host controller.\r | |
937 | //\r | |
938 | PciIo->Attributes (\r | |
939 | PciIo,\r | |
940 | EfiPciIoAttributeOperationDisable,\r | |
941 | Instance->EnabledPciAttributes,\r | |
942 | NULL\r | |
943 | );\r | |
944 | \r | |
a41b5272 | 945 | //\r |
946 | // If the current working mode is AHCI mode, then pre-allocated resource\r | |
947 | // for AHCI initialization should be released.\r | |
948 | //\r | |
949 | if (Instance->Mode == EfiAtaAhciMode) {\r | |
950 | AhciRegisters = &Instance->AhciRegisters;\r | |
951 | PciIo->Unmap (\r | |
952 | PciIo,\r | |
953 | AhciRegisters->MapCommandTable\r | |
954 | );\r | |
955 | PciIo->FreeBuffer (\r | |
956 | PciIo,\r | |
ed365e93 | 957 | EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxCommandTableSize),\r |
a41b5272 | 958 | AhciRegisters->AhciCommandTable\r |
959 | );\r | |
960 | PciIo->Unmap (\r | |
961 | PciIo,\r | |
962 | AhciRegisters->MapCmdList\r | |
963 | );\r | |
964 | PciIo->FreeBuffer (\r | |
965 | PciIo,\r | |
ed365e93 | 966 | EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxCommandListSize),\r |
a41b5272 | 967 | AhciRegisters->AhciCmdList\r |
968 | );\r | |
969 | PciIo->Unmap (\r | |
970 | PciIo,\r | |
971 | AhciRegisters->MapRFis\r | |
972 | );\r | |
973 | PciIo->FreeBuffer (\r | |
974 | PciIo,\r | |
ed365e93 | 975 | EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxReceiveFisSize),\r |
a41b5272 | 976 | AhciRegisters->AhciRFis\r |
977 | );\r | |
978 | }\r | |
32e817c9 | 979 | \r |
32e817c9 FT |
980 | //\r |
981 | // Restore original PCI attributes\r | |
982 | //\r | |
983 | Status = PciIo->Attributes (\r | |
984 | PciIo,\r | |
985 | EfiPciIoAttributeOperationSet,\r | |
986 | Instance->OriginalPciAttributes,\r | |
987 | NULL\r | |
988 | );\r | |
989 | ASSERT_EFI_ERROR (Status);\r | |
990 | \r | |
a41b5272 | 991 | FreePool (Instance);\r |
992 | \r | |
993 | return Status;\r | |
994 | }\r | |
995 | \r | |
996 | /**\r | |
997 | Traverse the attached ATA devices list to find out the device to access.\r | |
58727f29 | 998 | \r |
a41b5272 | 999 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r |
58727f29 | 1000 | @param[in] Port The port number of the ATA device to send the command.\r |
a41b5272 | 1001 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.\r |
23a596db | 1002 | If there is no port multiplier, then specify 0xFFFF.\r |
a41b5272 | 1003 | @param[in] DeviceType The device type of the ATA device.\r |
58727f29 | 1004 | \r |
a41b5272 | 1005 | @retval The pointer to the data structure of the device info to access.\r |
1006 | \r | |
1007 | **/\r | |
1008 | LIST_ENTRY *\r | |
1009 | EFIAPI\r | |
1010 | SearchDeviceInfoList (\r | |
1011 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,\r | |
1012 | IN UINT16 Port,\r | |
1013 | IN UINT16 PortMultiplier,\r | |
1014 | IN EFI_ATA_DEVICE_TYPE DeviceType\r | |
1015 | )\r | |
1016 | {\r | |
1017 | EFI_ATA_DEVICE_INFO *DeviceInfo;\r | |
1018 | LIST_ENTRY *Node;\r | |
1019 | \r | |
1020 | Node = GetFirstNode (&Instance->DeviceList);\r | |
1021 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
1022 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
1023 | \r | |
23a596db HW |
1024 | //\r |
1025 | // For CD-ROM working in the AHCI mode, only 8 bits are used to record\r | |
1026 | // the PortMultiplier information. If the CD-ROM is directly attached\r | |
1027 | // on a SATA port, the PortMultiplier should be translated from 0xFF\r | |
1028 | // to 0xFFFF according to the UEFI spec.\r | |
1029 | //\r | |
1030 | if ((Instance->Mode == EfiAtaAhciMode) &&\r | |
1031 | (DeviceInfo->Type == EfiIdeCdrom) &&\r | |
1032 | (PortMultiplier == 0xFF)) {\r | |
1033 | PortMultiplier = 0xFFFF;\r | |
1034 | }\r | |
1035 | \r | |
a41b5272 | 1036 | if ((DeviceInfo->Type == DeviceType) &&\r |
58727f29 | 1037 | (Port == DeviceInfo->Port) &&\r |
a41b5272 | 1038 | (PortMultiplier == DeviceInfo->PortMultiplier)) {\r |
1039 | return Node;\r | |
1040 | }\r | |
1041 | \r | |
1042 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
490b5ea1 | 1043 | }\r |
a41b5272 | 1044 | \r |
1045 | return NULL;\r | |
1046 | }\r | |
1047 | \r | |
1048 | /**\r | |
1049 | Allocate device info data structure to contain device info.\r | |
1050 | And insert the data structure to the tail of device list for tracing.\r | |
58727f29 | 1051 | \r |
a41b5272 | 1052 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r |
58727f29 | 1053 | @param[in] Port The port number of the ATA device to send the command.\r |
a41b5272 | 1054 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.\r |
23a596db | 1055 | If there is no port multiplier, then specify 0xFFFF.\r |
a41b5272 | 1056 | @param[in] DeviceType The device type of the ATA device.\r |
1057 | @param[in] IdentifyData The data buffer to store the output of the IDENTIFY cmd.\r | |
1058 | \r | |
1059 | @retval EFI_SUCCESS Successfully insert the ata device to the tail of device list.\r | |
1060 | @retval EFI_OUT_OF_RESOURCES Can not allocate enough resource for use.\r | |
1061 | \r | |
1062 | **/\r | |
1063 | EFI_STATUS\r | |
1064 | EFIAPI\r | |
1065 | CreateNewDeviceInfo (\r | |
1066 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,\r | |
1067 | IN UINT16 Port,\r | |
1068 | IN UINT16 PortMultiplier,\r | |
1069 | IN EFI_ATA_DEVICE_TYPE DeviceType,\r | |
1070 | IN EFI_IDENTIFY_DATA *IdentifyData\r | |
1071 | )\r | |
1072 | {\r | |
1073 | EFI_ATA_DEVICE_INFO *DeviceInfo;\r | |
1074 | \r | |
1075 | DeviceInfo = AllocateZeroPool (sizeof (EFI_ATA_DEVICE_INFO));\r | |
1076 | \r | |
1077 | if (DeviceInfo == NULL) {\r | |
1078 | return EFI_OUT_OF_RESOURCES;\r | |
1079 | }\r | |
1080 | \r | |
1081 | DeviceInfo->Signature = ATA_ATAPI_DEVICE_SIGNATURE;\r | |
1082 | DeviceInfo->Port = Port;\r | |
1083 | DeviceInfo->PortMultiplier = PortMultiplier;\r | |
1084 | DeviceInfo->Type = DeviceType;\r | |
1085 | \r | |
1086 | if (IdentifyData != NULL) {\r | |
1087 | DeviceInfo->IdentifyData = AllocateCopyPool (sizeof (EFI_IDENTIFY_DATA), IdentifyData);\r | |
1088 | if (DeviceInfo->IdentifyData == NULL) {\r | |
1089 | FreePool (DeviceInfo);\r | |
1090 | return EFI_OUT_OF_RESOURCES;\r | |
1091 | }\r | |
1092 | }\r | |
1093 | \r | |
1094 | InsertTailList (&Instance->DeviceList, &DeviceInfo->Link);\r | |
1095 | \r | |
1096 | return EFI_SUCCESS;\r | |
1097 | }\r | |
1098 | \r | |
1099 | /**\r | |
1100 | Destroy all attached ATA devices info.\r | |
58727f29 | 1101 | \r |
a41b5272 | 1102 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r |
1103 | \r | |
1104 | **/\r | |
1105 | VOID\r | |
1106 | EFIAPI\r | |
1107 | DestroyDeviceInfoList (\r | |
1108 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance\r | |
1109 | )\r | |
1110 | {\r | |
1111 | EFI_ATA_DEVICE_INFO *DeviceInfo;\r | |
1112 | LIST_ENTRY *Node;\r | |
1113 | \r | |
1114 | Node = GetFirstNode (&Instance->DeviceList);\r | |
1115 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
1116 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
1117 | \r | |
1118 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
1119 | \r | |
1120 | RemoveEntryList (&DeviceInfo->Link);\r | |
1121 | if (DeviceInfo->IdentifyData != NULL) {\r | |
1122 | FreePool (DeviceInfo->IdentifyData);\r | |
1123 | }\r | |
1124 | FreePool (DeviceInfo);\r | |
1125 | }\r | |
1126 | }\r | |
1127 | \r | |
490b5ea1 | 1128 | /**\r |
1129 | Destroy all pending non blocking tasks.\r | |
58727f29 | 1130 | \r |
1131 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r | |
1132 | @param[in] IsSigEvent Indicate whether signal the task event when remove the\r | |
1133 | task.\r | |
490b5ea1 | 1134 | \r |
1135 | **/\r | |
1136 | VOID\r | |
1137 | EFIAPI\r | |
1138 | DestroyAsynTaskList (\r | |
58727f29 | 1139 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,\r |
1140 | IN BOOLEAN IsSigEvent\r | |
490b5ea1 | 1141 | )\r |
1142 | {\r | |
1143 | LIST_ENTRY *Entry;\r | |
1144 | LIST_ENTRY *DelEntry;\r | |
1145 | ATA_NONBLOCK_TASK *Task;\r | |
1146 | EFI_TPL OldTpl;\r | |
1147 | \r | |
1148 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
1149 | if (!IsListEmpty (&Instance->NonBlockingTaskList)) {\r | |
1150 | //\r | |
1151 | // Free the Subtask list.\r | |
1152 | //\r | |
58727f29 | 1153 | for (Entry = (&Instance->NonBlockingTaskList)->ForwardLink;\r |
490b5ea1 | 1154 | Entry != (&Instance->NonBlockingTaskList);\r |
1155 | ) {\r | |
1156 | DelEntry = Entry;\r | |
1157 | Entry = Entry->ForwardLink;\r | |
1158 | Task = ATA_NON_BLOCK_TASK_FROM_ENTRY (DelEntry);\r | |
1159 | \r | |
1160 | RemoveEntryList (DelEntry);\r | |
58727f29 | 1161 | if (IsSigEvent) {\r |
1162 | Task->Packet->Asb->AtaStatus = 0x01;\r | |
1163 | gBS->SignalEvent (Task->Event);\r | |
1164 | }\r | |
490b5ea1 | 1165 | FreePool (Task);\r |
1166 | }\r | |
1167 | }\r | |
1168 | gBS->RestoreTPL (OldTpl);\r | |
1169 | }\r | |
1170 | \r | |
a41b5272 | 1171 | /**\r |
1172 | Enumerate all attached ATA devices at IDE mode or AHCI mode separately.\r | |
58727f29 | 1173 | \r |
1174 | The function is designed to enumerate all attached ATA devices.\r | |
1175 | \r | |
a41b5272 | 1176 | @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r |
1177 | \r | |
1178 | @retval EFI_SUCCESS Successfully enumerate attached ATA devices.\r | |
1179 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
1180 | \r | |
1181 | **/\r | |
1182 | EFI_STATUS\r | |
1183 | EFIAPI\r | |
1184 | EnumerateAttachedDevice (\r | |
1185 | IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance\r | |
1186 | )\r | |
1187 | {\r | |
1188 | EFI_STATUS Status;\r | |
1189 | PCI_TYPE00 PciData;\r | |
1190 | UINT8 ClassCode;\r | |
1191 | \r | |
1192 | Status = EFI_SUCCESS;\r | |
1193 | \r | |
1194 | Status = Instance->PciIo->Pci.Read (\r | |
1195 | Instance->PciIo,\r | |
1196 | EfiPciIoWidthUint8,\r | |
1197 | PCI_CLASSCODE_OFFSET,\r | |
1198 | sizeof (PciData.Hdr.ClassCode),\r | |
1199 | PciData.Hdr.ClassCode\r | |
1200 | );\r | |
1201 | ASSERT_EFI_ERROR (Status);\r | |
1202 | \r | |
1203 | ClassCode = PciData.Hdr.ClassCode[1];\r | |
1204 | \r | |
1205 | switch (ClassCode) {\r | |
1206 | case PCI_CLASS_MASS_STORAGE_IDE :\r | |
1207 | //\r | |
1208 | // The ATA controller is working at IDE mode\r | |
1209 | //\r | |
1210 | Instance->Mode = EfiAtaIdeMode;\r | |
1211 | \r | |
1212 | Status = IdeModeInitialization (Instance);\r | |
1213 | if (EFI_ERROR (Status)) {\r | |
1214 | Status = EFI_DEVICE_ERROR;\r | |
1215 | goto Done;\r | |
1216 | }\r | |
1217 | break;\r | |
1218 | case PCI_CLASS_MASS_STORAGE_SATADPA :\r | |
1219 | //\r | |
1220 | // The ATA controller is working at AHCI mode\r | |
1221 | //\r | |
1222 | Instance->Mode = EfiAtaAhciMode;\r | |
1223 | \r | |
1224 | Status = AhciModeInitialization (Instance);\r | |
1225 | \r | |
1226 | if (EFI_ERROR (Status)) {\r | |
1227 | Status = EFI_DEVICE_ERROR;\r | |
1228 | goto Done;\r | |
1229 | }\r | |
1230 | \r | |
1231 | break;\r | |
1232 | default :\r | |
1233 | Status = EFI_UNSUPPORTED;\r | |
1234 | }\r | |
1235 | \r | |
1236 | Done:\r | |
1237 | return Status;\r | |
1238 | }\r | |
1239 | \r | |
1240 | /**\r | |
1241 | Sends an ATA command to an ATA device that is attached to the ATA controller. This function\r | |
1242 | supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required,\r | |
1243 | and the non-blocking I/O functionality is optional.\r | |
1244 | \r | |
58727f29 | 1245 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r |
1246 | @param[in] Port The port number of the ATA device to send the command.\r | |
a41b5272 | 1247 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.\r |
23a596db | 1248 | If there is no port multiplier, then specify 0xFFFF.\r |
a41b5272 | 1249 | @param[in, out] Packet A pointer to the ATA command to send to the ATA device specified by Port\r |
1250 | and PortMultiplierPort.\r | |
1251 | @param[in] Event If non-blocking I/O is not supported then Event is ignored, and blocking\r | |
1252 | I/O is performed. If Event is NULL, then blocking I/O is performed. If\r | |
1253 | Event is not NULL and non blocking I/O is supported, then non-blocking\r | |
1254 | I/O is performed, and Event will be signaled when the ATA command completes.\r | |
1255 | \r | |
58727f29 | 1256 | @retval EFI_SUCCESS The ATA command was sent by the host. For bi-directional commands,\r |
a41b5272 | 1257 | InTransferLength bytes were transferred from InDataBuffer. For write and\r |
1258 | bi-directional commands, OutTransferLength bytes were transferred by OutDataBuffer.\r | |
1259 | @retval EFI_BAD_BUFFER_SIZE The ATA command was not executed. The number of bytes that could be transferred\r | |
58727f29 | 1260 | is returned in InTransferLength. For write and bi-directional commands,\r |
a41b5272 | 1261 | OutTransferLength bytes were transferred by OutDataBuffer.\r |
1262 | @retval EFI_NOT_READY The ATA command could not be sent because there are too many ATA commands\r | |
1263 | already queued. The caller may retry again later.\r | |
1264 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the ATA command.\r | |
1265 | @retval EFI_INVALID_PARAMETER Port, PortMultiplierPort, or the contents of Acb are invalid. The ATA\r | |
1266 | command was not sent, so no additional status information is available.\r | |
1267 | \r | |
1268 | **/\r | |
1269 | EFI_STATUS\r | |
1270 | EFIAPI\r | |
1271 | AtaPassThruPassThru (\r | |
1272 | IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r | |
1273 | IN UINT16 Port,\r | |
1274 | IN UINT16 PortMultiplierPort,\r | |
1275 | IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,\r | |
1276 | IN EFI_EVENT Event OPTIONAL\r | |
490b5ea1 | 1277 | )\r |
a41b5272 | 1278 | {\r |
a41b5272 | 1279 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r |
a41b5272 | 1280 | LIST_ENTRY *Node;\r |
1281 | EFI_ATA_DEVICE_INFO *DeviceInfo;\r | |
1282 | EFI_IDENTIFY_DATA *IdentifyData;\r | |
1283 | UINT64 Capacity;\r | |
1284 | UINT32 MaxSectorCount;\r | |
490b5ea1 | 1285 | ATA_NONBLOCK_TASK *Task;\r |
1286 | EFI_TPL OldTpl;\r | |
e7401ee1 | 1287 | UINT32 BlockSize;\r |
a41b5272 | 1288 | \r |
1289 | Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
1290 | \r | |
1291 | if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->InDataBuffer, This->Mode->IoAlign)) {\r | |
1292 | return EFI_INVALID_PARAMETER;\r | |
1293 | }\r | |
1294 | \r | |
1295 | if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->OutDataBuffer, This->Mode->IoAlign)) {\r | |
1296 | return EFI_INVALID_PARAMETER;\r | |
1297 | }\r | |
1298 | \r | |
1299 | if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->Asb, This->Mode->IoAlign)) {\r | |
1300 | return EFI_INVALID_PARAMETER;\r | |
1301 | }\r | |
1302 | \r | |
df202d72 FT |
1303 | Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk);\r |
1304 | \r | |
1305 | if (Node == NULL) {\r | |
1306 | Node = SearchDeviceInfoList(Instance, Port, PortMultiplierPort, EfiIdeCdrom);\r | |
1307 | if (Node == NULL) {\r | |
1308 | return EFI_INVALID_PARAMETER;\r | |
1309 | }\r | |
1310 | }\r | |
1311 | \r | |
a41b5272 | 1312 | //\r |
1313 | // Check whether this device needs 48-bit addressing (ATAPI-6 ata device).\r | |
1314 | // Per ATA-6 spec, word83: bit15 is zero and bit14 is one.\r | |
58727f29 | 1315 | // If bit10 is one, it means the ata device support 48-bit addressing.\r |
a41b5272 | 1316 | //\r |
1317 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
1318 | IdentifyData = DeviceInfo->IdentifyData;\r | |
1319 | MaxSectorCount = 0x100;\r | |
1320 | if ((IdentifyData->AtaData.command_set_supported_83 & (BIT10 | BIT15 | BIT14)) == 0x4400) {\r | |
1321 | Capacity = *((UINT64 *)IdentifyData->AtaData.maximum_lba_for_48bit_addressing);\r | |
1322 | if (Capacity > 0xFFFFFFF) {\r | |
1323 | //\r | |
1324 | // Capacity exceeds 120GB. 48-bit addressing is really needed\r | |
1325 | // In this case, the max sector count is 0x10000\r | |
1326 | //\r | |
1327 | MaxSectorCount = 0x10000;\r | |
1328 | }\r | |
1329 | }\r | |
1330 | \r | |
e7401ee1 FT |
1331 | BlockSize = 0x200;\r |
1332 | if ((IdentifyData->AtaData.phy_logic_sector_support & (BIT14 | BIT15)) == BIT14) {\r | |
1333 | //\r | |
1334 | // Check logical block size\r | |
1335 | //\r | |
1336 | if ((IdentifyData->AtaData.phy_logic_sector_support & BIT12) != 0) {\r | |
1337 | BlockSize = (UINT32) (((IdentifyData->AtaData.logic_sector_size_hi << 16) | IdentifyData->AtaData.logic_sector_size_lo) * sizeof (UINT16));\r | |
1338 | }\r | |
1339 | }\r | |
1340 | \r | |
1341 | //\r | |
1342 | // convert the transfer length from sector count to byte.\r | |
1343 | //\r | |
1344 | if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&\r | |
1345 | (Packet->InTransferLength != 0)) {\r | |
1346 | Packet->InTransferLength = Packet->InTransferLength * BlockSize;\r | |
1347 | }\r | |
1348 | \r | |
1349 | //\r | |
1350 | // convert the transfer length from sector count to byte.\r | |
1351 | //\r | |
1352 | if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&\r | |
1353 | (Packet->OutTransferLength != 0)) {\r | |
1354 | Packet->OutTransferLength = Packet->OutTransferLength * BlockSize;\r | |
1355 | }\r | |
1356 | \r | |
a41b5272 | 1357 | //\r |
1358 | // If the data buffer described by InDataBuffer/OutDataBuffer and InTransferLength/OutTransferLength\r | |
1359 | // is too big to be transferred in a single command, then no data is transferred and EFI_BAD_BUFFER_SIZE\r | |
58727f29 | 1360 | // is returned.\r |
a41b5272 | 1361 | //\r |
e7401ee1 FT |
1362 | if (((Packet->InTransferLength != 0) && (Packet->InTransferLength > MaxSectorCount * BlockSize)) ||\r |
1363 | ((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize))) {\r | |
a41b5272 | 1364 | return EFI_BAD_BUFFER_SIZE;\r |
1365 | }\r | |
1366 | \r | |
490b5ea1 | 1367 | //\r |
1368 | // For non-blocking mode, queue the Task into the list.\r | |
1369 | //\r | |
1370 | if (Event != NULL) {\r | |
1371 | Task = AllocateZeroPool (sizeof (ATA_NONBLOCK_TASK));\r | |
1372 | if (Task == NULL) {\r | |
1373 | return EFI_OUT_OF_RESOURCES;\r | |
1374 | }\r | |
58727f29 | 1375 | \r |
490b5ea1 | 1376 | Task->Signature = ATA_NONBLOCKING_TASK_SIGNATURE;\r |
1377 | Task->Port = Port;\r | |
1378 | Task->PortMultiplier = PortMultiplierPort;\r | |
1379 | Task->Packet = Packet;\r | |
1380 | Task->Event = Event;\r | |
1381 | Task->IsStart = FALSE;\r | |
ab82122d TF |
1382 | Task->RetryTimes = DivU64x32(Packet->Timeout, 1000) + 1;\r |
1383 | if (Packet->Timeout == 0) {\r | |
1384 | Task->InfiniteWait = TRUE;\r | |
1385 | } else {\r | |
1386 | Task->InfiniteWait = FALSE;\r | |
1387 | }\r | |
490b5ea1 | 1388 | \r |
1389 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
1390 | InsertTailList (&Instance->NonBlockingTaskList, &Task->Link);\r | |
1391 | gBS->RestoreTPL (OldTpl);\r | |
a41b5272 | 1392 | \r |
490b5ea1 | 1393 | return EFI_SUCCESS;\r |
1394 | } else {\r | |
1395 | return AtaPassThruPassThruExecute (\r | |
1396 | Port,\r | |
1397 | PortMultiplierPort,\r | |
1398 | Packet,\r | |
1399 | Instance,\r | |
1400 | NULL\r | |
1401 | );\r | |
a41b5272 | 1402 | }\r |
a41b5272 | 1403 | }\r |
1404 | \r | |
1405 | /**\r | |
1406 | Used to retrieve the list of legal port numbers for ATA devices on an ATA controller.\r | |
1407 | These can either be the list of ports where ATA devices are actually present or the\r | |
1408 | list of legal port numbers for the ATA controller. Regardless, the caller of this\r | |
1409 | function must probe the port number returned to see if an ATA device is actually\r | |
1410 | present at that location on the ATA controller.\r | |
1411 | \r | |
1412 | The GetNextPort() function retrieves the port number on an ATA controller. If on input\r | |
1413 | Port is 0xFFFF, then the port number of the first port on the ATA controller is returned\r | |
1414 | in Port and EFI_SUCCESS is returned.\r | |
1415 | \r | |
1416 | If Port is a port number that was returned on a previous call to GetNextPort(), then the\r | |
1417 | port number of the next port on the ATA controller is returned in Port, and EFI_SUCCESS\r | |
1418 | is returned. If Port is not 0xFFFF and Port was not returned on a previous call to\r | |
1419 | GetNextPort(), then EFI_INVALID_PARAMETER is returned.\r | |
1420 | \r | |
1421 | If Port is the port number of the last port on the ATA controller, then EFI_NOT_FOUND is\r | |
1422 | returned.\r | |
1423 | \r | |
58727f29 | 1424 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r |
a41b5272 | 1425 | @param[in, out] Port On input, a pointer to the port number on the ATA controller.\r |
1426 | On output, a pointer to the next port number on the ATA\r | |
1427 | controller. An input value of 0xFFFF retrieves the first port\r | |
1428 | number on the ATA controller.\r | |
1429 | \r | |
1430 | @retval EFI_SUCCESS The next port number on the ATA controller was returned in Port.\r | |
1431 | @retval EFI_NOT_FOUND There are no more ports on this ATA controller.\r | |
1432 | @retval EFI_INVALID_PARAMETER Port is not 0xFFFF and Port was not returned on a previous call\r | |
1433 | to GetNextPort().\r | |
1434 | \r | |
1435 | **/\r | |
1436 | EFI_STATUS\r | |
1437 | EFIAPI\r | |
1438 | AtaPassThruGetNextPort (\r | |
1439 | IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r | |
1440 | IN OUT UINT16 *Port\r | |
1441 | )\r | |
1442 | {\r | |
1443 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
1444 | LIST_ENTRY *Node;\r | |
1445 | EFI_ATA_DEVICE_INFO *DeviceInfo;\r | |
1446 | \r | |
1447 | Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
1448 | \r | |
1449 | if (Port == NULL) {\r | |
1450 | return EFI_INVALID_PARAMETER;\r | |
1451 | }\r | |
1452 | \r | |
1453 | if (*Port == 0xFFFF) {\r | |
1454 | //\r | |
1455 | // If the Port is all 0xFF's, start to traverse the device list from the beginning\r | |
1456 | //\r | |
1457 | Node = GetFirstNode (&Instance->DeviceList);\r | |
1458 | \r | |
1459 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
1460 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
1461 | \r | |
1462 | if (DeviceInfo->Type == EfiIdeHarddisk) {\r | |
1463 | *Port = DeviceInfo->Port;\r | |
1464 | goto Exit;\r | |
1465 | }\r | |
1466 | \r | |
1467 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
1468 | }\r | |
1469 | \r | |
1470 | return EFI_NOT_FOUND;\r | |
1471 | } else if (*Port == Instance->PreviousPort) {\r | |
1472 | Node = GetFirstNode (&Instance->DeviceList);\r | |
1473 | \r | |
1474 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
1475 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
1476 | \r | |
1477 | if ((DeviceInfo->Type == EfiIdeHarddisk) &&\r | |
1478 | (DeviceInfo->Port > *Port)){\r | |
1479 | *Port = DeviceInfo->Port;\r | |
1480 | goto Exit;\r | |
1481 | }\r | |
1482 | \r | |
1483 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
1484 | }\r | |
1485 | \r | |
1486 | return EFI_NOT_FOUND;\r | |
1487 | } else {\r | |
1488 | //\r | |
1489 | // Port is not equal to 0xFFFF and also not equal to previous return value\r | |
1490 | //\r | |
1491 | return EFI_INVALID_PARAMETER;\r | |
1492 | }\r | |
490b5ea1 | 1493 | \r |
a41b5272 | 1494 | Exit:\r |
1495 | //\r | |
1496 | // Update the PreviousPort and PreviousPortMultiplier.\r | |
1497 | //\r | |
1498 | Instance->PreviousPort = *Port;\r | |
1499 | \r | |
1500 | return EFI_SUCCESS;\r | |
1501 | }\r | |
1502 | \r | |
1503 | /**\r | |
58727f29 | 1504 | Used to retrieve the list of legal port multiplier port numbers for ATA devices on a port of an ATA\r |
1505 | controller. These can either be the list of port multiplier ports where ATA devices are actually\r | |
1506 | present on port or the list of legal port multiplier ports on that port. Regardless, the caller of this\r | |
1507 | function must probe the port number and port multiplier port number returned to see if an ATA\r | |
a41b5272 | 1508 | device is actually present.\r |
1509 | \r | |
58727f29 | 1510 | The GetNextDevice() function retrieves the port multiplier port number of an ATA device\r |
a41b5272 | 1511 | present on a port of an ATA controller.\r |
490b5ea1 | 1512 | \r |
58727f29 | 1513 | If PortMultiplierPort points to a port multiplier port number value that was returned on a\r |
a41b5272 | 1514 | previous call to GetNextDevice(), then the port multiplier port number of the next ATA device\r |
1515 | on the port of the ATA controller is returned in PortMultiplierPort, and EFI_SUCCESS is\r | |
1516 | returned.\r | |
490b5ea1 | 1517 | \r |
58727f29 | 1518 | If PortMultiplierPort points to 0xFFFF, then the port multiplier port number of the first\r |
1519 | ATA device on port of the ATA controller is returned in PortMultiplierPort and\r | |
a41b5272 | 1520 | EFI_SUCCESS is returned.\r |
490b5ea1 | 1521 | \r |
a41b5272 | 1522 | If PortMultiplierPort is not 0xFFFF and the value pointed to by PortMultiplierPort\r |
1523 | was not returned on a previous call to GetNextDevice(), then EFI_INVALID_PARAMETER\r | |
1524 | is returned.\r | |
490b5ea1 | 1525 | \r |
58727f29 | 1526 | If PortMultiplierPort is the port multiplier port number of the last ATA device on the port of\r |
a41b5272 | 1527 | the ATA controller, then EFI_NOT_FOUND is returned.\r |
1528 | \r | |
1529 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r | |
1530 | @param[in] Port The port number present on the ATA controller.\r | |
1531 | @param[in, out] PortMultiplierPort On input, a pointer to the port multiplier port number of an\r | |
58727f29 | 1532 | ATA device present on the ATA controller.\r |
1533 | If on input a PortMultiplierPort of 0xFFFF is specified,\r | |
a41b5272 | 1534 | then the port multiplier port number of the first ATA device\r |
1535 | is returned. On output, a pointer to the port multiplier port\r | |
1536 | number of the next ATA device present on an ATA controller.\r | |
1537 | \r | |
1538 | @retval EFI_SUCCESS The port multiplier port number of the next ATA device on the port\r | |
1539 | of the ATA controller was returned in PortMultiplierPort.\r | |
1540 | @retval EFI_NOT_FOUND There are no more ATA devices on this port of the ATA controller.\r | |
1541 | @retval EFI_INVALID_PARAMETER PortMultiplierPort is not 0xFFFF, and PortMultiplierPort was not\r | |
1542 | returned on a previous call to GetNextDevice().\r | |
1543 | \r | |
1544 | **/\r | |
1545 | EFI_STATUS\r | |
1546 | EFIAPI\r | |
1547 | AtaPassThruGetNextDevice (\r | |
1548 | IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r | |
1549 | IN UINT16 Port,\r | |
1550 | IN OUT UINT16 *PortMultiplierPort\r | |
1551 | )\r | |
1552 | {\r | |
1553 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
1554 | LIST_ENTRY *Node;\r | |
1555 | EFI_ATA_DEVICE_INFO *DeviceInfo;\r | |
1556 | \r | |
1557 | Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
1558 | \r | |
1559 | if (PortMultiplierPort == NULL) {\r | |
1560 | return EFI_INVALID_PARAMETER;\r | |
1561 | }\r | |
1562 | \r | |
23a596db | 1563 | if (Instance->PreviousPortMultiplier == 0xFFFF) {\r |
a41b5272 | 1564 | //\r |
23a596db HW |
1565 | // If a device is directly attached on a port, previous call to this\r |
1566 | // function will return the value 0xFFFF for PortMultiplierPort. In\r | |
1567 | // this case, there should be no more device on the port multiplier.\r | |
a41b5272 | 1568 | //\r |
23a596db HW |
1569 | Instance->PreviousPortMultiplier = 0;\r |
1570 | return EFI_NOT_FOUND;\r | |
1571 | }\r | |
1572 | \r | |
1573 | if (*PortMultiplierPort == Instance->PreviousPortMultiplier) {\r | |
a41b5272 | 1574 | Node = GetFirstNode (&Instance->DeviceList);\r |
1575 | \r | |
1576 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
1577 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
1578 | \r | |
1579 | if ((DeviceInfo->Type == EfiIdeHarddisk) &&\r | |
23a596db HW |
1580 | (DeviceInfo->Port == Port) &&\r |
1581 | (DeviceInfo->PortMultiplier > *PortMultiplierPort)){\r | |
a41b5272 | 1582 | *PortMultiplierPort = DeviceInfo->PortMultiplier;\r |
1583 | goto Exit;\r | |
1584 | }\r | |
1585 | \r | |
1586 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
1587 | }\r | |
1588 | \r | |
1589 | return EFI_NOT_FOUND;\r | |
23a596db HW |
1590 | } else if (*PortMultiplierPort == 0xFFFF) {\r |
1591 | //\r | |
1592 | // If the PortMultiplierPort is all 0xFF's, start to traverse the device list from the beginning\r | |
1593 | //\r | |
a41b5272 | 1594 | Node = GetFirstNode (&Instance->DeviceList);\r |
1595 | \r | |
1596 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
1597 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
1598 | \r | |
1599 | if ((DeviceInfo->Type == EfiIdeHarddisk) &&\r | |
23a596db | 1600 | (DeviceInfo->Port == Port)){\r |
a41b5272 | 1601 | *PortMultiplierPort = DeviceInfo->PortMultiplier;\r |
1602 | goto Exit;\r | |
1603 | }\r | |
1604 | \r | |
1605 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
1606 | }\r | |
1607 | \r | |
1608 | return EFI_NOT_FOUND;\r | |
1609 | } else {\r | |
1610 | //\r | |
1611 | // PortMultiplierPort is not equal to 0xFFFF and also not equal to previous return value\r | |
1612 | //\r | |
1613 | return EFI_INVALID_PARAMETER;\r | |
1614 | }\r | |
490b5ea1 | 1615 | \r |
a41b5272 | 1616 | Exit:\r |
1617 | //\r | |
1618 | // Update the PreviousPort and PreviousPortMultiplier.\r | |
1619 | //\r | |
1620 | Instance->PreviousPortMultiplier = *PortMultiplierPort;\r | |
1621 | \r | |
1622 | return EFI_SUCCESS;\r | |
1623 | }\r | |
1624 | \r | |
1625 | /**\r | |
1626 | Used to allocate and build a device path node for an ATA device on an ATA controller.\r | |
1627 | \r | |
1628 | The BuildDevicePath() function allocates and builds a single device node for the ATA\r | |
1629 | device specified by Port and PortMultiplierPort. If the ATA device specified by Port and\r | |
1630 | PortMultiplierPort is not present on the ATA controller, then EFI_NOT_FOUND is returned.\r | |
1631 | If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned. If there are not enough\r | |
1632 | resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.\r | |
1633 | \r | |
1634 | Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of\r | |
1635 | DevicePath are initialized to describe the ATA device specified by Port and PortMultiplierPort,\r | |
1636 | and EFI_SUCCESS is returned.\r | |
1637 | \r | |
1638 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r | |
1639 | @param[in] Port Port specifies the port number of the ATA device for which a\r | |
1640 | device path node is to be allocated and built.\r | |
1641 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device for which a\r | |
1642 | device path node is to be allocated and built. If there is no\r | |
23a596db | 1643 | port multiplier, then specify 0xFFFF.\r |
a41b5272 | 1644 | @param[in, out] DevicePath A pointer to a single device path node that describes the ATA\r |
1645 | device specified by Port and PortMultiplierPort. This function\r | |
1646 | is responsible for allocating the buffer DevicePath with the\r | |
1647 | boot service AllocatePool(). It is the caller's responsibility\r | |
1648 | to free DevicePath when the caller is finished with DevicePath.\r | |
1649 | @retval EFI_SUCCESS The device path node that describes the ATA device specified by\r | |
1650 | Port and PortMultiplierPort was allocated and returned in DevicePath.\r | |
1651 | @retval EFI_NOT_FOUND The ATA device specified by Port and PortMultiplierPort does not\r | |
1652 | exist on the ATA controller.\r | |
1653 | @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r | |
1654 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.\r | |
1655 | \r | |
1656 | **/\r | |
1657 | EFI_STATUS\r | |
1658 | EFIAPI\r | |
1659 | AtaPassThruBuildDevicePath (\r | |
1660 | IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r | |
1661 | IN UINT16 Port,\r | |
1662 | IN UINT16 PortMultiplierPort,\r | |
1663 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r | |
1664 | )\r | |
1665 | {\r | |
1666 | EFI_DEV_PATH *DevicePathNode;\r | |
1667 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
1668 | LIST_ENTRY *Node;\r | |
1669 | \r | |
1670 | Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
1671 | \r | |
1672 | //\r | |
1673 | // Validate parameters passed in.\r | |
1674 | //\r | |
1675 | if (DevicePath == NULL) {\r | |
1676 | return EFI_INVALID_PARAMETER;\r | |
1677 | }\r | |
1678 | \r | |
1679 | Node = SearchDeviceInfoList(Instance, Port, PortMultiplierPort, EfiIdeHarddisk);\r | |
1680 | if (Node == NULL) {\r | |
1681 | return EFI_NOT_FOUND;\r | |
1682 | }\r | |
490b5ea1 | 1683 | \r |
a41b5272 | 1684 | if (Instance->Mode == EfiAtaIdeMode) {\r |
1685 | DevicePathNode = AllocateCopyPool (sizeof (ATAPI_DEVICE_PATH), &mAtapiDevicePathTemplate);\r | |
1686 | if (DevicePathNode == NULL) {\r | |
1687 | return EFI_OUT_OF_RESOURCES;\r | |
1688 | }\r | |
1689 | DevicePathNode->Atapi.PrimarySecondary = (UINT8) Port;\r | |
1690 | DevicePathNode->Atapi.SlaveMaster = (UINT8) PortMultiplierPort;\r | |
1691 | DevicePathNode->Atapi.Lun = 0;\r | |
1692 | } else {\r | |
1693 | DevicePathNode = AllocateCopyPool (sizeof (SATA_DEVICE_PATH), &mSataDevicePathTemplate);\r | |
1694 | if (DevicePathNode == NULL) {\r | |
1695 | return EFI_OUT_OF_RESOURCES;\r | |
1696 | }\r | |
1697 | \r | |
1698 | DevicePathNode->Sata.HBAPortNumber = Port;\r | |
1699 | DevicePathNode->Sata.PortMultiplierPortNumber = PortMultiplierPort;\r | |
1700 | DevicePathNode->Sata.Lun = 0;\r | |
1701 | }\r | |
1702 | \r | |
1703 | *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DevicePathNode;\r | |
1704 | \r | |
1705 | return EFI_SUCCESS;\r | |
1706 | }\r | |
1707 | \r | |
1708 | /**\r | |
1709 | Used to translate a device path node to a port number and port multiplier port number.\r | |
1710 | \r | |
1711 | The GetDevice() function determines the port and port multiplier port number associated with\r | |
1712 | the ATA device described by DevicePath. If DevicePath is a device path node type that the\r | |
58727f29 | 1713 | ATA Pass Thru driver supports, then the ATA Pass Thru driver will attempt to translate the contents\r |
a41b5272 | 1714 | DevicePath into a port number and port multiplier port number.\r |
1715 | \r | |
1716 | If this translation is successful, then that port number and port multiplier port number are returned\r | |
1717 | in Port and PortMultiplierPort, and EFI_SUCCESS is returned.\r | |
1718 | \r | |
1719 | If DevicePath, Port, or PortMultiplierPort are NULL, then EFI_INVALID_PARAMETER is returned.\r | |
1720 | \r | |
58727f29 | 1721 | If DevicePath is not a device path node type that the ATA Pass Thru driver supports, then\r |
a41b5272 | 1722 | EFI_UNSUPPORTED is returned.\r |
1723 | \r | |
58727f29 | 1724 | If DevicePath is a device path node type that the ATA Pass Thru driver supports, but there is not\r |
1725 | a valid translation from DevicePath to a port number and port multiplier port number, then\r | |
a41b5272 | 1726 | EFI_NOT_FOUND is returned.\r |
1727 | \r | |
1728 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r | |
1729 | @param[in] DevicePath A pointer to the device path node that describes an ATA device on the\r | |
1730 | ATA controller.\r | |
1731 | @param[out] Port On return, points to the port number of an ATA device on the ATA controller.\r | |
1732 | @param[out] PortMultiplierPort On return, points to the port multiplier port number of an ATA device\r | |
1733 | on the ATA controller.\r | |
1734 | \r | |
1735 | @retval EFI_SUCCESS DevicePath was successfully translated to a port number and port multiplier\r | |
1736 | port number, and they were returned in Port and PortMultiplierPort.\r | |
1737 | @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r | |
1738 | @retval EFI_INVALID_PARAMETER Port is NULL.\r | |
1739 | @retval EFI_INVALID_PARAMETER PortMultiplierPort is NULL.\r | |
1740 | @retval EFI_UNSUPPORTED This driver does not support the device path node type in DevicePath.\r | |
1741 | @retval EFI_NOT_FOUND A valid translation from DevicePath to a port number and port multiplier\r | |
1742 | port number does not exist.\r | |
1743 | **/\r | |
1744 | EFI_STATUS\r | |
1745 | EFIAPI\r | |
1746 | AtaPassThruGetDevice (\r | |
1747 | IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r | |
1748 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
1749 | OUT UINT16 *Port,\r | |
1750 | OUT UINT16 *PortMultiplierPort\r | |
1751 | )\r | |
1752 | {\r | |
1753 | EFI_DEV_PATH *DevicePathNode;\r | |
1754 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
1755 | LIST_ENTRY *Node;\r | |
1756 | \r | |
1757 | Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
1758 | \r | |
1759 | //\r | |
1760 | // Validate parameters passed in.\r | |
1761 | //\r | |
1762 | if (DevicePath == NULL || Port == NULL || PortMultiplierPort == NULL) {\r | |
1763 | return EFI_INVALID_PARAMETER;\r | |
1764 | }\r | |
1765 | \r | |
1766 | //\r | |
1767 | // Check whether the DevicePath belongs to SCSI_DEVICE_PATH or ATAPI_DEVICE_PATH\r | |
1768 | //\r | |
1769 | if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||\r | |
1770 | ((DevicePath->SubType != MSG_SATA_DP) &&\r | |
1771 | (DevicePath->SubType != MSG_ATAPI_DP)) ||\r | |
1772 | ((DevicePathNodeLength(DevicePath) != sizeof(ATAPI_DEVICE_PATH)) &&\r | |
1773 | (DevicePathNodeLength(DevicePath) != sizeof(SATA_DEVICE_PATH)))) {\r | |
1774 | return EFI_UNSUPPORTED;\r | |
1775 | }\r | |
1776 | \r | |
1777 | DevicePathNode = (EFI_DEV_PATH *) DevicePath;\r | |
1778 | \r | |
1779 | if (Instance->Mode == EfiAtaIdeMode) {\r | |
1780 | *Port = DevicePathNode->Atapi.PrimarySecondary;\r | |
1781 | *PortMultiplierPort = DevicePathNode->Atapi.SlaveMaster;\r | |
1782 | } else {\r | |
1783 | *Port = DevicePathNode->Sata.HBAPortNumber;\r | |
1784 | *PortMultiplierPort = DevicePathNode->Sata.PortMultiplierPortNumber;\r | |
1785 | }\r | |
1786 | \r | |
1787 | Node = SearchDeviceInfoList(Instance, *Port, *PortMultiplierPort, EfiIdeHarddisk);\r | |
1788 | \r | |
1789 | if (Node == NULL) {\r | |
1790 | return EFI_NOT_FOUND;\r | |
1791 | }\r | |
1792 | \r | |
1793 | return EFI_SUCCESS;\r | |
1794 | }\r | |
1795 | \r | |
1796 | /**\r | |
1797 | Resets a specific port on the ATA controller. This operation also resets all the ATA devices\r | |
1798 | connected to the port.\r | |
1799 | \r | |
1800 | The ResetChannel() function resets an a specific port on an ATA controller. This operation\r | |
1801 | resets all the ATA devices connected to that port. If this ATA controller does not support\r | |
1802 | a reset port operation, then EFI_UNSUPPORTED is returned.\r | |
1803 | \r | |
1804 | If a device error occurs while executing that port reset operation, then EFI_DEVICE_ERROR is\r | |
1805 | returned.\r | |
1806 | \r | |
1807 | If a timeout occurs during the execution of the port reset operation, then EFI_TIMEOUT is returned.\r | |
1808 | \r | |
1809 | If the port reset operation is completed, then EFI_SUCCESS is returned.\r | |
1810 | \r | |
1811 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r | |
1812 | @param[in] Port The port number on the ATA controller.\r | |
1813 | \r | |
1814 | @retval EFI_SUCCESS The ATA controller port was reset.\r | |
1815 | @retval EFI_UNSUPPORTED The ATA controller does not support a port reset operation.\r | |
1816 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA port.\r | |
1817 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA port.\r | |
1818 | \r | |
1819 | **/\r | |
1820 | EFI_STATUS\r | |
1821 | EFIAPI\r | |
1822 | AtaPassThruResetPort (\r | |
1823 | IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r | |
1824 | IN UINT16 Port\r | |
1825 | )\r | |
1826 | {\r | |
71fd9fae TF |
1827 | //\r |
1828 | // Return success directly then upper layer driver could think reset port operation is done.\r | |
1829 | //\r | |
1830 | return EFI_SUCCESS;\r | |
a41b5272 | 1831 | }\r |
1832 | \r | |
1833 | /**\r | |
1834 | Resets an ATA device that is connected to an ATA controller.\r | |
1835 | \r | |
1836 | The ResetDevice() function resets the ATA device specified by Port and PortMultiplierPort.\r | |
1837 | If this ATA controller does not support a device reset operation, then EFI_UNSUPPORTED is\r | |
1838 | returned.\r | |
1839 | \r | |
58727f29 | 1840 | If Port or PortMultiplierPort are not in a valid range for this ATA controller, then\r |
a41b5272 | 1841 | EFI_INVALID_PARAMETER is returned.\r |
1842 | \r | |
1843 | If a device error occurs while executing that device reset operation, then EFI_DEVICE_ERROR\r | |
1844 | is returned.\r | |
1845 | \r | |
1846 | If a timeout occurs during the execution of the device reset operation, then EFI_TIMEOUT is\r | |
1847 | returned.\r | |
1848 | \r | |
1849 | If the device reset operation is completed, then EFI_SUCCESS is returned.\r | |
1850 | \r | |
1851 | @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r | |
1852 | @param[in] Port Port represents the port number of the ATA device to be reset.\r | |
1853 | @param[in] PortMultiplierPort The port multiplier port number of the ATA device to reset.\r | |
23a596db | 1854 | If there is no port multiplier, then specify 0xFFFF.\r |
a41b5272 | 1855 | @retval EFI_SUCCESS The ATA device specified by Port and PortMultiplierPort was reset.\r |
1856 | @retval EFI_UNSUPPORTED The ATA controller does not support a device reset operation.\r | |
1857 | @retval EFI_INVALID_PARAMETER Port or PortMultiplierPort are invalid.\r | |
1858 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA device\r | |
1859 | specified by Port and PortMultiplierPort.\r | |
1860 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA device\r | |
1861 | specified by Port and PortMultiplierPort.\r | |
1862 | \r | |
1863 | **/\r | |
1864 | EFI_STATUS\r | |
1865 | EFIAPI\r | |
1866 | AtaPassThruResetDevice (\r | |
1867 | IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r | |
1868 | IN UINT16 Port,\r | |
1869 | IN UINT16 PortMultiplierPort\r | |
1870 | )\r | |
1871 | {\r | |
59b1b9d2 TF |
1872 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r |
1873 | LIST_ENTRY *Node;\r | |
1874 | \r | |
1875 | Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
1876 | \r | |
1877 | Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk);\r | |
1878 | \r | |
1879 | if (Node == NULL) {\r | |
1880 | return EFI_INVALID_PARAMETER;\r | |
1881 | }\r | |
1882 | \r | |
71fd9fae TF |
1883 | //\r |
1884 | // Return success directly then upper layer driver could think reset device operation is done.\r | |
1885 | //\r | |
1886 | return EFI_SUCCESS;\r | |
a41b5272 | 1887 | }\r |
1888 | \r | |
73a9e822 | 1889 | /**\r |
ed356b9e | 1890 | Submit ATAPI request sense command.\r |
73a9e822 TF |
1891 | \r |
1892 | @param[in] This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
1893 | @param[in] Target The Target is an array of size TARGET_MAX_BYTES and it represents\r | |
1894 | the id of the SCSI device to send the SCSI Request Packet. Each\r | |
1895 | transport driver may choose to utilize a subset of this size to suit the needs\r | |
1896 | of transport target representation. For example, a Fibre Channel driver\r | |
1897 | may use only 8 bytes (WWN) to represent an FC target.\r | |
1898 | @param[in] Lun The LUN of the SCSI device to send the SCSI Request Packet.\r | |
1899 | @param[in] SenseData A pointer to store sense data.\r | |
1900 | @param[in] SenseDataLength The sense data length.\r | |
1901 | @param[in] Timeout The timeout value to execute this cmd, uses 100ns as a unit.\r | |
1902 | \r | |
1903 | @retval EFI_SUCCESS Send out the ATAPI packet command successfully.\r | |
1904 | @retval EFI_DEVICE_ERROR The device failed to send data.\r | |
1905 | \r | |
1906 | **/\r | |
1907 | EFI_STATUS\r | |
1908 | EFIAPI\r | |
1909 | AtaPacketRequestSense (\r | |
1910 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
1911 | IN UINT8 *Target,\r | |
1912 | IN UINT64 Lun,\r | |
1913 | IN VOID *SenseData,\r | |
1914 | IN UINT8 SenseDataLength,\r | |
1915 | IN UINT64 Timeout\r | |
1916 | )\r | |
1917 | {\r | |
1918 | EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet;\r | |
1919 | UINT8 Cdb[12];\r | |
1920 | EFI_STATUS Status;\r | |
1921 | \r | |
1922 | ZeroMem (&Packet, sizeof (EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET));\r | |
1923 | ZeroMem (Cdb, 12);\r | |
1924 | \r | |
1925 | Cdb[0] = ATA_CMD_REQUEST_SENSE;\r | |
1926 | Cdb[4] = SenseDataLength;\r | |
1927 | \r | |
1928 | Packet.Timeout = Timeout;\r | |
1929 | Packet.Cdb = Cdb;\r | |
1930 | Packet.CdbLength = 12;\r | |
1931 | Packet.DataDirection = EFI_EXT_SCSI_DATA_DIRECTION_READ;\r | |
1932 | Packet.InDataBuffer = SenseData;\r | |
1933 | Packet.InTransferLength = SenseDataLength;\r | |
1934 | \r | |
1935 | Status = ExtScsiPassThruPassThru (This, Target, Lun, &Packet, NULL);\r | |
1936 | \r | |
1937 | return Status;\r | |
1938 | }\r | |
1939 | \r | |
a41b5272 | 1940 | /**\r |
58727f29 | 1941 | Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function\r |
a41b5272 | 1942 | supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the\r |
58727f29 | 1943 | nonblocking I/O functionality is optional.\r |
a41b5272 | 1944 | \r |
1945 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
1946 | @param Target The Target is an array of size TARGET_MAX_BYTES and it represents\r | |
1947 | the id of the SCSI device to send the SCSI Request Packet. Each\r | |
1948 | transport driver may choose to utilize a subset of this size to suit the needs\r | |
1949 | of transport target representation. For example, a Fibre Channel driver\r | |
1950 | may use only 8 bytes (WWN) to represent an FC target.\r | |
1951 | @param Lun The LUN of the SCSI device to send the SCSI Request Packet.\r | |
1952 | @param Packet A pointer to the SCSI Request Packet to send to the SCSI device\r | |
1953 | specified by Target and Lun.\r | |
1954 | @param Event If nonblocking I/O is not supported then Event is ignored, and blocking\r | |
1955 | I/O is performed. If Event is NULL, then blocking I/O is performed. If\r | |
1956 | Event is not NULL and non blocking I/O is supported, then\r | |
1957 | nonblocking I/O is performed, and Event will be signaled when the\r | |
1958 | SCSI Request Packet completes.\r | |
1959 | \r | |
1960 | @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional\r | |
1961 | commands, InTransferLength bytes were transferred from\r | |
1962 | InDataBuffer. For write and bi-directional commands,\r | |
1963 | OutTransferLength bytes were transferred by\r | |
1964 | OutDataBuffer.\r | |
1965 | @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was not executed. The number of bytes that\r | |
1966 | could be transferred is returned in InTransferLength. For write\r | |
1967 | and bi-directional commands, OutTransferLength bytes were\r | |
1968 | transferred by OutDataBuffer.\r | |
1969 | @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many\r | |
1970 | SCSI Request Packets already queued. The caller may retry again later.\r | |
1971 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request\r | |
1972 | Packet.\r | |
1973 | @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket are invalid.\r | |
1974 | @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported\r | |
1975 | by the host adapter. This includes the case of Bi-directional SCSI\r | |
1976 | commands not supported by the implementation. The SCSI Request\r | |
1977 | Packet was not sent, so no additional status information is available.\r | |
1978 | @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.\r | |
1979 | \r | |
1980 | **/\r | |
1981 | EFI_STATUS\r | |
1982 | EFIAPI\r | |
1983 | ExtScsiPassThruPassThru (\r | |
1984 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
1985 | IN UINT8 *Target,\r | |
1986 | IN UINT64 Lun,\r | |
1987 | IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,\r | |
1988 | IN EFI_EVENT Event OPTIONAL\r | |
1989 | )\r | |
1990 | {\r | |
1991 | EFI_STATUS Status;\r | |
1992 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
1993 | UINT8 Port;\r | |
1994 | UINT8 PortMultiplier;\r | |
1995 | EFI_ATA_HC_WORK_MODE Mode;\r | |
1996 | LIST_ENTRY *Node;\r | |
1997 | EFI_ATA_DEVICE_INFO *DeviceInfo;\r | |
73a9e822 TF |
1998 | BOOLEAN SenseReq;\r |
1999 | EFI_SCSI_SENSE_DATA *PtrSenseData;\r | |
2000 | UINTN SenseDataLen;\r | |
2001 | EFI_STATUS SenseStatus;\r | |
a41b5272 | 2002 | \r |
73a9e822 TF |
2003 | SenseDataLen = 0;\r |
2004 | Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
a41b5272 | 2005 | \r |
2006 | if ((Packet == NULL) || (Packet->Cdb == NULL)) {\r | |
2007 | return EFI_INVALID_PARAMETER;\r | |
2008 | }\r | |
2009 | \r | |
2010 | //\r | |
2011 | // Don't support variable length CDB\r | |
2012 | //\r | |
2013 | if ((Packet->CdbLength != 6) && (Packet->CdbLength != 10) &&\r | |
2014 | (Packet->CdbLength != 12) && (Packet->CdbLength != 16)) {\r | |
2015 | return EFI_INVALID_PARAMETER;\r | |
2016 | }\r | |
58727f29 | 2017 | \r |
73a9e822 TF |
2018 | if ((Packet->SenseDataLength != 0) && (Packet->SenseData == NULL)) {\r |
2019 | return EFI_INVALID_PARAMETER;\r | |
2020 | }\r | |
2021 | \r | |
a41b5272 | 2022 | if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->InDataBuffer, This->Mode->IoAlign)) {\r |
2023 | return EFI_INVALID_PARAMETER;\r | |
2024 | }\r | |
2025 | \r | |
2026 | if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->OutDataBuffer, This->Mode->IoAlign)) {\r | |
2027 | return EFI_INVALID_PARAMETER;\r | |
2028 | }\r | |
2029 | \r | |
2030 | if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->SenseData, This->Mode->IoAlign)) {\r | |
2031 | return EFI_INVALID_PARAMETER;\r | |
2032 | }\r | |
2033 | \r | |
2034 | //\r | |
2035 | // For ATAPI device, doesn't support multiple LUN device.\r | |
2036 | //\r | |
2037 | if (Lun != 0) {\r | |
2038 | return EFI_INVALID_PARAMETER;\r | |
2039 | }\r | |
2040 | \r | |
58727f29 | 2041 | //\r |
a41b5272 | 2042 | // The layout of Target array:\r |
2043 | // ________________________________________________________________________\r | |
2044 | // | Byte 0 | Byte 1 | ... | TARGET_MAX_BYTES - 1 |\r | |
2045 | // |_____________________|_____________________|_____|______________________|\r | |
2046 | // | | The port multiplier | | |\r | |
2047 | // | The port number | port number | N/A | N/A |\r | |
2048 | // |_____________________|_____________________|_____|______________________|\r | |
2049 | //\r | |
2050 | // For ATAPI device, 2 bytes is enough to represent the location of SCSI device.\r | |
2051 | //\r | |
2052 | Port = Target[0];\r | |
2053 | PortMultiplier = Target[1];\r | |
2054 | \r | |
2055 | Node = SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom);\r | |
2056 | if (Node == NULL) {\r | |
2057 | return EFI_INVALID_PARAMETER;\r | |
2058 | }\r | |
2059 | \r | |
2060 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
2061 | \r | |
2062 | //\r | |
2063 | // ATA_CMD_IDENTIFY_DEVICE cmd is a ATA cmd but not a SCSI cmd.\r | |
2064 | // Normally it should NOT be passed down through ExtScsiPassThru protocol interface.\r | |
2065 | // But to response EFI_DISK_INFO.Identify() request from ScsiDisk, we should handle this command.\r | |
2066 | //\r | |
2067 | if (*((UINT8*)Packet->Cdb) == ATA_CMD_IDENTIFY_DEVICE) {\r | |
2068 | CopyMem (Packet->InDataBuffer, DeviceInfo->IdentifyData, sizeof (EFI_IDENTIFY_DATA));\r | |
73a9e822 TF |
2069 | //\r |
2070 | // For IDENTIFY DEVICE cmd, we don't need to get sense data.\r | |
2071 | //\r | |
2072 | Packet->SenseDataLength = 0;\r | |
a41b5272 | 2073 | return EFI_SUCCESS;\r |
2074 | }\r | |
2075 | \r | |
2076 | Mode = Instance->Mode;\r | |
2077 | switch (Mode) {\r | |
2078 | case EfiAtaIdeMode:\r | |
2079 | //\r | |
2080 | // Reassign IDE mode io port registers' base addresses\r | |
2081 | //\r | |
2082 | Status = GetIdeRegisterIoAddr (Instance->PciIo, Instance->IdeRegisters);\r | |
2083 | \r | |
2084 | if (EFI_ERROR (Status)) {\r | |
2085 | return Status;\r | |
2086 | }\r | |
2087 | \r | |
2088 | Status = AtaPacketCommandExecute (Instance->PciIo, &Instance->IdeRegisters[Port], Port, PortMultiplier, Packet);\r | |
2089 | break;\r | |
2090 | case EfiAtaAhciMode:\r | |
23a596db HW |
2091 | if (PortMultiplier == 0xFF) {\r |
2092 | //\r | |
2093 | // If there is no port multiplier, the PortMultiplier will be 0xFF\r | |
2094 | // Here, we convert its value to 0 to follow the AHCI spec.\r | |
2095 | //\r | |
2096 | PortMultiplier = 0;\r | |
2097 | }\r | |
a41b5272 | 2098 | Status = AhciPacketCommandExecute (Instance->PciIo, &Instance->AhciRegisters, Port, PortMultiplier, Packet);\r |
2099 | break;\r | |
2100 | default :\r | |
2101 | Status = EFI_DEVICE_ERROR;\r | |
2102 | break;\r | |
2103 | }\r | |
2104 | \r | |
73a9e822 TF |
2105 | //\r |
2106 | // If the cmd doesn't get executed correctly, then check sense data.\r | |
2107 | //\r | |
2108 | if (EFI_ERROR (Status) && (Packet->SenseDataLength != 0) && (*((UINT8*)Packet->Cdb) != ATA_CMD_REQUEST_SENSE)) {\r | |
2109 | PtrSenseData = AllocateAlignedPages (EFI_SIZE_TO_PAGES (sizeof (EFI_SCSI_SENSE_DATA)), This->Mode->IoAlign);\r | |
2110 | if (PtrSenseData == NULL) {\r | |
2111 | return EFI_DEVICE_ERROR;\r | |
2112 | }\r | |
2113 | \r | |
2114 | for (SenseReq = TRUE; SenseReq;) {\r | |
2115 | SenseStatus = AtaPacketRequestSense (\r | |
2116 | This,\r | |
2117 | Target,\r | |
2118 | Lun,\r | |
2119 | PtrSenseData,\r | |
2120 | sizeof (EFI_SCSI_SENSE_DATA),\r | |
2121 | Packet->Timeout\r | |
2122 | );\r | |
2123 | if (EFI_ERROR (SenseStatus)) {\r | |
2124 | break;\r | |
2125 | }\r | |
2126 | \r | |
2127 | CopyMem ((UINT8*)Packet->SenseData + SenseDataLen, PtrSenseData, sizeof (EFI_SCSI_SENSE_DATA));\r | |
2128 | SenseDataLen += sizeof (EFI_SCSI_SENSE_DATA);\r | |
2129 | \r | |
2130 | //\r | |
2131 | // no more sense key or number of sense keys exceeds predefined,\r | |
2132 | // skip the loop.\r | |
2133 | //\r | |
e7401ee1 | 2134 | if ((PtrSenseData->Sense_Key == EFI_SCSI_SK_NO_SENSE) ||\r |
73a9e822 TF |
2135 | (SenseDataLen + sizeof (EFI_SCSI_SENSE_DATA) > Packet->SenseDataLength)) {\r |
2136 | SenseReq = FALSE;\r | |
2137 | }\r | |
2138 | }\r | |
2139 | FreeAlignedPages (PtrSenseData, EFI_SIZE_TO_PAGES (sizeof (EFI_SCSI_SENSE_DATA)));\r | |
2140 | }\r | |
2141 | //\r | |
2142 | // Update the SenseDataLength field to the data length received.\r | |
2143 | //\r | |
2144 | Packet->SenseDataLength = (UINT8)SenseDataLen;\r | |
a41b5272 | 2145 | return Status;\r |
2146 | }\r | |
2147 | \r | |
2148 | /**\r | |
58727f29 | 2149 | Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These\r |
a41b5272 | 2150 | can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal\r |
58727f29 | 2151 | Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the\r |
2152 | Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI\r | |
490b5ea1 | 2153 | channel.\r |
a41b5272 | 2154 | \r |
2155 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
2156 | @param Target On input, a pointer to the Target ID (an array of size\r | |
2157 | TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r | |
2158 | On output, a pointer to the Target ID (an array of\r | |
2159 | TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r | |
2160 | channel. An input value of 0xF(all bytes in the array are 0xF) in the\r | |
2161 | Target array retrieves the Target ID of the first SCSI device present on a\r | |
2162 | SCSI channel.\r | |
2163 | @param Lun On input, a pointer to the LUN of a SCSI device present on the SCSI\r | |
2164 | channel. On output, a pointer to the LUN of the next SCSI device present\r | |
2165 | on a SCSI channel.\r | |
2166 | \r | |
2167 | @retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI\r | |
2168 | channel was returned in Target and Lun.\r | |
2169 | @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were\r | |
2170 | not returned on a previous call to GetNextTargetLun().\r | |
2171 | @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.\r | |
2172 | \r | |
2173 | **/\r | |
2174 | EFI_STATUS\r | |
2175 | EFIAPI\r | |
2176 | ExtScsiPassThruGetNextTargetLun (\r | |
2177 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
2178 | IN OUT UINT8 **Target,\r | |
2179 | IN OUT UINT64 *Lun\r | |
2180 | )\r | |
2181 | {\r | |
2182 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
2183 | LIST_ENTRY *Node;\r | |
2184 | EFI_ATA_DEVICE_INFO *DeviceInfo;\r | |
2185 | UINT8 *Target8;\r | |
2186 | UINT16 *Target16;\r | |
2187 | \r | |
2188 | Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
2189 | \r | |
2190 | if (Target == NULL || Lun == NULL) {\r | |
2191 | return EFI_INVALID_PARAMETER;\r | |
2192 | }\r | |
2193 | \r | |
2194 | if (*Target == NULL) {\r | |
2195 | return EFI_INVALID_PARAMETER;\r | |
2196 | }\r | |
2197 | \r | |
2198 | Target8 = *Target;\r | |
2199 | Target16 = (UINT16 *)*Target;\r | |
2200 | \r | |
2201 | if (CompareMem(Target8, mScsiId, TARGET_MAX_BYTES) != 0) {\r | |
2202 | //\r | |
2203 | // For ATAPI device, we use 2 least significant bytes to represent the location of SCSI device.\r | |
2204 | // So the higher bytes in Target array should be 0xFF.\r | |
2205 | //\r | |
2206 | if (CompareMem (&Target8[2], &mScsiId[2], TARGET_MAX_BYTES - 2) != 0) {\r | |
2207 | return EFI_INVALID_PARAMETER;\r | |
2208 | }\r | |
2209 | \r | |
2210 | //\r | |
2211 | // When Target is not all 0xFF's, compare 2 least significant bytes with\r | |
2212 | // previous target id to see if it is returned by previous call.\r | |
2213 | //\r | |
2214 | if ((*Target16 != Instance->PreviousTargetId) ||\r | |
2215 | (*Lun != Instance->PreviousLun)) {\r | |
2216 | return EFI_INVALID_PARAMETER;\r | |
2217 | }\r | |
2218 | \r | |
2219 | //\r | |
2220 | // Traverse the whole device list to find the next cdrom closed to\r | |
2221 | // the device signified by Target[0] and Target[1].\r | |
2222 | //\r | |
2223 | // Note that we here use a tricky way to find the next cdrom :\r | |
2224 | // All ata devices are detected and inserted into the device list\r | |
2225 | // sequentially.\r | |
2226 | //\r | |
2227 | Node = GetFirstNode (&Instance->DeviceList);\r | |
2228 | \r | |
2229 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
2230 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
2231 | \r | |
2232 | if ((DeviceInfo->Type == EfiIdeCdrom) &&\r | |
58727f29 | 2233 | ((Target8[0] < DeviceInfo->Port) ||\r |
d8982b03 | 2234 | ((Target8[0] == DeviceInfo->Port) &&\r |
23a596db | 2235 | (Target8[1] < (UINT8)DeviceInfo->PortMultiplier)))) {\r |
a41b5272 | 2236 | Target8[0] = (UINT8)DeviceInfo->Port;\r |
2237 | Target8[1] = (UINT8)DeviceInfo->PortMultiplier;\r | |
2238 | goto Exit;\r | |
2239 | }\r | |
2240 | \r | |
2241 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
2242 | }\r | |
2243 | \r | |
2244 | return EFI_NOT_FOUND;\r | |
2245 | } else {\r | |
2246 | //\r | |
2247 | // If the array is all 0xFF's, start to traverse the device list from the beginning\r | |
2248 | //\r | |
2249 | Node = GetFirstNode (&Instance->DeviceList);\r | |
2250 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
2251 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
2252 | \r | |
2253 | if (DeviceInfo->Type == EfiIdeCdrom) {\r | |
2254 | Target8[0] = (UINT8)DeviceInfo->Port;\r | |
2255 | Target8[1] = (UINT8)DeviceInfo->PortMultiplier;\r | |
2256 | goto Exit;\r | |
2257 | }\r | |
2258 | \r | |
2259 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
2260 | }\r | |
2261 | \r | |
2262 | return EFI_NOT_FOUND;\r | |
2263 | }\r | |
2264 | \r | |
2265 | Exit:\r | |
2266 | *Lun = 0;\r | |
2267 | \r | |
2268 | //\r | |
2269 | // Update the PreviousTargetId.\r | |
2270 | //\r | |
2271 | Instance->PreviousTargetId = *Target16;\r | |
2272 | Instance->PreviousLun = *Lun;\r | |
58727f29 | 2273 | \r |
a41b5272 | 2274 | return EFI_SUCCESS;\r |
490b5ea1 | 2275 | }\r |
a41b5272 | 2276 | \r |
2277 | /**\r | |
2278 | Used to allocate and build a device path node for a SCSI device on a SCSI channel.\r | |
2279 | \r | |
2280 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
2281 | @param Target The Target is an array of size TARGET_MAX_BYTES and it specifies the\r | |
2282 | Target ID of the SCSI device for which a device path node is to be\r | |
2283 | allocated and built. Transport drivers may chose to utilize a subset of\r | |
2284 | this size to suit the representation of targets. For example, a Fibre\r | |
2285 | Channel driver may use only 8 bytes (WWN) in the array to represent a\r | |
2286 | FC target.\r | |
2287 | @param Lun The LUN of the SCSI device for which a device path node is to be\r | |
2288 | allocated and built.\r | |
2289 | @param DevicePath A pointer to a single device path node that describes the SCSI device\r | |
2290 | specified by Target and Lun. This function is responsible for\r | |
2291 | allocating the buffer DevicePath with the boot service\r | |
2292 | AllocatePool(). It is the caller's responsibility to free\r | |
2293 | DevicePath when the caller is finished with DevicePath.\r | |
2294 | \r | |
2295 | @retval EFI_SUCCESS The device path node that describes the SCSI device specified by\r | |
2296 | Target and Lun was allocated and returned in\r | |
2297 | DevicePath.\r | |
2298 | @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r | |
2299 | @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does not exist\r | |
2300 | on the SCSI channel.\r | |
2301 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.\r | |
2302 | \r | |
2303 | **/\r | |
2304 | EFI_STATUS\r | |
2305 | EFIAPI\r | |
2306 | ExtScsiPassThruBuildDevicePath (\r | |
2307 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
2308 | IN UINT8 *Target,\r | |
2309 | IN UINT64 Lun,\r | |
2310 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r | |
2311 | )\r | |
2312 | {\r | |
2313 | EFI_DEV_PATH *DevicePathNode;\r | |
2314 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
2315 | UINT8 Port;\r | |
2316 | UINT8 PortMultiplier;\r | |
2317 | \r | |
2318 | Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
2319 | \r | |
2320 | Port = Target[0];\r | |
2321 | PortMultiplier = Target[1];\r | |
2322 | \r | |
2323 | //\r | |
2324 | // Validate parameters passed in.\r | |
2325 | //\r | |
2326 | if (DevicePath == NULL) {\r | |
2327 | return EFI_INVALID_PARAMETER;\r | |
2328 | }\r | |
2329 | \r | |
2330 | //\r | |
2331 | // can not build device path for the SCSI Host Controller.\r | |
2332 | //\r | |
2333 | if (Lun != 0) {\r | |
2334 | return EFI_NOT_FOUND;\r | |
2335 | }\r | |
2336 | \r | |
2337 | if (SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom) == NULL) {\r | |
2338 | return EFI_NOT_FOUND;\r | |
2339 | }\r | |
58727f29 | 2340 | \r |
a41b5272 | 2341 | if (Instance->Mode == EfiAtaIdeMode) {\r |
2342 | DevicePathNode = AllocateCopyPool (sizeof (ATAPI_DEVICE_PATH), &mAtapiDevicePathTemplate);\r | |
2343 | if (DevicePathNode == NULL) {\r | |
2344 | return EFI_OUT_OF_RESOURCES;\r | |
2345 | }\r | |
2346 | \r | |
2347 | DevicePathNode->Atapi.PrimarySecondary = Port;\r | |
2348 | DevicePathNode->Atapi.SlaveMaster = PortMultiplier;\r | |
2349 | DevicePathNode->Atapi.Lun = (UINT16) Lun;\r | |
2350 | } else {\r | |
2351 | DevicePathNode = AllocateCopyPool (sizeof (SATA_DEVICE_PATH), &mSataDevicePathTemplate);\r | |
2352 | if (DevicePathNode == NULL) {\r | |
2353 | return EFI_OUT_OF_RESOURCES;\r | |
2354 | }\r | |
2355 | \r | |
2356 | DevicePathNode->Sata.HBAPortNumber = Port;\r | |
23a596db HW |
2357 | //\r |
2358 | // For CD-ROM working in the AHCI mode, only 8 bits are used to record\r | |
2359 | // the PortMultiplier information. If the CD-ROM is directly attached\r | |
2360 | // on a SATA port, the PortMultiplier should be translated from 0xFF\r | |
2361 | // to 0xFFFF according to the UEFI spec.\r | |
2362 | //\r | |
2363 | DevicePathNode->Sata.PortMultiplierPortNumber = PortMultiplier == 0xFF ? 0xFFFF : PortMultiplier;\r | |
a41b5272 | 2364 | DevicePathNode->Sata.Lun = (UINT16) Lun;\r |
2365 | }\r | |
2366 | \r | |
2367 | *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DevicePathNode;\r | |
2368 | \r | |
2369 | return EFI_SUCCESS;\r | |
2370 | }\r | |
2371 | \r | |
2372 | /**\r | |
2373 | Used to translate a device path node to a Target ID and LUN.\r | |
2374 | \r | |
2375 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
2376 | @param DevicePath A pointer to a single device path node that describes the SCSI device\r | |
2377 | on the SCSI channel.\r | |
2378 | @param Target A pointer to the Target Array which represents the ID of a SCSI device\r | |
2379 | on the SCSI channel.\r | |
2380 | @param Lun A pointer to the LUN of a SCSI device on the SCSI channel.\r | |
2381 | \r | |
2382 | @retval EFI_SUCCESS DevicePath was successfully translated to a Target ID and\r | |
2383 | LUN, and they were returned in Target and Lun.\r | |
2384 | @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.\r | |
2385 | @retval EFI_NOT_FOUND A valid translation from DevicePath to a Target ID and LUN\r | |
2386 | does not exist.\r | |
2387 | @retval EFI_UNSUPPORTED This driver does not support the device path node type in\r | |
2388 | DevicePath.\r | |
2389 | \r | |
2390 | **/\r | |
2391 | EFI_STATUS\r | |
2392 | EFIAPI\r | |
2393 | ExtScsiPassThruGetTargetLun (\r | |
2394 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
2395 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
2396 | OUT UINT8 **Target,\r | |
2397 | OUT UINT64 *Lun\r | |
2398 | )\r | |
2399 | {\r | |
2400 | EFI_DEV_PATH *DevicePathNode;\r | |
2401 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
2402 | LIST_ENTRY *Node;\r | |
2403 | \r | |
2404 | Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
2405 | \r | |
2406 | //\r | |
2407 | // Validate parameters passed in.\r | |
2408 | //\r | |
2409 | if (DevicePath == NULL || Target == NULL || Lun == NULL) {\r | |
2410 | return EFI_INVALID_PARAMETER;\r | |
2411 | }\r | |
2412 | \r | |
2413 | if (*Target == NULL) {\r | |
2414 | return EFI_INVALID_PARAMETER;\r | |
2415 | }\r | |
2416 | //\r | |
2417 | // Check whether the DevicePath belongs to SCSI_DEVICE_PATH\r | |
2418 | //\r | |
2419 | if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||\r | |
2420 | ((DevicePath->SubType != MSG_ATAPI_DP) &&\r | |
2421 | (DevicePath->SubType != MSG_SATA_DP)) ||\r | |
2422 | ((DevicePathNodeLength(DevicePath) != sizeof(ATAPI_DEVICE_PATH)) &&\r | |
2423 | (DevicePathNodeLength(DevicePath) != sizeof(SATA_DEVICE_PATH)))) {\r | |
2424 | return EFI_UNSUPPORTED;\r | |
2425 | }\r | |
2426 | \r | |
2427 | SetMem (*Target, TARGET_MAX_BYTES, 0xFF);\r | |
2428 | \r | |
2429 | DevicePathNode = (EFI_DEV_PATH *) DevicePath;\r | |
2430 | \r | |
2431 | if (Instance->Mode == EfiAtaIdeMode) {\r | |
2432 | (*Target)[0] = (UINT8) DevicePathNode->Atapi.PrimarySecondary;\r | |
2433 | (*Target)[1] = (UINT8) DevicePathNode->Atapi.SlaveMaster;\r | |
2434 | *Lun = (UINT8) DevicePathNode->Atapi.Lun;\r | |
2435 | } else {\r | |
2436 | (*Target)[0] = (UINT8) DevicePathNode->Sata.HBAPortNumber;\r | |
2437 | (*Target)[1] = (UINT8) DevicePathNode->Sata.PortMultiplierPortNumber;\r | |
2438 | *Lun = (UINT8) DevicePathNode->Sata.Lun;\r | |
2439 | }\r | |
2440 | \r | |
2441 | Node = SearchDeviceInfoList(Instance, (*Target)[0], (*Target)[1], EfiIdeCdrom);\r | |
2442 | \r | |
2443 | if (Node == NULL) {\r | |
2444 | return EFI_NOT_FOUND;\r | |
2445 | }\r | |
2446 | \r | |
2447 | if (*Lun != 0) {\r | |
2448 | return EFI_NOT_FOUND;\r | |
2449 | }\r | |
2450 | \r | |
2451 | return EFI_SUCCESS;\r | |
2452 | }\r | |
2453 | \r | |
2454 | /**\r | |
2455 | Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.\r | |
2456 | \r | |
2457 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
2458 | \r | |
2459 | @retval EFI_SUCCESS The SCSI channel was reset.\r | |
2460 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel.\r | |
2461 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI channel.\r | |
2462 | @retval EFI_UNSUPPORTED The SCSI channel does not support a channel reset operation.\r | |
2463 | \r | |
2464 | **/\r | |
2465 | EFI_STATUS\r | |
2466 | EFIAPI\r | |
2467 | ExtScsiPassThruResetChannel (\r | |
2468 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This\r | |
2469 | )\r | |
2470 | {\r | |
71fd9fae TF |
2471 | //\r |
2472 | // Return success directly then upper layer driver could think reset channel operation is done.\r | |
2473 | //\r | |
2474 | return EFI_SUCCESS;\r | |
490b5ea1 | 2475 | }\r |
2476 | \r | |
a41b5272 | 2477 | /**\r |
2478 | Resets a SCSI logical unit that is connected to a SCSI channel.\r | |
2479 | \r | |
2480 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
2481 | @param Target The Target is an array of size TARGET_MAX_BYTE and it represents the\r | |
2482 | target port ID of the SCSI device containing the SCSI logical unit to\r | |
2483 | reset. Transport drivers may chose to utilize a subset of this array to suit\r | |
2484 | the representation of their targets.\r | |
2485 | @param Lun The LUN of the SCSI device to reset.\r | |
2486 | \r | |
2487 | @retval EFI_SUCCESS The SCSI device specified by Target and Lun was reset.\r | |
2488 | @retval EFI_INVALID_PARAMETER Target or Lun is NULL.\r | |
2489 | @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI device\r | |
2490 | specified by Target and Lun.\r | |
2491 | @retval EFI_UNSUPPORTED The SCSI channel does not support a target reset operation.\r | |
2492 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI device\r | |
2493 | specified by Target and Lun.\r | |
2494 | \r | |
2495 | **/\r | |
2496 | EFI_STATUS\r | |
2497 | EFIAPI\r | |
2498 | ExtScsiPassThruResetTargetLun (\r | |
2499 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
2500 | IN UINT8 *Target,\r | |
2501 | IN UINT64 Lun\r | |
2502 | )\r | |
2503 | {\r | |
59b1b9d2 TF |
2504 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r |
2505 | LIST_ENTRY *Node;\r | |
2506 | UINT8 Port;\r | |
2507 | UINT8 PortMultiplier;\r | |
2508 | \r | |
2509 | Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
2510 | //\r | |
2511 | // For ATAPI device, doesn't support multiple LUN device.\r | |
2512 | //\r | |
2513 | if (Lun != 0) {\r | |
2514 | return EFI_INVALID_PARAMETER;\r | |
2515 | }\r | |
2516 | //\r | |
2517 | // The layout of Target array:\r | |
2518 | // ________________________________________________________________________\r | |
2519 | // | Byte 0 | Byte 1 | ... | TARGET_MAX_BYTES - 1 |\r | |
2520 | // |_____________________|_____________________|_____|______________________|\r | |
2521 | // | | The port multiplier | | |\r | |
2522 | // | The port number | port number | N/A | N/A |\r | |
2523 | // |_____________________|_____________________|_____|______________________|\r | |
2524 | //\r | |
2525 | // For ATAPI device, 2 bytes is enough to represent the location of SCSI device.\r | |
2526 | //\r | |
2527 | Port = Target[0];\r | |
2528 | PortMultiplier = Target[1];\r | |
2529 | \r | |
2530 | Node = SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom);\r | |
2531 | if (Node == NULL) {\r | |
2532 | return EFI_INVALID_PARAMETER;\r | |
2533 | }\r | |
2534 | \r | |
71fd9fae TF |
2535 | //\r |
2536 | // Return success directly then upper layer driver could think reset target LUN operation is done.\r | |
2537 | //\r | |
2538 | return EFI_SUCCESS;\r | |
490b5ea1 | 2539 | }\r |
a41b5272 | 2540 | \r |
2541 | /**\r | |
58727f29 | 2542 | Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either\r |
a41b5272 | 2543 | be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs\r |
58727f29 | 2544 | for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to\r |
2545 | see if a SCSI device is actually present at that location on the SCSI channel.\r | |
a41b5272 | 2546 | \r |
2547 | @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r | |
2548 | @param Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r | |
2549 | On output, a pointer to the Target ID (an array of\r | |
2550 | TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r | |
2551 | channel. An input value of 0xF(all bytes in the array are 0xF) in the\r | |
2552 | Target array retrieves the Target ID of the first SCSI device present on a\r | |
2553 | SCSI channel.\r | |
2554 | \r | |
2555 | @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI\r | |
2556 | channel was returned in Target.\r | |
2557 | @retval EFI_INVALID_PARAMETER Target or Lun is NULL.\r | |
2558 | @retval EFI_TIMEOUT Target array is not all 0xF, and Target was not\r | |
2559 | returned on a previous call to GetNextTarget().\r | |
2560 | @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.\r | |
2561 | \r | |
2562 | **/\r | |
2563 | EFI_STATUS\r | |
2564 | EFIAPI\r | |
2565 | ExtScsiPassThruGetNextTarget (\r | |
2566 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,\r | |
2567 | IN OUT UINT8 **Target\r | |
2568 | )\r | |
2569 | {\r | |
2570 | ATA_ATAPI_PASS_THRU_INSTANCE *Instance;\r | |
2571 | LIST_ENTRY *Node;\r | |
2572 | EFI_ATA_DEVICE_INFO *DeviceInfo;\r | |
2573 | UINT8 *Target8;\r | |
2574 | UINT16 *Target16;\r | |
2575 | \r | |
2576 | Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);\r | |
2577 | \r | |
2578 | if (Target == NULL || *Target == NULL) {\r | |
2579 | return EFI_INVALID_PARAMETER;\r | |
2580 | }\r | |
2581 | \r | |
2582 | Target8 = *Target;\r | |
2583 | Target16 = (UINT16 *)*Target;\r | |
2584 | \r | |
2585 | if (CompareMem(Target8, mScsiId, TARGET_MAX_BYTES) != 0) {\r | |
2586 | //\r | |
2587 | // For ATAPI device, we use 2 least significant bytes to represent the location of SCSI device.\r | |
2588 | // So the higher bytes in Target array should be 0xFF.\r | |
2589 | //\r | |
2590 | if (CompareMem (&Target8[2], &mScsiId[2], TARGET_MAX_BYTES - 2) != 0) {\r | |
2591 | return EFI_INVALID_PARAMETER;\r | |
2592 | }\r | |
2593 | \r | |
2594 | //\r | |
2595 | // When Target is not all 0xFF's, compare 2 least significant bytes with\r | |
2596 | // previous target id to see if it is returned by previous call.\r | |
2597 | //\r | |
2598 | if (*Target16 != Instance->PreviousTargetId) {\r | |
2599 | return EFI_INVALID_PARAMETER;\r | |
2600 | }\r | |
2601 | \r | |
2602 | //\r | |
2603 | // Traverse the whole device list to find the next cdrom closed to\r | |
2604 | // the device signified by Target[0] and Target[1].\r | |
2605 | //\r | |
2606 | // Note that we here use a tricky way to find the next cdrom :\r | |
2607 | // All ata devices are detected and inserted into the device list\r | |
2608 | // sequentially.\r | |
2609 | //\r | |
2610 | Node = GetFirstNode (&Instance->DeviceList);\r | |
2611 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
2612 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
2613 | \r | |
2614 | if ((DeviceInfo->Type == EfiIdeCdrom) &&\r | |
58727f29 | 2615 | ((Target8[0] < DeviceInfo->Port) ||\r |
d8982b03 | 2616 | ((Target8[0] == DeviceInfo->Port) &&\r |
23a596db | 2617 | (Target8[1] < (UINT8)DeviceInfo->PortMultiplier)))) {\r |
a41b5272 | 2618 | Target8[0] = (UINT8)DeviceInfo->Port;\r |
2619 | Target8[1] = (UINT8)DeviceInfo->PortMultiplier;\r | |
2620 | goto Exit;\r | |
2621 | }\r | |
2622 | \r | |
2623 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
2624 | }\r | |
2625 | \r | |
2626 | return EFI_NOT_FOUND;\r | |
2627 | } else {\r | |
2628 | //\r | |
2629 | // If the array is all 0xFF's, start to traverse the device list from the beginning\r | |
2630 | //\r | |
2631 | Node = GetFirstNode (&Instance->DeviceList);\r | |
2632 | \r | |
2633 | while (!IsNull (&Instance->DeviceList, Node)) {\r | |
2634 | DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);\r | |
2635 | \r | |
2636 | if (DeviceInfo->Type == EfiIdeCdrom) {\r | |
2637 | Target8[0] = (UINT8)DeviceInfo->Port;\r | |
2638 | Target8[1] = (UINT8)DeviceInfo->PortMultiplier;\r | |
2639 | goto Exit;\r | |
2640 | }\r | |
2641 | \r | |
2642 | Node = GetNextNode (&Instance->DeviceList, Node);\r | |
2643 | }\r | |
2644 | \r | |
2645 | return EFI_NOT_FOUND;\r | |
2646 | }\r | |
2647 | \r | |
2648 | Exit:\r | |
2649 | //\r | |
2650 | // Update the PreviousTargetId.\r | |
2651 | //\r | |
2652 | Instance->PreviousTargetId = *Target16;\r | |
2653 | \r | |
2654 | return EFI_SUCCESS;\r | |
490b5ea1 | 2655 | }\r |
a41b5272 | 2656 | \r |