]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/SmmPciLibPciRootBridgeIo/PciLib.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / SmmPciLibPciRootBridgeIo / PciLib.c
index d8b7e72dbda94a83ec6a037ff4ec7d41396b286b..1503ebb3fdf2a3072ae16e5964c477d2e48e91cb 100644 (file)
@@ -1,15 +1,8 @@
 /** @file\r
   PCI Library using SMM PCI Root Bridge I/O Protocol.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials are\r
-  licensed and made available under the terms and conditions of\r
-  the BSD License which accompanies this distribution.  The full\r
-  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
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 #include <PiSmm.h>\r
@@ -19,7 +12,6 @@
 #include <Library/BaseLib.h>\r
 #include <Library/SmmServicesTableLib.h>\r
 \r
-\r
 /**\r
   Assert the validity of a PCI address. A valid PCI address should contain 1's\r
   only in the low 28 bits.\r
@@ -28,7 +20,7 @@
   @param  M Additional bits to assert to be zero.\r
 \r
 **/\r
-#define ASSERT_INVALID_PCI_ADDRESS(A,M) \\r
+#define ASSERT_INVALID_PCI_ADDRESS(A, M) \\r
   ASSERT (((A) & (~0xfffffff | (M))) == 0)\r
 \r
 /**\r
   ((((A) << 4) & 0xff000000) | (((A) >> 4) & 0x00000700) | (((A) << 1) & 0x001f0000) | (LShiftU64((A) & 0xfff, 32)))\r
 \r
 //\r
-// Global varible to cache pointer to PCI Root Bridge I/O protocol.\r
+// Global variable to cache pointer to PCI Root Bridge I/O protocol.\r
 //\r
-EFI_SMM_PCI_ROOT_BRIDGE_IO_PROTOCOL      *mSmmPciRootBridgeIo = NULL; \r
+EFI_SMM_PCI_ROOT_BRIDGE_IO_PROTOCOL  *mSmmPciRootBridgeIo = NULL;\r
 \r
 /**\r
   The constructor function caches the pointer to PCI Root Bridge I/O protocol.\r
-  \r
+\r
   The constructor function locates PCI Root Bridge I/O protocol from protocol database.\r
-  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
+  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
 \r
   @param  ImageHandle   The firmware allocated handle for the EFI image.\r
   @param  SystemTable   A pointer to the EFI System Table.\r
-  \r
+\r
   @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PciLibConstructor (\r
-  IN EFI_HANDLE                ImageHandle,\r
-  IN EFI_SYSTEM_TABLE          *SystemTable\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
   EFI_STATUS  Status;\r
-  \r
-  Status = gSmst->SmmLocateProtocol (&gEfiSmmPciRootBridgeIoProtocolGuid, NULL, (VOID**) &mSmmPciRootBridgeIo);\r
+\r
+  Status = gSmst->SmmLocateProtocol (&gEfiSmmPciRootBridgeIoProtocolGuid, NULL, (VOID **)&mSmmPciRootBridgeIo);\r
   ASSERT_EFI_ERROR (Status);\r
   ASSERT (mSmmPciRootBridgeIo != NULL);\r
 \r
@@ -97,12 +89,12 @@ SmmPciLibPciRootBridgeIoReadWorker (
   UINT32  Data;\r
 \r
   mSmmPciRootBridgeIo->Pci.Read (\r
-                          mSmmPciRootBridgeIo,\r
-                          Width,\r
-                          PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS (Address),\r
-                          1,\r
-                          &Data\r
-                          );\r
+                             mSmmPciRootBridgeIo,\r
+                             Width,\r
+                             PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS (Address),\r
+                             1,\r
+                             &Data\r
+                             );\r
 \r
   return Data;\r
 }\r
@@ -112,7 +104,7 @@ SmmPciLibPciRootBridgeIoReadWorker (
 \r
   This function wraps EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Pci.Write() service.\r
   It writes the PCI configuration register specified by Address with the\r
-  value specified by Data. The width of data is specifed by Width.\r
+  value specified by Data. The width of data is specified by Width.\r
   Data is returned.\r
 \r
   @param  Address The address that encodes the PCI Bus, Device, Function and\r
@@ -131,29 +123,29 @@ SmmPciLibPciRootBridgeIoWriteWorker (
   )\r
 {\r
   mSmmPciRootBridgeIo->Pci.Write (\r
-                          mSmmPciRootBridgeIo,\r
-                          Width,\r
-                          PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS (Address),\r
-                          1,\r
-                          &Data\r
-                          );\r
+                             mSmmPciRootBridgeIo,\r
+                             Width,\r
+                             PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS (Address),\r
+                             1,\r
+                             &Data\r
+                             );\r
   return Data;\r
 }\r
 \r
 /**\r
-  Registers a PCI device so PCI configuration registers may be accessed after \r
+  Registers a PCI device so PCI configuration registers may be accessed after\r
   SetVirtualAddressMap().\r
-  \r
-  Registers the PCI device specified by Address so all the PCI configuration registers \r
+\r
+  Registers the PCI device specified by Address so all the PCI configuration registers\r
   associated with that PCI device may be accessed after SetVirtualAddressMap() is called.\r
-  \r
+\r
   If Address > 0x0FFFFFFF, then ASSERT().\r
 \r
   @param  Address The address that encodes the PCI Bus, Device, Function and\r
                   Register.\r
-  \r
+\r
   @retval RETURN_SUCCESS           The PCI device was registered for runtime access.\r
-  @retval RETURN_UNSUPPORTED       An attempt was made to call this function \r
+  @retval RETURN_UNSUPPORTED       An attempt was made to call this function\r
                                    after ExitBootServices().\r
   @retval RETURN_UNSUPPORTED       The resources required to access the PCI device\r
                                    at runtime could not be mapped.\r
@@ -189,12 +181,12 @@ PciRegisterForRuntimeAccess (
 UINT8\r
 EFIAPI\r
 PciRead8 (\r
-  IN      UINTN                     Address\r
+  IN      UINTN  Address\r
   )\r
 {\r
   ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
 \r
-  return (UINT8) SmmPciLibPciRootBridgeIoReadWorker (Address, EfiPciWidthUint8);\r
+  return (UINT8)SmmPciLibPciRootBridgeIoReadWorker (Address, EfiPciWidthUint8);\r
 }\r
 \r
 /**\r
@@ -216,13 +208,13 @@ PciRead8 (
 UINT8\r
 EFIAPI\r
 PciWrite8 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT8                     Value\r
+  IN      UINTN  Address,\r
+  IN      UINT8  Value\r
   )\r
 {\r
   ASSERT_INVALID_PCI_ADDRESS (Address, 0);\r
 \r
-  return (UINT8) SmmPciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint8, Value);\r
+  return (UINT8)SmmPciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint8, Value);\r
 }\r
 \r
 /**\r
@@ -248,11 +240,11 @@ PciWrite8 (
 UINT8\r
 EFIAPI\r
 PciOr8 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT8                     OrData\r
+  IN      UINTN  Address,\r
+  IN      UINT8  OrData\r
   )\r
 {\r
-  return PciWrite8 (Address, (UINT8) (PciRead8 (Address) | OrData));\r
+  return PciWrite8 (Address, (UINT8)(PciRead8 (Address) | OrData));\r
 }\r
 \r
 /**\r
@@ -278,11 +270,11 @@ PciOr8 (
 UINT8\r
 EFIAPI\r
 PciAnd8 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT8                     AndData\r
+  IN      UINTN  Address,\r
+  IN      UINT8  AndData\r
   )\r
 {\r
-  return PciWrite8 (Address, (UINT8) (PciRead8 (Address) & AndData));\r
+  return PciWrite8 (Address, (UINT8)(PciRead8 (Address) & AndData));\r
 }\r
 \r
 /**\r
@@ -310,12 +302,12 @@ PciAnd8 (
 UINT8\r
 EFIAPI\r
 PciAndThenOr8 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT8                     AndData,\r
-  IN      UINT8                     OrData\r
+  IN      UINTN  Address,\r
+  IN      UINT8  AndData,\r
+  IN      UINT8  OrData\r
   )\r
 {\r
-  return PciWrite8 (Address, (UINT8) ((PciRead8 (Address) & AndData) | OrData));\r
+  return PciWrite8 (Address, (UINT8)((PciRead8 (Address) & AndData) | OrData));\r
 }\r
 \r
 /**\r
@@ -342,9 +334,9 @@ PciAndThenOr8 (
 UINT8\r
 EFIAPI\r
 PciBitFieldRead8 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit\r
+  IN      UINTN  Address,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit\r
   )\r
 {\r
   return BitFieldRead8 (PciRead8 (Address), StartBit, EndBit);\r
@@ -362,6 +354,7 @@ PciBitFieldRead8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -376,10 +369,10 @@ PciBitFieldRead8 (
 UINT8\r
 EFIAPI\r
 PciBitFieldWrite8 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT8                     Value\r
+  IN      UINTN  Address,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit,\r
+  IN      UINT8  Value\r
   )\r
 {\r
   return PciWrite8 (\r
@@ -403,6 +396,7 @@ PciBitFieldWrite8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -417,10 +411,10 @@ PciBitFieldWrite8 (
 UINT8\r
 EFIAPI\r
 PciBitFieldOr8 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT8                     OrData\r
+  IN      UINTN  Address,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit,\r
+  IN      UINT8  OrData\r
   )\r
 {\r
   return PciWrite8 (\r
@@ -444,6 +438,7 @@ PciBitFieldOr8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -458,10 +453,10 @@ PciBitFieldOr8 (
 UINT8\r
 EFIAPI\r
 PciBitFieldAnd8 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT8                     AndData\r
+  IN      UINTN  Address,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit,\r
+  IN      UINT8  AndData\r
   )\r
 {\r
   return PciWrite8 (\r
@@ -487,6 +482,8 @@ PciBitFieldAnd8 (
   If StartBit is greater than 7, then ASSERT().\r
   If EndBit is greater than 7, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -502,11 +499,11 @@ PciBitFieldAnd8 (
 UINT8\r
 EFIAPI\r
 PciBitFieldAndThenOr8 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT8                     AndData,\r
-  IN      UINT8                     OrData\r
+  IN      UINTN  Address,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit,\r
+  IN      UINT8  AndData,\r
+  IN      UINT8  OrData\r
   )\r
 {\r
   return PciWrite8 (\r
@@ -534,12 +531,12 @@ PciBitFieldAndThenOr8 (
 UINT16\r
 EFIAPI\r
 PciRead16 (\r
-  IN      UINTN                     Address\r
+  IN      UINTN  Address\r
   )\r
 {\r
   ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
 \r
-  return (UINT16) SmmPciLibPciRootBridgeIoReadWorker (Address, EfiPciWidthUint16);\r
+  return (UINT16)SmmPciLibPciRootBridgeIoReadWorker (Address, EfiPciWidthUint16);\r
 }\r
 \r
 /**\r
@@ -562,13 +559,13 @@ PciRead16 (
 UINT16\r
 EFIAPI\r
 PciWrite16 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT16                    Value\r
+  IN      UINTN   Address,\r
+  IN      UINT16  Value\r
   )\r
 {\r
   ASSERT_INVALID_PCI_ADDRESS (Address, 1);\r
 \r
-  return (UINT16) SmmPciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint16, Value);\r
+  return (UINT16)SmmPciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint16, Value);\r
 }\r
 \r
 /**\r
@@ -595,11 +592,11 @@ PciWrite16 (
 UINT16\r
 EFIAPI\r
 PciOr16 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT16                    OrData\r
+  IN      UINTN   Address,\r
+  IN      UINT16  OrData\r
   )\r
 {\r
-  return PciWrite16 (Address, (UINT16) (PciRead16 (Address) | OrData));\r
+  return PciWrite16 (Address, (UINT16)(PciRead16 (Address) | OrData));\r
 }\r
 \r
 /**\r
@@ -626,11 +623,11 @@ PciOr16 (
 UINT16\r
 EFIAPI\r
 PciAnd16 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT16                    AndData\r
+  IN      UINTN   Address,\r
+  IN      UINT16  AndData\r
   )\r
 {\r
-  return PciWrite16 (Address, (UINT16) (PciRead16 (Address) & AndData));\r
+  return PciWrite16 (Address, (UINT16)(PciRead16 (Address) & AndData));\r
 }\r
 \r
 /**\r
@@ -659,12 +656,12 @@ PciAnd16 (
 UINT16\r
 EFIAPI\r
 PciAndThenOr16 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT16                    AndData,\r
-  IN      UINT16                    OrData\r
+  IN      UINTN   Address,\r
+  IN      UINT16  AndData,\r
+  IN      UINT16  OrData\r
   )\r
 {\r
-  return PciWrite16 (Address, (UINT16) ((PciRead16 (Address) & AndData) | OrData));\r
+  return PciWrite16 (Address, (UINT16)((PciRead16 (Address) & AndData) | OrData));\r
 }\r
 \r
 /**\r
@@ -692,9 +689,9 @@ PciAndThenOr16 (
 UINT16\r
 EFIAPI\r
 PciBitFieldRead16 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit\r
+  IN      UINTN  Address,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit\r
   )\r
 {\r
   return BitFieldRead16 (PciRead16 (Address), StartBit, EndBit);\r
@@ -713,6 +710,7 @@ PciBitFieldRead16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -727,10 +725,10 @@ PciBitFieldRead16 (
 UINT16\r
 EFIAPI\r
 PciBitFieldWrite16 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT16                    Value\r
+  IN      UINTN   Address,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT16  Value\r
   )\r
 {\r
   return PciWrite16 (\r
@@ -755,6 +753,7 @@ PciBitFieldWrite16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -769,10 +768,10 @@ PciBitFieldWrite16 (
 UINT16\r
 EFIAPI\r
 PciBitFieldOr16 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT16                    OrData\r
+  IN      UINTN   Address,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT16  OrData\r
   )\r
 {\r
   return PciWrite16 (\r
@@ -797,6 +796,7 @@ PciBitFieldOr16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -811,10 +811,10 @@ PciBitFieldOr16 (
 UINT16\r
 EFIAPI\r
 PciBitFieldAnd16 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT16                    AndData\r
+  IN      UINTN   Address,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT16  AndData\r
   )\r
 {\r
   return PciWrite16 (\r
@@ -841,6 +841,8 @@ PciBitFieldAnd16 (
   If StartBit is greater than 15, then ASSERT().\r
   If EndBit is greater than 15, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -856,11 +858,11 @@ PciBitFieldAnd16 (
 UINT16\r
 EFIAPI\r
 PciBitFieldAndThenOr16 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT16                    AndData,\r
-  IN      UINT16                    OrData\r
+  IN      UINTN   Address,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT16  AndData,\r
+  IN      UINT16  OrData\r
   )\r
 {\r
   return PciWrite16 (\r
@@ -888,7 +890,7 @@ PciBitFieldAndThenOr16 (
 UINT32\r
 EFIAPI\r
 PciRead32 (\r
-  IN      UINTN                     Address\r
+  IN      UINTN  Address\r
   )\r
 {\r
   ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
@@ -916,8 +918,8 @@ PciRead32 (
 UINT32\r
 EFIAPI\r
 PciWrite32 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT32                    Value\r
+  IN      UINTN   Address,\r
+  IN      UINT32  Value\r
   )\r
 {\r
   ASSERT_INVALID_PCI_ADDRESS (Address, 3);\r
@@ -949,8 +951,8 @@ PciWrite32 (
 UINT32\r
 EFIAPI\r
 PciOr32 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT32                    OrData\r
+  IN      UINTN   Address,\r
+  IN      UINT32  OrData\r
   )\r
 {\r
   return PciWrite32 (Address, PciRead32 (Address) | OrData);\r
@@ -980,8 +982,8 @@ PciOr32 (
 UINT32\r
 EFIAPI\r
 PciAnd32 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT32                    AndData\r
+  IN      UINTN   Address,\r
+  IN      UINT32  AndData\r
   )\r
 {\r
   return PciWrite32 (Address, PciRead32 (Address) & AndData);\r
@@ -1013,9 +1015,9 @@ PciAnd32 (
 UINT32\r
 EFIAPI\r
 PciAndThenOr32 (\r
-  IN      UINTN                     Address,\r
-  IN      UINT32                    AndData,\r
-  IN      UINT32                    OrData\r
+  IN      UINTN   Address,\r
+  IN      UINT32  AndData,\r
+  IN      UINT32  OrData\r
   )\r
 {\r
   return PciWrite32 (Address, (PciRead32 (Address) & AndData) | OrData);\r
@@ -1046,9 +1048,9 @@ PciAndThenOr32 (
 UINT32\r
 EFIAPI\r
 PciBitFieldRead32 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit\r
+  IN      UINTN  Address,\r
+  IN      UINTN  StartBit,\r
+  IN      UINTN  EndBit\r
   )\r
 {\r
   return BitFieldRead32 (PciRead32 (Address), StartBit, EndBit);\r
@@ -1067,6 +1069,7 @@ PciBitFieldRead32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1081,10 +1084,10 @@ PciBitFieldRead32 (
 UINT32\r
 EFIAPI\r
 PciBitFieldWrite32 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    Value\r
+  IN      UINTN   Address,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT32  Value\r
   )\r
 {\r
   return PciWrite32 (\r
@@ -1109,6 +1112,7 @@ PciBitFieldWrite32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1123,10 +1127,10 @@ PciBitFieldWrite32 (
 UINT32\r
 EFIAPI\r
 PciBitFieldOr32 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    OrData\r
+  IN      UINTN   Address,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT32  OrData\r
   )\r
 {\r
   return PciWrite32 (\r
@@ -1151,6 +1155,7 @@ PciBitFieldOr32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1165,10 +1170,10 @@ PciBitFieldOr32 (
 UINT32\r
 EFIAPI\r
 PciBitFieldAnd32 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    AndData\r
+  IN      UINTN   Address,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT32  AndData\r
   )\r
 {\r
   return PciWrite32 (\r
@@ -1195,6 +1200,8 @@ PciBitFieldAnd32 (
   If StartBit is greater than 31, then ASSERT().\r
   If EndBit is greater than 31, then ASSERT().\r
   If EndBit is less than StartBit, then ASSERT().\r
+  If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
+  If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
 \r
   @param  Address   The PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1210,11 +1217,11 @@ PciBitFieldAnd32 (
 UINT32\r
 EFIAPI\r
 PciBitFieldAndThenOr32 (\r
-  IN      UINTN                     Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    AndData,\r
-  IN      UINT32                    OrData\r
+  IN      UINTN   Address,\r
+  IN      UINTN   StartBit,\r
+  IN      UINTN   EndBit,\r
+  IN      UINT32  AndData,\r
+  IN      UINT32  OrData\r
   )\r
 {\r
   return PciWrite32 (\r
@@ -1230,7 +1237,7 @@ PciBitFieldAndThenOr32 (
   Size into the buffer specified by Buffer. This function only allows the PCI\r
   configuration registers from a single PCI function to be read. Size is\r
   returned. When possible 32-bit PCI configuration read cycles are used to read\r
-  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
+  from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
   and 16-bit PCI configuration read cycles may be used at the beginning and the\r
   end of the range.\r
 \r
@@ -1249,12 +1256,12 @@ PciBitFieldAndThenOr32 (
 UINTN\r
 EFIAPI\r
 PciReadBuffer (\r
-  IN      UINTN                     StartAddress,\r
-  IN      UINTN                     Size,\r
-  OUT     VOID                      *Buffer\r
+  IN      UINTN  StartAddress,\r
+  IN      UINTN  Size,\r
+  OUT     VOID   *Buffer\r
   )\r
 {\r
-  UINTN                             ReturnValue;\r
+  UINTN  ReturnValue;\r
 \r
   ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
   ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
@@ -1275,19 +1282,19 @@ PciReadBuffer (
     // Read a byte if StartAddress is byte aligned\r
     //\r
     *(volatile UINT8 *)Buffer = PciRead8 (StartAddress);\r
-    StartAddress += sizeof (UINT8);\r
-    Size -= sizeof (UINT8);\r
-    Buffer = (UINT8*)Buffer + 1;\r
+    StartAddress             += sizeof (UINT8);\r
+    Size                     -= sizeof (UINT8);\r
+    Buffer                    = (UINT8 *)Buffer + 1;\r
   }\r
 \r
-  if (Size >= sizeof (UINT16) && (StartAddress & BIT1) != 0) {\r
+  if ((Size >= sizeof (UINT16)) && ((StartAddress & BIT1) != 0)) {\r
     //\r
     // Read a word if StartAddress is word aligned\r
     //\r
     WriteUnaligned16 (Buffer, PciRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
-    Size -= sizeof (UINT16);\r
-    Buffer = (UINT16*)Buffer + 1;\r
+    Size         -= sizeof (UINT16);\r
+    Buffer        = (UINT16 *)Buffer + 1;\r
   }\r
 \r
   while (Size >= sizeof (UINT32)) {\r
@@ -1296,8 +1303,8 @@ PciReadBuffer (
     //\r
     WriteUnaligned32 (Buffer, PciRead32 (StartAddress));\r
     StartAddress += sizeof (UINT32);\r
-    Size -= sizeof (UINT32);\r
-    Buffer = (UINT32*)Buffer + 1;\r
+    Size         -= sizeof (UINT32);\r
+    Buffer        = (UINT32 *)Buffer + 1;\r
   }\r
 \r
   if (Size >= sizeof (UINT16)) {\r
@@ -1306,8 +1313,8 @@ PciReadBuffer (
     //\r
     WriteUnaligned16 (Buffer, PciRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
-    Size -= sizeof (UINT16);\r
-    Buffer = (UINT16*)Buffer + 1;\r
+    Size         -= sizeof (UINT16);\r
+    Buffer        = (UINT16 *)Buffer + 1;\r
   }\r
 \r
   if (Size >= sizeof (UINT8)) {\r
@@ -1328,7 +1335,7 @@ PciReadBuffer (
   Size from the buffer specified by Buffer. This function only allows the PCI\r
   configuration registers from a single PCI function to be written. Size is\r
   returned. When possible 32-bit PCI configuration write cycles are used to\r
-  write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
+  write from StartAddress to StartAddress + Size. Due to alignment restrictions,\r
   8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
   and the end of the range.\r
 \r
@@ -1347,12 +1354,12 @@ PciReadBuffer (
 UINTN\r
 EFIAPI\r
 PciWriteBuffer (\r
-  IN      UINTN                     StartAddress,\r
-  IN      UINTN                     Size,\r
-  IN      VOID                      *Buffer\r
+  IN      UINTN  StartAddress,\r
+  IN      UINTN  Size,\r
+  IN      VOID   *Buffer\r
   )\r
 {\r
-  UINTN                             ReturnValue;\r
+  UINTN  ReturnValue;\r
 \r
   ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);\r
   ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);\r
@@ -1372,20 +1379,20 @@ PciWriteBuffer (
     //\r
     // Write a byte if StartAddress is byte aligned\r
     //\r
-    PciWrite8 (StartAddress, *(UINT8*)Buffer);\r
+    PciWrite8 (StartAddress, *(UINT8 *)Buffer);\r
     StartAddress += sizeof (UINT8);\r
-    Size -= sizeof (UINT8);\r
-    Buffer = (UINT8*)Buffer + 1;\r
+    Size         -= sizeof (UINT8);\r
+    Buffer        = (UINT8 *)Buffer + 1;\r
   }\r
 \r
-  if (Size >= sizeof (UINT16) && (StartAddress & BIT1) != 0) {\r
+  if ((Size >= sizeof (UINT16)) && ((StartAddress & BIT1) != 0)) {\r
     //\r
     // Write a word if StartAddress is word aligned\r
     //\r
     PciWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
-    Size -= sizeof (UINT16);\r
-    Buffer = (UINT16*)Buffer + 1;\r
+    Size         -= sizeof (UINT16);\r
+    Buffer        = (UINT16 *)Buffer + 1;\r
   }\r
 \r
   while (Size >= sizeof (UINT32)) {\r
@@ -1394,8 +1401,8 @@ PciWriteBuffer (
     //\r
     PciWrite32 (StartAddress, ReadUnaligned32 (Buffer));\r
     StartAddress += sizeof (UINT32);\r
-    Size -= sizeof (UINT32);\r
-    Buffer = (UINT32*)Buffer + 1;\r
+    Size         -= sizeof (UINT32);\r
+    Buffer        = (UINT32 *)Buffer + 1;\r
   }\r
 \r
   if (Size >= sizeof (UINT16)) {\r
@@ -1404,15 +1411,15 @@ PciWriteBuffer (
     //\r
     PciWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
-    Size -= sizeof (UINT16);\r
-    Buffer = (UINT16*)Buffer + 1;\r
+    Size         -= sizeof (UINT16);\r
+    Buffer        = (UINT16 *)Buffer + 1;\r
   }\r
 \r
   if (Size >= sizeof (UINT8)) {\r
     //\r
     // Write the last remaining byte if exist\r
     //\r
-    PciWrite8 (StartAddress, *(UINT8*)Buffer);\r
+    PciWrite8 (StartAddress, *(UINT8 *)Buffer);\r
   }\r
 \r
   return ReturnValue;\r