]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaBusDxe / AtaBus.c
... / ...
CommitLineData
1/** @file\r
2 This file implements protocol interfaces for ATA bus driver.\r
3\r
4 This file implements protocol interfaces: Driver Binding protocol,\r
5 Block IO protocol and DiskInfo protocol.\r
6\r
7 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
9\r
10\r
11**/\r
12\r
13#include "AtaBus.h"\r
14\r
15//\r
16// ATA Bus Driver Binding Protocol Instance\r
17//\r
18EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding = {\r
19 AtaBusDriverBindingSupported,\r
20 AtaBusDriverBindingStart,\r
21 AtaBusDriverBindingStop,\r
22 0x10,\r
23 NULL,\r
24 NULL\r
25};\r
26\r
27//\r
28// Template for ATA Child Device.\r
29//\r
30ATA_DEVICE gAtaDeviceTemplate = {\r
31 ATA_DEVICE_SIGNATURE, // Signature\r
32 NULL, // Handle\r
33 { // BlockIo\r
34 EFI_BLOCK_IO_PROTOCOL_REVISION,\r
35 NULL,\r
36 AtaBlockIoReset,\r
37 AtaBlockIoReadBlocks,\r
38 AtaBlockIoWriteBlocks,\r
39 AtaBlockIoFlushBlocks\r
40 },\r
41 { // BlockIo2\r
42 NULL,\r
43 AtaBlockIoResetEx,\r
44 AtaBlockIoReadBlocksEx,\r
45 AtaBlockIoWriteBlocksEx,\r
46 AtaBlockIoFlushBlocksEx\r
47 },\r
48 { // BlockMedia\r
49 0, // MediaId\r
50 FALSE, // RemovableMedia\r
51 TRUE, // MediaPresent\r
52 FALSE, // LogicPartition\r
53 FALSE, // ReadOnly\r
54 FALSE, // WritingCache\r
55 0x200, // BlockSize\r
56 0, // IoAlign\r
57 0, // LastBlock\r
58 0, // LowestAlignedLba\r
59 1 // LogicalBlocksPerPhysicalBlock\r
60 },\r
61 { // DiskInfo\r
62 EFI_DISK_INFO_IDE_INTERFACE_GUID,\r
63 AtaDiskInfoInquiry,\r
64 AtaDiskInfoIdentify,\r
65 AtaDiskInfoSenseData,\r
66 AtaDiskInfoWhichIde\r
67 },\r
68 NULL, // DevicePath\r
69 {\r
70 AtaStorageSecurityReceiveData,\r
71 AtaStorageSecuritySendData\r
72 },\r
73 NULL, // AtaBusDriverData\r
74 0, // Port\r
75 0, // PortMultiplierPort\r
76 { 0, }, // Packet\r
77 {{ 0}, }, // Acb\r
78 NULL, // Asb\r
79 FALSE, // UdmaValid\r
80 FALSE, // Lba48Bit\r
81 NULL, // IdentifyData\r
82 NULL, // ControllerNameTable\r
83 {L'\0', }, // ModelName\r
84 {NULL, NULL}, // AtaTaskList\r
85 {NULL, NULL}, // AtaSubTaskList\r
86 FALSE // Abort\r
87};\r
88\r
89/**\r
90 Allocates an aligned buffer for ATA device.\r
91\r
92 This function allocates an aligned buffer for the ATA device to perform\r
93 ATA pass through operations. The alignment requirement is from ATA pass\r
94 through interface.\r
95\r
96 @param AtaDevice The ATA child device involved for the operation.\r
97 @param BufferSize The request buffer size.\r
98\r
99 @return A pointer to the aligned buffer or NULL if the allocation fails.\r
100\r
101**/\r
102VOID *\r
103AllocateAlignedBuffer (\r
104 IN ATA_DEVICE *AtaDevice,\r
105 IN UINTN BufferSize\r
106 )\r
107{\r
108 return AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), AtaDevice->AtaBusDriverData->AtaPassThru->Mode->IoAlign);\r
109}\r
110\r
111/**\r
112 Frees an aligned buffer for ATA device.\r
113\r
114 This function frees an aligned buffer for the ATA device to perform\r
115 ATA pass through operations.\r
116\r
117 @param Buffer The aligned buffer to be freed.\r
118 @param BufferSize The request buffer size.\r
119\r
120**/\r
121VOID\r
122FreeAlignedBuffer (\r
123 IN VOID *Buffer,\r
124 IN UINTN BufferSize\r
125 )\r
126{\r
127 if (Buffer != NULL) {\r
128 FreeAlignedPages (Buffer, EFI_SIZE_TO_PAGES (BufferSize));\r
129 }\r
130}\r
131\r
132\r
133/**\r
134 Release all the resources allocated for the ATA device.\r
135\r
136 This function releases all the resources allocated for the ATA device.\r
137\r
138 @param AtaDevice The ATA child device involved for the operation.\r
139\r
140**/\r
141VOID\r
142ReleaseAtaResources (\r
143 IN ATA_DEVICE *AtaDevice\r
144 )\r
145{\r
146 ATA_BUS_ASYN_SUB_TASK *SubTask;\r
147 ATA_BUS_ASYN_TASK *AtaTask;\r
148 LIST_ENTRY *Entry;\r
149 LIST_ENTRY *DelEntry;\r
150 EFI_TPL OldTpl;\r
151\r
152 FreeUnicodeStringTable (AtaDevice->ControllerNameTable);\r
153 FreeAlignedBuffer (AtaDevice->Asb, sizeof (EFI_ATA_STATUS_BLOCK));\r
154 FreeAlignedBuffer (AtaDevice->IdentifyData, sizeof (ATA_IDENTIFY_DATA));\r
155 if (AtaDevice->DevicePath != NULL) {\r
156 FreePool (AtaDevice->DevicePath);\r
157 }\r
158 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
159 if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {\r
160 //\r
161 // Free the Subtask list.\r
162 //\r
163 for(Entry = AtaDevice->AtaSubTaskList.ForwardLink;\r
164 Entry != (&AtaDevice->AtaSubTaskList);\r
165 ) {\r
166 DelEntry = Entry;\r
167 Entry = Entry->ForwardLink;\r
168 SubTask = ATA_ASYN_SUB_TASK_FROM_ENTRY (DelEntry);\r
169\r
170 RemoveEntryList (DelEntry);\r
171 FreeAtaSubTask (SubTask);\r
172 }\r
173 }\r
174 if (!IsListEmpty (&AtaDevice->AtaTaskList)) {\r
175 //\r
176 // Free the Subtask list.\r
177 //\r
178 for(Entry = AtaDevice->AtaTaskList.ForwardLink;\r
179 Entry != (&AtaDevice->AtaTaskList);\r
180 ) {\r
181 DelEntry = Entry;\r
182 Entry = Entry->ForwardLink;\r
183 AtaTask = ATA_ASYN_TASK_FROM_ENTRY (DelEntry);\r
184\r
185 RemoveEntryList (DelEntry);\r
186 FreePool (AtaTask);\r
187 }\r
188 }\r
189 gBS->RestoreTPL (OldTpl);\r
190 FreePool (AtaDevice);\r
191}\r
192\r
193\r
194/**\r
195 Registers an ATA device.\r
196\r
197 This function allocates an ATA device structure for the ATA device specified by\r
198 Port and PortMultiplierPort if the ATA device is identified as a valid one.\r
199 Then it will create child handle and install Block IO and Disk Info protocol on\r
200 it.\r
201\r
202 @param AtaBusDriverData The parent ATA bus driver data structure.\r
203 @param Port The port number of the ATA device.\r
204 @param PortMultiplierPort The port multiplier port number of the ATA device.\r
205\r
206 @retval EFI_SUCCESS The ATA device is successfully registered.\r
207 @retval EFI_OUT_OF_RESOURCES There is not enough memory to allocate the ATA device\r
208 and related data structures.\r
209 @return Others Some error occurs when registering the ATA device.\r
210**/\r
211EFI_STATUS\r
212RegisterAtaDevice (\r
213 IN OUT ATA_BUS_DRIVER_DATA *AtaBusDriverData,\r
214 IN UINT16 Port,\r
215 IN UINT16 PortMultiplierPort\r
216 )\r
217{\r
218 EFI_STATUS Status;\r
219 ATA_DEVICE *AtaDevice;\r
220 EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
221 EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;\r
222 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
223 EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;\r
224 EFI_HANDLE DeviceHandle;\r
225\r
226 AtaDevice = NULL;\r
227 NewDevicePathNode = NULL;\r
228 DevicePath = NULL;\r
229 RemainingDevicePath = NULL;\r
230\r
231 //\r
232 // Build device path\r
233 //\r
234 AtaPassThru = AtaBusDriverData->AtaPassThru;\r
235 Status = AtaPassThru->BuildDevicePath (AtaPassThru, Port, PortMultiplierPort, &NewDevicePathNode);\r
236 if (EFI_ERROR (Status)) {\r
237 goto Done;\r
238 }\r
239\r
240 DevicePath = AppendDevicePathNode (AtaBusDriverData->ParentDevicePath, NewDevicePathNode);\r
241 if (DevicePath == NULL) {\r
242 Status = EFI_OUT_OF_RESOURCES;\r
243 goto Done;\r
244 }\r
245\r
246 DeviceHandle = NULL;\r
247 RemainingDevicePath = DevicePath;\r
248 Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);\r
249 if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd(RemainingDevicePath)) {\r
250 Status = EFI_ALREADY_STARTED;\r
251 FreePool (DevicePath);\r
252 goto Done;\r
253 }\r
254\r
255 //\r
256 // Allocate ATA device from the template.\r
257 //\r
258 AtaDevice = AllocateCopyPool (sizeof (ATA_DEVICE), &gAtaDeviceTemplate);\r
259 if (AtaDevice == NULL) {\r
260 Status = EFI_OUT_OF_RESOURCES;\r
261 goto Done;\r
262 }\r
263\r
264 //\r
265 // Initializes ATA device structures and allocates the required buffer.\r
266 //\r
267 AtaDevice->BlockIo.Media = &AtaDevice->BlockMedia;\r
268 AtaDevice->BlockIo2.Media = &AtaDevice->BlockMedia;\r
269 AtaDevice->AtaBusDriverData = AtaBusDriverData;\r
270 AtaDevice->DevicePath = DevicePath;\r
271 AtaDevice->Port = Port;\r
272 AtaDevice->PortMultiplierPort = PortMultiplierPort;\r
273 AtaDevice->Asb = AllocateAlignedBuffer (AtaDevice, sizeof (EFI_ATA_STATUS_BLOCK));\r
274 if (AtaDevice->Asb == NULL) {\r
275 Status = EFI_OUT_OF_RESOURCES;\r
276 goto Done;\r
277 }\r
278 AtaDevice->IdentifyData = AllocateAlignedBuffer (AtaDevice, sizeof (ATA_IDENTIFY_DATA));\r
279 if (AtaDevice->IdentifyData == NULL) {\r
280 Status = EFI_OUT_OF_RESOURCES;\r
281 goto Done;\r
282 }\r
283\r
284 //\r
285 // Initial Ata Task List\r
286 //\r
287 InitializeListHead (&AtaDevice->AtaTaskList);\r
288 InitializeListHead (&AtaDevice->AtaSubTaskList);\r
289\r
290 //\r
291 // Report Status Code to indicate the ATA device will be enabled\r
292 //\r
293 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
294 EFI_PROGRESS_CODE,\r
295 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_ENABLE),\r
296 AtaBusDriverData->ParentDevicePath\r
297 );\r
298\r
299 //\r
300 // Try to identify the ATA device via the ATA pass through command.\r
301 //\r
302 Status = DiscoverAtaDevice (AtaDevice);\r
303 if (EFI_ERROR (Status)) {\r
304 goto Done;\r
305 }\r
306\r
307 //\r
308 // Build controller name for Component Name (2) protocol.\r
309 //\r
310 Status = AddUnicodeString2 (\r
311 "eng",\r
312 gAtaBusComponentName.SupportedLanguages,\r
313 &AtaDevice->ControllerNameTable,\r
314 AtaDevice->ModelName,\r
315 TRUE\r
316 );\r
317 if (EFI_ERROR (Status)) {\r
318 goto Done;\r
319 }\r
320\r
321 Status = AddUnicodeString2 (\r
322 "en",\r
323 gAtaBusComponentName2.SupportedLanguages,\r
324 &AtaDevice->ControllerNameTable,\r
325 AtaDevice->ModelName,\r
326 FALSE\r
327 );\r
328 if (EFI_ERROR (Status)) {\r
329 goto Done;\r
330 }\r
331\r
332 //\r
333 // Update to AHCI interface GUID based on device path node. The default one\r
334 // is IDE interface GUID copied from template.\r
335 //\r
336 if (NewDevicePathNode->SubType == MSG_SATA_DP) {\r
337 CopyGuid (&AtaDevice->DiskInfo.Interface, &gEfiDiskInfoAhciInterfaceGuid);\r
338 }\r
339\r
340 Status = gBS->InstallMultipleProtocolInterfaces (\r
341 &AtaDevice->Handle,\r
342 &gEfiDevicePathProtocolGuid,\r
343 AtaDevice->DevicePath,\r
344 &gEfiBlockIoProtocolGuid,\r
345 &AtaDevice->BlockIo,\r
346 &gEfiBlockIo2ProtocolGuid,\r
347 &AtaDevice->BlockIo2,\r
348 &gEfiDiskInfoProtocolGuid,\r
349 &AtaDevice->DiskInfo,\r
350 NULL\r
351 );\r
352 if (EFI_ERROR (Status)) {\r
353 goto Done;\r
354 }\r
355\r
356 //\r
357 // See if the ata device support trust computing feature or not.\r
358 // If yes, then install Storage Security Protocol at the ata device handle.\r
359 //\r
360 if ((AtaDevice->IdentifyData->trusted_computing_support & BIT0) != 0) {\r
361 DEBUG ((EFI_D_INFO, "Found TCG support in Port %x PortMultiplierPort %x\n", Port, PortMultiplierPort));\r
362 Status = gBS->InstallProtocolInterface (\r
363 &AtaDevice->Handle,\r
364 &gEfiStorageSecurityCommandProtocolGuid,\r
365 EFI_NATIVE_INTERFACE,\r
366 &AtaDevice->StorageSecurity\r
367 );\r
368 if (EFI_ERROR (Status)) {\r
369 goto Done;\r
370 }\r
371 DEBUG ((EFI_D_INFO, "Successfully Install Storage Security Protocol on the ATA device\n"));\r
372 }\r
373\r
374 gBS->OpenProtocol (\r
375 AtaBusDriverData->Controller,\r
376 &gEfiAtaPassThruProtocolGuid,\r
377 (VOID **) &AtaPassThru,\r
378 AtaBusDriverData->DriverBindingHandle,\r
379 AtaDevice->Handle,\r
380 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
381 );\r
382\r
383Done:\r
384 if (NewDevicePathNode != NULL) {\r
385 FreePool (NewDevicePathNode);\r
386 }\r
387\r
388 if (EFI_ERROR (Status) && (AtaDevice != NULL)) {\r
389 ReleaseAtaResources (AtaDevice);\r
390 DEBUG ((EFI_D_ERROR | EFI_D_INIT, "Failed to initialize Port %x PortMultiplierPort %x, status = %r\n", Port, PortMultiplierPort, Status));\r
391 }\r
392 return Status;\r
393}\r
394\r
395\r
396/**\r
397 Unregisters an ATA device.\r
398\r
399 This function removes the protocols installed on the controller handle and\r
400 frees the resources allocated for the ATA device.\r
401\r
402 @param This The pointer to EFI_DRIVER_BINDING_PROTOCOL instance.\r
403 @param Controller The controller handle of the ATA device.\r
404 @param Handle The child handle.\r
405\r
406 @retval EFI_SUCCESS The ATA device is successfully unregistered.\r
407 @return Others Some error occurs when unregistering the ATA device.\r
408\r
409**/\r
410EFI_STATUS\r
411UnregisterAtaDevice (\r
412 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
413 IN EFI_HANDLE Controller,\r
414 IN EFI_HANDLE Handle\r
415 )\r
416{\r
417 EFI_STATUS Status;\r
418 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
419 EFI_BLOCK_IO2_PROTOCOL *BlockIo2;\r
420 ATA_DEVICE *AtaDevice;\r
421 EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
422 EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *StorageSecurity;\r
423\r
424 BlockIo2 = NULL;\r
425 BlockIo = NULL;\r
426\r
427 Status = gBS->OpenProtocol (\r
428 Handle,\r
429 &gEfiBlockIoProtocolGuid,\r
430 (VOID **) &BlockIo,\r
431 This->DriverBindingHandle,\r
432 Controller,\r
433 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
434 );\r
435 if (EFI_ERROR (Status)) {\r
436 //\r
437 // Locate BlockIo2 protocol\r
438 //\r
439 Status = gBS->OpenProtocol (\r
440 Handle,\r
441 &gEfiBlockIo2ProtocolGuid,\r
442 (VOID **) &BlockIo2,\r
443 This->DriverBindingHandle,\r
444 Controller,\r
445 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
446 );\r
447 if (EFI_ERROR (Status)) {\r
448 return Status;\r
449 }\r
450 }\r
451\r
452 //\r
453 // Get AtaDevice data.\r
454 //\r
455 if (BlockIo != NULL) {\r
456 AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);\r
457 } else {\r
458 ASSERT (BlockIo2 != NULL);\r
459 AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (BlockIo2);\r
460 }\r
461\r
462 //\r
463 // Close the child handle\r
464 //\r
465 gBS->CloseProtocol (\r
466 Controller,\r
467 &gEfiAtaPassThruProtocolGuid,\r
468 This->DriverBindingHandle,\r
469 Handle\r
470 );\r
471\r
472 //\r
473 // The Ata Bus driver installs the BlockIo and BlockIo2 in the DriverBindingStart().\r
474 // Here should uninstall both of them.\r
475 //\r
476 Status = gBS->UninstallMultipleProtocolInterfaces (\r
477 Handle,\r
478 &gEfiDevicePathProtocolGuid,\r
479 AtaDevice->DevicePath,\r
480 &gEfiBlockIoProtocolGuid,\r
481 &AtaDevice->BlockIo,\r
482 &gEfiBlockIo2ProtocolGuid,\r
483 &AtaDevice->BlockIo2,\r
484 &gEfiDiskInfoProtocolGuid,\r
485 &AtaDevice->DiskInfo,\r
486 NULL\r
487 );\r
488\r
489 if (EFI_ERROR (Status)) {\r
490 gBS->OpenProtocol (\r
491 Controller,\r
492 &gEfiAtaPassThruProtocolGuid,\r
493 (VOID **) &AtaPassThru,\r
494 This->DriverBindingHandle,\r
495 Handle,\r
496 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
497 );\r
498 return Status;\r
499 }\r
500\r
501 //\r
502 // If Storage Security Command Protocol is installed, then uninstall this protocol.\r
503 //\r
504 Status = gBS->OpenProtocol (\r
505 Handle,\r
506 &gEfiStorageSecurityCommandProtocolGuid,\r
507 (VOID **) &StorageSecurity,\r
508 This->DriverBindingHandle,\r
509 Controller,\r
510 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
511 );\r
512\r
513 if (!EFI_ERROR (Status)) {\r
514 Status = gBS->UninstallProtocolInterface (\r
515 Handle,\r
516 &gEfiStorageSecurityCommandProtocolGuid,\r
517 &AtaDevice->StorageSecurity\r
518 );\r
519 if (EFI_ERROR (Status)) {\r
520 gBS->OpenProtocol (\r
521 Controller,\r
522 &gEfiAtaPassThruProtocolGuid,\r
523 (VOID **) &AtaPassThru,\r
524 This->DriverBindingHandle,\r
525 Handle,\r
526 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
527 );\r
528 return Status;\r
529 }\r
530 }\r
531\r
532 ReleaseAtaResources (AtaDevice);\r
533 return EFI_SUCCESS;\r
534}\r
535\r
536\r
537\r
538/**\r
539 Tests to see if this driver supports a given controller. If a child device is provided,\r
540 it further tests to see if this driver supports creating a handle for the specified child device.\r
541\r
542 This function checks to see if the driver specified by This supports the device specified by\r
543 ControllerHandle. Drivers will typically use the device path attached to\r
544 ControllerHandle and/or the services from the bus I/O abstraction attached to\r
545 ControllerHandle to determine if the driver supports ControllerHandle. This function\r
546 may be called many times during platform initialization. In order to reduce boot times, the tests\r
547 performed by this function must be very small, and take as little time as possible to execute. This\r
548 function must not change the state of any hardware devices, and this function must be aware that the\r
549 device specified by ControllerHandle may already be managed by the same driver or a\r
550 different driver. This function must match its calls to AllocatePages() with FreePages(),\r
551 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r
552 Since ControllerHandle may have been previously started by the same driver, if a protocol is\r
553 already in the opened state, then it must not be closed with CloseProtocol(). This is required\r
554 to guarantee the state of ControllerHandle is not modified by this function.\r
555\r
556 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
557 @param[in] ControllerHandle The handle of the controller to test. This handle\r
558 must support a protocol interface that supplies\r
559 an I/O abstraction to the driver.\r
560 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
561 parameter is ignored by device drivers, and is optional for bus\r
562 drivers. For bus drivers, if this parameter is not NULL, then\r
563 the bus driver must determine if the bus controller specified\r
564 by ControllerHandle and the child controller specified\r
565 by RemainingDevicePath are both supported by this\r
566 bus driver.\r
567\r
568 @retval EFI_SUCCESS The device specified by ControllerHandle and\r
569 RemainingDevicePath is supported by the driver specified by This.\r
570 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
571 RemainingDevicePath is already being managed by the driver\r
572 specified by This.\r
573 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
574 RemainingDevicePath is already being managed by a different\r
575 driver or an application that requires exclusive access.\r
576 Currently not implemented.\r
577 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
578 RemainingDevicePath is not supported by the driver specified by This.\r
579**/\r
580EFI_STATUS\r
581EFIAPI\r
582AtaBusDriverBindingSupported (\r
583 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
584 IN EFI_HANDLE Controller,\r
585 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
586 )\r
587{\r
588 EFI_STATUS Status;\r
589 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
590 EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
591 UINT16 Port;\r
592 UINT16 PortMultiplierPort;\r
593\r
594 //\r
595 // Test EFI_ATA_PASS_THRU_PROTOCOL on controller handle.\r
596 //\r
597 Status = gBS->OpenProtocol (\r
598 Controller,\r
599 &gEfiAtaPassThruProtocolGuid,\r
600 (VOID **) &AtaPassThru,\r
601 This->DriverBindingHandle,\r
602 Controller,\r
603 EFI_OPEN_PROTOCOL_BY_DRIVER\r
604 );\r
605\r
606 if (Status == EFI_ALREADY_STARTED) {\r
607 return EFI_SUCCESS;\r
608 }\r
609\r
610 if (EFI_ERROR (Status)) {\r
611 return Status;\r
612 }\r
613\r
614 //\r
615 // Test to see if this ATA Pass Thru Protocol is for a LOGICAL channel\r
616 //\r
617 if ((AtaPassThru->Mode->Attributes & EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL) == 0) {\r
618 //\r
619 // Close the I/O Abstraction(s) used to perform the supported test\r
620 //\r
621 gBS->CloseProtocol (\r
622 Controller,\r
623 &gEfiAtaPassThruProtocolGuid,\r
624 This->DriverBindingHandle,\r
625 Controller\r
626 );\r
627 return EFI_UNSUPPORTED;\r
628 }\r
629\r
630 //\r
631 // Test RemainingDevicePath is valid or not.\r
632 //\r
633 if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {\r
634 Status = AtaPassThru->GetDevice (AtaPassThru, RemainingDevicePath, &Port, &PortMultiplierPort);\r
635 if (EFI_ERROR (Status)) {\r
636 //\r
637 // Close the I/O Abstraction(s) used to perform the supported test\r
638 //\r
639 gBS->CloseProtocol (\r
640 Controller,\r
641 &gEfiAtaPassThruProtocolGuid,\r
642 This->DriverBindingHandle,\r
643 Controller\r
644 );\r
645 return Status;\r
646 }\r
647 }\r
648\r
649 //\r
650 // Close the I/O Abstraction(s) used to perform the supported test\r
651 //\r
652 gBS->CloseProtocol (\r
653 Controller,\r
654 &gEfiAtaPassThruProtocolGuid,\r
655 This->DriverBindingHandle,\r
656 Controller\r
657 );\r
658\r
659 //\r
660 // Open the EFI Device Path protocol needed to perform the supported test\r
661 //\r
662 Status = gBS->OpenProtocol (\r
663 Controller,\r
664 &gEfiDevicePathProtocolGuid,\r
665 (VOID **) &ParentDevicePath,\r
666 This->DriverBindingHandle,\r
667 Controller,\r
668 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
669 );\r
670 return Status;\r
671}\r
672\r
673\r
674/**\r
675 Starts a device controller or a bus controller.\r
676\r
677 The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
678 As a result, much of the error checking on the parameters to Start() has been moved into this\r
679 common boot service. It is legal to call Start() from other locations,\r
680 but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
681 1. ControllerHandle must be a valid EFI_HANDLE.\r
682 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
683 EFI_DEVICE_PATH_PROTOCOL.\r
684 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
685 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
686\r
687 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
688 @param[in] ControllerHandle The handle of the controller to start. This handle\r
689 must support a protocol interface that supplies\r
690 an I/O abstraction to the driver.\r
691 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
692 parameter is ignored by device drivers, and is optional for bus\r
693 drivers. For a bus driver, if this parameter is NULL, then handles\r
694 for all the children of Controller are created by this driver.\r
695 If this parameter is not NULL and the first Device Path Node is\r
696 not the End of Device Path Node, then only the handle for the\r
697 child device specified by the first Device Path Node of\r
698 RemainingDevicePath is created by this driver.\r
699 If the first Device Path Node of RemainingDevicePath is\r
700 the End of Device Path Node, no child handle is created by this\r
701 driver.\r
702\r
703 @retval EFI_SUCCESS The device was started.\r
704 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r
705 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
706 @retval Others The driver failded to start the device.\r
707\r
708**/\r
709EFI_STATUS\r
710EFIAPI\r
711AtaBusDriverBindingStart (\r
712 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
713 IN EFI_HANDLE Controller,\r
714 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
715 )\r
716{\r
717 EFI_STATUS Status;\r
718 EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;\r
719 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
720 ATA_BUS_DRIVER_DATA *AtaBusDriverData;\r
721 UINT16 Port;\r
722 UINT16 PortMultiplierPort;\r
723\r
724 AtaBusDriverData = NULL;\r
725\r
726 Status = gBS->OpenProtocol (\r
727 Controller,\r
728 &gEfiDevicePathProtocolGuid,\r
729 (VOID **) &ParentDevicePath,\r
730 This->DriverBindingHandle,\r
731 Controller,\r
732 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
733 );\r
734 if (EFI_ERROR (Status)) {\r
735 return Status;\r
736 }\r
737\r
738 //\r
739 // Report Status Code to indicate ATA bus starts\r
740 //\r
741 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
742 EFI_PROGRESS_CODE,\r
743 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_INIT),\r
744 ParentDevicePath\r
745 );\r
746\r
747 Status = gBS->OpenProtocol (\r
748 Controller,\r
749 &gEfiAtaPassThruProtocolGuid,\r
750 (VOID **) &AtaPassThru,\r
751 This->DriverBindingHandle,\r
752 Controller,\r
753 EFI_OPEN_PROTOCOL_BY_DRIVER\r
754 );\r
755 if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {\r
756 goto ErrorExit;\r
757 }\r
758\r
759 //\r
760 // Check EFI_ALREADY_STARTED to reuse the original ATA_BUS_DRIVER_DATA.\r
761 //\r
762 if (Status != EFI_ALREADY_STARTED) {\r
763 AtaBusDriverData = AllocateZeroPool (sizeof (ATA_BUS_DRIVER_DATA));\r
764 if (AtaBusDriverData == NULL) {\r
765 Status = EFI_OUT_OF_RESOURCES;\r
766 goto ErrorExit;\r
767 }\r
768\r
769 AtaBusDriverData->AtaPassThru = AtaPassThru;\r
770 AtaBusDriverData->Controller = Controller;\r
771 AtaBusDriverData->ParentDevicePath = ParentDevicePath;\r
772 AtaBusDriverData->DriverBindingHandle = This->DriverBindingHandle;\r
773\r
774 Status = gBS->InstallMultipleProtocolInterfaces (\r
775 &Controller,\r
776 &gEfiCallerIdGuid,\r
777 AtaBusDriverData,\r
778 NULL\r
779 );\r
780 if (EFI_ERROR (Status)) {\r
781 goto ErrorExit;\r
782 }\r
783\r
784 } else {\r
785 Status = gBS->OpenProtocol (\r
786 Controller,\r
787 &gEfiCallerIdGuid,\r
788 (VOID **) &AtaBusDriverData,\r
789 This->DriverBindingHandle,\r
790 Controller,\r
791 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
792 );\r
793 if (EFI_ERROR (Status)) {\r
794 AtaBusDriverData = NULL;\r
795 goto ErrorExit;\r
796 }\r
797 }\r
798\r
799 //\r
800 // Report Status Code to indicate detecting devices on bus\r
801 //\r
802 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
803 EFI_PROGRESS_CODE,\r
804 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_DETECT),\r
805 ParentDevicePath\r
806 );\r
807\r
808 if (RemainingDevicePath == NULL) {\r
809 Port = 0xFFFF;\r
810 while (TRUE) {\r
811 Status = AtaPassThru->GetNextPort (AtaPassThru, &Port);\r
812 if (EFI_ERROR (Status)) {\r
813 //\r
814 // We cannot find more legal port then we are done.\r
815 //\r
816 break;\r
817 }\r
818\r
819 PortMultiplierPort = 0xFFFF;\r
820 while (TRUE) {\r
821 Status = AtaPassThru->GetNextDevice (AtaPassThru, Port, &PortMultiplierPort);\r
822 if (EFI_ERROR (Status)) {\r
823 //\r
824 // We cannot find more legal port multiplier port number for ATA device\r
825 // on the port, then we are done.\r
826 //\r
827 break;\r
828 }\r
829 RegisterAtaDevice (AtaBusDriverData, Port, PortMultiplierPort);\r
830 }\r
831 }\r
832 Status = EFI_SUCCESS;\r
833 } else if (!IsDevicePathEnd (RemainingDevicePath)) {\r
834 Status = AtaPassThru->GetDevice (AtaPassThru, RemainingDevicePath, &Port, &PortMultiplierPort);\r
835 if (!EFI_ERROR (Status)) {\r
836 Status = RegisterAtaDevice (AtaBusDriverData,Port, PortMultiplierPort);\r
837 }\r
838 }\r
839\r
840 return Status;\r
841\r
842ErrorExit:\r
843\r
844 if (AtaBusDriverData != NULL) {\r
845 gBS->UninstallMultipleProtocolInterfaces (\r
846 Controller,\r
847 &gEfiCallerIdGuid,\r
848 AtaBusDriverData,\r
849 NULL\r
850 );\r
851 FreePool (AtaBusDriverData);\r
852 }\r
853\r
854 gBS->CloseProtocol (\r
855 Controller,\r
856 &gEfiAtaPassThruProtocolGuid,\r
857 This->DriverBindingHandle,\r
858 Controller\r
859 );\r
860\r
861 return Status;\r
862\r
863}\r
864\r
865\r
866/**\r
867 Stops a device controller or a bus controller.\r
868\r
869 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
870 As a result, much of the error checking on the parameters to Stop() has been moved\r
871 into this common boot service. It is legal to call Stop() from other locations,\r
872 but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
873 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
874 same driver's Start() function.\r
875 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
876 EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
877 Start() function, and the Start() function must have called OpenProtocol() on\r
878 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
879\r
880 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
881 @param[in] ControllerHandle A handle to the device being stopped. The handle must\r
882 support a bus specific I/O protocol for the driver\r
883 to use to stop the device.\r
884 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
885 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r
886 if NumberOfChildren is 0.\r
887\r
888 @retval EFI_SUCCESS The device was stopped.\r
889 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
890\r
891**/\r
892EFI_STATUS\r
893EFIAPI\r
894AtaBusDriverBindingStop (\r
895 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
896 IN EFI_HANDLE Controller,\r
897 IN UINTN NumberOfChildren,\r
898 IN EFI_HANDLE *ChildHandleBuffer\r
899 )\r
900{\r
901 EFI_STATUS Status;\r
902 BOOLEAN AllChildrenStopped;\r
903 UINTN Index;\r
904 ATA_BUS_DRIVER_DATA *AtaBusDriverData;\r
905\r
906 if (NumberOfChildren == 0) {\r
907 Status = gBS->OpenProtocol (\r
908 Controller,\r
909 &gEfiCallerIdGuid,\r
910 (VOID **) &AtaBusDriverData,\r
911 This->DriverBindingHandle,\r
912 Controller,\r
913 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
914 );\r
915 if (!EFI_ERROR (Status)) {\r
916 gBS->UninstallMultipleProtocolInterfaces (\r
917 Controller,\r
918 &gEfiCallerIdGuid,\r
919 AtaBusDriverData,\r
920 NULL\r
921 );\r
922 FreePool (AtaBusDriverData);\r
923 }\r
924\r
925 gBS->CloseProtocol (\r
926 Controller,\r
927 &gEfiAtaPassThruProtocolGuid,\r
928 This->DriverBindingHandle,\r
929 Controller\r
930 );\r
931\r
932 return EFI_SUCCESS;\r
933 }\r
934\r
935 AllChildrenStopped = TRUE;\r
936\r
937 for (Index = 0; Index < NumberOfChildren; Index++) {\r
938\r
939 Status = UnregisterAtaDevice (This, Controller, ChildHandleBuffer[Index]);\r
940 if (EFI_ERROR (Status)) {\r
941 AllChildrenStopped = FALSE;\r
942 }\r
943 }\r
944\r
945 if (!AllChildrenStopped) {\r
946 return EFI_DEVICE_ERROR;\r
947 }\r
948\r
949 return EFI_SUCCESS;\r
950}\r
951\r
952\r
953/**\r
954 Reset the Block Device.\r
955\r
956 @param This Indicates a pointer to the calling context.\r
957 @param ExtendedVerification Driver may perform diagnostics on reset.\r
958\r
959 @retval EFI_SUCCESS The device was reset.\r
960 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
961 not be reset.\r
962\r
963**/\r
964EFI_STATUS\r
965EFIAPI\r
966AtaBlockIoReset (\r
967 IN EFI_BLOCK_IO_PROTOCOL *This,\r
968 IN BOOLEAN ExtendedVerification\r
969 )\r
970{\r
971 EFI_STATUS Status;\r
972 ATA_DEVICE *AtaDevice;\r
973 EFI_TPL OldTpl;\r
974\r
975 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
976\r
977 AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (This);\r
978\r
979 Status = ResetAtaDevice (AtaDevice);\r
980\r
981 if (EFI_ERROR (Status)) {\r
982 Status = EFI_DEVICE_ERROR;\r
983 }\r
984\r
985 gBS->RestoreTPL (OldTpl);\r
986 return Status;\r
987}\r
988\r
989\r
990/**\r
991 Read/Write BufferSize bytes from Lba from/into Buffer.\r
992\r
993 @param[in] This Indicates a pointer to the calling context. Either be\r
994 block I/O or block I/O2.\r
995 @param[in] MediaId The media ID that the read/write request is for.\r
996 @param[in] Lba The starting logical block address to be read/written.\r
997 The caller is responsible for reading/writing to only\r
998 legitimate locations.\r
999 @param[in, out] Token A pointer to the token associated with the transaction.\r
1000 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
1001 @param[out] Buffer A pointer to the destination/source buffer for the data.\r
1002 @param[in] IsBlockIo2 Indicate the calling is from BlockIO or BlockIO2. TRUE is\r
1003 from BlockIO2, FALSE is for BlockIO.\r
1004 @param[in] IsWrite Indicates whether it is a write operation.\r
1005\r
1006 @retval EFI_SUCCESS The data was read/written correctly to the device.\r
1007 @retval EFI_WRITE_PROTECTED The device can not be read/written to.\r
1008 @retval EFI_DEVICE_ERROR The device reported an error while performing the read/write.\r
1009 @retval EFI_NO_MEDIA There is no media in the device.\r
1010 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
1011 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
1012 @retval EFI_INVALID_PARAMETER The read/write request contains LBAs that are not valid,\r
1013 or the buffer is not on proper alignment.\r
1014\r
1015**/\r
1016EFI_STATUS\r
1017BlockIoReadWrite (\r
1018 IN VOID *This,\r
1019 IN UINT32 MediaId,\r
1020 IN EFI_LBA Lba,\r
1021 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
1022 IN UINTN BufferSize,\r
1023 OUT VOID *Buffer,\r
1024 IN BOOLEAN IsBlockIo2,\r
1025 IN BOOLEAN IsWrite\r
1026 )\r
1027{\r
1028 ATA_DEVICE *AtaDevice;\r
1029 EFI_STATUS Status;\r
1030 EFI_TPL OldTpl;\r
1031 EFI_BLOCK_IO_MEDIA *Media;\r
1032 UINTN BlockSize;\r
1033 UINTN NumberOfBlocks;\r
1034 UINTN IoAlign;\r
1035\r
1036 if (IsBlockIo2) {\r
1037 Media = ((EFI_BLOCK_IO2_PROTOCOL *) This)->Media;\r
1038 AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);\r
1039 } else {\r
1040 Media = ((EFI_BLOCK_IO_PROTOCOL *) This)->Media;\r
1041 AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (This);\r
1042 }\r
1043\r
1044 if (MediaId != Media->MediaId) {\r
1045 return EFI_MEDIA_CHANGED;\r
1046 }\r
1047\r
1048 //\r
1049 // Check parameters.\r
1050 //\r
1051 if (Buffer == NULL) {\r
1052 return EFI_INVALID_PARAMETER;\r
1053 }\r
1054\r
1055 if (BufferSize == 0) {\r
1056 if ((Token != NULL) && (Token->Event != NULL)) {\r
1057 Token->TransactionStatus = EFI_SUCCESS;\r
1058 gBS->SignalEvent (Token->Event);\r
1059 }\r
1060 return EFI_SUCCESS;\r
1061 }\r
1062\r
1063 BlockSize = Media->BlockSize;\r
1064 if ((BufferSize % BlockSize) != 0) {\r
1065 return EFI_BAD_BUFFER_SIZE;\r
1066 }\r
1067\r
1068 NumberOfBlocks = BufferSize / BlockSize;\r
1069 if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {\r
1070 return EFI_INVALID_PARAMETER;\r
1071 }\r
1072\r
1073 IoAlign = Media->IoAlign;\r
1074 if (IoAlign > 0 && (((UINTN) Buffer & (IoAlign - 1)) != 0)) {\r
1075 return EFI_INVALID_PARAMETER;\r
1076 }\r
1077\r
1078 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
1079\r
1080 //\r
1081 // Invoke low level AtaDevice Access Routine.\r
1082 //\r
1083 Status = AccessAtaDevice (AtaDevice, Buffer, Lba, NumberOfBlocks, IsWrite, Token);\r
1084\r
1085 gBS->RestoreTPL (OldTpl);\r
1086\r
1087 return Status;\r
1088}\r
1089\r
1090\r
1091/**\r
1092 Read BufferSize bytes from Lba into Buffer.\r
1093\r
1094 @param This Indicates a pointer to the calling context.\r
1095 @param MediaId Id of the media, changes every time the media is replaced.\r
1096 @param Lba The starting Logical Block Address to read from\r
1097 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
1098 @param Buffer A pointer to the destination buffer for the data. The caller is\r
1099 responsible for either having implicit or explicit ownership of the buffer.\r
1100\r
1101 @retval EFI_SUCCESS The data was read correctly from the device.\r
1102 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
1103 @retval EFI_NO_MEDIA There is no media in the device.\r
1104 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
1105 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
1106 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
1107 or the buffer is not on proper alignment.\r
1108\r
1109**/\r
1110EFI_STATUS\r
1111EFIAPI\r
1112AtaBlockIoReadBlocks (\r
1113 IN EFI_BLOCK_IO_PROTOCOL *This,\r
1114 IN UINT32 MediaId,\r
1115 IN EFI_LBA Lba,\r
1116 IN UINTN BufferSize,\r
1117 OUT VOID *Buffer\r
1118 )\r
1119{\r
1120 return BlockIoReadWrite ((VOID *) This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, FALSE);\r
1121}\r
1122\r
1123\r
1124/**\r
1125 Write BufferSize bytes from Lba into Buffer.\r
1126\r
1127 @param This Indicates a pointer to the calling context.\r
1128 @param MediaId The media ID that the write request is for.\r
1129 @param Lba The starting logical block address to be written. The caller is\r
1130 responsible for writing to only legitimate locations.\r
1131 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
1132 @param Buffer A pointer to the source buffer for the data.\r
1133\r
1134 @retval EFI_SUCCESS The data was written correctly to the device.\r
1135 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
1136 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
1137 @retval EFI_NO_MEDIA There is no media in the device.\r
1138 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
1139 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
1140 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
1141 or the buffer is not on proper alignment.\r
1142\r
1143**/\r
1144EFI_STATUS\r
1145EFIAPI\r
1146AtaBlockIoWriteBlocks (\r
1147 IN EFI_BLOCK_IO_PROTOCOL *This,\r
1148 IN UINT32 MediaId,\r
1149 IN EFI_LBA Lba,\r
1150 IN UINTN BufferSize,\r
1151 IN VOID *Buffer\r
1152 )\r
1153{\r
1154 return BlockIoReadWrite ((VOID *) This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, TRUE);\r
1155}\r
1156\r
1157\r
1158/**\r
1159 Flush the Block Device.\r
1160\r
1161 @param This Indicates a pointer to the calling context.\r
1162\r
1163 @retval EFI_SUCCESS All outstanding data was written to the device\r
1164 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data\r
1165 @retval EFI_NO_MEDIA There is no media in the device.\r
1166\r
1167**/\r
1168EFI_STATUS\r
1169EFIAPI\r
1170AtaBlockIoFlushBlocks (\r
1171 IN EFI_BLOCK_IO_PROTOCOL *This\r
1172 )\r
1173{\r
1174 //\r
1175 // return directly\r
1176 //\r
1177 return EFI_SUCCESS;\r
1178}\r
1179\r
1180/**\r
1181 Reset the Block Device.\r
1182\r
1183 @param[in] This Indicates a pointer to the calling context.\r
1184 @param[in] ExtendedVerification Driver may perform diagnostics on reset.\r
1185\r
1186 @retval EFI_SUCCESS The device was reset.\r
1187 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
1188 not be reset.\r
1189\r
1190**/\r
1191EFI_STATUS\r
1192EFIAPI\r
1193AtaBlockIoResetEx (\r
1194 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
1195 IN BOOLEAN ExtendedVerification\r
1196 )\r
1197{\r
1198 EFI_STATUS Status;\r
1199 ATA_DEVICE *AtaDevice;\r
1200 EFI_TPL OldTpl;\r
1201\r
1202 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
1203\r
1204 AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);\r
1205\r
1206 AtaTerminateNonBlockingTask (AtaDevice);\r
1207\r
1208 Status = ResetAtaDevice (AtaDevice);\r
1209\r
1210 if (EFI_ERROR (Status)) {\r
1211 Status = EFI_DEVICE_ERROR;\r
1212 }\r
1213\r
1214 gBS->RestoreTPL (OldTpl);\r
1215 return Status;\r
1216}\r
1217\r
1218/**\r
1219 Read BufferSize bytes from Lba into Buffer.\r
1220\r
1221 @param[in] This Indicates a pointer to the calling context.\r
1222 @param[in] MediaId Id of the media, changes every time the media is replaced.\r
1223 @param[in] Lba The starting Logical Block Address to read from.\r
1224 @param[in, out] Token A pointer to the token associated with the transaction.\r
1225 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
1226 @param[out] Buffer A pointer to the destination buffer for the data. The caller is\r
1227 responsible for either having implicit or explicit ownership of the buffer.\r
1228\r
1229 @retval EFI_SUCCESS The read request was queued if Event is not NULL.\r
1230 The data was read correctly from the device if\r
1231 the Event is NULL.\r
1232 @retval EFI_DEVICE_ERROR The device reported an error while performing\r
1233 the read.\r
1234 @retval EFI_NO_MEDIA There is no media in the device.\r
1235 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
1236 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
1237 intrinsic block size of the device.\r
1238 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
1239 or the buffer is not on proper alignment.\r
1240 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
1241 of resources.\r
1242\r
1243**/\r
1244EFI_STATUS\r
1245EFIAPI\r
1246AtaBlockIoReadBlocksEx (\r
1247 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
1248 IN UINT32 MediaId,\r
1249 IN EFI_LBA Lba,\r
1250 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
1251 IN UINTN BufferSize,\r
1252 OUT VOID *Buffer\r
1253 )\r
1254{\r
1255 return BlockIoReadWrite ((VOID *) This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, FALSE);\r
1256}\r
1257\r
1258\r
1259/**\r
1260 Write BufferSize bytes from Lba into Buffer.\r
1261\r
1262 @param[in] This Indicates a pointer to the calling context.\r
1263 @param[in] MediaId The media ID that the write request is for.\r
1264 @param[in] Lba The starting logical block address to be written. The\r
1265 caller is responsible for writing to only legitimate\r
1266 locations.\r
1267 @param[in, out] Token A pointer to the token associated with the transaction.\r
1268 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
1269 @param[in] Buffer A pointer to the source buffer for the data.\r
1270\r
1271 @retval EFI_SUCCESS The data was written correctly to the device.\r
1272 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
1273 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
1274 @retval EFI_NO_MEDIA There is no media in the device.\r
1275 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
1276 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
1277 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
1278 or the buffer is not on proper alignment.\r
1279\r
1280**/\r
1281EFI_STATUS\r
1282EFIAPI\r
1283AtaBlockIoWriteBlocksEx (\r
1284 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
1285 IN UINT32 MediaId,\r
1286 IN EFI_LBA Lba,\r
1287 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
1288 IN UINTN BufferSize,\r
1289 IN VOID *Buffer\r
1290 )\r
1291{\r
1292 return BlockIoReadWrite ((VOID *) This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, TRUE);\r
1293}\r
1294\r
1295\r
1296/**\r
1297 Flush the Block Device.\r
1298\r
1299 @param[in] This Indicates a pointer to the calling context.\r
1300 @param[in, out] Token A pointer to the token associated with the transaction.\r
1301\r
1302 @retval EFI_SUCCESS All outstanding data was written to the device\r
1303 @retval EFI_DEVICE_ERROR The device reported an error while writing back the data\r
1304 @retval EFI_NO_MEDIA There is no media in the device.\r
1305\r
1306**/\r
1307EFI_STATUS\r
1308EFIAPI\r
1309AtaBlockIoFlushBlocksEx (\r
1310 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
1311 IN OUT EFI_BLOCK_IO2_TOKEN *Token\r
1312 )\r
1313{\r
1314 //\r
1315 // Signal event and return directly.\r
1316 //\r
1317 if (Token != NULL && Token->Event != NULL) {\r
1318 Token->TransactionStatus = EFI_SUCCESS;\r
1319 gBS->SignalEvent (Token->Event);\r
1320 }\r
1321 return EFI_SUCCESS;\r
1322}\r
1323/**\r
1324 Provides inquiry information for the controller type.\r
1325\r
1326 This function is used by the IDE bus driver to get inquiry data. Data format\r
1327 of Identify data is defined by the Interface GUID.\r
1328\r
1329 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
1330 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.\r
1331 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.\r
1332\r
1333 @retval EFI_SUCCESS The command was accepted without any errors.\r
1334 @retval EFI_NOT_FOUND Device does not support this data class\r
1335 @retval EFI_DEVICE_ERROR Error reading InquiryData from device\r
1336 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough\r
1337\r
1338**/\r
1339EFI_STATUS\r
1340EFIAPI\r
1341AtaDiskInfoInquiry (\r
1342 IN EFI_DISK_INFO_PROTOCOL *This,\r
1343 IN OUT VOID *InquiryData,\r
1344 IN OUT UINT32 *InquiryDataSize\r
1345 )\r
1346{\r
1347 return EFI_NOT_FOUND;\r
1348}\r
1349\r
1350\r
1351/**\r
1352 Provides identify information for the controller type.\r
1353\r
1354 This function is used by the IDE bus driver to get identify data. Data format\r
1355 of Identify data is defined by the Interface GUID.\r
1356\r
1357 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL\r
1358 instance.\r
1359 @param[in, out] IdentifyData Pointer to a buffer for the identify data.\r
1360 @param[in, out] IdentifyDataSize Pointer to the value for the identify data\r
1361 size.\r
1362\r
1363 @retval EFI_SUCCESS The command was accepted without any errors.\r
1364 @retval EFI_NOT_FOUND Device does not support this data class\r
1365 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device\r
1366 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough\r
1367\r
1368**/\r
1369EFI_STATUS\r
1370EFIAPI\r
1371AtaDiskInfoIdentify (\r
1372 IN EFI_DISK_INFO_PROTOCOL *This,\r
1373 IN OUT VOID *IdentifyData,\r
1374 IN OUT UINT32 *IdentifyDataSize\r
1375 )\r
1376{\r
1377 EFI_STATUS Status;\r
1378 ATA_DEVICE *AtaDevice;\r
1379\r
1380 AtaDevice = ATA_DEVICE_FROM_DISK_INFO (This);\r
1381\r
1382 Status = EFI_BUFFER_TOO_SMALL;\r
1383 if (*IdentifyDataSize >= sizeof (ATA_IDENTIFY_DATA)) {\r
1384 Status = EFI_SUCCESS;\r
1385 CopyMem (IdentifyData, AtaDevice->IdentifyData, sizeof (ATA_IDENTIFY_DATA));\r
1386 }\r
1387 *IdentifyDataSize = sizeof (ATA_IDENTIFY_DATA);\r
1388\r
1389 return Status;\r
1390}\r
1391\r
1392\r
1393/**\r
1394 Provides sense data information for the controller type.\r
1395\r
1396 This function is used by the IDE bus driver to get sense data.\r
1397 Data format of Sense data is defined by the Interface GUID.\r
1398\r
1399 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
1400 @param[in, out] SenseData Pointer to the SenseData.\r
1401 @param[in, out] SenseDataSize Size of SenseData in bytes.\r
1402 @param[out] SenseDataNumber Pointer to the value for the sense data size.\r
1403\r
1404 @retval EFI_SUCCESS The command was accepted without any errors.\r
1405 @retval EFI_NOT_FOUND Device does not support this data class.\r
1406 @retval EFI_DEVICE_ERROR Error reading SenseData from device.\r
1407 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.\r
1408\r
1409**/\r
1410EFI_STATUS\r
1411EFIAPI\r
1412AtaDiskInfoSenseData (\r
1413 IN EFI_DISK_INFO_PROTOCOL *This,\r
1414 IN OUT VOID *SenseData,\r
1415 IN OUT UINT32 *SenseDataSize,\r
1416 OUT UINT8 *SenseDataNumber\r
1417 )\r
1418{\r
1419 return EFI_NOT_FOUND;\r
1420}\r
1421\r
1422\r
1423/**\r
1424 This function is used by the IDE bus driver to get controller information.\r
1425\r
1426 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
1427 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.\r
1428 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.\r
1429\r
1430 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.\r
1431 @retval EFI_UNSUPPORTED This is not an IDE device.\r
1432\r
1433**/\r
1434EFI_STATUS\r
1435EFIAPI\r
1436AtaDiskInfoWhichIde (\r
1437 IN EFI_DISK_INFO_PROTOCOL *This,\r
1438 OUT UINT32 *IdeChannel,\r
1439 OUT UINT32 *IdeDevice\r
1440 )\r
1441{\r
1442 ATA_DEVICE *AtaDevice;\r
1443\r
1444 AtaDevice = ATA_DEVICE_FROM_DISK_INFO (This);\r
1445 *IdeChannel = AtaDevice->Port;\r
1446 *IdeDevice = AtaDevice->PortMultiplierPort;\r
1447\r
1448 return EFI_SUCCESS;\r
1449}\r
1450\r
1451/**\r
1452 Send a security protocol command to a device that receives data and/or the result\r
1453 of one or more commands sent by SendData.\r
1454\r
1455 The ReceiveData function sends a security protocol command to the given MediaId.\r
1456 The security protocol command sent is defined by SecurityProtocolId and contains\r
1457 the security protocol specific data SecurityProtocolSpecificData. The function\r
1458 returns the data from the security protocol command in PayloadBuffer.\r
1459\r
1460 For devices supporting the SCSI command set, the security protocol command is sent\r
1461 using the SECURITY PROTOCOL IN command defined in SPC-4.\r
1462\r
1463 For devices supporting the ATA command set, the security protocol command is sent\r
1464 using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize\r
1465 is non-zero.\r
1466\r
1467 If the PayloadBufferSize is zero, the security protocol command is sent using the\r
1468 Trusted Non-Data command defined in ATA8-ACS.\r
1469\r
1470 If PayloadBufferSize is too small to store the available data from the security\r
1471 protocol command, the function shall copy PayloadBufferSize bytes into the\r
1472 PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.\r
1473\r
1474 If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,\r
1475 the function shall return EFI_INVALID_PARAMETER.\r
1476\r
1477 If the given MediaId does not support security protocol commands, the function shall\r
1478 return EFI_UNSUPPORTED. If there is no media in the device, the function returns\r
1479 EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,\r
1480 the function returns EFI_MEDIA_CHANGED.\r
1481\r
1482 If the security protocol fails to complete within the Timeout period, the function\r
1483 shall return EFI_TIMEOUT.\r
1484\r
1485 If the security protocol command completes without an error, the function shall\r
1486 return EFI_SUCCESS. If the security protocol command completes with an error, the\r
1487 function shall return EFI_DEVICE_ERROR.\r
1488\r
1489 @param This Indicates a pointer to the calling context.\r
1490 @param MediaId ID of the medium to receive data from.\r
1491 @param Timeout The timeout, in 100ns units, to use for the execution\r
1492 of the security protocol command. A Timeout value of 0\r
1493 means that this function will wait indefinitely for the\r
1494 security protocol command to execute. If Timeout is greater\r
1495 than zero, then this function will return EFI_TIMEOUT\r
1496 if the time required to execute the receive data command\r
1497 is greater than Timeout.\r
1498 @param SecurityProtocolId The value of the "Security Protocol" parameter of\r
1499 the security protocol command to be sent.\r
1500 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
1501 of the security protocol command to be sent.\r
1502 @param PayloadBufferSize Size in bytes of the payload data buffer.\r
1503 @param PayloadBuffer A pointer to a destination buffer to store the security\r
1504 protocol command specific payload data for the security\r
1505 protocol command. The caller is responsible for having\r
1506 either implicit or explicit ownership of the buffer.\r
1507 @param PayloadTransferSize A pointer to a buffer to store the size in bytes of the\r
1508 data written to the payload data buffer.\r
1509\r
1510 @retval EFI_SUCCESS The security protocol command completed successfully.\r
1511 @retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available\r
1512 data from the device. The PayloadBuffer contains the truncated data.\r
1513 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.\r
1514 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.\r
1515 @retval EFI_NO_MEDIA There is no media in the device.\r
1516 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
1517 @retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and\r
1518 PayloadBufferSize is non-zero.\r
1519 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
1520 protocol command to execute.\r
1521\r
1522**/\r
1523EFI_STATUS\r
1524EFIAPI\r
1525AtaStorageSecurityReceiveData (\r
1526 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
1527 IN UINT32 MediaId,\r
1528 IN UINT64 Timeout,\r
1529 IN UINT8 SecurityProtocolId,\r
1530 IN UINT16 SecurityProtocolSpecificData,\r
1531 IN UINTN PayloadBufferSize,\r
1532 OUT VOID *PayloadBuffer,\r
1533 OUT UINTN *PayloadTransferSize\r
1534 )\r
1535{\r
1536 EFI_STATUS Status;\r
1537 ATA_DEVICE *Private;\r
1538 EFI_TPL OldTpl;\r
1539\r
1540 DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Read\n"));\r
1541 if ((PayloadBuffer == NULL || PayloadTransferSize == NULL) && PayloadBufferSize != 0) {\r
1542 return EFI_INVALID_PARAMETER;\r
1543 }\r
1544\r
1545 Status = EFI_SUCCESS;\r
1546 Private = ATA_DEVICE_FROM_STORAGE_SECURITY (This);\r
1547\r
1548 if (MediaId != Private->BlockIo.Media->MediaId) {\r
1549 return EFI_MEDIA_CHANGED;\r
1550 }\r
1551\r
1552 if (!Private->BlockIo.Media->MediaPresent) {\r
1553 return EFI_NO_MEDIA;\r
1554 }\r
1555\r
1556 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
1557\r
1558 Status = TrustTransferAtaDevice (\r
1559 Private,\r
1560 PayloadBuffer,\r
1561 SecurityProtocolId,\r
1562 SecurityProtocolSpecificData,\r
1563 PayloadBufferSize,\r
1564 FALSE,\r
1565 Timeout,\r
1566 PayloadTransferSize\r
1567 );\r
1568\r
1569 gBS->RestoreTPL (OldTpl);\r
1570 return Status;\r
1571}\r
1572\r
1573/**\r
1574 Send a security protocol command to a device.\r
1575\r
1576 The SendData function sends a security protocol command containing the payload\r
1577 PayloadBuffer to the given MediaId. The security protocol command sent is\r
1578 defined by SecurityProtocolId and contains the security protocol specific data\r
1579 SecurityProtocolSpecificData. If the underlying protocol command requires a\r
1580 specific padding for the command payload, the SendData function shall add padding\r
1581 bytes to the command payload to satisfy the padding requirements.\r
1582\r
1583 For devices supporting the SCSI command set, the security protocol command is sent\r
1584 using the SECURITY PROTOCOL OUT command defined in SPC-4.\r
1585\r
1586 For devices supporting the ATA command set, the security protocol command is sent\r
1587 using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize\r
1588 is non-zero. If the PayloadBufferSize is zero, the security protocol command is\r
1589 sent using the Trusted Non-Data command defined in ATA8-ACS.\r
1590\r
1591 If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall\r
1592 return EFI_INVALID_PARAMETER.\r
1593\r
1594 If the given MediaId does not support security protocol commands, the function\r
1595 shall return EFI_UNSUPPORTED. If there is no media in the device, the function\r
1596 returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the\r
1597 device, the function returns EFI_MEDIA_CHANGED.\r
1598\r
1599 If the security protocol fails to complete within the Timeout period, the function\r
1600 shall return EFI_TIMEOUT.\r
1601\r
1602 If the security protocol command completes without an error, the function shall return\r
1603 EFI_SUCCESS. If the security protocol command completes with an error, the function\r
1604 shall return EFI_DEVICE_ERROR.\r
1605\r
1606 @param This Indicates a pointer to the calling context.\r
1607 @param MediaId ID of the medium to receive data from.\r
1608 @param Timeout The timeout, in 100ns units, to use for the execution\r
1609 of the security protocol command. A Timeout value of 0\r
1610 means that this function will wait indefinitely for the\r
1611 security protocol command to execute. If Timeout is greater\r
1612 than zero, then this function will return EFI_TIMEOUT\r
1613 if the time required to execute the receive data command\r
1614 is greater than Timeout.\r
1615 @param SecurityProtocolId The value of the "Security Protocol" parameter of\r
1616 the security protocol command to be sent.\r
1617 @param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
1618 of the security protocol command to be sent.\r
1619 @param PayloadBufferSize Size in bytes of the payload data buffer.\r
1620 @param PayloadBuffer A pointer to a destination buffer to store the security\r
1621 protocol command specific payload data for the security\r
1622 protocol command.\r
1623\r
1624 @retval EFI_SUCCESS The security protocol command completed successfully.\r
1625 @retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.\r
1626 @retval EFI_DEVICE_ERROR The security protocol command completed with an error.\r
1627 @retval EFI_NO_MEDIA There is no media in the device.\r
1628 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
1629 @retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero.\r
1630 @retval EFI_TIMEOUT A timeout occurred while waiting for the security\r
1631 protocol command to execute.\r
1632\r
1633**/\r
1634EFI_STATUS\r
1635EFIAPI\r
1636AtaStorageSecuritySendData (\r
1637 IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,\r
1638 IN UINT32 MediaId,\r
1639 IN UINT64 Timeout,\r
1640 IN UINT8 SecurityProtocolId,\r
1641 IN UINT16 SecurityProtocolSpecificData,\r
1642 IN UINTN PayloadBufferSize,\r
1643 IN VOID *PayloadBuffer\r
1644 )\r
1645{\r
1646 EFI_STATUS Status;\r
1647 ATA_DEVICE *Private;\r
1648 EFI_TPL OldTpl;\r
1649\r
1650 DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Send\n"));\r
1651 if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) {\r
1652 return EFI_INVALID_PARAMETER;\r
1653 }\r
1654\r
1655 Status = EFI_SUCCESS;\r
1656 Private = ATA_DEVICE_FROM_STORAGE_SECURITY (This);\r
1657\r
1658 if (MediaId != Private->BlockIo.Media->MediaId) {\r
1659 return EFI_MEDIA_CHANGED;\r
1660 }\r
1661\r
1662 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
1663 Status = TrustTransferAtaDevice (\r
1664 Private,\r
1665 PayloadBuffer,\r
1666 SecurityProtocolId,\r
1667 SecurityProtocolSpecificData,\r
1668 PayloadBufferSize,\r
1669 TRUE,\r
1670 Timeout,\r
1671 NULL\r
1672 );\r
1673\r
1674 gBS->RestoreTPL (OldTpl);\r
1675 return Status;\r
1676}\r
1677\r
1678/**\r
1679 The user Entry Point for module AtaBus. The user code starts with this function.\r
1680\r
1681 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
1682 @param[in] SystemTable A pointer to the EFI System Table.\r
1683\r
1684 @retval EFI_SUCCESS The entry point is executed successfully.\r
1685 @retval other Some error occurs when executing this entry point.\r
1686\r
1687**/\r
1688EFI_STATUS\r
1689EFIAPI\r
1690InitializeAtaBus(\r
1691 IN EFI_HANDLE ImageHandle,\r
1692 IN EFI_SYSTEM_TABLE *SystemTable\r
1693 )\r
1694{\r
1695 EFI_STATUS Status;\r
1696\r
1697 //\r
1698 // Install driver model protocol(s).\r
1699 //\r
1700 Status = EfiLibInstallDriverBindingComponentName2 (\r
1701 ImageHandle,\r
1702 SystemTable,\r
1703 &gAtaBusDriverBinding,\r
1704 ImageHandle,\r
1705 &gAtaBusComponentName,\r
1706 &gAtaBusComponentName2\r
1707 );\r
1708 ASSERT_EFI_ERROR (Status);\r
1709\r
1710 return Status;\r
1711}\r
1712\r