]>
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.
65 assert(p
!= vm_page_fictitious_addr
);
66 bzero((char *)phystokv(p
), PAGE_SIZE
);
71 * zeros the specified (machine independent) part of a page.
79 assert(p
!= vm_page_fictitious_addr
);
80 assert(offset
+ len
<= PAGE_SIZE
);
82 bzero((char *)phystokv(p
) + offset
, len
);
86 * pmap_copy_page copies the specified (machine independent) pages.
93 assert(src
!= vm_page_fictitious_addr
);
94 assert(dst
!= vm_page_fictitious_addr
);
96 memcpy((void *)phystokv(dst
), (void *)phystokv(src
), PAGE_SIZE
);
100 * pmap_copy_page copies the specified (machine independent) pages.
105 vm_offset_t src_offset
,
107 vm_offset_t dst_offset
,
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
);
115 memcpy((void *)(phystokv(dst
) + dst_offset
),
116 (void *)(phystokv(src
) + src_offset
), len
);
120 * pmap_copy_part_lpage copies part of a virtually addressed page
121 * to a physically addressed page.
124 pmap_copy_part_lpage(
127 vm_offset_t dst_offset
,
130 assert(src
!= vm_page_fictitious_addr
);
131 assert(dst
!= vm_page_fictitious_addr
);
132 assert(((dst
& PAGE_MASK
) + dst_offset
+ len
) <= PAGE_SIZE
);
134 memcpy((void *)(phystokv(dst
) + dst_offset
), (void *)src
, len
);
138 * pmap_copy_part_rpage copies part of a physically addressed page
139 * to a virtually addressed page.
142 pmap_copy_part_rpage(
144 vm_offset_t src_offset
,
148 assert(src
!= vm_page_fictitious_addr
);
149 assert(dst
!= vm_page_fictitious_addr
);
150 assert(((src
& PAGE_MASK
) + src_offset
+ len
) <= PAGE_SIZE
);
152 memcpy((void *)dst
, (void *)(phystokv(src
) + src_offset
), len
);
158 * Convert a kernel virtual address to a physical address
166 if ((pte
= pmap_pte(kernel_pmap
, addr
)) == PT_ENTRY_NULL
)
168 return i386_trunc_page(*pte
) | (addr
& INTEL_OFFMASK
);