Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 5 commits
  • 13 files changed
  • 0 comments
  • 1 contributor
3  sys/arch/lm32/conf/files.lm32
@@ -6,6 +6,9 @@ file	arch/lm32/lm32/cpu.c
6 6
 file	arch/lm32/lm32/syscall.c
7 7
 file	arch/lm32/lm32/process_machdep.c
8 8
 file	arch/lm32/lm32/interrupt.c
  9
+file	arch/lm32/lm32/vm_machdep.c
  10
+file	arch/lm32/lm32/procfs_machdep.c
  11
+file	arch/lm32/lm32/sig_machdep.c
9 12
 file    arch/lm32/lm32/lock_stubs.S
10 13
 file	arch/lm32/lm32/locore_subr.S
11 14
 file	dev/cons.c
7  sys/arch/lm32/include/cpu.h
@@ -154,6 +154,7 @@ struct cpu_info {
154 154
 	char *ci_doubleflt_stack;
155 155
 	char *ci_ddbipi_stack;
156 156
 	volatile int	ci_want_resched;
  157
+	int		ci_idepth;
157 158
 };
158 159
 
159 160
 
@@ -219,7 +220,7 @@ do {									\
219 220
  * Notify the LWP l that it has a signal pending, process as soon as
220 221
  * possible.
221 222
  */
222  
-extern void	cpu_signotify(struct lwp *);
  223
+#define		cpu_signotify(l)	aston(l)
223 224
 
224 225
 /*
225 226
  * We need a machine-independent name for this.
@@ -296,4 +297,8 @@ struct disklist {
296 297
 		int ni_biosmatches[MAX_BIOSDISKS]; /* indices in dl_biosdisks */
297 298
 	} dl_nativedisks[1];			   /* actually longer */
298 299
 };
  300
+
  301
+#define	LM32_TF_R1(tf)	tf->tf_regs.r_regs[R1]
  302
+#define	LM32_TF_R2(tf)	tf->tf_regs.r_regs[R2]
  303
+
299 304
 #endif /* !_LM32_CPU_H_ */
