diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1997-02-10 11:11:52 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1997-02-10 11:11:52 +0000 |
commit | 625d2c4a2749d270601a648f3e61d18f134d4ffe (patch) | |
tree | 28025c5d9f66813cc875a3e6cac75c072fa1ed27 /sys | |
parent | 8d90252fabf25feccc3e0f923cd9f1858da8315a (diff) |
Add the generic m68k part of the copypage/zeropage/mappedcopy changes
from NetBSD.
m68k ports may/will need changing in order to cope with this.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/m68k/conf/files.m68k | 5 | ||||
-rw-r--r-- | sys/arch/m68k/include/cpu.h | 14 | ||||
-rw-r--r-- | sys/arch/m68k/m68k/copy.s | 59 | ||||
-rw-r--r-- | sys/arch/m68k/m68k/mappedcopy.c | 177 |
4 files changed, 249 insertions, 6 deletions
diff --git a/sys/arch/m68k/conf/files.m68k b/sys/arch/m68k/conf/files.m68k index a20d684a416..112c229a0eb 100644 --- a/sys/arch/m68k/conf/files.m68k +++ b/sys/arch/m68k/conf/files.m68k @@ -1,10 +1,11 @@ -# $OpenBSD: files.m68k,v 1.4 1997/01/13 11:07:49 niklas Exp $ -# $NetBSD: files.m68k,v 1.14 1996/09/10 22:07:10 thorpej Exp $ +# $OpenBSD: files.m68k,v 1.5 1997/02/10 11:11:46 downsj Exp $ +# $NetBSD: files.m68k,v 1.15 1997/02/02 06:55:15 thorpej Exp $ # file arch/m68k/m68k/db_disasm.c ddb file arch/m68k/m68k/db_interface.c ddb file arch/m68k/m68k/db_trace.c ddb file arch/m68k/m68k/in_cksum.c inet +file arch/m68k/m68k/mappedcopy.c mappedcopy file arch/m68k/m68k/ns_cksum.c ns file arch/m68k/m68k/oc_cksum.s inet file arch/m68k/m68k/process_machdep.c diff --git a/sys/arch/m68k/include/cpu.h b/sys/arch/m68k/include/cpu.h index 42f491b3c8d..5fc92af1db8 100644 --- a/sys/arch/m68k/include/cpu.h +++ b/sys/arch/m68k/include/cpu.h @@ -1,5 +1,5 @@ -/* $OpenBSD: cpu.h,v 1.1 1996/10/14 00:59:24 briggs Exp $ */ -/* $NetBSD: cpu.h,v 1.2 1996/09/12 02:52:34 thorpej Exp $ */ +/* $OpenBSD: cpu.h,v 1.2 1997/02/10 11:11:48 downsj Exp $ */ +/* $NetBSD: cpu.h,v 1.3 1997/02/02 06:56:57 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -188,4 +188,14 @@ extern int mmutype; /* MMU on this host */ #define CACHE60_ON (CACHE40_ON|IC60_CABC|IC60_EBC|DC60_ESB) #define CACHE60_OFF (CACHE40_OFF|IC60_CABC) +#ifdef _KERNEL +void copypage __P((void *fromaddr, void *toaddr)); +void zeropage __P((void *addr)); +#ifdef MAPPEDCOPY +int mappedcopyin __P((void *fromp, void *top, size_t count)); +int mappedcopyout __P((void *fromp, void *top, size_t count)); +extern u_int mappedcopysize; +#endif /* MAPPEDCOPY */ +#endif /* _KERNEL */ + #endif /* _M68K_CPU_H_ */ diff --git a/sys/arch/m68k/m68k/copy.s b/sys/arch/m68k/m68k/copy.s index da3f6b2feca..a8f34937851 100644 --- a/sys/arch/m68k/m68k/copy.s +++ b/sys/arch/m68k/m68k/copy.s @@ -1,5 +1,5 @@ -/* $OpenBSD: copy.s,v 1.4 1997/01/13 11:51:11 niklas Exp $ */ -/* $NetBSD: copy.s,v 1.24 1996/07/20 01:53:42 jtc Exp $ */ +/* $OpenBSD: copy.s,v 1.5 1997/02/10 11:11:50 downsj Exp $ */ +/* $NetBSD: copy.s,v 1.25 1997/02/02 06:50:06 thorpej Exp $ */ /*- * Copyright (c) 1994, 1995 Charles Hannum. @@ -532,3 +532,58 @@ Lbccbbloop: movb a0@-,a1@- | copy bytes dbf d0,Lbccbbloop | til done rts + +/* + * copypage(fromaddr, toaddr) + * + * Optimized version of bcopy for a single page-aligned NBPG byte copy. + */ +ENTRY(copypage) + movl sp@(4),a0 | source address + movl sp@(8),a1 | destiniation address + movl #NBPG/32-1,d0 | number of 32 byte chunks - 1 +#if defined(M68040) || defined(M68060) +#if defined(M68020) || defined(M68030) + cmpl #CPU_68030,_cputype | 68030 or less? + jle Lmlloop | yes, use movl +#endif /* M68020 || M68030 */ +Lm16loop: + .long 0xf6209000 | move16 a0@+,a1@+ + .long 0xf6209000 | move16 a0@+,a1@+ + dbf d0,Lm16loop + rts +#endif /* M68040 || M68060 */ +#if defined(M68020) || defined(M68030) +Lmlloop: + movl a0@+,a1@+ + movl a0@+,a1@+ + movl a0@+,a1@+ + movl a0@+,a1@+ + movl a0@+,a1@+ + movl a0@+,a1@+ + movl a0@+,a1@+ + movl a0@+,a1@+ + dbf d0,Lmlloop +#endif /* M68020 || M68030 */ + rts + +/* + * zeropage(addr) + * + * Optimized version of bzero for a single page-aligned NBPG byte zero. + */ +ENTRY(zeropage) + movl sp@(4),a0 | dest address + movl #NBPG/32-1,d0 | number of 32 byte chunks - 1 + movq #0,d1 +Lzloop: + movl d1,a0@+ + movl d1,a0@+ + movl d1,a0@+ + movl d1,a0@+ + movl d1,a0@+ + movl d1,a0@+ + movl d1,a0@+ + movl d1,a0@+ + dbf d0,Lzloop + rts diff --git a/sys/arch/m68k/m68k/mappedcopy.c b/sys/arch/m68k/m68k/mappedcopy.c new file mode 100644 index 00000000000..e2adb099ddd --- /dev/null +++ b/sys/arch/m68k/m68k/mappedcopy.c @@ -0,0 +1,177 @@ +/* $OpenBSD: mappedcopy.c,v 1.1 1997/02/10 11:11:51 downsj Exp $ */ +/* $NetBSD: mappedcopy.c,v 1.1 1997/02/02 06:54:10 thorpej Exp $ */ + +/* + * XXX This doesn't work yet. Soon. --thorpej@netbsd.org + */ + +/* + * Copyright (c) 1988 University of Utah. + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: Utah $Hdr: vm_machdep.c 1.21 91/04/06$ + * + * @(#)vm_machdep.c 8.6 (Berkeley) 1/12/94 + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/proc.h> + +#include <vm/vm.h> +#include <vm/vm_kern.h> + +#include <machine/cpu.h> + +#ifdef DEBUG +#define MDB_COPYIN 0x01 +#define MDB_COPYOUT 0x02 +int mappedcopydebug = 0; + +int mappedcopyincount; +int mappedcopyoutcount; +#endif + +/* + * This turns off mappedcopy by default. Ports initialize the + * threshold in initcpu(). + */ +u_int mappedcopysize = -1; + +/* + * N.B. Both of these routines assume PAGE_SIZE == NBPG. + */ + +int +mappedcopyin(fromp, top, count) + register void *fromp, *top; + register size_t count; +{ + register vm_offset_t kva, upa; + register size_t len; + int off, alignable; + pmap_t upmap; + extern caddr_t CADDR1; + +#ifdef DEBUG + if (mappedcopydebug & MDB_COPYIN) + printf("mappedcopyin(%p, %p, %lu), pid %d\n", + fromp, top, (u_long)count, curproc->p_pid); + mappedcopyincount++; +#endif + + kva = (vm_offset_t)CADDR1; + off = (int)((u_long)fromp & PAGE_MASK); + alignable = (off == ((u_long)top & PAGE_MASK)); + upmap = vm_map_pmap(&curproc->p_vmspace->vm_map); + while (count > 0) { + /* + * First access of a page, use fubyte to make sure + * page is faulted in and read access allowed. + */ + if (fubyte(fromp) == -1) + return (EFAULT); + /* + * Map in the page and bcopy data in from it + */ + upa = pmap_extract(upmap, trunc_page(fromp)); + if (upa == 0) + panic("mappedcopyin: null page frame"); + len = min(count, (PAGE_SIZE - off)); + pmap_enter(pmap_kernel(), kva, upa, VM_PROT_READ, TRUE); + if (len == PAGE_SIZE && alignable && off == 0) + copypage((caddr_t)kva, top); + else + bcopy((void *)(kva + off), top, len); + fromp += len; + top += len; + count -= len; + off = 0; + } + pmap_remove(pmap_kernel(), kva, kva + PAGE_SIZE); + return (0); +} + +int +mappedcopyout(fromp, top, count) + register void *fromp, *top; + register size_t count; +{ + register vm_offset_t kva, upa; + register size_t len; + int off, alignable; + pmap_t upmap; + extern caddr_t CADDR2; + +#ifdef DEBUG + if (mappedcopydebug & MDB_COPYOUT) + printf("mappedcopyout(%p, %p, %lu), pid %d\n", + fromp, top, (u_long)count, curproc->p_pid); + mappedcopyoutcount++; +#endif + + kva = (vm_offset_t) CADDR2; + off = (int)((u_long)top & PAGE_MASK); + alignable = (off == ((u_long)fromp & PAGE_MASK)); + upmap = vm_map_pmap(&curproc->p_vmspace->vm_map); + while (count > 0) { + /* + * First access of a page, use subyte to make sure + * page is faulted in and write access allowed. + */ + if (subyte(top, *((char *)fromp)) == -1) + return (EFAULT); + /* + * Map in the page and bcopy data out to it + */ + upa = pmap_extract(upmap, trunc_page(top)); + if (upa == 0) + panic("mappedcopyout: null page frame"); + len = min(count, (PAGE_SIZE - off)); + pmap_enter(pmap_kernel(), kva, upa, + VM_PROT_READ|VM_PROT_WRITE, TRUE); + if (len == PAGE_SIZE && alignable && off == 0) + copypage(fromp, (caddr_t)kva); + else + bcopy(fromp, (void *)(kva + off), len); + fromp += len; + top += len; + count -= len; + off = 0; + } + pmap_remove(pmap_kernel(), kva, kva + PAGE_SIZE); + return (0); +} |