]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiPciSegmentLibPciRootBridgeIo/PciSegmentLib.c
MdePkg/PciSegmentLib: Fix typo in function header comments
[mirror_edk2.git] / MdePkg / Library / UefiPciSegmentLibPciRootBridgeIo / PciSegmentLib.c
index cb8991e2da7dd1b56827b3d6337d9b521c25161f..7e57ec21f9695c305541a23e78e9d42733eb51b6 100644 (file)
@@ -1,12 +1,12 @@
 /** @file\r
   PCI Segment Library implementation using PCI Root Bridge I/O Protocol.\r
 \r
-  Copyright (c) 2007 - 2008, Intel Corporation All rights\r
-  reserved. This program and the accompanying materials are\r
+  Copyright (c) 2007 - 2017, 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
+  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
 #include "PciSegmentLib.h"\r
 \r
 //\r
-// Global varible to record data of PCI Root Bridge I/O Protcol instances\r
+// Global variable to record data of PCI Root Bridge I/O Protocol instances\r
 //\r
 PCI_ROOT_BRIDGE_DATA   *mPciRootBridgeData     = NULL;\r
 UINTN                  mNumberOfPciRootBridges = 0;\r
 \r
 /**\r
-  The constructor function caches data of PCI Root Bridge I/O Protcol instances.\r
+  The constructor function caches data of PCI Root Bridge I/O Protocol instances.\r
   \r
   The constructor function locates PCI Root Bridge I/O protocol instances,\r
   and caches the protocol instances, together with their segment numbers and bus ranges.\r
@@ -131,7 +131,7 @@ PciSegmentLibDestructor (
   This internal function extracts segment number and bus number data from address, and\r
   retrieves the corresponding PCI Root Bridge I/O Protocol instance.\r
 \r
-  @param  Address Address that encodes the Segment, PCI Bus, Device, Function and\r
+  @param  Address The address that encodes the Segment, PCI Bus, Device, Function and\r
                   Register.\r
 \r
   @return The address for PCI Root Bridge I/O Protocol.\r
@@ -171,7 +171,7 @@ PciSegmentLibSearchForRootBridge (
   It reads and returns the PCI configuration register specified by Address,\r
   the width of data is specified by Width.\r
 \r
-  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+  @param  Address The address that encodes the PCI Bus, Device, Function and\r
                   Register.\r
   @param  Width   Width of data to read\r
 \r
@@ -209,7 +209,7 @@ DxePciSegmentLibPciRootBridgeIoReadWorker (
   value specified by Data. The width of data is specifed by Width.\r
   Data is returned.\r
 \r
-  @param  Address Address that encodes the PCI Bus, Device, Function and\r
+  @param  Address The address that encodes the PCI Bus, Device, Function and\r
                   Register.\r
   @param  Width   Width of data to write\r
   @param  Data    The value to write.\r
@@ -244,7 +244,7 @@ DxePciSegmentLibPciRootBridgeIoWriteWorker (
   Register a PCI device so PCI configuration registers may be accessed after \r
   SetVirtualAddressMap().\r
   \r
-  If Address > 0x0FFFFFFF, then ASSERT().\r
+  If any reserved bits in Address are set, then ASSERT().\r
 \r
   @param  Address Address that encodes the PCI Bus, Device, Function and\r
                   Register.\r
@@ -264,6 +264,7 @@ PciSegmentRegisterForRuntimeAccess (
   IN UINTN  Address\r
   )\r
 {\r
+  ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0);\r
   return RETURN_UNSUPPORTED;\r
 }\r
 \r
@@ -271,21 +272,19 @@ PciSegmentRegisterForRuntimeAccess (
   Reads an 8-bit PCI configuration register.\r
 \r
   Reads and returns the 8-bit PCI configuration register specified by Address.\r
-  This function must guarantee that all PCI read and write operations are\r
-  serialized.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
 \r
-  @return The value read from the PCI configuration register.\r
+  @return The 8-bit PCI configuration register specified by Address.\r
 \r
 **/\r
 UINT8\r
 EFIAPI\r
 PciSegmentRead8 (\r
-  IN      UINT64                    Address\r
+  IN UINT64                    Address\r
   )\r
 {\r
   ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0);\r
