From 3495845eece6b13c12d181b8153f82b974cb7774 Mon Sep 17 00:00:00 2001 From: Benno Rice Date: Tue, 9 Jul 2002 13:44:24 +0000 Subject: [PATCH] Add an implementation for pmap_zero_page_area. --- sys/powerpc/aim/mmu_oea.c | 25 ++++++++++++++++++++++++- sys/powerpc/powerpc/mmu_oea.c | 25 ++++++++++++++++++++++++- sys/powerpc/powerpc/pmap.c | 25 ++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c index 187e4b3eb790..50e3f1201c1f 100644 --- a/sys/powerpc/aim/mmu_oea.c +++ b/sys/powerpc/aim/mmu_oea.c @@ -906,7 +906,30 @@ pmap_zero_page(vm_page_t m) void pmap_zero_page_area(vm_page_t m, int off, int size) { - TODO; + vm_offset_t pa = VM_PAGE_TO_PHYS(m); + caddr_t va; + int i; + + if (pa < SEGMENT_LENGTH) { + va = (caddr_t) pa; + } else if (pmap_initialized) { + if (pmap_pvo_zeropage == NULL) + pmap_pvo_zeropage = pmap_rkva_alloc(); + pmap_pa_map(pmap_pvo_zeropage, pa, NULL, NULL); + va = (caddr_t)PVO_VADDR(pmap_pvo_zeropage); + } else { + panic("pmap_zero_page: can't zero pa %#x", pa); + } + + bzero(va, size); + + for (i = size / CACHELINESIZE; i > 0; i--) { + __asm __volatile("dcbz 0,%0" :: "r"(va)); + va += CACHELINESIZE; + } + + if (pa >= SEGMENT_LENGTH) + pmap_pa_unmap(pmap_pvo_zeropage, NULL, NULL); } void diff --git a/sys/powerpc/powerpc/mmu_oea.c b/sys/powerpc/powerpc/mmu_oea.c index 187e4b3eb790..50e3f1201c1f 100644 --- a/sys/powerpc/powerpc/mmu_oea.c +++ b/sys/powerpc/powerpc/mmu_oea.c @@ -906,7 +906,30 @@ pmap_zero_page(vm_page_t m) void pmap_zero_page_area(vm_page_t m, int off, int size) { - TODO; + vm_offset_t pa = VM_PAGE_TO_PHYS(m); + caddr_t va; + int i; + + if (pa < SEGMENT_LENGTH) { + va = (caddr_t) pa; + } else if (pmap_initialized) { + if (pmap_pvo_zeropage == NULL) + pmap_pvo_zeropage = pmap_rkva_alloc(); + pmap_pa_map(pmap_pvo_zeropage, pa, NULL, NULL); + va = (caddr_t)PVO_VADDR(pmap_pvo_zeropage); + } else { + panic("pmap_zero_page: can't zero pa %#x", pa); + } + + bzero(va, size); + + for (i = size / CACHELINESIZE; i > 0; i--) { + __asm __volatile("dcbz 0,%0" :: "r"(va)); + va += CACHELINESIZE; + } + + if (pa >= SEGMENT_LENGTH) + pmap_pa_unmap(pmap_pvo_zeropage, NULL, NULL); } void diff --git a/sys/powerpc/powerpc/pmap.c b/sys/powerpc/powerpc/pmap.c index 187e4b3eb790..50e3f1201c1f 100644 --- a/sys/powerpc/powerpc/pmap.c +++ b/sys/powerpc/powerpc/pmap.c @@ -906,7 +906,30 @@ pmap_zero_page(vm_page_t m) void pmap_zero_page_area(vm_page_t m, int off, int size) { - TODO; + vm_offset_t pa = VM_PAGE_TO_PHYS(m); + caddr_t va; + int i; + + if (pa < SEGMENT_LENGTH) { + va = (caddr_t) pa; + } else if (pmap_initialized) { + if (pmap_pvo_zeropage == NULL) + pmap_pvo_zeropage = pmap_rkva_alloc(); + pmap_pa_map(pmap_pvo_zeropage, pa, NULL, NULL); + va = (caddr_t)PVO_VADDR(pmap_pvo_zeropage); + } else { + panic("pmap_zero_page: can't zero pa %#x", pa); + } + + bzero(va, size); + + for (i = size / CACHELINESIZE; i > 0; i--) { + __asm __volatile("dcbz 0,%0" :: "r"(va)); + va += CACHELINESIZE; + } + + if (pa >= SEGMENT_LENGTH) + pmap_pa_unmap(pmap_pvo_zeropage, NULL, NULL); } void