xref: /netbsd-src/sys/arch/usermode/target/arm/cpu_arm.c (revision df3dd44824305f5aaedf730a010facfe570c00e2)
1*df3dd448Sandvar /* $NetBSD: cpu_arm.c,v 1.3 2022/01/01 21:07:14 andvar Exp $ */
2ccb870baSjmcneill 
3ccb870baSjmcneill /*-
4ccb870baSjmcneill  * Copyright (c) 2011 Reinoud Zandijk <reinoud@netbsd.org>
5ccb870baSjmcneill  * Copyright (c) 2007, 2013 Jared D. McNeill <jmcneill@invisible.ca>
6ccb870baSjmcneill  * All rights reserved.
7ccb870baSjmcneill  *
8ccb870baSjmcneill  * Redistribution and use in source and binary forms, with or without
9ccb870baSjmcneill  * modification, are permitted provided that the following conditions
10ccb870baSjmcneill  * are met:
11ccb870baSjmcneill  * 1. Redistributions of source code must retain the above copyright
12ccb870baSjmcneill  *    notice, this list of conditions and the following disclaimer.
13ccb870baSjmcneill  * 2. Redistributions in binary form must reproduce the above copyright
14ccb870baSjmcneill  *    notice, this list of conditions and the following disclaimer in the
15ccb870baSjmcneill  *    documentation and/or other materials provided with the distribution.
16ccb870baSjmcneill  *
17ccb870baSjmcneill  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18ccb870baSjmcneill  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19ccb870baSjmcneill  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20ccb870baSjmcneill  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21ccb870baSjmcneill  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22ccb870baSjmcneill  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23ccb870baSjmcneill  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24ccb870baSjmcneill  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25ccb870baSjmcneill  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26ccb870baSjmcneill  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27ccb870baSjmcneill  * POSSIBILITY OF SUCH DAMAGE.
28ccb870baSjmcneill  */
29ccb870baSjmcneill 
30ccb870baSjmcneill /*
31ccb870baSjmcneill  * Note that this machdep.c uses the `dummy' mcontext_t defined for usermode.
32*df3dd448Sandvar  * This is basically a blob of PAGE_SIZE big. We might want to switch over to
33ccb870baSjmcneill  * non-generic mcontext_t's one day, but will this break non-NetBSD hosts?
34ccb870baSjmcneill  */
35ccb870baSjmcneill 
36ccb870baSjmcneill #include <sys/cdefs.h>
37*df3dd448Sandvar __KERNEL_RCSID(0, "$NetBSD: cpu_arm.c,v 1.3 2022/01/01 21:07:14 andvar Exp $");
38ccb870baSjmcneill 
39ccb870baSjmcneill #include <sys/types.h>
40ccb870baSjmcneill #include <sys/systm.h>
41ccb870baSjmcneill #include <sys/param.h>
42ccb870baSjmcneill #include <sys/time.h>
43ccb870baSjmcneill #include <sys/exec.h>
44ccb870baSjmcneill #include <sys/buf.h>
45ccb870baSjmcneill #include <sys/boot_flag.h>
46ccb870baSjmcneill #include <sys/ucontext.h>
47ccb870baSjmcneill #include <sys/utsname.h>
48ccb870baSjmcneill #include <machine/pcb.h>
49ccb870baSjmcneill #include <machine/psl.h>
50ccb870baSjmcneill 
51ccb870baSjmcneill #include <uvm/uvm_extern.h>
52ccb870baSjmcneill #include <uvm/uvm_page.h>
53ccb870baSjmcneill 
54ccb870baSjmcneill #include <dev/mm.h>
55ccb870baSjmcneill #include <machine/machdep.h>
56ccb870baSjmcneill #include <machine/thunk.h>
57ccb870baSjmcneill 
58ccb870baSjmcneill #include "opt_exec.h"
59ccb870baSjmcneill 
60ccb870baSjmcneill /* from sys/arch/arm/include/frame.h : KEEP IN SYNC */
61ccb870baSjmcneill struct sigframe_siginfo {
62ccb870baSjmcneill 	siginfo_t	sf_si;		/* actual saved siginfo */
63ccb870baSjmcneill 	ucontext_t	sf_uc;		/* actual saved ucontext */
64ccb870baSjmcneill };
65ccb870baSjmcneill 
66ccb870baSjmcneill void
sendsig_siginfo(const ksiginfo_t * ksi,const sigset_t * mask)67ccb870baSjmcneill sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
68ccb870baSjmcneill {
69ccb870baSjmcneill 	panic("sendsig_siginfo not implemented");
70ccb870baSjmcneill }
71ccb870baSjmcneill 
72ccb870baSjmcneill void
setregs(struct lwp * l,struct exec_package * pack,vaddr_t stack)73ccb870baSjmcneill setregs(struct lwp *l, struct exec_package *pack, vaddr_t stack)
74ccb870baSjmcneill {
75ccb870baSjmcneill 	panic("sendsig_siginfo not implemented");
76ccb870baSjmcneill }
77ccb870baSjmcneill 
78ccb870baSjmcneill void
md_syscall_get_syscallnumber(ucontext_t * ucp,uint32_t * code)79ccb870baSjmcneill md_syscall_get_syscallnumber(ucontext_t *ucp, uint32_t *code)
80ccb870baSjmcneill {
81ccb870baSjmcneill 	panic("md_syscall_get_syscallnumber not implemented");
82ccb870baSjmcneill }
83ccb870baSjmcneill 
84ccb870baSjmcneill int
md_syscall_getargs(lwp_t * l,ucontext_t * ucp,int nargs,int argsize,register_t * args)85ccb870baSjmcneill md_syscall_getargs(lwp_t *l, ucontext_t *ucp, int nargs, int argsize,
86ccb870baSjmcneill 	register_t *args)
87ccb870baSjmcneill {
88ccb870baSjmcneill 	panic("md_syscall_getargs not implemented");
89ccb870baSjmcneill 	return 0;
90ccb870baSjmcneill }
91ccb870baSjmcneill 
92ccb870baSjmcneill void
md_syscall_set_returnargs(lwp_t * l,ucontext_t * ucp,int error,register_t * rval)93ccb870baSjmcneill md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp,
94ccb870baSjmcneill 	int error, register_t *rval)
95ccb870baSjmcneill {
96ccb870baSjmcneill 	panic("md_syscall_set_returnargs not implemented");
97ccb870baSjmcneill }
98ccb870baSjmcneill 
99ccb870baSjmcneill register_t
md_get_pc(ucontext_t * ucp)100ccb870baSjmcneill md_get_pc(ucontext_t *ucp)
101ccb870baSjmcneill {
1023bd31d9dSjmcneill 	unsigned int *reg = (unsigned int *)&ucp->uc_mcontext;
1033bd31d9dSjmcneill 	return reg[15];
104ccb870baSjmcneill }
105ccb870baSjmcneill 
106ccb870baSjmcneill register_t
md_get_sp(ucontext_t * ucp)107ccb870baSjmcneill md_get_sp(ucontext_t *ucp)
108ccb870baSjmcneill {
1093bd31d9dSjmcneill 	unsigned int *reg = (unsigned int *)&ucp->uc_mcontext;
1103bd31d9dSjmcneill 	return reg[13];
111ccb870baSjmcneill }
112ccb870baSjmcneill 
113ccb870baSjmcneill int
md_syscall_check_opcode(ucontext_t * ucp)114ccb870baSjmcneill md_syscall_check_opcode(ucontext_t *ucp)
115ccb870baSjmcneill {
116ccb870baSjmcneill 	panic("md_syscall_check_opcode not implemented");
117ccb870baSjmcneill 	return 0;
118ccb870baSjmcneill }
119ccb870baSjmcneill 
120ccb870baSjmcneill void
md_syscall_get_opcode(ucontext_t * ucp,uint32_t * opcode)121ccb870baSjmcneill md_syscall_get_opcode(ucontext_t *ucp, uint32_t *opcode)
122ccb870baSjmcneill {
123ccb870baSjmcneill 	panic("md_syscall_get_opcode not implemented");
124ccb870baSjmcneill }
125ccb870baSjmcneill 
126ccb870baSjmcneill void
md_syscall_inc_pc(ucontext_t * ucp,uint32_t opcode)127ccb870baSjmcneill md_syscall_inc_pc(ucontext_t *ucp, uint32_t opcode)
128ccb870baSjmcneill {
129ccb870baSjmcneill 	panic("md_syscall_inc_pc not implemented");
130ccb870baSjmcneill }
131ccb870baSjmcneill 
132ccb870baSjmcneill void
md_syscall_dec_pc(ucontext_t * ucp,uint32_t opcode)133ccb870baSjmcneill md_syscall_dec_pc(ucontext_t *ucp, uint32_t opcode)
134ccb870baSjmcneill {
135ccb870baSjmcneill 	panic("md_syscall_dec_pc not implemented");
136ccb870baSjmcneill }
137ccb870baSjmcneill 
138