From 4f6a8b30c9ca96ca4df6ed16232bbc9eeba05a5e Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Fri, 19 Jun 2009 21:40:55 +0800 Subject: [PATCH] Put mp_nbusses and bus_data under APIC_IO --- sys/platform/pc32/i386/mp_machdep.c | 37 +++++++++++++++-------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sys/platform/pc32/i386/mp_machdep.c b/sys/platform/pc32/i386/mp_machdep.c index 1be79555eb..385f09c5bd 100644 --- a/sys/platform/pc32/i386/mp_machdep.c +++ b/sys/platform/pc32/i386/mp_machdep.c @@ -230,8 +230,8 @@ int current_postcode; extern struct region_descriptor r_gdt, r_idt; int mp_naps; /* # of Applications processors */ -static int mp_nbusses; /* # of busses */ #ifdef APIC_IO +static int mp_nbusses; /* # of busses */ int mp_napics; /* # of IO APICs */ #endif vm_offset_t cpu_apic_address; @@ -708,18 +708,20 @@ static int default_data[7][5] = }; +#ifdef APIC_IO + /* the bus data */ static bus_datum *bus_data; -#ifdef APIC_IO /* the IO INT data, one entry per possible APIC INTerrupt */ static io_int *io_apic_ints; static int nintrs; + #endif static int processor_entry (proc_entry_ptr entry, int cpu); -static int bus_entry (bus_entry_ptr entry, int bus); #ifdef APIC_IO +static int bus_entry (bus_entry_ptr entry, int bus); static int io_apic_entry (io_apic_entry_ptr entry, int apic); static int int_entry (int_entry_ptr entry, int intr); #endif @@ -767,8 +769,8 @@ mptable_pass1(struct mptable_pos *mpt) /* init everything to empty */ mp_naps = 0; - mp_nbusses = 0; #ifdef APIC_IO + mp_nbusses = 0; mp_napics = 0; nintrs = 0; #endif @@ -784,8 +786,8 @@ mptable_pass1(struct mptable_pos *mpt) /* fill in with defaults */ mp_naps = 2; /* includes BSP */ - mp_nbusses = default_data[fps->mpfb1 - 1][0]; #if defined(APIC_IO) + mp_nbusses = default_data[fps->mpfb1 - 1][0]; mp_napics = 1; nintrs = 16; #endif /* APIC_IO */ @@ -813,7 +815,9 @@ mptable_pass1(struct mptable_pos *mpt) } break; case 1: /* bus_entry */ +#ifdef APIC_IO ++mp_nbusses; +#endif break; case 2: /* io_apic_entry */ #ifdef APIC_IO @@ -898,9 +902,9 @@ mptable_pass2(struct mptable_pos *mpt) M_DEVBUF, M_WAITOK | M_ZERO); MALLOC(io_apic_ints, io_int *, sizeof(io_int) * (nintrs + FIXUP_EXTRA_APIC_INTS), M_DEVBUF, M_WAITOK); -#endif MALLOC(bus_data, bus_datum *, sizeof(bus_datum) * mp_nbusses, M_DEVBUF, M_WAITOK); +#endif #ifdef APIC_IO for (i = 0; i < mp_napics; i++) { @@ -917,11 +921,11 @@ mptable_pass2(struct mptable_pos *mpt) #endif } +#ifdef APIC_IO /* clear bus data table */ for (x = 0; x < mp_nbusses; ++x) bus_data[x].bus_id = 0xff; -#ifdef APIC_IO /* clear IO APIC INT table */ for (x = 0; x < (nintrs + 1); ++x) { io_apic_ints[x].int_type = 0xff; @@ -969,8 +973,10 @@ mptable_pass2(struct mptable_pos *mpt) } break; case 1: +#ifdef APIC_IO if (bus_entry(position, bus)) ++bus; +#endif break; case 2: #ifdef APIC_IO @@ -1369,14 +1375,13 @@ io_apic_find_int_entry(int apic, int pin) static void mptable_fix(void) { - int x; #ifdef APIC_IO + int x; int id; int apic; /* IO APIC unit number */ int freeid; /* Free physical APIC ID */ int physid; /* Current physical IO APIC ID */ io_int *io14; -#endif int bus_0 = 0; /* Stop GCC warning */ int bus_pci = 0; /* Stop GCC warning */ int num_pci_bus; @@ -1419,7 +1424,6 @@ mptable_fix(void) bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type; bus_data[bus_0].bus_type = PCI; -#ifdef APIC_IO /* swap each relavant INTerrupt entry */ id = bus_data[bus_pci].bus_id; for (x = 0; x < nintrs; ++x) { @@ -1430,10 +1434,8 @@ mptable_fix(void) io_apic_ints[x].src_bus_id = id; } } -#endif } -#ifdef APIC_IO /* Assign IO APIC IDs. * * First try the existing ID. If a conflict is detected, try @@ -1469,9 +1471,7 @@ mptable_fix(void) panic("Free physical APIC ID not usable"); } fix_id_to_io_mapping(); -#endif -#ifdef APIC_IO /* detect and fix broken Compaq MP table */ if (apic_int_type(0, 0) == -1) { kprintf("APIC_IO: MP table broken: 8259->APIC entry missing!\n"); @@ -1593,6 +1593,7 @@ processor_entry(proc_entry_ptr entry, int cpu) return 0; } +#ifdef APIC_IO static int bus_entry(bus_entry_ptr entry, int bus) @@ -1617,8 +1618,6 @@ bus_entry(bus_entry_ptr entry, int bus) return 1; } -#ifdef APIC_IO - static int io_apic_entry(io_apic_entry_ptr entry, int apic) { @@ -1883,6 +1882,8 @@ undirect_pci_irq(int rirq) } +#ifdef APIC_IO + /* * given a bus ID, return: * the bus type if found @@ -1900,8 +1901,6 @@ apic_bus_type(int id) return -1; } -#ifdef APIC_IO - /* * given a LOGICAL APIC# and pin#, return: * the associated src bus ID if found @@ -2110,10 +2109,12 @@ mptable_default(int type) case 5: case 6: case 7: +#ifdef APIC_IO bus_data[0].bus_id = default_data[type - 1][1]; bus_data[0].bus_type = default_data[type - 1][2]; bus_data[1].bus_id = default_data[type - 1][3]; bus_data[1].bus_type = default_data[type - 1][4]; +#endif break; /* case 4: case 7: MCA NOT supported */ -- 2.41.0