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 Initialize gdt on boot cpu earli...



details:   https://anonhg.NetBSD.org/src/rev/7054fbd0c9e0
branches:  sommerfeld_i386mp_1
changeset: 482504:7054fbd0c9e0
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sun Feb 24 01:58:56 2002 +0000

description:
Initialize gdt on boot cpu earlier in boot instead of in gdt_init().
Put apm back in GENERIC and APM_NO_IDLE in GENERIC.MP.
Subsystems which install gdt entries during autoconf no longer explode.
(Do *not* expect full apm functionality on multiprocessors).

diffstat:

 sys/arch/i386/conf/GENERIC    |   6 +++---
 sys/arch/i386/conf/GENERIC.MP |   3 ++-
 sys/arch/i386/i386/cpu.c      |   4 +++-
 sys/arch/i386/i386/gdt.c      |  36 ++++++++++++++++++++++++------------
 sys/arch/i386/include/gdt.h   |   3 ++-
 5 files changed, 34 insertions(+), 18 deletions(-)

diffs (196 lines):

diff -r c54b931999c0 -r 7054fbd0c9e0 sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Sun Feb 24 01:55:11 2002 +0000
+++ b/sys/arch/i386/conf/GENERIC        Sun Feb 24 01:58:56 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.300.2.26 2002/02/24 00:17:42 sommerfeld Exp $
+# $NetBSD: GENERIC,v 1.300.2.27 2002/02/24 01:58:56 sommerfeld Exp $
 #
 # GENERIC machine description file
 # 
@@ -20,7 +20,7 @@
 
 include        "arch/i386/conf/std.i386"
 
-#ident                 "GENERIC-$Revision: 1.300.2.26 $"
+#ident                 "GENERIC-$Revision: 1.300.2.27 $"
 
 maxusers       32              # estimated number of users
 
@@ -212,7 +212,7 @@
 cpu* at mainbus? apid ?
 #ioapic* at mainbus? apid ?
 
-#apm0  at mainbus0                     # Advanced power management
+apm0   at mainbus0                     # Advanced power management
 
 # Tuning for power management, see apm(4) for more details.
 #options       APM_NO_IDLE             # Don't call BIOS CPU idle function
diff -r c54b931999c0 -r 7054fbd0c9e0 sys/arch/i386/conf/GENERIC.MP
--- a/sys/arch/i386/conf/GENERIC.MP     Sun Feb 24 01:55:11 2002 +0000
+++ b/sys/arch/i386/conf/GENERIC.MP     Sun Feb 24 01:58:56 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: GENERIC.MP,v 1.1.2.5 2001/05/23 03:13:36 sommerfeld Exp $
+#      $NetBSD: GENERIC.MP,v 1.1.2.6 2002/02/24 01:58:57 sommerfeld Exp $
 #
 #      GENERIC.MP -- Generic, plus enable Multiprocessor support.
 #
@@ -8,6 +8,7 @@
 options                MULTIPROCESSOR
 options        COM_MPLOCK      # com MP locking; REQUIRED on MP i386
 
+options        APM_NO_IDLE
 #options       DIAGNOSTIC      # STRONGLY RECOMMENDED
 #options       LOCKDEBUG
 #options       MPDEBUG
