diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 0d0caab8c9bf..e6568c9410a8 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -22,12 +22,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.3 1997/04/28 00:24:47 fsmp Exp $ + * $Id: mp_machdep.c,v 1.2 1997/04/29 22:05:13 smp Exp smp $ */ #include "opt_smp.h" -#define FIX_MP_TABLE_WORKS_NOT +#define FIX_MP_TABLE_WORKS #include "opt_serial.h" @@ -670,10 +670,11 @@ parse_mp_table(void) static void fix_mp_table(void) { - int x; - int y; - int num_pci_bus; - bus_datum bus_record; + int x; + int id; + int bus_0; + int bus_pci; + int num_pci_bus; /* * Fix mis-numbering of the PCI bus and its INT entries if the BIOS @@ -687,51 +688,56 @@ fix_mp_table(void) * busses and associated INTs in an effort to "make it right". */ - /* count the number of PCI busses */ + /* find bus 0, PCI bus, count the number of PCI busses */ for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) + if (bus_data[x].bus_id == 0) { + bus_0 = x; + } + if (bus_data[x].bus_type == PCI) { ++num_pci_bus; + bus_pci = x; + } } + /* + * bus_0 == slot of bus with ID of 0 + * bus_pci == slot of last PCI bus encountered + */ /* check the 1 PCI bus case for sanity */ if (num_pci_bus == 1) { - /* if its in the first slot all is well */ - if (bus_data[0].bus_type == PCI) + /* if it is number 0 all is well */ + if (bus_data[bus_pci].bus_id == 0) return; /* mis-numbered, swap with whichever bus uses slot 0 */ - /* locate the entry holding the PCI bus */ - for (x = 1; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) - break; - } - - /* swap the bus entry records */ - bus_record = bus_data[0]; - bus_data[0] = bus_data[x]; - bus_data[x] = bus_record; + /* swap the bus entry types */ + bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type; + bus_data[bus_0].bus_type = PCI; /* swap each relavant INTerrupt entry */ - for (y = 0; y < nintrs; ++y) { - if (io_apic_ints[y].src_bus_id == x) - io_apic_ints[y].src_bus_id = 0; - else - if (io_apic_ints[y].src_bus_id == 0) - io_apic_ints[y].src_bus_id = x; + id = bus_data[bus_pci].bus_id; + for (x = 0; x < nintrs; ++x) { + if (io_apic_ints[x].src_bus_id == id) { + io_apic_ints[x].src_bus_id = 0; + } + else if (io_apic_ints[x].src_bus_id == 0) { + io_apic_ints[x].src_bus_id = id; + } } } /* sanity check if more than 1 PCI bus */ - else - if (num_pci_bus > 1) { - for (x = 0; x < num_pci_bus; ++x) { - if (bus_data[x].bus_type != PCI) { - printf("bad PCI bus numbering\n"); - panic("\n"); - } + else if (num_pci_bus > 1) { + for (x = 0; x < mp_nbusses; ++x) { + if (bus_data[x].bus_type != PCI) + continue; + if (bus_data[x].bus_id >= num_pci_bus ) { + printf("bad PCI bus numbering\n"); + panic("\n"); } } + } } #endif /* FIX_MP_TABLE_WORKS */ diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c index 0d0caab8c9bf..e6568c9410a8 100644 --- a/sys/amd64/amd64/mptable.c +++ b/sys/amd64/amd64/mptable.c @@ -22,12 +22,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.3 1997/04/28 00:24:47 fsmp Exp $ + * $Id: mp_machdep.c,v 1.2 1997/04/29 22:05:13 smp Exp smp $ */ #include "opt_smp.h" -#define FIX_MP_TABLE_WORKS_NOT +#define FIX_MP_TABLE_WORKS #include "opt_serial.h" @@ -670,10 +670,11 @@ parse_mp_table(void) static void fix_mp_table(void) { - int x; - int y; - int num_pci_bus; - bus_datum bus_record; + int x; + int id; + int bus_0; + int bus_pci; + int num_pci_bus; /* * Fix mis-numbering of the PCI bus and its INT entries if the BIOS @@ -687,51 +688,56 @@ fix_mp_table(void) * busses and associated INTs in an effort to "make it right". */ - /* count the number of PCI busses */ + /* find bus 0, PCI bus, count the number of PCI busses */ for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) + if (bus_data[x].bus_id == 0) { + bus_0 = x; + } + if (bus_data[x].bus_type == PCI) { ++num_pci_bus; + bus_pci = x; + } } + /* + * bus_0 == slot of bus with ID of 0 + * bus_pci == slot of last PCI bus encountered + */ /* check the 1 PCI bus case for sanity */ if (num_pci_bus == 1) { - /* if its in the first slot all is well */ - if (bus_data[0].bus_type == PCI) + /* if it is number 0 all is well */ + if (bus_data[bus_pci].bus_id == 0) return; /* mis-numbered, swap with whichever bus uses slot 0 */ - /* locate the entry holding the PCI bus */ - for (x = 1; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) - break; - } - - /* swap the bus entry records */ - bus_record = bus_data[0]; - bus_data[0] = bus_data[x]; - bus_data[x] = bus_record; + /* swap the bus entry types */ + bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type; + bus_data[bus_0].bus_type = PCI; /* swap each relavant INTerrupt entry */ - for (y = 0; y < nintrs; ++y) { - if (io_apic_ints[y].src_bus_id == x) - io_apic_ints[y].src_bus_id = 0; - else - if (io_apic_ints[y].src_bus_id == 0) - io_apic_ints[y].src_bus_id = x; + id = bus_data[bus_pci].bus_id; + for (x = 0; x < nintrs; ++x) { + if (io_apic_ints[x].src_bus_id == id) { + io_apic_ints[x].src_bus_id = 0; + } + else if (io_apic_ints[x].src_bus_id == 0) { + io_apic_ints[x].src_bus_id = id; + } } } /* sanity check if more than 1 PCI bus */ - else - if (num_pci_bus > 1) { - for (x = 0; x < num_pci_bus; ++x) { - if (bus_data[x].bus_type != PCI) { - printf("bad PCI bus numbering\n"); - panic("\n"); - } + else if (num_pci_bus > 1) { + for (x = 0; x < mp_nbusses; ++x) { + if (bus_data[x].bus_type != PCI) + continue; + if (bus_data[x].bus_id >= num_pci_bus ) { + printf("bad PCI bus numbering\n"); + panic("\n"); } } + } } #endif /* FIX_MP_TABLE_WORKS */ diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h index 0d0caab8c9bf..e6568c9410a8 100644 --- a/sys/amd64/include/mptable.h +++ b/sys/amd64/include/mptable.h @@ -22,12 +22,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.3 1997/04/28 00:24:47 fsmp Exp $ + * $Id: mp_machdep.c,v 1.2 1997/04/29 22:05:13 smp Exp smp $ */ #include "opt_smp.h" -#define FIX_MP_TABLE_WORKS_NOT +#define FIX_MP_TABLE_WORKS #include "opt_serial.h" @@ -670,10 +670,11 @@ parse_mp_table(void) static void fix_mp_table(void) { - int x; - int y; - int num_pci_bus; - bus_datum bus_record; + int x; + int id; + int bus_0; + int bus_pci; + int num_pci_bus; /* * Fix mis-numbering of the PCI bus and its INT entries if the BIOS @@ -687,51 +688,56 @@ fix_mp_table(void) * busses and associated INTs in an effort to "make it right". */ - /* count the number of PCI busses */ + /* find bus 0, PCI bus, count the number of PCI busses */ for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) + if (bus_data[x].bus_id == 0) { + bus_0 = x; + } + if (bus_data[x].bus_type == PCI) { ++num_pci_bus; + bus_pci = x; + } } + /* + * bus_0 == slot of bus with ID of 0 + * bus_pci == slot of last PCI bus encountered + */ /* check the 1 PCI bus case for sanity */ if (num_pci_bus == 1) { - /* if its in the first slot all is well */ - if (bus_data[0].bus_type == PCI) + /* if it is number 0 all is well */ + if (bus_data[bus_pci].bus_id == 0) return; /* mis-numbered, swap with whichever bus uses slot 0 */ - /* locate the entry holding the PCI bus */ - for (x = 1; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) - break; - } - - /* swap the bus entry records */ - bus_record = bus_data[0]; - bus_data[0] = bus_data[x]; - bus_data[x] = bus_record; + /* swap the bus entry types */ + bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type; + bus_data[bus_0].bus_type = PCI; /* swap each relavant INTerrupt entry */ - for (y = 0; y < nintrs; ++y) { - if (io_apic_ints[y].src_bus_id == x) - io_apic_ints[y].src_bus_id = 0; - else - if (io_apic_ints[y].src_bus_id == 0) - io_apic_ints[y].src_bus_id = x; + id = bus_data[bus_pci].bus_id; + for (x = 0; x < nintrs; ++x) { + if (io_apic_ints[x].src_bus_id == id) { + io_apic_ints[x].src_bus_id = 0; + } + else if (io_apic_ints[x].src_bus_id == 0) { + io_apic_ints[x].src_bus_id = id; + } } } /* sanity check if more than 1 PCI bus */ - else - if (num_pci_bus > 1) { - for (x = 0; x < num_pci_bus; ++x) { - if (bus_data[x].bus_type != PCI) { - printf("bad PCI bus numbering\n"); - panic("\n"); - } + else if (num_pci_bus > 1) { + for (x = 0; x < mp_nbusses; ++x) { + if (bus_data[x].bus_type != PCI) + continue; + if (bus_data[x].bus_id >= num_pci_bus ) { + printf("bad PCI bus numbering\n"); + panic("\n"); } } + } } #endif /* FIX_MP_TABLE_WORKS */ diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 0d0caab8c9bf..e6568c9410a8 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -22,12 +22,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.3 1997/04/28 00:24:47 fsmp Exp $ + * $Id: mp_machdep.c,v 1.2 1997/04/29 22:05:13 smp Exp smp $ */ #include "opt_smp.h" -#define FIX_MP_TABLE_WORKS_NOT +#define FIX_MP_TABLE_WORKS #include "opt_serial.h" @@ -670,10 +670,11 @@ parse_mp_table(void) static void fix_mp_table(void) { - int x; - int y; - int num_pci_bus; - bus_datum bus_record; + int x; + int id; + int bus_0; + int bus_pci; + int num_pci_bus; /* * Fix mis-numbering of the PCI bus and its INT entries if the BIOS @@ -687,51 +688,56 @@ fix_mp_table(void) * busses and associated INTs in an effort to "make it right". */ - /* count the number of PCI busses */ + /* find bus 0, PCI bus, count the number of PCI busses */ for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) + if (bus_data[x].bus_id == 0) { + bus_0 = x; + } + if (bus_data[x].bus_type == PCI) { ++num_pci_bus; + bus_pci = x; + } } + /* + * bus_0 == slot of bus with ID of 0 + * bus_pci == slot of last PCI bus encountered + */ /* check the 1 PCI bus case for sanity */ if (num_pci_bus == 1) { - /* if its in the first slot all is well */ - if (bus_data[0].bus_type == PCI) + /* if it is number 0 all is well */ + if (bus_data[bus_pci].bus_id == 0) return; /* mis-numbered, swap with whichever bus uses slot 0 */ - /* locate the entry holding the PCI bus */ - for (x = 1; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) - break; - } - - /* swap the bus entry records */ - bus_record = bus_data[0]; - bus_data[0] = bus_data[x]; - bus_data[x] = bus_record; + /* swap the bus entry types */ + bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type; + bus_data[bus_0].bus_type = PCI; /* swap each relavant INTerrupt entry */ - for (y = 0; y < nintrs; ++y) { - if (io_apic_ints[y].src_bus_id == x) - io_apic_ints[y].src_bus_id = 0; - else - if (io_apic_ints[y].src_bus_id == 0) - io_apic_ints[y].src_bus_id = x; + id = bus_data[bus_pci].bus_id; + for (x = 0; x < nintrs; ++x) { + if (io_apic_ints[x].src_bus_id == id) { + io_apic_ints[x].src_bus_id = 0; + } + else if (io_apic_ints[x].src_bus_id == 0) { + io_apic_ints[x].src_bus_id = id; + } } } /* sanity check if more than 1 PCI bus */ - else - if (num_pci_bus > 1) { - for (x = 0; x < num_pci_bus; ++x) { - if (bus_data[x].bus_type != PCI) { - printf("bad PCI bus numbering\n"); - panic("\n"); - } + else if (num_pci_bus > 1) { + for (x = 0; x < mp_nbusses; ++x) { + if (bus_data[x].bus_type != PCI) + continue; + if (bus_data[x].bus_id >= num_pci_bus ) { + printf("bad PCI bus numbering\n"); + panic("\n"); } } + } } #endif /* FIX_MP_TABLE_WORKS */ diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c index 0d0caab8c9bf..e6568c9410a8 100644 --- a/sys/i386/i386/mptable.c +++ b/sys/i386/i386/mptable.c @@ -22,12 +22,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.3 1997/04/28 00:24:47 fsmp Exp $ + * $Id: mp_machdep.c,v 1.2 1997/04/29 22:05:13 smp Exp smp $ */ #include "opt_smp.h" -#define FIX_MP_TABLE_WORKS_NOT +#define FIX_MP_TABLE_WORKS #include "opt_serial.h" @@ -670,10 +670,11 @@ parse_mp_table(void) static void fix_mp_table(void) { - int x; - int y; - int num_pci_bus; - bus_datum bus_record; + int x; + int id; + int bus_0; + int bus_pci; + int num_pci_bus; /* * Fix mis-numbering of the PCI bus and its INT entries if the BIOS @@ -687,51 +688,56 @@ fix_mp_table(void) * busses and associated INTs in an effort to "make it right". */ - /* count the number of PCI busses */ + /* find bus 0, PCI bus, count the number of PCI busses */ for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) + if (bus_data[x].bus_id == 0) { + bus_0 = x; + } + if (bus_data[x].bus_type == PCI) { ++num_pci_bus; + bus_pci = x; + } } + /* + * bus_0 == slot of bus with ID of 0 + * bus_pci == slot of last PCI bus encountered + */ /* check the 1 PCI bus case for sanity */ if (num_pci_bus == 1) { - /* if its in the first slot all is well */ - if (bus_data[0].bus_type == PCI) + /* if it is number 0 all is well */ + if (bus_data[bus_pci].bus_id == 0) return; /* mis-numbered, swap with whichever bus uses slot 0 */ - /* locate the entry holding the PCI bus */ - for (x = 1; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) - break; - } - - /* swap the bus entry records */ - bus_record = bus_data[0]; - bus_data[0] = bus_data[x]; - bus_data[x] = bus_record; + /* swap the bus entry types */ + bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type; + bus_data[bus_0].bus_type = PCI; /* swap each relavant INTerrupt entry */ - for (y = 0; y < nintrs; ++y) { - if (io_apic_ints[y].src_bus_id == x) - io_apic_ints[y].src_bus_id = 0; - else - if (io_apic_ints[y].src_bus_id == 0) - io_apic_ints[y].src_bus_id = x; + id = bus_data[bus_pci].bus_id; + for (x = 0; x < nintrs; ++x) { + if (io_apic_ints[x].src_bus_id == id) { + io_apic_ints[x].src_bus_id = 0; + } + else if (io_apic_ints[x].src_bus_id == 0) { + io_apic_ints[x].src_bus_id = id; + } } } /* sanity check if more than 1 PCI bus */ - else - if (num_pci_bus > 1) { - for (x = 0; x < num_pci_bus; ++x) { - if (bus_data[x].bus_type != PCI) { - printf("bad PCI bus numbering\n"); - panic("\n"); - } + else if (num_pci_bus > 1) { + for (x = 0; x < mp_nbusses; ++x) { + if (bus_data[x].bus_type != PCI) + continue; + if (bus_data[x].bus_id >= num_pci_bus ) { + printf("bad PCI bus numbering\n"); + panic("\n"); } } + } } #endif /* FIX_MP_TABLE_WORKS */ diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h index 0d0caab8c9bf..e6568c9410a8 100644 --- a/sys/i386/include/mptable.h +++ b/sys/i386/include/mptable.h @@ -22,12 +22,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.3 1997/04/28 00:24:47 fsmp Exp $ + * $Id: mp_machdep.c,v 1.2 1997/04/29 22:05:13 smp Exp smp $ */ #include "opt_smp.h" -#define FIX_MP_TABLE_WORKS_NOT +#define FIX_MP_TABLE_WORKS #include "opt_serial.h" @@ -670,10 +670,11 @@ parse_mp_table(void) static void fix_mp_table(void) { - int x; - int y; - int num_pci_bus; - bus_datum bus_record; + int x; + int id; + int bus_0; + int bus_pci; + int num_pci_bus; /* * Fix mis-numbering of the PCI bus and its INT entries if the BIOS @@ -687,51 +688,56 @@ fix_mp_table(void) * busses and associated INTs in an effort to "make it right". */ - /* count the number of PCI busses */ + /* find bus 0, PCI bus, count the number of PCI busses */ for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) + if (bus_data[x].bus_id == 0) { + bus_0 = x; + } + if (bus_data[x].bus_type == PCI) { ++num_pci_bus; + bus_pci = x; + } } + /* + * bus_0 == slot of bus with ID of 0 + * bus_pci == slot of last PCI bus encountered + */ /* check the 1 PCI bus case for sanity */ if (num_pci_bus == 1) { - /* if its in the first slot all is well */ - if (bus_data[0].bus_type == PCI) + /* if it is number 0 all is well */ + if (bus_data[bus_pci].bus_id == 0) return; /* mis-numbered, swap with whichever bus uses slot 0 */ - /* locate the entry holding the PCI bus */ - for (x = 1; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) - break; - } - - /* swap the bus entry records */ - bus_record = bus_data[0]; - bus_data[0] = bus_data[x]; - bus_data[x] = bus_record; + /* swap the bus entry types */ + bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type; + bus_data[bus_0].bus_type = PCI; /* swap each relavant INTerrupt entry */ - for (y = 0; y < nintrs; ++y) { - if (io_apic_ints[y].src_bus_id == x) - io_apic_ints[y].src_bus_id = 0; - else - if (io_apic_ints[y].src_bus_id == 0) - io_apic_ints[y].src_bus_id = x; + id = bus_data[bus_pci].bus_id; + for (x = 0; x < nintrs; ++x) { + if (io_apic_ints[x].src_bus_id == id) { + io_apic_ints[x].src_bus_id = 0; + } + else if (io_apic_ints[x].src_bus_id == 0) { + io_apic_ints[x].src_bus_id = id; + } } } /* sanity check if more than 1 PCI bus */ - else - if (num_pci_bus > 1) { - for (x = 0; x < num_pci_bus; ++x) { - if (bus_data[x].bus_type != PCI) { - printf("bad PCI bus numbering\n"); - panic("\n"); - } + else if (num_pci_bus > 1) { + for (x = 0; x < mp_nbusses; ++x) { + if (bus_data[x].bus_type != PCI) + continue; + if (bus_data[x].bus_id >= num_pci_bus ) { + printf("bad PCI bus numbering\n"); + panic("\n"); } } + } } #endif /* FIX_MP_TABLE_WORKS */ diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 0d0caab8c9bf..e6568c9410a8 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -22,12 +22,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.3 1997/04/28 00:24:47 fsmp Exp $ + * $Id: mp_machdep.c,v 1.2 1997/04/29 22:05:13 smp Exp smp $ */ #include "opt_smp.h" -#define FIX_MP_TABLE_WORKS_NOT +#define FIX_MP_TABLE_WORKS #include "opt_serial.h" @@ -670,10 +670,11 @@ parse_mp_table(void) static void fix_mp_table(void) { - int x; - int y; - int num_pci_bus; - bus_datum bus_record; + int x; + int id; + int bus_0; + int bus_pci; + int num_pci_bus; /* * Fix mis-numbering of the PCI bus and its INT entries if the BIOS @@ -687,51 +688,56 @@ fix_mp_table(void) * busses and associated INTs in an effort to "make it right". */ - /* count the number of PCI busses */ + /* find bus 0, PCI bus, count the number of PCI busses */ for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) + if (bus_data[x].bus_id == 0) { + bus_0 = x; + } + if (bus_data[x].bus_type == PCI) { ++num_pci_bus; + bus_pci = x; + } } + /* + * bus_0 == slot of bus with ID of 0 + * bus_pci == slot of last PCI bus encountered + */ /* check the 1 PCI bus case for sanity */ if (num_pci_bus == 1) { - /* if its in the first slot all is well */ - if (bus_data[0].bus_type == PCI) + /* if it is number 0 all is well */ + if (bus_data[bus_pci].bus_id == 0) return; /* mis-numbered, swap with whichever bus uses slot 0 */ - /* locate the entry holding the PCI bus */ - for (x = 1; x < mp_nbusses; ++x) { - if (bus_data[x].bus_type == PCI) - break; - } - - /* swap the bus entry records */ - bus_record = bus_data[0]; - bus_data[0] = bus_data[x]; - bus_data[x] = bus_record; + /* swap the bus entry types */ + bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type; + bus_data[bus_0].bus_type = PCI; /* swap each relavant INTerrupt entry */ - for (y = 0; y < nintrs; ++y) { - if (io_apic_ints[y].src_bus_id == x) - io_apic_ints[y].src_bus_id = 0; - else - if (io_apic_ints[y].src_bus_id == 0) - io_apic_ints[y].src_bus_id = x; + id = bus_data[bus_pci].bus_id; + for (x = 0; x < nintrs; ++x) { + if (io_apic_ints[x].src_bus_id == id) { + io_apic_ints[x].src_bus_id = 0; + } + else if (io_apic_ints[x].src_bus_id == 0) { + io_apic_ints[x].src_bus_id = id; + } } } /* sanity check if more than 1 PCI bus */ - else - if (num_pci_bus > 1) { - for (x = 0; x < num_pci_bus; ++x) { - if (bus_data[x].bus_type != PCI) { - printf("bad PCI bus numbering\n"); - panic("\n"); - } + else if (num_pci_bus > 1) { + for (x = 0; x < mp_nbusses; ++x) { + if (bus_data[x].bus_type != PCI) + continue; + if (bus_data[x].bus_id >= num_pci_bus ) { + printf("bad PCI bus numbering\n"); + panic("\n"); } } + } } #endif /* FIX_MP_TABLE_WORKS */