/** @file\r
Collect IDE information from Native EFI Driver\r
\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions\r
-of the BSD License which accompanies this distribution. The\r
-full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
(VOID *) &LocalHddInfo\r
);\r
if (!EFI_ERROR (Status)) {\r
- IdeController = HandleBuffer[0]; \r
+ IdeController = HandleBuffer[0];\r
//\r
// Force IDE drive spin up!\r
//\r
)\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
Status = gBS->HandleProtocol (\r
IdeController,\r
&gEfiPciIoProtocolGuid,\r
- (VOID **) &PciIo\r
+ (VOID **)&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