|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /*
26: * Copyright (c) 1992 NeXT Computer, Inc.
27: *
28: * Intel386 Family: MD VM crud.
29: *
30: * HISTORY
31: *
32: * 18 May 1992 ? at NeXT
33: * Created.
34: */
35:
36: #import <sys/param.h>
37: #import <sys/buf.h>
38: #import <sys/errno.h>
39:
40: #import <kern/thread.h>
41:
42: #import <vm/vm_kern.h>
43:
44: #import <machdep/i386/cpu_inline.h>
45:
46: /*
47: * Move pages from one kernel virtual address to another.
48: * Both addresses are assumed to reside in the Sysmap,
49: * and size must be a multiple of the page size.
50: */
51: pagemove(from, to, size)
52: register caddr_t from, to;
53: int size;
54: {
55: register pt_entry_t *fpte, *tpte;
56:
57: if (size % I386_PGBYTES)
58: panic("pagemove");
59:
60: while (size > 0) {
61: fpte = pmap_pt_entry(kernel_pmap, (vm_offset_t)from);
62: tpte = pmap_pt_entry(kernel_pmap, (vm_offset_t)to);
63: *tpte++ = *fpte;
64: *fpte++ = (pt_entry_t) { 0 };
65: from += I386_PGBYTES;
66: to += I386_PGBYTES;
67: size -= I386_PGBYTES;
68: }
69:
70: flush_tlb();
71: }
72:
73: /*
74: * kernacc - check kernel access to kernel memory.
75: *
76: */
77: boolean_t
78: kernacc(
79: vm_offset_t base,
80: unsigned int len,
81: int op
82: )
83: {
84: vm_offset_t end = base + len;
85: pt_entry_t *pte;
86:
87: base = trunc_page(base);
88:
89: while (base < end) {
90: pte = pmap_pt_entry(kernel_pmap, base);
91: if (pte == PT_ENTRY_NULL)
92: return (FALSE);
93:
94: if (!pte->valid)
95: return (FALSE);
96:
97: if (op == B_WRITE && pte->prot == PT_PROT_KR)
98: return (FALSE);
99:
100: base += PAGE_SIZE;
101: }
102:
103: return (TRUE);
104: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.