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
 struct pci_driver undipci_driver __pci_driver_fallback = {
140
 struct pci_driver undipci_driver __pci_driver_fallback = {
141
 	.ids = undipci_nics,
141
 	.ids = undipci_nics,
142
 	.id_count = ( sizeof ( undipci_nics ) / sizeof ( undipci_nics[0] ) ),
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
 	.probe = undipci_probe,
144
 	.probe = undipci_probe,
145
 	.remove = undipci_remove,
145
 	.remove = undipci_remove,
146
 };
146
 };

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

1877
 struct pci_driver ehci_driver __pci_driver = {
1877
 struct pci_driver ehci_driver __pci_driver = {
1878
 	.ids = ehci_ids,
1878
 	.ids = ehci_ids,
1879
 	.id_count = ( sizeof ( ehci_ids ) / sizeof ( ehci_ids[0] ) ),
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
 	.probe = ehci_probe,
1882
 	.probe = ehci_probe,
1883
 	.remove = ehci_remove,
1883
 	.remove = ehci_remove,
1884
 };
1884
 };

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

3280
 struct pci_driver xhci_driver __pci_driver = {
3280
 struct pci_driver xhci_driver __pci_driver = {
3281
 	.ids = xhci_ids,
3281
 	.ids = xhci_ids,
3282
 	.id_count = ( sizeof ( xhci_ids ) / sizeof ( xhci_ids[0] ) ),
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
 	.probe = xhci_probe,
3285
 	.probe = xhci_probe,
3286
 	.remove = xhci_remove,
3286
 	.remove = xhci_remove,
3287
 };
3287
 };

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

118
 #define PCI_CLASS_SERIAL_USB_EHCI	 0x20	/**< ECHI USB controller */
118
 #define PCI_CLASS_SERIAL_USB_EHCI	 0x20	/**< ECHI USB controller */
119
 #define PCI_CLASS_SERIAL_USB_XHCI	 0x30	/**< xHCI USB controller */
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
 /** A PCI device ID list entry */
131
 /** A PCI device ID list entry */
122
 struct pci_device_id {
132
 struct pci_device_id {
123
 	/** Name */
133
 	/** Name */
147
  * @v sub		Subclass (or PCI_ANY_ID)
157
  * @v sub		Subclass (or PCI_ANY_ID)
148
  * @v progif		Programming interface (or PCI_ANY_ID)
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
 	.mask = ( ( ( ( (base) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 16 ) |   \
162
 	.mask = ( ( ( ( (base) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 16 ) |   \
155
 		  ( ( ( (sub) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 8 ) |	   \
163
 		  ( ( ( (sub) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 8 ) |	   \
156
 		  ( ( ( (progif) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 0 ) ), \
164
 		  ( ( ( (progif) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 0 ) ), \

Loading…
Cancel
Save