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