1  sys/arch/lm32/include/frame.h
@@ -87,6 +87,7 @@ struct sigframe_siginfo {
87 87
 
88 88
 struct trapframe {
89 89
 	struct reg tf_regs;
  90
+	int	tf_pc;
90 91
 };
91 92
 
92 93
 void *getframe(struct lwp *, int, int *);
5  sys/arch/lm32/include/mcontext.h
@@ -49,7 +49,7 @@
49 49
 /*
50 50
  * General register state
51 51
  */
52  
-#define _NGREG		29
  52
+#define _NGREG		32
53 53
 typedef	int		__greg_t;
54 54
 typedef	__greg_t	__gregset_t[_NGREG];
55 55
 
@@ -82,6 +82,9 @@ typedef	__greg_t	__gregset_t[_NGREG];
82 82
 #define _REG_FP		26
83 83
 #define _REG_SP		27
84 84
 #define _REG_RA		28
  85
+#define _REG_EA		29
  86
+#define _REG_BA		30
  87
+#define _REG_PC		31
85 88
 
86 89
 typedef struct {
87 90
 	__gregset_t	__gregs;
3  sys/arch/lm32/include/proc.h
@@ -55,9 +55,6 @@ struct mdproc {
55 55
 		.md_flags = 0, \
56 56
 		.md_utf = { \
57 57
 			.tf_regs = { .r_regs = { 0 }, \
58  
-				.r_ra = 0, \
59  
-				.r_ea = 0, \
60  
-				.r_ba = 0, \
61 58
 				.r_pc = 0} } \
62 59
 	}
63 60
 #endif /* _KERNEL */
20  sys/arch/lm32/include/reg.h
... ...
@@ -1,8 +1,7 @@
1  
-/*	$NetBSD: reg.h,v 1.18 2011/02/08 20:20:16 rmind Exp $	*/
2  
-
3 1
 /*
4 2
  * Copyright (c) 1988 University of Utah.
5 3
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
  4
+ * Copyright (c) 2013 Yann Sionneau <yann.sionneau@gmail.com>
6 5
  * All rights reserved.
7 6
  *
8 7
  * This code is derived from software contributed to Berkeley by
@@ -45,10 +44,7 @@
45 44
  * Register set accessible via /proc/$pid/reg and ptrace()
46 45
  */
47 46
 struct reg {
48  
-	int	r_regs[28];	/* R1-R28 , R0 is always 0 */
49  
-	int	r_ra;
50  
-	int	r_ea;
51  
-	int 	r_ba;
  47
+	int	r_regs[31];	/* R1-R31 , R0 is always 0 */
52 48
 	int	r_pc;
53 49
 };
54 50
 
@@ -83,12 +79,18 @@ struct reg {
83 79
 #define	R24	(23)
84 80
 #define	R25	(24)
85 81
 #define	R26	(25)
  82
+#define	R_GP	(R26)
86 83
 #define	R27	(26)
  84
+#define	R_FP	R27
87 85
 #define	R28	(27)
  86
+#define	R_SP	R28
88 87
 
89  
-#define	RA	(28)
90  
-#define	EA	(29)
91  
-#define	BA	(30)
  88
+#define	R29	(28)
  89
+#define	R_RA	R29
  90
+#define	R30 	(29)
  91
+#define	R_EA	R30
  92
+#define	R31	(30)
  93
+#define	R_BA	R31
92 94
 
93 95
 #ifdef _KERNEL
94 96
 
1  sys/arch/lm32/include/types.h
@@ -91,7 +91,6 @@ typedef	volatile unsigned char		__cpu_simple_lock_t;
91 91
 #define	__HAVE_OLD_DISKLABEL
92 92
 #define	__HAVE_CPU_LWP_SETPRIVATE
93 93
 #define	__HAVE_INTR_CONTROL
94  
-#define	__HAVE_MM_MD_OPEN
95 94
 #define	__HAVE___LWP_GETPRIVATE_FAST
96 95
 
97 96
 #if defined(_KERNEL)
24  sys/arch/lm32/lm32/procfs_machdep.c
... ...
@@ -0,0 +1,24 @@
  1
+/*
  2
+ * Copyright (c) 2013 Yann Sionneau <yann.sionneau@gmail.com>
  3
+ */
  4
+
  5
+#include <sys/cdefs.h>
  6
+
  7
+#include <sys/param.h>
  8
+#include <sys/systm.h>
  9
+#include <sys/mount.h>
  10
+#include <sys/vnode.h>
  11
+#include <miscfs/procfs/procfs.h>
  12
+
  13
+
  14
+/*
  15
+ * Linux-style /proc/cpuinfo.
  16
+ * Only used when procfs is mounted with -o linux.
  17
+ */
  18
+int
  19
+procfs_getcpuinfstr(char *buf, int *len)
  20
+{
  21
+	*len = 0;
  22
+
  23
+	return 0;
  24
+}
115  sys/arch/lm32/lm32/sig_machdep.c
... ...
@@ -0,0 +1,115 @@
  1
+/*-
  2
+ * Copyright (C) 2013 Yann Sionneau <yann.sionneau@gmail.com>
  3
+ * All rights reserved.
  4
+ *
  5
+ * This code is derived from software contributed to The NetBSD Foundation
  6
+ * by Christos Zoulas.
  7
+ *
  8
+ * Redistribution and use in source and binary forms, with or without
  9
+ * modification, are permitted provided that the following conditions
  10
+ * are met:
  11
+ * 1. Redistributions of source code must retain the above copyright
  12
+ *    notice, this list of conditions and the following disclaimer.
  13
+ * 2. Redistributions in binary form must reproduce the above copyright
  14
+ *    notice, this list of conditions and the following disclaimer in the
  15
+ *    documentation and/or other materials provided with the distribution.
  16
+ *
  17
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  18
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  19
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  21
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  24
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  25
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  27
+ * POSSIBILITY OF SUCH DAMAGE.
  28
+ */
  29
+
  30
+#include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
  31
+
  32
+#include <sys/param.h>
  33
+#include <sys/cpu.h>
  34
+#include <sys/kernel.h>
  35
+#include <sys/proc.h>
  36
+#include <sys/signal.h>
  37
+#include <sys/signalvar.h>
  38
+#include <sys/mount.h>
  39
+#include <sys/syscallargs.h>
  40
+
  41
+#include <lm32/frame.h>
  42
+#include <lm32/reg.h>
  43
+
  44
+void *	
  45
+getframe(struct lwp *l, int sig, int *onstack)
  46
+{
  47
+	struct proc * const p = l->l_proc;
  48
+	struct trapframe * const tf = &l->l_md.md_utf;
  49
+ 
  50
+	/* Do we need to jump onto the signal stack? */
  51
+	*onstack = (l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0
  52
+	    && (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
  53
+	if (*onstack)
  54
+		return (char *)l->l_sigstk.ss_sp + l->l_sigstk.ss_size;
  55
+	return (void *)(intptr_t)tf->tf_regs.r_regs[R_SP];
  56
+}
  57
+
  58
+/*
  59
+ * Send a signal to process.
  60
+ */
  61
+void
  62
+sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
  63
+{
  64
+	struct lwp * const l = curlwp;
  65
+	struct proc * const p = l->l_proc;
  66
+	struct sigacts * const sa = p->p_sigacts;
  67
+	struct trapframe * const tf = &l->l_md.md_utf;
  68
+	int onstack, error;
  69
+	const int signo = ksi->ksi_signo;
  70
+	struct sigframe_siginfo *sf = getframe(l, signo, &onstack);
  71
+	struct sigframe_siginfo ksf;
  72
+	const sig_t catcher = SIGACTION(p, signo).sa_handler;
  73
+
  74
+	/* allocate a sigframe_siginfo structure on the stack */
  75
+	sf--;
  76
+
  77
+	ksf.sf_si._info = ksi->ksi_info;
  78
+	ksf.sf_uc.uc_flags = _UC_SIGMASK
  79
+	    | (l->l_sigstk.ss_flags & SS_ONSTACK ? _UC_SETSTACK : _UC_CLRSTACK);
  80
+	ksf.sf_uc.uc_sigmask = *mask;
  81
+	ksf.sf_uc.uc_link = l->l_ctxlink;
  82
+	memset(&ksf.sf_uc.uc_stack, 0, sizeof(ksf.sf_uc.uc_stack));
  83
+	sendsig_reset(l, signo);
  84
+
  85
+	mutex_exit(p->p_lock);
  86
+	cpu_getmcontext(l, &ksf.sf_uc.uc_mcontext, &ksf.sf_uc.uc_flags);
  87
+	error = copyout(&ksf, sf, sizeof(ksf));
  88
+	mutex_enter(p->p_lock);
  89
+
  90
+	if (error != 0) {
  91
+		/*
  92
+		 * Process has trashed its stack; give it an illegal
  93
+		 * instruction to halt it in its tracks.
  94
+		 */
  95
+		sigexit(l, SIGILL);
  96
+		/* NOTREACHED */
  97
+	}
  98
+
  99
+	/*
  100
+	 * Set up the registers to directly invoke the signal
  101
+	 * handler.  The return address will be set up to point
  102
+	 * to the signal trampoline to bounce us back.
  103
+	 */
  104
+	tf->tf_regs.r_regs[R1] = signo;
  105
+	tf->tf_regs.r_regs[R2] = (intptr_t)&sf->sf_si;
  106
+	tf->tf_regs.r_regs[R3] = (intptr_t)&sf->sf_uc;
  107
+
  108
+	tf->tf_pc = (intptr_t)catcher;
  109
+	tf->tf_regs.r_regs[R_SP] = (intptr_t)sf;
  110
+	tf->tf_regs.r_regs[R_RA] = (intptr_t)sa->sa_sigdesc[signo].sd_tramp;
  111
+
  112
+	/* Remember that we're now on the signal stack. */
  113
+	if (onstack)
  114
+		l->l_sigstk.ss_flags |= SS_ONSTACK;
  115
+}
89  sys/arch/lm32/lm32/syscall.c
@@ -6,12 +6,16 @@
6 6
 #include <sys/systm.h>
7 7
 #include <sys/syscallvar.h>
8 8
 #include <sys/syscall.h>
9  
-
  9
+#include <sys/syscall_stats.h>
10 10
 #include <uvm/uvm_extern.h>
11 11
 
12 12
 #include <lm32/frame.h>
13 13
 #include <lm32/pcb.h>
14 14
 #include <lm32/reg.h>
  15
+#include <machine/userret.h>
  16
+
  17
+void		syscall_intern(struct proc *);
  18
+static void	syscall(struct trapframe *);
15 19
 
16 20
 void
17 21
 child_return(void *arg)
@@ -22,3 +26,86 @@ child_return(void *arg)
22 26
 	tf->tf_regs.r_regs[R1] = 0; // set return value to 0 as the result of fork() for the child
23 27
 	ktrsysret(SYS_fork, 0, 0);
24 28
 }
  29
+
  30
+/*
  31
+ * Process the tail end of a posix_spawn() for the child.
  32
+ */
  33
+void
  34
+cpu_spawn_return(struct lwp *l)
  35
+{
  36
+	userret(l);
  37
+}
  38
+
  39
+void
  40
+syscall_intern(struct proc *p)
  41
+{
  42
+
  43
+	p->p_md.md_syscall = syscall;
  44
+}
  45
+
  46
+/*
  47
+ * syscall(frame):
  48
+ *	System call request from POSIX system call gate interface to kernel.
  49
+ *	Like trap(), argument is call by reference.
  50
+ */
  51
+static void
  52
+syscall(struct trapframe *frame)
  53
+{
  54
+	const struct sysent *callp;
  55
+	struct proc *p;
  56
+	struct lwp *l;
  57
+	int error;
  58
+	register_t code, rval[2];
  59
+	register_t args[2 + SYS_MAXSYSARGS];
  60
+
  61
+	l = curlwp;
  62
+	p = l->l_proc;
  63
+	LWP_CACHE_CREDS(l, p);
  64
+
  65
+	code = LM32_TF_R1(frame) & (SYS_NSYSENT - 1);
  66
+	callp = p->p_emul->e_sysent + code;
  67
+
  68
+	SYSCALL_COUNT(syscall_counts, code);
  69
+	SYSCALL_TIME_SYS_ENTRY(l, syscall_times, code);
  70
+
  71
+	if (callp->sy_argsize) {
  72
+		error = copyin((char *)frame->tf_regs.r_regs[R_SP] + sizeof(int), args,
  73
+			    callp->sy_argsize);
  74
+		if (__predict_false(error != 0))
  75
+			goto bad;
  76
+	}
  77
+
  78
+	if (!__predict_false(p->p_trace_enabled)
  79
+	    || __predict_false(callp->sy_flags & SYCALL_INDIRECT)
  80
+	    || (error = trace_enter(code, args, callp->sy_narg)) == 0) {
  81
+		rval[0] = 0;
  82
+		rval[1] = 0;
  83
+		error = sy_call(callp, l, args, rval);
  84
+	}
  85
+
  86
+	if (__predict_false(p->p_trace_enabled)
  87
+	    && !__predict_false(callp->sy_flags & SYCALL_INDIRECT)) {
  88
+		trace_exit(code, rval, error);
  89
+	}
  90
+
  91
+	if (__predict_true(error == 0)) {
  92
+		LM32_TF_R1(frame) = rval[0];
  93
+		LM32_TF_R2(frame) = rval[1];
  94
+	} else {
  95
+		switch (error) {
  96
+		case ERESTART:
  97
+			/* nothing to do */
  98
+			break;
  99
+		case EJUSTRETURN:
  100
+			/* nothing to do */
  101
+			break;
  102
+		default:
  103
+		bad:
  104
+			LM32_TF_R1(frame) = error;
  105
+			break;
  106
+		}
  107
+	}
  108
+
  109
+	SYSCALL_TIME_SYS_EXIT(l);
  110
+	userret(l);
  111
+}
255  sys/arch/lm32/lm32/vm_machdep.c
... ...
@@ -0,0 +1,255 @@
  1
+/*
  2
+ * Copyright (c) 1999-2004 Michael Shalayeff
  3
+ * Copyright (c) 2013 Yann Sionneau <yann.sionneau@gmail.com>
  4
+ * All rights reserved.
  5
+ *
  6
+ * Redistribution and use in source and binary forms, with or without
  7
+ * modification, are permitted provided that the following conditions
  8
+ * are met:
  9
+ * 1. Redistributions of source code must retain the above copyright
  10
+ *    notice, this list of conditions and the following disclaimer.
  11
+ * 2. Redistributions in binary form must reproduce the above copyright
  12
+ *    notice, this list of conditions and the following disclaimer in the
  13
+ *    documentation and/or other materials provided with the distribution.
  14
+ *
  15
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18
+ * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
  19
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21
+ * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  23
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  24
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  25
+ * THE POSSIBILITY OF SUCH DAMAGE.
  26
+ */
  27
+
  28
+#include <sys/cdefs.h>
  29
+
  30
+#include <sys/param.h>
  31
+#include <sys/systm.h>
  32
+#include <sys/proc.h>
  33
+#include <sys/signalvar.h>
  34
+#include <sys/malloc.h>
  35
+#include <sys/buf.h>
  36
+#include <sys/vnode.h>
  37
+#include <sys/ptrace.h>
  38
+#include <sys/exec.h>
  39
+#include <sys/core.h>
  40
+#include <sys/pool.h>
  41
+#include <sys/cpu.h>
  42
+#include <sys/kcore.h>
  43
+#include <sys/kauth.h>
  44
+#include <sys/ras.h>
  45
+#include <dev/mm.h>
  46
+
  47
+#include <machine/pmap.h>
  48
+#include <machine/pcb.h>
  49
+
  50
+#include <uvm/uvm.h>
  51
+
  52
+// TODO adapt the following function for lm32 pmap subsystem
  53
+static inline void
  54
+cpu_activate_pcb(struct lwp *l)
  55
+{
  56
+}
  57
+
  58
+
  59
+// TODO adapt the following function for lm32 pmap subsystem
  60
+void
  61
+cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
  62
+    void (*func)(void *), void *arg)
  63
+{
  64
+}
  65
+
  66
+/*
  67
+ * Map an IO request into kernel virtual address space.
  68
+ */
  69
+// TODO implement vmapbuf
  70
+int
  71
+vmapbuf(struct buf *bp, vsize_t len)
  72
+{
  73
+	return 0;
  74
+}
  75
+
  76
+/*
  77
+ * Unmap IO request from the kernel virtual address space.
  78
+ */
  79
+// TODO implement vunmapbuf
  80
+void
  81
+vunmapbuf(struct buf *bp, vsize_t len)
  82
+{
  83
+}
  84
+
  85
+// TODO implement cpu_lwp_setprivate
  86
+int
  87
+cpu_lwp_setprivate(lwp_t *l, void *addr)
  88
+{
  89
+	return 0;
  90
+}
  91
+
  92
+/*
  93
+ * cpu_lwp_free is called from exit() to let machine-dependent
  94
+ * code free machine-dependent resources.  Note that this routine
  95
+ * must not block.
  96
+ */
  97
+void
  98
+cpu_lwp_free(struct lwp *l, int proc)
  99
+{
  100
+}
  101
+
  102
+/*
  103
+ * cpu_lwp_free2 is called when an LWP is being reaped.
  104
+ * This routine may block.
  105
+ */
  106
+void
  107
+cpu_lwp_free2(struct lwp *l)
  108
+{
  109
+}
  110
+
  111
+bool
  112
+cpu_intr_p(void)
  113
+{
  114
+	int idepth;
  115
+
  116
+	kpreempt_disable();
  117
+	idepth = curcpu()->ci_idepth;
  118
+	kpreempt_enable();
  119
+	return (idepth >= 0);
  120
+}
  121
+
  122
+
  123
+/*
  124
+ * mm_md_physacc: check if given pa is accessible.
  125
+ */
  126
+
  127
+// TODO: this is copy paste from i386, must be adapted for lm32
  128
+int
  129
+mm_md_physacc(paddr_t pa, vm_prot_t prot)
  130
+{
  131
+	extern phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
  132
+	extern int mem_cluster_cnt;
  133
+	int i;
  134
+
  135
+	for (i = 0; i < mem_cluster_cnt; i++) {
  136
+		const phys_ram_seg_t *seg = &mem_clusters[i];
  137
+		paddr_t lstart = seg->start;
  138
+
  139
+		if (lstart <= pa && pa - lstart <= seg->size) {
  140
+			return 0;
  141
+		}
  142
+	}
  143
+	return kauth_authorize_machdep(kauth_cred_get(),
  144
+	    KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL);
  145
+}
  146
+
  147
+void
  148
+cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags)
  149
+{
  150
+	const struct trapframe *tf = &l->l_md.md_utf;
  151
+	__greg_t *gr = mcp->__gregs;
  152
+	__greg_t ras_pc;
  153
+
  154
+	gr[_REG_R1] = tf->tf_regs.r_regs[R1];
  155
+	gr[_REG_R2] = tf->tf_regs.r_regs[R2];
  156
+	gr[_REG_R3] = tf->tf_regs.r_regs[R3];
  157
+	gr[_REG_R4] = tf->tf_regs.r_regs[R4];
  158
+	gr[_REG_R5] = tf->tf_regs.r_regs[R5];
  159
+	gr[_REG_R6] = tf->tf_regs.r_regs[R6];
  160
+	gr[_REG_R7] = tf->tf_regs.r_regs[R7];
  161
+	gr[_REG_R8] = tf->tf_regs.r_regs[R8];
  162
+	gr[_REG_R9] = tf->tf_regs.r_regs[R9];
  163
+	gr[_REG_R10] = tf->tf_regs.r_regs[R10];
  164
+	gr[_REG_R11] = tf->tf_regs.r_regs[R11];
  165
+	gr[_REG_R12] = tf->tf_regs.r_regs[R12];
  166
+	gr[_REG_R13] = tf->tf_regs.r_regs[R13];
  167
+	gr[_REG_R14] = tf->tf_regs.r_regs[R14];
  168
+	gr[_REG_R15] = tf->tf_regs.r_regs[R15];
  169
+	gr[_REG_R16] = tf->tf_regs.r_regs[R16];
  170
+	gr[_REG_R17] = tf->tf_regs.r_regs[R17];
  171
+	gr[_REG_R18] = tf->tf_regs.r_regs[R18];
  172
+	gr[_REG_R19] = tf->tf_regs.r_regs[R19];
  173
+	gr[_REG_R20] = tf->tf_regs.r_regs[R20];
  174
+	gr[_REG_R21] = tf->tf_regs.r_regs[R21];
  175
+	gr[_REG_R22] = tf->tf_regs.r_regs[R22];
  176
+	gr[_REG_R23] = tf->tf_regs.r_regs[R23];
  177
+	gr[_REG_R24] = tf->tf_regs.r_regs[R24];
  178
+	gr[_REG_R25] = tf->tf_regs.r_regs[R25];
  179
+	gr[_REG_GP] = tf->tf_regs.r_regs[R_GP];
  180
+	gr[_REG_FP] = tf->tf_regs.r_regs[R_FP];
  181
+	gr[_REG_SP] = tf->tf_regs.r_regs[R_SP];
  182
+	gr[_REG_RA] = tf->tf_regs.r_regs[R_RA];
  183
+	gr[_REG_EA] = tf->tf_regs.r_regs[R_EA];
  184
+	gr[_REG_BA] = tf->tf_regs.r_regs[R_BA];
  185
+
  186
+	gr[_REG_PC] = tf->tf_pc;
  187
+
  188
+	if ((ras_pc = (__greg_t)ras_lookup(l->l_proc,
  189
+	    (void *) gr[_REG_PC])) != -1)
  190
+		gr[_REG_PC] = ras_pc;
  191
+
  192
+}
  193
+
  194
+int
  195
+cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags)
  196
+{
  197
+	struct trapframe *tf = &l->l_md.md_utf;
  198
+	const __greg_t *gr = mcp->__gregs;
  199
+	struct proc *p = l->l_proc;
  200
+	int error;
  201
+
  202
+	/* Restore register context, if any. */
  203
+	if ((flags & _UC_CPU) != 0) {
  204
+		error = cpu_mcontext_validate(l, mcp);
  205
+		if (error)
  206
+			return error;
  207
+
  208
+		tf->tf_regs.r_regs[R1] = gr[_REG_R1];
  209
+		tf->tf_regs.r_regs[R2] = gr[_REG_R2];
  210
+		tf->tf_regs.r_regs[R3] = gr[_REG_R3];
  211
+		tf->tf_regs.r_regs[R4] = gr[_REG_R4];
  212
+		tf->tf_regs.r_regs[R5] = gr[_REG_R5];
  213
+		tf->tf_regs.r_regs[R6] = gr[_REG_R6];
  214
+		tf->tf_regs.r_regs[R7] = gr[_REG_R7];
  215
+		tf->tf_regs.r_regs[R8] = gr[_REG_R8];
  216
+		tf->tf_regs.r_regs[R9] = gr[_REG_R9];
  217
+		tf->tf_regs.r_regs[R10] = gr[_REG_R10];
  218
+		tf->tf_regs.r_regs[R11] = gr[_REG_R11];
  219
+		tf->tf_regs.r_regs[R12] = gr[_REG_R12];
  220
+		tf->tf_regs.r_regs[R13] = gr[_REG_R13];
  221
+		tf->tf_regs.r_regs[R14] = gr[_REG_R14];
  222
+		tf->tf_regs.r_regs[R15] = gr[_REG_R15];
  223
+		tf->tf_regs.r_regs[R16] = gr[_REG_R16];
  224
+		tf->tf_regs.r_regs[R17] = gr[_REG_R17];
  225
+		tf->tf_regs.r_regs[R18] = gr[_REG_R18];
  226
+		tf->tf_regs.r_regs[R19] = gr[_REG_R19];
  227
+		tf->tf_regs.r_regs[R20] = gr[_REG_R20];
  228
+		tf->tf_regs.r_regs[R21] = gr[_REG_R21];
  229
+		tf->tf_regs.r_regs[R22] = gr[_REG_R22];
  230
+		tf->tf_regs.r_regs[R23] = gr[_REG_R23];
  231
+		tf->tf_regs.r_regs[R24] = gr[_REG_R24];
  232
+		tf->tf_regs.r_regs[R25] = gr[_REG_R25];
  233
+		tf->tf_regs.r_regs[R_GP] = gr[_REG_GP];
  234
+		tf->tf_regs.r_regs[R_FP] = gr[_REG_FP];
  235
+		tf->tf_regs.r_regs[R_SP] = gr[_REG_SP];
  236
+		tf->tf_regs.r_regs[R_RA] = gr[_REG_RA];
  237
+		tf->tf_regs.r_regs[R_EA] = gr[_REG_EA];
  238
+		tf->tf_regs.r_regs[R_BA] = gr[_REG_BA];
  239
+	}
  240
+
  241
+	mutex_enter(p->p_lock);
  242
+	if (flags & _UC_SETSTACK)
  243
+		l->l_sigstk.ss_flags |= SS_ONSTACK;
  244
+	if (flags & _UC_CLRSTACK)
  245
+		l->l_sigstk.ss_flags &= ~SS_ONSTACK;
  246
+	mutex_exit(p->p_lock);
  247
+	return (0);
  248
+}
  249
+
  250
+// TODO: do we need any validation here?
  251
+int
  252
+cpu_mcontext_validate(struct lwp *l, const mcontext_t *mcp)
  253
+{
  254
+	return 0;
  255
+}
1  sys/arch/milkymist/include/types.h
@@ -6,6 +6,5 @@
6 6
 #include <lm32/types.h>
7 7
 
8 8
 #define	__GENERIC_SOFT_INTERRUPTS_ALL_LEVELS
9  
-#define	__HAVE_MM_MD_READWRITE
10 9
 
11 10
 #endif
77  sys/arch/milkymist/include/userret.h
... ...
@@ -0,0 +1,77 @@
  1
+/*-
  2
+ * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
  3
+ * All rights reserved.
  4
+ *
  5
+ * This code is derived from software contributed to The NetBSD Foundation
  6
+ * by Charles M. Hannum.
  7
+ *
  8
+ * Redistribution and use in source and binary forms, with or without
  9
+ * modification, are permitted provided that the following conditions
  10
+ * are met:
  11
+ * 1. Redistributions of source code must retain the above copyright
  12
+ *    notice, this list of conditions and the following disclaimer.
  13
+ * 2. Redistributions in binary form must reproduce the above copyright
  14
+ *    notice, this list of conditions and the following disclaimer in the
  15
+ *    documentation and/or other materials provided with the distribution.
  16
+ *
  17
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  18
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  19
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  21
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  24
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  25
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  27
+ * POSSIBILITY OF SUCH DAMAGE.
  28
+ */
  29
+
  30
+/*-
  31
+ * Copyright (c) 1990 The Regents of the University of California.
  32
+ * All rights reserved.
  33
+ *
  34
+ * This code is derived from software contributed to Berkeley by
  35
+ * William Jolitz.
  36
+ *
  37
+ * Redistribution and use in source and binary forms, with or without
  38
+ * modification, are permitted provided that the following conditions
  39
+ * are met:
  40
+ * 1. Redistributions of source code must retain the above copyright
  41
+ *    notice, this list of conditions and the following disclaimer.
  42
+ * 2. Redistributions in binary form must reproduce the above copyright
  43
+ *    notice, this list of conditions and the following disclaimer in the
  44
+ *    documentation and/or other materials provided with the distribution.
  45
+ * 3. Neither the name of the University nor the names of its contributors
  46
+ *    may be used to endorse or promote products derived from this software
  47
+ *    without specific prior written permission.
  48
+ *
  49
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  50
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  52
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  53
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  55
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  56
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  57
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  58
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59
+ * SUCH DAMAGE.
  60
+ *
  61
+ */
  62
+
  63
+#include <sys/userret.h>
  64
+
  65
+static __inline void userret(struct lwp *);
  66
+
  67
+/*
  68
+ * Define the code needed before returning to user mode, for
  69
+ * trap and syscall.
  70
+ */
  71
+static __inline void
  72
+userret(struct lwp *l)
  73
+{
  74
+
  75
+	/* Invoke MI userret code */
  76
+	mi_userret(l);
  77
+}

No commit comments for this range

Something went wrong with that request. Please try again.