Home | History | Annotate | Line # | Download | only in mips
linux_machdep.c revision 1.13.2.2
      1  1.13.2.2   gehenna /*	$NetBSD: linux_machdep.c,v 1.13.2.2 2002/07/15 10:34:55 gehenna 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  * 3. All advertising materials mentioning features or use of this software
     19       1.1      manu  *    must display the following acknowledgement:
     20       1.1      manu  *	This product includes software developed by the NetBSD
     21       1.1      manu  *	Foundation, Inc. and its contributors.
     22       1.1      manu  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.1      manu  *    contributors may be used to endorse or promote products derived
     24       1.1      manu  *    from this software without specific prior written permission.
     25       1.1      manu  *
     26       1.1      manu  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.1      manu  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.1      manu  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.1      manu  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30       1.1      manu  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.1      manu  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.1      manu  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.1      manu  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.1      manu  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.1      manu  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.1      manu  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1      manu  */
     38       1.5     lukem 
     39       1.5     lukem #include <sys/cdefs.h>
     40  1.13.2.2   gehenna __KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.13.2.2 2002/07/15 10:34:55 gehenna Exp $");
     41       1.1      manu 
     42       1.1      manu #include <sys/param.h>
     43       1.1      manu #include <sys/systm.h>
     44       1.1      manu #include <sys/signalvar.h>
     45       1.1      manu #include <sys/kernel.h>
     46       1.1      manu #include <sys/map.h>
     47       1.1      manu #include <sys/proc.h>
     48       1.1      manu #include <sys/user.h>
     49       1.1      manu #include <sys/buf.h>
     50       1.1      manu #include <sys/reboot.h>
     51       1.1      manu #include <sys/conf.h>
     52       1.1      manu #include <sys/exec.h>
     53       1.1      manu #include <sys/file.h>
     54       1.1      manu #include <sys/callout.h>
     55       1.1      manu #include <sys/malloc.h>
     56       1.1      manu #include <sys/mbuf.h>
     57       1.1      manu #include <sys/msgbuf.h>
     58       1.1      manu #include <sys/mount.h>
     59       1.1      manu #include <sys/vnode.h>
     60       1.1      manu #include <sys/device.h>
     61       1.1      manu #include <sys/syscallargs.h>
     62       1.1      manu #include <sys/filedesc.h>
     63       1.1      manu #include <sys/exec_elf.h>
     64       1.1      manu #include <sys/disklabel.h>
     65       1.1      manu #include <sys/ioctl.h>
     66       1.2      manu #include <sys/sysctl.h>
     67       1.1      manu #include <miscfs/specfs/specdev.h>
     68       1.1      manu 
     69       1.1      manu #include <compat/linux/common/linux_types.h>
     70       1.1      manu #include <compat/linux/common/linux_signal.h>
     71       1.1      manu #include <compat/linux/common/linux_util.h>
     72       1.1      manu #include <compat/linux/common/linux_ioctl.h>
     73       1.1      manu #include <compat/linux/common/linux_hdio.h>
     74       1.1      manu #include <compat/linux/common/linux_exec.h>
     75       1.1      manu #include <compat/linux/common/linux_machdep.h>
     76       1.1      manu 
     77       1.1      manu #include <compat/linux/linux_syscallargs.h>
     78       1.1      manu 
     79       1.1      manu #include <machine/cpu.h>
     80       1.1      manu #include <machine/psl.h>
     81       1.1      manu #include <machine/reg.h>
     82       1.1      manu #include <machine/regnum.h>
     83       1.1      manu #include <machine/vmparam.h>
     84       1.1      manu #include <machine/locore.h>
     85       1.1      manu 
     86       1.7      manu #include <mips/cache.h>
     87       1.7      manu 
     88       1.1      manu /*
     89       1.1      manu  * To see whether wscons is configured (for virtual console ioctl calls).
     90       1.1      manu  */
     91       1.1      manu #if defined(_KERNEL_OPT)
     92       1.1      manu #include "wsdisplay.h"
     93       1.1      manu #endif
     94       1.1      manu #if (NWSDISPLAY > 0)
     95       1.1      manu #include <dev/wscons/wsconsio.h>
     96       1.1      manu #include <dev/wscons/wsdisplay_usl_io.h>
     97       1.1      manu #endif
     98       1.1      manu 
     99       1.1      manu /*
    100       1.1      manu  * Set set up registers on exec.
    101       1.1      manu  * XXX not used at the moment since in sys/kern/exec_conf, LINUX_COMPAT
    102       1.1      manu  * entry uses NetBSD's native setregs instead of linux_setregs
    103       1.1      manu  */
    104       1.1      manu void
    105       1.1      manu linux_setregs(p, pack, stack)
    106       1.1      manu 	struct proc *p;
    107       1.1      manu 	struct exec_package *pack;
    108       1.1      manu 	u_long stack;
    109       1.1      manu {
    110       1.1      manu 	setregs(p, pack, stack);
    111       1.1      manu 	return;
    112       1.1      manu }
    113       1.1      manu 
    114       1.1      manu /*
    115       1.1      manu  * Send an interrupt to process.
    116       1.1      manu  *
    117       1.1      manu  * Adapted from sys/arch/mips/mips/mips_machdep.c
    118       1.1      manu  *
    119       1.1      manu  * XXX Does not work well yet with RT signals
    120       1.1      manu  *
    121       1.1      manu  */
    122       1.1      manu 
    123       1.1      manu void
    124  1.13.2.2   gehenna linux_sendsig(sig, mask, code)  /* XXX Check me */
    125       1.1      manu 	int sig;
    126       1.1      manu 	sigset_t *mask;
    127       1.1      manu 	u_long code;
    128       1.1      manu {
    129       1.1      manu 	struct proc *p = curproc;
    130       1.1      manu 	struct linux_sigframe *fp;
    131       1.1      manu 	struct frame *f;
    132       1.1      manu 	int i,onstack;
    133  1.13.2.2   gehenna 	sig_t catcher = SIGACTION(p, sig).sa_handler;
    134       1.1      manu 	struct linux_sigframe sf;
    135       1.1      manu 
    136       1.4      manu #ifdef DEBUG_LINUX
    137       1.1      manu 	printf("linux_sendsig()\n");
    138       1.4      manu #endif /* DEBUG_LINUX */
    139       1.1      manu 	f = (struct frame *)p->p_md.md_regs;
    140       1.1      manu 
    141       1.1      manu 	/*
    142       1.1      manu 	 * Do we need to jump onto the signal stack?
    143       1.1      manu 	 */
    144       1.1      manu 	onstack =
    145       1.1      manu 	    (p->p_sigctx.ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
    146       1.1      manu 	    (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
    147       1.1      manu 
    148       1.1      manu 	/*
    149       1.6      manu 	 * Signal stack is broken (see at the end of linux_sigreturn), so we do
    150       1.1      manu 	 * not use it yet. XXX fix this.
    151       1.1      manu 	 */
    152       1.1      manu 	onstack=0;
    153       1.1      manu 
    154       1.1      manu 	/*
    155       1.1      manu 	 * Allocate space for the signal handler context.
    156       1.1      manu 	 */
    157       1.1      manu 	if (onstack)
    158       1.1      manu 		fp = (struct linux_sigframe *)
    159       1.1      manu 		    ((caddr_t)p->p_sigctx.ps_sigstk.ss_sp
    160       1.1      manu 		    + p->p_sigctx.ps_sigstk.ss_size);
    161       1.1      manu 	else
    162       1.1      manu 		/* cast for _MIPS_BSD_API == _MIPS_BSD_API_LP32_64CLEAN case */
    163       1.1      manu 		fp = (struct linux_sigframe *)(u_int32_t)f->f_regs[SP];
    164       1.1      manu 
    165       1.4      manu 	/*
    166       1.4      manu 	 * Build stack frame for signal trampoline.
    167       1.4      manu 	 */
    168       1.1      manu 	memset(&sf, 0, sizeof sf);
    169       1.4      manu 
    170       1.4      manu 	/*
    171       1.4      manu 	 * This is the signal trampoline used by Linux, we don't use it,
    172       1.6      manu 	 * but we set it up in case an application expects it to be there
    173       1.4      manu 	 */
    174       1.1      manu 	sf.lsf_code[0] = 0x24020000;	/* li	v0, __NR_sigreturn	*/
    175       1.4      manu 	sf.lsf_code[1] = 0x0000000c;	/* syscall			*/
    176       1.4      manu 
    177      1.11     rafal 	native_to_linux_sigset(&sf.lsf_mask, mask);
    178       1.8      manu 	for (i=0; i<32; i++) {
    179       1.1      manu 		sf.lsf_sc.lsc_regs[i] = f->f_regs[i];
    180       1.8      manu 	}
    181       1.1      manu 	sf.lsf_sc.lsc_mdhi = f->f_regs[MULHI];
    182       1.1      manu 	sf.lsf_sc.lsc_mdlo = f->f_regs[MULLO];
    183       1.1      manu 	sf.lsf_sc.lsc_pc = f->f_regs[PC];
    184      1.13      manu 	sf.lsf_sc.lsc_status = f->f_regs[SR];
    185       1.1      manu 	sf.lsf_sc.lsc_cause = f->f_regs[CAUSE];
    186      1.13      manu 	sf.lsf_sc.lsc_badvaddr = f->f_regs[BADVADDR];
    187       1.1      manu 
    188       1.1      manu 	/*
    189       1.1      manu 	 * Save signal stack.  XXX broken
    190       1.1      manu 	 */
    191       1.1      manu 	/* kregs.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK; */
    192       1.1      manu 
    193       1.1      manu 	/*
    194       1.1      manu 	 * Install the sigframe onto the stack
    195       1.1      manu 	 */
    196       1.1      manu 	fp -= sizeof(struct linux_sigframe);
    197       1.1      manu 	if (copyout(&sf, fp, sizeof(sf)) != 0) {
    198       1.1      manu 		/*
    199       1.1      manu 		 * Process has trashed its stack; give it an illegal
    200       1.1      manu 		 * instruction to halt it in its tracks.
    201       1.1      manu 		 */
    202       1.4      manu #ifdef DEBUG_LINUX
    203       1.4      manu 		printf("linux_sendsig: stack trashed\n");
    204       1.4      manu #endif /* DEBUG_LINUX */
    205       1.1      manu 		sigexit(p, SIGILL);
    206       1.1      manu 		/* NOTREACHED */
    207       1.1      manu 	}
    208       1.1      manu 
    209       1.1      manu 	/* Set up the registers to return to sigcode. */
    210      1.12  christos 	f->f_regs[A0] = native_to_linux_signo[sig];
    211       1.1      manu 	f->f_regs[A1] = 0;
    212       1.4      manu 	f->f_regs[A2] = (unsigned long)&fp->lsf_sc;
    213       1.1      manu 
    214       1.4      manu #ifdef DEBUG_LINUX
    215       1.4      manu 	printf("sigcontext is at %p\n", &fp->lsf_sc);
    216       1.4      manu #endif /* DEBUG_LINUX */
    217       1.1      manu 
    218       1.4      manu 	f->f_regs[SP] = (unsigned long)fp;
    219       1.1      manu 	/* Signal trampoline code is at base of user stack. */
    220       1.4      manu 	f->f_regs[RA] = (unsigned long)p->p_sigctx.ps_sigcode;
    221       1.4      manu 	f->f_regs[T9] = (unsigned long)catcher;
    222       1.4      manu 	f->f_regs[PC] = (unsigned long)catcher;
    223       1.1      manu 
    224       1.1      manu 	/* Remember that we're now on the signal stack. */
    225       1.1      manu 	if (onstack)
    226       1.1      manu 		p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK;
    227       1.8      manu 
    228       1.1      manu 	return;
    229       1.1      manu }
    230       1.1      manu 
    231       1.1      manu /*
    232       1.1      manu  * System call to cleanup state after a signal
    233       1.1      manu  * has been taken.  Reset signal mask and
    234       1.1      manu  * stack state from context left by sendsig (above).
    235       1.1      manu  */
    236       1.1      manu int
    237       1.1      manu linux_sys_sigreturn(p, v, retval)
    238       1.1      manu 	struct proc *p;
    239       1.1      manu 	void *v;
    240       1.1      manu 	register_t *retval;
    241       1.1      manu {
    242       1.1      manu 	struct linux_sys_sigreturn_args /* {
    243       1.8      manu 		syscallarg(struct linux_sigframe *) sf;
    244       1.1      manu 	} */ *uap = v;
    245       1.1      manu 	struct linux_sigframe *sf, ksf;
    246       1.1      manu 	struct frame *f;
    247       1.1      manu 	sigset_t mask;
    248       1.1      manu 	int i, error;
    249       1.1      manu 
    250       1.4      manu #ifdef DEBUG_LINUX
    251       1.1      manu 	printf("linux_sys_sigreturn()\n");
    252       1.4      manu #endif /* DEBUG_LINUX */
    253       1.4      manu 
    254       1.1      manu 	/*
    255       1.1      manu 	 * The trampoline code hands us the context.
    256       1.1      manu 	 * It is unsafe to keep track of it ourselves, in the event that a
    257       1.1      manu 	 * program jumps out of a signal handler.
    258       1.1      manu 	 */
    259       1.8      manu 	sf = SCARG(uap, sf);
    260       1.1      manu 
    261       1.1      manu 	if ((error = copyin(sf, &ksf, sizeof(ksf))) != 0)
    262       1.1      manu 		return (error);
    263       1.1      manu 
    264       1.1      manu 	/* Restore the register context. */
    265       1.1      manu 	f = (struct frame *)p->p_md.md_regs;
    266       1.1      manu 	for (i=0; i<32; i++)
    267       1.8      manu 		f->f_regs[i] = ksf.lsf_sc.lsc_regs[i];
    268       1.8      manu 	f->f_regs[MULLO] = ksf.lsf_sc.lsc_mdlo;
    269       1.8      manu 	f->f_regs[MULHI] = ksf.lsf_sc.lsc_mdhi;
    270       1.8      manu 	f->f_regs[PC] = ksf.lsf_sc.lsc_pc;
    271       1.8      manu 	f->f_regs[BADVADDR] = ksf.lsf_sc.lsc_badvaddr;
    272       1.8      manu 	f->f_regs[CAUSE] = ksf.lsf_sc.lsc_cause;
    273       1.1      manu 
    274       1.1      manu 	/* Restore signal stack. */
    275       1.1      manu 	p->p_sigctx.ps_sigstk.ss_flags &= ~SS_ONSTACK;
    276       1.1      manu 
    277       1.1      manu 	/* Restore signal mask. */
    278      1.11     rafal 	linux_to_native_sigset(&mask, (linux_sigset_t *)&ksf.lsf_mask);
    279       1.1      manu 	(void)sigprocmask1(p, SIG_SETMASK, &mask, 0);
    280       1.1      manu 
    281       1.1      manu 	return (EJUSTRETURN);
    282       1.1      manu }
    283       1.1      manu 
    284       1.1      manu 
    285       1.1      manu int
    286       1.1      manu linux_sys_rt_sigreturn(p, v, retval)
    287       1.1      manu 	struct proc *p;
    288       1.1      manu 	void *v;
    289       1.1      manu 	register_t *retval;
    290       1.1      manu {
    291       1.1      manu 	return 0;
    292       1.1      manu }
    293       1.1      manu 
    294       1.1      manu 
    295       1.1      manu #if 0
    296       1.1      manu int
    297       1.1      manu linux_sys_modify_ldt(p, v, retval)
    298       1.1      manu 	struct proc *p;
    299       1.1      manu 	void *v;
    300       1.1      manu 	register_t *retval;
    301       1.1      manu {
    302       1.1      manu 	/*
    303       1.1      manu 	 * This syscall is not implemented in Linux/Mips: we should not
    304       1.1      manu 	 * be here
    305       1.1      manu 	 */
    306       1.1      manu #ifdef DEBUG_LINUX
    307       1.1      manu 	printf("linux_sys_modify_ldt: should not be here.\n");
    308       1.4      manu #endif /* DEBUG_LINUX */
    309       1.1      manu   return 0;
    310       1.1      manu }
    311       1.1      manu #endif
    312       1.1      manu 
    313       1.1      manu /*
    314       1.1      manu  * major device numbers remapping
    315       1.1      manu  */
    316       1.1      manu dev_t
    317      1.10  christos linux_fakedev(dev, raw)
    318       1.1      manu 	dev_t dev;
    319      1.10  christos 	int raw;
    320       1.1      manu {
    321  1.13.2.1   gehenna 	/* XXX write me */
    322  1.13.2.1   gehenna 	return dev;
    323       1.1      manu }
    324       1.1      manu 
    325       1.1      manu /*
    326       1.1      manu  * We come here in a last attempt to satisfy a Linux ioctl() call
    327       1.1      manu  */
    328       1.1      manu int
    329       1.1      manu linux_machdepioctl(p, v, retval)
    330       1.1      manu 	struct proc *p;
    331       1.1      manu 	void *v;
    332       1.1      manu 	register_t *retval;
    333       1.1      manu {
    334       1.1      manu 	return 0;
    335       1.1      manu }
    336       1.1      manu 
    337       1.1      manu /*
    338       1.1      manu  * See above. If a root process tries to set access to an I/O port,
    339       1.1      manu  * just let it have the whole range.
    340       1.1      manu  */
    341       1.1      manu int
    342       1.1      manu linux_sys_ioperm(p, v, retval)
    343       1.1      manu 	struct proc *p;
    344       1.1      manu 	void *v;
    345       1.1      manu 	register_t *retval;
    346       1.1      manu {
    347       1.1      manu 	/*
    348       1.1      manu 	 * This syscall is not implemented in Linux/Mips: we should not be here
    349       1.1      manu 	 */
    350       1.1      manu #ifdef DEBUG_LINUX
    351       1.1      manu 	printf("linux_sys_ioperm: should not be here.\n");
    352       1.4      manu #endif /* DEBUG_LINUX */
    353       1.1      manu 	return 0;
    354       1.1      manu }
    355       1.1      manu 
    356       1.1      manu /*
    357       1.1      manu  * wrapper linux_sys_new_uname() -> linux_sys_uname()
    358       1.1      manu  */
    359       1.1      manu int
    360       1.1      manu linux_sys_new_uname(p, v, retval)
    361       1.1      manu 	struct proc *p;
    362       1.1      manu 	void *v;
    363       1.1      manu 	register_t *retval;
    364       1.1      manu {
    365       1.4      manu /*
    366       1.4      manu  * Use this if you want to try Linux emulation with a glibc-2.2
    367       1.4      manu  * or higher. Note that signals will not work
    368       1.4      manu  */
    369       1.4      manu #if 0
    370       1.4      manu         struct linux_sys_uname_args /* {
    371       1.4      manu                 syscallarg(struct linux_utsname *) up;
    372       1.4      manu         } */ *uap = v;
    373       1.4      manu         struct linux_utsname luts;
    374       1.4      manu 
    375       1.4      manu         strncpy(luts.l_sysname, linux_sysname, sizeof(luts.l_sysname));
    376       1.4      manu         strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename));
    377       1.4      manu         strncpy(luts.l_release, "2.4.0", sizeof(luts.l_release));
    378       1.4      manu         strncpy(luts.l_version, linux_version, sizeof(luts.l_version));
    379       1.4      manu         strncpy(luts.l_machine, machine, sizeof(luts.l_machine));
    380       1.4      manu         strncpy(luts.l_domainname, domainname, sizeof(luts.l_domainname));
    381       1.4      manu 
    382       1.4      manu         return copyout(&luts, SCARG(uap, up), sizeof(luts));
    383       1.4      manu #else
    384       1.4      manu 	return linux_sys_uname(p, v, retval);
    385       1.4      manu #endif
    386       1.1      manu }
    387       1.1      manu 
    388       1.1      manu /*
    389       1.2      manu  * In Linux, cacheflush is icurrently implemented
    390       1.1      manu  * as a whole cache flush (arguments are ignored)
    391       1.1      manu  * we emulate this broken beahior.
    392       1.1      manu  */
    393       1.1      manu int
    394       1.1      manu linux_sys_cacheflush(p, v, retval)
    395       1.1      manu 	struct proc *p;
    396       1.1      manu 	void *v;
    397       1.1      manu 	register_t *retval;
    398       1.1      manu {
    399       1.7      manu 	mips_icache_sync_all();
    400       1.7      manu 	mips_dcache_wbinv_all();
    401       1.1      manu 	return 0;
    402       1.1      manu }
    403       1.1      manu 
    404       1.2      manu /*
    405       1.2      manu  * This system call is depecated in Linux, but
    406       1.2      manu  * some binaries and some libraries use it.
    407       1.2      manu  */
    408       1.2      manu int
    409       1.2      manu linux_sys_sysmips(p, v, retval)
    410       1.2      manu 	struct proc *p;
    411       1.2      manu 	void *v;
    412       1.2      manu 	register_t *retval;
    413       1.2      manu {
    414       1.2      manu 	struct linux_sys_sysmips_args {
    415       1.2      manu 		syscallarg(int) cmd;
    416       1.2      manu 		syscallarg(int) arg1;
    417       1.2      manu 		syscallarg(int) arg2;
    418       1.2      manu 		syscallarg(int) arg3;
    419       1.2      manu 	} *uap = v;
    420       1.2      manu 	int error;
    421       1.2      manu 
    422       1.2      manu 	switch (SCARG(uap, cmd)) {
    423       1.2      manu 	case LINUX_SETNAME: {
    424       1.2      manu 		char nodename [LINUX___NEW_UTS_LEN + 1];
    425       1.2      manu 		int name;
    426       1.2      manu 		size_t len;
    427       1.2      manu 
    428       1.2      manu 		if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
    429       1.2      manu 			return error;
    430       1.2      manu 		if ((error = copyinstr((char *)SCARG(uap, arg1), nodename,
    431       1.2      manu 		    LINUX___NEW_UTS_LEN, &len)) != 0)
    432       1.2      manu 			return error;
    433       1.2      manu 
    434       1.2      manu 		name = KERN_HOSTNAME;
    435       1.2      manu 		return (kern_sysctl(&name, 1, 0, 0, nodename, len, p));
    436       1.2      manu 
    437       1.2      manu 		break;
    438       1.2      manu 	}
    439       1.3      manu 	case LINUX_MIPS_ATOMIC_SET: {
    440       1.3      manu 		void *addr;
    441       1.3      manu 		int s;
    442       1.3      manu 
    443       1.3      manu 		addr = (void *)SCARG(uap, arg1);
    444       1.3      manu 
    445       1.3      manu 		if ((uvm_useracc((caddr_t)addr, sizeof(int),
    446       1.3      manu 		    B_READ | B_WRITE)) != 1)
    447       1.3      manu 			return EFAULT;
    448       1.3      manu 
    449       1.3      manu 		s = splhigh();
    450       1.3      manu 		/*
    451       1.3      manu 		 * No error testing here. This is bad, but Linux does
    452       1.3      manu 		 * it like this. The source aknowledge "This is broken"
    453       1.3      manu 		 * in a comment...
    454       1.3      manu 		 */
    455       1.3      manu 		*retval = (register_t)fubyte(addr);
    456       1.3      manu 		error = subyte(addr, SCARG(uap, arg2));
    457       1.3      manu 		splx(s);
    458       1.3      manu 
    459       1.3      manu 		return 0;
    460       1.2      manu 		break;
    461       1.3      manu 	}
    462       1.2      manu 	case LINUX_MIPS_FIXADE:		/* XXX not implemented */
    463       1.2      manu 		break;
    464       1.2      manu 	case LINUX_FLUSH_CACHE:
    465       1.7      manu 		mips_icache_sync_all();
    466       1.7      manu 		mips_dcache_wbinv_all();
    467       1.2      manu 		break;
    468       1.2      manu 	case LINUX_MIPS_RDNVRAM:
    469       1.2      manu 		return EIO;
    470       1.2      manu 		break;
    471       1.2      manu 	default:
    472       1.2      manu 		return EINVAL;
    473       1.2      manu 		break;
    474       1.2      manu 	}
    475       1.3      manu #ifdef DEBUG_LINUX
    476       1.2      manu 	printf("linux_sys_sysmips(): unimplemented command %d\n",
    477       1.2      manu 	    SCARG(uap,cmd));
    478       1.2      manu #endif /* DEBUG_LINUX */
    479       1.2      manu 	return 0;
    480       1.2      manu }
    481