X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/a3d08fcd5120d2aa8303b6349ca8b14e3f284af3..91447636331957f3d9b5ca5b508f07c526b0074d:/osfmk/i386/phys.c diff --git a/osfmk/i386/phys.c b/osfmk/i386/phys.c index fe2374e3e..3676a4f95 100644 --- a/osfmk/i386/phys.c +++ b/osfmk/i386/phys.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -47,13 +47,41 @@ * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ -#include +#include +#include +#include + +#include + +#include +#include #include -#include -#include -#include + +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * pmap_zero_page zeros the specified (machine independent) page. @@ -62,10 +90,8 @@ void pmap_zero_page( ppnum_t pn) { - vm_offset_t p; assert(pn != vm_page_fictitious_addr); - p = (vm_offset_t)i386_ptob(pn); - bzero((char *)phystokv(p), PAGE_SIZE); + bzero_phys((addr64_t)i386_ptob(pn), PAGE_SIZE); } /* @@ -80,26 +106,7 @@ pmap_zero_part_page( { assert(pn != vm_page_fictitious_addr); assert(offset + len <= PAGE_SIZE); - bzero((char *)phystokv(i386_ptob(pn)) + offset, len); -} - -/* - * pmap_copy_page copies the specified (machine independent) pages. - */ -void -pmap_copy_page( - ppnum_t psrc, - ppnum_t pdst) - -{ - vm_offset_t src,dst; - - assert(psrc != vm_page_fictitious_addr); - assert(pdst != vm_page_fictitious_addr); - src = (vm_offset_t)i386_ptob(psrc); - dst = (vm_offset_t)i386_ptob(pdst); - - memcpy((void *)phystokv(dst), (void *)phystokv(src), PAGE_SIZE); + bzero_phys((addr64_t)(i386_ptob(pn) + offset), len); } /* @@ -114,16 +121,15 @@ pmap_copy_part_page( vm_size_t len) { vm_offset_t src, dst; - assert(psrc != vm_page_fictitious_addr); assert(pdst != vm_page_fictitious_addr); src = (vm_offset_t)i386_ptob(psrc); dst = (vm_offset_t)i386_ptob(pdst); assert(((dst & PAGE_MASK) + dst_offset + len) <= PAGE_SIZE); assert(((src & PAGE_MASK) + src_offset + len) <= PAGE_SIZE); - - memcpy((void *)(phystokv(dst) + dst_offset), - (void *)(phystokv(src) + src_offset), len); + bcopy_phys((addr64_t)src + (src_offset & INTEL_OFFMASK), + (addr64_t)dst + (dst_offset & INTEL_OFFMASK), + len); } /* @@ -137,14 +143,21 @@ pmap_copy_part_lpage( vm_offset_t dst_offset, vm_size_t len) { - vm_offset_t dst; + pt_entry_t *ptep; + thread_t thr_act = current_thread(); - assert(src != vm_page_fictitious_addr); assert(pdst != vm_page_fictitious_addr); - dst = (vm_offset_t)i386_ptob(pdst); - assert(((dst & PAGE_MASK) + dst_offset + len) <= PAGE_SIZE); - - memcpy((void *)(phystokv(dst) + dst_offset), (void *)src, len); + ptep = pmap_pte(thr_act->map->pmap, i386_ptob(pdst)); + if (0 == ptep) + panic("pmap_copy_part_lpage ptep"); + assert(((pdst & PAGE_MASK) + dst_offset + len) <= PAGE_SIZE); + if (*(pt_entry_t *) CM2) + panic("pmap_copy_part_lpage"); + *(int *) CM2 = INTEL_PTE_VALID | INTEL_PTE_RW | (*ptep & PG_FRAME) | + INTEL_PTE_REF | INTEL_PTE_MOD; + invlpg((unsigned int) CA2); + memcpy((void *) (CA2 + (dst_offset & INTEL_OFFMASK)), (void *) src, len); + *(pt_entry_t *) CM2 = 0; } /* @@ -158,14 +171,21 @@ pmap_copy_part_rpage( vm_offset_t dst, vm_size_t len) { - vm_offset_t src; + pt_entry_t *ptep; + thread_t thr_act = current_thread(); assert(psrc != vm_page_fictitious_addr); - assert(dst != vm_page_fictitious_addr); - src = (vm_offset_t)i386_ptob(psrc); - assert(((src & PAGE_MASK) + src_offset + len) <= PAGE_SIZE); - - memcpy((void *)dst, (void *)(phystokv(src) + src_offset), len); + ptep = pmap_pte(thr_act->map->pmap, i386_ptob(psrc)); + if (0 == ptep) + panic("pmap_copy_part_rpage ptep"); + assert(((psrc & PAGE_MASK) + src_offset + len) <= PAGE_SIZE); + if (*(pt_entry_t *) CM2) + panic("pmap_copy_part_rpage"); + *(pt_entry_t *) CM2 = INTEL_PTE_VALID | INTEL_PTE_RW | (*ptep & PG_FRAME) | + INTEL_PTE_REF; + invlpg((unsigned int) CA2); + memcpy((void *) dst, (void *) (CA2 + (src_offset & INTEL_OFFMASK)), len); + *(pt_entry_t *) CM2 = 0; } /* @@ -177,9 +197,15 @@ vm_offset_t kvtophys( vm_offset_t addr) { - pt_entry_t *pte; - - if ((pte = pmap_pte(kernel_pmap, addr)) == PT_ENTRY_NULL) - return 0; - return i386_trunc_page(*pte) | (addr & INTEL_OFFMASK); + pt_entry_t *ptep; + pmap_paddr_t pa; + + if ((ptep = pmap_pte(kernel_pmap, addr)) == PT_ENTRY_NULL) { + pa = 0; + } else { + pa = pte_to_pa(*ptep) | (addr & INTEL_OFFMASK); + } + if (0 == pa) + kprintf("kvtophys ret 0!\n"); + return (pa); }