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 Get ready for context switch cha...



details:   https://anonhg.NetBSD.org/src/rev/75485a96e112
branches:  sommerfeld_i386mp_1
changeset: 482249:75485a96e112
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sat Aug 12 17:53:00 2000 +0000

description:
Get ready for context switch changes:
 - initialize idle pcbs earlier, before the first tsleep (instead of as
part of booting the secondary cpu's), since we'll actually use them
when idling in the near future.
 - clean up cpu_hatch()
 - fixup curproc's cpu pointer when switching to "real" cpu_info (XXX).
 - turn on local apic clock in cpu_hatch()
 - load the right gdt descriptor in cpu_hatch()
 - return from cpu_hatch() instead of spinning there; current
mptramp code will spin; future code will jump to idle loop.

diffstat:

 sys/arch/i386/i386/autoconf.c |   3 +-
 sys/arch/i386/i386/cpu.c      |  61 ++++++++++++++++++++++--------------------
 sys/arch/i386/include/cpu.h   |   3 +-
 3 files changed, 36 insertions(+), 31 deletions(-)

diffs (150 lines):

diff -r 0137acbd12e6 -r 75485a96e112 sys/arch/i386/i386/autoconf.c
--- a/sys/arch/i386/i386/autoconf.c     Sat Aug 12 16:14:09 2000 +0000
+++ b/sys/arch/i386/i386/autoconf.c     Sat Aug 12 17:53:00 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.45.2.3 2000/06/25 19:37:02 sommerfeld Exp $     */
+/*     $NetBSD: autoconf.c,v 1.45.2.4 2000/08/12 17:53:02 sommerfeld Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -128,6 +128,7 @@
        /* Set up proc0's TSS and LDT (after the FPU is configured). */
        i386_proc0_tss_ldt_init();
 
+       cpu_init_idle_pcbs();
        /* XXX Finish deferred buffer cache allocation. */
        i386_bufinit();
 }
diff -r 0137acbd12e6 -r 75485a96e112 sys/arch/i386/i386/cpu.c
--- a/sys/arch/i386/i386/cpu.c  Sat Aug 12 16:14:09 2000 +0000
+++ b/sys/arch/i386/i386/cpu.c  Sat Aug 12 17:53:00 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.1.2.8 2000/08/07 01:08:33 sommerfeld Exp $ */
+/* $NetBSD: cpu.c,v 1.1.2.9 2000/08/12 17:53:02 sommerfeld Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -94,6 +94,7 @@
 #include <machine/pcb.h>
 #include <machine/specialreg.h>
 #include <machine/segments.h>
+#include <machine/gdt.h>
 
 #if NLAPIC > 0
 #include <machine/apicvar.h>
@@ -181,6 +182,7 @@
                if (cpu_info[cpunum] == &dummy_cpu_info) {          /* XXX */
                        ci->ci_curproc = dummy_cpu_info.ci_curproc; /* XXX */
                        cpu_info[cpunum] = NULL;                    /* XXX */
+                       ci->ci_curproc->p_cpu = ci;                 /* XXX */
                }                                                   /* XXX */
        }
        if (cpu_info[cpunum] != NULL)
@@ -318,7 +320,6 @@
                        continue;
                if ((ci->ci_flags & CPUF_PRESENT) == 0)
                        continue;
-               i386_init_pcb_tss_ldt(ci->ci_idle_pcb);
                if (ci->ci_flags & (CPUF_BSP|CPUF_SP|CPUF_PRIMARY))
                        continue;
                cpu_boot_secondary(ci);
@@ -326,6 +327,24 @@
 }
 
 void
+cpu_init_idle_pcbs()
+{
+       struct cpu_info *ci;
+       u_long i;
+
+       for (i=0; i < I386_MAXPROCS; i++) {
+               ci = cpu_info[i];
+               if (ci == NULL)
+                       continue;
+               if (ci->ci_idle_pcb == NULL)
+                       continue;
+               if ((ci->ci_flags & CPUF_PRESENT) == 0)
+                       continue;
+               i386_init_pcb_tss_ldt(ci->ci_idle_pcb);
+       }
+}
+
+void
 cpu_boot_secondary (ci)
        struct cpu_info *ci;
 {
@@ -360,46 +379,30 @@
 
 /*
  * The CPU ends up here when its ready to run
+ * This is called from code in mptramp.s; at this point, we are running
+ * in the idle pcb/idle stack of the new cpu.  When this function returns,
+ * this processor will enter the idle loop and start looking for work.
+ *
  * XXX should share some of this with init386 in machdep.c
- * for now it jumps into an infinite loop.
  */
 void
 cpu_hatch(void *v) 
 {
        struct cpu_info *ci = (struct cpu_info *)v;
-        struct region_descriptor region;
-#if 0
-       volatile int i;
-#endif
-       
+       int s;
+
        cpu_init_idt();
-
+       gdt_init_cpu();
        lapic_enable();
        lapic_set_lvt();
 
        cpu_init(ci);
 
-       splbio();               /* XXX prevent softints from running here.. */
-
+       s = splhigh();
        enable_intr();
-       printf("%s: CPU %d reporting for duty, Sir!\n",ci->ci_dev.dv_xname, cpu_number());
-       printf("%s: stack is %p\n", ci->ci_dev.dv_xname, &region);
-#if 0
-       printf("%s: sending IPI to cpu 0\n",ci->ci_dev.dv_xname);
-       i386_send_ipi(cpu_primary, I386_IPI_GMTB);
-
-       /* give it a chance to be handled.. */
-       for (i=0; i<1000000; i++)
-               ;
-       
-       printf("%s: sending another IPI to cpu 0\n",
-           ci->ci_dev.dv_xname);
-       i386_send_ipi(cpu_primary, I386_IPI_GMTB);
-#endif 
-       for (;;)
-               ;
-
-
+       lapic_initclocks();
+       printf("%s: CPU %d running\n",ci->ci_dev.dv_xname, cpu_number());
+       splx(s);
 }
 
 static void
diff -r 0137acbd12e6 -r 75485a96e112 sys/arch/i386/include/cpu.h
--- a/sys/arch/i386/include/cpu.h       Sat Aug 12 16:14:09 2000 +0000
+++ b/sys/arch/i386/include/cpu.h       Sat Aug 12 17:53:00 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.59.2.8 2000/06/26 02:04:14 sommerfeld Exp $  */
+/*     $NetBSD: cpu.h,v 1.59.2.9 2000/08/12 17:53:00 sommerfeld Exp $  */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -143,6 +143,7 @@
 extern u_long cpus_running;
 
 extern void cpu_boot_secondary_processors __P((void));
+extern void cpu_init_idle_pcbs __P((void));
 
 #define want_resched (curcpu()->ci_want_resched)
 #define astpending (curcpu()->ci_astpending)



Home | Main Index | Thread Index | Old Index