Sfoglia il codice sorgente

[efi] Standardise PCI debug messages

Use the PCI bus:dev.fn address in debug messages, falling back to the
EFI handle name only if we do not yet have enough information to
determine the bus:dev.fn address.

Include the vendor and device IDs in debug messages when no suitable
driver is found, to match the diagnostics available in a BIOS
environment.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 anni fa
parent
commit
17887f87b7
1 ha cambiato i file con 31 aggiunte e 29 eliminazioni
  1. 31
    29
      src/interface/efi/efi_pci.c

+ 31
- 29
src/interface/efi/efi_pci.c Vedi File

@@ -87,8 +87,8 @@ static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
87 87
 			&efi_pci_root_bridge_io_protocol_guid,
88 88
 			NULL, &num_handles, &handles ) ) != 0 ) {
89 89
 		rc = -EEFI ( efirc );
90
-		DBGC ( pci, "EFIPCI cannot locate root bridges: %s\n",
91
-		       strerror ( rc ) );
90
+		DBGC ( pci, "EFIPCI " PCI_FMT " cannot locate root bridges: "
91
+		       "%s\n", PCI_ARGS ( pci ), strerror ( rc ) );
92 92
 		goto err_locate;
93 93
 	}
94 94
 
@@ -100,8 +100,9 @@ static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
100 100
 				&u.interface, efi_image_handle, *handle,
101 101
 				EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
102 102
 			rc = -EEFI ( efirc );
103
-			DBGC ( pci, "EFIPCI cannot open %s: %s\n",
104
-			       efi_handle_name ( *handle ), strerror ( rc ) );
103
+			DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n",
104
+			       PCI_ARGS ( pci ), efi_handle_name ( *handle ),
105
+			       strerror ( rc ) );
105 106
 			continue;
106 107
 		}
107 108
 		if ( u.root->SegmentNumber == PCI_SEG ( pci->busdevfn ) ) {
@@ -113,7 +114,7 @@ static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
113 114
 				    &efi_pci_root_bridge_io_protocol_guid,
114 115
 				    efi_image_handle, *handle );
115 116
 	}
116
-	DBGC ( pci, "EFIPCI found no root bridge for " PCI_FMT "\n",
117
+	DBGC ( pci, "EFIPCI " PCI_FMT " found no root bridge\n",
117 118
 	       PCI_ARGS ( pci ) );
118 119
 	rc = -ENOENT;
119 120
 
@@ -163,9 +164,9 @@ int efipci_read ( struct pci_device *pci, unsigned long location,
163 164
 					efipci_address ( pci, location ), 1,
164 165
 					value ) ) != 0 ) {
165 166
 		rc = -EEFI ( efirc );
166
-		DBG ( "EFIPCI config read from " PCI_FMT " offset %02lx "
167
-		      "failed: %s\n", PCI_ARGS ( pci ),
168
-		      EFIPCI_OFFSET ( location ), strerror ( rc ) );
167
+		DBGC ( pci, "EFIPCI " PCI_FMT " config read from offset %02lx "
168
+		       "failed: %s\n", PCI_ARGS ( pci ),
169
+		       EFIPCI_OFFSET ( location ), strerror ( rc ) );
169 170
 		goto err_read;
170 171
 	}
171 172
 
@@ -201,9 +202,9 @@ int efipci_write ( struct pci_device *pci, unsigned long location,
201 202
 					 efipci_address ( pci, location ), 1,
202 203
 					 &value ) ) != 0 ) {
203 204
 		rc = -EEFI ( efirc );
204
-		DBG ( "EFIPCI config write to " PCI_FMT " offset %02lx "
205
-		      "failed: %s\n", PCI_ARGS ( pci ),
206
-		      EFIPCI_OFFSET ( location ), strerror ( rc ) );
205
+		DBGC ( pci, "EFIPCI " PCI_FMT " config write to offset %02lx "
206
+		       "failed: %s\n", PCI_ARGS ( pci ),
207
+		       EFIPCI_OFFSET ( location ), strerror ( rc ) );
207 208
 		goto err_write;
208 209
 	}
209 210
 
@@ -268,10 +269,10 @@ int efipci_open ( EFI_HANDLE device, UINT32 attributes,
268 269
 		       efi_handle_name ( device ), strerror ( rc ) );
269 270
 		goto err_get_location;
270 271
 	}
