Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: fallen/NetBSD
base: 257242bc2a09
...
head fork: fallen/NetBSD
compare: daf8573229bd
  • 5 commits
  • 13 files changed
  • 0 commit comments
  • 1 contributor
3  sys/arch/lm32/conf/files.lm32
View
@@ -6,6 +6,9 @@ file arch/lm32/lm32/cpu.c
file arch/lm32/lm32/syscall.c
file arch/lm32/lm32/process_machdep.c
file arch/lm32/lm32/interrupt.c
+file arch/lm32/lm32/vm_machdep.c
+file arch/lm32/lm32/procfs_machdep.c
+file arch/lm32/lm32/sig_machdep.c
file arch/lm32/lm32/lock_stubs.S
file arch/lm32/lm32/locore_subr.S
file dev/cons.c
7 sys/arch/lm32/include/cpu.h
View
@@ -154,6 +154,7 @@ struct cpu_info {
char *ci_doubleflt_stack;
char *ci_ddbipi_stack;
volatile int ci_want_resched;
+ int ci_idepth;
};
@@ -219,7 +220,7 @@ do { \
* Notify the LWP l that it has a signal pending, process as soon as
* possible.
*/
-extern void cpu_signotify(struct lwp *);
+#define cpu_signotify(l) aston(l)
/*
* We need a machine-independent name for this.
@@ -296,4 +297,8 @@ struct disklist {
int ni_biosmatches[MAX_BIOSDISKS]; /* indices in dl_biosdisks */
} dl_nativedisks[1]; /* actually longer */
};
+
+#define LM32_TF_R1(tf) tf->tf_regs.r_regs[R1]
+#define LM32_TF_R2(tf) tf->tf_regs.r_regs[R2]
+
#endif /* !_LM32_CPU_H_ */
1  sys/arch/lm32/include/frame.h
View
@@ -87,6 +87,7 @@ struct sigframe_siginfo {
struct trapframe {
struct reg tf_regs;
+ int tf_pc;
};
void *getframe(struct lwp *, int, int *);
5 sys/arch/lm32/include/mcontext.h
View
@@ -49,7 +49,7 @@
/*
* General register state
*/
-#define _NGREG 29
+#define _NGREG 32
typedef int __greg_t;
typedef __greg_t __gregset_t[_NGREG];
@@ -82,6 +82,9 @@ typedef __greg_t __gregset_t[_NGREG];
#define _REG_FP 26
#define _REG_SP 27
#define _REG_RA 28
+#define _REG_EA 29
+#define _REG_BA 30
+#define _REG_PC 31
typedef struct {
__gregset_t __gregs;
3  sys/arch/lm32/include/proc.h
View
@@ -55,9 +55,6 @@ struct mdproc {
.md_flags = 0, \
.md_utf = { \
.tf_regs = { .r_regs = { 0 }, \
- .r_ra = 0, \
- .r_ea = 0, \
- .r_ba = 0, \
.r_pc = 0} } \
}
#endif /* _KERNEL */
20 sys/arch/lm32/include/reg.h
View
@@ -1,8 +1,7 @@
-/* $NetBSD: reg.h,v 1.18 2011/02/08 20:20:16 rmind Exp $ */
-
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
+ * Copyright (c) 2013 Yann Sionneau <yann.sionneau@gmail.com>
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
@@ -45,10 +44,7 @@
* Register set accessible via /proc/$pid/reg and ptrace()
*/
struct reg {
- int r_regs[28]; /* R1-R28 , R0 is always 0 */
- int r_ra;
- int r_ea;
- int r_ba;
+ int r_regs[31]; /* R1-R31 , R0 is always 0 */
int r_pc;
};
@@ -83,12 +79,18 @@ struct reg {
#define R24 (23)
#define R25 (24)
#define R26 (25)
+#define R_GP (R26)
#define R27 (26)
+#define R_FP R27
#define R28 (27)
+#define R_SP R28
-#define RA (28)
-#define EA (29)
-#define BA (30)
+#define R29 (28)
+#define R_RA R29
+#define R30 (29)
+#define R_EA R30
+#define R31 (30)
+#define R_BA R31
#ifdef _KERNEL
1  sys/arch/lm32/include/types.h
View
@@ -91,7 +91,6 @@ typedef volatile unsigned char __cpu_simple_lock_t;
#define __HAVE_OLD_DISKLABEL
#define __HAVE_CPU_LWP_SETPRIVATE
#define __HAVE_INTR_CONTROL
-#define __HAVE_MM_MD_OPEN
#define __HAVE___LWP_GETPRIVATE_FAST
#if defined(_KERNEL)
24 sys/arch/lm32/lm32/procfs_machdep.c
View
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2013 Yann Sionneau <yann.sionneau@gmail.com>
+ */
+
+#include <sys/cdefs.h>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+#include <miscfs/procfs/procfs.h>
+
+
+/*
+ * Linux-style /proc/cpuinfo.
+ * Only used when procfs is mounted with -o linux.
+ */
+int
+procfs_getcpuinfstr(char *buf, int *len)
+{
+ *len = 0;
+
+ return 0;
+}
115 sys/arch/lm32/lm32/sig_machdep.c
View
@@ -0,0 +1,115 @@
+/*-
+ * Copyright (C) 2013 Yann Sionneau <yann.sionneau@gmail.com>
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
+
+#include <sys/param.h>
+#include <sys/cpu.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <lm32/frame.h>
+#include <lm32/reg.h>
+
+void *
+getframe(struct lwp *l, int sig, int *onstack)
+{
+ struct proc * const p = l->l_proc;
+ struct trapframe * const tf = &l->l_md.md_utf;
+
+ /* Do we need to jump onto the signal stack? */
+ *onstack = (l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0
+ && (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
+ if (*onstack)
+ return (char *)l->l_sigstk.ss_sp + l->l_sigstk.ss_size;
+ return (void *)(intptr_t)tf->tf_regs.r_regs[R_SP];
+}
+
+/*
+ * Send a signal to process.
+ */
+void
+sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
+{
+ struct lwp * const l = curlwp;
+ struct proc * const p = l->l_proc;
+ struct sigacts * const sa = p->p_sigacts;
+ struct trapframe * const tf = &l->l_md.md_utf;
+ int onstack, error;
+ const int signo = ksi->ksi_signo;
+ struct sigframe_siginfo *sf = getframe(l, signo, &onstack);
+ struct sigframe_siginfo ksf;
+ const sig_t catcher = SIGACTION(p, signo).sa_handler;
+
+ /* allocate a sigframe_siginfo structure on the stack */
+ sf--;
+
+ ksf.sf_si._info = ksi->ksi_info;
+ ksf.sf_uc.uc_flags = _UC_SIGMASK
+ | (l->l_sigstk.ss_flags & SS_ONSTACK ? _UC_SETSTACK : _UC_CLRSTACK);
+ ksf.sf_uc.uc_sigmask = *mask;
+ ksf.sf_uc.uc_link = l->l_ctxlink;
+ memset(&ksf.sf_uc.uc_stack, 0, sizeof(ksf.sf_uc.uc_stack));
+ sendsig_reset(l, signo);
+
+ mutex_exit(p->p_lock);
+ cpu_getmcontext(l, &ksf.sf_uc.uc_mcontext, &ksf.sf_uc.uc_flags);
+ error = copyout(&ksf, sf, sizeof(ksf));
+ mutex_enter(p->p_lock);
+
+ if (error != 0) {
+ /*
+ * Process has trashed its stack; give it an illegal
+ * instruction to halt it in its tracks.
+ */
+ sigexit(l, SIGILL);
+ /* NOTREACHED */
+ }
+
+ /*
+ * Set up the registers to directly invoke the signal
+ * handler. The return address will be set up to point
+ * to the signal trampoline to bounce us back.
+ */
+ tf->tf_regs.r_regs[R1] = signo;
+ tf->tf_regs.r_regs[R2] = (intptr_t)&sf->sf_si;
+ tf->tf_regs.r_regs[R3] = (intptr_t)&sf->sf_uc;
+
+ tf->tf_pc = (intptr_t)catcher;
+ tf->tf_regs.r_regs[R_SP] = (intptr_t)sf;
+ tf->tf_regs.r_regs[R_RA] = (intptr_t)sa->sa_sigdesc[signo].sd_tramp;
+
+ /* Remember that we're now on the signal stack. */
+ if (onstack)
+ l->l_sigstk.ss_flags |= SS_ONSTACK;
+}
89 sys/arch/lm32/lm32/syscall.c
View
@@ -6,12 +6,16 @@
#include <sys/systm.h>
#include <sys/syscallvar.h>
#include <sys/syscall.h>
-
+#include <sys/syscall_stats.h>
#include <uvm/uvm_extern.h>
#include <lm32/frame.h>
#include <lm32/pcb.h>
#include <lm32/reg.h>
+#include <machine/userret.h>
+
+void syscall_intern(struct proc *);
+static void syscall(struct trapframe *);
void
child_return(void *arg)
@@ -22,3 +26,86 @@ child_return(void *arg)
tf->tf_regs.r_regs[R1] = 0; // set return value to 0 as the result of fork() for the child
ktrsysret(SYS_fork, 0, 0);
}
+
+/*
+ * Process the tail end of a posix_spawn() for the child.
+ */
+void
+cpu_spawn_return(struct lwp *l)
+{
+ userret(l);
+}
+
+void
+syscall_intern(struct proc *p)
+{
+
+ p->p_md.md_syscall = syscall;
+}
+
+/*
+ * syscall(frame):
+ * System call request from POSIX system call gate interface to kernel.
+ * Like trap(), argument is call by reference.
+ */
+static void
+syscall(struct trapframe *frame)
+{
+ const struct sysent *callp;
+ struct proc *p;
+ struct lwp *l;
+ int error;
+ register_t code, rval[2];
+ register_t args[2 + SYS_MAXSYSARGS];
+
+ l = curlwp;
+ p = l->l_proc;
+ LWP_CACHE_CREDS(l, p);
+
+ code = LM32_TF_R1(frame) & (SYS_NSYSENT - 1);
+ callp = p->p_emul->e_sysent + code;
+
+ SYSCALL_COUNT(syscall_counts, code);
+ SYSCALL_TIME_SYS_ENTRY(l, syscall_times, code);
+
+ if (callp->sy_argsize) {
+ error = copyin((char *)frame->tf_regs.r_regs[R_SP] + sizeof(int), args,
+ callp->sy_argsize);
+ if (__predict_false(error != 0))
+ goto bad;
+ }
+
+ if (!__predict_false(p->p_trace_enabled)
+ || __predict_false(callp->sy_flags & SYCALL_INDIRECT)
+ || (error = trace_enter(code, args, callp->sy_narg)) == 0) {
+ rval[0] = 0;
+ rval[1] = 0;
+ error = sy_call(callp, l, args, rval);
+ }
+
+ if (__predict_false(p->p_trace_enabled)
+ && !__predict_false(callp->sy_flags & SYCALL_INDIRECT)) {
+ trace_exit(code, rval, error);
+ }
+
+ if (__predict_true(error == 0)) {
+ LM32_TF_R1(frame) = rval[0];
+ LM32_TF_R2(frame) = rval[1];
+ } else {
+ switch (error) {
+ case ERESTART:
+ /* nothing to do */
+ break;
+ case EJUSTRETURN:
+ /* nothing to do */
+ break;
+ default:
+ bad:
+ LM32_TF_R1(frame) = error;
+ break;
+ }
+ }
+
+ SYSCALL_TIME_SYS_EXIT(l);
+ userret(l);
+}
255 sys/arch/lm32/lm32/vm_machdep.c
View
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 1999-2004 Michael Shalayeff
+ * Copyright (c) 2013 Yann Sionneau <yann.sionneau@gmail.com>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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.
+ */
+
+#include <sys/cdefs.h>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/signalvar.h>
+#include <sys/malloc.h>
+#include <sys/buf.h>
+#include <sys/vnode.h>
+#include <sys/ptrace.h>
+#include <sys/exec.h>
+#include <sys/core.h>
+#include <sys/pool.h>
+#include <sys/cpu.h>
+#include <sys/kcore.h>
+#include <sys/kauth.h>
+#include <sys/ras.h>
+#include <dev/mm.h>
+
+#include <machine/pmap.h>
+#include <machine/pcb.h>
+
+#include <uvm/uvm.h>
+
+// TODO adapt the following function for lm32 pmap subsystem
+static inline void
+cpu_activate_pcb(struct lwp *l)
+{
+}
+
+
+// TODO adapt the following function for lm32 pmap subsystem
+void
+cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
+ void (*func)(void *), void *arg)
+{
+}
+
+/*
+ * Map an IO request into kernel virtual address space.
+ */
+// TODO implement vmapbuf
+int
+vmapbuf(struct buf *bp, vsize_t len)
+{
+ return 0;
+}
+
+/*
+ * Unmap IO request from the kernel virtual address space.
+ */
+// TODO implement vunmapbuf
+void
+vunmapbuf(struct buf *bp, vsize_t len)
+{
+}
+
+// TODO implement cpu_lwp_setprivate
+int
+cpu_lwp_setprivate(lwp_t *l, void *addr)
+{
+ return 0;
+}
+
+/*
+ * cpu_lwp_free is called from exit() to let machine-dependent
+ * code free machine-dependent resources. Note that this routine
+ * must not block.
+ */
+void
+cpu_lwp_free(struct lwp *l, int proc)
+{
+}
+
+/*
+ * cpu_lwp_free2 is called when an LWP is being reaped.
+ * This routine may block.
+ */
+void
+cpu_lwp_free2(struct lwp *l)
+{
+}
+
+bool
+cpu_intr_p(void)
+{
+ int idepth;
+
+ kpreempt_disable();
+ idepth = curcpu()->ci_idepth;
+ kpreempt_enable();
+ return (idepth >= 0);
+}
+
+
+/*
+ * mm_md_physacc: check if given pa is accessible.
+ */
+
+// TODO: this is copy paste from i386, must be adapted for lm32
+int
+mm_md_physacc(paddr_t pa, vm_prot_t prot)
+{
+ extern phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
+ extern int mem_cluster_cnt;
+ int i;
+
+ for (i = 0; i < mem_cluster_cnt; i++) {
+ const phys_ram_seg_t *seg = &mem_clusters[i];
+ paddr_t lstart = seg->start;
+
+ if (lstart <= pa && pa - lstart <= seg->size) {
+ return 0;
+ }
+ }
+ return kauth_authorize_machdep(kauth_cred_get(),
+ KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL);
+}
+
+void
+cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags)
+{
+ const struct trapframe *tf = &l->l_md.md_utf;
+ __greg_t *gr = mcp->__gregs;
+ __greg_t ras_pc;
+
+ gr[_REG_R1] = tf->tf_regs.r_regs[R1];
+ gr[_REG_R2] = tf->tf_regs.r_regs[R2];
+ gr[_REG_R3] = tf->tf_regs.r_regs[R3];
+ gr[_REG_R4] = tf->tf_regs.r_regs[R4];
+ gr[_REG_R5] = tf->tf_regs.r_regs[R5];
+ gr[_REG_R6] = tf->tf_regs.r_regs[R6];
+ gr[_REG_R7] = tf->tf_regs.r_regs[R7];
+ gr[_REG_R8] = tf->tf_regs.r_regs[R8];
+ gr[_REG_R9] = tf->tf_regs.r_regs[R9];
+ gr[_REG_R10] = tf->tf_regs.r_regs[R10];
+ gr[_REG_R11] = tf->tf_regs.r_regs[R11];
+ gr[_REG_R12] = tf->tf_regs.r_regs[R12];
+ gr[_REG_R13] = tf->tf_regs.r_regs[R13];
+ gr[_REG_R14] = tf->tf_regs.r_regs[R14];
+ gr[_REG_R15] = tf->tf_regs.r_regs[R15];
+ gr[_REG_R16] = tf->tf_regs.r_regs[R16];
+ gr[_REG_R17] = tf->tf_regs.r_regs[R17];
+ gr[_REG_R18] = tf->tf_regs.r_regs[R18];
+ gr[_REG_R19] = tf->tf_regs.r_regs[R19];
+ gr[_REG_R20] = tf->tf_regs.r_regs[R20];
+ gr[_REG_R21] = tf->tf_regs.r_regs[R21];
+ gr[_REG_R22] = tf->tf_regs.r_regs[R22];
+ gr[_REG_R23] = tf->tf_regs.r_regs[R23];
+ gr[_REG_R24] = tf->tf_regs.r_regs[R24];
+ gr[_REG_R25] = tf->tf_regs.r_regs[R25];
+ gr[_REG_GP] = tf->tf_regs.r_regs[R_GP];
+ gr[_REG_FP] = tf->tf_regs.r_regs[R_FP];
+ gr[_REG_SP] = tf->tf_regs.r_regs[R_SP];
+ gr[_REG_RA] = tf->tf_regs.r_regs[R_RA];
+ gr[_REG_EA] = tf->tf_regs.r_regs[R_EA];
+ gr[_REG_BA] = tf->tf_regs.r_regs[R_BA];
+
+ gr[_REG_PC] = tf->tf_pc;
+
+ if ((ras_pc = (__greg_t)ras_lookup(l->l_proc,
+ (void *) gr[_REG_PC])) != -1)
+ gr[_REG_PC] = ras_pc;
+
+}
+
+int
+cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags)
+{
+ struct trapframe *tf = &l->l_md.md_utf;
+ const __greg_t *gr = mcp->__gregs;
+ struct proc *p = l->l_proc;
+ int error;
+
+ /* Restore register context, if any. */
+ if ((flags & _UC_CPU) != 0) {
+ error = cpu_mcontext_validate(l, mcp);
+ if (error)
+ return error;
+
+ tf->tf_regs.r_regs[R1] = gr[_REG_R1];
+ tf->tf_regs.r_regs[R2] = gr[_REG_R2];
+ tf->tf_regs.r_regs[R3] = gr[_REG_R3];
+ tf->tf_regs.r_regs[R4] = gr[_REG_R4];
+ tf->tf_regs.r_regs[R5] = gr[_REG_R5];
+ tf->tf_regs.r_regs[R6] = gr[_REG_R6];
+ tf->tf_regs.r_regs[R7] = gr[_REG_R7];
+ tf->tf_regs.r_regs[R8] = gr[_REG_R8];
+ tf->tf_regs.r_regs[R9] = gr[_REG_R9];
+ tf->tf_regs.r_regs[R10] = gr[_REG_R10];
+ tf->tf_regs.r_regs[R11] = gr[_REG_R11];
+ tf->tf_regs.r_regs[R12] = gr[_REG_R12];
+ tf->tf_regs.r_regs[R13] = gr[_REG_R13];
+ tf->tf_regs.r_regs[R14] = gr[_REG_R14];
+ tf->tf_regs.r_regs[R15] = gr[_REG_R15];
+ tf->tf_regs.r_regs[R16] = gr[_REG_R16];
+ tf->tf_regs.r_regs[R17] = gr[_REG_R17];
+ tf->tf_regs.r_regs[R18] = gr[_REG_R18];
+ tf->tf_regs.r_regs[R19] = gr[_REG_R19];
+ tf->tf_regs.r_regs[R20] = gr[_REG_R20];
+ tf->tf_regs.r_regs[R21] = gr[_REG_R21];
+ tf->tf_regs.r_regs[R22] = gr[_REG_R22];
+ tf->tf_regs.r_regs[R23] = gr[_REG_R23];
+ tf->tf_regs.r_regs[R24] = gr[_REG_R24];
+ tf->tf_regs.r_regs[R25] = gr[_REG_R25];
+ tf->tf_regs.r_regs[R_GP] = gr[_REG_GP];
+ tf->tf_regs.r_regs[R_FP] = gr[_REG_FP];
+ tf->tf_regs.r_regs[R_SP] = gr[_REG_SP];
+ tf->tf_regs.r_regs[R_RA] = gr[_REG_RA];
+ tf->tf_regs.r_regs[R_EA] = gr[_REG_EA];
+ tf->tf_regs.r_regs[R_BA] = gr[_REG_BA];
+ }
+
+ mutex_enter(p->p_lock);
+ if (flags & _UC_SETSTACK)
+ l->l_sigstk.ss_flags |= SS_ONSTACK;
+ if (flags & _UC_CLRSTACK)
+ l->l_sigstk.ss_flags &= ~SS_ONSTACK;
+ mutex_exit(p->p_lock);
+ return (0);
+}
+
+// TODO: do we need any validation here?
+int
+cpu_mcontext_validate(struct lwp *l, const mcontext_t *mcp)
+{
+ return 0;
+}
1  sys/arch/milkymist/include/types.h
View
@@ -6,6 +6,5 @@
#include <lm32/types.h>
#define __GENERIC_SOFT_INTERRUPTS_ALL_LEVELS
-#define __HAVE_MM_MD_READWRITE
#endif
77 sys/arch/milkymist/include/userret.h
View
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ *
+ */
+
+#include <sys/userret.h>
+
+static __inline void userret(struct lwp *);
+
+/*
+ * Define the code needed before returning to user mode, for
+ * trap and syscall.
+ */
+static __inline void
+userret(struct lwp *l)
+{
+
+ /* Invoke MI userret code */
+ mi_userret(l);
+}

No commit comments for this range

Something went wrong with that request. Please try again.