Browse Source

[pci] Standardise debug message format

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
ef0376483c
2 changed files with 24 additions and 19 deletions
  1. 17
    19
      src/drivers/bus/pci.c
  2. 7
    0
      src/include/ipxe/pci.h

+ 17
- 19
src/drivers/bus/pci.c View File

64
 			if ( sizeof ( unsigned long ) > sizeof ( uint32_t ) ) {
64
 			if ( sizeof ( unsigned long ) > sizeof ( uint32_t ) ) {
65
 				return ( ( ( uint64_t ) high << 32 ) | low );
65
 				return ( ( ( uint64_t ) high << 32 ) | low );
66
 			} else {
66
 			} else {
67
-				DBG ( "Unhandled 64-bit BAR %08x%08x\n",
68
-				      high, low );
67
+				DBGC ( pci, PCI_FMT " unhandled 64-bit BAR "
68
+				       "%08x%08x\n",
69
+				       PCI_ARGS ( pci ), high, low );
69
 				return PCI_BASE_ADDRESS_MEM_TYPE_64;
70
 				return PCI_BASE_ADDRESS_MEM_TYPE_64;
70
 			}
71
 			}
71
 		}
72
 		}
148
 	new_command = ( pci_command | PCI_COMMAND_MASTER |
149
 	new_command = ( pci_command | PCI_COMMAND_MASTER |
149
 			PCI_COMMAND_MEM | PCI_COMMAND_IO );
150
 			PCI_COMMAND_MEM | PCI_COMMAND_IO );
150
 	if ( pci_command != new_command ) {
151
 	if ( pci_command != new_command ) {
151
-		DBG ( "PCI BIOS has not enabled device %02x:%02x.%x! "
152
-		      "Updating PCI command %04x->%04x\n", pci->bus,
153
-		      PCI_SLOT ( pci->devfn ), PCI_FUNC ( pci->devfn ),
154
-		      pci_command, new_command );
152
+		DBGC ( pci, PCI_FMT " device not enabled by BIOS! Updating "
153
+		       "PCI command %04x->%04x\n",
154
+		       PCI_ARGS ( pci ), pci_command, new_command );
155
 		pci_write_config_word ( pci, PCI_COMMAND, new_command );
155
 		pci_write_config_word ( pci, PCI_COMMAND, new_command );
156
 	}
156
 	}
157
 
157
 
158
 	pci_read_config_byte ( pci, PCI_LATENCY_TIMER, &pci_latency);
158
 	pci_read_config_byte ( pci, PCI_LATENCY_TIMER, &pci_latency);
159
 	if ( pci_latency < 32 ) {
159
 	if ( pci_latency < 32 ) {
160
-		DBG ( "PCI device %02x:%02x.%x latency timer is unreasonably "
161
-		      "low at %d. Setting to 32.\n", pci->bus,
162
-		      PCI_SLOT ( pci->devfn ), PCI_FUNC ( pci->devfn ),
163
-		      pci_latency );
160
+		DBGC ( pci, PCI_FMT " latency timer is unreasonably low at "
161
+		       "%d. Setting to 32.\n", PCI_ARGS ( pci ), pci_latency );
164
 		pci_write_config_byte ( pci, PCI_LATENCY_TIMER, 32);
162
 		pci_write_config_byte ( pci, PCI_LATENCY_TIMER, 32);
165
 	}
163
 	}
166
 }
164
 }
180
 	unsigned int i;
178
 	unsigned int i;
181
 	int rc;
179
 	int rc;
182
 
180
 
183
-	DBG ( "Adding PCI device %02x:%02x.%x (%04x:%04x mem %lx io %lx "
184
-	      "irq %d)\n", pci->bus, PCI_SLOT ( pci->devfn ),
185
-	      PCI_FUNC ( pci->devfn ), pci->vendor, pci->device,
186
-	      pci->membase, pci->ioaddr, pci->irq );
181
+	DBGC ( pci, PCI_FMT " is %04x:%04x mem %lx io %lx irq %d\n",
182
+	       PCI_ARGS ( pci ), pci->vendor, pci->device, pci->membase,
183
+	       pci->ioaddr, pci->irq );
187
 
184
 
188
 	for_each_table_entry ( driver, PCI_DRIVERS ) {
185
 	for_each_table_entry ( driver, PCI_DRIVERS ) {
189
 		for ( i = 0 ; i < driver->id_count ; i++ ) {
186
 		for ( i = 0 ; i < driver->id_count ; i++ ) {
196
 				continue;
193
 				continue;
197
 			pci->driver = driver;
194
 			pci->driver = driver;
198
 			pci->driver_name = id->name;
195
 			pci->driver_name = id->name;
199
-			DBG ( "...using driver %s\n", pci->driver_name );
196
+			DBGC ( pci, "...using driver %s\n", pci->driver_name );
200
 			if ( ( rc = driver->probe ( pci, id ) ) != 0 ) {
197
 			if ( ( rc = driver->probe ( pci, id ) ) != 0 ) {
201
-				DBG ( "......probe failed\n" );
198
+				DBGC ( pci, "......probe failed: %s\n",
199
+				       strerror ( rc ) );
202
 				continue;
200
 				continue;
203
 			}
201
 			}
202
+			DBGC ( pci, PCI_FMT " added\n", PCI_ARGS ( pci ) );
204
 			return 0;
203
 			return 0;
205
 		}
204
 		}
206
 	}
205
 	}
207
 
206
 
208
-	DBG ( "...no driver found\n" );
207
+	DBGC ( pci, "...no driver found\n" );
209
 	return -ENOTTY;
208
 	return -ENOTTY;
210
 }
209
 }
211
 
210
 
216
  */
215
  */
217
 static void pci_remove ( struct pci_device *pci ) {
216
 static void pci_remove ( struct pci_device *pci ) {
218
 	pci->driver->remove ( pci );
217
 	pci->driver->remove ( pci );
219
-	DBG ( "Removed PCI device %02x:%02x.%x\n", pci->bus,
220
-	      PCI_SLOT ( pci->devfn ), PCI_FUNC ( pci->devfn ) );
218
+	DBGC ( pci, PCI_FMT " removed\n", PCI_ARGS ( pci ) );
221
 }
219
 }
222
 
220
 
223
 /**
221
 /**

+ 7
- 0
src/include/ipxe/pci.h View File

374
 #define PCI_ROM( _vendor, _device, _name, _description, _data ) \
374
 #define PCI_ROM( _vendor, _device, _name, _description, _data ) \
375
 	PCI_ID( _vendor, _device, _name, _description, _data )
375
 	PCI_ID( _vendor, _device, _name, _description, _data )
376
 
376
 
377
+/** PCI device debug message format */
378
+#define PCI_FMT "PCI %02x:%02x.%x"
379
+
380
+/** PCI device debug message arguments */
381
+#define PCI_ARGS( pci ) \
382
+	(pci)->bus, PCI_SLOT ( (pci)->devfn ), PCI_FUNC ( (pci)->devfn )
383
+
377
 extern void adjust_pci_device ( struct pci_device *pci );
384
 extern void adjust_pci_device ( struct pci_device *pci );
378
 extern unsigned long pci_bar_start ( struct pci_device *pci,
385
 extern unsigned long pci_bar_start ( struct pci_device *pci,
379
 				     unsigned int reg );
386
 				     unsigned int reg );

Loading…
Cancel
Save