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