1129198Scognet/*- 2129198Scognet * Copyright (c) 1990 The Regents of the University of California. 3129198Scognet * All rights reserved. 4129198Scognet * 5129198Scognet * Redistribution and use in source and binary forms, with or without 6129198Scognet * modification, are permitted provided that the following conditions 7129198Scognet * are met: 8129198Scognet * 1. Redistributions of source code must retain the above copyright 9129198Scognet * notice, this list of conditions and the following disclaimer. 10129198Scognet * 2. Redistributions in binary form must reproduce the above copyright 11129198Scognet * notice, this list of conditions and the following disclaimer in the 12129198Scognet * documentation and/or other materials provided with the distribution. 13129198Scognet * 3. All advertising materials mentioning features or use of this software 14129198Scognet * must display the following acknowledgement: 15129198Scognet * This product includes software developed by the University of 16129198Scognet * California, Berkeley and its contributors. 17129198Scognet * 4. Neither the name of the University nor the names of its contributors 18129198Scognet * may be used to endorse or promote products derived from this software 19129198Scognet * without specific prior written permission. 20129198Scognet * 21129198Scognet * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22129198Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23129198Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24129198Scognet * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25129198Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26129198Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27129198Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28129198Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29129198Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30129198Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31129198Scognet * SUCH DAMAGE. 32129198Scognet * 33129198Scognet * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 34129198Scognet */ 35129198Scognet 36129198Scognet#include <sys/cdefs.h> 37129198Scognet__FBSDID("$FreeBSD$"); 38129198Scognet 39223668Sjonathan#include "opt_capsicum.h" 40219134Srwatson 41129198Scognet#include <sys/param.h> 42129198Scognet#include <sys/systm.h> 43219134Srwatson#include <sys/capability.h> 44129198Scognet#include <sys/proc.h> 45129198Scognet#include <sys/sysproto.h> 46129198Scognet#include <sys/syscall.h> 47129198Scognet#include <sys/sysent.h> 48129198Scognet 49135642Scognet#include <machine/sysarch.h> 50135642Scognet 51129198Scognet#ifndef _SYS_SYSPROTO_H_ 52129198Scognetstruct sysarch_args { 53129198Scognet int op; 54129198Scognet char *parms; 55129198Scognet}; 56129198Scognet#endif 57129198Scognet 58135642Scognet/* Prototypes */ 59135642Scognetstatic int arm32_sync_icache (struct thread *, void *); 60135642Scognetstatic int arm32_drain_writebuf(struct thread *, void *); 61135642Scognet 62135642Scognetstatic int 63135642Scognetarm32_sync_icache(struct thread *td, void *args) 64135642Scognet{ 65135642Scognet struct arm_sync_icache_args ua; 66135642Scognet int error; 67135642Scognet 68135642Scognet if ((error = copyin(args, &ua, sizeof(ua))) != 0) 69135642Scognet return (error); 70135642Scognet 71135642Scognet cpu_icache_sync_range(ua.addr, ua.len); 72135642Scognet 73135642Scognet td->td_retval[0] = 0; 74166695Skevlo return (0); 75135642Scognet} 76135642Scognet 77135642Scognetstatic int 78135642Scognetarm32_drain_writebuf(struct thread *td, void *args) 79135642Scognet{ 80135642Scognet /* No args. */ 81135642Scognet 82135642Scognet td->td_retval[0] = 0; 83135642Scognet cpu_drain_writebuf(); 84166695Skevlo return (0); 85135642Scognet} 86135642Scognet 87142519Scognetstatic int 88142519Scognetarm32_set_tp(struct thread *td, void *args) 89142519Scognet{ 90142519Scognet 91218310Simp td->td_md.md_tp = (register_t)args; 92142519Scognet return (0); 93142519Scognet} 94142519Scognet 95142519Scognetstatic int 96142519Scognetarm32_get_tp(struct thread *td, void *args) 97142519Scognet{ 98142519Scognet 99218310Simp td->td_retval[0] = td->td_md.md_tp; 100142519Scognet return (0); 101142519Scognet} 102142519Scognet 103129198Scognetint 104129198Scognetsysarch(td, uap) 105129198Scognet struct thread *td; 106129198Scognet register struct sysarch_args *uap; 107129198Scognet{ 108135642Scognet int error; 109135642Scognet 110223668Sjonathan#ifdef CAPABILITY_MODE 111219134Srwatson /* 112223692Sjonathan * When adding new operations, add a new case statement here to 113223692Sjonathan * explicitly indicate whether or not the operation is safe to 114223692Sjonathan * perform in capability mode. 115219134Srwatson */ 116219134Srwatson if (IN_CAPABILITY_MODE(td)) { 117219134Srwatson switch (uap->op) { 118223692Sjonathan case ARM_SYNC_ICACHE: 119223692Sjonathan case ARM_DRAIN_WRITEBUF: 120223692Sjonathan case ARM_SET_TP: 121223692Sjonathan case ARM_GET_TP: 122223692Sjonathan break; 123219134Srwatson 124223692Sjonathan default: 125223692Sjonathan return (ECAPMODE); 126219134Srwatson } 127219134Srwatson } 128219134Srwatson#endif 129219134Srwatson 130135642Scognet switch (uap->op) { 131251866Sscottl case ARM_SYNC_ICACHE: 132135642Scognet error = arm32_sync_icache(td, uap->parms); 133135642Scognet break; 134251866Sscottl case ARM_DRAIN_WRITEBUF: 135135642Scognet error = arm32_drain_writebuf(td, uap->parms); 136135642Scognet break; 137142519Scognet case ARM_SET_TP: 138142519Scognet error = arm32_set_tp(td, uap->parms); 139142519Scognet break; 140142519Scognet case ARM_GET_TP: 141142519Scognet error = arm32_get_tp(td, uap->parms); 142142519Scognet break; 143135642Scognet default: 144135642Scognet error = EINVAL; 145135642Scognet break; 146135642Scognet } 147135642Scognet return (error); 148129198Scognet} 149