david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[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>
This commit is contained in:
Michael Brown 2017-05-01 14:01:54 +01:00
parent b91cc983da
commit 17887f87b7
1 changed files with 31 additions and 29 deletions

View File

@ -87,8 +87,8 @@ static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
&efi_pci_root_bridge_io_protocol_guid, &efi_pci_root_bridge_io_protocol_guid,
NULL, &num_handles, &handles ) ) != 0 ) { NULL, &num_handles, &handles ) ) != 0 ) {
rc = -EEFI ( efirc ); rc = -EEFI ( efirc );
DBGC ( pci, "EFIPCI cannot locate root bridges: %s\n", DBGC ( pci, "EFIPCI " PCI_FMT " cannot locate root bridges: "
strerror ( rc ) ); "%s\n", PCI_ARGS ( pci ), strerror ( rc ) );
goto err_locate; goto err_locate;
} }
@ -100,8 +100,9 @@ static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
&u.interface, efi_image_handle, *handle, &u.interface, efi_image_handle, *handle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
rc = -EEFI ( efirc ); rc = -EEFI ( efirc );
DBGC ( pci, "EFIPCI cannot open %s: %s\n", DBGC ( pci, "EFIPCI " PCI_FMT " cannot open %s: %s\n",
efi_handle_name ( *handle ), strerror ( rc ) ); PCI_ARGS ( pci ), efi_handle_name ( *handle ),
strerror ( rc ) );
continue; continue;
} }
if ( u.root->SegmentNumber == PCI_SEG ( pci->busdevfn ) ) { if ( u.root->SegmentNumber == PCI_SEG ( pci->busdevfn ) ) {
@ -113,7 +114,7 @@ static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
&efi_pci_root_bridge_io_protocol_guid, &efi_pci_root_bridge_io_protocol_guid,
efi_image_handle, *handle ); efi_image_handle, *handle );
} }
DBGC ( pci, "EFIPCI found no root bridge for " PCI_FMT "\n", DBGC ( pci, "EFIPCI " PCI_FMT " found no root bridge\n",
PCI_ARGS ( pci ) ); PCI_ARGS ( pci ) );
rc = -ENOENT; rc = -ENOENT;
@ -163,9 +164,9 @@ int efipci_read ( struct pci_device *pci, unsigned long location,
efipci_address ( pci, location ), 1, efipci_address ( pci, location ), 1,
value ) ) != 0 ) { value ) ) != 0 ) {
rc = -EEFI ( efirc ); rc = -EEFI ( efirc );
DBG ( "EFIPCI config read from " PCI_FMT " offset %02lx " DBGC ( pci, "EFIPCI " PCI_FMT " config read from offset %02lx "
"failed: %s\n", PCI_ARGS ( pci ), "failed: %s\n", PCI_ARGS ( pci ),
EFIPCI_OFFSET ( location ), strerror ( rc ) ); EFIPCI_OFFSET ( location ), strerror ( rc ) );
goto err_read; goto err_read;
} }
@ -201,9 +202,9 @@ int efipci_write ( struct pci_device *pci, unsigned long location,
efipci_address ( pci, location ), 1, efipci_address ( pci, location ), 1,
&value ) ) != 0 ) { &value ) ) != 0 ) {
rc = -EEFI ( efirc ); rc = -EEFI ( efirc );
DBG ( "EFIPCI config write to " PCI_FMT " offset %02lx " DBGC ( pci, "EFIPCI " PCI_FMT " config write to offset %02lx "
"failed: %s\n", PCI_ARGS ( pci ), "failed: %s\n", PCI_ARGS ( pci ),
EFIPCI_OFFSET ( location ), strerror ( rc ) ); EFIPCI_OFFSET ( location ), strerror ( rc ) );
goto err_write; goto err_write;
} }
@ -268,10 +269,10 @@ int efipci_open ( EFI_HANDLE device, UINT32 attributes,
efi_handle_name ( device ), strerror ( rc ) ); efi_handle_name ( device ), strerror ( rc ) );
goto err_get_location; goto err_get_location;
} }
DBGC2 ( device, "EFIPCI %s is PCI %04lx:%02lx:%02lx.%lx\n", busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn );
efi_handle_name ( device ), ( ( unsigned long ) pci_segment ), pci_init ( pci, busdevfn );
( ( unsigned long ) pci_bus ), ( ( unsigned long ) pci_dev ), DBGCP ( device, "EFIPCI " PCI_FMT " is %s\n",
( ( unsigned long ) pci_fn ) ); PCI_ARGS ( pci ), efi_handle_name ( device ) );
/* Try to enable I/O cycles, memory cycles, and bus mastering. /* Try to enable I/O cycles, memory cycles, and bus mastering.
* Some platforms will 'helpfully' report errors if these bits * Some platforms will 'helpfully' report errors if these bits
@ -290,11 +291,10 @@ int efipci_open ( EFI_HANDLE device, UINT32 attributes,
EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, NULL ); EFI_PCI_IO_ATTRIBUTE_BUS_MASTER, NULL );
/* Populate PCI device */ /* Populate PCI device */
busdevfn = PCI_BUSDEVFN ( pci_segment, pci_bus, pci_dev, pci_fn );
pci_init ( pci, busdevfn );
if ( ( rc = pci_read_config ( pci ) ) != 0 ) { if ( ( rc = pci_read_config ( pci ) ) != 0 ) {
DBGC ( device, "EFIPCI %s cannot read PCI configuration: %s\n", DBGC ( device, "EFIPCI " PCI_FMT " cannot read PCI "
efi_handle_name ( device ), strerror ( rc ) ); "configuration: %s\n",
PCI_ARGS ( pci ), strerror ( rc ) );
goto err_pci_read_config; goto err_pci_read_config;
} }
@ -364,12 +364,14 @@ static int efipci_supported ( EFI_HANDLE device ) {
/* Look for a driver */ /* Look for a driver */
if ( ( rc = pci_find_driver ( &pci ) ) != 0 ) { if ( ( rc = pci_find_driver ( &pci ) ) != 0 ) {
DBGCP ( device, "EFIPCI %s has no driver\n", DBGC ( device, "EFIPCI " PCI_FMT " (%04x:%04x class %06x) "
efi_handle_name ( device ) ); "has no driver\n", PCI_ARGS ( &pci ), pci.vendor,
pci.device, pci.class );
return rc; return rc;
} }
DBGC ( device, "EFIPCI %s has driver \"%s\"\n", DBGC ( device, "EFIPCI " PCI_FMT " (%04x:%04x class %06x) has driver "
efi_handle_name ( device ), pci.id->name ); "\"%s\"\n", PCI_ARGS ( &pci ), pci.vendor, pci.device,
pci.class, pci.id->name );
return 0; return 0;
} }
@ -404,8 +406,8 @@ static int efipci_start ( struct efi_device *efidev ) {
/* Find driver */ /* Find driver */
if ( ( rc = pci_find_driver ( pci ) ) != 0 ) { if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
DBGC ( device, "EFIPCI %s has no driver\n", DBGC ( device, "EFIPCI " PCI_FMT " has no driver\n",
efi_handle_name ( device ) ); PCI_ARGS ( pci ) );
goto err_find_driver; goto err_find_driver;
} }
@ -415,13 +417,13 @@ static int efipci_start ( struct efi_device *efidev ) {
/* Probe driver */ /* Probe driver */
if ( ( rc = pci_probe ( pci ) ) != 0 ) { if ( ( rc = pci_probe ( pci ) ) != 0 ) {
DBGC ( device, "EFIPCI %s could not probe driver \"%s\": %s\n", DBGC ( device, "EFIPCI " PCI_FMT " could not probe driver "
efi_handle_name ( device ), pci->id->name, "\"%s\": %s\n", PCI_ARGS ( pci ), pci->id->name,
strerror ( rc ) ); strerror ( rc ) );
goto err_probe; goto err_probe;
} }
DBGC ( device, "EFIPCI %s using driver \"%s\"\n", DBGC ( device, "EFIPCI " PCI_FMT " using driver \"%s\"\n",
efi_handle_name ( device ), pci->id->name ); PCI_ARGS ( pci ), pci->id->name );
efidev_set_drvdata ( efidev, pci ); efidev_set_drvdata ( efidev, pci );
return 0; return 0;