summaryrefslogtreecommitdiffstats
path: root/IntelFrameworkModulePkg
diff options
context:
space:
mode:
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2010-12-10 02:45:29 +0000
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2010-12-10 02:45:29 +0000
commite519401bd5d1e370e9e41f451dac6c376e218c8d (patch)
treec49f5ee913b90a0fd33922326b8a87af002619a4 /IntelFrameworkModulePkg
parent5091b4759fffebb4189f175a32d8d39e2faa74c6 (diff)
downloadedk2-e519401bd5d1e370e9e41f451dac6c376e218c8d.tar.gz
edk2-e519401bd5d1e370e9e41f451dac6c376e218c8d.tar.bz2
edk2-e519401bd5d1e370e9e41f451dac6c376e218c8d.zip
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
Diffstat (limited to 'IntelFrameworkModulePkg')
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c45
1 files changed, 41 insertions, 4 deletions
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;
}