)\r
{\r
EFI_PCI_IO_PROTOCOL *PciIo;\r
- UINT8 Pi;\r
UINT32 IOBarClear;\r
EFI_STATUS Status;\r
+ PCI_TYPE00 PciData;\r
\r
//\r
// If the IDE channel is in compatibility (legacy) mode, remove all\r
// and has PCI I/O resources allocated\r
//\r
Status = gBS->HandleProtocol (\r
- IdeController,\r
- &gEfiPciIoProtocolGuid,\r
- (VOID **) &PciIo\r
+ IdeController, \r
+ &gEfiPciIoProtocolGuid, \r
+ &PciIo\r
);\r
- if (!EFI_ERROR (Status)) {\r
- IOBarClear = 0x00;\r
- PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 1, &Pi);\r
- if ((Pi & 0x01) == 0) {\r
- PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x10, 1, &IOBarClear);\r
- PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x14, 1, &IOBarClear);\r
- }\r
- if ((Pi & 0x04) == 0) {\r
- PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x18, 1, &IOBarClear);\r
- PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1C, 1, &IOBarClear);\r
- }\r
+ if (EFI_ERROR (Status)) {\r
+ return ;\r
+ }\r
+\r
+ Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0, sizeof (PciData), &PciData);\r
+ if (EFI_ERROR (Status)) {\r
+ return ;\r
+ }\r
+\r
+ //\r
+ // Check whether this is IDE\r
+ //\r
+ if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) ||\r
+ (PciData.Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE)) {\r
+ return ;\r
+ }\r
+\r
+ //\r
+ // Clear bar for legacy IDE\r
+ //\r
+ IOBarClear = 0x00;\r
+ if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_PNE) == 0) {\r
+ PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x10, 1, &IOBarClear);\r
+ PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x14, 1, &IOBarClear);\r
+ }\r
+ if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_SNE) == 0) {\r
+ PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x18, 1, &IOBarClear);\r
+ PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1C, 1, &IOBarClear);\r
}\r
\r
return ;\r