@@ -296,15 +295,13 @@ PciSegmentRead8 (
 /**\r
   Writes an 8-bit PCI configuration register.\r
 \r
-  Writes the 8-bit PCI configuration register specified by Address with the\r
-  value specified by Value. Value is returned. This function must guarantee\r
-  that all PCI read and write operations are serialized.\r
+  Writes the 8-bit PCI configuration register specified by Address with the value specified by Value.\r
+  Value is returned.  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  Data    The value to write.\r
+  @param  Address     Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  Value       The value to write.\r
 \r
   @return The value written to the PCI configuration register.\r
 \r
@@ -312,103 +309,94 @@ PciSegmentRead8 (
 UINT8\r
 EFIAPI\r
 PciSegmentWrite8 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT8                     Data\r
+  IN UINT64                    Address,\r
+  IN UINT8                     Value\r
   )\r
 {\r
   ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0);\r
 \r
-  return (UINT8) DxePciSegmentLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint8, Data);\r
+  return (UINT8) DxePciSegmentLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint8, Value);\r
 }\r
 \r
 /**\r
-  Performs a bitwise inclusive OR of an 8-bit PCI configuration register with\r
-  an 8-bit value.\r
+  Performs a bitwise OR of an 8-bit PCI configuration register with an 8-bit value.\r
 \r
-  Reads the 8-bit PCI configuration register specified by Address, performs a\r
-  bitwise inclusive OR between the read result and the value specified by\r
-  OrData, and writes the result to the 8-bit PCI configuration register\r
-  specified by Address. The value written to the PCI configuration register is\r
-  returned. This function must guarantee that all PCI read and write operations\r
-  are serialized.\r
+  Reads the 8-bit PCI configuration register specified by Address,\r
+  performs a bitwise OR between the read result and the value specified by OrData,\r
+  and writes the result to the 8-bit PCI configuration register specified by Address.\r
+  The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  OrData  The value to OR with the PCI configuration register.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
 \r
-  @return The value written back to the PCI configuration register.\r
+  @return The value written to the PCI configuration register.\r
 \r
 **/\r
 UINT8\r
 EFIAPI\r
 PciSegmentOr8 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT8                     OrData\r
+  IN UINT64                    Address,\r
+  IN UINT8                     OrData\r
   )\r
 {\r
   return PciSegmentWrite8 (Address, (UINT8) (PciSegmentRead8 (Address) | OrData));\r
 }\r
 \r
 /**\r
-  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
-  value.\r
-\r
-  Reads the 8-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND between the read result and the value specified by AndData, and\r
-  writes the result to the 8-bit PCI configuration register specified by\r
-  Address. The value written to the PCI configuration register is returned.\r
-  This function must guarantee that all PCI read and write operations are\r
-  serialized.\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value.\r
 \r
+  Reads the 8-bit PCI configuration register specified by Address,\r
+  performs a bitwise AND between the read result and the value specified by AndData,\r
+  and writes the result to the 8-bit PCI configuration register specified by Address.\r
+  The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
   If any reserved bits in Address are set, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
 \r
-  @return The value written back to the PCI configuration register.\r
+  @return The value written to the PCI configuration register.\r
 \r
 **/\r
 UINT8\r
 EFIAPI\r
 PciSegmentAnd8 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT8                     AndData\r
+  IN UINT64                    Address,\r
+  IN UINT8                     AndData\r
   )\r
 {\r
   return PciSegmentWrite8 (Address, (UINT8) (PciSegmentRead8 (Address) & AndData));\r
 }\r
 \r
 /**\r
-  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit\r
-  value, followed a  bitwise inclusive OR with another 8-bit value.\r
+  Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value,\r
+  followed a  bitwise OR with another 8-bit value.\r
 \r
-  Reads the 8-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND between the read result and the value specified by AndData,\r
-  performs a bitwise inclusive OR between the result of the AND operation and\r
-  the value specified by OrData, and writes the result to the 8-bit PCI\r
-  configuration register specified by Address. The value written to the PCI\r
-  configuration register is returned. This function must guarantee that all PCI\r
-  read and write operations are serialized.\r
+  Reads the 8-bit PCI configuration register specified by Address,\r
+  performs a bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 8-bit PCI configuration register specified by Address.\r
+  The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  AndData The value to AND with the PCI configuration register.\r
-  @param  OrData  The value to OR with the result of the AND operation.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
 \r
-  @return The value written back to the PCI configuration register.\r
+  @return The value written to the PCI configuration register.\r
 \r
 **/\r
 UINT8\r
 EFIAPI\r
 PciSegmentAndThenOr8 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT8                     AndData,\r
