]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kdp/ml/ppc/kdp_vm.c
ddb002b8c63c2aab3981d5bc454ce89170fb65ab
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #include <mach/mach_types.h>
26 #include <mach/vm_attributes.h>
27 #include <mach/vm_param.h>
31 #include <ppc/proc_reg.h>
32 #include <ppc/machparam.h>
35 #include <ppc/mappings.h>
38 boolean_t kdp_trans_off
=0;
39 boolean_t kdp_read_io
=0;
41 unsigned kdp_vm_read( caddr_t
, caddr_t
, unsigned);
42 unsigned kdp_vm_write( caddr_t
, caddr_t
, unsigned);
55 pp
= pmap_find_phys(pmap
, va
); /* Get the page number */
56 if(!pp
) return 0; /* Just return if no translation */
58 pa
= ((addr64_t
)pp
<< 12) | (va
& 0x0000000000000FFFULL
); /* Shove in the page offset */
70 addr64_t cur_virt_src
, cur_virt_dst
;
71 addr64_t cur_phys_src
;
76 #ifdef KDP_VM_READ_DEBUG
77 kprintf("kdp_vm_read1: src %x dst %x len %x - %08X %08X\n", src
, dst
, len
, ((unsigned long *)src
)[0], ((unsigned long *)src
)[1]);
80 cur_virt_src
= (addr64_t
)((unsigned int)src
);
81 cur_virt_dst
= (addr64_t
)((unsigned int)dst
);
86 resid
= len
; /* Get the length to copy */
91 if(!mapping_phys_lookup((ppnum_t
)(cur_virt_src
>> 12), &dummy
)) return 0; /* Can't read where there's not any memory */
93 cnt
= 4096 - (cur_virt_src
& 0xFFF); /* Get length left on page */
95 if (cnt
> resid
) cnt
= resid
;
97 bcopy_phys(cur_virt_src
, cur_virt_dst
, cnt
); /* Copy stuff over */
108 if(kdp_pmap
) pmap
= kdp_pmap
; /* If special pmap, use it */
109 else pmap
= kernel_pmap
; /* otherwise, use kernel's */
113 if((cur_phys_src
= kdp_vtophys(pmap
, cur_virt_src
)) == 0) goto exit
;
115 if(!mapping_phys_lookup((ppnum_t
)(cur_phys_src
>> 12), &dummy
)) goto exit
; /* Can't read where there's not any memory */
117 cnt
= 4096 - (cur_virt_src
& 0xFFF); /* Get length left on page */
118 if (cnt
> resid
) cnt
= resid
;
120 #ifdef KDP_VM_READ_DEBUG
121 kprintf("kdp_vm_read2: pmap %08X, virt %016LLX, phys %016LLX\n",
122 pmap
, cur_virt_src
, cur_phys_src
);
125 bcopy_phys(cur_phys_src
, cur_virt_dst
, cnt
); /* Copy stuff over */
133 #ifdef KDP_VM_READ_DEBUG
134 kprintf("kdp_vm_read: ret %08X\n", len
-resid
);
136 return (len
- resid
);
142 unsigned kdp_vm_write(
147 addr64_t cur_virt_src
, cur_virt_dst
;
148 addr64_t cur_phys_src
, cur_phys_dst
;
149 unsigned resid
, cnt
, cnt_src
, cnt_dst
;
151 #ifdef KDP_VM_WRITE_DEBUG
152 printf("kdp_vm_write: src %x dst %x len %x - %08X %08X\n", src
, dst
, len
, ((unsigned long *)src
)[0], ((unsigned long *)src
)[1]);
155 cur_virt_src
= (addr64_t
)((unsigned int)src
);
156 cur_virt_dst
= (addr64_t
)((unsigned int)dst
);
161 if ((cur_phys_dst
= kdp_vtophys(kernel_pmap
, cur_virt_dst
)) == 0)
163 if ((cur_phys_src
= kdp_vtophys(kernel_pmap
, cur_virt_src
)) == 0)
166 cnt_src
= ((cur_phys_src
+ NBPG
) & (-NBPG
)) - cur_phys_src
;
167 cnt_dst
= ((cur_phys_dst
+ NBPG
) & (-NBPG
)) - cur_phys_dst
;
169 if (cnt_src
> cnt_dst
)
176 bcopy_phys(cur_phys_src
, cur_phys_dst
, cnt
); /* Copy stuff over */
177 sync_cache64(cur_phys_dst
, cnt
); /* Sync caches */
184 return (len
- resid
);