]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/phys.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
28 * All Rights Reserved.
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.
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.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
52 #include <mach/vm_param.h>
53 #include <mach/boolean.h>
55 #include <vm/vm_page.h>
56 #include <kern/misc_protos.h>
59 * pmap_zero_page zeros the specified (machine independent) page.
66 assert(pn
!= vm_page_fictitious_addr
);
67 p
= (vm_offset_t
)i386_ptob(pn
);
68 bzero((char *)phystokv(p
), PAGE_SIZE
);
73 * zeros the specified (machine independent) part of a page.
81 assert(pn
!= vm_page_fictitious_addr
);
82 assert(offset
+ len
<= PAGE_SIZE
);
83 bzero((char *)phystokv(i386_ptob(pn
)) + offset
, len
);
87 * pmap_copy_page copies the specified (machine independent) pages.
97 assert(psrc
!= vm_page_fictitious_addr
);
98 assert(pdst
!= vm_page_fictitious_addr
);
99 src
= (vm_offset_t
)i386_ptob(psrc
);
100 dst
= (vm_offset_t
)i386_ptob(pdst
);
102 memcpy((void *)phystokv(dst
), (void *)phystokv(src
), PAGE_SIZE
);
106 * pmap_copy_page copies the specified (machine independent) pages.
111 vm_offset_t src_offset
,
113 vm_offset_t dst_offset
,
116 vm_offset_t src
, dst
;
118 assert(psrc
!= vm_page_fictitious_addr
);
119 assert(pdst
!= vm_page_fictitious_addr
);
120 src
= (vm_offset_t
)i386_ptob(psrc
);
121 dst
= (vm_offset_t
)i386_ptob(pdst
);
122 assert(((dst
& PAGE_MASK
) + dst_offset
+ len
) <= PAGE_SIZE
);
123 assert(((src
& PAGE_MASK
) + src_offset
+ len
) <= PAGE_SIZE
);
125 memcpy((void *)(phystokv(dst
) + dst_offset
),
126 (void *)(phystokv(src
) + src_offset
), len
);
130 * pmap_copy_part_lpage copies part of a virtually addressed page
131 * to a physically addressed page.
134 pmap_copy_part_lpage(
137 vm_offset_t dst_offset
,
142 assert(src
!= vm_page_fictitious_addr
);
143 assert(pdst
!= vm_page_fictitious_addr
);
144 dst
= (vm_offset_t
)i386_ptob(pdst
);
145 assert(((dst
& PAGE_MASK
) + dst_offset
+ len
) <= PAGE_SIZE
);
147 memcpy((void *)(phystokv(dst
) + dst_offset
), (void *)src
, len
);
151 * pmap_copy_part_rpage copies part of a physically addressed page
152 * to a virtually addressed page.
155 pmap_copy_part_rpage(
157 vm_offset_t src_offset
,
163 assert(psrc
!= vm_page_fictitious_addr
);
164 assert(dst
!= vm_page_fictitious_addr
);
165 src
= (vm_offset_t
)i386_ptob(psrc
);
166 assert(((src
& PAGE_MASK
) + src_offset
+ len
) <= PAGE_SIZE
);
168 memcpy((void *)dst
, (void *)(phystokv(src
) + src_offset
), len
);
174 * Convert a kernel virtual address to a physical address
182 if ((pte
= pmap_pte(kernel_pmap
, addr
)) == PT_ENTRY_NULL
)
184 return i386_trunc_page(*pte
) | (addr
& INTEL_OFFMASK
);