Source-Changes-HG archive

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

[src/sommerfeld_i386mp_1]: src/sys/arch/i386 MP: attempt to deal with the cas...



details:   https://anonhg.NetBSD.org/src/rev/25503fee868d
branches:  sommerfeld_i386mp_1
changeset: 482187:25503fee868d
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Mon Feb 21 18:46:14 2000 +0000

description:
MP: attempt to deal with the case where the BSP is at apic id 1 instead
of apic id 0.

diffstat:

 sys/arch/i386/i386/cpu.c          |  71 +++++++++++++++++--------------
 sys/arch/i386/i386/lapic.c        |  23 ++++++---
 sys/arch/i386/i386/locore.s       |  12 +++--
 sys/arch/i386/i386/mpbios.c       |  87 +++++++++++++-------------------------
 sys/arch/i386/include/cpu.h       |   4 +-
 sys/arch/i386/include/cpuvar.h    |   2 +-
 sys/arch/i386/include/i82489var.h |   5 +-
 7 files changed, 96 insertions(+), 108 deletions(-)

diffs (truncated from 488 to 300 lines):

diff -r 2908ad481f0d -r 25503fee868d sys/arch/i386/i386/cpu.c
--- a/sys/arch/i386/i386/cpu.c  Mon Feb 21 18:44:50 2000 +0000
+++ b/sys/arch/i386/i386/cpu.c  Mon Feb 21 18:46:14 2000 +0000
@@ -111,15 +111,33 @@
  * curproc, etc. are used early.
  */
 
-static struct cpu_info dummy_cpu_info;
+static struct cpu_info dummy_cpu_info; /* XXX */
 struct cpu_info *cpu_info[I386_MAXPROCS] = { &dummy_cpu_info };
 extern 
 
 void           cpu_hatch __P((void *));
 static void            cpu_boot_secondary __P((struct cpu_info *ci));
 static void    cpu_copy_trampoline __P((void));
+
+/*
+ * Runs once per boot once multiprocessor goo has been detected and
+ * the local APIC has been mapped.
+ * Called from mpbios_scan();
+ */
+void
+cpu_init_first()
+{
+       int cpunum = cpu_number();
+
+       if (cpunum != 0) {
+               cpu_info[0] = NULL;
+               cpu_info[cpunum] = &dummy_cpu_info;
+       }
+
+       cpu_copy_trampoline();
+}
 #endif
-
+       
 struct cfattach cpu_ca = {
        sizeof(struct cpu_info), cpu_match, cpu_attach
 };
