Index: sys/arch/amd64/amd64/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/machdep.c,v
retrieving revision 1.245
diff -u -r1.245 machdep.c
--- sys/arch/amd64/amd64/machdep.c 26 Dec 2016 13:55:13 -0000 1.245
+++ sys/arch/amd64/amd64/machdep.c 26 Dec 2016 17:11:58 -0000
@@ -254,14 +254,6 @@
size_t dump_header_size;
size_t dump_totalbytesleft;
-vaddr_t msgbuf_vaddr;
-
-struct {
- paddr_t paddr;
- psize_t sz;
-} msgbuf_p_seg[VM_PHYSSEG_MAX];
-unsigned int msgbuf_p_cnt = 0;
-
vaddr_t idt_vaddr;
paddr_t idt_paddr;
vaddr_t gdt_vaddr;
@@ -1466,52 +1458,6 @@
extern vector *IDTVEC(exceptions)[];
static void
-init_x86_64_msgbuf(void)
-{
- /* Message buffer is located at end of core. */
- psize_t sz = round_page(MSGBUFSIZE);
- psize_t reqsz = sz;
- uvm_physseg_t x;
-
- search_again:
- for (x = uvm_physseg_get_first();
- uvm_physseg_valid_p(x);
- x = uvm_physseg_get_next(x)) {
-
- if (ctob(uvm_physseg_get_avail_end(x)) == avail_end)
- break;
- }
-
- if (uvm_physseg_valid_p(x) == false)
- panic("init_x86_64: can't find end of memory");
-
- /* Shrink so it'll fit in the last segment. */
- if (uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x) < atop(sz))
- sz = ctob(uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x));
-
- uvm_physseg_unplug(uvm_physseg_get_end(x) - atop(sz), atop(sz));
- msgbuf_p_seg[msgbuf_p_cnt].sz = sz;
- msgbuf_p_seg[msgbuf_p_cnt++].paddr = ctob(uvm_physseg_get_avail_end(x));
-
- /* Now find where the new avail_end is. */
- avail_end = ctob(uvm_physseg_get_avail_end(x));
-
- if (sz == reqsz)
- return;
-
- reqsz -= sz;
- if (msgbuf_p_cnt == VM_PHYSSEG_MAX) {
- /* No more segments available, bail out. */
- printf("WARNING: MSGBUFSIZE (%zu) too large, using %zu.\n",
- (size_t)MSGBUFSIZE, (size_t)(MSGBUFSIZE - reqsz));
- return;
- }
-
- sz = reqsz;
- goto search_again;
-}
-
-static void
init_x86_64_ksyms(void)
{
#if NKSYMS || defined(DDB) || defined(MODULAR)
@@ -1640,7 +1586,7 @@
atop(avail_start), atop(avail_end), VM_FREELIST_DEFAULT);
#endif
- init_x86_64_msgbuf();
+ init_x86_msgbuf();
pmap_growkernel(VM_MIN_KERNEL_ADDRESS + 32 * 1024 * 1024);
Index: sys/arch/i386/i386/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.775
diff -u -r1.775 machdep.c
--- sys/arch/i386/i386/machdep.c 26 Dec 2016 15:47:48 -0000 1.775
+++ sys/arch/i386/i386/machdep.c 26 Dec 2016 17:11:59 -0000
@@ -236,13 +236,6 @@
int i386_has_sse;
int i386_has_sse2;
-vaddr_t msgbuf_vaddr;
-struct {
- paddr_t paddr;
- psize_t sz;
-} msgbuf_p_seg[VM_PHYSSEG_MAX];
-unsigned int msgbuf_p_cnt = 0;
-
vaddr_t idt_vaddr;
paddr_t idt_paddr;
vaddr_t gdt_vaddr;
@@ -1034,51 +1027,6 @@
#endif /* !XEN */
}
-static void
-init386_msgbuf(void)
-{
- /* Message buffer is located at end of core. */
- psize_t sz = round_page(MSGBUFSIZE);
- psize_t reqsz = sz;
- uvm_physseg_t x;
-
-search_again:
- for (x = uvm_physseg_get_first();
- uvm_physseg_valid_p(x);
- x = uvm_physseg_get_next(x)) {
- if (ctob(uvm_physseg_get_avail_end(x)) == avail_end) {
- break;
- }
- }
- if (uvm_physseg_valid_p(x) == false)
- panic("init386: can't find end of memory");
-
- /* Shrink so it'll fit in the last segment. */
- if (uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x) < atop(sz))
- sz = ctob(uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x));
-
- uvm_physseg_unplug(uvm_physseg_get_end(x) - atop(sz), atop(sz));
- msgbuf_p_seg[msgbuf_p_cnt].sz = sz;
- msgbuf_p_seg[msgbuf_p_cnt++].paddr = ctob(uvm_physseg_get_avail_end(x));
-
- /* Now find where the new avail_end is. */
- avail_end = ctob(uvm_physseg_get_avail_end(x));
-
- if (sz == reqsz)
- return;
-
- reqsz -= sz;
- if (msgbuf_p_cnt == VM_PHYSSEG_MAX) {
- /* No more segments available, bail out. */
- printf("WARNING: MSGBUFSIZE (%zu) too large, using %zu.\n",
- (size_t)MSGBUFSIZE, (size_t)(MSGBUFSIZE - reqsz));
- return;
- }
-
- sz = reqsz;
- goto search_again;
-}
-
#ifndef XEN
static void
init386_pte0(void)
@@ -1273,7 +1221,7 @@
#endif /* !XEN */
- init386_msgbuf();
+ init_x86_msgbuf();
#if !defined(XEN) && NBIOSCALL > 0
/*
Index: sys/arch/x86/include/machdep.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/machdep.h,v
retrieving revision 1.8
diff -u -r1.8 machdep.h
--- sys/arch/x86/include/machdep.h 16 Jul 2016 17:02:34 -0000 1.8
+++ sys/arch/x86/include/machdep.h 26 Dec 2016 17:11:59 -0000
@@ -32,11 +32,21 @@
extern phys_ram_seg_t mem_clusters[];
extern int mem_cluster_cnt;
+extern vaddr_t msgbuf_vaddr;
+extern unsigned int msgbuf_p_cnt;
+
struct btinfo_memmap;
struct extent;
struct sysctllog;
+struct msgbuf_p_seg {
+ paddr_t paddr;
+ psize_t sz;
+};
+
+extern struct msgbuf_p_seg msgbuf_p_seg[];
+
void x86_cpu_idle_init(void);
void x86_cpu_idle_get(void (**)(void), char *, size_t);
void x86_cpu_idle_set(void (*)(void), const char *, bool);
@@ -45,6 +55,7 @@
void init_x86_clusters(void);
int init_x86_vm(paddr_t);
+void init_x86_msgbuf(void);
void x86_startup(void);
void x86_sysctl_machdep_setup(struct sysctllog **);
Index: sys/arch/x86/x86/x86_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/x86_machdep.c,v
retrieving revision 1.79
diff -u -r1.79 x86_machdep.c
--- sys/arch/x86/x86/x86_machdep.c 20 Dec 2016 14:03:15 -0000 1.79
+++ sys/arch/x86/x86/x86_machdep.c 26 Dec 2016 17:11:59 -0000
@@ -101,6 +101,14 @@
static kauth_listener_t x86_listener;
+vaddr_t msgbuf_vaddr;
+
+struct msgbuf_p_seg msgbuf_p_seg[VM_PHYSSEG_MAX];
+
+unsigned int msgbuf_p_cnt = 0;
+
+void init_x86_msgbuf(void);
+
/*
* Given the type of a bootinfo entry, looks for a matching item inside
* the bootinfo structure. If found, returns a pointer to it (which must
@@ -902,6 +910,52 @@
#endif /* !XEN */
void
+init_x86_msgbuf(void)
+{
+ /* Message buffer is located at end of core. */
+ psize_t sz = round_page(MSGBUFSIZE);
+ psize_t reqsz = sz;
+ uvm_physseg_t x;
+
+ search_again:
+ for (x = uvm_physseg_get_first();
+ uvm_physseg_valid_p(x);
+ x = uvm_physseg_get_next(x)) {
+
+ if (ctob(uvm_physseg_get_avail_end(x)) == avail_end)
+ break;
+ }
+
+ if (uvm_physseg_valid_p(x) == false)
+ panic("init_x86_msgbuf: can't find end of memory");
+
+ /* Shrink so it'll fit in the last segment. */
+ if (uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x) < atop(sz))
+ sz = ctob(uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x));
+
+ uvm_physseg_unplug(uvm_physseg_get_end(x) - atop(sz), atop(sz));
+ msgbuf_p_seg[msgbuf_p_cnt].sz = sz;
+ msgbuf_p_seg[msgbuf_p_cnt++].paddr = ctob(uvm_physseg_get_avail_end(x));
+
+ /* Now find where the new avail_end is. */
+ avail_end = ctob(uvm_physseg_get_avail_end(x));
+
+ if (sz == reqsz)
+ return;
+
+ reqsz -= sz;
+ if (msgbuf_p_cnt == VM_PHYSSEG_MAX) {
+ /* No more segments available, bail out. */
+ printf("WARNING: MSGBUFSIZE (%zu) too large, using %zu.\n",
+ (size_t)MSGBUFSIZE, (size_t)(MSGBUFSIZE - reqsz));
+ return;
+ }
+
+ sz = reqsz;
+ goto search_again;
+}
+
+void
x86_reset(void)
{
uint8_t b;