FreeBSD/Linux Kernel Cross Reference
sys/i386/phys.c
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: phys.c,v $
29 * Revision 2.8 91/05/18 14:30:02 rpd
30 * Added vm_page_fictitious_addr assertions.
31 * [91/04/10 rpd]
32 *
33 * Revision 2.7 91/05/14 16:13:29 mrt
34 * Correcting copyright
35 *
36 * Revision 2.6 91/05/08 12:41:06 dbg
37 * More cleanup.
38 * [91/03/21 dbg]
39 *
40 * Revision 2.5 91/03/16 14:45:06 rpd
41 * Added resume, continuation arguments to vm_fault.
42 * [91/02/05 rpd]
43 *
44 * Revision 2.4 91/02/05 17:13:36 mrt
45 * Changed to new Mach copyright
46 * [91/02/01 17:36:36 mrt]
47 *
48 * Revision 2.3 90/12/04 14:46:19 jsb
49 * Changes for merged intel/pmap.{c,h}.
50 * [90/12/04 11:17:19 jsb]
51 *
52 * Revision 2.2 90/05/03 15:35:56 dbg
53 * Use 'write' bit in pte instead of protection field.
54 * [90/03/25 dbg]
55 *
56 * Use bzero instead of bclear.
57 * [90/02/15 dbg]
58 *
59 * Revision 1.3 89/02/26 12:32:59 gm0w
60 * Changes for cleanup.
61 *
62 */
63
64 #include <mach/boolean.h>
65 #include <kern/task.h>
66 #include <kern/thread.h>
67 #include <vm/vm_map.h>
68 #include <mach/vm_param.h>
69 #include <mach/vm_prot.h>
70 #include <vm/vm_kern.h>
71 #include <vm/vm_page.h>
72
73 #include <i386/pmap.h>
74 #include <mach/i386/vm_param.h>
75
76 /*
77 * pmap_zero_page zeros the specified (machine independent) page.
78 */
79 pmap_zero_page(p)
80 vm_offset_t p;
81 {
82 assert(p != vm_page_fictitious_addr);
83 bzero(phystokv(p), PAGE_SIZE);
84 }
85
86 /*
87 * pmap_copy_page copies the specified (machine independent) pages.
88 */
89 pmap_copy_page(src, dst)
90 vm_offset_t src, dst;
91 {
92 assert(src != vm_page_fictitious_addr);
93 assert(dst != vm_page_fictitious_addr);
94
95 bcopy(phystokv(src), phystokv(dst), PAGE_SIZE);
96 }
97
98 /*
99 * copy_to_phys(src_addr_v, dst_addr_p, count)
100 *
101 * Copy virtual memory to physical memory
102 */
103 copy_to_phys(src_addr_v, dst_addr_p, count)
104 vm_offset_t src_addr_v, dst_addr_p;
105 int count;
106 {
107 assert(dst_addr_p != vm_page_fictitious_addr);
108 bcopy(src_addr_v, phystokv(dst_addr_p), count);
109 }
110
111 /*
112 * copy_from_phys(src_addr_p, dst_addr_v, count)
113 *
114 * Copy physical memory to virtual memory. The virtual memory
115 * is assumed to be present (e.g. the buffer pool).
116 */
117 copy_from_phys(src_addr_p, dst_addr_v, count)
118 vm_offset_t src_addr_p, dst_addr_v;
119 int count;
120 {
121 assert(src_addr_p != vm_page_fictitious_addr);
122 bcopy(phystokv(src_addr_p), dst_addr_v, count);
123 }
124
125 /*
126 * kvtophys(addr)
127 *
128 * Convert a kernel virtual address to a physical address
129 */
130 vm_offset_t
131 kvtophys(addr)
132 vm_offset_t addr;
133 {
134 pt_entry_t *pte;
135
136 if ((pte = pmap_pte(kernel_pmap, addr)) == PT_ENTRY_NULL)
137 return 0;
138 return i386_trunc_page(*pte) | (addr & INTEL_OFFMASK);
139 }
Cache object: e99ecf3bd8a22a06733213dce8eae10d
|