]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaIo.c
Fix comparisons of enumerated types which may cause warnings for some compilers.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaBusDxe / IsaIo.c
index 4673d8379a3c4012f493c3fab89d4fe5d844f7a8..6f1cd1b8b11947124b455289f0c3c855a23e2b73 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   The implementation for EFI_ISA_IO_PROTOCOL. \r
   \r
-Copyright (c) 2006 - 2009, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -80,24 +80,6 @@ EFI_ISA_DMA_REGISTERS  mDmaRegisters[8] = {
   },\r
 };\r
 \r
-/**\r
-  report a error Status code\r
-\r
-  @param Code          The error status code.\r
-  \r
-  @return EFI_SUCCESS  Success to report status code.\r
-**/\r
-EFI_STATUS\r
-ReportErrorStatusCode (\r
-  EFI_STATUS_CODE_VALUE Code\r
-  )\r
-{\r
-  return REPORT_STATUS_CODE (\r
-           EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-           Code\r
-           );\r
-}\r
-\r
 /**\r
   Initializes an ISA I/O Instance\r
 \r
@@ -176,7 +158,10 @@ IsaIoIoRead (
                                     );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    ReportErrorStatusCode (EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR);\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
+      );\r
   }\r
 \r
   return Status;\r
@@ -235,7 +220,10 @@ IsaIoIoWrite (
                                     );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    ReportErrorStatusCode (EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR);\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
+      );\r
   }\r
 \r
   return Status;\r
@@ -274,7 +262,10 @@ WritePort (
                                     &Value\r
                                     );\r
   if (EFI_ERROR (Status)) {\r
-    ReportErrorStatusCode (EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR);\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
+      );\r
     return Status;\r
   }\r
 \r
@@ -353,9 +344,9 @@ IsaIoUnmap (
   ISA_MAP_INFO  *IsaMapInfo;\r
 \r
   //\r
-  // Unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.\r
+  // Check if DMA is supported.\r
   //\r
-  if (!FeaturePcdGet (PcdIsaBusSupportDma)) {\r
+  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -414,7 +405,10 @@ IsaIoFlush (
   Status = IsaIoDevice->PciIo->Flush (IsaIoDevice->PciIo);\r
 \r
   if (EFI_ERROR (Status)) {\r
-    ReportErrorStatusCode (EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR);\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
+      );\r
   }\r
 \r
   return Status;\r
@@ -445,8 +439,7 @@ IsaIoVerifyAccess (
   EFI_ISA_ACPI_RESOURCE *Item;\r
   EFI_STATUS            Status;\r
 \r
-  if (Width < EfiIsaIoWidthUint8 ||\r
-      Width >= EfiIsaIoWidthMaximum ||\r
+  if ((UINT32)Width >= EfiIsaIoWidthMaximum ||\r
       Width == EfiIsaIoWidthReserved ||\r
       Width == EfiIsaIoWidthFifoReserved ||\r
       Width == EfiIsaIoWidthFillReserved\r
@@ -512,10 +505,9 @@ IsaIoMemRead (
   ISA_IO_DEVICE *IsaIoDevice;\r
 \r
   //\r
-  // Set Feature Flag PcdIsaBusSupportIsaMemory to FALSE to disable support for\r
-  // ISA bus memory read/write operations.\r
+  // Check if ISA memory is supported.\r
   //\r
-  if (!FeaturePcdGet (PcdIsaBusSupportIsaMemory)) {\r
+  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -545,7 +537,10 @@ IsaIoMemRead (
                                      );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    ReportErrorStatusCode (EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR);\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
+      );\r
   }\r
 \r
   return Status;\r
@@ -579,10 +574,9 @@ IsaIoMemWrite (
   ISA_IO_DEVICE *IsaIoDevice;\r
 \r
   //\r
-  // Set Feature Flag PcdIsaBusSupportIsaMemory to FALSE to disable support for\r
-  // ISA bus memory read/write operations.\r
+  // Check if ISA memory is supported.\r
   //\r
-  if (!FeaturePcdGet (PcdIsaBusSupportIsaMemory)) {\r
+  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -612,7 +606,10 @@ IsaIoMemWrite (
                                      );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    ReportErrorStatusCode (EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR);\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
+      );\r
   }\r
 \r
   return Status;\r
@@ -646,10 +643,9 @@ IsaIoCopyMem (
   ISA_IO_DEVICE *IsaIoDevice;\r
 \r
   //\r
-  // Set Feature Flag PcdIsaBusSupportIsaMemory to FALSE to disable support for\r
-  // ISA bus memory read/write operations.\r
+  // Check if ISA memory is supported.\r
   //\r
-  if (!FeaturePcdGet (PcdIsaBusSupportIsaMemory)) {\r
+  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -691,7 +687,10 @@ IsaIoCopyMem (
                                  );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    ReportErrorStatusCode (EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR);\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
+      );\r
   }\r
 \r
   return Status;\r
@@ -1000,7 +999,7 @@ IsaIoMapFullSupport (
   //\r
   // Make sure the Operation parameter is valid\r
   //\r
-  if (Operation < 0 || Operation >= EfiIsaIoOperationMaximum) {\r
+  if ((UINT32)Operation >= EfiIsaIoOperationMaximum) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1297,9 +1296,9 @@ IsaIoMap (
   )\r
 {\r
   //\r
-  // Set Feature Flag PcdIsaBusSupportDma to FALSE to disable support for ISA DMA.\r
+  // Check if DMA is supported.\r
   //\r
-  if (!FeaturePcdGet (PcdIsaBusSupportDma)) {\r
+  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {\r
     return EFI_UNSUPPORTED;\r
   }\r
   //\r
@@ -1308,7 +1307,7 @@ IsaIoMap (
   //\r
   // So we just return EFI_UNSUPPORTED for these functions.\r
   //\r
-  if (FeaturePcdGet (PcdIsaBusOnlySupportSlaveDma)) {\r
+  if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0) {\r
     return IsaIoMapOnlySupportSlaveReadWrite (\r
              This,\r
              Operation,\r
@@ -1369,7 +1368,8 @@ IsaIoAllocateBuffer (
   // ISA Bus Master.\r
   // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.\r
   //\r
-  if (!FeaturePcdGet (PcdIsaBusSupportDma) || FeaturePcdGet (PcdIsaBusOnlySupportSlaveDma)) {\r
+  if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||\r
+      ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -1377,7 +1377,7 @@ IsaIoAllocateBuffer (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (Type < AllocateAnyPages || Type >= MaxAllocateType) {\r
+  if ((UINT32)Type >= MaxAllocateType) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   //\r
@@ -1406,7 +1406,10 @@ IsaIoAllocateBuffer (
 \r
   Status = gBS->AllocatePages (Type, MemoryType, Pages, &PhysicalAddress);\r
   if (EFI_ERROR (Status)) {\r
-    ReportErrorStatusCode (EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR);\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
+      );\r
     return Status;\r
   }\r
 \r
@@ -1439,7 +1442,8 @@ IsaIoFreeBuffer (
   // ISA Bus Master.\r
   // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.\r
   //\r
-  if (!FeaturePcdGet (PcdIsaBusSupportDma) || FeaturePcdGet (PcdIsaBusOnlySupportSlaveDma)) {\r
+  if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||\r
+      ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -1448,7 +1452,10 @@ IsaIoFreeBuffer (
                   Pages\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    ReportErrorStatusCode (EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR);\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+      EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR\r
+      );\r
   }\r
 \r
   return Status;\r