]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/PciRootBridgeNoEnumerationDxe/PcatPciRootBridgeIo.c
MdeModulePkg/ResetUtilityLib: Add pack(1) for reset data structure
[mirror_edk2.git] / DuetPkg / PciRootBridgeNoEnumerationDxe / PcatPciRootBridgeIo.c
index abb6acbd96c85ac2534b87d246da868d67f4fac4..d5d79aee2e9f9b551bf0aeab366069efb3c8bf0e 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2005 - 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
@@ -69,26 +69,6 @@ PcatRootBridgeIoMemWrite (
   IN OUT VOID                                   *Buffer\r
   );\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoIoRead (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT64                                 UserAddress,\r
-  IN     UINTN                                  Count,\r
-  IN OUT VOID                                   *UserBuffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PcatRootBridgeIoIoWrite (\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
-  IN     UINT64                                 UserAddress,\r
-  IN     UINTN                                  Count,\r
-  IN OUT VOID                                   *UserBuffer\r
-  );\r
-\r
 EFI_STATUS\r
 EFIAPI\r
 PcatRootBridgeIoCopyMem (\r
@@ -189,7 +169,6 @@ PcatRootBridgeIoConfiguration (
 //\r
 // Private Function Prototypes\r
 //\r
-STATIC \r
 EFI_STATUS\r
 EFIAPI\r
 PcatRootBridgeIoMemRW (\r
@@ -203,7 +182,7 @@ PcatRootBridgeIoMemRW (
 \r
 EFI_STATUS\r
 PcatRootBridgeIoConstructor (\r
-       IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *Protocol,\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *Protocol,\r
   IN UINTN                            SegmentNumber\r
   )\r
 /*++\r
@@ -270,14 +249,14 @@ PcatRootBridgeIoPollMem (
 {\r
   EFI_STATUS  Status;\r
   UINT64      NumberOfTicks;\r
-  UINT      Remainder;\r
+  UINT32      Remainder;\r
 \r
   if (Result == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
 \r
-  if (Width < 0 || Width > EfiPciWidthUint64) {\r
+  if ((UINT32)Width > EfiPciWidthUint64) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   //\r
@@ -291,7 +270,9 @@ PcatRootBridgeIoPollMem (
     return EFI_SUCCESS;\r
   }\r
 \r
-  if ( Delay != 0 ) {\r
+  if (Delay == 0) {\r
+    return EFI_SUCCESS;\r
+  } else {\r
 \r
     NumberOfTicks = DivU64x32Remainder (Delay, 100, &Remainder);\r
     if ( Remainder !=0 ) {\r
@@ -332,13 +313,13 @@ PcatRootBridgeIoPollIo (
 {\r
   EFI_STATUS  Status;\r
   UINT64      NumberOfTicks;\r
-  UINTN       Remainder;\r
+  UINT32       Remainder;\r
 \r
   if (Result == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (Width < 0 || Width > EfiPciWidthUint64) {\r
+  if ((UINT32)Width > EfiPciWidthUint64) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   //\r
@@ -352,7 +333,9 @@ PcatRootBridgeIoPollIo (
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (Delay != 0) {\r
+  if (Delay == 0) {\r
+    return EFI_SUCCESS;\r
+  } else {\r
 \r
     NumberOfTicks = DivU64x32Remainder (Delay, 100, &Remainder);\r
     if ( Remainder !=0 ) {\r
@@ -429,7 +412,7 @@ PcatRootBridgeIoMemRead (
 \r
   In.buf  = Buffer;\r
   Out.buf = (VOID *)(UINTN) Address;\r
-  if (Width >= EfiPciWidthUint8 && Width <= EfiPciWidthUint64) {\r
+  if ((UINT32)Width <= EfiPciWidthUint64) {\r
     return PcatRootBridgeIoMemRW (Width, Count, TRUE, In, TRUE, Out);\r
   }\r
   if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) {\r
@@ -476,7 +459,7 @@ PcatRootBridgeIoMemWrite (
 \r
   In.buf  = (VOID *)(UINTN) Address;\r
   Out.buf = Buffer;\r
-  if (Width >= EfiPciWidthUint8 && Width <= EfiPciWidthUint64) {\r
+  if ((UINT32)Width <= EfiPciWidthUint64) {\r
     return PcatRootBridgeIoMemRW (Width, Count, TRUE, In, TRUE, Out);\r
   }\r
   if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) {\r
@@ -506,7 +489,7 @@ PcatRootBridgeIoCopyMem (
   UINTN       Index;\r
   UINT64      Result;\r
 \r
-  if (Width < 0 || Width > EfiPciWidthUint64) {\r
+  if ((UINT32)Width > EfiPciWidthUint64) {\r
     return EFI_INVALID_PARAMETER;\r
   }       \r
 \r
@@ -626,7 +609,7 @@ PcatRootBridgeIoMap (
   //\r
   // Make sure that Operation is valid\r
   //\r
-  if (Operation < 0 || Operation >= EfiPciOperationMaximum) {\r
+  if ((UINT32)Operation >= EfiPciOperationMaximum) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -636,7 +619,7 @@ PcatRootBridgeIoMap (
   // map the DMA transfer to a buffer below 4GB.\r
   //\r
   PhysicalAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress;\r
-  if ((PhysicalAddress + *NumberOfBytes) > 0x100000000) {\r
+  if ((PhysicalAddress + *NumberOfBytes) > 0x100000000ULL) {\r
 \r
     //\r
     // Common Buffer operations can not be remapped.  If the common buffer\r
@@ -654,7 +637,7 @@ PcatRootBridgeIoMap (
     Status = gBS->AllocatePool (\r
                     EfiBootServicesData, \r
                     sizeof(MAP_INFO), \r
-                    &MapInfo\r
+                    (VOID **)&MapInfo\r
                     );\r
     if (EFI_ERROR (Status)) {\r
       *NumberOfBytes = 0;\r
@@ -704,10 +687,10 @@ PcatRootBridgeIoMap (
     }\r
 \r
 \r
-       Status =gBS->AllocatePool (\r
+  Status =gBS->AllocatePool (\r
                     EfiBootServicesData, \r
                     sizeof(MAP_INFO_INSTANCE), \r
-                    &MapInstance\r
+                    (VOID **)&MapInstance\r
                     );                    \r
     if (EFI_ERROR(Status)) {\r
       gBS->FreePages (MapInfo->MappedHostAddress,MapInfo->NumberOfPages);\r
@@ -720,7 +703,7 @@ PcatRootBridgeIoMap (
     PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);\r
     InsertTailList(&PrivateData->MapInfo,&MapInstance->Link);\r
     \r
-       //\r
+  //\r
     // The DeviceAddress is the address of the maped buffer below 4GB\r
     //\r
     *DeviceAddress = MapInfo->MappedHostAddress;\r
@@ -767,14 +750,14 @@ PcatRootBridgeIoUnmap (
     //\r
     MapInfo = (MAP_INFO *)Mapping;\r
 \r
-       for (Link = PrivateData->MapInfo.ForwardLink; Link != &PrivateData->MapInfo; Link = Link->ForwardLink) {\r
-       if (((MAP_INFO_INSTANCE*)Link)->Map == MapInfo)\r
-               break;\r
+  for (Link = PrivateData->MapInfo.ForwardLink; Link != &PrivateData->MapInfo; Link = Link->ForwardLink) {\r
+      if (((MAP_INFO_INSTANCE*)Link)->Map == MapInfo)\r
+        break;\r
     }\r
 \r
     if (Link == &PrivateData->MapInfo) {\r
-       return EFI_INVALID_PARAMETER;\r
-       }\r
+      return EFI_INVALID_PARAMETER;\r
+  }\r
 \r
     RemoveEntryList(Link);\r
     ((MAP_INFO_INSTANCE*)Link)->Map = NULL;\r
@@ -869,7 +852,7 @@ PcatRootBridgeIoFreeBuffer (
 {\r
 \r
   if( HostAddress == NULL ){\r
-        return EFI_INVALID_PARAMETER;\r
+     return EFI_INVALID_PARAMETER;\r
   } \r
   return gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress, Pages);\r
 }\r
@@ -979,7 +962,6 @@ PcatRootBridgeIoConfiguration (
 // Internal function\r
 //\r
 \r
-STATIC \r
 EFI_STATUS\r
 EFIAPI\r
 PcatRootBridgeIoMemRW (\r
@@ -1015,7 +997,7 @@ Returns:
   UINTN  OutStride;\r
 \r
 \r
-  Width     = Width & 0x03;\r
+  Width     = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) (Width & 0x03);\r
   Stride    = (UINTN)1 << Width;\r
   InStride  = InStrideFlag  ? Stride : 0;\r
   OutStride = OutStrideFlag ? Stride : 0;\r