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,8 +64,9 @@ static unsigned long pci_bar ( struct pci_device *pci, unsigned int reg ) {
64 64
 			if ( sizeof ( unsigned long ) > sizeof ( uint32_t ) ) {
65 65
 				return ( ( ( uint64_t ) high << 32 ) | low );
66 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 70
 				return PCI_BASE_ADDRESS_MEM_TYPE_64;
70 71
 			}
71 72
 		}
@@ -148,19 +149,16 @@ void adjust_pci_device ( struct pci_device *pci ) {
148 149
 	new_command = ( pci_command | PCI_COMMAND_MASTER |
149 150
 			PCI_COMMAND_MEM | PCI_COMMAND_IO );
150 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 155
 		pci_write_config_word ( pci, PCI_COMMAND, new_command );
156 156
 	}
157 157
 
158 158
 	pci_read_config_byte ( pci, PCI_LATENCY_TIMER, &pci_latency);
159 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 162
 		pci_write_config_byte ( pci, PCI_LATENCY_TIMER, 32);
165 163
 	}
166 164
 }
@@ -180,10 +178,9 @@ static int pci_probe ( struct pci_device *pci ) {
180 178
 	unsigned int i;
181 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 185
 	for_each_table_entry ( driver, PCI_DRIVERS ) {
189 186
 		for ( i = 0 ; i < driver->id_count ; i++ ) {
@@ -196,16 +193,18 @@ static int pci_probe ( struct pci_device *pci ) {
196 193
 				continue;
197 194
 			pci->driver = driver;
198 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 197
 			if ( ( rc = driver->probe ( pci, id ) ) != 0 ) {
201
-				DBG ( "......probe failed\n" );
198
+				DBGC ( pci, "......probe failed: %s\n",
199
+				       strerror ( rc ) );
202 200
 				continue;
203 201
 			}
202
+			DBGC ( pci, PCI_FMT " added\n", PCI_ARGS ( pci ) );
204 203
 			return 0;
205 204
 		}
206 205
 	}
207 206
 
208
-	DBG ( "...no driver found\n" );
207
+	DBGC ( pci, "...no driver found\n" );
209 208
 	return -ENOTTY;
210 209
 }
211 210
 
@@ -216,8 +215,7 @@ static int pci_probe ( struct pci_device *pci ) {
216 215
  */
217 216
 static void pci_remove ( struct pci_device *pci ) {
218 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,6 +374,13 @@ struct pci_driver {
374 374
 #define PCI_ROM( _vendor, _device, _name, _description, _data ) \
375 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 384
 extern void adjust_pci_device ( struct pci_device *pci );
378 385
 extern unsigned long pci_bar_start ( struct pci_device *pci,
379 386
 				     unsigned int reg );

Loading…
Cancel
Save