2 * Copyright (c) 1982, 1986 The Regents of the University of California.
3 * Copyright (c) 1989, 1990 William Jolitz
4 * Copyright (c) 1994 John Dyson
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department, and William Jolitz.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
40 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
41 * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.132.2.9 2003/01/25 19:02:23 dillon Exp $
42 * $DragonFly: src/sys/platform/pc64/amd64/vm_machdep.c,v 1.2 2007/09/24 03:24:45 yanyh Exp $
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/malloc.h>
50 #include <sys/interrupt.h>
51 #include <sys/vnode.h>
52 #include <sys/vmmeter.h>
53 #include <sys/kernel.h>
54 #include <sys/sysctl.h>
55 #include <sys/unistd.h>
57 #include <machine/clock.h>
58 #include <machine/cpu.h>
59 #include <machine/md_var.h>
60 #include <machine/smp.h>
61 #include <machine/pcb_ext.h>
62 #include <machine/pcb.h>
63 #include <machine/segments.h>
64 #include <machine/globaldata.h> /* npxthread */
67 #include <vm/vm_param.h>
69 #include <vm/vm_kern.h>
70 #include <vm/vm_page.h>
71 #include <vm/vm_map.h>
72 #include <vm/vm_extern.h>
74 #include <sys/thread2.h>
76 char machine[] = MACHINE;
78 char cpu_vendor[] = "DragonFly"; /* XXX */
79 u_int cpu_id = 0x80000000; /* XXX */
82 * Finish a fork operation, with lwp lp2 nearly set up.
83 * Copy and update the pcb, set up the stack so that the child
84 * ready to run and return to user mode.
87 cpu_fork(struct lwp *lp1, struct lwp *lp2, int flags)
92 * Prepare new lwp to return to the address specified in params.
95 cpu_prepare_lwp(struct lwp *lp, struct lwp_params *params)
101 * Intercept the return address from a freshly forked process that has NOT
102 * been scheduled yet.
104 * This is needed to make kernel threads stay in kernel mode.
107 cpu_set_fork_handler(struct lwp *lp, void (*func)(void *, struct trapframe *),
113 cpu_set_thread_handler(thread_t td, void (*rfunc)(void), void *func, void *arg)
123 * Terminate the current thread. The caller must have already acquired
124 * the thread's rwlock and placed it on a reap list or otherwise notified
125 * a reaper of its existance. We set a special assembly switch function which
126 * releases td_rwlock after it has cleaned up the MMU state and switched
129 * Must be caller from a critical section and with the thread descheduled.
132 cpu_thread_exit(void)
137 * Process Reaper. Called after the caller has acquired the thread's
138 * rwlock and removed it from the reap list.
141 cpu_proc_wait(struct proc *p)
146 kvm_access_check(vm_offset_t saddr, vm_offset_t eaddr, int prot)