Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/i386 Some changes to make single-CPU systems t...



details:   https://anonhg.NetBSD.org/src/rev/937cab328ce8
branches:  trunk
changeset: 539882:937cab328ce8
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Thu Nov 28 16:37:35 2002 +0000

description:
Some changes to make single-CPU systems that have an ioapic (and
an MP BIOS table enabled) work. Some MULTIPROCESSOR defines to
make things compile, and a split of ci_cpuid into ci_cpuid and
ci_apicid. They're always equal for the MULTIPROCESSOR case,
but different otherwise (ci_cpuid will always be 0).

diffstat:

 sys/arch/i386/i386/cpu.c      |  14 ++++++++++----
 sys/arch/i386/i386/intr.c     |  16 +++++++++-------
 sys/arch/i386/i386/ioapic.c   |   4 ++--
 sys/arch/i386/i386/ipifuncs.c |   8 ++++----
 sys/arch/i386/i386/lapic.c    |   4 ++--
 sys/arch/i386/i386/mpbios.c   |   8 ++++----
 6 files changed, 31 insertions(+), 23 deletions(-)

diffs (236 lines):

diff -r 3de790410cec -r 937cab328ce8 sys/arch/i386/i386/cpu.c
--- a/sys/arch/i386/i386/cpu.c  Thu Nov 28 16:18:49 2002 +0000
+++ b/sys/arch/i386/i386/cpu.c  Thu Nov 28 16:37:35 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.6 2002/11/22 15:23:39 fvdl Exp $ */
+/* $NetBSD: cpu.c,v 1.7 2002/11/28 16:37:35 fvdl Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -266,13 +266,16 @@
        sc->sc_info = ci;
 
        ci->ci_dev = self;
-       ci->ci_cpuid = caa->cpu_number;
+       ci->ci_apicid = caa->cpu_number;
+#ifdef MULTIPROCESSOR
+       ci->ci_cpuid = ci->ci_apicid;
+#else
+       ci->ci_cpuid = 0;       /* False for APs, but they're not used anyway */
+#endif
        ci->ci_func = caa->cpu_func;
 
        simple_lock_init(&ci->ci_slock);
 
-       cpu_intr_init(ci);
-
 #if defined(MULTIPROCESSOR)
        /*
         * Allocate UPAGES contiguous pages for the idle PCB and stack.
@@ -308,6 +311,7 @@
        case CPU_ROLE_SP:
                printf("(uniprocessor)\n");
                ci->ci_flags |= CPUF_PRESENT | CPUF_SP | CPUF_PRIMARY;
+               cpu_intr_init(ci);
                identifycpu(ci);
                cpu_init(ci);
                cpu_set_tss_gates(ci);
@@ -316,6 +320,7 @@
        case CPU_ROLE_BP:
                printf("apid %d (boot processor)\n", caa->cpu_number);
                ci->ci_flags |= CPUF_PRESENT | CPUF_BSP | CPUF_PRIMARY;
+               cpu_intr_init(ci);
                identifycpu(ci);
                cpu_init(ci);
                cpu_set_tss_gates(ci);
@@ -339,6 +344,7 @@
                printf("apid %d (application processor)\n", caa->cpu_number);
 
 #if defined(MULTIPROCESSOR)
+               cpu_intr_init(ci);
                gdt_alloc_cpu(ci);
                cpu_set_tss_gates(ci);
                cpu_start_secondary(ci);
diff -r 3de790410cec -r 937cab328ce8 sys/arch/i386/i386/intr.c
--- a/sys/arch/i386/i386/intr.c Thu Nov 28 16:18:49 2002 +0000
+++ b/sys/arch/i386/i386/intr.c Thu Nov 28 16:37:35 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.4 2002/11/27 00:43:12 fvdl Exp $    */
+/*     $NetBSD: intr.c,v 1.5 2002/11/28 16:37:35 fvdl Exp $    */
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -460,7 +460,7 @@
 #ifdef INTRDEBUG
        printf("allocated pic %s type %s pin %d level %d to cpu%u slot %d idt entry %d\n",
            pic->pic_name, type == IST_EDGE ? "edge" : "level", pin, level,
-           (unsigned)ci->ci_cpuid, slot, idt_vec);
+           (unsigned)ci->ci_apicid, slot, idt_vec);
 #endif
 
        return (ih);
