/* Update the value of an 16-bit PCI configuration register in a PCI device. If the PCI Configuration register specified by PciAddress is already programmed with a non-zero value, then return the current value. Otherwise update the PCI configuration register specified by PciAddress with the value specified by Value and return the value programmed into the PCI configuration register. All values must be masked using the bitmask specified by Mask. */
UINT16 SerialPortLibUpdatePciRegister16(UINTN PciAddress, UINT16 Value, UINT16 Mask)
/* Update the value of an 16-bit PCI configuration register in a PCI device. If the PCI Configuration register specified by PciAddress is already programmed with a non-zero value, then return the current value. Otherwise update the PCI configuration register specified by PciAddress with the value specified by Value and return the value programmed into the PCI configuration register. All values must be masked using the bitmask specified by Mask. */
UINT16 SerialPortLibUpdatePciRegister16(UINTN PciAddress, UINT16 Value, UINT16 Mask)
{
  UINT16  CurrentValue;
  CurrentValue = PciRead16 (PciAddress) & Mask;
  if (CurrentValue != 0) {
    return CurrentValue;
  }
  return PciWrite16 (PciAddress, Value & Mask);
}