summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2008-04-07 22:37:19 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2008-04-07 22:37:19 +0000
commit4daaa30806c6bc03f7497d244da68c0006efb101 (patch)
tree80d99a94a1a5e132acd19ba0916f90dc9971e73b /sys/arch
parent3b155998b905d3951937b9aa72b3f53c5f07d8e0 (diff)
Add ``guarded'' word read and write routines, to be used by machine-dependent
code soon. Similar to what ddb does, but does not need ddb to be compiled in.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/mips64/include/cpu.h6
-rw-r--r--sys/arch/mips64/include/trap.h3
-rw-r--r--sys/arch/mips64/mips64/lcore_access.S41
3 files changed, 46 insertions, 4 deletions
diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h
index 629c4bf8766..d320ef5a309 100644
--- a/sys/arch/mips64/include/cpu.h
+++ b/sys/arch/mips64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.23 2008/04/07 22:29:16 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.24 2008/04/07 22:37:16 miod Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -545,10 +545,12 @@ int tlb_update(vaddr_t, unsigned);
void tlb_read(int, struct tlb_entry *);
void savectx(struct user *, int);
-void switch_exit(struct proc *);
void MipsSaveCurFPState(struct proc *);
void MipsSaveCurFPState16(struct proc *);
+int guarded_read_4(paddr_t, uint32_t *);
+int guarded_write_4(paddr_t, uint32_t);
+
extern u_int32_t cpu_counter_interval; /* Number of counter ticks/tick */
extern u_int32_t cpu_counter_last; /* Last compare value loaded */
diff --git a/sys/arch/mips64/include/trap.h b/sys/arch/mips64/include/trap.h
index 2fd793bd754..8095310ad01 100644
--- a/sys/arch/mips64/include/trap.h
+++ b/sys/arch/mips64/include/trap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.h,v 1.8 2007/05/20 14:34:21 miod Exp $ */
+/* $OpenBSD: trap.h,v 1.9 2008/04/07 22:37:16 miod Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -77,6 +77,7 @@
#define KT_COPYERR 1 /* User space copy error */
#define KT_KCOPYERR 2 /* Kernel space copy error */
#define KT_DDBERR 3 /* DDB access error */
+#define KT_GUARDERR 4 /* guarded access error */
#ifndef _LOCORE
diff --git a/sys/arch/mips64/mips64/lcore_access.S b/sys/arch/mips64/mips64/lcore_access.S
index 9da36ec7b38..a6e2b25cdbc 100644
--- a/sys/arch/mips64/mips64/lcore_access.S
+++ b/sys/arch/mips64/mips64/lcore_access.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: lcore_access.S,v 1.13 2008/02/20 21:34:19 miod Exp $ */
+/* $OpenBSD: lcore_access.S,v 1.14 2008/04/07 22:37:18 miod Exp $ */
/*
* Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -64,6 +64,7 @@ onfault_table:
#else
PTR_VAL 0
#endif
+ PTR_VAL _guarderr
.text
/*
@@ -330,3 +331,41 @@ _kcopyerr:
PTR_ADDU sp, sp, FRAMESZ(CF_SZ + REGSZ)
j ra
li v0, EFAULT # return error
+
+/*
+ * Guarded ``memory'' access routines
+ * int guarded_read_4(paddr_t address, uint32_t *dest);
+ * int guarded_write_4(paddr_t address, uint32_t src);
+ */
+
+LEAF(guarded_read_4, 0)
+ PTR_L t3, curprocpaddr
+ li v0, KT_GUARDERR
+ lw v1, PCB_ONFAULT(t3)
+ sw v0, PCB_ONFAULT(t3)
+
+ lw v0, 0(a0)
+ sw v0, 0(a1)
+
+ sw v1, PCB_ONFAULT(t3)
+ j ra
+ move v0, zero
+END(guarded_read_4)
+
+LEAF(guarded_write_4, 0)
+ PTR_L t3, curprocpaddr
+ li v0, KT_GUARDERR
+ lw v1, PCB_ONFAULT(t3)
+ sw v0, PCB_ONFAULT(t3)
+
+ sw a1, 0(a0)
+
+ sw v1, PCB_ONFAULT(t3)
+ j ra
+ move v0, zero
+END(guarded_write_4)
+
+_guarderr:
+ sw v1, PCB_ONFAULT(t3)
+ j ra
+ li v0, EFAULT # return error