@@ -506,7 +506,7 @@
 
 #ifdef INTRDEBUG
        printf("cpu%lu: remove slot %d (pic %s pin %d vec %d)\n",
-           ci->ci_cpuid, ih->ih_slot, pic->pic_dev.dv_xname, ih->ih_pin,
+           ci->ci_apicid, ih->ih_slot, pic->pic_dev.dv_xname, ih->ih_pin,
            idtvec);
 #endif
 
@@ -535,7 +535,7 @@
 struct intrhand fake_timer_intrhand;
 struct intrhand fake_ipi_intrhand;
 
-#if NLAPIC > 0
+#if NLAPIC > 0 && defined(MULTIPROCESSOR)
 static char *i386_ipi_names[I386_NIPI] = I386_IPI_NAMES;
 #endif
 
@@ -547,7 +547,7 @@
 cpu_intr_init(struct cpu_info *ci)
 {
        struct intrsource *isp;
-#if NLAPIC > 0
+#if NLAPIC > 0 && defined(MULTIPROCESSOR)
        int i;
 #endif
 
@@ -604,6 +604,7 @@
        evcnt_attach_dynamic(&isp->is_evcnt, EVCNT_TYPE_INTR, NULL,
            ci->ci_dev->dv_xname, "timer");
 
+#ifdef MULTIPROCESSOR
        MALLOC(isp, struct intrsource *, sizeof (struct intrsource), M_DEVBUF,
            M_WAITOK|M_ZERO);
        if (isp == NULL)
@@ -619,6 +620,7 @@
                evcnt_attach_dynamic(&ci->ci_ipi_events[i], EVCNT_TYPE_INTR,
                    NULL, ci->ci_dev->dv_xname, i386_ipi_names[i]);
 #endif
+#endif
 
        intr_calculatemasks(ci);
 
@@ -651,7 +653,7 @@
        CPU_INFO_ITERATOR cii;
 
        for (CPU_INFO_FOREACH(cii, ci)) {
-               printf("cpu%d: interrupt masks:\n", (unsigned)ci->ci_cpuid);
+               printf("cpu%d: interrupt masks:\n", (unsigned)ci->ci_apicid);
                for (i = 0; i < NIPL; i++)
                        printf("IPL %d mask %lx unmask %lx\n", i,
                            (u_long)ci->ci_imask[i], (u_long)ci->ci_iunmask[i]);
@@ -661,7 +663,7 @@
                        if (isp == NULL)
                                continue;
                        printf("cpu%u source %d is pin %d from pic %s maxlevel %d\n",
-                           (unsigned)ci->ci_cpuid, i, isp->is_pin,
+                           (unsigned)ci->ci_apicid, i, isp->is_pin,
                            isp->is_pic->pic_name, isp->is_maxlevel);
                        for (ih = isp->is_handlers; ih != NULL;
                             ih = ih->ih_next)
diff -r 3de790410cec -r 937cab328ce8 sys/arch/i386/i386/ioapic.c
--- a/sys/arch/i386/i386/ioapic.c       Thu Nov 28 16:18:49 2002 +0000
+++ b/sys/arch/i386/i386/ioapic.c       Thu Nov 28 16:37:35 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ioapic.c,v 1.5 2002/11/22 15:23:40 fvdl Exp $  */
+/*     $NetBSD: ioapic.c,v 1.6 2002/11/28 16:37:35 fvdl Exp $  */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -368,7 +368,7 @@
                 * cpu's.  but there's no point in doing that until after 
                 * most interrupts run without the kernel lock.  
                 */
-               redhi |= (ci->ci_cpuid << IOAPIC_REDHI_DEST_SHIFT);
+               redhi |= (ci->ci_apicid << IOAPIC_REDHI_DEST_SHIFT);
 
                /* XXX derive this bit from BIOS info */
                if (pp->ip_type == IST_LEVEL)
diff -r 3de790410cec -r 937cab328ce8 sys/arch/i386/i386/ipifuncs.c
--- a/sys/arch/i386/i386/ipifuncs.c     Thu Nov 28 16:18:49 2002 +0000
+++ b/sys/arch/i386/i386/ipifuncs.c     Thu Nov 28 16:37:35 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipifuncs.c,v 1.5 2002/11/22 15:23:40 fvdl Exp $ */
+/* $NetBSD: ipifuncs.c,v 1.6 2002/11/28 16:37:35 fvdl Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -143,7 +143,7 @@
 #endif
 
 int
-i386_send_ipi (struct cpu_info *ci, int ipimask)
+i386_send_ipi(struct cpu_info *ci, int ipimask)
 {
        int ret;
 
@@ -153,7 +153,7 @@
        if (!(ci->ci_flags & CPUF_RUNNING))
                return ENOENT;
 
-       ret = i386_ipi(LAPIC_IPI_VECTOR, ci->ci_cpuid, LAPIC_DLMODE_FIXED);
+       ret = i386_ipi(LAPIC_IPI_VECTOR, ci->ci_apicid, LAPIC_DLMODE_FIXED);
        if (ret != 0) {
                printf("ipi of %x from %s to %s failed\n",
                    ipimask,
@@ -197,7 +197,7 @@
 }
 
 void
-i386_multicast_ipi (int cpumask, int ipimask)
+i386_multicast_ipi(int cpumask, int ipimask)
 {
        struct cpu_info *ci;
        CPU_INFO_ITERATOR cii;
diff -r 3de790410cec -r 937cab328ce8 sys/arch/i386/i386/lapic.c
--- a/sys/arch/i386/i386/lapic.c        Thu Nov 28 16:18:49 2002 +0000
+++ b/sys/arch/i386/i386/lapic.c        Thu Nov 28 16:37:35 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lapic.c,v 1.5 2002/11/22 15:23:41 fvdl Exp $ */
+/* $NetBSD: lapic.c,v 1.6 2002/11/28 16:37:36 fvdl Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -149,7 +149,7 @@
        for (i = 0; i < mp_nintr; i++) {
                mpi = &mp_intrs[i];
                if (mpi->ioapic == NULL && (mpi->cpu_id == MPS_ALL_APICS
-                                           || mpi->cpu_id == ci->ci_cpuid)) {
+                                           || mpi->cpu_id == ci->ci_apicid)) {
 #ifdef DIAGNOSTIC
                        if (mpi->ioapic_pin > 1)
                                panic("lapic_set_lvt: bad pin value %d",
diff -r 3de790410cec -r 937cab328ce8 sys/arch/i386/i386/mpbios.c
--- a/sys/arch/i386/i386/mpbios.c       Thu Nov 28 16:18:49 2002 +0000
+++ b/sys/arch/i386/i386/mpbios.c       Thu Nov 28 16:37:35 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mpbios.c,v 1.6 2002/11/22 15:23:43 fvdl Exp $  */
+/*     $NetBSD: mpbios.c,v 1.7 2002/11/28 16:37:36 fvdl Exp $  */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -1107,19 +1107,19 @@
         */
 
        if (ci->ci_flags & CPUF_AP) {
-               if ((error = i386_ipi_init(ci->ci_cpuid)) != 0)
+               if ((error = i386_ipi_init(ci->ci_apicid)) != 0)
                        return error;
 
                delay(10000);
 
                if (cpu_feature & CPUID_APIC) {
 
-                       if ((error = i386_ipi(MP_TRAMPOLINE/NBPG,ci->ci_cpuid,
+                       if ((error = i386_ipi(MP_TRAMPOLINE/NBPG,ci->ci_apicid,
                            LAPIC_DLMODE_STARTUP)) != 0)
                                return error;
                        delay(200);
 
-                       if ((error = i386_ipi(MP_TRAMPOLINE/NBPG,ci->ci_cpuid,
+                       if ((error = i386_ipi(MP_TRAMPOLINE/NBPG,ci->ci_apicid,
                            LAPIC_DLMODE_STARTUP)) != 0)
                                return error;
                        delay(200);



Home | Main Index | Thread Index | Old Index