summaryrefslogtreecommitdiffstats
path: root/src/drivers
diff options
context:
space:
mode:
authorMichael Brown2016-06-09 10:36:28 +0200
committerMichael Brown2016-06-09 10:36:28 +0200
commitf76210961c76a3f54f673d668e21e30d2eed9612 (patch)
treedf0eb4b64085a587d2df39bcee478a6b320b9c01 /src/drivers
parent[libc] Always use a non-zero seed for the (non-crypto) RNG (diff)
downloadipxe-f76210961c76a3f54f673d668e21e30d2eed9612.tar.gz
ipxe-f76210961c76a3f54f673d668e21e30d2eed9612.tar.xz
ipxe-f76210961c76a3f54f673d668e21e30d2eed9612.zip
[pci] Support systems with multiple PCI root bridges
Extend the 16-bit PCI bus:dev.fn address to a 32-bit seg:bus: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>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/bus/pci.c8
-rw-r--r--src/drivers/bus/pci_settings.c2
-rw-r--r--src/drivers/net/phantom/phantom.c12
3 files changed, 12 insertions, 10 deletions
diff --git a/src/drivers/bus/pci.c b/src/drivers/bus/pci.c
index 6fbedd940..06b36a770 100644
--- a/src/drivers/bus/pci.c
+++ b/src/drivers/bus/pci.c
@@ -175,7 +175,7 @@ void adjust_pci_device ( struct pci_device *pci ) {
* @ret rc Return status code
*/
int pci_read_config ( struct pci_device *pci ) {
- uint16_t busdevfn;
+ uint32_t busdevfn;
uint8_t hdrtype;
uint32_t tmp;
@@ -203,8 +203,8 @@ int pci_read_config ( struct pci_device *pci ) {
pci_read_bases ( pci );
/* Initialise generic device component */
- snprintf ( pci->dev.name, sizeof ( pci->dev.name ),
- "PCI%02x:%02x.%x", PCI_BUS ( pci->busdevfn ),
+ snprintf ( pci->dev.name, sizeof ( pci->dev.name ), "%04x:%02x:%02x.%x",
+ PCI_SEG ( pci->busdevfn ), PCI_BUS ( pci->busdevfn ),
PCI_SLOT ( pci->busdevfn ), PCI_FUNC ( pci->busdevfn ) );
pci->dev.desc.bus_type = BUS_TYPE_PCI;
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 */
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 */
for ( ; busdevfn < end ; busdevfn++ ) {
diff --git a/src/drivers/bus/pci_settings.c b/src/drivers/bus/pci_settings.c
index 1cb9fa5a3..98005559d 100644
--- a/src/drivers/bus/pci_settings.c
+++ b/src/drivers/bus/pci_settings.c
@@ -70,7 +70,7 @@ static int pci_settings_fetch ( struct settings *settings __unused,
unsigned int i;
/* 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_len = ( ( setting->tag >> 0 ) & 0xff );
diff --git a/src/drivers/net/phantom/phantom.c b/src/drivers/net/phantom/phantom.c
index 38b66743c..781049ff4 100644
--- a/src/drivers/net/phantom/phantom.c
+++ b/src/drivers/net/phantom/phantom.c
@@ -2060,6 +2060,7 @@ static int phantom_probe ( struct pci_device *pci ) {
struct net_device *netdev;
struct phantom_nic *phantom;
struct settings *parent_settings;
+ unsigned int busdevfn;
int rc;
/* 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
* longer in use.
*/
- if ( PCI_FUNC ( pci->busdevfn ) == 0 ) {
+ busdevfn = pci->busdevfn;
+ if ( PCI_FUNC ( busdevfn ) == 0 ) {
unsigned int i;
for ( i = 0 ; i < 8 ; i++ ) {
uint32_t temp;
pci->busdevfn =
- PCI_BUSDEVFN ( PCI_BUS ( pci->busdevfn ),
- PCI_SLOT ( pci->busdevfn ), i );
+ PCI_BUSDEVFN ( PCI_SEG ( busdevfn ),
+ PCI_BUS ( busdevfn ),
+ PCI_SLOT ( busdevfn ), i );
pci_read_config_dword ( pci, 0xc8, &temp );
pci_read_config_dword ( pci, 0xc8, &temp );
pci_write_config_dword ( pci, 0xc8, 0xf1000 );
}
- pci->busdevfn = PCI_BUSDEVFN ( PCI_BUS ( pci->busdevfn ),
- PCI_SLOT ( pci->busdevfn ), 0 );
+ pci->busdevfn = busdevfn;
}
/* Initialise the command PEG */