1998-09-11 16:50:05 +04:00
|
|
|
/* $NetBSD: linux_machdep.c,v 1.42 1998/09/11 12:50:06 mycroft Exp $ */
|
1995-04-08 02:29:34 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Frank van der Linden
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed for the NetBSD Project
|
|
|
|
* by Frank van der Linden
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1998-01-16 01:25:52 +03:00
|
|
|
#include "opt_vm86.h"
|
1998-01-22 03:39:16 +03:00
|
|
|
#include "opt_user_ldt.h"
|
1998-01-16 01:25:52 +03:00
|
|
|
|
1995-04-08 02:29:34 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/signalvar.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/map.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/reboot.h>
|
|
|
|
#include <sys/conf.h>
|
1996-10-12 06:20:37 +04:00
|
|
|
#include <sys/exec.h>
|
1995-04-08 02:29:34 +04:00
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/callout.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/msgbuf.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/syscallargs.h>
|
1995-08-28 00:56:38 +04:00
|
|
|
#include <sys/filedesc.h>
|
1998-01-24 16:19:46 +03:00
|
|
|
#include <sys/exec_elf.h>
|
1995-05-07 06:59:30 +04:00
|
|
|
|
1995-04-08 02:29:34 +04:00
|
|
|
#include <compat/linux/linux_types.h>
|
1995-08-14 05:38:24 +04:00
|
|
|
#include <compat/linux/linux_signal.h>
|
1995-04-08 02:29:34 +04:00
|
|
|
#include <compat/linux/linux_syscallargs.h>
|
1995-05-07 06:59:30 +04:00
|
|
|
#include <compat/linux/linux_util.h>
|
1996-05-03 23:41:56 +04:00
|
|
|
#include <compat/linux/linux_ioctl.h>
|
1998-01-24 15:45:16 +03:00
|
|
|
#include <compat/linux/linux_exec.h>
|
1995-04-08 02:29:34 +04:00
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/cpufunc.h>
|
|
|
|
#include <machine/psl.h>
|
|
|
|
#include <machine/reg.h>
|
1995-05-07 06:59:30 +04:00
|
|
|
#include <machine/segments.h>
|
1995-04-08 02:29:34 +04:00
|
|
|
#include <machine/specialreg.h>
|
1995-05-07 06:59:30 +04:00
|
|
|
#include <machine/sysarch.h>
|
1996-04-11 11:47:33 +04:00
|
|
|
#include <machine/vm86.h>
|
1997-10-16 08:23:36 +04:00
|
|
|
#include <machine/vmparam.h>
|
1995-04-08 02:29:34 +04:00
|
|
|
#include <machine/linux_machdep.h>
|
|
|
|
|
1995-08-28 00:56:38 +04:00
|
|
|
/*
|
|
|
|
* To see whether pcvt is configured (for virtual console ioctl calls).
|
|
|
|
*/
|
1996-10-29 05:19:25 +03:00
|
|
|
#ifndef NVT
|
1995-08-28 00:56:38 +04:00
|
|
|
#include "vt.h"
|
1996-10-29 05:19:25 +03:00
|
|
|
#endif
|
1995-08-28 00:56:38 +04:00
|
|
|
#if NVT > 0
|
|
|
|
#include <arch/i386/isa/pcvt/pcvt_ioctl.h>
|
|
|
|
#endif
|
|
|
|
|
1998-06-12 02:26:13 +04:00
|
|
|
#include "wsdisplay.h"
|
|
|
|
#if (NWSDISPLAY > 0)
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <dev/wscons/wsdisplay_usl_io.h>
|
|
|
|
#include "opt_xserver.h"
|
|
|
|
#endif
|
|
|
|
|
1996-05-03 23:41:56 +04:00
|
|
|
#ifdef USER_LDT
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
int linux_read_ldt __P((struct proc *, struct linux_sys_modify_ldt_args *,
|
|
|
|
register_t *));
|
|
|
|
int linux_write_ldt __P((struct proc *, struct linux_sys_modify_ldt_args *,
|
|
|
|
register_t *));
|
|
|
|
#endif
|
|
|
|
|
1995-04-08 02:29:34 +04:00
|
|
|
/*
|
|
|
|
* Deal with some i386-specific things in the Linux emulation code.
|
|
|
|
*/
|
|
|
|
|
1998-01-24 15:42:22 +03:00
|
|
|
void
|
|
|
|
linux_setregs(p, epp, stack)
|
|
|
|
struct proc *p;
|
|
|
|
struct exec_package *epp;
|
|
|
|
u_long stack;
|
|
|
|
{
|
1998-01-24 16:19:46 +03:00
|
|
|
register struct pcb *pcb = &p->p_addr->u_pcb;
|
1998-01-24 15:42:22 +03:00
|
|
|
|
1998-01-24 16:19:46 +03:00
|
|
|
pcb->pcb_savefpu.sv_env.en_cw = __Linux_NPXCW__;
|
1998-01-24 15:42:22 +03:00
|
|
|
setregs(p, epp, stack);
|
|
|
|
}
|
|
|
|
|
1995-04-08 02:29:34 +04:00
|
|
|
/*
|
|
|
|
* Send an interrupt to process.
|
|
|
|
*
|
|
|
|
* Stack is set up to allow sigcode stored
|
|
|
|
* in u. to call routine, followed by kcall
|
|
|
|
* to sigreturn routine below. After sigreturn
|
|
|
|
* resets the signal mask, the stack, and the
|
|
|
|
* frame pointer, it returns to the user
|
|
|
|
* specified pc, psl.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
linux_sendsig(catcher, sig, mask, code)
|
|
|
|
sig_t catcher;
|
1998-09-11 16:50:05 +04:00
|
|
|
int sig;
|
|
|
|
sigset_t *mask;
|
1995-04-08 02:29:34 +04:00
|
|
|
u_long code;
|
|
|
|
{
|
|
|
|
register struct proc *p = curproc;
|
|
|
|
register struct trapframe *tf;
|
|
|
|
struct linux_sigframe *fp, frame;
|
|
|
|
struct sigacts *psp = p->p_sigacts;
|
|
|
|
|
1995-05-01 12:06:22 +04:00
|
|
|
tf = p->p_md.md_regs;
|
1995-04-08 02:29:34 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
/* Allocate space for the signal handler context. */
|
|
|
|
/* XXX Linux doesn't support the signal stack. */
|
|
|
|
fp = (struct linux_sigframe *)tf->tf_esp;
|
|
|
|
fp--;
|
1995-04-08 02:29:34 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
/* Build stack frame for signal trampoline. */
|
1995-05-07 06:59:30 +04:00
|
|
|
frame.sf_handler = catcher;
|
1998-09-11 16:50:05 +04:00
|
|
|
frame.sf_sig = native_to_linux_sig[sig];
|
1995-04-08 02:29:34 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
/* Save register context. */
|
1995-05-01 18:15:07 +04:00
|
|
|
#ifdef VM86
|
|
|
|
if (tf->tf_eflags & PSL_VM) {
|
1995-05-07 06:59:30 +04:00
|
|
|
frame.sf_sc.sc_gs = tf->tf_vm86_gs;
|
|
|
|
frame.sf_sc.sc_fs = tf->tf_vm86_fs;
|
|
|
|
frame.sf_sc.sc_es = tf->tf_vm86_es;
|
|
|
|
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
|
1996-04-11 11:47:33 +04:00
|
|
|
frame.sf_sc.sc_eflags = get_vflags(p);
|
1995-05-01 18:15:07 +04:00
|
|
|
} else
|
1995-09-08 11:57:15 +04:00
|
|
|
#endif
|
1995-05-01 18:15:07 +04:00
|
|
|
{
|
1995-05-07 06:59:30 +04:00
|
|
|
__asm("movl %%gs,%w0" : "=r" (frame.sf_sc.sc_gs));
|
|
|
|
__asm("movl %%fs,%w0" : "=r" (frame.sf_sc.sc_fs));
|
|
|
|
frame.sf_sc.sc_es = tf->tf_es;
|
|
|
|
frame.sf_sc.sc_ds = tf->tf_ds;
|
1996-04-11 11:47:33 +04:00
|
|
|
frame.sf_sc.sc_eflags = tf->tf_eflags;
|
1995-05-01 18:15:07 +04:00
|
|
|
}
|
1996-04-11 11:47:33 +04:00
|
|
|
frame.sf_sc.sc_edi = tf->tf_edi;
|
|
|
|
frame.sf_sc.sc_esi = tf->tf_esi;
|
|
|
|
frame.sf_sc.sc_ebp = tf->tf_ebp;
|
|
|
|
frame.sf_sc.sc_ebx = tf->tf_ebx;
|
|
|
|
frame.sf_sc.sc_edx = tf->tf_edx;
|
|
|
|
frame.sf_sc.sc_ecx = tf->tf_ecx;
|
|
|
|
frame.sf_sc.sc_eax = tf->tf_eax;
|
|
|
|
frame.sf_sc.sc_eip = tf->tf_eip;
|
|
|
|
frame.sf_sc.sc_cs = tf->tf_cs;
|
1995-05-07 06:59:30 +04:00
|
|
|
frame.sf_sc.sc_esp_at_signal = tf->tf_esp;
|
1996-04-11 11:47:33 +04:00
|
|
|
frame.sf_sc.sc_ss = tf->tf_ss;
|
|
|
|
frame.sf_sc.sc_err = tf->tf_err;
|
1995-05-07 06:59:30 +04:00
|
|
|
frame.sf_sc.sc_trapno = tf->tf_trapno;
|
1995-04-08 02:29:34 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
/* Save signal stack. */
|
|
|
|
/* XXX Linux doesn't support the signal stack. */
|
|
|
|
|
|
|
|
/* Save signal mask. */
|
|
|
|
native_to_linux_sigset(mask, &frame.sf_sc.sc_mask);
|
|
|
|
|
1995-04-08 02:29:34 +04:00
|
|
|
if (copyout(&frame, fp, sizeof(frame)) != 0) {
|
|
|
|
/*
|
|
|
|
* Process has trashed its stack; give it an illegal
|
|
|
|
* instruction to halt it in its tracks.
|
|
|
|
*/
|
|
|
|
sigexit(p, SIGILL);
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build context to run handler in.
|
|
|
|
*/
|
1996-04-11 11:47:33 +04:00
|
|
|
tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
|
|
|
|
tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
|
1998-09-11 16:50:05 +04:00
|
|
|
tf->tf_eip = (int)psp->ps_sigcode;
|
1995-10-10 07:54:18 +03:00
|
|
|
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
|
1996-04-18 12:36:20 +04:00
|
|
|
tf->tf_eflags &= ~(PSL_T|PSL_VM|PSL_AC);
|
1996-04-11 11:47:33 +04:00
|
|
|
tf->tf_esp = (int)fp;
|
1995-10-10 07:54:18 +03:00
|
|
|
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
|
1998-09-11 16:50:05 +04:00
|
|
|
|
|
|
|
/* Remember that we're now on the signal stack. */
|
|
|
|
/* XXX Linux doesn't support the signal stack. */
|
1995-04-08 02:29:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* System call to cleanup state after a signal
|
|
|
|
* has been taken. Reset signal mask and
|
|
|
|
* stack state from context left by sendsig (above).
|
|
|
|
* Return to previous pc and psl as specified by
|
|
|
|
* context left by sendsig. Check carefully to
|
|
|
|
* make sure that the user has not modified the
|
|
|
|
* psl to gain improper privileges or to cause
|
|
|
|
* a machine fault.
|
|
|
|
*/
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
linux_sys_sigreturn(p, v, retval)
|
1995-04-08 02:29:34 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1995-04-08 02:29:34 +04:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_sigreturn_args /* {
|
1995-09-20 02:53:47 +04:00
|
|
|
syscallarg(struct linux_sigcontext *) scp;
|
|
|
|
} */ *uap = v;
|
1995-04-08 02:29:34 +04:00
|
|
|
struct linux_sigcontext *scp, context;
|
|
|
|
register struct trapframe *tf;
|
1998-09-11 16:50:05 +04:00
|
|
|
sigset_t mask;
|
1995-04-08 02:29:34 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The trampoline code hands us the context.
|
|
|
|
* It is unsafe to keep track of it ourselves, in the event that a
|
|
|
|
* program jumps out of a signal handler.
|
|
|
|
*/
|
|
|
|
scp = SCARG(uap, scp);
|
|
|
|
if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0)
|
|
|
|
return (EFAULT);
|
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
/* Restore register context. */
|
|
|
|
tf = p->p_md.md_regs;
|
1995-05-01 18:15:07 +04:00
|
|
|
#ifdef VM86
|
1995-05-07 06:59:30 +04:00
|
|
|
if (context.sc_eflags & PSL_VM) {
|
|
|
|
tf->tf_vm86_gs = context.sc_gs;
|
|
|
|
tf->tf_vm86_fs = context.sc_fs;
|
|
|
|
tf->tf_vm86_es = context.sc_es;
|
|
|
|
tf->tf_vm86_ds = context.sc_ds;
|
1996-04-11 11:47:33 +04:00
|
|
|
set_vflags(p, context.sc_eflags);
|
1995-05-01 18:15:07 +04:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
1996-04-11 11:47:33 +04:00
|
|
|
/*
|
|
|
|
* Check for security violations. If we're returning to
|
|
|
|
* protected mode, the CPU will validate the segment registers
|
|
|
|
* automatically and generate a trap on violations. We handle
|
|
|
|
* the trap, rather than doing all of the checking here.
|
|
|
|
*/
|
|
|
|
if (((context.sc_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
|
|
|
|
!USERMODE(context.sc_cs, context.sc_eflags))
|
|
|
|
return (EINVAL);
|
|
|
|
|
1995-05-01 18:15:07 +04:00
|
|
|
/* %fs and %gs were restored by the trampoline. */
|
1995-05-07 06:59:30 +04:00
|
|
|
tf->tf_es = context.sc_es;
|
|
|
|
tf->tf_ds = context.sc_ds;
|
1996-04-11 11:47:33 +04:00
|
|
|
tf->tf_eflags = context.sc_eflags;
|
1995-05-01 18:15:07 +04:00
|
|
|
}
|
1996-04-11 11:47:33 +04:00
|
|
|
tf->tf_edi = context.sc_edi;
|
|
|
|
tf->tf_esi = context.sc_esi;
|
|
|
|
tf->tf_ebp = context.sc_ebp;
|
|
|
|
tf->tf_ebx = context.sc_ebx;
|
|
|
|
tf->tf_edx = context.sc_edx;
|
|
|
|
tf->tf_ecx = context.sc_ecx;
|
|
|
|
tf->tf_eax = context.sc_eax;
|
|
|
|
tf->tf_eip = context.sc_eip;
|
|
|
|
tf->tf_cs = context.sc_cs;
|
|
|
|
tf->tf_esp = context.sc_esp_at_signal;
|
|
|
|
tf->tf_ss = context.sc_ss;
|
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
/* Restore signal stack. */
|
1996-04-11 11:47:33 +04:00
|
|
|
p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
|
1998-09-11 16:50:05 +04:00
|
|
|
|
|
|
|
/* Restore signal mask. */
|
|
|
|
linux_to_native_sigset(&context.sc_mask, &mask);
|
|
|
|
(void) sigprocmask1(p, SIG_SETMASK, &mask, 0);
|
1995-04-08 02:29:34 +04:00
|
|
|
|
|
|
|
return (EJUSTRETURN);
|
|
|
|
}
|
1995-05-06 22:17:15 +04:00
|
|
|
|
1995-05-07 06:59:30 +04:00
|
|
|
#ifdef USER_LDT
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_read_ldt(p, uap, retval)
|
|
|
|
struct proc *p;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_modify_ldt_args /* {
|
1995-05-07 06:59:30 +04:00
|
|
|
syscallarg(int) func;
|
|
|
|
syscallarg(void *) ptr;
|
|
|
|
syscallarg(size_t) bytecount;
|
|
|
|
} */ *uap;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct i386_get_ldt_args gl;
|
|
|
|
int error;
|
|
|
|
caddr_t sg;
|
|
|
|
char *parms;
|
|
|
|
|
1995-06-25 00:36:28 +04:00
|
|
|
sg = stackgap_init(p->p_emul);
|
1995-05-07 06:59:30 +04:00
|
|
|
|
|
|
|
gl.start = 0;
|
|
|
|
gl.desc = SCARG(uap, ptr);
|
|
|
|
gl.num = SCARG(uap, bytecount) / sizeof(union descriptor);
|
|
|
|
|
|
|
|
parms = stackgap_alloc(&sg, sizeof(gl));
|
|
|
|
|
1996-05-03 23:41:56 +04:00
|
|
|
if ((error = copyout(&gl, parms, sizeof(gl))) != 0)
|
1995-05-07 06:59:30 +04:00
|
|
|
return (error);
|
|
|
|
|
1996-05-03 23:41:56 +04:00
|
|
|
if ((error = i386_get_ldt(p, parms, retval)) != 0)
|
1995-05-07 06:59:30 +04:00
|
|
|
return (error);
|
|
|
|
|
|
|
|
*retval *= sizeof(union descriptor);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct linux_ldt_info {
|
|
|
|
u_int entry_number;
|
|
|
|
u_long base_addr;
|
|
|
|
u_int limit;
|
|
|
|
u_int seg_32bit:1;
|
|
|
|
u_int contents:2;
|
|
|
|
u_int read_exec_only:1;
|
|
|
|
u_int limit_in_pages:1;
|
|
|
|
u_int seg_not_present:1;
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_write_ldt(p, uap, retval)
|
|
|
|
struct proc *p;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_modify_ldt_args /* {
|
1995-05-07 06:59:30 +04:00
|
|
|
syscallarg(int) func;
|
|
|
|
syscallarg(void *) ptr;
|
|
|
|
syscallarg(size_t) bytecount;
|
|
|
|
} */ *uap;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct linux_ldt_info ldt_info;
|
|
|
|
struct segment_descriptor sd;
|
|
|
|
struct i386_set_ldt_args sl;
|
|
|
|
int error;
|
|
|
|
caddr_t sg;
|
|
|
|
char *parms;
|
|
|
|
|
|
|
|
if (SCARG(uap, bytecount) != sizeof(ldt_info))
|
|
|
|
return (EINVAL);
|
1996-05-03 23:41:56 +04:00
|
|
|
if ((error = copyin(SCARG(uap, ptr), &ldt_info, sizeof(ldt_info))) != 0)
|
1995-05-07 06:59:30 +04:00
|
|
|
return error;
|
|
|
|
if (ldt_info.contents == 3)
|
|
|
|
return (EINVAL);
|
|
|
|
|
1995-06-25 00:36:28 +04:00
|
|
|
sg = stackgap_init(p->p_emul);
|
1995-05-07 06:59:30 +04:00
|
|
|
|
|
|
|
sd.sd_lobase = ldt_info.base_addr & 0xffffff;
|
|
|
|
sd.sd_hibase = (ldt_info.base_addr >> 24) & 0xff;
|
|
|
|
sd.sd_lolimit = ldt_info.limit & 0xffff;
|
|
|
|
sd.sd_hilimit = (ldt_info.limit >> 16) & 0xf;
|
|
|
|
sd.sd_type =
|
|
|
|
16 | (ldt_info.contents << 2) | (!ldt_info.read_exec_only << 1);
|
|
|
|
sd.sd_dpl = SEL_UPL;
|
|
|
|
sd.sd_p = !ldt_info.seg_not_present;
|
|
|
|
sd.sd_def32 = ldt_info.seg_32bit;
|
|
|
|
sd.sd_gran = ldt_info.limit_in_pages;
|
|
|
|
|
|
|
|
sl.start = ldt_info.entry_number;
|
|
|
|
sl.desc = stackgap_alloc(&sg, sizeof(sd));
|
|
|
|
sl.num = 1;
|
|
|
|
|
1995-05-07 07:27:37 +04:00
|
|
|
#if 0
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("linux_write_ldt: idx=%d, base=%x, limit=%x\n",
|
1995-05-07 06:59:30 +04:00
|
|
|
ldt_info.entry_number, ldt_info.base_addr, ldt_info.limit);
|
1995-05-07 07:27:37 +04:00
|
|
|
#endif
|
1995-05-07 06:59:30 +04:00
|
|
|
|
|
|
|
parms = stackgap_alloc(&sg, sizeof(sl));
|
|
|
|
|
1996-05-03 23:41:56 +04:00
|
|
|
if ((error = copyout(&sd, sl.desc, sizeof(sd))) != 0)
|
1995-05-07 06:59:30 +04:00
|
|
|
return (error);
|
1996-05-03 23:41:56 +04:00
|
|
|
if ((error = copyout(&sl, parms, sizeof(sl))) != 0)
|
1995-05-07 06:59:30 +04:00
|
|
|
return (error);
|
|
|
|
|
1996-05-03 23:41:56 +04:00
|
|
|
if ((error = i386_set_ldt(p, parms, retval)) != 0)
|
1995-05-07 06:59:30 +04:00
|
|
|
return (error);
|
|
|
|
|
|
|
|
*retval = 0;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* USER_LDT */
|
|
|
|
|
1995-05-06 22:17:15 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
linux_sys_modify_ldt(p, v, retval)
|
1995-05-06 22:17:15 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_modify_ldt_args /* {
|
1995-05-06 22:17:15 +04:00
|
|
|
syscallarg(int) func;
|
|
|
|
syscallarg(void *) ptr;
|
|
|
|
syscallarg(size_t) bytecount;
|
1995-09-20 02:53:47 +04:00
|
|
|
} */ *uap = v;
|
1995-05-06 22:17:15 +04:00
|
|
|
|
|
|
|
switch (SCARG(uap, func)) {
|
1995-05-07 06:59:30 +04:00
|
|
|
#ifdef USER_LDT
|
1995-05-06 22:17:15 +04:00
|
|
|
case 0:
|
1995-05-07 06:59:30 +04:00
|
|
|
return (linux_read_ldt(p, uap, retval));
|
|
|
|
|
1995-05-06 22:17:15 +04:00
|
|
|
case 1:
|
1995-05-07 06:59:30 +04:00
|
|
|
return (linux_write_ldt(p, uap, retval));
|
|
|
|
#endif /* USER_LDT */
|
|
|
|
|
1995-05-06 22:17:15 +04:00
|
|
|
default:
|
|
|
|
return (ENOSYS);
|
|
|
|
}
|
|
|
|
}
|
1995-08-28 00:56:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX Pathetic hack to make svgalib work. This will fake the major
|
|
|
|
* device number of an opened VT so that svgalib likes it. grmbl.
|
|
|
|
* Should probably do it 'wrong the right way' and use a mapping
|
|
|
|
* array for all major device numbers, and map linux_mknod too.
|
|
|
|
*/
|
|
|
|
dev_t
|
|
|
|
linux_fakedev(dev)
|
|
|
|
dev_t dev;
|
|
|
|
{
|
1998-06-12 02:26:13 +04:00
|
|
|
#if (NVT > 0)
|
|
|
|
if (major(dev) == NETBSD_PCCONS_MAJOR)
|
1995-09-08 01:55:43 +04:00
|
|
|
return makedev(LINUX_CONS_MAJOR, (minor(dev) + 1));
|
1998-06-12 02:26:13 +04:00
|
|
|
#endif
|
|
|
|
#if (NWSDISPLAY > 0)
|
|
|
|
if (major(dev) == NETBSD_WSCONS_MAJOR)
|
|
|
|
return makedev(LINUX_CONS_MAJOR, (minor(dev) + 1));
|
|
|
|
#endif
|
1995-08-28 00:56:38 +04:00
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
1998-06-12 02:26:13 +04:00
|
|
|
#if (NWSDISPLAY > 0) && defined(XSERVER)
|
|
|
|
/*
|
|
|
|
* That's not complete, but enough to get an X server running.
|
|
|
|
*/
|
|
|
|
#define NR_KEYS 128
|
|
|
|
static u_short plain_map[NR_KEYS] = {
|
|
|
|
0x0200, 0x001b, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036,
|
|
|
|
0x0037, 0x0038, 0x0039, 0x0030, 0x002d, 0x003d, 0x007f, 0x0009,
|
|
|
|
0x0b71, 0x0b77, 0x0b65, 0x0b72, 0x0b74, 0x0b79, 0x0b75, 0x0b69,
|
|
|
|
0x0b6f, 0x0b70, 0x005b, 0x005d, 0x0201, 0x0702, 0x0b61, 0x0b73,
|
|
|
|
0x0b64, 0x0b66, 0x0b67, 0x0b68, 0x0b6a, 0x0b6b, 0x0b6c, 0x003b,
|
|
|
|
0x0027, 0x0060, 0x0700, 0x005c, 0x0b7a, 0x0b78, 0x0b63, 0x0b76,
|
|
|
|
0x0b62, 0x0b6e, 0x0b6d, 0x002c, 0x002e, 0x002f, 0x0700, 0x030c,
|
|
|
|
0x0703, 0x0020, 0x0207, 0x0100, 0x0101, 0x0102, 0x0103, 0x0104,
|
|
|
|
0x0105, 0x0106, 0x0107, 0x0108, 0x0109, 0x0208, 0x0209, 0x0307,
|
|
|
|
0x0308, 0x0309, 0x030b, 0x0304, 0x0305, 0x0306, 0x030a, 0x0301,
|
|
|
|
0x0302, 0x0303, 0x0300, 0x0310, 0x0206, 0x0200, 0x003c, 0x010a,
|
|
|
|
0x010b, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200,
|
|
|
|
0x030e, 0x0702, 0x030d, 0x001c, 0x0701, 0x0205, 0x0114, 0x0603,
|
|
|
|
0x0118, 0x0601, 0x0602, 0x0117, 0x0600, 0x0119, 0x0115, 0x0116,
|
|
|
|
0x011a, 0x010c, 0x010d, 0x011b, 0x011c, 0x0110, 0x0311, 0x011d,
|
|
|
|
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200,
|
|
|
|
}, shift_map[NR_KEYS] = {
|
|
|
|
0x0200, 0x001b, 0x0021, 0x0040, 0x0023, 0x0024, 0x0025, 0x005e,
|
|
|
|
0x0026, 0x002a, 0x0028, 0x0029, 0x005f, 0x002b, 0x007f, 0x0009,
|
|
|
|
0x0b51, 0x0b57, 0x0b45, 0x0b52, 0x0b54, 0x0b59, 0x0b55, 0x0b49,
|
|
|
|
0x0b4f, 0x0b50, 0x007b, 0x007d, 0x0201, 0x0702, 0x0b41, 0x0b53,
|
|
|
|
0x0b44, 0x0b46, 0x0b47, 0x0b48, 0x0b4a, 0x0b4b, 0x0b4c, 0x003a,
|
|
|
|
0x0022, 0x007e, 0x0700, 0x007c, 0x0b5a, 0x0b58, 0x0b43, 0x0b56,
|
|
|
|
0x0b42, 0x0b4e, 0x0b4d, 0x003c, 0x003e, 0x003f, 0x0700, 0x030c,
|
|
|
|
0x0703, 0x0020, 0x0207, 0x010a, 0x010b, 0x010c, 0x010d, 0x010e,
|
|
|
|
0x010f, 0x0110, 0x0111, 0x0112, 0x0113, 0x0213, 0x0203, 0x0307,
|
|
|
|
0x0308, 0x0309, 0x030b, 0x0304, 0x0305, 0x0306, 0x030a, 0x0301,
|
|
|
|
0x0302, 0x0303, 0x0300, 0x0310, 0x0206, 0x0200, 0x003e, 0x010a,
|
|
|
|
0x010b, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200,
|
|
|
|
0x030e, 0x0702, 0x030d, 0x0200, 0x0701, 0x0205, 0x0114, 0x0603,
|
|
|
|
0x020b, 0x0601, 0x0602, 0x0117, 0x0600, 0x020a, 0x0115, 0x0116,
|
|
|
|
0x011a, 0x010c, 0x010d, 0x011b, 0x011c, 0x0110, 0x0311, 0x011d,
|
|
|
|
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200,
|
|
|
|
}, altgr_map[NR_KEYS] = {
|
|
|
|
0x0200, 0x0200, 0x0200, 0x0040, 0x0200, 0x0024, 0x0200, 0x0200,
|
|
|
|
0x007b, 0x005b, 0x005d, 0x007d, 0x005c, 0x0200, 0x0200, 0x0200,
|
|
|
|
0x0b71, 0x0b77, 0x0918, 0x0b72, 0x0b74, 0x0b79, 0x0b75, 0x0b69,
|
|
|
|
0x0b6f, 0x0b70, 0x0200, 0x007e, 0x0201, 0x0702, 0x0914, 0x0b73,
|
|
|
|
0x0917, 0x0919, 0x0b67, 0x0b68, 0x0b6a, 0x0b6b, 0x0b6c, 0x0200,
|
|
|
|
0x0200, 0x0200, 0x0700, 0x0200, 0x0b7a, 0x0b78, 0x0916, 0x0b76,
|
|
|
|
0x0915, 0x0b6e, 0x0b6d, 0x0200, 0x0200, 0x0200, 0x0700, 0x030c,
|
|
|
|
0x0703, 0x0200, 0x0207, 0x050c, 0x050d, 0x050e, 0x050f, 0x0510,
|
|
|
|
0x0511, 0x0512, 0x0513, 0x0514, 0x0515, 0x0208, 0x0202, 0x0911,
|
|
|
|
0x0912, 0x0913, 0x030b, 0x090e, 0x090f, 0x0910, 0x030a, 0x090b,
|
|
|
|
0x090c, 0x090d, 0x090a, 0x0310, 0x0206, 0x0200, 0x007c, 0x0516,
|
|
|
|
0x0517, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200,
|
|
|
|
0x030e, 0x0702, 0x030d, 0x0200, 0x0701, 0x0205, 0x0114, 0x0603,
|
|
|
|
0x0118, 0x0601, 0x0602, 0x0117, 0x0600, 0x0119, 0x0115, 0x0116,
|
|
|
|
0x011a, 0x010c, 0x010d, 0x011b, 0x011c, 0x0110, 0x0311, 0x011d,
|
|
|
|
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200,
|
|
|
|
}, ctrl_map[NR_KEYS] = {
|
|
|
|
0x0200, 0x0200, 0x0200, 0x0000, 0x001b, 0x001c, 0x001d, 0x001e,
|
|
|
|
0x001f, 0x007f, 0x0200, 0x0200, 0x001f, 0x0200, 0x0008, 0x0200,
|
|
|
|
0x0011, 0x0017, 0x0005, 0x0012, 0x0014, 0x0019, 0x0015, 0x0009,
|
|
|
|
0x000f, 0x0010, 0x001b, 0x001d, 0x0201, 0x0702, 0x0001, 0x0013,
|
|
|
|
0x0004, 0x0006, 0x0007, 0x0008, 0x000a, 0x000b, 0x000c, 0x0200,
|
|
|
|
0x0007, 0x0000, 0x0700, 0x001c, 0x001a, 0x0018, 0x0003, 0x0016,
|
|
|
|
0x0002, 0x000e, 0x000d, 0x0200, 0x020e, 0x007f, 0x0700, 0x030c,
|
|
|
|
0x0703, 0x0000, 0x0207, 0x0100, 0x0101, 0x0102, 0x0103, 0x0104,
|
|
|
|
0x0105, 0x0106, 0x0107, 0x0108, 0x0109, 0x0208, 0x0204, 0x0307,
|
|
|
|
0x0308, 0x0309, 0x030b, 0x0304, 0x0305, 0x0306, 0x030a, 0x0301,
|
|
|
|
0x0302, 0x0303, 0x0300, 0x0310, 0x0206, 0x0200, 0x0200, 0x010a,
|
|
|
|
0x010b, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200,
|
|
|
|
0x030e, 0x0702, 0x030d, 0x001c, 0x0701, 0x0205, 0x0114, 0x0603,
|
|
|
|
0x0118, 0x0601, 0x0602, 0x0117, 0x0600, 0x0119, 0x0115, 0x0116,
|
|
|
|
0x011a, 0x010c, 0x010d, 0x011b, 0x011c, 0x0110, 0x0311, 0x011d,
|
|
|
|
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200,
|
|
|
|
};
|
|
|
|
|
|
|
|
u_short *linux_keytabs[] = {
|
|
|
|
plain_map, shift_map, altgr_map, altgr_map, ctrl_map
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1995-08-28 00:56:38 +04:00
|
|
|
/*
|
|
|
|
* We come here in a last attempt to satisfy a Linux ioctl() call
|
|
|
|
*/
|
|
|
|
int
|
1995-09-20 02:53:47 +04:00
|
|
|
linux_machdepioctl(p, v, retval)
|
1995-08-28 00:56:38 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_ioctl_args /* {
|
1995-08-28 00:56:38 +04:00
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(u_long) com;
|
|
|
|
syscallarg(caddr_t) data;
|
1995-09-20 02:53:47 +04:00
|
|
|
} */ *uap = v;
|
1996-05-03 23:41:56 +04:00
|
|
|
struct sys_ioctl_args bia;
|
1995-08-31 13:33:10 +04:00
|
|
|
u_long com;
|
1998-06-12 02:26:13 +04:00
|
|
|
#if (NVT > 0) || (NWSDISPLAY > 0)
|
1996-05-03 23:41:56 +04:00
|
|
|
int error;
|
1995-08-28 00:56:38 +04:00
|
|
|
struct vt_mode lvt;
|
|
|
|
caddr_t bvtp, sg;
|
1995-08-31 13:33:10 +04:00
|
|
|
#endif
|
1998-06-12 02:26:13 +04:00
|
|
|
#if (NWSDISPLAY > 0) && defined(XSERVER)
|
|
|
|
struct kbentry kbe;
|
|
|
|
#endif
|
1995-08-28 00:56:38 +04:00
|
|
|
|
|
|
|
SCARG(&bia, fd) = SCARG(uap, fd);
|
|
|
|
SCARG(&bia, data) = SCARG(uap, data);
|
|
|
|
com = SCARG(uap, com);
|
|
|
|
|
|
|
|
switch (com) {
|
1998-06-12 02:26:13 +04:00
|
|
|
#if (NVT > 0) || (NWSDISPLAY > 0)
|
1995-08-28 00:56:38 +04:00
|
|
|
case LINUX_KDGKBMODE:
|
1995-10-09 01:45:20 +03:00
|
|
|
com = KDGKBMODE;
|
|
|
|
break;
|
1995-08-28 00:56:38 +04:00
|
|
|
case LINUX_KDSKBMODE:
|
|
|
|
com = KDSKBMODE;
|
|
|
|
if ((unsigned)SCARG(uap, data) == LINUX_K_MEDIUMRAW)
|
|
|
|
SCARG(&bia, data) = (caddr_t)K_RAW;
|
|
|
|
break;
|
|
|
|
case LINUX_KDMKTONE:
|
|
|
|
com = KDMKTONE;
|
|
|
|
break;
|
|
|
|
case LINUX_KDSETMODE:
|
|
|
|
com = KDSETMODE;
|
|
|
|
break;
|
|
|
|
case LINUX_KDENABIO:
|
|
|
|
com = KDENABIO;
|
|
|
|
break;
|
|
|
|
case LINUX_KDDISABIO:
|
|
|
|
com = KDDISABIO;
|
|
|
|
break;
|
|
|
|
case LINUX_KDGETLED:
|
|
|
|
com = KDGETLED;
|
|
|
|
break;
|
|
|
|
case LINUX_KDSETLED:
|
|
|
|
com = KDSETLED;
|
|
|
|
break;
|
|
|
|
case LINUX_VT_OPENQRY:
|
|
|
|
com = VT_OPENQRY;
|
|
|
|
break;
|
|
|
|
case LINUX_VT_GETMODE:
|
|
|
|
SCARG(&bia, com) = VT_GETMODE;
|
1995-10-07 09:25:19 +03:00
|
|
|
if ((error = sys_ioctl(p, &bia, retval)))
|
1995-08-28 00:56:38 +04:00
|
|
|
return error;
|
|
|
|
if ((error = copyin(SCARG(uap, data), (caddr_t)&lvt,
|
|
|
|
sizeof (struct vt_mode))))
|
|
|
|
return error;
|
1998-09-11 16:50:05 +04:00
|
|
|
lvt.relsig = native_to_linux_sig[lvt.relsig];
|
|
|
|
lvt.acqsig = native_to_linux_sig[lvt.acqsig];
|
|
|
|
lvt.frsig = native_to_linux_sig[lvt.frsig];
|
1995-08-28 00:56:38 +04:00
|
|
|
return copyout((caddr_t)&lvt, SCARG(uap, data),
|
|
|
|
sizeof (struct vt_mode));
|
|
|
|
case LINUX_VT_SETMODE:
|
|
|
|
com = VT_SETMODE;
|
|
|
|
if ((error = copyin(SCARG(uap, data), (caddr_t)&lvt,
|
|
|
|
sizeof (struct vt_mode))))
|
|
|
|
return error;
|
1998-09-11 16:50:05 +04:00
|
|
|
lvt.relsig = linux_to_native_sig[lvt.relsig];
|
|
|
|
lvt.acqsig = linux_to_native_sig[lvt.acqsig];
|
|
|
|
lvt.frsig = linux_to_native_sig[lvt.frsig];
|
1995-08-28 00:56:38 +04:00
|
|
|
sg = stackgap_init(p->p_emul);
|
|
|
|
bvtp = stackgap_alloc(&sg, sizeof (struct vt_mode));
|
|
|
|
if ((error = copyout(&lvt, bvtp, sizeof (struct vt_mode))))
|
|
|
|
return error;
|
|
|
|
SCARG(&bia, data) = bvtp;
|
|
|
|
break;
|
|
|
|
case LINUX_VT_RELDISP:
|
|
|
|
com = VT_RELDISP;
|
|
|
|
break;
|
|
|
|
case LINUX_VT_ACTIVATE:
|
|
|
|
com = VT_ACTIVATE;
|
|
|
|
break;
|
|
|
|
case LINUX_VT_WAITACTIVE:
|
|
|
|
com = VT_WAITACTIVE;
|
|
|
|
break;
|
1998-06-12 02:26:13 +04:00
|
|
|
#endif
|
|
|
|
#if (NWSDISPLAY > 0)
|
|
|
|
case LINUX_VT_GETSTATE:
|
|
|
|
com = VT_GETSTATE;
|
|
|
|
break;
|
|
|
|
#ifdef XSERVER
|
|
|
|
case LINUX_KDGKBTYPE:
|
|
|
|
/* This is what Linux does. */
|
|
|
|
return (subyte(SCARG(uap, data), KB_101));
|
|
|
|
case LINUX_KDGKBENT:
|
|
|
|
/*
|
|
|
|
* The Linux KDGKBENT ioctl is different from the
|
|
|
|
* SYSV original. So we handle it in machdep code.
|
|
|
|
* XXX We should use keyboard mapping information
|
|
|
|
* from wsdisplay, but this would be expensive.
|
|
|
|
*/
|
|
|
|
if ((error = copyin(SCARG(uap, data), &kbe,
|
|
|
|
sizeof(struct kbentry))))
|
|
|
|
return (error);
|
|
|
|
if (kbe.kb_table >= sizeof(linux_keytabs) / sizeof(u_short *)
|
|
|
|
|| kbe.kb_index >= NR_KEYS)
|
|
|
|
return (EINVAL);
|
|
|
|
kbe.kb_value = linux_keytabs[kbe.kb_table][kbe.kb_index];
|
|
|
|
return (copyout(&kbe, SCARG(uap, data),
|
|
|
|
sizeof(struct kbentry)));
|
|
|
|
#endif
|
1995-08-28 00:56:38 +04:00
|
|
|
#endif
|
|
|
|
default:
|
1996-10-13 07:19:38 +04:00
|
|
|
printf("linux_machdepioctl: invalid ioctl %08lx\n", com);
|
1995-08-28 00:56:38 +04:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
SCARG(&bia, com) = com;
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_ioctl(p, &bia, retval);
|
1995-08-28 00:56:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set I/O permissions for a process. Just set the maximum level
|
|
|
|
* right away (ignoring the argument), otherwise we would have
|
|
|
|
* to rely on I/O permission maps, which are not implemented.
|
|
|
|
*/
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
linux_sys_iopl(p, v, retval)
|
1995-08-28 00:56:38 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1995-08-28 00:56:38 +04:00
|
|
|
register_t *retval;
|
|
|
|
{
|
1996-05-03 23:41:56 +04:00
|
|
|
#if 0
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_iopl_args /* {
|
1995-09-20 02:53:47 +04:00
|
|
|
syscallarg(int) level;
|
|
|
|
} */ *uap = v;
|
1996-05-03 23:41:56 +04:00
|
|
|
#endif
|
1995-08-28 00:56:38 +04:00
|
|
|
struct trapframe *fp = p->p_md.md_regs;
|
|
|
|
|
|
|
|
if (suser(p->p_ucred, &p->p_acflag) != 0)
|
|
|
|
return EPERM;
|
|
|
|
fp->tf_eflags |= PSL_IOPL;
|
|
|
|
*retval = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See above. If a root process tries to set access to an I/O port,
|
|
|
|
* just let it have the whole range.
|
|
|
|
*/
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
linux_sys_ioperm(p, v, retval)
|
1995-08-28 00:56:38 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct linux_sys_ioperm_args /* {
|
1995-08-28 00:56:38 +04:00
|
|
|
syscallarg(unsigned int) lo;
|
|
|
|
syscallarg(unsigned int) hi;
|
|
|
|
syscallarg(int) val;
|
1995-09-20 02:53:47 +04:00
|
|
|
} */ *uap = v;
|
1995-08-28 00:56:38 +04:00
|
|
|
struct trapframe *fp = p->p_md.md_regs;
|
|
|
|
|
|
|
|
if (suser(p->p_ucred, &p->p_acflag) != 0)
|
|
|
|
return EPERM;
|
|
|
|
if (SCARG(uap, val))
|
|
|
|
fp->tf_eflags |= PSL_IOPL;
|
|
|
|
*retval = 0;
|
|
|
|
return 0;
|
|
|
|
}
|