]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/PciSegmentLib.h
MdePkg/PciSegmentLib: Optimize PCI_SEGMENT_LIB_ADDRESS()
[mirror_edk2.git] / MdePkg / Include / Library / PciSegmentLib.h
index 113501034e799e93c301eefda4a1bcbe0df54754..5175e0760646aac453fcd73482f0a32a834e8672 100644 (file)
@@ -23,7 +23,7 @@
   access method.  Modules will typically use the PCI Segment Library for its PCI configuration \r
   accesses when PCI Segments other than Segment #0 must be accessed.  \r
 \r
   access method.  Modules will typically use the PCI Segment Library for its PCI configuration \r
   accesses when PCI Segments other than Segment #0 must be accessed.  \r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, 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
 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
@@ -56,11 +56,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 #define PCI_SEGMENT_LIB_ADDRESS(Segment,Bus,Device,Function,Register) \\r
 \r
 **/\r
 #define PCI_SEGMENT_LIB_ADDRESS(Segment,Bus,Device,Function,Register) \\r
-  ( ((Register) & 0xfff)              | \\r
-    (((Function) & 0x07) << 12)       | \\r
-    (((Device) & 0x1f) << 15)         | \\r
-    (((Bus) & 0xff) << 20)            | \\r
-    (LShiftU64((Segment) & 0xffff, 32)) \\r
+  ((Segment != 0) ? \\r
+    ( ((Register) & 0xfff)                 | \\r
+      (((Function) & 0x07) << 12)          | \\r
+      (((Device) & 0x1f) << 15)            | \\r
+      (((Bus) & 0xff) << 20)               | \\r
+      (LShiftU64 ((Segment) & 0xffff, 32))   \\r
+    ) :                                      \\r
+    ( ((Register) & 0xfff)                 | \\r
+      (((Function) & 0x07) << 12)          | \\r
+      (((Device) & 0x1f) << 15)            | \\r
+      (((Bus) & 0xff) << 20)                 \\r
+    )                                        \\r
   )\r
 \r
 /**\r
   )\r
 \r
 /**\r