mirror of https://github.com/ipxe/ipxe.git
[pci] Support systems with multiple PCI root bridges
Extend the 16-bit PCI bus:dev.fn address to a 32-bit seg🚌dev.fn
address, assuming a segment value of zero in contexts where multiple
segments are unsupported by the underlying data structures (e.g. in
the iBFT or BOFM tables).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/56/head
parent
2c197517f2
commit
f76210961c
|
@ -39,7 +39,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
* @v where Location within PCI configuration space
|
* @v where Location within PCI configuration space
|
||||||
*/
|
*/
|
||||||
void pcidirect_prepare ( struct pci_device *pci, int where ) {
|
void pcidirect_prepare ( struct pci_device *pci, int where ) {
|
||||||
outl ( ( 0x80000000 | ( pci->busdevfn << 8 ) | ( where & ~3 ) ),
|
uint16_t busdevfn = ( pci->busdevfn & 0xffff );
|
||||||
|
|
||||||
|
outl ( ( 0x80000000 | ( busdevfn << 8 ) | ( where & ~3 ) ),
|
||||||
PCIDIRECT_CONFIG_ADDRESS );
|
PCIDIRECT_CONFIG_ADDRESS );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2232,6 +2232,10 @@ static int format_busdevfn_setting ( const struct setting_type *type __unused,
|
||||||
const void *raw, size_t raw_len, char *buf,
|
const void *raw, size_t raw_len, char *buf,
|
||||||
size_t len ) {
|
size_t len ) {
|
||||||
unsigned long busdevfn;
|
unsigned long busdevfn;
|
||||||
|
unsigned int seg;
|
||||||
|
unsigned int bus;
|
||||||
|
unsigned int slot;
|
||||||
|
unsigned int func;
|
||||||
int check_len;
|
int check_len;
|
||||||
|
|
||||||
/* Extract numeric value */
|
/* Extract numeric value */
|
||||||
|
@ -2240,9 +2244,14 @@ static int format_busdevfn_setting ( const struct setting_type *type __unused,
|
||||||
return check_len;
|
return check_len;
|
||||||
assert ( check_len == ( int ) raw_len );
|
assert ( check_len == ( int ) raw_len );
|
||||||
|
|
||||||
|
/* Extract PCI address components */
|
||||||
|
seg = PCI_SEG ( busdevfn );
|
||||||
|
bus = PCI_BUS ( busdevfn );
|
||||||
|
slot = PCI_SLOT ( busdevfn );
|
||||||
|
func = PCI_FUNC ( busdevfn );
|
||||||
|
|
||||||
/* Format value */
|
/* Format value */
|
||||||
return snprintf ( buf, len, "%02lx:%02lx.%lx", PCI_BUS ( busdevfn ),
|
return snprintf ( buf, len, "%04x:%02x:%02x.%x", seg, bus, slot, func );
|
||||||
PCI_SLOT ( busdevfn ), PCI_FUNC ( busdevfn ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** PCI bus:dev.fn setting type */
|
/** PCI bus:dev.fn setting type */
|
||||||
|
|
|
@ -175,7 +175,7 @@ void adjust_pci_device ( struct pci_device *pci ) {
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int pci_read_config ( struct pci_device *pci ) {
|
int pci_read_config ( struct pci_device *pci ) {
|
||||||
uint16_t busdevfn;
|
uint32_t busdevfn;
|
||||||
uint8_t hdrtype;
|
uint8_t hdrtype;
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
|
@ -203,8 +203,8 @@ int pci_read_config ( struct pci_device *pci ) {
|
||||||
pci_read_bases ( pci );
|
pci_read_bases ( pci );
|
||||||
|
|
||||||
/* Initialise generic device component */
|
/* Initialise generic device component */
|
||||||
snprintf ( pci->dev.name, sizeof ( pci->dev.name ),
|
snprintf ( pci->dev.name, sizeof ( pci->dev.name ), "%04x:%02x:%02x.%x",
|
||||||
"PCI%02x:%02x.%x", PCI_BUS ( pci->busdevfn ),
|
PCI_SEG ( pci->busdevfn ), PCI_BUS ( pci->busdevfn ),
|
||||||
PCI_SLOT ( pci->busdevfn ), PCI_FUNC ( pci->busdevfn ) );
|
PCI_SLOT ( pci->busdevfn ), PCI_FUNC ( pci->busdevfn ) );
|
||||||
pci->dev.desc.bus_type = BUS_TYPE_PCI;
|
pci->dev.desc.bus_type = BUS_TYPE_PCI;
|
||||||
pci->dev.desc.location = pci->busdevfn;
|
pci->dev.desc.location = pci->busdevfn;
|
||||||
|
@ -232,7 +232,7 @@ int pci_find_next ( struct pci_device *pci, unsigned int busdevfn ) {
|
||||||
|
|
||||||
/* Determine number of PCI buses */
|
/* Determine number of PCI buses */
|
||||||
if ( ! end )
|
if ( ! end )
|
||||||
end = PCI_BUSDEVFN ( pci_num_bus(), 0, 0 );
|
end = PCI_BUSDEVFN ( 0, pci_num_bus(), 0, 0 );
|
||||||
|
|
||||||
/* Find next PCI device, if any */
|
/* Find next PCI device, if any */
|
||||||
for ( ; busdevfn < end ; busdevfn++ ) {
|
for ( ; busdevfn < end ; busdevfn++ ) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ static int pci_settings_fetch ( struct settings *settings __unused,
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
/* Extract busdevfn, offset, and length from tag */
|
/* Extract busdevfn, offset, and length from tag */
|
||||||
tag_busdevfn = ( ( setting->tag >> 16 ) & 0xffff );
|
tag_busdevfn = ( setting->tag >> 16 );
|
||||||
tag_offset = ( ( setting->tag >> 8 ) & 0xff );
|
tag_offset = ( ( setting->tag >> 8 ) & 0xff );
|
||||||
tag_len = ( ( setting->tag >> 0 ) & 0xff );
|
tag_len = ( ( setting->tag >> 0 ) & 0xff );
|
||||||
|
|
||||||
|
|
|
@ -2060,6 +2060,7 @@ static int phantom_probe ( struct pci_device *pci ) {
|
||||||
struct net_device *netdev;
|
struct net_device *netdev;
|
||||||
struct phantom_nic *phantom;
|
struct phantom_nic *phantom;
|
||||||
struct settings *parent_settings;
|
struct settings *parent_settings;
|
||||||
|
unsigned int busdevfn;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Allocate Phantom device */
|
/* Allocate Phantom device */
|
||||||
|
@ -2090,19 +2091,20 @@ static int phantom_probe ( struct pci_device *pci ) {
|
||||||
* B2 will have this fixed; remove this hack when B1 is no
|
* B2 will have this fixed; remove this hack when B1 is no
|
||||||
* longer in use.
|
* longer in use.
|
||||||
*/
|
*/
|
||||||
if ( PCI_FUNC ( pci->busdevfn ) == 0 ) {
|
busdevfn = pci->busdevfn;
|
||||||
|
if ( PCI_FUNC ( busdevfn ) == 0 ) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for ( i = 0 ; i < 8 ; i++ ) {
|
for ( i = 0 ; i < 8 ; i++ ) {
|
||||||
uint32_t temp;
|
uint32_t temp;
|
||||||
pci->busdevfn =
|
pci->busdevfn =
|
||||||
PCI_BUSDEVFN ( PCI_BUS ( pci->busdevfn ),
|
PCI_BUSDEVFN ( PCI_SEG ( busdevfn ),
|
||||||
PCI_SLOT ( pci->busdevfn ), i );
|
PCI_BUS ( busdevfn ),
|
||||||
|
PCI_SLOT ( busdevfn ), i );
|
||||||
pci_read_config_dword ( pci, 0xc8, &temp );
|
pci_read_config_dword ( pci, 0xc8, &temp );
|
||||||
pci_read_config_dword ( pci, 0xc8, &temp );
|
pci_read_config_dword ( pci, 0xc8, &temp );
|
||||||
pci_write_config_dword ( pci, 0xc8, 0xf1000 );
|
pci_write_config_dword ( pci, 0xc8, 0xf1000 );
|
||||||
}
|
}
|
||||||
pci->busdevfn = PCI_BUSDEVFN ( PCI_BUS ( pci->busdevfn ),
|
pci->busdevfn = busdevfn;
|
||||||
PCI_SLOT ( pci->busdevfn ), 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise the command PEG */
|
/* Initialise the command PEG */
|
||||||
|
|
|
@ -195,8 +195,8 @@ struct pci_device {
|
||||||
uint32_t class;
|
uint32_t class;
|
||||||
/** Interrupt number */
|
/** Interrupt number */
|
||||||
uint8_t irq;
|
uint8_t irq;
|
||||||
/** Bus, device, and function (bus:dev.fn) number */
|
/** Segment, bus, device, and function (bus:dev.fn) number */
|
||||||
uint16_t busdevfn;
|
uint32_t busdevfn;
|
||||||
/** Driver for this device */
|
/** Driver for this device */
|
||||||
struct pci_driver *driver;
|
struct pci_driver *driver;
|
||||||
/** Driver-private data
|
/** Driver-private data
|
||||||
|
@ -241,11 +241,13 @@ struct pci_driver {
|
||||||
/** Declare a fallback PCI driver */
|
/** Declare a fallback PCI driver */
|
||||||
#define __pci_driver_fallback __table_entry ( PCI_DRIVERS, 02 )
|
#define __pci_driver_fallback __table_entry ( PCI_DRIVERS, 02 )
|
||||||
|
|
||||||
|
#define PCI_SEG( busdevfn ) ( ( (busdevfn) >> 16 ) & 0xffff )
|
||||||
#define PCI_BUS( busdevfn ) ( ( (busdevfn) >> 8 ) & 0xff )
|
#define PCI_BUS( busdevfn ) ( ( (busdevfn) >> 8 ) & 0xff )
|
||||||
#define PCI_SLOT( busdevfn ) ( ( (busdevfn) >> 3 ) & 0x1f )
|
#define PCI_SLOT( busdevfn ) ( ( (busdevfn) >> 3 ) & 0x1f )
|
||||||
#define PCI_FUNC( busdevfn ) ( ( (busdevfn) >> 0 ) & 0x07 )
|
#define PCI_FUNC( busdevfn ) ( ( (busdevfn) >> 0 ) & 0x07 )
|
||||||
#define PCI_BUSDEVFN( bus, slot, func ) \
|
#define PCI_BUSDEVFN( segment, bus, slot, func ) \
|
||||||
( ( (bus) << 8 ) | ( (slot) << 3 ) | ( (func) << 0 ) )
|
( ( (segment) << 16 ) | ( (bus) << 8 ) | \
|
||||||
|
( (slot) << 3 ) | ( (func) << 0 ) )
|
||||||
#define PCI_FIRST_FUNC( busdevfn ) ( (busdevfn) & ~0x07 )
|
#define PCI_FIRST_FUNC( busdevfn ) ( (busdevfn) & ~0x07 )
|
||||||
#define PCI_LAST_FUNC( busdevfn ) ( (busdevfn) | 0x07 )
|
#define PCI_LAST_FUNC( busdevfn ) ( (busdevfn) | 0x07 )
|
||||||
|
|
||||||
|
@ -271,12 +273,12 @@ struct pci_driver {
|
||||||
PCI_ID( _vendor, _device, _name, _description, _data )
|
PCI_ID( _vendor, _device, _name, _description, _data )
|
||||||
|
|
||||||
/** PCI device debug message format */
|
/** PCI device debug message format */
|
||||||
#define PCI_FMT "PCI %02x:%02x.%x"
|
#define PCI_FMT "%04x:%02x:%02x.%x"
|
||||||
|
|
||||||
/** PCI device debug message arguments */
|
/** PCI device debug message arguments */
|
||||||
#define PCI_ARGS( pci ) \
|
#define PCI_ARGS( pci ) \
|
||||||
PCI_BUS ( (pci)->busdevfn ), PCI_SLOT ( (pci)->busdevfn ), \
|
PCI_SEG ( (pci)->busdevfn ), PCI_BUS ( (pci)->busdevfn ), \
|
||||||
PCI_FUNC ( (pci)->busdevfn )
|
PCI_SLOT ( (pci)->busdevfn ), PCI_FUNC ( (pci)->busdevfn )
|
||||||
|
|
||||||
extern void adjust_pci_device ( struct pci_device *pci );
|
extern void adjust_pci_device ( struct pci_device *pci );
|
||||||
extern unsigned long pci_bar_start ( struct pci_device *pci,
|
extern unsigned long pci_bar_start ( struct pci_device *pci,
|
||||||
|
|
|
@ -313,12 +313,12 @@ int bofm ( userptr_t bofmtab, struct pci_device *pci ) {
|
||||||
}
|
}
|
||||||
DBG ( "BOFM: slot %d port %d%s is " PCI_FMT " mport %d\n",
|
DBG ( "BOFM: slot %d port %d%s is " PCI_FMT " mport %d\n",
|
||||||
en.slot, ( en.port + 1 ),
|
en.slot, ( en.port + 1 ),
|
||||||
( ( en.slot || en.port ) ? "" : "(?)" ),
|
( ( en.slot || en.port ) ? "" : "(?)" ), 0,
|
||||||
PCI_BUS ( en.busdevfn ), PCI_SLOT ( en.busdevfn ),
|
PCI_BUS ( en.busdevfn ), PCI_SLOT ( en.busdevfn ),
|
||||||
PCI_FUNC ( en.busdevfn ), en.mport );
|
PCI_FUNC ( en.busdevfn ), en.mport );
|
||||||
bofm = bofm_find_busdevfn ( en.busdevfn );
|
bofm = bofm_find_busdevfn ( en.busdevfn );
|
||||||
if ( ! bofm ) {
|
if ( ! bofm ) {
|
||||||
DBG ( "BOFM: " PCI_FMT " mport %d ignored\n",
|
DBG ( "BOFM: " PCI_FMT " mport %d ignored\n", 0,
|
||||||
PCI_BUS ( en.busdevfn ), PCI_SLOT ( en.busdevfn ),
|
PCI_BUS ( en.busdevfn ), PCI_SLOT ( en.busdevfn ),
|
||||||
PCI_FUNC ( en.busdevfn ), en.mport );
|
PCI_FUNC ( en.busdevfn ), en.mport );
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -61,58 +61,157 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** PCI root bridge I/O protocol */
|
/**
|
||||||
static EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *efipci;
|
* Locate EFI PCI root bridge I/O protocol
|
||||||
EFI_REQUEST_PROTOCOL ( EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL, &efipci );
|
*
|
||||||
|
* @v pci PCI device
|
||||||
|
* @ret handle EFI PCI root bridge handle
|
||||||
|
* @ret root EFI PCI root bridge I/O protocol, or NULL if not found
|
||||||
|
* @ret rc Return status code
|
||||||
|
*/
|
||||||
|
static int efipci_root ( struct pci_device *pci, EFI_HANDLE *handle,
|
||||||
|
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **root ) {
|
||||||
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
EFI_HANDLE *handles;
|
||||||
|
UINTN num_handles;
|
||||||
|
union {
|
||||||
|
void *interface;
|
||||||
|
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root;
|
||||||
|
} u;
|
||||||
|
EFI_STATUS efirc;
|
||||||
|
UINTN i;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
/* Enumerate all handles */
|
||||||
|
if ( ( efirc = bs->LocateHandleBuffer ( ByProtocol,
|
||||||
|
&efi_pci_root_bridge_io_protocol_guid,
|
||||||
|
NULL, &num_handles, &handles ) ) != 0 ) {
|
||||||
|
rc = -EEFI ( efirc );
|
||||||
|
DBGC ( pci, "EFIPCI cannot locate root bridges: %s\n",
|
||||||
|
strerror ( rc ) );
|
||||||
|
goto err_locate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Look for matching root bridge I/O protocol */
|
||||||
|
for ( i = 0 ; i < num_handles ; i++ ) {
|
||||||
|
*handle = handles[i];
|
||||||
|
if ( ( efirc = bs->OpenProtocol ( *handle,
|
||||||
|
&efi_pci_root_bridge_io_protocol_guid,
|
||||||
|
&u.interface, efi_image_handle, *handle,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||||
|
rc = -EEFI ( efirc );
|
||||||
|
DBGC ( pci, "EFIPCI cannot open %s: %s\n",
|
||||||
|
efi_handle_name ( *handle ), strerror ( rc ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( u.root->SegmentNumber == PCI_SEG ( pci->busdevfn ) ) {
|
||||||
|
*root = u.root;
|
||||||
|
bs->FreePool ( handles );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
bs->CloseProtocol ( *handle,
|
||||||
|
&efi_pci_root_bridge_io_protocol_guid,
|
||||||
|
efi_image_handle, *handle );
|
||||||
|
}
|
||||||
|
DBGC ( pci, "EFIPCI found no root bridge for " PCI_FMT "\n",
|
||||||
|
PCI_ARGS ( pci ) );
|
||||||
|
rc = -ENOENT;
|
||||||
|
|
||||||
|
bs->FreePool ( handles );
|
||||||
|
err_locate:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate EFI PCI configuration space address
|
||||||
|
*
|
||||||
|
* @v pci PCI device
|
||||||
|
* @v location Encoded offset and width
|
||||||
|
* @ret address EFI PCI address
|
||||||
|
*/
|
||||||
static unsigned long efipci_address ( struct pci_device *pci,
|
static unsigned long efipci_address ( struct pci_device *pci,
|
||||||
unsigned long location ) {
|
unsigned long location ) {
|
||||||
|
|
||||||
return EFI_PCI_ADDRESS ( PCI_BUS ( pci->busdevfn ),
|
return EFI_PCI_ADDRESS ( PCI_BUS ( pci->busdevfn ),
|
||||||
PCI_SLOT ( pci->busdevfn ),
|
PCI_SLOT ( pci->busdevfn ),
|
||||||
PCI_FUNC ( pci->busdevfn ),
|
PCI_FUNC ( pci->busdevfn ),
|
||||||
EFIPCI_OFFSET ( location ) );
|
EFIPCI_OFFSET ( location ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read from PCI configuration space
|
||||||
|
*
|
||||||
|
* @v pci PCI device
|
||||||
|
* @v location Encoded offset and width
|
||||||
|
* @ret value Value
|
||||||
|
* @ret rc Return status code
|
||||||
|
*/
|
||||||
int efipci_read ( struct pci_device *pci, unsigned long location,
|
int efipci_read ( struct pci_device *pci, unsigned long location,
|
||||||
void *value ) {
|
void *value ) {
|
||||||
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root;
|
||||||
|
EFI_HANDLE handle;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if ( ! efipci )
|
/* Identify root bridge */
|
||||||
return -ENOTSUP;
|
if ( ( rc = efipci_root ( pci, &handle, &root ) ) != 0 )
|
||||||
|
goto err_root;
|
||||||
|
|
||||||
if ( ( efirc = efipci->Pci.Read ( efipci, EFIPCI_WIDTH ( location ),
|
/* Read from configuration space */
|
||||||
|
if ( ( efirc = root->Pci.Read ( root, EFIPCI_WIDTH ( 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 "
|
DBG ( "EFIPCI config read from " PCI_FMT " offset %02lx "
|
||||||
"failed: %s\n", PCI_ARGS ( pci ),
|
"failed: %s\n", PCI_ARGS ( pci ),
|
||||||
EFIPCI_OFFSET ( location ), strerror ( rc ) );
|
EFIPCI_OFFSET ( location ), strerror ( rc ) );
|
||||||
return -EIO;
|
goto err_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
err_read:
|
||||||
|
bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid,
|
||||||
|
efi_image_handle, handle );
|
||||||
|
err_root:
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write to PCI configuration space
|
||||||
|
*
|
||||||
|
* @v pci PCI device
|
||||||
|
* @v location Encoded offset and width
|
||||||
|
* @v value Value
|
||||||
|
* @ret rc Return status code
|
||||||
|
*/
|
||||||
int efipci_write ( struct pci_device *pci, unsigned long location,
|
int efipci_write ( struct pci_device *pci, unsigned long location,
|
||||||
unsigned long value ) {
|
unsigned long value ) {
|
||||||
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *root;
|
||||||
|
EFI_HANDLE handle;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if ( ! efipci )
|
/* Identify root bridge */
|
||||||
return -ENOTSUP;
|
if ( ( rc = efipci_root ( pci, &handle, &root ) ) != 0 )
|
||||||
|
goto err_root;
|
||||||
|
|
||||||
if ( ( efirc = efipci->Pci.Write ( efipci, EFIPCI_WIDTH ( location ),
|
/* Read from configuration space */
|
||||||
|
if ( ( efirc = root->Pci.Write ( root, EFIPCI_WIDTH ( 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 "
|
DBG ( "EFIPCI config write to " PCI_FMT " offset %02lx "
|
||||||
"failed: %s\n", PCI_ARGS ( pci ),
|
"failed: %s\n", PCI_ARGS ( pci ),
|
||||||
EFIPCI_OFFSET ( location ), strerror ( rc ) );
|
EFIPCI_OFFSET ( location ), strerror ( rc ) );
|
||||||
return -EIO;
|
goto err_write;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
err_write:
|
||||||
|
bs->CloseProtocol ( handle, &efi_pci_root_bridge_io_protocol_guid,
|
||||||
|
efi_image_handle, handle );
|
||||||
|
err_root:
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
PROVIDE_PCIAPI_INLINE ( efi, pci_num_bus );
|
PROVIDE_PCIAPI_INLINE ( efi, pci_num_bus );
|
||||||
|
@ -146,6 +245,7 @@ int efipci_open ( EFI_HANDLE device, UINT32 attributes,
|
||||||
void *interface;
|
void *interface;
|
||||||
} pci_io;
|
} pci_io;
|
||||||
UINTN pci_segment, pci_bus, pci_dev, pci_fn;
|
UINTN pci_segment, pci_bus, pci_dev, pci_fn;
|
||||||
|
unsigned int busdevfn;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -190,7 +290,8 @@ 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 */
|
||||||
pci_init ( pci, PCI_BUSDEVFN ( pci_bus, pci_dev, pci_fn ) );
|
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 %s cannot read PCI configuration: %s\n",
|
||||||
efi_handle_name ( device ), strerror ( rc ) );
|
efi_handle_name ( device ), strerror ( rc ) );
|
||||||
|
|
|
@ -422,7 +422,9 @@ static void settings_test_exec ( void ) {
|
||||||
|
|
||||||
/* "busdevfn" setting type (no store capability) */
|
/* "busdevfn" setting type (no store capability) */
|
||||||
fetchf_ok ( &test_settings, &test_busdevfn_setting,
|
fetchf_ok ( &test_settings, &test_busdevfn_setting,
|
||||||
RAW ( 0x03, 0x45 ), "03:08.5" );
|
RAW ( 0x03, 0x45 ), "0000:03:08.5" );
|
||||||
|
fetchf_ok ( &test_settings, &test_busdevfn_setting,
|
||||||
|
RAW ( 0x00, 0x02, 0x0a, 0x21 ), "0002:0a:04.1" );
|
||||||
|
|
||||||
/* Clear and unregister test settings block */
|
/* Clear and unregister test settings block */
|
||||||
clear_settings ( &test_settings );
|
clear_settings ( &test_settings );
|
||||||
|
|
Loading…
Reference in New Issue