]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaIo.c
Use REPORT_STATUS_CODExxx() macros directly.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaBusDxe / IsaIo.c
index 99295f48c41e79c77e57a846d49e3b942b7d0ecb..e4715383eacf4442b6df6a7c01fd1af7ba89fd05 100644 (file)
@@ -1,8 +1,8 @@
-/**@file\r
+/** @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 - 2011, 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,31 +80,12 @@ 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
   @param[in] IsaIoDevice            The iso device to be initialized.\r
   @param[in] IsaDeviceResourceList  The resource list.\r
   \r
-  @retval None\r
 **/\r
 VOID\r
 InitializeIsaIoInstance (\r
@@ -177,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
@@ -236,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
@@ -275,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
@@ -354,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
@@ -387,7 +377,7 @@ IsaIoUnmap (
     // Free the mapped buffer and the MAP_INFO structure.\r
     //\r
     gBS->FreePages (IsaMapInfo->MappedHostAddress, IsaMapInfo->NumberOfPages);\r
-    gBS->FreePool (IsaMapInfo);\r
+    FreePool (IsaMapInfo);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -415,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
@@ -513,10 +506,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
@@ -546,7 +538,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
@@ -580,10 +575,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
@@ -613,7 +607,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
@@ -624,7 +621,7 @@ IsaIoMemWrite (
 \r
   @param[in]  This               A pointer to the EFI_ISA_IO_PROTOCOL instance.\r
   @param[in]  Width              Specifies the width of the memory copy operation.\r
-  @param[out] DestOffset         The offset of the destination \r
+  @param[in]  DestOffset         The offset of the destination \r
   @param[in]  SrcOffset          The offset of the source\r
   @param[in]  Count              The number of memory copy  operations to perform\r
 \r
@@ -647,10 +644,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
@@ -692,7 +688,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
@@ -822,7 +821,7 @@ IsaIoMapOnlySupportSlaveReadWrite (
                     &IsaMapInfo->MappedHostAddress\r
                     );\r
     if (EFI_ERROR (Status)) {\r
-      gBS->FreePool (IsaMapInfo);\r
+      FreePool (IsaMapInfo);\r
       *NumberOfBytes  = 0;\r
       *Mapping        = NULL;\r
       return Status;\r
@@ -1037,17 +1036,14 @@ IsaIoMapFullSupport (
     //\r
     // This implementation only support COMPATIBLE DMA Transfers\r
     //\r
-    if (!(ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE)) {\r
+    if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE) == 0) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    if (ChannelAttributes &\r
-       (\r
-         EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A |\r
-         EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B |\r
-         EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C\r
-       )\r
-       ) {\r
+    if ((ChannelAttributes &\r
+         (EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A |\r
+          EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B |\r
+          EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C)) != 0) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -1055,8 +1051,8 @@ IsaIoMapFullSupport (
       //\r
       // If this is Channel 0..3, then the width must be 8 bit\r
       //\r
-      if (!(ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) ||\r
-          (ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16)\r
+      if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) == 0) ||\r
+          ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) != 0)\r
           ) {\r
         return EFI_INVALID_PARAMETER;\r
       }\r
@@ -1064,21 +1060,20 @@ IsaIoMapFullSupport (
       //\r
       // If this is Channel 4..7, then the width must be 16 bit\r
       //\r
-      if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) ||\r
-          (!(ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16))\r
-          ) {\r
+      if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) != 0) ||\r
+          ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) == 0)) {\r
         return EFI_INVALID_PARAMETER;\r
       }\r
     }\r
     //\r
     // Either Demand Mode or Single Mode must be selected, but not both\r
     //\r
-    if (ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) {\r
-      if (ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) {\r
+    if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {\r
+      if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {\r
         return EFI_INVALID_PARAMETER;\r
       }\r
     } else {\r
-      if (!(ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE)) {\r
+      if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) == 0) {\r
         return EFI_INVALID_PARAMETER;\r
       }\r
     }\r
@@ -1129,7 +1124,7 @@ IsaIoMapFullSupport (
                     &IsaMapInfo->MappedHostAddress\r
                     );\r
     if (EFI_ERROR (Status)) {\r
-      gBS->FreePool (IsaMapInfo);\r
+      FreePool (IsaMapInfo);\r
       *NumberOfBytes  = 0;\r
       *Mapping        = NULL;\r
       return Status;\r
@@ -1173,15 +1168,15 @@ IsaIoMapFullSupport (
     DmaMode |= V_8237_DMA_CHMODE_IO2MEM;\r
   }\r
 \r
-  if (ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE) {\r
+  if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE) != 0) {\r
     DmaMode |= B_8237_DMA_CHMODE_AE;\r
   }\r
 \r
-  if (ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) {\r
+  if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {\r
     DmaMode |= V_8237_DMA_CHMODE_DEMAND;\r
   }\r
 \r
-  if (ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) {\r
+  if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {\r
     DmaMode |= V_8237_DMA_CHMODE_SINGLE;\r
   }\r
   //\r
@@ -1302,9 +1297,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
@@ -1313,7 +1308,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
@@ -1374,7 +1369,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
@@ -1392,7 +1388,7 @@ IsaIoAllocateBuffer (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (Attributes & ~(EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED)) {\r
+  if ((Attributes & ~(EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED)) != 0) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -1411,7 +1407,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
@@ -1444,7 +1443,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
@@ -1453,7 +1453,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