271
-	DBGC2 ( device, "EFIPCI %s is PCI %04lx:%02lx:%02lx.%lx\n",
272
-		efi_handle_name ( device ), ( ( unsigned long ) pci_segment ),
273
-		( ( unsigned long ) pci_bus ), ( ( unsigned long ) pci_dev ),
274
-		( ( unsigned long ) pci_fn ) );
272
+	busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn );
273
+	pci_init ( pci, busdevfn );
274
+	DBGCP ( device, "EFIPCI " PCI_FMT " is %s\n",
275
+		PCI_ARGS ( pci ), efi_handle_name ( device ) );
275 276
 
276 277
 	/* Try to enable I/O cycles, memory cycles, and bus mastering.
277 278
 	 * Some platforms will 'helpfully' report errors if these bits
@@ -290,11 +291,10 @@ int efipci_open ( EFI_HANDLE device, UINT32 attributes,
290 291
 				    EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, NULL );
291 292
 
292 293
 	/* Populate PCI device */
293
-	busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn );
294
-	pci_init ( pci, busdevfn );
295 294
 	if ( ( rc = pci_read_config ( pci ) ) != 0 ) {
296
-		DBGC ( device, "EFIPCI %s cannot read PCI configuration: %s\n",
297
-		       efi_handle_name ( device ), strerror ( rc ) );
295
+		DBGC ( device, "EFIPCI " PCI_FMT " cannot read PCI "
296
+		       "configuration: %s\n",
297
+		       PCI_ARGS ( pci ), strerror ( rc ) );
298 298
 		goto err_pci_read_config;
299 299
 	}
300 300
 
@@ -364,12 +364,14 @@ static int efipci_supported ( EFI_HANDLE device ) {
364 364
 
365 365
 	/* Look for a driver */
366 366
 	if ( ( rc = pci_find_driver ( &pci ) ) != 0 ) {
367
-		DBGCP ( device, "EFIPCI %s has no driver\n",
368
-			efi_handle_name ( device ) );
367
+		DBGC ( device, "EFIPCI " PCI_FMT " (%04x:%04x class %06x) "
368
+		       "has no driver\n", PCI_ARGS ( &pci ), pci.vendor,
369
+		       pci.device, pci.class );
369 370
 		return rc;
370 371
 	}
371
-	DBGC ( device, "EFIPCI %s has driver \"%s\"\n",
372
-	       efi_handle_name ( device ), pci.id->name );
372
+	DBGC ( device, "EFIPCI " PCI_FMT " (%04x:%04x class %06x) has driver "
373
+	       "\"%s\"\n", PCI_ARGS ( &pci ), pci.vendor, pci.device,
374
+	       pci.class, pci.id->name );
373 375
 
374 376
 	return 0;
375 377
 }
@@ -404,8 +406,8 @@ static int efipci_start ( struct efi_device *efidev ) {
404 406
 
405 407
 	/* Find driver */
406 408
 	if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
407
-		DBGC ( device, "EFIPCI %s has no driver\n",
408
-		       efi_handle_name ( device ) );
409
+		DBGC ( device, "EFIPCI " PCI_FMT " has no driver\n",
410
+		       PCI_ARGS ( pci ) );
409 411
 		goto err_find_driver;
410 412
 	}
411 413
 
@@ -415,13 +417,13 @@ static int efipci_start ( struct efi_device *efidev ) {
415 417
 
416 418
 	/* Probe driver */
417 419
 	if ( ( rc = pci_probe ( pci ) ) != 0 ) {
418
-		DBGC ( device, "EFIPCI %s could not probe driver \"%s\": %s\n",
419
-		       efi_handle_name ( device ), pci->id->name,
420
+		DBGC ( device, "EFIPCI " PCI_FMT " could not probe driver "
421
+		       "\"%s\": %s\n", PCI_ARGS ( pci ), pci->id->name,
420 422
 		       strerror ( rc ) );
421 423
 		goto err_probe;
422 424
 	}
423
-	DBGC ( device, "EFIPCI %s using driver \"%s\"\n",
424
-	       efi_handle_name ( device ), pci->id->name );
425
+	DBGC ( device, "EFIPCI " PCI_FMT " using driver \"%s\"\n",
426
+	       PCI_ARGS ( pci ), pci->id->name );
425 427
 
426 428
 	efidev_set_drvdata ( efidev, pci );
427 429
 	return 0;

Loading…
Annulla
Salva