From: lzeng14 Date: Fri, 10 Dec 2010 02:45:29 +0000 (+0000) Subject: Enhance IdeBusDxe to check the class code for IDE mode only. X-Git-Tag: edk2-stable201903~15328 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=e519401bd5d1e370e9e41f451dac6c376e218c8d Enhance IdeBusDxe to check the class code for IDE mode only. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11147 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c index 7ed004d150..a38611304f 100644 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c +++ b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c @@ -148,6 +148,8 @@ IDEBusDriverBindingSupported ( EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; EFI_DEV_PATH *Node; EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit; + EFI_PCI_IO_PROTOCOL *PciIo; + PCI_TYPE00 PciData; if (RemainingDevicePath != NULL) { Node = (EFI_DEV_PATH *) RemainingDevicePath; @@ -171,10 +173,6 @@ IDEBusDriverBindingSupported ( // // Verify the Ide Controller Init Protocol, which installed by the // IdeController module. - // Note 1: PciIo protocol has been opened BY_DRIVER by ide_init, so We can't - // open BY_DRIVER here) That's why we don't check pciio protocol - // Note 2: ide_init driver check ide controller's pci config space, so we dont - // check here any more to save code size // Status = gBS->OpenProtocol ( Controller, @@ -228,6 +226,45 @@ IDEBusDriverBindingSupported ( Controller ); + // + // Get the EfiPciIoProtocol + // + Status = gBS->OpenProtocol ( + Controller, + &gEfiPciIoProtocolGuid, + (VOID **) &PciIo, + This->DriverBindingHandle, + Controller, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Now further check the PCI header: Base class (offset 0x0B) and + // Sub Class (offset 0x0A). This controller should be an IDE controller + // + Status = PciIo->Pci.Read ( + PciIo, + EfiPciIoWidthUint8, + 0, + sizeof (PciData), + &PciData + ); + + if (!EFI_ERROR (Status)) { + // + // Examine if it is IDE mode by class code + // + if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) || (PciData.Hdr.ClassCode[1] != PCI_SUB_CLASS_IDE)) { + Status = EFI_UNSUPPORTED; + } else { + Status = EFI_SUCCESS; + } + } + return Status; }