From e519401bd5d1e370e9e41f451dac6c376e218c8d Mon Sep 17 00:00:00 2001 From: lzeng14 Date: Fri, 10 Dec 2010 02:45:29 +0000 Subject: 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 --- IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c | 45 ++++++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c') 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; } -- cgit v1.2.3