Browse Source

[pci] Provide PCI_CLASS() to calculate a scalar PCI class value

Rename PCI_CLASS() (which constructs a struct pci_class_id) to
PCI_CLASS_ID(), and provide PCI_CLASS() as a macro which constructs
the 24-bit scalar value of a PCI class code.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
b88ab14ba3
4 changed files with 17 additions and 9 deletions
  1. 1
    1
      src/arch/i386/drivers/net/undi.c
  2. 2
    2
      src/drivers/usb/ehci.c
  3. 2
    2
      src/drivers/usb/xhci.c
  4. 12
    4
      src/include/ipxe/pci.h

+ 1
- 1
src/arch/i386/drivers/net/undi.c View File

@@ -140,7 +140,7 @@ static struct pci_device_id undipci_nics[] = {
140 140
 struct pci_driver undipci_driver __pci_driver_fallback = {
141 141
 	.ids = undipci_nics,
142 142
 	.id_count = ( sizeof ( undipci_nics ) / sizeof ( undipci_nics[0] ) ),
143
-	.class = PCI_CLASS ( PCI_CLASS_NETWORK, PCI_ANY_ID, PCI_ANY_ID ),
143
+	.class = PCI_CLASS_ID ( PCI_CLASS_NETWORK, PCI_ANY_ID, PCI_ANY_ID ),
144 144
 	.probe = undipci_probe,
145 145
 	.remove = undipci_remove,
146 146
 };

+ 2
- 2
src/drivers/usb/ehci.c View File

@@ -1877,8 +1877,8 @@ static struct pci_device_id ehci_ids[] = {
1877 1877
 struct pci_driver ehci_driver __pci_driver = {
1878 1878
 	.ids = ehci_ids,
1879 1879
 	.id_count = ( sizeof ( ehci_ids ) / sizeof ( ehci_ids[0] ) ),
1880
-	.class = PCI_CLASS ( PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB,
1881
-			     PCI_CLASS_SERIAL_USB_EHCI ),
1880
+	.class = PCI_CLASS_ID ( PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB,
1881
+				PCI_CLASS_SERIAL_USB_EHCI ),
1882 1882
 	.probe = ehci_probe,
1883 1883
 	.remove = ehci_remove,
1884 1884
 };

+ 2
- 2
src/drivers/usb/xhci.c View File

@@ -3280,8 +3280,8 @@ static struct pci_device_id xhci_ids[] = {
3280 3280
 struct pci_driver xhci_driver __pci_driver = {
3281 3281
 	.ids = xhci_ids,
3282 3282
 	.id_count = ( sizeof ( xhci_ids ) / sizeof ( xhci_ids[0] ) ),
3283
-	.class = PCI_CLASS ( PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB,
3284
-			     PCI_CLASS_SERIAL_USB_XHCI ),
3283
+	.class = PCI_CLASS_ID ( PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB,
3284
+				PCI_CLASS_SERIAL_USB_XHCI ),
3285 3285
 	.probe = xhci_probe,
3286 3286
 	.remove = xhci_remove,
3287 3287
 };

+ 12
- 4
src/include/ipxe/pci.h View File

@@ -118,6 +118,16 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
118 118
 #define PCI_CLASS_SERIAL_USB_EHCI	 0x20	/**< ECHI USB controller */
119 119
 #define PCI_CLASS_SERIAL_USB_XHCI	 0x30	/**< xHCI USB controller */
120 120
 
121
+/** Construct PCI class
122
+ *
123
+ * @v base		Base class (or PCI_ANY_ID)
124
+ * @v sub		Subclass (or PCI_ANY_ID)
125
+ * @v progif		Programming interface (or PCI_ANY_ID)
126
+ */
127
+#define PCI_CLASS( base, sub, progif )					\
128
+	( ( ( (base) & 0xff ) << 16 ) |	( ( (sub) & 0xff ) << 8 ) |	\
129
+	  ( ( (progif) & 0xff) << 0 ) )
130
+
121 131
 /** A PCI device ID list entry */
122 132
 struct pci_device_id {
123 133
 	/** Name */
@@ -147,10 +157,8 @@ struct pci_class_id {
147 157
  * @v sub		Subclass (or PCI_ANY_ID)
148 158
  * @v progif		Programming interface (or PCI_ANY_ID)
149 159
  */
150
-#define PCI_CLASS(base,sub,progif) {					   \
151
-	.class = ( ( ( (base) & 0xff ) << 16 ) |			   \
152
-		   ( ( (sub) & 0xff ) << 8 ) |				   \
153
-		   ( ( (progif) & 0xff) << 0 ) ),			   \
160
+#define PCI_CLASS_ID( base, sub, progif ) {				   \
161
+	.class = PCI_CLASS ( base, sub, progif ),			   \
154 162
 	.mask = ( ( ( ( (base) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 16 ) |   \
155 163
 		  ( ( ( (sub) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 8 ) |	   \
156 164
 		  ( ( ( (progif) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 0 ) ), \

Loading…
Cancel
Save