xref: /netbsd-src/sys/compat/linux/arch/arm/linux_sys_machdep.c (revision ac344355818cabb30d36c6cae34daa86658a1d2e)
1*ac344355Sskrll /*	$NetBSD: linux_sys_machdep.c,v 1.15 2018/01/24 09:04:45 skrll Exp $	*/
28a3c27fbSbjh21 
38a3c27fbSbjh21 /*-
48a3c27fbSbjh21  * Copyright (c) 2002 Ben Harris
58a3c27fbSbjh21  * All rights reserved.
68a3c27fbSbjh21  *
78a3c27fbSbjh21  * Redistribution and use in source and binary forms, with or without
88a3c27fbSbjh21  * modification, are permitted provided that the following conditions
98a3c27fbSbjh21  * are met:
108a3c27fbSbjh21  * 1. Redistributions of source code must retain the above copyright
118a3c27fbSbjh21  *    notice, this list of conditions and the following disclaimer.
128a3c27fbSbjh21  * 2. Redistributions in binary form must reproduce the above copyright
138a3c27fbSbjh21  *    notice, this list of conditions and the following disclaimer in the
148a3c27fbSbjh21  *    documentation and/or other materials provided with the distribution.
158a3c27fbSbjh21  * 3. The name of the author may not be used to endorse or promote products
168a3c27fbSbjh21  *    derived from this software without specific prior written permission.
178a3c27fbSbjh21  *
188a3c27fbSbjh21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
198a3c27fbSbjh21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
208a3c27fbSbjh21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
218a3c27fbSbjh21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
228a3c27fbSbjh21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
238a3c27fbSbjh21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
248a3c27fbSbjh21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
258a3c27fbSbjh21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
268a3c27fbSbjh21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
278a3c27fbSbjh21  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
288a3c27fbSbjh21  */
298a3c27fbSbjh21 
308a3c27fbSbjh21 #include <sys/param.h>
318a3c27fbSbjh21 
32*ac344355Sskrll __KERNEL_RCSID(0, "$NetBSD: linux_sys_machdep.c,v 1.15 2018/01/24 09:04:45 skrll Exp $");
338a3c27fbSbjh21 
348a3c27fbSbjh21 #include <sys/systm.h>
35f5ff7e48Syamt #include <sys/signalvar.h>
3633fa5ccbSchs #include <sys/lwp.h>
3733fa5ccbSchs #include <sys/cpu.h>
388a3c27fbSbjh21 
398a3c27fbSbjh21 #include <compat/linux/common/linux_types.h>
408a3c27fbSbjh21 #include <compat/linux/common/linux_signal.h>
418a3c27fbSbjh21 #include <compat/linux/common/linux_siginfo.h>
428a3c27fbSbjh21 #include <compat/linux/common/linux_machdep.h>
438a3c27fbSbjh21 #include <compat/linux/linux_syscallargs.h>
448a3c27fbSbjh21 
458a3c27fbSbjh21 #include <arm/cpufunc.h>
468a3c27fbSbjh21 
478a3c27fbSbjh21 int
linux_sys_breakpoint(struct lwp * l,const void * v,register_t * retval)487e2790cfSdsl linux_sys_breakpoint(struct lwp *l, const void *v, register_t *retval)
498c36606fSbjh21 {
500dbe439eSmatt 	ksiginfo_t ksi;
518c36606fSbjh21 
520dbe439eSmatt 	KSI_INIT_TRAP(&ksi);
530dbe439eSmatt 	ksi.ksi_signo = SIGTRAP;
540dbe439eSmatt 	ksi.ksi_code = TRAP_BRKPT;
550dbe439eSmatt 	trapsignal(l, &ksi);
568c36606fSbjh21 	return ERESTART; /* Leave PC pointing back at the breakpoint. */
578c36606fSbjh21 }
588c36606fSbjh21 
598c36606fSbjh21 int
linux_sys_cacheflush(struct lwp * l,const struct linux_sys_cacheflush_args * uap,register_t * retval)607e2790cfSdsl linux_sys_cacheflush(struct lwp *l, const struct linux_sys_cacheflush_args *uap, register_t *retval)
618a3c27fbSbjh21 {
627e2790cfSdsl 	/* {
638a3c27fbSbjh21 		syscallarg(uintptr_t) from;
648a3c27fbSbjh21 		syscallarg(uintptr_t) to;
6533fa5ccbSchs 		syscallarg(int) flags;
667e2790cfSdsl 	} */
678a3c27fbSbjh21 
68043db35fSbjh21 	cpu_icache_sync_range(SCARG(uap, from),
698a3c27fbSbjh21 	    SCARG(uap, to) - SCARG(uap, from) + 1);
708a3c27fbSbjh21 	*retval = 0;
718a3c27fbSbjh21 	return 0;
728a3c27fbSbjh21 }
7333fa5ccbSchs 
7433fa5ccbSchs int
linux_sys_set_tls(struct lwp * l,const struct linux_sys_set_tls_args * uap,register_t * retval)7533fa5ccbSchs linux_sys_set_tls(struct lwp *l, const struct linux_sys_set_tls_args *uap, register_t *retval)
7633fa5ccbSchs {
7733fa5ccbSchs 
7833fa5ccbSchs 	return lwp_setprivate(l, SCARG(uap, tls));
7933fa5ccbSchs }
80