summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-08-01 11:54:26 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-08-01 11:54:26 +0000
commitc0b929a7d733ebd19869cc7bce698dc1ded92d13 (patch)
treea2dae6bafe51fbb906792f57adf3a62438cf49ba
parenta5cf009c5477467bd0e5f178fd37ac50ddeea367 (diff)
Factorize cachectl() accross m68k platforms, and make the CC_ constants
public.
-rw-r--r--sys/arch/hp300/hp300/sys_machdep.c151
-rw-r--r--sys/arch/hp300/include/cpu.h5
-rw-r--r--sys/arch/m68k/conf/files.m68k11
-rw-r--r--sys/arch/m68k/include/cpu.h8
-rw-r--r--sys/arch/m68k/m68k/cachectl.c176
-rw-r--r--sys/arch/m68k/m68k/pmap_motorola.c4
-rw-r--r--sys/arch/mac68k/include/cpu.h5
-rw-r--r--sys/arch/mac68k/mac68k/sys_machdep.c124
-rw-r--r--sys/arch/mvme68k/include/cpu.h3
-rw-r--r--sys/arch/mvme68k/mvme68k/sys_machdep.c136
10 files changed, 197 insertions, 426 deletions
diff --git a/sys/arch/hp300/hp300/sys_machdep.c b/sys/arch/hp300/hp300/sys_machdep.c
index 2053462e2fa..e22aa956161 100644
--- a/sys/arch/hp300/hp300/sys_machdep.c
+++ b/sys/arch/hp300/hp300/sys_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_machdep.c,v 1.14 2005/01/15 21:13:08 miod Exp $ */
+/* $OpenBSD: sys_machdep.c,v 1.15 2005/08/01 11:54:19 miod Exp $ */
/* $NetBSD: sys_machdep.c,v 1.17 1997/05/19 10:15:00 veego Exp $ */
/*
@@ -45,157 +45,8 @@
#include <sys/buf.h>
#include <sys/mount.h>
-#include <uvm/uvm_extern.h>
-
#include <sys/syscallargs.h>
-#include <machine/cpu.h>
-
-/* XXX should be in an include file somewhere */
-#define CC_PURGE 1
-#define CC_FLUSH 2
-#define CC_IPURGE 4
-#define CC_EXTPURGE 0x80000000
-/* XXX end should be */
-
-/*
- * Note that what we do here for a 68040 is different than HP-UX.
- *
- * In 'pux they either act on a line (len == 16), a page (len == NBPG)
- * or the whole cache (len == anything else).
- *
- * In BSD we attempt to be more optimal when acting on "odd" sizes.
- * For lengths up to 1024 we do all affected lines, up to 2*NBPG we
- * do pages, above that we do the entire cache.
- */
-/*ARGSUSED1*/
-int
-cachectl(p, req, addr, len)
- struct proc *p;
- int req;
- vaddr_t addr;
- int len;
-{
- int error = 0;
-
-#if defined(M68040)
- if (mmutype == MMU_68040) {
- int inc = 0;
- int doall = 0;
- paddr_t pa = 0;
- vaddr_t end = 0;
-#ifdef COMPAT_HPUX
- extern struct emul emul_hpux;
-
- if ((p->p_emul == &emul_hpux) &&
- len != 16 && len != NBPG)
- doall = 1;
-#endif
-
- if (addr == 0 ||
- ((req & ~CC_EXTPURGE) != CC_PURGE && len > 2*NBPG))
- doall = 1;
-
- if (!doall) {
- end = addr + len;
- if (len <= 1024) {
- addr = addr & ~0xF;
- inc = 16;
- } else {
- addr = addr & ~PGOFSET;
- inc = NBPG;
- }
- }
- do {
- /*
- * Convert to physical address if needed.
- * If translation fails, we perform operation on
- * entire cache (XXX is this a rational thing to do?)
- */
- if (!doall &&
- (pa == 0 || ((int)addr & PGOFSET) == 0)) {
- if (pmap_extract(
- p->p_vmspace->vm_map.pmap,
- addr, &pa) == FALSE)
- doall = 1;
- }
- switch (req) {
- case CC_EXTPURGE|CC_IPURGE:
- case CC_IPURGE:
- if (doall) {
- DCFA();
- ICPA();
- } else if (inc == 16) {
- DCFL(pa);
- ICPL(pa);
- } else if (inc == NBPG) {
- DCFP(pa);
- ICPP(pa);
- }
- break;
-
- case CC_EXTPURGE|CC_PURGE:
- case CC_PURGE:
- if (doall)
- DCFA(); /* note: flush not purge */
- else if (inc == 16)
- DCPL(pa);
- else if (inc == NBPG)
- DCPP(pa);
- break;
-
- case CC_EXTPURGE|CC_FLUSH:
- case CC_FLUSH:
- if (doall)
- DCFA();
- else if (inc == 16)
- DCFL(pa);
- else if (inc == NBPG)
- DCFP(pa);
- break;
-
- default:
- error = EINVAL;
- break;
- }
- if (doall)
- break;
- pa += inc;
- addr += inc;
- } while (addr < end);
- return(error);
- }
-#endif
- switch (req) {
- case CC_EXTPURGE|CC_PURGE:
- case CC_EXTPURGE|CC_FLUSH:
-#if defined(CACHE_HAVE_PAC)
- if (ectype == EC_PHYS)
- PCIA();
- /* fall into... */
-#endif
- case CC_PURGE:
- case CC_FLUSH:
- DCIU();
- break;
- case CC_EXTPURGE|CC_IPURGE:
-#if defined(CACHE_HAVE_PAC)
- if (ectype == EC_PHYS)
- PCIA();
- else
-#endif
- DCIU();
- /* fall into... */
- case CC_IPURGE:
- ICIA();
- break;
- default:
- error = EINVAL;
- break;
- }
- return(error);
-}
-
int
sys_sysarch(p, v, retval)
struct proc *p;
diff --git a/sys/arch/hp300/include/cpu.h b/sys/arch/hp300/include/cpu.h
index 9a6cd45134b..f82f7083f18 100644
--- a/sys/arch/hp300/include/cpu.h
+++ b/sys/arch/hp300/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.26 2005/01/14 22:39:29 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.27 2005/08/01 11:54:22 miod Exp $ */
/* $NetBSD: cpu.h,v 1.28 1998/02/13 07:41:51 scottr Exp $ */
/*
@@ -179,9 +179,6 @@ int badaddr(caddr_t);
int badbaddr(caddr_t);
void dumpconf(void);
-/* sys_machdep.c functions */
-int cachectl(struct proc *, int, vaddr_t, int);
-
/* vm_machdep.c functions */
void physaccess(caddr_t, caddr_t, int, int);
void physunaccess(caddr_t, int);
diff --git a/sys/arch/m68k/conf/files.m68k b/sys/arch/m68k/conf/files.m68k
index a17fd1b5fb3..ec43562b555 100644
--- a/sys/arch/m68k/conf/files.m68k
+++ b/sys/arch/m68k/conf/files.m68k
@@ -1,6 +1,10 @@
-# $OpenBSD: files.m68k,v 1.13 2005/07/14 02:09:46 uwe Exp $
+# $OpenBSD: files.m68k,v 1.14 2005/08/01 11:54:23 miod Exp $
# $NetBSD: files.m68k,v 1.18 1997/06/06 23:15:28 veego Exp $
#
+file arch/m68k/m68k/bcopy.s
+file arch/m68k/m68k/cachectl.c
+file arch/m68k/m68k/copy.s
+file arch/m68k/m68k/copypage.s
file arch/m68k/m68k/db_disasm.c ddb
file arch/m68k/m68k/db_interface.c ddb
file arch/m68k/m68k/db_trace.c ddb
@@ -11,12 +15,9 @@ file arch/m68k/m68k/m68k_machdep.c
file arch/m68k/m68k/mappedcopy.c mappedcopy
file arch/m68k/m68k/oc_cksum.s inet
file arch/m68k/m68k/process_machdep.c
-file arch/m68k/m68k/sig_machdep.c
file arch/m68k/m68k/random.s
-file arch/m68k/m68k/copy.s
-file arch/m68k/m68k/bcopy.s
-file arch/m68k/m68k/copypage.s
file arch/m68k/m68k/regdump.c
+file arch/m68k/m68k/sig_machdep.c
#
# Older m68k4k executables binary compatibility
diff --git a/sys/arch/m68k/include/cpu.h b/sys/arch/m68k/include/cpu.h
index f9686dc0dda..232dd54eb5b 100644
--- a/sys/arch/m68k/include/cpu.h
+++ b/sys/arch/m68k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.11 2003/09/26 21:43:30 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.12 2005/08/01 11:54:23 miod Exp $ */
/* $NetBSD: cpu.h,v 1.3 1997/02/02 06:56:57 thorpej Exp $ */
/*
@@ -206,6 +206,12 @@ void userret(struct proc *, struct frame *, u_quad_t, u_int, int);
struct trapframe;
void regdump(struct trapframe *, int);
+/* sys_machdep.c */
+int cachectl(struct proc *, int, vaddr_t, int);
+#define CC_PURGE 0x00000001
+#define CC_FLUSH 0x00000002
+#define CC_IPURGE 0x00000004
+#define CC_EXTPURGE 0x80000000
#endif /* _KERNEL */
diff --git a/sys/arch/m68k/m68k/cachectl.c b/sys/arch/m68k/m68k/cachectl.c
new file mode 100644
index 00000000000..b1a74ff90ef
--- /dev/null
+++ b/sys/arch/m68k/m68k/cachectl.c
@@ -0,0 +1,176 @@
+/* $OpenBSD: cachectl.c,v 1.1 2005/08/01 11:54:24 miod Exp $ */
+/* $NetBSD: sys_machdep.c,v 1.17 1997/05/19 10:15:00 veego Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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. 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.
+ *
+ * @(#)sys_machdep.c 8.2 (Berkeley) 1/13/94
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/kernel.h>
+
+#include <machine/cpu.h>
+
+#include <uvm/uvm_extern.h>
+
+/*
+ * Note that what we do here for a 68040 is different than HP-UX.
+ *
+ * In HP-UX they either act on a line (len == 16), a page (len == NBPG)
+ * or the whole cache (len == anything else).
+ *
+ * In BSD we attempt to be more optimal when acting on "odd" sizes.
+ * For lengths up to 1024 we do all affected lines, up to 2 * NBPG we
+ * do pages, above that we do the entire cache.
+ */
+/*ARGSUSED1*/
+int
+cachectl(struct proc *p, int req, vaddr_t addr, int len)
+{
+ int error = 0;
+
+#if defined(M68040) || defined(M68060)
+ if (mmutype <= MMU_68040) {
+ int inc = 0;
+ int doall = 0;
+ paddr_t pa = 0;
+ vaddr_t end = 0;
+#ifdef COMPAT_HPUX
+ extern struct emul emul_hpux;
+
+ if ((p->p_emul == &emul_hpux) &&
+ len != 16 && len != NBPG)
+ doall = 1;
+#endif
+
+ if (addr == 0 ||
+ ((req & ~CC_EXTPURGE) != CC_PURGE && len > 2*NBPG))
+ doall = 1;
+
+ if (!doall) {
+ end = addr + len;
+ if (len <= 1024) {
+ addr = addr & ~0xF;
+ inc = 16;
+ } else {
+ addr = addr & ~PGOFSET;
+ inc = NBPG;
+ }
+ }
+ do {
+ /*
+ * Convert to physical address if needed.
+ * If translation fails, we perform operation on
+ * entire cache (XXX is this a rational thing to do?)
+ */
+ if (!doall &&
+ (pa == 0 || ((int)addr & PGOFSET) == 0)) {
+ if (pmap_extract(
+ p->p_vmspace->vm_map.pmap,
+ addr, &pa) == FALSE)
+ doall = 1;
+ }
+ switch (req) {
+ case CC_EXTPURGE|CC_IPURGE:
+ case CC_IPURGE:
+ if (doall) {
+ DCFA();
+ ICPA();
+ } else if (inc == 16) {
+ DCFL(pa);
+ ICPL(pa);
+ } else if (inc == NBPG) {
+ DCFP(pa);
+ ICPP(pa);
+ }
+ break;
+
+ case CC_EXTPURGE|CC_PURGE:
+ case CC_PURGE:
+ if (doall)
+ DCFA(); /* note: flush not purge */
+ else if (inc == 16)
+ DCPL(pa);
+ else if (inc == NBPG)
+ DCPP(pa);
+ break;
+
+ case CC_EXTPURGE|CC_FLUSH:
+ case CC_FLUSH:
+ if (doall)
+ DCFA();
+ else if (inc == 16)
+ DCFL(pa);
+ else if (inc == NBPG)
+ DCFP(pa);
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+ if (doall)
+ break;
+ pa += inc;
+ addr += inc;
+ } while (addr < end);
+ return (error);
+ }
+#endif
+ switch (req) {
+ case CC_EXTPURGE|CC_PURGE:
+ case CC_EXTPURGE|CC_FLUSH:
+#if defined(CACHE_HAVE_PAC)
+ if (ectype == EC_PHYS)
+ PCIA();
+ /* FALLTHROUGH */
+#endif
+ case CC_PURGE:
+ case CC_FLUSH:
+ DCIU();
+ break;
+ case CC_EXTPURGE|CC_IPURGE:
+#if defined(CACHE_HAVE_PAC)
+ if (ectype == EC_PHYS)
+ PCIA();
+ else
+#endif
+ DCIU();
+ /* FALLTHROUGH */
+ case CC_IPURGE:
+ ICIA();
+ break;
+ default:
+ error = EINVAL;
+ break;
+ }
+ return (error);
+}
diff --git a/sys/arch/m68k/m68k/pmap_motorola.c b/sys/arch/m68k/m68k/pmap_motorola.c
index b3d60d608fd..53dc51a96c5 100644
--- a/sys/arch/m68k/m68k/pmap_motorola.c
+++ b/sys/arch/m68k/m68k/pmap_motorola.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap_motorola.c,v 1.38 2005/04/27 00:12:41 miod Exp $ */
+/* $OpenBSD: pmap_motorola.c,v 1.39 2005/08/01 11:54:24 miod Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -2702,7 +2702,7 @@ pmap_proc_iflush(p, va, len)
vaddr_t va;
vsize_t len;
{
- (void)cachectl(p, 0x80000004, va, len);
+ (void)cachectl(p, CC_EXTPURGE | CC_IPURGE, va, len);
}
#ifdef DEBUG
diff --git a/sys/arch/mac68k/include/cpu.h b/sys/arch/mac68k/include/cpu.h
index c4abd9ff8df..cf1b4d4d85c 100644
--- a/sys/arch/mac68k/include/cpu.h
+++ b/sys/arch/mac68k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.33 2005/07/31 15:39:56 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.34 2005/08/01 11:54:24 miod Exp $ */
/* $NetBSD: cpu.h,v 1.45 1997/02/10 22:13:40 scottr Exp $ */
/*
@@ -323,9 +323,6 @@ void savectx(struct pcb *);
void proc_trampoline(void);
void loadustp(int);
-/* sys_machdep.c */
-int cachectl(struct proc *, int, vaddr_t, int);
-
/* vm_machdep.c */
void physaccess(caddr_t, caddr_t, register int, register int);
void physunaccess(caddr_t, register int);
diff --git a/sys/arch/mac68k/mac68k/sys_machdep.c b/sys/arch/mac68k/mac68k/sys_machdep.c
index ca8c802c3c5..77db7b5750e 100644
--- a/sys/arch/mac68k/mac68k/sys_machdep.c
+++ b/sys/arch/mac68k/mac68k/sys_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_machdep.c,v 1.9 2004/05/20 09:20:42 kettenis Exp $ */
+/* $OpenBSD: sys_machdep.c,v 1.10 2005/08/01 11:54:24 miod Exp $ */
/* $NetBSD: sys_machdep.c,v 1.9 1996/05/05 06:18:58 briggs Exp $ */
/*
@@ -79,130 +79,8 @@
#include <sys/buf.h>
#include <sys/mount.h>
-#include <uvm/uvm_extern.h>
-
#include <sys/syscallargs.h>
-#include <machine/cpu.h>
-
-/* XXX should be in an include file somewhere */
-#define CC_PURGE 1
-#define CC_FLUSH 2
-#define CC_IPURGE 4
-#define CC_EXTPURGE 0x80000000
-/* XXX end should be */
-
-/*ARGSUSED1*/
-int
-cachectl(p, req, addr, len)
- struct proc *p;
- int req;
- vaddr_t addr;
- int len;
-{
- int error = 0;
-
-#if defined(M68040)
- if (mmutype == MMU_68040) {
- int inc = 0;
- int doall = 0;
- paddr_t pa = 0;
- vaddr_t end = 0;
-
- if (addr == 0 ||
- ((req & ~CC_EXTPURGE) != CC_PURGE && len > 2*NBPG))
- doall = 1;
-
- if (!doall) {
- end = addr + len;
- if (len <= 1024) {
- addr = addr & ~0xF;
- inc = 16;
- } else {
- addr = addr & ~PGOFSET;
- inc = NBPG;
- }
- }
- do {
- /*
- * Convert to physical address if needed.
- * If translation fails, we perform operation on
- * entire cache (XXX is this a rational thing to do?)
- */
- if (!doall &&
- (pa == 0 || ((int)addr & PGOFSET) == 0)) {
- if (pmap_extract(
- p->p_vmspace->vm_map.pmap,
- addr, &pa) == FALSE)
- doall = 1;
- }
- switch (req) {
- case CC_EXTPURGE|CC_IPURGE:
- case CC_IPURGE:
- if (doall) {
- DCFA();
- ICPA();
- } else if (inc == 16) {
- DCFL(pa);
- ICPL(pa);
- } else if (inc == NBPG) {
- DCFP(pa);
- ICPP(pa);
- }
- break;
-
- case CC_EXTPURGE|CC_PURGE:
- case CC_PURGE:
- if (doall)
- DCFA(); /* note: flush not purge */
- else if (inc == 16)
- DCPL(pa);
- else if (inc == NBPG)
- DCPP(pa);
- break;
-
- case CC_EXTPURGE|CC_FLUSH:
- case CC_FLUSH:
- if (doall)
- DCFA();
- else if (inc == 16)
- DCFL(pa);
- else if (inc == NBPG)
- DCFP(pa);
- break;
-
- default:
- error = EINVAL;
- break;
- }
- if (doall)
- break;
- pa += inc;
- addr += inc;
- } while (addr < end);
- return(error);
- }
-#endif
- switch (req) {
- case CC_EXTPURGE|CC_PURGE:
- case CC_EXTPURGE|CC_FLUSH:
- case CC_PURGE:
- case CC_FLUSH:
- DCIU();
- break;
- case CC_EXTPURGE|CC_IPURGE:
- DCIU();
- /* fall into... */
- case CC_IPURGE:
- ICIA();
- break;
- default:
- error = EINVAL;
- break;
- }
- return(error);
-}
-
int
sys_sysarch(p, v, retval)
struct proc *p;
diff --git a/sys/arch/mvme68k/include/cpu.h b/sys/arch/mvme68k/include/cpu.h
index f9770cac365..2dea1d93e5c 100644
--- a/sys/arch/mvme68k/include/cpu.h
+++ b/sys/arch/mvme68k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.19 2004/07/30 22:29:48 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.20 2005/08/01 11:54:25 miod Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -233,7 +233,6 @@ int badvaddr(vaddr_t, int);
void nmihand(void *);
int intr_findvec(int, int);
-int cachectl(struct proc *, int, vaddr_t, int);
void dma_cachectl(caddr_t, int);
paddr_t kvtop(vaddr_t);
void physaccess(vaddr_t, paddr_t, size_t, int);
diff --git a/sys/arch/mvme68k/mvme68k/sys_machdep.c b/sys/arch/mvme68k/mvme68k/sys_machdep.c
index aaf73796ce5..e234de054d6 100644
--- a/sys/arch/mvme68k/mvme68k/sys_machdep.c
+++ b/sys/arch/mvme68k/mvme68k/sys_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_machdep.c,v 1.17 2004/12/01 21:13:03 miod Exp $ */
+/* $OpenBSD: sys_machdep.c,v 1.18 2005/08/01 11:54:25 miod Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -50,140 +50,6 @@
#include <machine/cpu.h>
-/* XXX should be in an include file somewhere */
-#define CC_PURGE 1
-#define CC_FLUSH 2
-#define CC_IPURGE 4
-#define CC_EXTPURGE 0x80000000
-/* XXX end should be */
-
-/*
- * Note that what we do here for a 68040 is different than HP-UX.
- *
- * In 'pux they either act on a line (len == 16), a page (len == NBPG)
- * or the whole cache (len == anything else).
- *
- * In BSD we attempt to be more optimal when acting on "odd" sizes.
- * For lengths up to 1024 we do all affected lines, up to 2*NBPG we
- * do pages, above that we do the entire cache.
- */
-/*ARGSUSED1*/
-int
-cachectl(p, req, addr, len)
- struct proc *p;
- int req;
- vaddr_t addr;
- int len;
-{
- int error = 0;
-
-#if defined(M68040) || defined(M68060)
- if (mmutype <= MMU_68040) {
- int inc = 0;
- int doall = 0;
- paddr_t pa = 0;
- vaddr_t end = 0;
-#ifdef COMPAT_HPUX
- extern struct emul emul_hpux;
-
- if ((p->p_emul == &emul_hpux) &&
- len != 16 && len != NBPG)
- doall = 1;
-#endif
- if (addr == 0 ||
- ((req & ~CC_EXTPURGE) != CC_PURGE && len > 2*NBPG))
- doall = 1;
-
- if (!doall) {
- end = addr + len;
- if (len <= 1024) {
- addr = addr & ~0xF;
- inc = 16;
- } else {
- addr = addr & ~PGOFSET;
- inc = NBPG;
- }
- }
- do {
- /*
- * Convert to physical address if needed.
- * If translation fails, we perform operation on
- * entire cache (XXX is this a rational thing to do?)
- */
- if (!doall &&
- (pa == 0 || ((int)addr & PGOFSET) == 0)) {
- if (pmap_extract(
- p->p_vmspace->vm_map.pmap,
- addr, &pa) == FALSE)
- doall = 1;
- }
- switch (req) {
- case CC_EXTPURGE|CC_IPURGE:
- case CC_IPURGE:
- if (doall) {
- DCFA();
- ICPA();
- } else if (inc == 16) {
- DCFL(pa);
- ICPL(pa);
- } else if (inc == NBPG) {
- DCFP(pa);
- ICPP(pa);
- }
- break;
-
- case CC_EXTPURGE|CC_PURGE:
- case CC_PURGE:
- if (doall)
- DCFA(); /* note: flush not purge */
- else if (inc == 16)
- DCPL(pa);
- else if (inc == NBPG)
- DCPP(pa);
- break;
-
- case CC_EXTPURGE|CC_FLUSH:
- case CC_FLUSH:
- if (doall)
- DCFA();
- else if (inc == 16)
- DCFL(pa);
- else if (inc == NBPG)
- DCFP(pa);
- break;
-
- default:
- error = EINVAL;
- break;
- }
- if (doall)
- break;
- pa += inc;
- addr += inc;
- } while (addr < end);
- return (error);
- }
-#endif
- switch (req) {
- case CC_EXTPURGE|CC_PURGE:
- case CC_EXTPURGE|CC_FLUSH:
- case CC_PURGE:
- case CC_FLUSH:
- DCIU();
- break;
- case CC_EXTPURGE|CC_IPURGE:
- DCIU();
- /* fall into... */
- case CC_IPURGE:
- ICIA();
- break;
- default:
- error = EINVAL;
- break;
- }
- return (error);
-}
-
/*
* DMA cache control
*/