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