summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1999-09-03 18:11:30 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1999-09-03 18:11:30 +0000
commit0fea0dd47ea6070fd1755262432fd2fc46562ccd (patch)
treee438f529b172a3829e755941537b7270b2c8d50f /sys
parent2a4977388d8ca2cef9e73cd2e0bbdaef83b4a180 (diff)
We have to set the pagetable pointers with the atomic swap instruction.
From NetBSD. (actually from a paper I read recently, but since NetBSD already did that it was easier to grab the code from them)
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc/sparc/asm.h8
-rw-r--r--sys/arch/sparc/sparc/pmap.c4
2 files changed, 9 insertions, 3 deletions
diff --git a/sys/arch/sparc/sparc/asm.h b/sys/arch/sparc/sparc/asm.h
index 534853ce491..3258be1e584 100644
--- a/sys/arch/sparc/sparc/asm.h
+++ b/sys/arch/sparc/sparc/asm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: asm.h,v 1.2 1997/08/08 08:26:58 downsj Exp $ */
+/* $OpenBSD: asm.h,v 1.3 1999/09/03 18:11:28 art Exp $ */
/* $NetBSD: asm.h,v 1.4 1996/07/01 18:01:26 abrown Exp $ */
/*
@@ -117,3 +117,9 @@
__asm __volatile("stda %0,[%1]%2" : : \
"r" ((long long)(value)), "r" ((int)(loc)), "n" (asi)); \
})
+
+/* atomic swap of a word between a register and memory */
+#define swap(loc, val) ({ \
+ __asm __volatile("swap [%2],%0" : "=&r" (val) : "0" (val), "r" (loc)); \
+})
+
diff --git a/sys/arch/sparc/sparc/pmap.c b/sys/arch/sparc/sparc/pmap.c
index 1867c14bcff..0416d02833f 100644
--- a/sys/arch/sparc/sparc/pmap.c
+++ b/sys/arch/sparc/sparc/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.32 1999/09/03 18:01:59 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.33 1999/09/03 18:11:29 art Exp $ */
/* $NetBSD: pmap.c,v 1.118 1998/05/19 19:00:18 thorpej Exp $ */
/*
@@ -612,7 +612,7 @@ setpgt4m(ptep, pte)
int *ptep;
int pte;
{
- *ptep = pte;
+ swap(ptep, pte);
if ((cpuinfo.flags & CPUFLG_CACHEPAGETABLES) == 0)
cpuinfo.pcache_flush_line((int)ptep, VA2PA((caddr_t)ptep));
}