16fc729afSOlivier Houchard /*- 26fc729afSOlivier Houchard * Copyright (c) 1990 The Regents of the University of California. 36fc729afSOlivier Houchard * All rights reserved. 46fc729afSOlivier Houchard * 56fc729afSOlivier Houchard * Redistribution and use in source and binary forms, with or without 66fc729afSOlivier Houchard * modification, are permitted provided that the following conditions 76fc729afSOlivier Houchard * are met: 86fc729afSOlivier Houchard * 1. Redistributions of source code must retain the above copyright 96fc729afSOlivier Houchard * notice, this list of conditions and the following disclaimer. 106fc729afSOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright 116fc729afSOlivier Houchard * notice, this list of conditions and the following disclaimer in the 126fc729afSOlivier Houchard * documentation and/or other materials provided with the distribution. 136fc729afSOlivier Houchard * 3. All advertising materials mentioning features or use of this software 146fc729afSOlivier Houchard * must display the following acknowledgement: 156fc729afSOlivier Houchard * This product includes software developed by the University of 166fc729afSOlivier Houchard * California, Berkeley and its contributors. 176fc729afSOlivier Houchard * 4. Neither the name of the University nor the names of its contributors 186fc729afSOlivier Houchard * may be used to endorse or promote products derived from this software 196fc729afSOlivier Houchard * without specific prior written permission. 206fc729afSOlivier Houchard * 216fc729afSOlivier Houchard * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 226fc729afSOlivier Houchard * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 236fc729afSOlivier Houchard * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 246fc729afSOlivier Houchard * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 256fc729afSOlivier Houchard * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 266fc729afSOlivier Houchard * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 276fc729afSOlivier Houchard * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 286fc729afSOlivier Houchard * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 296fc729afSOlivier Houchard * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 306fc729afSOlivier Houchard * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 316fc729afSOlivier Houchard * SUCH DAMAGE. 326fc729afSOlivier Houchard * 336fc729afSOlivier Houchard * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 346fc729afSOlivier Houchard */ 356fc729afSOlivier Houchard 366fc729afSOlivier Houchard #include <sys/cdefs.h> 376fc729afSOlivier Houchard __FBSDID("$FreeBSD$"); 386fc729afSOlivier Houchard 396fc729afSOlivier Houchard #include <sys/param.h> 406fc729afSOlivier Houchard #include <sys/systm.h> 416fc729afSOlivier Houchard #include <sys/proc.h> 426fc729afSOlivier Houchard #include <sys/sysproto.h> 436fc729afSOlivier Houchard #include <sys/syscall.h> 446fc729afSOlivier Houchard #include <sys/sysent.h> 456fc729afSOlivier Houchard 46371853e5SOlivier Houchard #include <machine/sysarch.h> 47371853e5SOlivier Houchard 486fc729afSOlivier Houchard #ifndef _SYS_SYSPROTO_H_ 496fc729afSOlivier Houchard struct sysarch_args { 506fc729afSOlivier Houchard int op; 516fc729afSOlivier Houchard char *parms; 526fc729afSOlivier Houchard }; 536fc729afSOlivier Houchard #endif 546fc729afSOlivier Houchard 55371853e5SOlivier Houchard /* Prototypes */ 56371853e5SOlivier Houchard static int arm32_sync_icache (struct thread *, void *); 57371853e5SOlivier Houchard static int arm32_drain_writebuf(struct thread *, void *); 58371853e5SOlivier Houchard 59371853e5SOlivier Houchard static int 60371853e5SOlivier Houchard arm32_sync_icache(struct thread *td, void *args) 61371853e5SOlivier Houchard { 62371853e5SOlivier Houchard struct arm_sync_icache_args ua; 63371853e5SOlivier Houchard int error; 64371853e5SOlivier Houchard 65371853e5SOlivier Houchard if ((error = copyin(args, &ua, sizeof(ua))) != 0) 66371853e5SOlivier Houchard return (error); 67371853e5SOlivier Houchard 68371853e5SOlivier Houchard cpu_icache_sync_range(ua.addr, ua.len); 69371853e5SOlivier Houchard 70371853e5SOlivier Houchard td->td_retval[0] = 0; 71371853e5SOlivier Houchard return(0); 72371853e5SOlivier Houchard } 73371853e5SOlivier Houchard 74371853e5SOlivier Houchard static int 75371853e5SOlivier Houchard arm32_drain_writebuf(struct thread *td, void *args) 76371853e5SOlivier Houchard { 77371853e5SOlivier Houchard /* No args. */ 78371853e5SOlivier Houchard 79371853e5SOlivier Houchard td->td_retval[0] = 0; 80371853e5SOlivier Houchard cpu_drain_writebuf(); 81371853e5SOlivier Houchard return(0); 82371853e5SOlivier Houchard } 83371853e5SOlivier Houchard 84a74985cdSOlivier Houchard static int 85a74985cdSOlivier Houchard arm32_set_tp(struct thread *td, void *args) 86a74985cdSOlivier Houchard { 87a74985cdSOlivier Houchard 88a74985cdSOlivier Houchard td->td_md.md_tp = args; 89a74985cdSOlivier Houchard return (0); 90a74985cdSOlivier Houchard } 91a74985cdSOlivier Houchard 92a74985cdSOlivier Houchard static int 93a74985cdSOlivier Houchard arm32_get_tp(struct thread *td, void *args) 94a74985cdSOlivier Houchard { 95a74985cdSOlivier Houchard 96a74985cdSOlivier Houchard td->td_retval[0] = (uint32_t)td->td_md.md_tp; 97a74985cdSOlivier Houchard return (0); 98a74985cdSOlivier Houchard } 99a74985cdSOlivier Houchard 1006fc729afSOlivier Houchard int 1016fc729afSOlivier Houchard sysarch(td, uap) 1026fc729afSOlivier Houchard struct thread *td; 1036fc729afSOlivier Houchard register struct sysarch_args *uap; 1046fc729afSOlivier Houchard { 105371853e5SOlivier Houchard int error; 106371853e5SOlivier Houchard 107371853e5SOlivier Houchard switch (uap->op) { 108371853e5SOlivier Houchard case ARM_SYNC_ICACHE : 109371853e5SOlivier Houchard error = arm32_sync_icache(td, uap->parms); 110371853e5SOlivier Houchard break; 111371853e5SOlivier Houchard 112371853e5SOlivier Houchard case ARM_DRAIN_WRITEBUF : 113371853e5SOlivier Houchard error = arm32_drain_writebuf(td, uap->parms); 114371853e5SOlivier Houchard break; 115a74985cdSOlivier Houchard case ARM_SET_TP: 116a74985cdSOlivier Houchard error = arm32_set_tp(td, uap->parms); 117a74985cdSOlivier Houchard break; 118a74985cdSOlivier Houchard case ARM_GET_TP: 119a74985cdSOlivier Houchard error = arm32_get_tp(td, uap->parms); 120a74985cdSOlivier Houchard break; 121371853e5SOlivier Houchard default: 122371853e5SOlivier Houchard error = EINVAL; 123371853e5SOlivier Houchard break; 124371853e5SOlivier Houchard } 125371853e5SOlivier Houchard return (error); 1266fc729afSOlivier Houchard } 1276fc729afSOlivier Houchard 128