@@ -144,22 +162,27 @@
 {
        struct cpu_info *ci = (struct cpu_info *)self;  
        struct cpu_attach_args  *caa = (struct cpu_attach_args  *) aux;
+
 #ifdef MULTIPROCESSOR
        int cpunum = caa->cpu_number;
        vaddr_t kstack;
        struct pcb *pcb;
-#endif
-       
-#ifdef MULTIPROCESSOR
-       if (cpunum == 0) {                                          /* XXX */
-               /* special-case CPU 0 */                            /* XXX */
-               if (cpu_info[0] == &dummy_cpu_info) {               /* XXX */
+
+       if (caa->cpu_role != CPU_ROLE_AP) {
+               if (cpunum != cpu_number()) {
+                       panic("%s: running cpu is at apic %d"
+                           " instead of at expected %d\n",
+                           self->dv_xname, cpu_number(), cpunum);
+               }
+               
+               /* special-case boot CPU */                         /* XXX */
+               if (cpu_info[cpunum] == &dummy_cpu_info) {          /* XXX */
                        ci->ci_curproc = dummy_cpu_info.ci_curproc; /* XXX */
-                       cpu_info[0] = NULL;                         /* XXX */
+                       cpu_info[cpunum] = NULL;                    /* XXX */
                }                                                   /* XXX */
-       }                                                           /* XXX */
+       }
        if (cpu_info[cpunum] != NULL)
-               panic("cpu %d already attached?", cpunum);
+               panic("cpu at apic id %d already attached?", cpunum);
 
        cpu_info[cpunum] = ci;
 #endif                 
@@ -204,38 +227,22 @@
                ci->ci_flags |= CPUF_PRESENT | CPUF_SP;
                identifycpu(ci);
                cpu_init(ci);
-#if NLAPIC > 0
-               if (caa->lapic_paddr) {
-                       /*
-                        * Map, and enable local apic
-                        */
-                       lapic_map(caa->lapic_paddr);
-                       lapic_enable();
-                       lapic_calibrate_timer(ci);
-               }
-#endif
                break;
 
        case CPU_ROLE_BP:
                printf("apid %d (", caa->cpu_number);
                printf("boot processor");
                ci->ci_flags |= CPUF_PRESENT | CPUF_BSP;
-#ifdef MULTIPROCESSOR          
-               cpu_copy_trampoline(); /* XXX WRONG PLACE */
-#endif
                printf(")\n");
                identifycpu(ci);
                cpu_init(ci);
 
 #if NLAPIC > 0
-               if (caa->lapic_paddr) {
-                       /*
-                        * Map, and enable local apic
-                        */
-                       lapic_map(caa->lapic_paddr);
-                       lapic_enable();
-                       lapic_calibrate_timer(ci);
-               }
+               /*
+                * Enable local apic
+                */
+               lapic_enable();
+               lapic_calibrate_timer(ci);
 #endif
                break;
                
diff -r 2908ad481f0d -r 25503fee868d sys/arch/i386/i386/lapic.c
--- a/sys/arch/i386/i386/lapic.c        Mon Feb 21 18:44:50 2000 +0000
+++ b/sys/arch/i386/i386/lapic.c        Mon Feb 21 18:46:14 2000 +0000
@@ -74,10 +74,11 @@
 static u_int32_t lapic_gettick __P((void));
 void           lapic_clockintr __P((void *));
 void           lapic_initclocks __P((void));
+static void    lapic_map __P((paddr_t));
 
-void
-lapic_map(apic_paddr)
-       paddr_t apic_paddr;
+static void
+lapic_map(lapic_base)
+       paddr_t lapic_base;
 {
        int s;
        pt_entry_t *pte;
@@ -88,7 +89,7 @@
        /*
         * Map local apic.
         */
-       pmap_enter(pmap_kernel(), va, apic_paddr,
+       pmap_enter(pmap_kernel(), va, lapic_base,
            VM_PROT_ALL, PMAP_WIRED|VM_PROT_ALL);
 
        /*
@@ -160,8 +161,17 @@
  * Initialize fixed idt vectors for use by local apic.
  */
 void
-lapic_vector_init(void)
+lapic_boot_init(lapic_base)
+       paddr_t lapic_base;
 {
+       lapic_map(lapic_base);
+
+#ifdef MULTIPROCESSOR
+       idt_vec_set(LAPIC_IPI_VECTOR, Xintripi);
+       cpu_init_first();
+#endif
+       
+       
        idt_vec_set(LAPIC_SPURIOUS_VECTOR, Xintrspurious);
        idt_vec_set(LAPIC_TIMER_VECTOR, Xintrltimer);
 
@@ -169,9 +179,6 @@
        idt_vec_set(LAPIC_SOFTNET_VECTOR, Xintrsoftnet);
        idt_vec_set(LAPIC_SOFTSER_VECTOR, Xintrsoftser);
 
-#ifdef MULTIPROCESSOR
-       idt_vec_set(LAPIC_IPI_VECTOR, Xintripi);
-#endif
 }
 
 static inline u_int32_t lapic_gettick()
diff -r 2908ad481f0d -r 25503fee868d sys/arch/i386/i386/locore.s
--- a/sys/arch/i386/i386/locore.s       Mon Feb 21 18:44:50 2000 +0000
+++ b/sys/arch/i386/i386/locore.s       Mon Feb 21 18:46:14 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.215.2.1 2000/02/20 18:06:41 sommerfeld Exp $      */
+/*     $NetBSD: locore.s,v 1.215.2.2 2000/02/21 18:46:14 sommerfeld Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -140,8 +140,8 @@
 
 #include <machine/i82489reg.h>
 
-#define GET_CPUINFO(reg)                               \
-       movzbl  _C_LABEL(local_apic)+LAPIC_ID+3,reg     ; \
+#define GET_CPUINFO(reg)                         \
+       movzbl  _C_LABEL(lapic_id)+3,reg        ; \
        movl    _C_LABEL(cpu_info)(,reg,4),reg
 
 #define GET_CURPROC(reg, treg)                 \
@@ -305,7 +305,9 @@
 #if NLAPIC > 0
        .globl _C_LABEL(local_apic)
 _C_LABEL(local_apic):
-               .space  LAPIC_TPRI
+               .space  LAPIC_ID
+_C_LABEL(lapic_id):    
+               .space  LAPIC_TPRI-LAPIC_ID
 _C_LABEL(lapic_tpr):           
                .space  LAPIC_PPRI-LAPIC_TPRI
 _C_LABEL(lapic_ppr):           
@@ -313,7 +315,7 @@
 _C_LABEL(lapic_isr):
                .space  NBPG-LAPIC_ISR
 #else
-       _C_LABEL(lapic_tpr):    
+_C_LABEL(lapic_tpr):   
        .long 0
 #endif
        
diff -r 2908ad481f0d -r 25503fee868d sys/arch/i386/i386/mpbios.c
--- a/sys/arch/i386/i386/mpbios.c       Mon Feb 21 18:44:50 2000 +0000
+++ b/sys/arch/i386/i386/mpbios.c       Mon Feb 21 18:46:14 2000 +0000
@@ -95,7 +95,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     $Id: mpbios.c,v 1.1.2.1 2000/02/20 17:09:12 sommerfeld Exp $
+ *     $Id: mpbios.c,v 1.1.2.2 2000/02/21 18:46:14 sommerfeld Exp $
  */
 
 /*
@@ -175,7 +175,7 @@
 static void mp_print_pci_intr (int intr);
 static void mp_print_isa_intr (int intr);
 
-static int mpbios_cpu __P((const u_int8_t *, struct device *, paddr_t));
+static int mpbios_cpu __P((const u_int8_t *, struct device *));
 static int mpbios_bus __P((const u_int8_t *, struct device *));
 static int mpbios_ioapic __P((const u_int8_t *, struct device *));
 static int mpbios_int __P((const u_int8_t *, int, struct mp_intr_map *));
@@ -318,24 +318,10 @@
        return 0;
 
  found:
-       if(mp_verbose) {
-#if 0
-               int i;
-               u_int8_t *cp = (u_int8_t *)mp_fps;
-#endif
-                       
+       if (mp_verbose)
                printf("%s: MP floating pointer found in %s at 0x%lx\n",
                    self->dv_xname, loc_where[scan_loc], mp_fp_map.pa);
 
-#if 0
-               printf("%s: Mapped in at %p\n", self->dv_xname, mp_fps);
-               printf("%s: fps is ", self->dv_xname);
-               for (i=0; i<16; i++)
-                       printf(" %02x", cp[i]);
-               printf("\n");
-#endif
-       }
-       
        if (mp_fps->pap == 0) {
                if (mp_fps->mpfb1 == 0) {
                        printf("%s: MP fps invalid: "
@@ -357,7 +343,7 @@
        
        mp_cth = mpbios_map (cthpa, cthlen, &mp_cfg_table_map);
        
-       if(mp_verbose)
+       if (mp_verbose)
                printf("%s: MP config table at 0x%lx, %d bytes long\n",
                    self->dv_xname, cthpa, cthlen);
 
@@ -425,7 +411,7 @@
        struct mp_map t;
 
        int i, len;
-       struct mpbios_fps *m;
+       const struct mpbios_fps *m;
        int end = count - sizeof(*m);
        const u_int8_t *base = mpbios_map (start, count, &t);   
 
@@ -439,28 +425,10 @@
                if ((m->signature == MP_FP_SIG) &&
                    ((len = m->length << 4) != 0) &&
                    mpbios_cksum(m, (m->length << 4)) == 0) {
-#if 0
-                       int j;
-                       const u_int8_t *cp = (const u_int8_t *)m;
-                       
-                       printf("%s: found at pa 0x%lx, va %p, len is %d\n",
-                           self->dv_xname, start + i, m, len);
 
-                       printf("%s: fps is ", self->dv_xname);
-                       for (j=0; j<16; j++)
-                               printf(" %02x", cp[j]);
-                       printf("\n");
-#endif
-                       
                        mpbios_unmap (&t);
 



Home | Main Index | Thread Index | Old Index