Some library instance's PCD is missing in FPD file for a module, it break single...
[mirror_edk2.git] / EdkModulePkg / Bus / Pci / IdeBus / Dxe / idebus.c
1 /** @file
2 Copyright (c) 2006, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
7
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11 @par Revision Reference:
12 This module is modified from DXE\IDE module for Ide Contriller Init support
13
14 **/
15
16 #include "idebus.h"
17
18 #define PCI_CLASS_MASS_STORAGE 0x01
19 #define PCI_SUB_CLASS_IDE 0x01
20
21
22 //
23 // IDE Bus Driver Binding Protocol Instance
24 //
25 EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding = {
26 IDEBusDriverBindingSupported,
27 IDEBusDriverBindingStart,
28 IDEBusDriverBindingStop,
29 0x10,
30 NULL,
31 NULL
32 };
33
34 //
35 // ***********************************************************************************
36 // IDEBusDriverBindingSupported
37 // ***********************************************************************************
38 //
39 /**
40 Register Driver Binding protocol for this driver.
41
42 @param[in] This -- A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
43 @param[in] ControllerHandle -- The handle of the controller to test.
44 @param[in] RemainingDevicePath -- A pointer to the remaining portion of a device path.
45
46 @retval EFI_SUCCESS Driver loaded.
47 @retval other Driver not loaded.
48
49 **/
50 EFI_STATUS
51 EFIAPI
52 IDEBusDriverBindingSupported (
53 IN EFI_DRIVER_BINDING_PROTOCOL *This,
54 IN EFI_HANDLE Controller,
55 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
56 )
57 // TODO: Controller - add argument and description to function comment
58 // TODO: EFI_UNSUPPORTED - add return value to function comment
59 {
60 EFI_STATUS Status;
61 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
62 EFI_DEV_PATH *Node;
63 EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit;
64
65 if (RemainingDevicePath != NULL) {
66 Node = (EFI_DEV_PATH *) RemainingDevicePath;
67 if (Node->DevPath.Type != MESSAGING_DEVICE_PATH ||
68 Node->DevPath.SubType != MSG_ATAPI_DP ||
69 DevicePathNodeLength(&Node->DevPath) != sizeof(ATAPI_DEVICE_PATH)) {
70 return EFI_UNSUPPORTED;
71 }
72 }
73
74 //
75 // Open the IO Abstraction(s) needed to perform the supported test
76 //
77 Status = gBS->OpenProtocol (
78 Controller,
79 &gEfiDevicePathProtocolGuid,
80 (VOID **) &ParentDevicePath,
81 This->DriverBindingHandle,
82 Controller,
83 EFI_OPEN_PROTOCOL_BY_DRIVER
84 );
85 if (Status == EFI_ALREADY_STARTED) {
86 return EFI_SUCCESS;
87 }
88
89 if (EFI_ERROR (Status)) {
90 return Status;
91 }
92
93 //
94 // Clsoe protocol, don't use device path protocol in the .Support() function
95 //
96 gBS->CloseProtocol (
97 Controller,
98 &gEfiDevicePathProtocolGuid,
99 This->DriverBindingHandle,
100 Controller
101 );
102
103 //
104 // Verify the Ide Controller Init Protocol, which installed by the
105 // IdeController module.
106 // Note 1: PciIo protocol has been opened BY_DRIVER by ide_init, so We can't
107 // open BY_DRIVER here) That's why we don't check pciio protocol
108 // Note 2: ide_init driver check ide controller's pci config space, so we dont
109 // check here any more to save code size
110 //
111 Status = gBS->OpenProtocol (
112 Controller,
113 &gEfiIdeControllerInitProtocolGuid,
114 (VOID **) &IdeInit,
115 This->DriverBindingHandle,
116 Controller,
117 EFI_OPEN_PROTOCOL_BY_DRIVER
118 );
119
120 if (Status == EFI_ALREADY_STARTED) {
121 return EFI_SUCCESS;
122 }
123
124 //
125 // If protocols were opened normally, closed it
126 //
127 gBS->CloseProtocol (
128 Controller,
129 &gEfiIdeControllerInitProtocolGuid,
130 This->DriverBindingHandle,
131 Controller
132 );
133
134 return Status;
135 }
136
137 //
138 // ***********************************************************************************
139 // IDEBusDriverBindingStart
140 // ***********************************************************************************
141 //
142 /**
143 Start this driver on Controller by detecting all disks and installing
144 BlockIo protocol on them.
145
146 @param This Protocol instance pointer.
147 @param Controller Handle of device to bind driver to.
148 @param RemainingDevicePath Not used, always produce all possible children.
149
150 @retval EFI_SUCCESS This driver is added to ControllerHandle.
151 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
152 @retval other This driver does not support this device.
153
154 **/
155 EFI_STATUS
156 EFIAPI
157 IDEBusDriverBindingStart (
158 IN EFI_DRIVER_BINDING_PROTOCOL *This,
159 IN EFI_HANDLE Controller,
160 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
161 )
162 {
163 EFI_STATUS Status;
164 EFI_STATUS SavedStatus;
165 EFI_PCI_IO_PROTOCOL *PciIo;
166 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
167 EFI_DEV_PATH *Node;
168 UINT8 IdeChannel;
169 UINT8 BeginningIdeChannel;
170 UINT8 EndIdeChannel;
171 UINT8 IdeDevice;
172 UINT8 BeginningIdeDevice;
173 UINT8 EndIdeDevice;
174 IDE_BLK_IO_DEV *IdeBlkIoDevice[IdeMaxChannel][IdeMaxDevice];
175 IDE_BLK_IO_DEV *IdeBlkIoDevicePtr;
176 IDE_REGISTERS_BASE_ADDR IdeRegsBaseAddr[IdeMaxChannel];
177 ATA_TRANSFER_MODE TransferMode;
178 ATA_DRIVE_PARMS DriveParameters;
179 EFI_DEV_PATH NewNode;
180 UINT8 ConfigurationOptions;
181 UINT16 CommandBlockBaseAddr;
182 UINT16 ControlBlockBaseAddr;
183 UINTN DataSize;
184 UINT32 Attributes;
185 IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
186
187 //
188 // Local variables declaration for IdeControllerInit support
189 //
190 EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit;
191 BOOLEAN EnumAll;
192 BOOLEAN ChannelEnabled;
193 UINT8 ChannelCount;
194 UINT8 MaxDevices;
195 EFI_IDENTIFY_DATA IdentifyData;
196 EFI_ATA_COLLECTIVE_MODE *SupportedModes;
197
198 IdeBusDriverPrivateData = NULL;
199 SupportedModes = NULL;
200
201 //
202 // Perform IdeBus initialization
203 //
204 Status = gBS->OpenProtocol (
205 Controller,
206 &gEfiDevicePathProtocolGuid,
207 (VOID **) &ParentDevicePath,
208 This->DriverBindingHandle,
209 Controller,
210 EFI_OPEN_PROTOCOL_BY_DRIVER
211 );
212 if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {
213 return Status;
214 }
215
216 //
217 // Now open the IDE_CONTROLLER_INIT protocol. Step7.1
218 //
219 Status = gBS->OpenProtocol (
220 Controller,
221 &gEfiIdeControllerInitProtocolGuid,
222 (VOID **) &IdeInit,
223 This->DriverBindingHandle,
224 Controller,
225 EFI_OPEN_PROTOCOL_BY_DRIVER
226 );
227
228 //
229 // The following OpenProtocol function with _GET_PROTOCOL attribute and
230 // will not return EFI_ALREADY_STARTED, so save it for now
231 //
232 SavedStatus = Status;
233
234 if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {
235 DEBUG ((EFI_D_ERROR, "Open Init, Status=%x", Status));
236 //
237 // open protocol is not SUCCESS or not ALREADY_STARTED, error exit
238 //
239 goto ErrorExit;
240 }
241
242 //
243 // Save Enumall and ChannelCount. Step7.2
244 //
245 EnumAll = IdeInit->EnumAll;
246 ChannelCount = IdeInit->ChannelCount;
247
248 //
249 // Consume PCI I/O protocol. Note that the OpenProtocol with _GET_PROTOCOL
250 // attribute will not return EFI_ALREADY_STARTED
251 //
252 Status = gBS->OpenProtocol (
253 Controller,
254 &gEfiPciIoProtocolGuid,
255 (VOID **) &PciIo,
256 This->DriverBindingHandle,
257 Controller,
258 EFI_OPEN_PROTOCOL_GET_PROTOCOL
259 );
260 if (EFI_ERROR (Status)) {
261 DEBUG ((EFI_D_ERROR, "Open PciIo, Status=%x", Status));
262 goto ErrorExit;
263 }
264
265 //
266 // We must check EFI_ALREADY_STARTED because many ATAPI devices are removable
267 //
268 if (SavedStatus != EFI_ALREADY_STARTED) {
269 IdeBusDriverPrivateData = AllocatePool (sizeof (IDE_BUS_DRIVER_PRIVATE_DATA));
270 if (IdeBusDriverPrivateData == NULL) {
271 Status = EFI_OUT_OF_RESOURCES;
272 goto ErrorExit;
273 }
274
275 ZeroMem (IdeBusDriverPrivateData, sizeof (IDE_BUS_DRIVER_PRIVATE_DATA));
276 Status = gBS->InstallMultipleProtocolInterfaces (
277 &Controller,
278 &gEfiCallerIdGuid,
279 IdeBusDriverPrivateData,
280 NULL
281 );
282 if (EFI_ERROR (Status)) {
283 goto ErrorExit;
284 }
285
286 } else {
287 Status = gBS->OpenProtocol (
288 Controller,
289 &gEfiCallerIdGuid,
290 (VOID **) &IdeBusDriverPrivateData,
291 This->DriverBindingHandle,
292 Controller,
293 EFI_OPEN_PROTOCOL_GET_PROTOCOL
294 );
295 if (EFI_ERROR (Status)) {
296 IdeBusDriverPrivateData = NULL;
297 goto ErrorExit;
298 }
299 }
300
301 Status = PciIo->Attributes (
302 PciIo,
303 EfiPciIoAttributeOperationEnable,
304 EFI_PCI_DEVICE_ENABLE,
305 NULL
306 );
307 if (EFI_ERROR (Status)) {
308 goto ErrorExit;
309 }
310
311 //
312 // Read the environment variable that contains the IDEBus Driver's
313 // Config options that were set by the Driver Configuration Protocol
314 //
315 DataSize = sizeof (ConfigurationOptions);
316 Status = gRT->GetVariable (
317 (CHAR16 *) L"Configuration",
318 &gEfiCallerIdGuid,
319 &Attributes,
320 &DataSize,
321 &ConfigurationOptions
322 );
323 if (EFI_ERROR (Status)) {
324 ConfigurationOptions = 0x0f;
325 }
326
327 if (EnumAll) {
328 //
329 // If IdeInit->EnumAll is TRUE, must enumerate all IDE device anyway
330 //
331 BeginningIdeChannel = IdePrimary;
332 EndIdeChannel = IdeSecondary;
333 BeginningIdeDevice = IdeMaster;
334 EndIdeDevice = IdeSlave;
335 } else if (RemainingDevicePath == NULL) {
336 //
337 // RemainingDevicePath is NULL, scan IDE bus for each device;
338 //
339 BeginningIdeChannel = IdePrimary;
340 EndIdeChannel = IdeSecondary;
341 BeginningIdeDevice = IdeMaster;
342 //
343 // default, may be redefined by IdeInit
344 //
345 EndIdeDevice = IdeSlave;
346 } else {
347 //
348 // RemainingDevicePath is not NULL, only scan the specified device.
349 //
350 Node = (EFI_DEV_PATH *) RemainingDevicePath;
351 BeginningIdeChannel = Node->Atapi.PrimarySecondary;
352 EndIdeChannel = BeginningIdeChannel;
353 BeginningIdeDevice = Node->Atapi.SlaveMaster;
354 EndIdeDevice = BeginningIdeDevice;
355 }
356
357 //
358 // Obtain IDE IO port registers' base addresses
359 //
360 Status = GetIdeRegistersBaseAddr (PciIo, IdeRegsBaseAddr);
361 if (EFI_ERROR (Status)) {
362 goto ErrorExit;
363 }
364
365 //
366 // Report status code: begin IdeBus initialization
367 //
368 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
369 EFI_PROGRESS_CODE,
370 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_RESET),
371 ParentDevicePath
372 );
373
374 //
375 // Strictly follow the enumeration based on IDE_CONTROLLER_INIT protocol
376 //
377 for (IdeChannel = BeginningIdeChannel; IdeChannel <= EndIdeChannel; IdeChannel++) {
378
379 IdeInit->NotifyPhase (IdeInit, EfiIdeBeforeChannelEnumeration, IdeChannel);
380
381 //
382 // now obtain channel information fron IdeControllerInit protocol. Step9
383 //
384 Status = IdeInit->GetChannelInfo (
385 IdeInit,
386 IdeChannel,
387 &ChannelEnabled,
388 &MaxDevices
389 );
390 if (EFI_ERROR (Status)) {
391 DEBUG ((EFI_D_ERROR, "[GetChannel, Status=%x]", Status));
392 continue;
393 }
394
395 if (!ChannelEnabled) {
396 continue;
397 }
398
399 EndIdeDevice = (UINT8) EFI_MIN ((MaxDevices - 1), EndIdeDevice);
400
401 //
402 // Now inform the IDE Controller Init Module. Sept10
403 //
404 IdeInit->NotifyPhase (IdeInit, EfiIdeBeforeChannelReset, IdeChannel);
405
406 //
407 // No reset channel function implemented. Sept11
408 //
409 IdeInit->NotifyPhase (IdeInit, EfiIdeAfterChannelReset, IdeChannel);
410
411 //
412 // Step13
413 //
414 IdeInit->NotifyPhase (
415 IdeInit,
416 EfiIdeBusBeforeDevicePresenceDetection,
417 IdeChannel
418 );
419 //
420 // -- 1st inner loop --- Master/Slave ------------ Step14
421 //
422 for (IdeDevice = BeginningIdeDevice; IdeDevice <= EndIdeDevice; IdeDevice++) {
423 //
424 // Check whether the configuration options allow this device
425 //
426 if (!(ConfigurationOptions & (1 << (IdeChannel * 2 + IdeDevice)))) {
427 continue;
428 }
429
430 //
431 // The device has been scanned in another Start(), No need to scan it again
432 // for perf optimization.
433 //
434 if (IdeBusDriverPrivateData->HaveScannedDevice[IdeChannel * 2 + IdeDevice]) {
435 continue;
436 }
437
438 //
439 // create child handle for the detected device.
440 //
441 IdeBlkIoDevice[IdeChannel][IdeDevice] = AllocatePool (sizeof (IDE_BLK_IO_DEV));
442 if (IdeBlkIoDevice[IdeChannel][IdeDevice] == NULL) {
443 continue;
444 }
445
446 IdeBlkIoDevicePtr = IdeBlkIoDevice[IdeChannel][IdeDevice];
447
448 ZeroMem (IdeBlkIoDevicePtr, sizeof (IDE_BLK_IO_DEV));
449
450 IdeBlkIoDevicePtr->Signature = IDE_BLK_IO_DEV_SIGNATURE;
451 IdeBlkIoDevicePtr->Channel = IdeChannel;
452 IdeBlkIoDevicePtr->Device = IdeDevice;
453
454 //
455 // initialize Block IO interface's Media pointer
456 //
457 IdeBlkIoDevicePtr->BlkIo.Media = &IdeBlkIoDevicePtr->BlkMedia;
458
459 //
460 // Initialize IDE IO port addresses, including Command Block registers
461 // and Control Block registers
462 //
463 IdeBlkIoDevicePtr->IoPort = AllocatePool (sizeof (IDE_BASE_REGISTERS));
464 if (IdeBlkIoDevicePtr->IoPort == NULL) {
465 continue;
466 }
467
468 ZeroMem (IdeBlkIoDevicePtr->IoPort, sizeof (IDE_BASE_REGISTERS));
469 CommandBlockBaseAddr = IdeRegsBaseAddr[IdeChannel].CommandBlockBaseAddr;
470 ControlBlockBaseAddr = IdeRegsBaseAddr[IdeChannel].ControlBlockBaseAddr;
471
472 IdeBlkIoDevicePtr->IoPort->Data = CommandBlockBaseAddr;
473 (*(UINT16 *) &IdeBlkIoDevicePtr->IoPort->Reg1) = (UINT16) (CommandBlockBaseAddr + 0x01);
474 IdeBlkIoDevicePtr->IoPort->SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);
475 IdeBlkIoDevicePtr->IoPort->SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);
476 IdeBlkIoDevicePtr->IoPort->CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);
477 IdeBlkIoDevicePtr->IoPort->CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);
478 IdeBlkIoDevicePtr->IoPort->Head = (UINT16) (CommandBlockBaseAddr + 0x06);
479 (*(UINT16 *) &IdeBlkIoDevicePtr->IoPort->Reg) = (UINT16) (CommandBlockBaseAddr + 0x07);
480
481 (*(UINT16 *) &IdeBlkIoDevicePtr->IoPort->Alt) = ControlBlockBaseAddr;
482 IdeBlkIoDevicePtr->IoPort->DriveAddress = (UINT16) (ControlBlockBaseAddr + 0x01);
483
484 IdeBlkIoDevicePtr->IoPort->MasterSlave = (UINT16) ((IdeDevice == IdeMaster) ? 1 : 0);
485
486 IdeBlkIoDevicePtr->PciIo = PciIo;
487 IdeBlkIoDevicePtr->IdeBusDriverPrivateData = IdeBusDriverPrivateData;
488 IdeBlkIoDevicePtr->IoPort->BusMasterBaseAddr = IdeRegsBaseAddr[IdeChannel].BusMasterBaseAddr;
489
490 //
491 // Discover device, now!
492 //
493 PERF_START (0, "DiscoverIdeDevice", "IDE", 0);
494 Status = DiscoverIdeDevice (IdeBlkIoDevicePtr);
495 PERF_END (0, "DiscoverIdeDevice", "IDE", 0);
496
497 IdeBusDriverPrivateData->HaveScannedDevice[IdeChannel * 2 + IdeDevice] = TRUE;
498 IdeBusDriverPrivateData->DeviceProcessed[IdeChannel * 2 + IdeDevice] = FALSE;
499
500 if (!EFI_ERROR (Status)) {
501 //
502 // Set Device Path
503 //
504 ZeroMem (&NewNode, sizeof (NewNode));
505 NewNode.DevPath.Type = MESSAGING_DEVICE_PATH;
506 NewNode.DevPath.SubType = MSG_ATAPI_DP;
507 SetDevicePathNodeLength (&NewNode.DevPath, sizeof (ATAPI_DEVICE_PATH));
508
509 NewNode.Atapi.PrimarySecondary = (UINT8) IdeBlkIoDevicePtr->Channel;
510 NewNode.Atapi.SlaveMaster = (UINT8) IdeBlkIoDevicePtr->Device;
511 NewNode.Atapi.Lun = IdeBlkIoDevicePtr->Lun;
512 IdeBlkIoDevicePtr->DevicePath = AppendDevicePathNode (
513 ParentDevicePath,
514 &NewNode.DevPath
515 );
516 if (IdeBlkIoDevicePtr->DevicePath == NULL) {
517 ReleaseIdeResources (IdeBlkIoDevicePtr);
518 continue;
519 }
520
521 //
522 // Submit identify data to IDE controller init driver
523 //
524 CopyMem (&IdentifyData, IdeBlkIoDevicePtr->pIdData, sizeof (IdentifyData));
525 // IdentifyData = *IdeBlkIoDevicePtr->pIdData;
526 IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = TRUE;
527 IdeInit->SubmitData (IdeInit, IdeChannel, IdeDevice, &IdentifyData);
528 } else {
529 //
530 // Device detection failed
531 //
532 IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;
533 IdeInit->SubmitData (IdeInit, IdeChannel, IdeDevice, NULL);
534 ReleaseIdeResources (IdeBlkIoDevicePtr);
535 IdeBlkIoDevicePtr = NULL;
536 }
537 //
538 // end of 1st inner loop ---
539 //
540 }
541 //
542 // end of 1st outer loop =========
543 //
544 }
545
546 //
547 // = 2nd outer loop == Primary/Secondary =================
548 //
549 for (IdeChannel = BeginningIdeChannel; IdeChannel <= EndIdeChannel; IdeChannel++) {
550
551 //
552 // -- 2nd inner loop --- Master/Slave --------
553 //
554 for (IdeDevice = BeginningIdeDevice; IdeDevice <= EndIdeDevice; IdeDevice++) {
555
556 if (IdeBusDriverPrivateData->DeviceProcessed[IdeChannel * 2 + IdeDevice]) {
557 continue;
558 }
559
560 if (!IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice]) {
561 continue;
562 }
563
564 Status = IdeInit->CalculateMode (
565 IdeInit,
566 IdeChannel,
567 IdeDevice,
568 &SupportedModes
569 );
570 if (EFI_ERROR (Status)) {
571 DEBUG ((EFI_D_ERROR, "[bStStp20S=%x]", Status));
572 continue;
573 }
574
575 IdeBlkIoDevicePtr = IdeBlkIoDevice[IdeChannel][IdeDevice];
576
577 //
578 // Set best supported PIO mode on this IDE device
579 //
580 if (SupportedModes->PioMode.Mode <= ATA_PIO_MODE_2) {
581 TransferMode.ModeCategory = ATA_MODE_CATEGORY_DEFAULT_PIO;
582 } else {
583 TransferMode.ModeCategory = ATA_MODE_CATEGORY_FLOW_PIO;
584 }
585
586 TransferMode.ModeNumber = (UINT8) (SupportedModes->PioMode.Mode);
587
588 if (SupportedModes->ExtModeCount == 0){
589 Status = SetDeviceTransferMode (IdeBlkIoDevicePtr, &TransferMode);
590
591 if (EFI_ERROR (Status)) {
592 IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;
593 ReleaseIdeResources (IdeBlkIoDevicePtr);
594 IdeBlkIoDevicePtr = NULL;
595 continue;
596 }
597 }
598
599 //
600 // Set supported DMA mode on this IDE device. Note that UDMA & MDMA cann't
601 // be set together. Only one DMA mode can be set to a device. If setting
602 // DMA mode operation fails, we can continue moving on because we only use
603 // PIO mode at boot time. DMA modes are used by certain kind of OS booting
604 //
605 if (SupportedModes->UdmaMode.Valid) {
606
607 TransferMode.ModeCategory = ATA_MODE_CATEGORY_UDMA;
608 TransferMode.ModeNumber = (UINT8) (SupportedModes->UdmaMode.Mode);
609 Status = SetDeviceTransferMode (IdeBlkIoDevicePtr, &TransferMode);
610
611 if (EFI_ERROR (Status)) {
612 IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;
613 ReleaseIdeResources (IdeBlkIoDevicePtr);
614 IdeBlkIoDevicePtr = NULL;
615 continue;
616 }
617
618 EnableInterrupt (IdeBlkIoDevicePtr);
619 } else if (SupportedModes->MultiWordDmaMode.Valid) {
620
621 TransferMode.ModeCategory = ATA_MODE_CATEGORY_MDMA;
622 TransferMode.ModeNumber = (UINT8) SupportedModes->MultiWordDmaMode.Mode;
623 Status = SetDeviceTransferMode (IdeBlkIoDevicePtr, &TransferMode);
624
625 if (EFI_ERROR (Status)) {
626 IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;
627 ReleaseIdeResources (IdeBlkIoDevicePtr);
628 IdeBlkIoDevicePtr = NULL;
629 continue;
630 }
631
632 EnableInterrupt (IdeBlkIoDevicePtr);
633 }
634 //
635 // Init driver parameters
636 //
637 DriveParameters.Sector = (UINT8) IdeBlkIoDevicePtr->pIdData->AtaData.sectors_per_track;
638 DriveParameters.Heads = (UINT8) (IdeBlkIoDevicePtr->pIdData->AtaData.heads - 1);
639 DriveParameters.MultipleSector = (UINT8) IdeBlkIoDevicePtr->pIdData->AtaData.multi_sector_cmd_max_sct_cnt;
640 //
641 // Set Parameters for the device:
642 // 1) Init
643 // 2) Establish the block count for READ/WRITE MULTIPLE (EXT) command
644 //
645 if ((IdeBlkIoDevicePtr->Type == IdeHardDisk) || (IdeBlkIoDevicePtr->Type == Ide48bitAddressingHardDisk)) {
646 Status = SetDriveParameters (IdeBlkIoDevicePtr, &DriveParameters);
647 }
648
649 //
650 // Record PIO mode used in private data
651 //
652 IdeBlkIoDevicePtr->PioMode = SupportedModes->PioMode.Mode;
653
654 //
655 // Set IDE controller Timing Blocks in the PCI Configuration Space
656 //
657 IdeInit->SetTiming (IdeInit, IdeChannel, IdeDevice, SupportedModes);
658
659 //
660 // Add Component Name for the IDE/ATAPI device that was discovered.
661 //
662 IdeBlkIoDevicePtr->ControllerNameTable = NULL;
663 ADD_NAME (IdeBlkIoDevicePtr);
664
665 Status = gBS->InstallMultipleProtocolInterfaces (
666 &IdeBlkIoDevicePtr->Handle,
667 &gEfiDevicePathProtocolGuid,
668 IdeBlkIoDevicePtr->DevicePath,
669 &gEfiBlockIoProtocolGuid,
670 &IdeBlkIoDevicePtr->BlkIo,
671 &gEfiDiskInfoProtocolGuid,
672 &IdeBlkIoDevicePtr->DiskInfo,
673 NULL
674 );
675
676 if (EFI_ERROR (Status)) {
677 ReleaseIdeResources (IdeBlkIoDevicePtr);
678 }
679
680 gBS->OpenProtocol (
681 Controller,
682 &gEfiPciIoProtocolGuid,
683 (VOID **) &PciIo,
684 This->DriverBindingHandle,
685 IdeBlkIoDevicePtr->Handle,
686 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
687 );
688
689 IdeBusDriverPrivateData->DeviceProcessed[IdeChannel * 2 + IdeDevice] = TRUE;
690
691 //
692 // Report status code: device eanbled!
693 //
694 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
695 EFI_PROGRESS_CODE,
696 (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_ENABLE),
697 IdeBlkIoDevicePtr->DevicePath
698 );
699 //
700 // end of 2nd inner loop ----
701 //
702 }
703 //
704 // end of 2nd outer loop ==========
705 //
706 }
707
708 //
709 // All configurations done! Notify IdeController to do post initialization
710 // work such as saving IDE controller PCI settings for S3 resume
711 //
712 IdeInit->NotifyPhase (IdeInit, EfiIdeBusPhaseMaximum, 0);
713
714 if (SupportedModes != NULL) {
715 gBS->FreePool (SupportedModes);
716 }
717
718 PERF_START (0, "Finish IDE detection", "IDE", 1);
719 PERF_END (0, "Finish IDE detection", "IDE", 0);
720
721 return EFI_SUCCESS;
722
723 ErrorExit:
724
725 //
726 // Report error code: controller error
727 //
728 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
729 EFI_ERROR_CODE | EFI_ERROR_MINOR,
730 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_EC_CONTROLLER_ERROR),
731 ParentDevicePath
732 );
733
734 gBS->CloseProtocol (
735 Controller,
736 &gEfiIdeControllerInitProtocolGuid,
737 This->DriverBindingHandle,
738 Controller
739 );
740
741 gBS->UninstallMultipleProtocolInterfaces (
742 Controller,
743 &gEfiCallerIdGuid,
744 IdeBusDriverPrivateData,
745 NULL
746 );
747
748 if (IdeBusDriverPrivateData != NULL) {
749 gBS->FreePool (IdeBusDriverPrivateData);
750 }
751
752 if (SupportedModes != NULL) {
753 gBS->FreePool (SupportedModes);
754 }
755
756 gBS->CloseProtocol (
757 Controller,
758 &gEfiPciIoProtocolGuid,
759 This->DriverBindingHandle,
760 Controller
761 );
762
763 gBS->CloseProtocol (
764 Controller,
765 &gEfiDevicePathProtocolGuid,
766 This->DriverBindingHandle,
767 Controller
768 );
769
770 return Status;
771
772 }
773
774 //
775 // ***********************************************************************************
776 // IDEBusDriverBindingStop
777 // ***********************************************************************************
778 //
779 /**
780 Stop this driver on Controller Handle.
781
782 @param This Protocol instance pointer.
783 @param DeviceHandle Handle of device to stop driver on
784 @param NumberOfChildren Not used
785 @param ChildHandleBuffer Not used
786
787 @retval EFI_SUCCESS This driver is removed DeviceHandle
788 @retval other This driver was not removed from this device
789
790 **/
791 EFI_STATUS
792 EFIAPI
793 IDEBusDriverBindingStop (
794 IN EFI_DRIVER_BINDING_PROTOCOL *This,
795 IN EFI_HANDLE Controller,
796 IN UINTN NumberOfChildren,
797 IN EFI_HANDLE *ChildHandleBuffer
798 )
799 // TODO: Controller - add argument and description to function comment
800 // TODO: EFI_DEVICE_ERROR - add return value to function comment
801 {
802 EFI_STATUS Status;
803 EFI_PCI_IO_PROTOCOL *PciIo;
804 BOOLEAN AllChildrenStopped;
805 UINTN Index;
806 IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
807
808 IdeBusDriverPrivateData = NULL;
809
810 if (NumberOfChildren == 0) {
811
812 Status = gBS->OpenProtocol (
813 Controller,
814 &gEfiPciIoProtocolGuid,
815 (VOID **) &PciIo,
816 This->DriverBindingHandle,
817 Controller,
818 EFI_OPEN_PROTOCOL_GET_PROTOCOL
819 );
820 if (!EFI_ERROR (Status)) {
821 PciIo->Attributes (
822 PciIo,
823 EfiPciIoAttributeOperationDisable,
824 EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO | EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO | EFI_PCI_DEVICE_ENABLE,
825 NULL
826 );
827 }
828
829 gBS->OpenProtocol (
830 Controller,
831 &gEfiCallerIdGuid,
832 (VOID **) &IdeBusDriverPrivateData,
833 This->DriverBindingHandle,
834 Controller,
835 EFI_OPEN_PROTOCOL_GET_PROTOCOL
836 );
837
838 gBS->UninstallMultipleProtocolInterfaces (
839 Controller,
840 &gEfiCallerIdGuid,
841 IdeBusDriverPrivateData,
842 NULL
843 );
844
845 if (IdeBusDriverPrivateData != NULL) {
846 gBS->FreePool (IdeBusDriverPrivateData);
847 }
848 //
849 // Close the bus driver
850 //
851 gBS->CloseProtocol (
852 Controller,
853 &gEfiIdeControllerInitProtocolGuid,
854 This->DriverBindingHandle,
855 Controller
856 );
857 gBS->CloseProtocol (
858 Controller,
859 &gEfiPciIoProtocolGuid,
860 This->DriverBindingHandle,
861 Controller
862 );
863 gBS->CloseProtocol (
864 Controller,
865 &gEfiDevicePathProtocolGuid,
866 This->DriverBindingHandle,
867 Controller
868 );
869
870 return EFI_SUCCESS;
871 }
872
873 AllChildrenStopped = TRUE;
874
875 for (Index = 0; Index < NumberOfChildren; Index++) {
876
877 Status = DeRegisterIdeDevice (This, Controller, ChildHandleBuffer[Index]);
878
879 if (EFI_ERROR (Status)) {
880 AllChildrenStopped = FALSE;
881 }
882 }
883
884 if (!AllChildrenStopped) {
885 return EFI_DEVICE_ERROR;
886 }
887
888 return EFI_SUCCESS;
889 }
890
891 //
892 // ***********************************************************************************
893 // DeRegisterIdeDevice
894 // ***********************************************************************************
895 //
896 /**
897 Deregister an IDE device and free resources
898
899 @param This Protocol instance pointer.
900 @param Controller Ide device handle
901 @param Handle Handle of device to deregister driver on
902
903 @return EFI_STATUS
904
905 **/
906 EFI_STATUS
907 DeRegisterIdeDevice (
908 IN EFI_DRIVER_BINDING_PROTOCOL *This,
909 IN EFI_HANDLE Controller,
910 IN EFI_HANDLE Handle
911 )
912 // TODO: EFI_SUCCESS - add return value to function comment
913 {
914 EFI_STATUS Status;
915 EFI_BLOCK_IO_PROTOCOL *BlkIo;
916 IDE_BLK_IO_DEV *IdeBlkIoDevice;
917 EFI_PCI_IO_PROTOCOL *PciIo;
918 UINTN Index;
919
920 Status = gBS->OpenProtocol (
921 Handle,
922 &gEfiBlockIoProtocolGuid,
923 (VOID **) &BlkIo,
924 This->DriverBindingHandle,
925 Controller,
926 EFI_OPEN_PROTOCOL_GET_PROTOCOL
927 );
928 if (EFI_ERROR (Status)) {
929 return Status;
930 }
931
932 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlkIo);
933
934 //
935 // Report Status code: Device disabled
936 //
937 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
938 EFI_PROGRESS_CODE,
939 (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_DISABLE),
940 IdeBlkIoDevice->DevicePath
941 );
942
943 //
944 // Close the child handle
945 //
946 Status = gBS->CloseProtocol (
947 Controller,
948 &gEfiPciIoProtocolGuid,
949 This->DriverBindingHandle,
950 Handle
951 );
952
953 Status = gBS->UninstallMultipleProtocolInterfaces (
954 Handle,
955 &gEfiDevicePathProtocolGuid,
956 IdeBlkIoDevice->DevicePath,
957 &gEfiBlockIoProtocolGuid,
958 &IdeBlkIoDevice->BlkIo,
959 &gEfiDiskInfoProtocolGuid,
960 &IdeBlkIoDevice->DiskInfo,
961 NULL
962 );
963
964 if (EFI_ERROR (Status)) {
965 gBS->OpenProtocol (
966 Controller,
967 &gEfiPciIoProtocolGuid,
968 (VOID **) &PciIo,
969 This->DriverBindingHandle,
970 Handle,
971 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
972 );
973 return Status;
974 }
975
976 //
977 // Release allocated resources
978 //
979 Index = IdeBlkIoDevice->Channel * 2 + IdeBlkIoDevice->Device;
980 IdeBlkIoDevice->IdeBusDriverPrivateData->HaveScannedDevice[Index] = FALSE;
981
982 ReleaseIdeResources (IdeBlkIoDevice);
983
984 return EFI_SUCCESS;
985 }
986
987 //
988 // ***********************************************************************************
989 // IDEBlkIoReset
990 // ***********************************************************************************
991 //
992 /**
993 TODO: This - add argument and description to function comment
994 TODO: ExtendedVerification - add argument and description to function comment
995 TODO: EFI_DEVICE_ERROR - add return value to function comment
996
997 **/
998 EFI_STATUS
999 EFIAPI
1000 IDEBlkIoReset (
1001 IN EFI_BLOCK_IO_PROTOCOL *This,
1002 IN BOOLEAN ExtendedVerification
1003 )
1004 {
1005 IDE_BLK_IO_DEV *IdeBlkIoDevice;
1006 EFI_STATUS Status;
1007
1008 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (This);
1009 //
1010 // Requery IDE IO resources in case of the switch of native and legacy modes
1011 //
1012 ReassignIdeResources (IdeBlkIoDevice);
1013
1014 //
1015 // for ATA device, using ATA reset method
1016 //
1017 if (IdeBlkIoDevice->Type == IdeHardDisk) {
1018 return AtaSoftReset (IdeBlkIoDevice);
1019 }
1020
1021 if (IdeBlkIoDevice->Type == IdeUnknown) {
1022 return EFI_DEVICE_ERROR;
1023 }
1024
1025 //
1026 // for ATAPI device, using ATAPI reset method
1027 //
1028 Status = AtapiSoftReset (IdeBlkIoDevice);
1029 if (ExtendedVerification) {
1030 Status = AtaSoftReset (IdeBlkIoDevice);
1031 }
1032
1033 return Status;
1034 }
1035
1036 /**
1037 Read data from block io device
1038
1039 @param This Protocol instance pointer.
1040 @param MediaId The media ID of the device
1041 @param LBA Starting LBA address to read data
1042 @param BufferSize The size of data to be read
1043 @param Buffer Caller supplied buffer to save data
1044
1045 @return read data status
1046
1047 **/
1048 EFI_STATUS
1049 EFIAPI
1050 IDEBlkIoReadBlocks (
1051 IN EFI_BLOCK_IO_PROTOCOL *This,
1052 IN UINT32 MediaId,
1053 IN EFI_LBA LBA,
1054 IN UINTN BufferSize,
1055 OUT VOID *Buffer
1056 )
1057 // TODO: EFI_DEVICE_ERROR - add return value to function comment
1058 {
1059 IDE_BLK_IO_DEV *IdeBlkIoDevice;
1060
1061 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (This);
1062
1063 //
1064 // Requery IDE IO resources in case of the switch of native and legacy modes
1065 //
1066 ReassignIdeResources (IdeBlkIoDevice);
1067
1068 //
1069 // For ATA compatible device, use ATA read block's mechanism
1070 //
1071 if (IdeBlkIoDevice->Type == IdeHardDisk ||
1072 IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {
1073 return AtaBlkIoReadBlocks (
1074 IdeBlkIoDevice,
1075 MediaId,
1076 LBA,
1077 BufferSize,
1078 Buffer
1079 );
1080 }
1081
1082 if (IdeBlkIoDevice->Type == IdeUnknown) {
1083 return EFI_DEVICE_ERROR;
1084 }
1085
1086 //
1087 // for ATAPI device, using ATAPI read block's mechanism
1088 //
1089 return AtapiBlkIoReadBlocks (
1090 IdeBlkIoDevice,
1091 MediaId,
1092 LBA,
1093 BufferSize,
1094 Buffer
1095 );
1096
1097 }
1098
1099 /**
1100 Write data to block io device
1101
1102 @param This Protocol instance pointer.
1103 @param MediaId The media ID of the device
1104 @param LBA Starting LBA address to write data
1105 @param BufferSize The size of data to be written
1106 @param Buffer Caller supplied buffer to save data
1107
1108 @return write data status
1109
1110 **/
1111 EFI_STATUS
1112 EFIAPI
1113 IDEBlkIoWriteBlocks (
1114 IN EFI_BLOCK_IO_PROTOCOL *This,
1115 IN UINT32 MediaId,
1116 IN EFI_LBA LBA,
1117 IN UINTN BufferSize,
1118 IN VOID *Buffer
1119 )
1120 // TODO: EFI_DEVICE_ERROR - add return value to function comment
1121 {
1122 IDE_BLK_IO_DEV *IdeBlkIoDevice;
1123
1124 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (This);
1125 //
1126 // Requery IDE IO resources in case of the switch of native and legacy modes
1127 //
1128 ReassignIdeResources (IdeBlkIoDevice);
1129
1130 //
1131 // for ATA device, using ATA write block's mechanism
1132 //
1133 if (IdeBlkIoDevice->Type == IdeHardDisk ||
1134 IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {
1135
1136 return AtaBlkIoWriteBlocks (
1137 IdeBlkIoDevice,
1138 MediaId,
1139 LBA,
1140 BufferSize,
1141 Buffer
1142 );
1143 }
1144
1145 if (IdeBlkIoDevice->Type == IdeUnknown) {
1146 return EFI_DEVICE_ERROR;
1147 }
1148
1149 //
1150 // for ATAPI device, using ATAPI write block's mechanism
1151 //
1152 return AtapiBlkIoWriteBlocks (
1153 IdeBlkIoDevice,
1154 MediaId,
1155 LBA,
1156 BufferSize,
1157 Buffer
1158 );
1159 }
1160
1161 //
1162 // ***********************************************************************************
1163 // IDEBlkIoFlushBlocks
1164 // ***********************************************************************************
1165 //
1166 /**
1167 TODO: This - add argument and description to function comment
1168 TODO: EFI_SUCCESS - add return value to function comment
1169 **/
1170 EFI_STATUS
1171 EFIAPI
1172 IDEBlkIoFlushBlocks (
1173 IN EFI_BLOCK_IO_PROTOCOL *This
1174 )
1175 {
1176 //
1177 // return directly
1178 //
1179 return EFI_SUCCESS;
1180 }
1181
1182 /**
1183 Return the results of the Inquiry command to a drive in InquiryData.
1184 Data format of Inquiry data is defined by the Interface GUID.
1185
1186 @param This Protocol instance pointer.
1187 @param InquiryData Results of Inquiry command to device
1188 @param InquiryDataSize Size of InquiryData in bytes.
1189
1190 @retval EFI_SUCCESS InquiryData valid
1191 @retval EFI_NOT_FOUND Device does not support this data class
1192 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
1193 @retval EFI_BUFFER_TOO_SMALL IntquiryDataSize not big enough
1194
1195 **/
1196 EFI_STATUS
1197 EFIAPI
1198 IDEDiskInfoInquiry (
1199 IN EFI_DISK_INFO_PROTOCOL *This,
1200 IN OUT VOID *InquiryData,
1201 IN OUT UINT32 *InquiryDataSize
1202 )
1203 {
1204 IDE_BLK_IO_DEV *IdeBlkIoDevice;
1205
1206 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS (This);
1207
1208 if (*InquiryDataSize < sizeof (INQUIRY_DATA)) {
1209 *InquiryDataSize = sizeof (INQUIRY_DATA);
1210 return EFI_BUFFER_TOO_SMALL;
1211 }
1212
1213 if (IdeBlkIoDevice->pInquiryData == NULL) {
1214 return EFI_NOT_FOUND;
1215 }
1216
1217 gBS->CopyMem (InquiryData, IdeBlkIoDevice->pInquiryData, sizeof (INQUIRY_DATA));
1218 *InquiryDataSize = sizeof (INQUIRY_DATA);
1219
1220 return EFI_SUCCESS;
1221 }
1222
1223 /**
1224 Return the results of the Identify command to a drive in IdentifyData.
1225 Data format of Identify data is defined by the Interface GUID.
1226
1227 @param This Protocol instance pointer.
1228 @param IdentifyData Results of Identify command to device
1229 @param IdentifyDataSize Size of IdentifyData in bytes.
1230
1231 @retval EFI_SUCCESS IdentifyData valid
1232 @retval EFI_NOT_FOUND Device does not support this data class
1233 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
1234 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
1235
1236 **/
1237 EFI_STATUS
1238 EFIAPI
1239 IDEDiskInfoIdentify (
1240 IN EFI_DISK_INFO_PROTOCOL *This,
1241 IN OUT VOID *IdentifyData,
1242 IN OUT UINT32 *IdentifyDataSize
1243 )
1244 {
1245 IDE_BLK_IO_DEV *IdeBlkIoDevice;
1246
1247 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS (This);
1248
1249 if (*IdentifyDataSize < sizeof (EFI_IDENTIFY_DATA)) {
1250 *IdentifyDataSize = sizeof (EFI_IDENTIFY_DATA);
1251 return EFI_BUFFER_TOO_SMALL;
1252 }
1253
1254 if (IdeBlkIoDevice->pIdData == NULL) {
1255 return EFI_NOT_FOUND;
1256 }
1257
1258 gBS->CopyMem (IdentifyData, IdeBlkIoDevice->pIdData, sizeof (EFI_IDENTIFY_DATA));
1259 *IdentifyDataSize = sizeof (EFI_IDENTIFY_DATA);
1260
1261 return EFI_SUCCESS;
1262 }
1263
1264 /**
1265 Return the results of the Request Sense command to a drive in SenseData.
1266 Data format of Sense data is defined by the Interface GUID.
1267
1268 @param This Protocol instance pointer.
1269 @param SenseData Results of Request Sense command to device
1270 @param SenseDataSize Size of SenseData in bytes.
1271 @param SenseDataNumber Type of SenseData
1272
1273 @retval EFI_SUCCESS InquiryData valid
1274 @retval EFI_NOT_FOUND Device does not support this data class
1275 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
1276 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough
1277
1278 **/
1279 EFI_STATUS
1280 EFIAPI
1281 IDEDiskInfoSenseData (
1282 IN EFI_DISK_INFO_PROTOCOL *This,
1283 IN OUT VOID *SenseData,
1284 IN OUT UINT32 *SenseDataSize,
1285 OUT UINT8 *SenseDataNumber
1286 )
1287 {
1288 return EFI_NOT_FOUND;
1289 }
1290
1291 /**
1292 Return the results of the Request Sense command to a drive in SenseData.
1293 Data format of Sense data is defined by the Interface GUID.
1294
1295 @param This Protocol instance pointer.
1296 @param IdeChannel Primary or Secondary
1297 @param IdeDevice Master or Slave
1298
1299 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid
1300 @retval EFI_UNSUPPORTED This is not an IDE device
1301
1302 **/
1303 EFI_STATUS
1304 EFIAPI
1305 IDEDiskInfoWhichIde (
1306 IN EFI_DISK_INFO_PROTOCOL *This,
1307 OUT UINT32 *IdeChannel,
1308 OUT UINT32 *IdeDevice
1309 )
1310 {
1311 IDE_BLK_IO_DEV *IdeBlkIoDevice;
1312
1313 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS (This);
1314 *IdeChannel = IdeBlkIoDevice->Channel;
1315 *IdeDevice = IdeBlkIoDevice->Device;
1316
1317 return EFI_SUCCESS;
1318 }