Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Localify, add a comment and merge some others.



details:   https://anonhg.NetBSD.org/src/rev/41e9f20219af
branches:  trunk
changeset: 351247:41e9f20219af
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Feb 08 09:39:32 2017 +0000

description:
Localify, add a comment and merge some others.

diffstat:

 sys/arch/amd64/amd64/gdt.c       |  10 +++++++---
 sys/arch/amd64/include/gdt.h     |   4 +---
 sys/arch/i386/i386/gdt.c         |  27 ++++++++++++++++-----------
 sys/arch/i386/include/segments.h |   3 +--
 4 files changed, 25 insertions(+), 19 deletions(-)

diffs (165 lines):

diff -r 76b16857a69f -r 41e9f20219af sys/arch/amd64/amd64/gdt.c
--- a/sys/arch/amd64/amd64/gdt.c        Wed Feb 08 09:00:37 2017 +0000
+++ b/sys/arch/amd64/amd64/gdt.c        Wed Feb 08 09:39:32 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.c,v 1.34 2016/08/21 10:42:33 maxv Exp $    */
+/*     $NetBSD: gdt.c,v 1.35 2017/02/08 09:39:32 maxv Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.34 2016/08/21 10:42:33 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.35 2017/02/08 09:39:32 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -63,6 +63,7 @@
 int gdt_next;          /* next available slot for sweeping */
 int gdt_free;          /* next free slot; terminated with GNULL_SEL */
 
+static void set_sys_gdt(int, void *, size_t, int, int, int);
 void gdt_init(void);
 
 void
@@ -84,7 +85,10 @@
 #endif
 }
 
-void
+/*
+ * Called on a newly-allocated GDT slot, so no race between CPUs.
+ */
+static void
 set_sys_gdt(int slot, void *base, size_t limit, int type, int dpl, int gran)
 {
        union {
diff -r 76b16857a69f -r 41e9f20219af sys/arch/amd64/include/gdt.h
--- a/sys/arch/amd64/include/gdt.h      Wed Feb 08 09:00:37 2017 +0000
+++ b/sys/arch/amd64/include/gdt.h      Wed Feb 08 09:39:32 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.h,v 1.8 2016/08/20 18:31:06 maxv Exp $     */
+/*     $NetBSD: gdt.h,v 1.9 2017/02/08 09:39:32 maxv Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -44,8 +44,6 @@
 
 int ldt_alloc(void *, size_t);
 void ldt_free(int);
-
-void set_sys_gdt(int, void *, size_t, int, int, int);
 #endif
 
 #define MINGDTSIZ       PAGE_SIZE
diff -r 76b16857a69f -r 41e9f20219af sys/arch/i386/i386/gdt.c
--- a/sys/arch/i386/i386/gdt.c  Wed Feb 08 09:00:37 2017 +0000
+++ b/sys/arch/i386/i386/gdt.c  Wed Feb 08 09:39:32 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.c,v 1.57 2017/02/05 10:42:21 maxv Exp $    */
+/*     $NetBSD: gdt.c,v 1.58 2017/02/08 09:39:32 maxv Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.57 2017/02/05 10:42:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.58 2017/02/08 09:39:32 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -60,6 +60,7 @@
 static int ldt_count;  /* number of LDTs */
 static int ldt_max = 1000;/* max number of LDTs */
 
+static void setgdt(int, const void *, size_t, int, int, int, int);
 void gdt_init(void);
 static void gdt_grow(int);
 static int gdt_get_slot1(int);
@@ -81,7 +82,10 @@
 #endif
 }
 
-void
+/*
+ * Called on a newly-allocated GDT slot, so no race between CPUs.
+ */
+static void
 setgdt(int sel, const void *base, size_t limit, int type, int dpl, int def32,
     int gran)
 {
@@ -104,7 +108,8 @@
 }
 
 /*
- * Initialize the GDT subsystem.  Called from autoconf().
+ * Initialize the GDT. We already have a gdtstore, which was temporarily used
+ * by the bootstrap code. Now, we allocate a new gdtstore, and put it in cpu0.
  */
 void
 gdt_init(void)
@@ -152,7 +157,8 @@
 }
 
 /*
- * Allocate shadow GDT for a slave CPU.
+ * Allocate shadow GDT for a secondary CPU. It contains the same values as the
+ * GDT present in cpu0 (gdtstore).
  */
 void
 gdt_alloc_cpu(struct cpu_info *ci)
@@ -180,10 +186,9 @@
            sizeof(struct cpu_info) - 1, SDT_MEMRWA, SEL_KPL, 1, 0);
 }
 
-
 /*
- * Load appropriate gdt descriptor; we better be running on *ci
- * (for the most part, this is how a CPU knows who it is).
+ * Load appropriate GDT descriptor into the currently running CPU, which must
+ * be ci.
  */
 void
 gdt_init_cpu(struct cpu_info *ci)
@@ -227,7 +232,6 @@
 }
 
 #if defined(MULTIPROCESSOR) && !defined(XEN)
-
 void
 gdt_reload_cpu(struct cpu_info *ci)
 {
@@ -240,9 +244,10 @@
 }
 #endif
 
-
 /*
- * Grow the GDT.
+ * Grow the GDT. The GDT is present on each CPU, so we need to iterate over all
+ * of them. We already have the virtual memory, we only need to grow the
+ * physical memory.
  */
 void
 gdt_grow(int which)
diff -r 76b16857a69f -r 41e9f20219af sys/arch/i386/include/segments.h
--- a/sys/arch/i386/include/segments.h  Wed Feb 08 09:00:37 2017 +0000
+++ b/sys/arch/i386/include/segments.h  Wed Feb 08 09:39:32 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: segments.h,v 1.58 2017/02/05 10:42:21 maxv Exp $       */
+/*     $NetBSD: segments.h,v 1.59 2017/02/08 09:39:32 maxv Exp $       */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -197,7 +197,6 @@
 void setregion(struct region_descriptor *, void *, size_t);
 void setsegment(struct segment_descriptor *, const void *, size_t, int, int,
     int, int);
-void setgdt(int, const void *, size_t, int, int, int, int);
 void unsetgate(struct gate_descriptor *);
 void cpu_init_idt(void);
 void update_descriptor(union descriptor *, union descriptor *);



Home | Main Index | Thread Index | Old Index