diff -r c54b931999c0 -r 7054fbd0c9e0 sys/arch/i386/i386/cpu.c
--- a/sys/arch/i386/i386/cpu.c  Sun Feb 24 01:55:11 2002 +0000
+++ b/sys/arch/i386/i386/cpu.c  Sun Feb 24 01:58:56 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.1.2.25 2001/12/29 23:30:59 sommerfeld Exp $ */
+/* $NetBSD: cpu.c,v 1.1.2.26 2002/02/24 01:58:57 sommerfeld Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -291,6 +291,7 @@
                printf("(uniprocessor)\n");
                ci->ci_flags |= CPUF_PRESENT | CPUF_SP | CPUF_PRIMARY;
                identifycpu(ci);
+               gdt_init_cpu0(ci);
                cpu_init(ci);
                break;
 
@@ -298,6 +299,7 @@
                printf("apid %d (boot processor)\n", caa->cpu_number);
                ci->ci_flags |= CPUF_PRESENT | CPUF_BSP | CPUF_PRIMARY;
                identifycpu(ci);
+               gdt_init_cpu0(ci);
                cpu_init(ci);
 
 #if NLAPIC > 0
diff -r c54b931999c0 -r 7054fbd0c9e0 sys/arch/i386/i386/gdt.c
--- a/sys/arch/i386/i386/gdt.c  Sun Feb 24 01:55:11 2002 +0000
+++ b/sys/arch/i386/i386/gdt.c  Sun Feb 24 01:58:56 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.c,v 1.22.2.7 2001/12/30 03:35:02 sommerfeld Exp $  */
+/*     $NetBSD: gdt.c,v 1.22.2.8 2002/02/24 01:58:57 sommerfeld Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.22.2.7 2001/12/30 03:35:02 sommerfeld Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.22.2.8 2002/02/24 01:58:57 sommerfeld Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -99,7 +99,7 @@
        struct segment_descriptor *sd = &gdt[sel].sd;
        CPU_INFO_ITERATOR cii;
        struct cpu_info *ci;
-       
+
        setsegment(sd, base, limit, type, dpl, def32, gran);
        for (CPU_INFO_FOREACH(cii, ci))
                ci->ci_gdt[sel].sd = *sd;
@@ -169,19 +169,27 @@
 #endif
 
 /*
- * Initialize the GDT.
+ * Initialize the GDT subsystem.  Called from autoconf() relatively
+ * late in boot.
  */
 void
 gdt_init()
 {
+
+       lockinit(&gdt_lock_store, PZERO, "gdtlck", 0, 0);
+}
+
+/*
+ * Initialize the boot cpu's GDT; called very early in boot.
+ */
+void
+gdt_init_cpu0(struct cpu_info *ci)
+{
        size_t max_len, min_len;
        union descriptor *old_gdt;
-       struct cpu_info *ci = curcpu();
        struct vm_page *pg;
        vaddr_t va;
 
-       lockinit(&gdt_lock_store, PZERO, "gdtlck", 0, 0);
-
        max_len = MAXGDTSIZ * sizeof(gdt[0]);
        min_len = MINGDTSIZ * sizeof(gdt[0]);
 
@@ -204,9 +212,13 @@
        ci->ci_gdt = gdt;
        setsegment(&ci->ci_gdt[GCPU_SEL].sd, ci, sizeof(struct cpu_info)-1,
            SDT_MEMRWA, SEL_KPL, 1, 1);
+
        gdt_init_cpu(ci);
 }
 
+/*
+ * Allocate shadow GDT for a slave cpu.
+ */
 void
 gdt_alloc_cpu(struct cpu_info *ci)
 {
@@ -224,15 +236,15 @@
 
 
 /*
- * Load appropriate gdt descriptor.
+ * Load appropriate gdt descriptor; we better be running on *ci
+ * (for the most part, this is how a cpu knows who it is).
  */
-
 void
 gdt_init_cpu(struct cpu_info *ci)
 {
        struct region_descriptor region;
        size_t max_len;
-       
+
        max_len = MAXGDTSIZ * sizeof(gdt[0]);
        setregion(&region, ci->ci_gdt, max_len - 1);
        lgdt(&region);
@@ -245,7 +257,7 @@
 {
        struct region_descriptor region;
        size_t max_len;
-       
+
        max_len = MAXGDTSIZ * sizeof(gdt[0]);
        setregion(&region, ci->ci_gdt, max_len - 1);
        lgdt(&region);
@@ -353,7 +365,7 @@
 
        gdt[slot].gd.gd_type = SDT_SYSNULL;
 #if 0
-       /* 
+       /*
         * shrink the GDT if we're using less than 1/4 of it.
         * Shrinking at that point means we'll still have room for
         * almost 2x as many processes as are now running without
diff -r c54b931999c0 -r 7054fbd0c9e0 sys/arch/i386/include/gdt.h
--- a/sys/arch/i386/include/gdt.h       Sun Feb 24 01:55:11 2002 +0000
+++ b/sys/arch/i386/include/gdt.h       Sun Feb 24 01:58:56 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.h,v 1.7.10.4 2001/12/29 23:31:06 sommerfeld Exp $  */
+/*     $NetBSD: gdt.h,v 1.7.10.5 2002/02/24 01:58:58 sommerfeld Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -43,6 +43,7 @@
 
 void gdt_init __P((void));
 void gdt_init_cpu __P((struct cpu_info *));
+void gdt_init_cpu0 __P((struct cpu_info *));
 void gdt_reload_cpu __P((struct cpu_info *));
 void gdt_alloc_cpu __P((struct cpu_info *));
 int tss_alloc __P((struct pcb *));



Home | Main Index | Thread Index | Old Index