Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/amd64 Add the prekern entry point in the kernel.
details: https://anonhg.NetBSD.org/src/rev/a2bf792b97f5
branches: trunk
changeset: 356688:a2bf792b97f5
user: maxv <maxv%NetBSD.org@localhost>
date: Sun Oct 08 08:26:01 2017 +0000
description:
Add the prekern entry point in the kernel.
diffstat:
sys/arch/amd64/amd64/prekern.c | 136 ++++++++++++++++++++++++++++++++++++++++
sys/arch/amd64/conf/files.amd64 | 3 +-
2 files changed, 138 insertions(+), 1 deletions(-)
diffs (157 lines):
diff -r 7ab5344bceb8 -r a2bf792b97f5 sys/arch/amd64/amd64/prekern.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amd64/amd64/prekern.c Sun Oct 08 08:26:01 2017 +0000
@@ -0,0 +1,136 @@
+/* $NetBSD: prekern.c,v 1.1 2017/10/08 08:26:01 maxv Exp $ */
+
+/*
+ * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Maxime Villard.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include "opt_realmem.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/cpu.h>
+#include <sys/conf.h>
+
+#include <uvm/uvm.h>
+#include <machine/pmap.h>
+#include <machine/bootinfo.h>
+#include <machine/cpufunc.h>
+
+#include <dev/isa/isareg.h>
+#include <machine/isa_machdep.h>
+
+struct prekern_args {
+ int boothowto;
+ void *bootinfo;
+ void *bootspace;
+ int esym;
+ int biosextmem;
+ int biosbasemem;
+ int cpuid_level;
+ uint32_t nox_flag;
+ uint64_t PDPpaddr;
+ vaddr_t atdevbase;
+ vaddr_t lwp0uarea;
+ paddr_t first_avail;
+};
+
+void main(void);
+void init_x86_64(paddr_t);
+
+static void prekern_copy_args(struct prekern_args *);
+static void prekern_unmap(void);
+int start_prekern(struct prekern_args *);
+
+static void
+prekern_copy_args(struct prekern_args *pkargs)
+{
+ extern int boothowto;
+ extern struct bootinfo bootinfo;
+ extern struct bootspace bootspace;
+ extern int esym;
+ extern int biosextmem;
+ extern int biosbasemem;
+ extern int cpuid_level;
+ extern uint32_t nox_flag;
+ extern uint64_t PDPpaddr;
+ extern vaddr_t lwp0uarea;
+
+ boothowto = pkargs->boothowto;
+ memcpy(&bootinfo, pkargs->bootinfo, sizeof(bootinfo));
+ memcpy(&bootspace, pkargs->bootspace, sizeof(bootspace));
+ esym = pkargs->esym;
+
+#ifndef REALEXTMEM
+ biosextmem = pkargs->biosextmem;
+#else
+ biosextmem = REALEXTMEM;
+#endif
+
+#ifndef REALBASEMEM
+ biosbasemem = pkargs->biosbasemem;
+#else
+ biosbasemem = REALBASEMEM;
+#endif
+
+ cpuid_level = pkargs->cpuid_level;
+ nox_flag = pkargs->nox_flag;
+ PDPpaddr = pkargs->PDPpaddr;
+ atdevbase = pkargs->atdevbase;
+ lwp0uarea = pkargs->lwp0uarea;
+}
+
+static void
+prekern_unmap(void)
+{
+ L4_BASE[0] = 0;
+ tlbflushg();
+}
+
+/*
+ * The prekern jumps here.
+ */
+int
+start_prekern(struct prekern_args *pkargs)
+{
+ paddr_t first_avail;
+
+ prekern_copy_args(pkargs);
+ first_avail = pkargs->first_avail;
+
+ init_x86_64(first_avail);
+
+ prekern_unmap();
+
+ main();
+
+ panic("main returned");
+
+ return -1;
+}
diff -r 7ab5344bceb8 -r a2bf792b97f5 sys/arch/amd64/conf/files.amd64
--- a/sys/arch/amd64/conf/files.amd64 Sun Oct 08 04:52:33 2017 +0000
+++ b/sys/arch/amd64/conf/files.amd64 Sun Oct 08 08:26:01 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.amd64,v 1.92 2017/08/15 08:51:38 maxv Exp $
+# $NetBSD: files.amd64,v 1.93 2017/10/08 08:26:01 maxv Exp $
#
# new style config file for amd64 architecture
#
@@ -46,6 +46,7 @@
file kern/subr_disk_mbr.c disk
file arch/amd64/amd64/gdt.c machdep
file arch/amd64/amd64/machdep.c machdep
+file arch/amd64/amd64/prekern.c machdep
file arch/amd64/amd64/process_machdep.c machdep
file arch/amd64/amd64/trap.c machdep
file arch/x86/x86/fpu.c machdep
Home |
Main Index |
Thread Index |
Old Index