-  IN      UINT8                     OrData\r
+  IN UINT64                    Address,\r
+  IN UINT8                     AndData,\r
+  IN UINT8                     OrData\r
   )\r
 {\r
   return PciSegmentWrite8 (Address, (UINT8) ((PciSegmentRead8 (Address) & AndData) | OrData));\r
@@ -438,9 +426,9 @@ PciSegmentAndThenOr8 (
 UINT8\r
 EFIAPI\r
 PciSegmentBitFieldRead8 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit\r
   )\r
 {\r
   return BitFieldRead8 (PciSegmentRead8 (Address), StartBit, EndBit);\r
@@ -458,6 +446,7 @@ PciSegmentBitFieldRead8 (
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -472,10 +461,10 @@ PciSegmentBitFieldRead8 (
 UINT8\r
 EFIAPI\r
 PciSegmentBitFieldWrite8 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT8                     Value\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT8                     Value\r
   )\r
 {\r
   return PciSegmentWrite8 (\r
@@ -489,7 +478,7 @@ PciSegmentBitFieldWrite8 (
   writes the result back to the bit field in the 8-bit port.\r
 \r
   Reads the 8-bit PCI configuration register specified by Address, performs a\r
-  bitwise inclusive OR between the read result and the value specified by\r
+  bitwise OR between the read result and the value specified by\r
   OrData, and writes the result to the 8-bit PCI configuration register\r
   specified by Address. The value written to the PCI configuration register is\r
   returned. This function must guarantee that all PCI read and write operations\r
@@ -499,6 +488,7 @@ PciSegmentBitFieldWrite8 (
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -513,10 +503,10 @@ PciSegmentBitFieldWrite8 (
 UINT8\r
 EFIAPI\r
 PciSegmentBitFieldOr8 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT8                     OrData\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT8                     OrData\r
   )\r
 {\r
   return PciSegmentWrite8 (\r
@@ -540,6 +530,7 @@ PciSegmentBitFieldOr8 (
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -554,10 +545,10 @@ PciSegmentBitFieldOr8 (
 UINT8\r
 EFIAPI\r
 PciSegmentBitFieldAnd8 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT8                     AndData\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT8                     AndData\r
   )\r
 {\r
   return PciSegmentWrite8 (\r
@@ -568,11 +559,10 @@ PciSegmentBitFieldAnd8 (
 \r
 /**\r
   Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
-  bitwise inclusive OR, and writes the result back to the bit field in the\r
-  8-bit port.\r
+  bitwise OR, and writes the result back to the bit field in the 8-bit port.\r
 \r
   Reads the 8-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  bitwise AND followed by a bitwise OR between the read result and\r
   the value specified by AndData, and writes the result to the 8-bit PCI\r
   configuration register specified by Address. The value written to the PCI\r
   configuration register is returned. This function must guarantee that all PCI\r
@@ -583,6 +573,8 @@ PciSegmentBitFieldAnd8 (
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -598,11 +590,11 @@ PciSegmentBitFieldAnd8 (
 UINT8\r
 EFIAPI\r
 PciSegmentBitFieldAndThenOr8 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT8                     AndData,\r
-  IN      UINT8                     OrData\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT8                     AndData,\r
+  IN UINT8                     OrData\r
   )\r
 {\r
   return PciSegmentWrite8 (\r
@@ -615,21 +607,20 @@ PciSegmentBitFieldAndThenOr8 (
   Reads a 16-bit PCI configuration register.\r
 \r
   Reads and returns the 16-bit PCI configuration register specified by Address.\r
-  This function must guarantee that all PCI read and write operations are\r
-  serialized.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
 \r
-  @return The value read from the PCI configuration register.\r
+  @return The 16-bit PCI configuration register specified by Address.\r
 \r
 **/\r
 UINT16\r
 EFIAPI\r
 PciSegmentRead16 (\r
-  IN      UINT64                    Address\r
+  IN UINT64                    Address\r
   )\r
 {\r
   ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 1);\r
@@ -640,43 +631,42 @@ PciSegmentRead16 (
 /**\r
   Writes a 16-bit PCI configuration register.\r
 \r
-  Writes the 16-bit PCI configuration register specified by Address with the\r
-  value specified by Value. Value is returned. This function must guarantee\r
-  that all PCI read and write operations are serialized.\r
+  Writes the 16-bit PCI configuration register specified by Address with the value specified by Value.\r
+  Value is returned.  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  Data    The value to write.\r
+  @param  Address     Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  Value       The value to write.\r
 \r
-  @return The value written to the PCI configuration register.\r
+  @return The parameter of Value.\r
 \r
 **/\r
 UINT16\r
 EFIAPI\r
 PciSegmentWrite16 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT16                    Data\r
+  IN UINT64                    Address,\r
+  IN UINT16                    Value\r
   )\r
 {\r
   ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 1);\r
 \r
-  return (UINT16) DxePciSegmentLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint16, Data);\r
+  return (UINT16) DxePciSegmentLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint16, Value);\r
 }\r
 \r
 /**\r
-  Performs a bitwise inclusive OR of a 16-bit PCI configuration register with\r
+  Performs a bitwise OR of a 16-bit PCI configuration register with\r
   a 16-bit value.\r
 \r
   Reads the 16-bit PCI configuration register specified by Address, performs a\r
-  bitwise inclusive OR between the read result and the value specified by\r
-  OrData, and writes the result to the 16-bit PCI configuration register\r
-  specified by Address. The value written to the PCI configuration register is\r
-  returned. This function must guarantee that all PCI read and write operations\r
-  are serialized.\r
+  bitwise OR between the read result and the value specified by OrData, and\r
+  writes the result to the 16-bit PCI configuration register specified by Address.\r
+  The value written to the PCI configuration register is returned. This function\r
+  must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
   @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
                   Register.\r
@@ -688,71 +678,68 @@ PciSegmentWrite16 (
 UINT16\r
 EFIAPI\r
 PciSegmentOr16 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT16                    OrData\r
+  IN UINT64                    Address,\r
+  IN UINT16                    OrData\r
   )\r
 {\r
   return PciSegmentWrite16 (Address, (UINT16) (PciSegmentRead16 (Address) | OrData));\r
 }\r
 \r
 /**\r
-  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
-  value.\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value.\r
 \r
-  Reads the 16-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND between the read result and the value specified by AndData, and\r
-  writes the result to the 16-bit PCI configuration register specified by\r
-  Address. The value written to the PCI configuration register is returned.\r
-  This function must guarantee that all PCI read and write operations are\r
-  serialized.\r
+  Reads the 16-bit PCI configuration register specified by Address,\r
+  performs a bitwise AND between the read result and the value specified by AndData,\r
+  and writes the result to the 16-bit PCI configuration register specified by Address.\r
+  The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
 \r
-  @return The value written back to the PCI configuration register.\r
+  @return The value written to the PCI configuration register.\r
 \r
 **/\r
 UINT16\r
 EFIAPI\r
 PciSegmentAnd16 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT16                    AndData\r
+  IN UINT64                    Address,\r
+  IN UINT16                    AndData\r
   )\r
 {\r
   return PciSegmentWrite16 (Address, (UINT16) (PciSegmentRead16 (Address) & AndData));\r
 }\r
 \r
 /**\r
-  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit\r
-  value, followed a  bitwise inclusive OR with another 16-bit value.\r
+  Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value,\r
+  followed a  bitwise OR with another 16-bit value.\r
 \r
-  Reads the 16-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND between the read result and the value specified by AndData,\r
-  performs a bitwise inclusive OR between the result of the AND operation and\r
-  the value specified by OrData, and writes the result to the 16-bit PCI\r
-  configuration register specified by Address. The value written to the PCI\r
-  configuration register is returned. This function must guarantee that all PCI\r
-  read and write operations are serialized.\r
+  Reads the 16-bit PCI configuration register specified by Address,\r
+  performs a bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 16-bit PCI configuration register specified by Address.\r
+  The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  AndData The value to AND with the PCI configuration register.\r
-  @param  OrData  The value to OR with the result of the AND operation.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
 \r
-  @return The value written back to the PCI configuration register.\r
+  @return The value written to the PCI configuration register.\r
 \r
 **/\r
 UINT16\r
 EFIAPI\r
 PciSegmentAndThenOr16 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT16                    AndData,\r
-  IN      UINT16                    OrData\r
+  IN UINT64                    Address,\r
+  IN UINT16                    AndData,\r
+  IN UINT16                    OrData\r
   )\r
 {\r
   return PciSegmentWrite16 (Address, (UINT16) ((PciSegmentRead16 (Address) & AndData) | OrData));\r
@@ -766,6 +753,7 @@ PciSegmentAndThenOr16 (
   returned.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
   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
@@ -782,9 +770,9 @@ PciSegmentAndThenOr16 (
 UINT16\r
 EFIAPI\r
 PciSegmentBitFieldRead16 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit\r
   )\r
 {\r
   return BitFieldRead16 (PciSegmentRead16 (Address), StartBit, EndBit);\r
@@ -799,9 +787,11 @@ PciSegmentBitFieldRead16 (
   16-bit register is returned.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -816,10 +806,10 @@ PciSegmentBitFieldRead16 (
 UINT16\r
 EFIAPI\r
 PciSegmentBitFieldWrite16 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT16                    Value\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT16                    Value\r
   )\r
 {\r
   return PciSegmentWrite16 (\r
@@ -829,20 +819,22 @@ PciSegmentBitFieldWrite16 (
 }\r
 \r
 /**\r
-  Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and\r
-  writes the result back to the bit field in the 16-bit port.\r
+  Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, writes\r
+  the result back to the bit field in the 16-bit port.\r
 \r
   Reads the 16-bit PCI configuration register specified by Address, performs a\r
-  bitwise inclusive OR between the read result and the value specified by\r
+  bitwise OR between the read result and the value specified by\r
   OrData, and writes the result to the 16-bit PCI configuration register\r
   specified by Address. The value written to the PCI configuration register is\r
   returned. This function must guarantee that all PCI read and write operations\r
   are serialized. Extra left bits in OrData are stripped.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -857,10 +849,10 @@ PciSegmentBitFieldWrite16 (
 UINT16\r
 EFIAPI\r
 PciSegmentBitFieldOr16 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT16                    OrData\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT16                    OrData\r
   )\r
 {\r
   return PciSegmentWrite16 (\r
@@ -871,7 +863,7 @@ PciSegmentBitFieldOr16 (
 \r
 /**\r
   Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r
-  AND, and writes the result back to the bit field in the 16-bit register.\r
+  AND, writes the result back to the bit field in the 16-bit register.\r
 \r
   Reads the 16-bit PCI configuration register specified by Address, performs a\r
   bitwise AND between the read result and the value specified by AndData, and\r
@@ -881,11 +873,13 @@ PciSegmentBitFieldOr16 (
   serialized. Extra left bits in AndData are stripped.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
   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   PCI configuration register to write.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
                     Range 0..15.\r
   @param  EndBit    The ordinal of the most significant bit in the bit field.\r
@@ -898,10 +892,10 @@ PciSegmentBitFieldOr16 (
 UINT16\r
 EFIAPI\r
 PciSegmentBitFieldAnd16 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT16                    AndData\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT16                    AndData\r
   )\r
 {\r
   return PciSegmentWrite16 (\r
@@ -912,11 +906,11 @@ PciSegmentBitFieldAnd16 (
 \r
 /**\r
   Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
-  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  bitwise OR, and writes the result back to the bit field in the\r
   16-bit port.\r
 \r
   Reads the 16-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  bitwise AND followed by a bitwise OR between the read result and\r
   the value specified by AndData, and writes the result to the 16-bit PCI\r
   configuration register specified by Address. The value written to the PCI\r
   configuration register is returned. This function must guarantee that all PCI\r
@@ -927,6 +921,8 @@ PciSegmentBitFieldAnd16 (
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -942,11 +938,11 @@ PciSegmentBitFieldAnd16 (
 UINT16\r
 EFIAPI\r
 PciSegmentBitFieldAndThenOr16 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT16                    AndData,\r
-  IN      UINT16                    OrData\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT16                    AndData,\r
+  IN UINT16                    OrData\r
   )\r
 {\r
   return PciSegmentWrite16 (\r
@@ -959,21 +955,20 @@ PciSegmentBitFieldAndThenOr16 (
   Reads a 32-bit PCI configuration register.\r
 \r
   Reads and returns the 32-bit PCI configuration register specified by Address.\r
-  This function must guarantee that all PCI read and write operations are\r
-  serialized.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
 \r
-  @return The value read from the PCI configuration register.\r
+  @return The 32-bit PCI configuration register specified by Address.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 PciSegmentRead32 (\r
-  IN      UINT64                    Address\r
+  IN UINT64                    Address\r
   )\r
 {\r
   ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 3);\r
@@ -984,119 +979,113 @@ PciSegmentRead32 (
 /**\r
   Writes a 32-bit PCI configuration register.\r
 \r
-  Writes the 32-bit PCI configuration register specified by Address with the\r
-  value specified by Value. Value is returned. This function must guarantee\r
-  that all PCI read and write operations are serialized.\r
+  Writes the 32-bit PCI configuration register specified by Address with the value specified by Value.\r
+  Value is returned.  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  Data    The value to write.\r
+  @param  Address     Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  Value       The value to write.\r
 \r
-  @return The value written to the PCI configuration register.\r
+  @return The parameter of Value.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 PciSegmentWrite32 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT32                    Data\r
+  IN UINT64                    Address,\r
+  IN UINT32                    Value\r
   )\r
 {\r
   ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 3);\r
 \r
-  return DxePciSegmentLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint32, Data);\r
+  return DxePciSegmentLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint32, Value);\r
 }\r
 \r
 /**\r
-  Performs a bitwise inclusive OR of a 32-bit PCI configuration register with\r
-  a 32-bit value.\r
+  Performs a bitwise OR of a 32-bit PCI configuration register with a 32-bit value.\r
 \r
-  Reads the 32-bit PCI configuration register specified by Address, performs a\r
-  bitwise inclusive OR between the read result and the value specified by\r
-  OrData, and writes the result to the 32-bit PCI configuration register\r
-  specified by Address. The value written to the PCI configuration register is\r
-  returned. This function must guarantee that all PCI read and write operations\r
-  are serialized.\r
+  Reads the 32-bit PCI configuration register specified by Address,\r
+  performs a bitwise OR between the read result and the value specified by OrData,\r
+  and writes the result to the 32-bit PCI configuration register specified by Address.\r
+  The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  OrData  The value to OR with the PCI configuration register.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
 \r
-  @return The value written back to the PCI configuration register.\r
+  @return The value written to the PCI configuration register.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 PciSegmentOr32 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT32                    OrData\r
+  IN UINT64                    Address,\r
+  IN UINT32                    OrData\r
   )\r
 {\r
   return PciSegmentWrite32 (Address, PciSegmentRead32 (Address) | OrData);\r
 }\r
 \r
 /**\r
-  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
-  value.\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value.\r
 \r
-  Reads the 32-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND between the read result and the value specified by AndData, and\r
-  writes the result to the 32-bit PCI configuration register specified by\r
-  Address. The value written to the PCI configuration register is returned.\r
-  This function must guarantee that all PCI read and write operations are\r
-  serialized.\r
+  Reads the 32-bit PCI configuration register specified by Address,\r
+  performs a bitwise AND between the read result and the value specified by AndData,\r
+  and writes the result to the 32-bit PCI configuration register specified by Address.\r
+  The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  AndData The value to AND with the PCI configuration register.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
 \r
-  @return The value written back to the PCI configuration register.\r
+  @return The value written to the PCI configuration register.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 PciSegmentAnd32 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT32                    AndData\r
+  IN UINT64                    Address,\r
+  IN UINT32                    AndData\r
   )\r
 {\r
   return PciSegmentWrite32 (Address, PciSegmentRead32 (Address) & AndData);\r
 }\r
 \r
 /**\r
-  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit\r
-  value, followed a  bitwise inclusive OR with another 32-bit value.\r
+  Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value,\r
+  followed a  bitwise OR with another 32-bit value.\r
 \r
-  Reads the 32-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND between the read result and the value specified by AndData,\r
-  performs a bitwise inclusive OR between the result of the AND operation and\r
-  the value specified by OrData, and writes the result to the 32-bit PCI\r
-  configuration register specified by Address. The value written to the PCI\r
-  configuration register is returned. This function must guarantee that all PCI\r
-  read and write operations are serialized.\r
+  Reads the 32-bit PCI configuration register specified by Address,\r
+  performs a bitwise AND between the read result and the value specified by AndData,\r
+  performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
+  and writes the result to the 32-bit PCI configuration register specified by Address.\r
+  The value written to the PCI configuration register is returned.\r
+  This function must guarantee that all PCI read and write operations are serialized.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
 \r
-  @param  Address Address that encodes the PCI Segment, Bus, Device, Function and\r
-                  Register.\r
-  @param  AndData The value to AND with the PCI configuration register.\r
-  @param  OrData  The value to OR with the result of the AND operation.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
+  @param  AndData   The value to AND with the PCI configuration register.\r
+  @param  OrData    The value to OR with the PCI configuration register.\r
 \r
-  @return The value written back to the PCI configuration register.\r
+  @return The value written to the PCI configuration register.\r
 \r
 **/\r
 UINT32\r
 EFIAPI\r
 PciSegmentAndThenOr32 (\r
-  IN      UINT64                    Address,\r
-  IN      UINT32                    AndData,\r
-  IN      UINT32                    OrData\r
+  IN UINT64                    Address,\r
+  IN UINT32                    AndData,\r
+  IN UINT32                    OrData\r
   )\r
 {\r
   return PciSegmentWrite32 (Address, (PciSegmentRead32 (Address) & AndData) | OrData);\r
@@ -1110,6 +1099,7 @@ PciSegmentAndThenOr32 (
   returned.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
   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
@@ -1126,9 +1116,9 @@ PciSegmentAndThenOr32 (
 UINT32\r
 EFIAPI\r
 PciSegmentBitFieldRead32 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit\r
   )\r
 {\r
   return BitFieldRead32 (PciSegmentRead32 (Address), StartBit, EndBit);\r
@@ -1143,9 +1133,11 @@ PciSegmentBitFieldRead32 (
   32-bit register is returned.\r
 \r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1160,10 +1152,10 @@ PciSegmentBitFieldRead32 (
 UINT32\r
 EFIAPI\r
 PciSegmentBitFieldWrite32 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    Value\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT32                    Value\r
   )\r
 {\r
   return PciSegmentWrite32 (\r
@@ -1177,7 +1169,7 @@ PciSegmentBitFieldWrite32 (
   writes the result back to the bit field in the 32-bit port.\r
 \r
   Reads the 32-bit PCI configuration register specified by Address, performs a\r
-  bitwise inclusive OR between the read result and the value specified by\r
+  bitwise OR between the read result and the value specified by\r
   OrData, and writes the result to the 32-bit PCI configuration register\r
   specified by Address. The value written to the PCI configuration register is\r
   returned. This function must guarantee that all PCI read and write operations\r
@@ -1187,6 +1179,7 @@ PciSegmentBitFieldWrite32 (
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1201,10 +1194,10 @@ PciSegmentBitFieldWrite32 (
 UINT32\r
 EFIAPI\r
 PciSegmentBitFieldOr32 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    OrData\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT32                    OrData\r
   )\r
 {\r
   return PciSegmentWrite32 (\r
@@ -1217,19 +1210,20 @@ PciSegmentBitFieldOr32 (
   Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
   AND, and writes the result back to the bit field in the 32-bit register.\r
 \r
-  Reads the 32-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND between the read result and the value specified by AndData, and\r
-  writes the result to the 32-bit PCI configuration register specified by\r
-  Address. The value written to the PCI configuration register is returned.\r
-  This function must guarantee that all PCI read and write operations are\r
-  serialized. Extra left bits in AndData are stripped.\r
 \r
+  Reads the 32-bit PCI configuration register specified by Address, performs a bitwise\r
+  AND between the read result and the value specified by AndData, and writes the result\r
+  to the 32-bit PCI configuration register specified by Address. The value written to\r
+  the PCI configuration register is returned.  This function must guarantee that all PCI\r
+  read and write operations are serialized.  Extra left bits in AndData are stripped.\r
   If any reserved bits in Address are set, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
   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   PCI configuration register to write.\r
+  @param  Address   Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
                     Range 0..31.\r
   @param  EndBit    The ordinal of the most significant bit in the bit field.\r
@@ -1242,10 +1236,10 @@ PciSegmentBitFieldOr32 (
 UINT32\r
 EFIAPI\r
 PciSegmentBitFieldAnd32 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    AndData\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT32                    AndData\r
   )\r
 {\r
   return PciSegmentWrite32 (\r
@@ -1256,11 +1250,11 @@ PciSegmentBitFieldAnd32 (
 \r
 /**\r
   Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
-  bitwise inclusive OR, and writes the result back to the bit field in the\r
+  bitwise OR, and writes the result back to the bit field in the\r
   32-bit port.\r
 \r
   Reads the 32-bit PCI configuration register specified by Address, performs a\r
-  bitwise AND followed by a bitwise inclusive OR between the read result and\r
+  bitwise AND followed by a bitwise OR between the read result and\r
   the value specified by AndData, and writes the result to the 32-bit PCI\r
   configuration register specified by Address. The value written to the PCI\r
   configuration register is returned. This function must guarantee that all PCI\r
@@ -1271,6 +1265,8 @@ PciSegmentBitFieldAnd32 (
   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   PCI configuration register to write.\r
   @param  StartBit  The ordinal of the least significant bit in the bit field.\r
@@ -1286,11 +1282,11 @@ PciSegmentBitFieldAnd32 (
 UINT32\r
 EFIAPI\r
 PciSegmentBitFieldAndThenOr32 (\r
-  IN      UINT64                    Address,\r
-  IN      UINTN                     StartBit,\r
-  IN      UINTN                     EndBit,\r
-  IN      UINT32                    AndData,\r
-  IN      UINT32                    OrData\r
+  IN UINT64                    Address,\r
+  IN UINTN                     StartBit,\r
+  IN UINTN                     EndBit,\r
+  IN UINT32                    AndData,\r
+  IN UINT32                    OrData\r
   )\r
 {\r
   return PciSegmentWrite32 (\r
@@ -1310,7 +1306,7 @@ PciSegmentBitFieldAndThenOr32 (
   and 16-bit PCI configuration read cycles may be used at the beginning and the\r
   end of the range.\r
 \r
-  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If any reserved bits in StartAddress are set, then ASSERT().\r
   If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
   If Size > 0 and Buffer is NULL, then ASSERT().\r
 \r
@@ -1325,9 +1321,9 @@ PciSegmentBitFieldAndThenOr32 (
 UINTN\r
 EFIAPI\r
 PciSegmentReadBuffer (\r
-  IN      UINT64                    StartAddress,\r
-  IN      UINTN                     Size,\r
-  OUT     VOID                      *Buffer\r
+  IN  UINT64                   StartAddress,\r
+  IN  UINTN                    Size,\r
+  OUT VOID                     *Buffer\r
   )\r
 {\r
   UINTN                                ReturnValue;\r
@@ -1360,7 +1356,7 @@ PciSegmentReadBuffer (
     //\r
     // Read a word if StartAddress is word aligned\r
     //\r
-    *(volatile UINT16 *)Buffer = PciSegmentRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1370,7 +1366,7 @@ PciSegmentReadBuffer (
     //\r
     // Read as many double words as possible\r
     //\r
-    *(volatile UINT32 *)Buffer = PciSegmentRead32 (StartAddress);\r
+    WriteUnaligned32 (Buffer, PciSegmentRead32 (StartAddress));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1380,7 +1376,7 @@ PciSegmentReadBuffer (
     //\r
     // Read the last remaining word if exist\r
     //\r
-    *(volatile UINT16 *)Buffer = PciSegmentRead16 (StartAddress);\r
+    WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1408,7 +1404,7 @@ PciSegmentReadBuffer (
   8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
   and the end of the range.\r
 \r
-  If StartAddress > 0x0FFFFFFF, then ASSERT().\r
+  If any reserved bits in StartAddress are set, then ASSERT().\r
   If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
   If Size > 0 and Buffer is NULL, then ASSERT().\r
 \r
@@ -1417,15 +1413,15 @@ PciSegmentReadBuffer (
   @param  Size          Size in bytes of the transfer.\r
   @param  Buffer        Pointer to a buffer containing the data to write.\r
 \r
-  @return Size\r
+  @return The parameter of Size.\r
 \r
 **/\r
 UINTN\r
 EFIAPI\r
 PciSegmentWriteBuffer (\r
-  IN      UINT64                    StartAddress,\r
-  IN      UINTN                     Size,\r
-  IN      VOID                      *Buffer\r
+  IN UINT64                    StartAddress,\r
+  IN UINTN                     Size,\r
+  IN VOID                      *Buffer\r
   )\r
 {\r
   UINTN                                ReturnValue;\r
@@ -1458,7 +1454,7 @@ PciSegmentWriteBuffer (
     //\r
     // Write a word if StartAddress is word aligned\r
     //\r
-    PciSegmentWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r
@@ -1468,7 +1464,7 @@ PciSegmentWriteBuffer (
     //\r
     // Write as many double words as possible\r
     //\r
-    PciSegmentWrite32 (StartAddress, *(UINT32*)Buffer);\r
+    PciSegmentWrite32 (StartAddress, ReadUnaligned32 (Buffer));\r
     StartAddress += sizeof (UINT32);\r
     Size -= sizeof (UINT32);\r
     Buffer = (UINT32*)Buffer + 1;\r
@@ -1478,7 +1474,7 @@ PciSegmentWriteBuffer (
     //\r
     // Write the last remaining word if exist\r
     //\r
-    PciSegmentWrite16 (StartAddress, *(UINT16*)Buffer);\r
+    PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer));\r
     StartAddress += sizeof (UINT16);\r
     Size -= sizeof (UINT16);\r
     Buffer = (UINT16*)Buffer + 1;\r