|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * The contents of this file constitute Original Code as defined in and
7: * are subject to the Apple Public Source License Version 1.1 (the
8: * "License"). You may not use this file except in compliance with the
9: * License. Please obtain a copy of the License at
10: * http://www.apple.com/publicsource and read it before using this file.
11: *
12: * This Original Code and all software distributed under the License are
13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /*
23: * @OSF_COPYRIGHT@
24: */
25: /*
26: * Mach Operating System
27: * Copyright (c) 1991,1990,1989 Carnegie Mellon University
28: * All Rights Reserved.
29: *
30: * Permission to use, copy, modify and distribute this software and its
31: * documentation is hereby granted, provided that both the copyright
32: * notice and this permission notice appear in all copies of the
33: * software, derivative works or modified versions, and any portions
34: * thereof, and that both notices appear in supporting documentation.
35: *
36: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39: *
40: * Carnegie Mellon requests users of this software to return to
41: *
42: * Software Distribution Coordinator or [email protected]
43: * School of Computer Science
44: * Carnegie Mellon University
45: * Pittsburgh PA 15213-3890
46: *
47: * any improvements or extensions that they make and grant Carnegie Mellon
48: * the rights to redistribute these changes.
49: */
50: #include <string.h>
51:
52: #include <mach/vm_param.h>
53: #include <mach/boolean.h>
54: #include <vm/pmap.h>
55: #include <vm/vm_page.h>
56: #include <kern/misc_protos.h>
57:
58: /*
59: * pmap_zero_page zeros the specified (machine independent) page.
60: */
61: void
62: pmap_zero_page(
63: vm_offset_t p)
64: {
65: assert(p != vm_page_fictitious_addr);
66: bzero((char *)phystokv(p), PAGE_SIZE);
67: }
68:
69: /*
70: * pmap_zero_part_page
71: * zeros the specified (machine independent) part of a page.
72: */
73: void
74: pmap_zero_part_page(
75: vm_offset_t p,
76: vm_offset_t offset,
77: vm_size_t len)
78: {
79: assert(p != vm_page_fictitious_addr);
80: assert(offset + len <= PAGE_SIZE);
81:
82: bzero((char *)phystokv(p) + offset, len);
83: }
84:
85: /*
86: * pmap_copy_page copies the specified (machine independent) pages.
87: */
88: void
89: pmap_copy_page(
90: vm_offset_t src,
91: vm_offset_t dst)
92: {
93: assert(src != vm_page_fictitious_addr);
94: assert(dst != vm_page_fictitious_addr);
95:
96: memcpy((void *)phystokv(dst), (void *)phystokv(src), PAGE_SIZE);
97: }
98:
99: /*
100: * pmap_copy_page copies the specified (machine independent) pages.
101: */
102: void
103: pmap_copy_part_page(
104: vm_offset_t src,
105: vm_offset_t src_offset,
106: vm_offset_t dst,
107: vm_offset_t dst_offset,
108: vm_size_t len)
109: {
110: assert(src != vm_page_fictitious_addr);
111: assert(dst != vm_page_fictitious_addr);
112: assert(((dst & PAGE_MASK) + dst_offset + len) <= PAGE_SIZE);
113: assert(((src & PAGE_MASK) + src_offset + len) <= PAGE_SIZE);
114:
115: memcpy((void *)(phystokv(dst) + dst_offset),
116: (void *)(phystokv(src) + src_offset), len);
117: }
118:
119: /*
120: * pmap_copy_part_lpage copies part of a virtually addressed page
121: * to a physically addressed page.
122: */
123: void
124: pmap_copy_part_lpage(
125: vm_offset_t src,
126: vm_offset_t dst,
127: vm_offset_t dst_offset,
128: vm_size_t len)
129: {
130: assert(src != vm_page_fictitious_addr);
131: assert(dst != vm_page_fictitious_addr);
132: assert(((dst & PAGE_MASK) + dst_offset + len) <= PAGE_SIZE);
133:
134: memcpy((void *)(phystokv(dst) + dst_offset), (void *)src, len);
135: }
136:
137: /*
138: * pmap_copy_part_rpage copies part of a physically addressed page
139: * to a virtually addressed page.
140: */
141: void
142: pmap_copy_part_rpage(
143: vm_offset_t src,
144: vm_offset_t src_offset,
145: vm_offset_t dst,
146: vm_size_t len)
147: {
148: assert(src != vm_page_fictitious_addr);
149: assert(dst != vm_page_fictitious_addr);
150: assert(((src & PAGE_MASK) + src_offset + len) <= PAGE_SIZE);
151:
152: memcpy((void *)dst, (void *)(phystokv(src) + src_offset), len);
153: }
154:
155: /*
156: * kvtophys(addr)
157: *
158: * Convert a kernel virtual address to a physical address
159: */
160: vm_offset_t
161: kvtophys(
162: vm_offset_t addr)
163: {
164: pt_entry_t *pte;
165:
166: if ((pte = pmap_pte(kernel_pmap, addr)) == PT_ENTRY_NULL)
167: return 0;
168: return i386_trunc_page(*pte) | (addr & INTEL_OFFMASK);
169: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.