1 1.45 andvar /* $NetBSD: linux_machdep.c,v 1.45 2025/08/10 09:17:59 andvar Exp $ */ 2 1.1 manu 3 1.1 manu /*- 4 1.1 manu * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc. 5 1.1 manu * All rights reserved. 6 1.1 manu * 7 1.1 manu * This code is derived from software contributed to The NetBSD Foundation 8 1.1 manu * by Frank van der Linden and Emmanuel Dreyfus. 9 1.1 manu * 10 1.1 manu * Redistribution and use in source and binary forms, with or without 11 1.1 manu * modification, are permitted provided that the following conditions 12 1.1 manu * are met: 13 1.1 manu * 1. Redistributions of source code must retain the above copyright 14 1.1 manu * notice, this list of conditions and the following disclaimer. 15 1.1 manu * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 manu * notice, this list of conditions and the following disclaimer in the 17 1.1 manu * documentation and/or other materials provided with the distribution. 18 1.1 manu * 19 1.1 manu * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 manu * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 manu * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 manu * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 manu * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 manu * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 manu * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 manu * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 manu * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 manu * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 manu * POSSIBILITY OF SUCH DAMAGE. 30 1.1 manu */ 31 1.5 lukem 32 1.5 lukem #include <sys/cdefs.h> 33 1.45 andvar __KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.45 2025/08/10 09:17:59 andvar Exp $"); 34 1.1 manu 35 1.1 manu #include <sys/param.h> 36 1.1 manu #include <sys/systm.h> 37 1.1 manu #include <sys/signalvar.h> 38 1.1 manu #include <sys/kernel.h> 39 1.1 manu #include <sys/proc.h> 40 1.1 manu #include <sys/buf.h> 41 1.1 manu #include <sys/reboot.h> 42 1.1 manu #include <sys/conf.h> 43 1.1 manu #include <sys/exec.h> 44 1.1 manu #include <sys/file.h> 45 1.1 manu #include <sys/callout.h> 46 1.1 manu #include <sys/mbuf.h> 47 1.1 manu #include <sys/msgbuf.h> 48 1.1 manu #include <sys/mount.h> 49 1.1 manu #include <sys/vnode.h> 50 1.1 manu #include <sys/device.h> 51 1.1 manu #include <sys/syscallargs.h> 52 1.1 manu #include <sys/filedesc.h> 53 1.1 manu #include <sys/exec_elf.h> 54 1.1 manu #include <sys/disklabel.h> 55 1.1 manu #include <sys/ioctl.h> 56 1.2 manu #include <sys/sysctl.h> 57 1.26 yamt #include <sys/kauth.h> 58 1.1 manu #include <miscfs/specfs/specdev.h> 59 1.1 manu 60 1.1 manu #include <compat/linux/common/linux_types.h> 61 1.1 manu #include <compat/linux/common/linux_signal.h> 62 1.1 manu #include <compat/linux/common/linux_util.h> 63 1.1 manu #include <compat/linux/common/linux_ioctl.h> 64 1.1 manu #include <compat/linux/common/linux_hdio.h> 65 1.1 manu #include <compat/linux/common/linux_exec.h> 66 1.1 manu #include <compat/linux/common/linux_machdep.h> 67 1.1 manu 68 1.1 manu #include <compat/linux/linux_syscallargs.h> 69 1.1 manu 70 1.32 ad #include <sys/cpu.h> 71 1.1 manu #include <machine/psl.h> 72 1.1 manu #include <machine/reg.h> 73 1.1 manu #include <machine/regnum.h> 74 1.1 manu #include <machine/vmparam.h> 75 1.1 manu #include <machine/locore.h> 76 1.1 manu 77 1.7 manu #include <mips/cache.h> 78 1.7 manu 79 1.42 matt union linux_ksigframe { 80 1.42 matt struct linux_sigframe sf; 81 1.42 matt #if !defined(__mips_o32) 82 1.42 matt struct linux_sigframe32 sf32; 83 1.42 matt #endif 84 1.42 matt }; 85 1.42 matt 86 1.1 manu /* 87 1.1 manu * To see whether wscons is configured (for virtual console ioctl calls). 88 1.1 manu */ 89 1.1 manu #if defined(_KERNEL_OPT) 90 1.1 manu #include "wsdisplay.h" 91 1.1 manu #endif 92 1.1 manu #if (NWSDISPLAY > 0) 93 1.1 manu #include <dev/wscons/wsconsio.h> 94 1.1 manu #include <dev/wscons/wsdisplay_usl_io.h> 95 1.1 manu #endif 96 1.1 manu 97 1.22 perry /* 98 1.1 manu * Set set up registers on exec. 99 1.1 manu */ 100 1.1 manu void 101 1.41 chs linux_setregs(struct lwp *l, struct exec_package *pack, vaddr_t stack) 102 1.22 perry { 103 1.17 thorpej setregs(l, pack, stack); 104 1.1 manu return; 105 1.1 manu } 106 1.1 manu 107 1.42 matt #if !defined(__mips_o32) 108 1.42 matt static void 109 1.42 matt linux_setup_sigcontext32(struct linux_sigcontext32 *sc, 110 1.42 matt const struct trapframe *tf) 111 1.42 matt { 112 1.42 matt for (u_int i = 0; i < 32; i++) { 113 1.42 matt sc->lsc_regs[i] = tf->tf_regs[i]; 114 1.42 matt } 115 1.42 matt sc->lsc_mdhi = tf->tf_regs[_R_MULHI]; 116 1.42 matt sc->lsc_mdlo = tf->tf_regs[_R_MULLO]; 117 1.42 matt sc->lsc_pc = tf->tf_regs[_R_PC]; 118 1.42 matt } 119 1.42 matt #endif 120 1.42 matt 121 1.42 matt static void 122 1.42 matt linux_setup_sigcontext(struct linux_sigcontext *sc, 123 1.42 matt const struct trapframe *tf) 124 1.42 matt { 125 1.42 matt for (u_int i = 0; i < 32; i++) { 126 1.42 matt sc->lsc_regs[i] = tf->tf_regs[i]; 127 1.42 matt } 128 1.42 matt sc->lsc_mdhi = tf->tf_regs[_R_MULHI]; 129 1.42 matt sc->lsc_mdlo = tf->tf_regs[_R_MULLO]; 130 1.42 matt sc->lsc_pc = tf->tf_regs[_R_PC]; 131 1.42 matt } 132 1.42 matt 133 1.1 manu /* 134 1.1 manu * Send an interrupt to process. 135 1.1 manu * 136 1.1 manu * Adapted from sys/arch/mips/mips/mips_machdep.c 137 1.1 manu * 138 1.1 manu * XXX Does not work well yet with RT signals 139 1.1 manu * 140 1.1 manu */ 141 1.1 manu 142 1.1 manu void 143 1.34 dsl linux_sendsig(const ksiginfo_t *ksi, const sigset_t *mask) 144 1.1 manu { 145 1.21 manu const int sig = ksi->ksi_signo; 146 1.42 matt struct lwp * const l = curlwp; 147 1.42 matt struct proc * const p = l->l_proc; 148 1.42 matt struct trapframe * const tf = l->l_md.md_utf; 149 1.42 matt #ifdef __mips_o32 150 1.42 matt const int abi = _MIPS_BSD_API_O32; 151 1.42 matt #else 152 1.42 matt const int abi = p->p_md.md_abi; 153 1.42 matt #endif 154 1.42 matt union linux_ksigframe ksf, *sf; 155 1.42 matt bool onstack; 156 1.42 matt int error; 157 1.15 thorpej sig_t catcher = SIGACTION(p, sig).sa_handler; 158 1.1 manu 159 1.4 manu #ifdef DEBUG_LINUX 160 1.1 manu printf("linux_sendsig()\n"); 161 1.4 manu #endif /* DEBUG_LINUX */ 162 1.1 manu 163 1.22 perry /* 164 1.22 perry * Do we need to jump onto the signal stack? 165 1.1 manu */ 166 1.42 matt onstack = (l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 167 1.42 matt && (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0; 168 1.1 manu 169 1.1 manu /* 170 1.6 manu * Signal stack is broken (see at the end of linux_sigreturn), so we do 171 1.1 manu * not use it yet. XXX fix this. 172 1.1 manu */ 173 1.42 matt onstack = false; 174 1.1 manu 175 1.22 perry /* 176 1.22 perry * Allocate space for the signal handler context. 177 1.1 manu */ 178 1.42 matt sf = (void *)(onstack 179 1.42 matt ? (uintptr_t) l->l_sigstk.ss_sp + l->l_sigstk.ss_size 180 1.42 matt : (uintptr_t) tf->tf_regs[_R_SP]); 181 1.1 manu 182 1.22 perry /* 183 1.22 perry * Build stack frame for signal trampoline. 184 1.4 manu */ 185 1.42 matt memset(&ksf, 0, sizeof ksf); 186 1.4 manu 187 1.4 manu /* 188 1.4 manu * This is the signal trampoline used by Linux, we don't use it, 189 1.6 manu * but we set it up in case an application expects it to be there 190 1.4 manu */ 191 1.42 matt ksf.sf.lsf_code[0] = 0x24020000; /* li v0, __NR_sigreturn */ 192 1.42 matt ksf.sf.lsf_code[1] = 0x0000000c; /* syscall */ 193 1.4 manu 194 1.42 matt switch (abi) { 195 1.42 matt default: 196 1.42 matt native_to_linux_sigset(&ksf.sf.lsf_mask, mask); 197 1.42 matt linux_setup_sigcontext(&ksf.sf.lsf_sc, tf); 198 1.42 matt break; 199 1.42 matt #if !defined(__mips_o32) 200 1.42 matt case _MIPS_BSD_API_O32: 201 1.42 matt native_to_linux_sigset(&ksf.sf32.lsf_mask, mask); 202 1.42 matt linux_setup_sigcontext32(&ksf.sf32.lsf_sc, tf); 203 1.42 matt break; 204 1.42 matt #endif 205 1.8 manu } 206 1.29 ad sendsig_reset(l, sig); 207 1.1 manu 208 1.22 perry /* 209 1.1 manu * Save signal stack. XXX broken 210 1.1 manu */ 211 1.29 ad /* kregs.sc_onstack = l->l_sigstk.ss_flags & SS_ONSTACK; */ 212 1.1 manu 213 1.1 manu /* 214 1.1 manu * Install the sigframe onto the stack 215 1.1 manu */ 216 1.42 matt sf -= sizeof(*sf); 217 1.37 ad mutex_exit(p->p_lock); 218 1.42 matt error = copyout(&ksf, sf, sizeof(ksf)); 219 1.37 ad mutex_enter(p->p_lock); 220 1.29 ad 221 1.29 ad if (error != 0) { 222 1.1 manu /* 223 1.1 manu * Process has trashed its stack; give it an illegal 224 1.1 manu * instruction to halt it in its tracks. 225 1.1 manu */ 226 1.4 manu #ifdef DEBUG_LINUX 227 1.4 manu printf("linux_sendsig: stack trashed\n"); 228 1.4 manu #endif /* DEBUG_LINUX */ 229 1.17 thorpej sigexit(l, SIGILL); 230 1.1 manu /* NOTREACHED */ 231 1.1 manu } 232 1.1 manu 233 1.1 manu /* Set up the registers to return to sigcode. */ 234 1.42 matt tf->tf_regs[_R_A0] = native_to_linux_signo[sig]; 235 1.42 matt tf->tf_regs[_R_A1] = 0; 236 1.42 matt tf->tf_regs[_R_A2] = (intptr_t)&sf->sf.lsf_sc; 237 1.1 manu 238 1.4 manu #ifdef DEBUG_LINUX 239 1.42 matt printf("sigcontext is at %p\n", &sf->sf.lsf_sc); 240 1.4 manu #endif /* DEBUG_LINUX */ 241 1.1 manu 242 1.42 matt tf->tf_regs[_R_SP] = (intptr_t)sf; 243 1.1 manu /* Signal trampoline code is at base of user stack. */ 244 1.42 matt tf->tf_regs[_R_RA] = (intptr_t)p->p_sigctx.ps_sigcode; 245 1.42 matt tf->tf_regs[_R_T9] = (intptr_t)catcher; 246 1.42 matt tf->tf_regs[_R_PC] = (intptr_t)catcher; 247 1.1 manu 248 1.1 manu /* Remember that we're now on the signal stack. */ 249 1.1 manu if (onstack) 250 1.29 ad l->l_sigstk.ss_flags |= SS_ONSTACK; 251 1.8 manu 252 1.1 manu return; 253 1.1 manu } 254 1.1 manu 255 1.42 matt static void 256 1.42 matt linux_putaway_sigcontext(struct trapframe *tf, 257 1.42 matt const struct linux_sigcontext *sc) 258 1.42 matt { 259 1.42 matt for (u_int i = 0; i < 32; i++) { 260 1.42 matt tf->tf_regs[i] = sc->lsc_regs[i]; 261 1.42 matt } 262 1.42 matt tf->tf_regs[_R_MULLO] = sc->lsc_mdlo; 263 1.42 matt tf->tf_regs[_R_MULHI] = sc->lsc_mdhi; 264 1.42 matt tf->tf_regs[_R_PC] = sc->lsc_pc; 265 1.42 matt } 266 1.42 matt 267 1.42 matt #ifndef __mips_o32 268 1.42 matt static void 269 1.42 matt linux_putaway_sigcontext32(struct trapframe *tf, 270 1.42 matt const struct linux_sigcontext32 *sc) 271 1.42 matt { 272 1.42 matt for (u_int i = 0; i < 32; i++) { 273 1.42 matt tf->tf_regs[i] = sc->lsc_regs[i]; 274 1.42 matt } 275 1.42 matt tf->tf_regs[_R_MULLO] = sc->lsc_mdlo; 276 1.42 matt tf->tf_regs[_R_MULHI] = sc->lsc_mdhi; 277 1.42 matt tf->tf_regs[_R_PC] = sc->lsc_pc; 278 1.42 matt } 279 1.42 matt #endif 280 1.42 matt 281 1.1 manu /* 282 1.1 manu * System call to cleanup state after a signal 283 1.1 manu * has been taken. Reset signal mask and 284 1.1 manu * stack state from context left by sendsig (above). 285 1.1 manu */ 286 1.1 manu int 287 1.35 dsl linux_sys_sigreturn(struct lwp *l, const struct linux_sys_sigreturn_args *uap, register_t *retval) 288 1.1 manu { 289 1.35 dsl /* { 290 1.8 manu syscallarg(struct linux_sigframe *) sf; 291 1.35 dsl } */ 292 1.17 thorpej struct proc *p = l->l_proc; 293 1.42 matt union linux_ksigframe ksf, *sf; 294 1.42 matt #ifdef __mips_o32 295 1.42 matt const int abi = _MIPS_BSD_API_O32; 296 1.42 matt #else 297 1.42 matt const int abi = p->p_md.md_abi; 298 1.42 matt #endif 299 1.42 matt linux_sigset_t *lmask; 300 1.1 manu sigset_t mask; 301 1.42 matt int error; 302 1.1 manu 303 1.4 manu #ifdef DEBUG_LINUX 304 1.1 manu printf("linux_sys_sigreturn()\n"); 305 1.4 manu #endif /* DEBUG_LINUX */ 306 1.4 manu 307 1.1 manu /* 308 1.1 manu * The trampoline code hands us the context. 309 1.1 manu * It is unsafe to keep track of it ourselves, in the event that a 310 1.1 manu * program jumps out of a signal handler. 311 1.1 manu */ 312 1.42 matt sf = (void *)SCARG(uap, sf); 313 1.1 manu 314 1.1 manu if ((error = copyin(sf, &ksf, sizeof(ksf))) != 0) 315 1.1 manu return (error); 316 1.1 manu 317 1.1 manu /* Restore the register context. */ 318 1.42 matt switch (abi) { 319 1.42 matt default: 320 1.42 matt lmask = &ksf.sf.lsf_mask; 321 1.42 matt linux_putaway_sigcontext(l->l_md.md_utf, &ksf.sf.lsf_sc); 322 1.42 matt break; 323 1.42 matt #if !defined(__mips_o32) 324 1.42 matt case _MIPS_BSD_API_O32: 325 1.42 matt lmask = &ksf.sf32.lsf_mask; 326 1.42 matt linux_putaway_sigcontext32(l->l_md.md_utf, &ksf.sf32.lsf_sc); 327 1.42 matt break; 328 1.42 matt #endif 329 1.42 matt } 330 1.1 manu 331 1.37 ad mutex_enter(p->p_lock); 332 1.29 ad 333 1.1 manu /* Restore signal stack. */ 334 1.29 ad l->l_sigstk.ss_flags &= ~SS_ONSTACK; 335 1.1 manu 336 1.1 manu /* Restore signal mask. */ 337 1.42 matt linux_to_native_sigset(&mask, lmask); 338 1.29 ad (void)sigprocmask1(l, SIG_SETMASK, &mask, 0); 339 1.29 ad 340 1.37 ad mutex_exit(p->p_lock); 341 1.1 manu 342 1.1 manu return (EJUSTRETURN); 343 1.1 manu } 344 1.1 manu 345 1.1 manu 346 1.1 manu int 347 1.41 chs linux_sys_rt_sigreturn(struct lwp *l, const struct linux_sys_rt_sigreturn_args *v, register_t *retval) 348 1.1 manu { 349 1.17 thorpej return (ENOSYS); 350 1.1 manu } 351 1.1 manu 352 1.1 manu 353 1.22 perry /* 354 1.1 manu * major device numbers remapping 355 1.1 manu */ 356 1.1 manu dev_t 357 1.34 dsl linux_fakedev(dev_t dev, int raw) 358 1.1 manu { 359 1.14 jdolecek /* XXX write me */ 360 1.14 jdolecek return dev; 361 1.1 manu } 362 1.1 manu 363 1.1 manu /* 364 1.1 manu * We come here in a last attempt to satisfy a Linux ioctl() call 365 1.1 manu */ 366 1.1 manu int 367 1.35 dsl linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, register_t *retval) 368 1.22 perry { 369 1.1 manu return 0; 370 1.1 manu } 371 1.1 manu 372 1.1 manu /* 373 1.1 manu * See above. If a root process tries to set access to an I/O port, 374 1.1 manu * just let it have the whole range. 375 1.1 manu */ 376 1.1 manu int 377 1.35 dsl linux_sys_ioperm(struct lwp *l, const struct linux_sys_ioperm_args *uap, register_t *retval) 378 1.1 manu { 379 1.22 perry /* 380 1.1 manu * This syscall is not implemented in Linux/Mips: we should not be here 381 1.1 manu */ 382 1.1 manu #ifdef DEBUG_LINUX 383 1.22 perry printf("linux_sys_ioperm: should not be here.\n"); 384 1.4 manu #endif /* DEBUG_LINUX */ 385 1.1 manu return 0; 386 1.1 manu } 387 1.1 manu 388 1.1 manu /* 389 1.22 perry * wrapper linux_sys_new_uname() -> linux_sys_uname() 390 1.1 manu */ 391 1.22 perry int 392 1.35 dsl linux_sys_new_uname(struct lwp *l, const struct linux_sys_new_uname_args *uap, register_t *retval) 393 1.1 manu { 394 1.4 manu /* 395 1.22 perry * Use this if you want to try Linux emulation with a glibc-2.2 396 1.4 manu * or higher. Note that signals will not work 397 1.4 manu */ 398 1.4 manu #if 0 399 1.4 manu struct linux_sys_uname_args /* { 400 1.4 manu syscallarg(struct linux_utsname *) up; 401 1.4 manu } */ *uap = v; 402 1.4 manu struct linux_utsname luts; 403 1.4 manu 404 1.44 riastrad memset(&luts, 0, sizeof(luts)); 405 1.33 njoly strlcpy(luts.l_sysname, linux_sysname, sizeof(luts.l_sysname)); 406 1.33 njoly strlcpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); 407 1.33 njoly strlcpy(luts.l_release, "2.4.0", sizeof(luts.l_release)); 408 1.33 njoly strlcpy(luts.l_version, linux_version, sizeof(luts.l_version)); 409 1.33 njoly strlcpy(luts.l_machine, machine, sizeof(luts.l_machine)); 410 1.33 njoly strlcpy(luts.l_domainname, domainname, sizeof(luts.l_domainname)); 411 1.4 manu 412 1.4 manu return copyout(&luts, SCARG(uap, up), sizeof(luts)); 413 1.4 manu #else 414 1.35 dsl return linux_sys_uname(l, (const void *)uap, retval); 415 1.4 manu #endif 416 1.1 manu } 417 1.1 manu 418 1.1 manu /* 419 1.17 thorpej * In Linux, cacheflush is currently implemented 420 1.1 manu * as a whole cache flush (arguments are ignored) 421 1.1 manu * we emulate this broken beahior. 422 1.1 manu */ 423 1.1 manu int 424 1.35 dsl linux_sys_cacheflush(struct lwp *l, const struct linux_sys_cacheflush_args *uap, register_t *retval) 425 1.1 manu { 426 1.7 manu mips_icache_sync_all(); 427 1.7 manu mips_dcache_wbinv_all(); 428 1.1 manu return 0; 429 1.1 manu } 430 1.1 manu 431 1.2 manu /* 432 1.22 perry * This system call is depecated in Linux, but 433 1.2 manu * some binaries and some libraries use it. 434 1.2 manu */ 435 1.2 manu int 436 1.35 dsl linux_sys_sysmips(struct lwp *l, const struct linux_sys_sysmips_args *uap, register_t *retval) 437 1.2 manu { 438 1.41 chs /* { 439 1.42 matt syscallarg(long) cmd; 440 1.42 matt syscallarg(long) arg1; 441 1.42 matt syscallarg(long) arg2; 442 1.42 matt syscallarg(long) arg3; 443 1.41 chs } */ 444 1.2 manu int error; 445 1.22 perry 446 1.2 manu switch (SCARG(uap, cmd)) { 447 1.2 manu case LINUX_SETNAME: { 448 1.2 manu char nodename [LINUX___NEW_UTS_LEN + 1]; 449 1.20 atatat int name[2]; 450 1.2 manu size_t len; 451 1.2 manu 452 1.22 perry if ((error = copyinstr((char *)SCARG(uap, arg1), nodename, 453 1.2 manu LINUX___NEW_UTS_LEN, &len)) != 0) 454 1.2 manu return error; 455 1.2 manu 456 1.20 atatat name[0] = CTL_KERN; 457 1.20 atatat name[1] = KERN_HOSTNAME; 458 1.20 atatat return (old_sysctl(&name[0], 2, 0, 0, nodename, len, NULL)); 459 1.22 perry 460 1.2 manu break; 461 1.2 manu } 462 1.3 manu case LINUX_MIPS_ATOMIC_SET: { 463 1.3 manu void *addr; 464 1.3 manu int s; 465 1.18 jdolecek u_int8_t value = 0; 466 1.3 manu 467 1.3 manu addr = (void *)SCARG(uap, arg1); 468 1.3 manu 469 1.3 manu s = splhigh(); 470 1.3 manu /* 471 1.3 manu * No error testing here. This is bad, but Linux does 472 1.45 andvar * it like this. The source acknowledge "This is broken" 473 1.3 manu * in a comment... 474 1.3 manu */ 475 1.18 jdolecek (void) copyin(addr, &value, 1); 476 1.18 jdolecek *retval = value; 477 1.18 jdolecek value = (u_int8_t) SCARG(uap, arg2); 478 1.18 jdolecek error = copyout(&value, addr, 1); 479 1.3 manu splx(s); 480 1.3 manu 481 1.3 manu return 0; 482 1.2 manu break; 483 1.3 manu } 484 1.2 manu case LINUX_MIPS_FIXADE: /* XXX not implemented */ 485 1.2 manu break; 486 1.2 manu case LINUX_FLUSH_CACHE: 487 1.7 manu mips_icache_sync_all(); 488 1.7 manu mips_dcache_wbinv_all(); 489 1.2 manu break; 490 1.2 manu case LINUX_MIPS_RDNVRAM: 491 1.2 manu return EIO; 492 1.2 manu break; 493 1.2 manu default: 494 1.2 manu return EINVAL; 495 1.2 manu break; 496 1.2 manu } 497 1.3 manu #ifdef DEBUG_LINUX 498 1.22 perry printf("linux_sys_sysmips(): unimplemented command %d\n", 499 1.22 perry SCARG(uap,cmd)); 500 1.2 manu #endif /* DEBUG_LINUX */ 501 1.2 manu return 0; 502 1.2 manu } 503 1.23 fvdl 504 1.23 fvdl int 505 1.23 fvdl linux_usertrap(struct lwp *l, vaddr_t trapaddr, void *arg) 506 1.23 fvdl { 507 1.23 fvdl return 0; 508 1.23 fvdl } 509 1.41 chs 510 1.41 chs int 511 1.41 chs linux_sys_set_thread_area(struct lwp *l, const struct linux_sys_set_thread_area_args *uap, register_t *retval) 512 1.41 chs { 513 1.41 chs /* { 514 1.41 chs syscallarg(void *) tls; 515 1.41 chs } */ 516 1.41 chs 517 1.41 chs return lwp_setprivate(l, SCARG(uap, tls)); 518 1.41 chs } 519