KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
This commit is contained in:
parent
9b36a30ee4
commit
b40ce4165d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=83366
@ -169,7 +169,7 @@ state(k, ve)
|
||||
KINFO *k;
|
||||
VARENT *ve;
|
||||
{
|
||||
int flag, sflag;
|
||||
int flag, sflag, tdflags;
|
||||
char *cp;
|
||||
VAR *v;
|
||||
char buf[16];
|
||||
@ -177,6 +177,7 @@ state(k, ve)
|
||||
v = ve->var;
|
||||
flag = k->ki_p->ki_flag;
|
||||
sflag = k->ki_p->ki_sflag;
|
||||
tdflags = k->ki_p->ki_tdflags; /* XXXKSE */
|
||||
cp = buf;
|
||||
|
||||
switch (k->ki_p->ki_stat) {
|
||||
@ -186,7 +187,7 @@ state(k, ve)
|
||||
break;
|
||||
|
||||
case SSLEEP:
|
||||
if (sflag & PS_SINTR) /* interruptable (long) */
|
||||
if (tdflags & TDF_SINTR) /* interruptable (long) */
|
||||
*cp = k->ki_p->ki_slptime >= MAXSLP ? 'I' : 'S';
|
||||
else
|
||||
*cp = 'D';
|
||||
|
@ -104,21 +104,21 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
|
||||
register int addr;
|
||||
int bad_reg = -1;
|
||||
int offset;
|
||||
struct user *tmp_uaddr;
|
||||
struct pcb *tmp_pcbaddr;
|
||||
|
||||
/*
|
||||
* First get virtual address of user structure. Then calculate offset.
|
||||
*/
|
||||
memcpy(&tmp_uaddr,
|
||||
&((struct user *) core_reg_sect)->u_kproc.ki_addr,
|
||||
sizeof(tmp_uaddr));
|
||||
offset = -reg_addr - (int) tmp_uaddr;
|
||||
memcpy(&tmp_pcbaddr,
|
||||
&((struct user *) core_reg_sect)->u_kproc.ki_pcb,
|
||||
sizeof(tmp_pcbaddr));
|
||||
offset = -reg_addr - (int) tmp_pcbaddr;
|
||||
|
||||
for (regno = 0; regno < NUM_REGS; regno++)
|
||||
{
|
||||
cregno = tregmap[regno];
|
||||
if (cregno == tGS)
|
||||
addr = offsetof (struct user, u_pcb) + offsetof (struct pcb, pcb_gs);
|
||||
addr = offsetof (struct pcb, pcb_gs);
|
||||
else
|
||||
addr = offset + 4 * cregno;
|
||||
if (addr < 0 || addr >= core_reg_size)
|
||||
@ -136,11 +136,7 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
|
||||
error ("Register %s not found in core file.", gdb_register_names[bad_reg]);
|
||||
}
|
||||
|
||||
#if __FreeBSD_version >= 500022
|
||||
addr = offsetof (struct user, u_pcb) + offsetof (struct pcb, pcb_save);
|
||||
#else
|
||||
addr = offsetof (struct user, u_pcb) + offsetof (struct pcb, pcb_savefpu);
|
||||
#endif
|
||||
addr = offsetof (struct pcb, pcb_save);
|
||||
memcpy (&pcb_savefpu, core_reg_sect + addr, sizeof pcb_savefpu);
|
||||
}
|
||||
|
||||
@ -170,11 +166,6 @@ extern void print_387_control_word (); /* i387-tdep.h */
|
||||
extern void print_387_status_word ();
|
||||
|
||||
#define fpstate save87
|
||||
#if __FreeBSD_version >= 500022
|
||||
#define U_FPSTATE(u) u.u_pcb.pcb_save.sv_87
|
||||
#else
|
||||
#define U_FPSTATE(u) u.u_pcb.pcb_savefpu
|
||||
#endif
|
||||
|
||||
static void
|
||||
i387_to_double (from, to)
|
||||
@ -344,15 +335,13 @@ i386_float_info ()
|
||||
/* fpstate defined in <sys/user.h> */
|
||||
struct fpstate *fpstatep;
|
||||
char buf[sizeof (struct fpstate) + 2 * sizeof (int)];
|
||||
unsigned int uaddr;
|
||||
char fpvalid;
|
||||
unsigned int rounded_addr;
|
||||
unsigned int rounded_size;
|
||||
/*extern int corechan;*/
|
||||
int skip;
|
||||
extern int inferior_pid;
|
||||
|
||||
uaddr = (char *)&U_FPSTATE(u) - (char *)&u;
|
||||
|
||||
if (inferior_pid != 0 && core_bfd == NULL)
|
||||
{
|
||||
int pid = inferior_pid & ((1 << 17) - 1); /* XXX extract pid from tid */
|
||||
|
@ -201,8 +201,12 @@ static struct proc *
|
||||
curProc ()
|
||||
{
|
||||
struct proc *p;
|
||||
CORE_ADDR addr = pcpu + PCPU_OFFSET (curproc);
|
||||
struct thread *td;
|
||||
CORE_ADDR addr = pcpu + PCPU_OFFSET (curthread);
|
||||
|
||||
if (kvread (addr, &td))
|
||||
error ("cannot read thread pointer at %x\n", addr);
|
||||
addr = (CORE_ADDR)td->td_proc;
|
||||
if (kvread (addr, &p))
|
||||
error ("cannot read proc pointer at %x\n", addr);
|
||||
return p;
|
||||
@ -380,13 +384,13 @@ static void
|
||||
get_kcore_registers (regno)
|
||||
int regno;
|
||||
{
|
||||
struct user *uaddr;
|
||||
struct pcb *pcbaddr;
|
||||
|
||||
/* find the pcb for the current process */
|
||||
if (cur_proc == NULL || kvread (&cur_proc->p_addr, &uaddr))
|
||||
if (cur_proc == NULL || kvread (&cur_proc->p_thread.td_pcb, &pcbaddr)) /* XXXKSE */
|
||||
error ("cannot read u area ptr for proc at %#x", cur_proc);
|
||||
if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0)
|
||||
error ("cannot read pcb at %#x", &uaddr->u_pcb);
|
||||
if (read_pcb (core_kd, (CORE_ADDR)pcbaddr) < 0)
|
||||
error ("cannot read pcb at %#x", pcbaddr);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -201,8 +201,12 @@ static struct proc *
|
||||
curProc ()
|
||||
{
|
||||
struct proc *p;
|
||||
CORE_ADDR addr = pcpu + PCPU_OFFSET (curproc);
|
||||
struct thread *td;
|
||||
CORE_ADDR addr = pcpu + PCPU_OFFSET (curthread);
|
||||
|
||||
if (kvread (addr, &td))
|
||||
error ("cannot read thread pointer at %x\n", addr);
|
||||
addr = (CORE_ADDR)td->td_proc;
|
||||
if (kvread (addr, &p))
|
||||
error ("cannot read proc pointer at %x\n", addr);
|
||||
return p;
|
||||
@ -380,13 +384,13 @@ static void
|
||||
get_kcore_registers (regno)
|
||||
int regno;
|
||||
{
|
||||
struct user *uaddr;
|
||||
struct pcb *pcbaddr;
|
||||
|
||||
/* find the pcb for the current process */
|
||||
if (cur_proc == NULL || kvread (&cur_proc->p_addr, &uaddr))
|
||||
if (cur_proc == NULL || kvread (&cur_proc->p_thread.td_pcb, &pcbaddr)) /* XXXKSE */
|
||||
error ("cannot read u area ptr for proc at %#x", cur_proc);
|
||||
if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0)
|
||||
error ("cannot read pcb at %#x", &uaddr->u_pcb);
|
||||
if (read_pcb (core_kd, (CORE_ADDR)pcbaddr) < 0)
|
||||
error ("cannot read pcb at %#x", pcbaddr);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -168,7 +168,8 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
|
||||
* gather kinfo_proc
|
||||
*/
|
||||
kp->ki_paddr = p;
|
||||
kp->ki_addr = proc.p_addr;
|
||||
kp->ki_addr = proc.p_uarea;
|
||||
/* kp->ki_kstack = proc.p_thread.td_kstack; XXXKSE */
|
||||
kp->ki_args = proc.p_args;
|
||||
kp->ki_tracep = proc.p_tracep;
|
||||
kp->ki_textvp = proc.p_textvp;
|
||||
@ -258,8 +259,8 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
|
||||
nopgrp:
|
||||
kp->ki_tdev = NODEV;
|
||||
}
|
||||
if (proc.p_wmesg)
|
||||
(void)kvm_read(kd, (u_long)proc.p_wmesg,
|
||||
if (proc.p_thread.td_wmesg) /* XXXKSE */
|
||||
(void)kvm_read(kd, (u_long)proc.p_thread.td_wmesg,
|
||||
kp->ki_wmesg, WMESGLEN);
|
||||
|
||||
#ifdef sparc
|
||||
@ -297,10 +298,10 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
|
||||
strncpy(kp->ki_comm, proc.p_comm, MAXCOMLEN);
|
||||
kp->ki_comm[MAXCOMLEN] = 0;
|
||||
}
|
||||
if (proc.p_blocked != 0) {
|
||||
if (proc.p_thread.td_blocked != 0) { /* XXXKSE */
|
||||
kp->ki_kiflag |= KI_MTXBLOCK;
|
||||
if (proc.p_mtxname)
|
||||
(void)kvm_read(kd, (u_long)proc.p_mtxname,
|
||||
if (proc.p_thread.td_mtxname) /* XXXKSE */
|
||||
(void)kvm_read(kd, (u_long)proc.p_thread.td_mtxname,
|
||||
kp->ki_mtxname, MTXNAMELEN);
|
||||
kp->ki_mtxname[MTXNAMELEN] = 0;
|
||||
}
|
||||
@ -310,21 +311,21 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
|
||||
kp->ki_sigmask = proc.p_sigmask;
|
||||
kp->ki_xstat = proc.p_xstat;
|
||||
kp->ki_acflag = proc.p_acflag;
|
||||
kp->ki_pctcpu = proc.p_pctcpu;
|
||||
kp->ki_estcpu = proc.p_estcpu;
|
||||
kp->ki_slptime = proc.p_slptime;
|
||||
kp->ki_pctcpu = proc.p_kse.ke_pctcpu; /* XXXKSE */
|
||||
kp->ki_estcpu = proc.p_ksegrp.kg_estcpu; /* XXXKSE */
|
||||
kp->ki_slptime = proc.p_kse.ke_slptime; /* XXXKSE */
|
||||
kp->ki_swtime = proc.p_swtime;
|
||||
kp->ki_flag = proc.p_flag;
|
||||
kp->ki_sflag = proc.p_sflag;
|
||||
kp->ki_wchan = proc.p_wchan;
|
||||
kp->ki_wchan = proc.p_thread.td_wchan; /* XXXKSE */
|
||||
kp->ki_traceflag = proc.p_traceflag;
|
||||
kp->ki_stat = proc.p_stat;
|
||||
kp->ki_pri = proc.p_pri;
|
||||
kp->ki_nice = proc.p_nice;
|
||||
kp->ki_pri = proc.p_ksegrp.kg_pri; /* XXXKSE */
|
||||
kp->ki_nice = proc.p_ksegrp.kg_nice; /* XXXKSE */
|
||||
kp->ki_lock = proc.p_lock;
|
||||
kp->ki_rqindex = proc.p_rqindex;
|
||||
kp->ki_oncpu = proc.p_oncpu;
|
||||
kp->ki_lastcpu = proc.p_lastcpu;
|
||||
kp->ki_rqindex = proc.p_kse.ke_rqindex; /* XXXKSE */
|
||||
kp->ki_oncpu = proc.p_kse.ke_oncpu; /* XXXKSE */
|
||||
kp->ki_lastcpu = proc.p_thread.td_lastcpu; /* XXXKSE */
|
||||
bcopy(&kinfo_proc, bp, sizeof(kinfo_proc));
|
||||
++bp;
|
||||
++cnt;
|
||||
|
@ -592,23 +592,26 @@ DB_SHOW_COMMAND(pcpu, db_show_pcpu)
|
||||
db_printf("cpuid = %d\n", gd->gd_cpuid);
|
||||
db_printf("ipis = %lx\n", gd->gd_pending_ipis);
|
||||
db_printf("next ASN = %d\n", gd->gd_next_asn);
|
||||
db_printf("curproc = ");
|
||||
if (gd->gd_curproc != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_curproc,
|
||||
gd->gd_curproc->p_pid, gd->gd_curproc->p_comm);
|
||||
db_printf("curthread = ");
|
||||
if (gd->gd_curthread != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_curthread,
|
||||
gd->gd_curthread->td_proc->p_pid,
|
||||
gd->gd_curthread->td_proc->p_comm);
|
||||
else
|
||||
db_printf("none\n");
|
||||
db_printf("curpcb = %p\n", gd->gd_curpcb);
|
||||
db_printf("fpcurproc = ");
|
||||
if (gd->gd_fpcurproc != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_fpcurproc,
|
||||
gd->gd_fpcurproc->p_pid, gd->gd_fpcurproc->p_comm);
|
||||
db_printf("fpcurthread = ");
|
||||
if (gd->gd_fpcurthread != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_fpcurthread,
|
||||
gd->gd_fpcurthread->td_proc->p_pid,
|
||||
gd->gd_fpcurthread->td_proc->p_comm);
|
||||
else
|
||||
db_printf("none\n");
|
||||
db_printf("idleproc = ");
|
||||
if (gd->gd_idleproc != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_idleproc,
|
||||
gd->gd_idleproc->p_pid, gd->gd_idleproc->p_comm);
|
||||
db_printf("idlethread = ");
|
||||
if (gd->gd_idlethread != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_idlethread,
|
||||
gd->gd_idlethread->td_proc->p_pid,
|
||||
gd->gd_idlethread->td_proc->p_comm);
|
||||
else
|
||||
db_printf("none\n");
|
||||
|
||||
|
@ -212,6 +212,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m
|
||||
boolean_t ra_from_pcb;
|
||||
u_long last_ipl = ~0L;
|
||||
struct proc *p = NULL;
|
||||
struct thread *td = NULL;
|
||||
boolean_t have_trapframe = FALSE;
|
||||
pid_t pid;
|
||||
|
||||
@ -219,7 +220,8 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m
|
||||
count = 65535;
|
||||
|
||||
if (!have_addr) {
|
||||
p = curproc;
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
addr = DDB_REGS->tf_regs[FRAME_SP] - FRAME_SIZE * 8;
|
||||
tf = (struct trapframe *)addr;
|
||||
have_trapframe = 1;
|
||||
@ -231,8 +233,9 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m
|
||||
* The pcb for curproc is not valid at this point,
|
||||
* so fall back to the default case.
|
||||
*/
|
||||
if (pid == curproc->p_pid) {
|
||||
p = curproc;
|
||||
if (pid == curthread->td_proc->p_pid) {
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
addr = DDB_REGS->tf_regs[FRAME_SP] - FRAME_SIZE * 8;
|
||||
tf = (struct trapframe *)addr;
|
||||
have_trapframe = 1;
|
||||
@ -251,7 +254,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *m
|
||||
db_printf("pid %d swapped out\n", pid);
|
||||
return;
|
||||
}
|
||||
pcbp = &p->p_addr->u_pcb;
|
||||
pcbp = p->p_thread.td_pcb; /* XXXKSE */
|
||||
addr = (db_expr_t)pcbp->pcb_hw.apcb_ksp;
|
||||
callpc = pcbp->pcb_context[7];
|
||||
frame = addr;
|
||||
|
@ -139,17 +139,17 @@
|
||||
beq t1, exception_return
|
||||
|
||||
/* set the hae register if this process has specified a value */
|
||||
ldq s0, GD_CURPROC(globalp)
|
||||
ldq t1, P_MD_FLAGS(s0)
|
||||
ldq s0, GD_CURTHREAD(globalp)
|
||||
ldq t1, TD_MD_FLAGS(s0)
|
||||
and t1, MDP_HAEUSED
|
||||
beq t1, 3f
|
||||
ldq a0, P_MD_HAE(s0)
|
||||
ldq a0, TD_MD_HAE(s0)
|
||||
ldq pv, chipset + CHIPSET_WRITE_HAE
|
||||
CALL((pv))
|
||||
3:
|
||||
#ifdef SMP
|
||||
/* leave the kernel */
|
||||
stl zero, P_MD_KERNNEST(s0)
|
||||
stl zero, TD_MD_KERNNEST(s0)
|
||||
#endif
|
||||
|
||||
/* restore the registers, and return */
|
||||
@ -255,9 +255,9 @@ LEAF(exception_return, 1) /* XXX should be NESTED */
|
||||
br pv, Ler1
|
||||
Ler1: LDGP(pv)
|
||||
|
||||
ldq s0, GD_CURPROC(globalp) /* save curproc in s0 */
|
||||
ldq s0, GD_CURTHREAD(globalp) /* save curthread in s0 */
|
||||
#ifdef SMP
|
||||
ldl s1, P_MD_KERNNEST(s0)
|
||||
ldl s1, TD_MD_KERNNEST(s0)
|
||||
subl s1, 1, s1 /* decrement nesting level */
|
||||
#endif
|
||||
|
||||
@ -280,16 +280,16 @@ Lkernelret:
|
||||
|
||||
Lrestoreregs:
|
||||
/* set the hae register if this process has specified a value */
|
||||
ldq t1, P_MD_FLAGS(s0)
|
||||
ldq t1, TD_MD_FLAGS(s0)
|
||||
and t1, MDP_HAEUSED
|
||||
beq t1, Lnohae
|
||||
ldq a0, P_MD_HAE(t0)
|
||||
ldq a0, TD_MD_HAE(t0)
|
||||
ldq pv, chipset + CHIPSET_WRITE_HAE
|
||||
CALL((pv))
|
||||
Lnohae:
|
||||
#ifdef SMP
|
||||
/* leave the kernel */
|
||||
stl s1, P_MD_KERNNEST(s0)
|
||||
stl s1, TD_MD_KERNNEST(s0)
|
||||
#endif
|
||||
|
||||
/* restore the registers, and return */
|
||||
|
@ -221,10 +221,10 @@ static fp_register_t fp_cvtql(union alpha_instruction ins,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int fp_emulate(union alpha_instruction ins, struct proc *p)
|
||||
static int fp_emulate(union alpha_instruction ins, struct thread *td)
|
||||
{
|
||||
u_int64_t control = p->p_addr->u_pcb.pcb_fp_control;
|
||||
struct fpreg *fpregs = &p->p_addr->u_pcb.pcb_fp;
|
||||
u_int64_t control = td->td_pcb->pcb_fp_control;
|
||||
struct fpreg *fpregs = &td->td_pcb->pcb_fp;
|
||||
static fp_opcode_handler *ops[16] = {
|
||||
fp_add, /* 0 */
|
||||
fp_sub, /* 1 */
|
||||
@ -261,7 +261,7 @@ static int fp_emulate(union alpha_instruction ins, struct proc *p)
|
||||
* them. We are potentially going to modify the fp state, so
|
||||
* cancel fpcurproc too.
|
||||
*/
|
||||
alpha_fpstate_save(p, 1);
|
||||
alpha_fpstate_save(td, 1);
|
||||
|
||||
/*
|
||||
* Decode and execute the instruction.
|
||||
@ -288,7 +288,7 @@ static int fp_emulate(union alpha_instruction ins, struct proc *p)
|
||||
|
||||
/* Record the exception in the software control word. */
|
||||
control |= (status >> IEEE_STATUS_TO_FPCR_SHIFT);
|
||||
p->p_addr->u_pcb.pcb_fp_control = control;
|
||||
td->td_pcb->pcb_fp_control = control;
|
||||
|
||||
/* Regenerate the control register */
|
||||
fpcr = fpregs->fpr_cr & FPCR_DYN_MASK;
|
||||
@ -323,9 +323,9 @@ static int fp_emulate(union alpha_instruction ins, struct proc *p)
|
||||
* emulating it in software. Return non-zero if the completion was
|
||||
* successful, otherwise zero.
|
||||
*/
|
||||
int fp_software_completion(u_int64_t regmask, struct proc *p)
|
||||
int fp_software_completion(u_int64_t regmask, struct thread *td)
|
||||
{
|
||||
struct trapframe *frame = p->p_frame;
|
||||
struct trapframe *frame = td->td_frame;
|
||||
u_int64_t pc = frame->tf_regs[FRAME_PC];
|
||||
int error;
|
||||
|
||||
@ -394,7 +394,7 @@ int fp_software_completion(u_int64_t regmask, struct proc *p)
|
||||
* instructions in the trap shadow, so this
|
||||
* must be the one which generated the trap.
|
||||
*/
|
||||
if (fp_emulate(ins, p)) {
|
||||
if (fp_emulate(ins, td)) {
|
||||
/*
|
||||
* Restore pc to the first instruction
|
||||
* in the trap shadow.
|
||||
|
@ -68,8 +68,8 @@
|
||||
#include <nfs/nfs.h>
|
||||
#include <nfs/nfsdiskless.h>
|
||||
|
||||
ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc));
|
||||
ASSYM(GD_FPCURPROC, offsetof(struct globaldata, gd_fpcurproc));
|
||||
ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread));
|
||||
ASSYM(GD_FPCURTHREAD, offsetof(struct globaldata, gd_fpcurthread));
|
||||
ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb));
|
||||
ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime));
|
||||
ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid));
|
||||
@ -80,12 +80,15 @@ ASSYM(MTX_RECURSE, offsetof(struct mtx, mtx_recurse));
|
||||
ASSYM(MTX_SAVECRIT, offsetof(struct mtx, mtx_savecrit));
|
||||
ASSYM(MTX_UNOWNED, MTX_UNOWNED);
|
||||
|
||||
ASSYM(P_ADDR, offsetof(struct proc, p_addr));
|
||||
ASSYM(P_MD_FLAGS, offsetof(struct proc, p_md.md_flags));
|
||||
ASSYM(P_MD_PCBPADDR, offsetof(struct proc, p_md.md_pcbpaddr));
|
||||
ASSYM(P_MD_HAE, offsetof(struct proc, p_md.md_hae));
|
||||
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
|
||||
ASSYM(TD_KSE, offsetof(struct thread, td_kse));
|
||||
ASSYM(TD_PROC, offsetof(struct thread, td_proc));
|
||||
|
||||
ASSYM(TD_MD_FLAGS, offsetof(struct thread, td_md.md_flags));
|
||||
ASSYM(TD_MD_PCBPADDR, offsetof(struct thread, td_md.md_pcbpaddr));
|
||||
ASSYM(TD_MD_HAE, offsetof(struct thread, td_md.md_hae));
|
||||
#ifdef SMP
|
||||
ASSYM(P_MD_KERNNEST, offsetof(struct proc, p_md.md_kernnest));
|
||||
ASSYM(TD_MD_KERNNEST, offsetof(struct thread, td_md.md_kernnest));
|
||||
#endif
|
||||
ASSYM(MDP_HAEUSED, MDP_HAEUSED);
|
||||
|
||||
@ -95,10 +98,9 @@ ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS);
|
||||
ASSYM(PTLEV1I, PTLEV1I);
|
||||
ASSYM(PTESIZE, PTESIZE);
|
||||
|
||||
ASSYM(U_PCB_ONFAULT, offsetof(struct user, u_pcb.pcb_onfault));
|
||||
ASSYM(U_PCB_HWPCB_KSP, offsetof(struct user, u_pcb.pcb_hw.apcb_ksp));
|
||||
ASSYM(U_PCB_CONTEXT, offsetof(struct user, u_pcb.pcb_context));
|
||||
|
||||
ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
|
||||
ASSYM(PCB_HWPCB_KSP, offsetof(struct pcb, pcb_hw.apcb_ksp));
|
||||
ASSYM(PCB_CONTEXT, offsetof(struct pcb, pcb_context));
|
||||
ASSYM(PCB_HW, offsetof(struct pcb, pcb_hw));
|
||||
|
||||
ASSYM(FPREG_FPR_REGS, offsetof(struct fpreg, fpr_regs));
|
||||
|
@ -90,7 +90,7 @@ interrupt(a0, a1, a2, framep)
|
||||
unsigned long a0, a1, a2;
|
||||
struct trapframe *framep;
|
||||
{
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
#ifdef SMP
|
||||
critical_t s;
|
||||
#endif
|
||||
@ -102,18 +102,20 @@ interrupt(a0, a1, a2, framep)
|
||||
s = critical_enter();
|
||||
#endif
|
||||
globalp = (struct globaldata *) alpha_pal_rdval();
|
||||
p = curproc;
|
||||
td = curthread;
|
||||
#ifdef SMP
|
||||
p->p_md.md_kernnest++;
|
||||
td->td_md.md_kernnest++;
|
||||
critical_exit(s);
|
||||
#endif
|
||||
atomic_add_int(&p->p_intr_nesting_level, 1);
|
||||
atomic_add_int(&td->td_intr_nesting_level, 1);
|
||||
#ifndef KSTACK_GUARD
|
||||
#ifndef SMP
|
||||
{
|
||||
if ((caddr_t) framep < (caddr_t) p->p_addr + 1024) {
|
||||
if ((caddr_t) framep < (caddr_t) td->td_pcb + 1024) {
|
||||
panic("possible stack overflow\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
framep->tf_regs[FRAME_TRAPARG_A0] = a0;
|
||||
@ -161,7 +163,7 @@ interrupt(a0, a1, a2, framep)
|
||||
a0, a1, a2);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
atomic_subtract_int(&p->p_intr_nesting_level, 1);
|
||||
atomic_subtract_int(&td->td_intr_nesting_level, 1);
|
||||
}
|
||||
|
||||
void
|
||||
@ -472,7 +474,7 @@ alpha_clock_interrupt(struct trapframe *framep)
|
||||
#ifdef SMP
|
||||
} else {
|
||||
mtx_lock_spin(&sched_lock);
|
||||
hardclock_process(curproc, TRAPF_USERMODE(framep));
|
||||
hardclock_process(curthread, TRAPF_USERMODE(framep));
|
||||
if ((schedclk2 & 0x7) == 0)
|
||||
statclock_process(curproc, TRAPF_PC(framep),
|
||||
TRAPF_USERMODE(framep));
|
||||
|
@ -114,10 +114,10 @@
|
||||
mov v0, globalp
|
||||
|
||||
/*
|
||||
* Switch to proc0's PCB, which is at U_PCB off of proc0paddr.
|
||||
* Switch to proc0's PCB.
|
||||
*/
|
||||
lda t0,proc0 /* get phys addr of pcb */
|
||||
ldq a0,P_MD_PCBPADDR(t0)
|
||||
ldq t0,thread0 /* get phys addr of pcb */
|
||||
ldq a0,TD_MD_PCBPADDR(t0)
|
||||
SWITCH_CONTEXT
|
||||
|
||||
/*
|
||||
@ -308,12 +308,6 @@ LEAF(restorefpstate, 1)
|
||||
RET
|
||||
END(restorefpstate)
|
||||
|
||||
.data
|
||||
EXPORT(proc0paddr)
|
||||
.quad 0
|
||||
|
||||
.text
|
||||
|
||||
/* XXX: make systat/vmstat happy */
|
||||
.data
|
||||
EXPORT(intrnames)
|
||||
|
@ -156,7 +156,8 @@ struct bootinfo_kernel bootinfo;
|
||||
struct mtx sched_lock;
|
||||
struct mtx Giant;
|
||||
|
||||
struct user *proc0paddr;
|
||||
struct user *proc0uarea;
|
||||
vm_offset_t proc0kstack;
|
||||
|
||||
char machine[] = "alpha";
|
||||
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "");
|
||||
@ -887,23 +888,30 @@ alpha_init(pfn, ptb, bim, bip, biv)
|
||||
|
||||
}
|
||||
|
||||
proc_linkup(&proc0);
|
||||
/*
|
||||
* Init mapping for u page(s) for proc 0
|
||||
*/
|
||||
proc0.p_addr = proc0paddr =
|
||||
(struct user *)pmap_steal_memory(UPAGES * PAGE_SIZE);
|
||||
proc0uarea = (struct user *)pmap_steal_memory(UAREA_PAGES * PAGE_SIZE);
|
||||
proc0kstack = pmap_steal_memory(KSTACK_PAGES * PAGE_SIZE);
|
||||
proc0.p_uarea = proc0uarea;
|
||||
thread0 = &proc0.p_thread;
|
||||
thread0->td_kstack = proc0kstack;
|
||||
thread0->td_pcb = (struct pcb *)
|
||||
(thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
|
||||
|
||||
/*
|
||||
* Setup the global data for the bootstrap cpu.
|
||||
*/
|
||||
{
|
||||
size_t sz = round_page(UPAGES * PAGE_SIZE);
|
||||
/* This is not a 'struct user' */
|
||||
size_t sz = round_page(KSTACK_PAGES * PAGE_SIZE);
|
||||
globalp = (struct globaldata *) pmap_steal_memory(sz);
|
||||
globaldata_init(globalp, alpha_pal_whami(), sz);
|
||||
alpha_pal_wrval((u_int64_t) globalp);
|
||||
PCPU_GET(next_asn) = 1; /* 0 used for proc0 pmap */
|
||||
#ifdef SMP
|
||||
proc0.p_md.md_kernnest = 1;
|
||||
thread0->td_md.md_kernnest = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -921,28 +929,26 @@ alpha_init(pfn, ptb, bim, bip, biv)
|
||||
* Initialize the rest of proc 0's PCB, and cache its physical
|
||||
* address.
|
||||
*/
|
||||
proc0.p_md.md_pcbpaddr =
|
||||
(struct pcb *)ALPHA_K0SEG_TO_PHYS((vm_offset_t)&proc0paddr->u_pcb);
|
||||
thread0->td_md.md_pcbpaddr =
|
||||
(struct pcb *)ALPHA_K0SEG_TO_PHYS((vm_offset_t)thread0->td_pcb);
|
||||
|
||||
/*
|
||||
* Set the kernel sp, reserving space for an (empty) trapframe,
|
||||
* and make proc0's trapframe pointer point to it for sanity.
|
||||
*/
|
||||
proc0paddr->u_pcb.pcb_hw.apcb_ksp =
|
||||
(u_int64_t)proc0paddr + USPACE - sizeof(struct trapframe);
|
||||
proc0.p_frame =
|
||||
(struct trapframe *)proc0paddr->u_pcb.pcb_hw.apcb_ksp;
|
||||
thread0->td_frame = (struct trapframe *)thread0->td_pcb - 1;
|
||||
thread0->td_pcb->pcb_hw.apcb_ksp = (u_int64_t)thread0->td_frame;
|
||||
|
||||
/*
|
||||
* Get the right value for the boot cpu's idle ptbr.
|
||||
*/
|
||||
globalp->gd_idlepcb.apcb_ptbr = proc0.p_addr->u_pcb.pcb_hw.apcb_ptbr;
|
||||
globalp->gd_idlepcb.apcb_ptbr = thread0->td_pcb->pcb_hw.apcb_ptbr;
|
||||
|
||||
/* Setup curproc so that mutexes work */
|
||||
PCPU_SET(curproc, &proc0);
|
||||
/* Setup curthread so that mutexes work */
|
||||
PCPU_SET(curthread, thread0);
|
||||
PCPU_SET(spinlocks, NULL);
|
||||
|
||||
LIST_INIT(&proc0.p_contested);
|
||||
LIST_INIT(&thread0->td_contested);
|
||||
|
||||
/*
|
||||
* Initialise mutexes.
|
||||
@ -1175,13 +1181,16 @@ DELAY(int n)
|
||||
void
|
||||
osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
{
|
||||
struct proc *p = curproc;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
osiginfo_t *sip, ksi;
|
||||
struct trapframe *frame;
|
||||
struct sigacts *psp;
|
||||
int oonstack, fsize, rndfsize;
|
||||
|
||||
frame = p->p_frame;
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
frame = td->td_frame;
|
||||
oonstack = sigonstack(alpha_pal_rdusp());
|
||||
fsize = sizeof ksi;
|
||||
rndfsize = ((fsize + 15) / 16) * 16;
|
||||
@ -1230,16 +1239,16 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
ksi.si_sc.sc_ps = frame->tf_regs[FRAME_PS];
|
||||
|
||||
/* copy the registers. */
|
||||
fill_regs(p, (struct reg *)ksi.si_sc.sc_regs);
|
||||
fill_regs(td, (struct reg *)ksi.si_sc.sc_regs);
|
||||
ksi.si_sc.sc_regs[R_ZERO] = 0xACEDBADE; /* magic number */
|
||||
ksi.si_sc.sc_regs[R_SP] = alpha_pal_rdusp();
|
||||
|
||||
/* save the floating-point state, if necessary, then copy it. */
|
||||
alpha_fpstate_save(p, 1); /* XXX maybe write=0 */
|
||||
ksi.si_sc.sc_ownedfp = p->p_md.md_flags & MDP_FPUSED;
|
||||
bcopy(&p->p_addr->u_pcb.pcb_fp, (struct fpreg *)ksi.si_sc.sc_fpregs,
|
||||
alpha_fpstate_save(td, 1); /* XXX maybe write=0 */
|
||||
ksi.si_sc.sc_ownedfp = td->td_md.md_flags & MDP_FPUSED;
|
||||
bcopy(&td->td_pcb->pcb_fp, (struct fpreg *)ksi.si_sc.sc_fpregs,
|
||||
sizeof(struct fpreg));
|
||||
ksi.si_sc.sc_fp_control = p->p_addr->u_pcb.pcb_fp_control;
|
||||
ksi.si_sc.sc_fp_control = td->td_pcb->pcb_fp_control;
|
||||
bzero(ksi.si_sc.sc_reserved, sizeof ksi.si_sc.sc_reserved); /* XXX */
|
||||
ksi.si_sc.sc_xxx1[0] = 0; /* XXX */
|
||||
ksi.si_sc.sc_xxx1[1] = 0; /* XXX */
|
||||
@ -1279,12 +1288,15 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
void
|
||||
sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
{
|
||||
struct proc *p = curproc;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
struct trapframe *frame;
|
||||
struct sigacts *psp;
|
||||
struct sigframe sf, *sfp;
|
||||
int oonstack, rndfsize;
|
||||
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
PROC_LOCK_ASSERT(p, MA_OWNED);
|
||||
psp = p->p_sigacts;
|
||||
#ifdef COMPAT_43
|
||||
@ -1294,7 +1306,7 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
}
|
||||
#endif
|
||||
|
||||
frame = p->p_frame;
|
||||
frame = td->td_frame;
|
||||
oonstack = sigonstack(alpha_pal_rdusp());
|
||||
rndfsize = ((sizeof(sf) + 15) / 16) * 16;
|
||||
|
||||
@ -1306,7 +1318,7 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE;
|
||||
sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0;
|
||||
|
||||
fill_regs(p, (struct reg *)sf.sf_uc.uc_mcontext.mc_regs);
|
||||
fill_regs(td, (struct reg *)sf.sf_uc.uc_mcontext.mc_regs);
|
||||
sf.sf_uc.uc_mcontext.mc_regs[R_SP] = alpha_pal_rdusp();
|
||||
sf.sf_uc.uc_mcontext.mc_regs[R_ZERO] = 0xACEDBADE; /* magic number */
|
||||
sf.sf_uc.uc_mcontext.mc_regs[R_PS] = frame->tf_regs[FRAME_PS];
|
||||
@ -1362,12 +1374,12 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
}
|
||||
|
||||
/* save the floating-point state, if necessary, then copy it. */
|
||||
alpha_fpstate_save(p, 1);
|
||||
sf.sf_uc.uc_mcontext.mc_ownedfp = p->p_md.md_flags & MDP_FPUSED;
|
||||
bcopy(&p->p_addr->u_pcb.pcb_fp,
|
||||
alpha_fpstate_save(td, 1);
|
||||
sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDP_FPUSED;
|
||||
bcopy(&td->td_pcb->pcb_fp,
|
||||
(struct fpreg *)sf.sf_uc.uc_mcontext.mc_fpregs,
|
||||
sizeof(struct fpreg));
|
||||
sf.sf_uc.uc_mcontext.mc_fp_control = p->p_addr->u_pcb.pcb_fp_control;
|
||||
sf.sf_uc.uc_mcontext.mc_fp_control = td->td_pcb->pcb_fp_control;
|
||||
|
||||
#ifdef COMPAT_OSF1
|
||||
/*
|
||||
@ -1428,12 +1440,13 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
*/
|
||||
#ifdef COMPAT_43
|
||||
int
|
||||
osigreturn(struct proc *p,
|
||||
osigreturn(struct thread *td,
|
||||
struct osigreturn_args /* {
|
||||
struct osigcontext *sigcntxp;
|
||||
} */ *uap)
|
||||
{
|
||||
struct osigcontext *scp, ksc;
|
||||
struct proc *p = td->td_proc;
|
||||
|
||||
scp = uap->sigcntxp;
|
||||
|
||||
@ -1470,25 +1483,25 @@ osigreturn(struct proc *p,
|
||||
SIG_CANTMASK(p->p_sigmask);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
set_regs(p, (struct reg *)ksc.sc_regs);
|
||||
p->p_frame->tf_regs[FRAME_PC] = ksc.sc_pc;
|
||||
p->p_frame->tf_regs[FRAME_PS] =
|
||||
set_regs(td, (struct reg *)ksc.sc_regs);
|
||||
td->td_frame->tf_regs[FRAME_PC] = ksc.sc_pc;
|
||||
td->td_frame->tf_regs[FRAME_PS] =
|
||||
(ksc.sc_ps | ALPHA_PSL_USERSET) & ~ALPHA_PSL_USERCLR;
|
||||
p->p_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */
|
||||
td->td_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */
|
||||
|
||||
alpha_pal_wrusp(ksc.sc_regs[R_SP]);
|
||||
|
||||
/* XXX ksc.sc_ownedfp ? */
|
||||
alpha_fpstate_drop(p);
|
||||
bcopy((struct fpreg *)ksc.sc_fpregs, &p->p_addr->u_pcb.pcb_fp,
|
||||
alpha_fpstate_drop(td);
|
||||
bcopy((struct fpreg *)ksc.sc_fpregs, &td->td_pcb->pcb_fp,
|
||||
sizeof(struct fpreg));
|
||||
p->p_addr->u_pcb.pcb_fp_control = ksc.sc_fp_control;
|
||||
td->td_pcb->pcb_fp_control = ksc.sc_fp_control;
|
||||
return (EJUSTRETURN);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
sigreturn(struct proc *p,
|
||||
sigreturn(struct thread *td,
|
||||
struct sigreturn_args /* {
|
||||
ucontext_t *sigcntxp;
|
||||
} */ *uap)
|
||||
@ -1496,14 +1509,16 @@ sigreturn(struct proc *p,
|
||||
ucontext_t uc, *ucp;
|
||||
struct pcb *pcb;
|
||||
unsigned long val;
|
||||
struct proc *p;
|
||||
|
||||
#ifdef COMPAT_43
|
||||
if (((struct osigcontext*)uap->sigcntxp)->sc_regs[R_ZERO] == 0xACEDBADE)
|
||||
return osigreturn(p, (struct osigreturn_args *)uap);
|
||||
return osigreturn(td, (struct osigreturn_args *)uap);
|
||||
#endif
|
||||
|
||||
ucp = uap->sigcntxp;
|
||||
pcb = &p->p_addr->u_pcb;
|
||||
pcb = td->td_pcb;
|
||||
p = td->td_proc;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (sigdebug & SDB_FOLLOW)
|
||||
@ -1519,12 +1534,12 @@ sigreturn(struct proc *p,
|
||||
/*
|
||||
* Restore the user-supplied information
|
||||
*/
|
||||
set_regs(p, (struct reg *)uc.uc_mcontext.mc_regs);
|
||||
set_regs(td, (struct reg *)uc.uc_mcontext.mc_regs);
|
||||
val = (uc.uc_mcontext.mc_regs[R_PS] | ALPHA_PSL_USERSET) &
|
||||
~ALPHA_PSL_USERCLR;
|
||||
p->p_frame->tf_regs[FRAME_PS] = val;
|
||||
p->p_frame->tf_regs[FRAME_PC] = uc.uc_mcontext.mc_regs[R_PC];
|
||||
p->p_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */
|
||||
td->td_frame->tf_regs[FRAME_PS] = val;
|
||||
td->td_frame->tf_regs[FRAME_PC] = uc.uc_mcontext.mc_regs[R_PC];
|
||||
td->td_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */
|
||||
alpha_pal_wrusp(uc.uc_mcontext.mc_regs[R_SP]);
|
||||
|
||||
PROC_LOCK(p);
|
||||
@ -1540,10 +1555,10 @@ sigreturn(struct proc *p,
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
/* XXX ksc.sc_ownedfp ? */
|
||||
alpha_fpstate_drop(p);
|
||||
alpha_fpstate_drop(td);
|
||||
bcopy((struct fpreg *)uc.uc_mcontext.mc_fpregs,
|
||||
&p->p_addr->u_pcb.pcb_fp, sizeof(struct fpreg));
|
||||
p->p_addr->u_pcb.pcb_fp_control = uc.uc_mcontext.mc_fp_control;
|
||||
&td->td_pcb->pcb_fp, sizeof(struct fpreg));
|
||||
td->td_pcb->pcb_fp_control = uc.uc_mcontext.mc_fp_control;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (sigdebug & SDB_FOLLOW)
|
||||
@ -1576,14 +1591,14 @@ cpu_halt(void)
|
||||
* Clear registers on exec
|
||||
*/
|
||||
void
|
||||
setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings)
|
||||
setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
|
||||
{
|
||||
struct trapframe *tfp = p->p_frame;
|
||||
struct trapframe *tfp = td->td_frame;
|
||||
|
||||
bzero(tfp->tf_regs, FRAME_SIZE * sizeof tfp->tf_regs[0]);
|
||||
bzero(&p->p_addr->u_pcb.pcb_fp, sizeof p->p_addr->u_pcb.pcb_fp);
|
||||
p->p_addr->u_pcb.pcb_fp_control = 0;
|
||||
p->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL
|
||||
bzero(&td->td_pcb->pcb_fp, sizeof td->td_pcb->pcb_fp);
|
||||
td->td_pcb->pcb_fp_control = 0;
|
||||
td->td_pcb->pcb_fp.fpr_cr = (FPCR_DYN_NORMAL
|
||||
| FPCR_INVD | FPCR_DZED
|
||||
| FPCR_OVFD | FPCR_INED
|
||||
| FPCR_UNFD);
|
||||
@ -1599,20 +1614,20 @@ setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings)
|
||||
tfp->tf_regs[FRAME_T12] = tfp->tf_regs[FRAME_PC]; /* a.k.a. PV */
|
||||
tfp->tf_regs[FRAME_FLAGS] = 0; /* full restore */
|
||||
|
||||
p->p_md.md_flags &= ~MDP_FPUSED;
|
||||
alpha_fpstate_drop(p);
|
||||
td->td_md.md_flags &= ~MDP_FPUSED;
|
||||
alpha_fpstate_drop(td);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_set_pc(struct proc *p, unsigned long addr)
|
||||
ptrace_set_pc(struct thread *td, unsigned long addr)
|
||||
{
|
||||
struct trapframe *tp = p->p_frame;
|
||||
struct trapframe *tp = td->td_frame;
|
||||
tp->tf_regs[FRAME_PC] = addr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ptrace_read_int(struct proc *p, vm_offset_t addr, u_int32_t *v)
|
||||
ptrace_read_int(struct thread *td, vm_offset_t addr, u_int32_t *v)
|
||||
{
|
||||
struct iovec iov;
|
||||
struct uio uio;
|
||||
@ -1624,12 +1639,12 @@ ptrace_read_int(struct proc *p, vm_offset_t addr, u_int32_t *v)
|
||||
uio.uio_resid = sizeof(u_int32_t);
|
||||
uio.uio_segflg = UIO_SYSSPACE;
|
||||
uio.uio_rw = UIO_READ;
|
||||
uio.uio_procp = p;
|
||||
return procfs_domem(curproc, p, NULL, &uio);
|
||||
uio.uio_td = td;
|
||||
return procfs_domem(curproc, td->td_proc, NULL, &uio);
|
||||
}
|
||||
|
||||
static int
|
||||
ptrace_write_int(struct proc *p, vm_offset_t addr, u_int32_t v)
|
||||
ptrace_write_int(struct thread *td, vm_offset_t addr, u_int32_t v)
|
||||
{
|
||||
struct iovec iov;
|
||||
struct uio uio;
|
||||
@ -1641,12 +1656,12 @@ ptrace_write_int(struct proc *p, vm_offset_t addr, u_int32_t v)
|
||||
uio.uio_resid = sizeof(u_int32_t);
|
||||
uio.uio_segflg = UIO_SYSSPACE;
|
||||
uio.uio_rw = UIO_WRITE;
|
||||
uio.uio_procp = p;
|
||||
return procfs_domem(curproc, p, NULL, &uio);
|
||||
uio.uio_td = td;
|
||||
return procfs_domem(curproc, td->td_proc, NULL, &uio);
|
||||
}
|
||||
|
||||
static u_int64_t
|
||||
ptrace_read_register(struct proc *p, int regno)
|
||||
ptrace_read_register(struct thread *td, int regno)
|
||||
{
|
||||
static int reg_to_frame[32] = {
|
||||
FRAME_V0,
|
||||
@ -1689,54 +1704,54 @@ ptrace_read_register(struct proc *p, int regno)
|
||||
if (regno == R_ZERO)
|
||||
return 0;
|
||||
|
||||
return p->p_frame->tf_regs[reg_to_frame[regno]];
|
||||
return td->td_frame->tf_regs[reg_to_frame[regno]];
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
ptrace_clear_bpt(struct proc *p, struct mdbpt *bpt)
|
||||
ptrace_clear_bpt(struct thread *td, struct mdbpt *bpt)
|
||||
{
|
||||
return ptrace_write_int(p, bpt->addr, bpt->contents);
|
||||
return ptrace_write_int(td, bpt->addr, bpt->contents);
|
||||
}
|
||||
|
||||
static int
|
||||
ptrace_set_bpt(struct proc *p, struct mdbpt *bpt)
|
||||
ptrace_set_bpt(struct thread *td, struct mdbpt *bpt)
|
||||
{
|
||||
int error;
|
||||
u_int32_t bpins = 0x00000080;
|
||||
error = ptrace_read_int(p, bpt->addr, &bpt->contents);
|
||||
error = ptrace_read_int(td, bpt->addr, &bpt->contents);
|
||||
if (error)
|
||||
return error;
|
||||
return ptrace_write_int(p, bpt->addr, bpins);
|
||||
return ptrace_write_int(td, bpt->addr, bpins);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_clear_single_step(struct proc *p)
|
||||
ptrace_clear_single_step(struct thread *td)
|
||||
{
|
||||
if (p->p_md.md_flags & MDP_STEP2) {
|
||||
ptrace_clear_bpt(p, &p->p_md.md_sstep[1]);
|
||||
ptrace_clear_bpt(p, &p->p_md.md_sstep[0]);
|
||||
p->p_md.md_flags &= ~MDP_STEP2;
|
||||
} else if (p->p_md.md_flags & MDP_STEP1) {
|
||||
ptrace_clear_bpt(p, &p->p_md.md_sstep[0]);
|
||||
p->p_md.md_flags &= ~MDP_STEP1;
|
||||
if (td->td_md.md_flags & MDP_STEP2) {
|
||||
ptrace_clear_bpt(td, &td->td_md.md_sstep[1]);
|
||||
ptrace_clear_bpt(td, &td->td_md.md_sstep[0]);
|
||||
td->td_md.md_flags &= ~MDP_STEP2;
|
||||
} else if (td->td_md.md_flags & MDP_STEP1) {
|
||||
ptrace_clear_bpt(td, &td->td_md.md_sstep[0]);
|
||||
td->td_md.md_flags &= ~MDP_STEP1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_single_step(struct proc *p)
|
||||
ptrace_single_step(struct thread *td)
|
||||
{
|
||||
int error;
|
||||
vm_offset_t pc = p->p_frame->tf_regs[FRAME_PC];
|
||||
vm_offset_t pc = td->td_frame->tf_regs[FRAME_PC];
|
||||
alpha_instruction ins;
|
||||
vm_offset_t addr[2]; /* places to set breakpoints */
|
||||
int count = 0; /* count of breakpoints */
|
||||
|
||||
if (p->p_md.md_flags & (MDP_STEP1|MDP_STEP2))
|
||||
if (td->td_md.md_flags & (MDP_STEP1|MDP_STEP2))
|
||||
panic("ptrace_single_step: step breakpoints not removed");
|
||||
|
||||
error = ptrace_read_int(p, pc, &ins.bits);
|
||||
error = ptrace_read_int(td, pc, &ins.bits);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
@ -1744,7 +1759,7 @@ ptrace_single_step(struct proc *p)
|
||||
|
||||
case op_j:
|
||||
/* Jump: target is register value */
|
||||
addr[0] = ptrace_read_register(p, ins.jump_format.rs) & ~3;
|
||||
addr[0] = ptrace_read_register(td, ins.jump_format.rs) & ~3;
|
||||
count = 1;
|
||||
break;
|
||||
|
||||
@ -1775,20 +1790,20 @@ ptrace_single_step(struct proc *p)
|
||||
count = 1;
|
||||
}
|
||||
|
||||
p->p_md.md_sstep[0].addr = addr[0];
|
||||
error = ptrace_set_bpt(p, &p->p_md.md_sstep[0]);
|
||||
td->td_md.md_sstep[0].addr = addr[0];
|
||||
error = ptrace_set_bpt(td, &td->td_md.md_sstep[0]);
|
||||
if (error)
|
||||
return error;
|
||||
if (count == 2) {
|
||||
p->p_md.md_sstep[1].addr = addr[1];
|
||||
error = ptrace_set_bpt(p, &p->p_md.md_sstep[1]);
|
||||
td->td_md.md_sstep[1].addr = addr[1];
|
||||
error = ptrace_set_bpt(td, &td->td_md.md_sstep[1]);
|
||||
if (error) {
|
||||
ptrace_clear_bpt(p, &p->p_md.md_sstep[0]);
|
||||
ptrace_clear_bpt(td, &td->td_md.md_sstep[0]);
|
||||
return error;
|
||||
}
|
||||
p->p_md.md_flags |= MDP_STEP2;
|
||||
td->td_md.md_flags |= MDP_STEP2;
|
||||
} else
|
||||
p->p_md.md_flags |= MDP_STEP1;
|
||||
td->td_md.md_flags |= MDP_STEP1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1812,15 +1827,13 @@ alpha_pa_access(vm_offset_t pa)
|
||||
}
|
||||
|
||||
int
|
||||
fill_regs(p, regs)
|
||||
struct proc *p;
|
||||
fill_regs(td, regs)
|
||||
struct thread *td;
|
||||
struct reg *regs;
|
||||
{
|
||||
struct pcb *pcb = &p->p_addr->u_pcb;
|
||||
struct trapframe *tp = p->p_frame;
|
||||
struct pcb *pcb = td->td_pcb;
|
||||
struct trapframe *tp = td->td_frame;
|
||||
|
||||
tp = p->p_frame;
|
||||
|
||||
#define C(r) regs->r_regs[R_ ## r] = tp->tf_regs[FRAME_ ## r]
|
||||
|
||||
C(V0);
|
||||
@ -1839,14 +1852,12 @@ fill_regs(p, regs)
|
||||
}
|
||||
|
||||
int
|
||||
set_regs(p, regs)
|
||||
struct proc *p;
|
||||
set_regs(td, regs)
|
||||
struct thread *td;
|
||||
struct reg *regs;
|
||||
{
|
||||
struct pcb *pcb = &p->p_addr->u_pcb;
|
||||
struct trapframe *tp = p->p_frame;
|
||||
|
||||
tp = p->p_frame;
|
||||
struct pcb *pcb = td->td_pcb;
|
||||
struct trapframe *tp = td->td_frame;
|
||||
|
||||
#define C(r) tp->tf_regs[FRAME_ ## r] = regs->r_regs[R_ ## r]
|
||||
|
||||
@ -1866,24 +1877,24 @@ set_regs(p, regs)
|
||||
}
|
||||
|
||||
int
|
||||
fill_fpregs(p, fpregs)
|
||||
struct proc *p;
|
||||
fill_fpregs(td, fpregs)
|
||||
struct thread *td;
|
||||
struct fpreg *fpregs;
|
||||
{
|
||||
alpha_fpstate_save(p, 0);
|
||||
alpha_fpstate_save(td, 0);
|
||||
|
||||
bcopy(&p->p_addr->u_pcb.pcb_fp, fpregs, sizeof *fpregs);
|
||||
bcopy(&td->td_pcb->pcb_fp, fpregs, sizeof *fpregs);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
set_fpregs(p, fpregs)
|
||||
struct proc *p;
|
||||
set_fpregs(td, fpregs)
|
||||
struct thread *td;
|
||||
struct fpreg *fpregs;
|
||||
{
|
||||
alpha_fpstate_drop(p);
|
||||
alpha_fpstate_drop(td);
|
||||
|
||||
bcopy(fpregs, &p->p_addr->u_pcb.pcb_fp, sizeof *fpregs);
|
||||
bcopy(fpregs, &td->td_pcb->pcb_fp, sizeof *fpregs);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1976,27 +1987,27 @@ SYSCTL_INT(_machdep, CPU_WALLCLOCK, wall_cmos_clock,
|
||||
CTLFLAG_RW, &wall_cmos_clock, 0, "");
|
||||
|
||||
void
|
||||
alpha_fpstate_check(struct proc *p)
|
||||
alpha_fpstate_check(struct thread *td)
|
||||
{
|
||||
/*
|
||||
* For SMP, we should check the fpcurproc of each cpu.
|
||||
* For SMP, we should check the fpcurthread of each cpu.
|
||||
*/
|
||||
#ifndef SMP
|
||||
critical_t s;
|
||||
|
||||
s = critical_enter();
|
||||
if (p->p_addr->u_pcb.pcb_hw.apcb_flags & ALPHA_PCB_FLAGS_FEN)
|
||||
if (p != PCPU_GET(fpcurproc))
|
||||
panic("alpha_check_fpcurproc: bogus");
|
||||
if (td->td_pcb->pcb_hw.apcb_flags & ALPHA_PCB_FLAGS_FEN)
|
||||
if (td != PCPU_GET(fpcurthread))
|
||||
panic("alpha_check_fpcurthread: bogus");
|
||||
critical_exit(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define SET_FEN(p) \
|
||||
(p)->p_addr->u_pcb.pcb_hw.apcb_flags |= ALPHA_PCB_FLAGS_FEN
|
||||
#define SET_FEN(td) \
|
||||
(td)->td_pcb->pcb_hw.apcb_flags |= ALPHA_PCB_FLAGS_FEN
|
||||
|
||||
#define CLEAR_FEN(p) \
|
||||
(p)->p_addr->u_pcb.pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN
|
||||
#define CLEAR_FEN(td) \
|
||||
(td)->td_pcb->pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN
|
||||
|
||||
/*
|
||||
* Save the floating point state in the pcb. Use this to get read-only
|
||||
@ -2006,14 +2017,14 @@ alpha_fpstate_check(struct proc *p)
|
||||
* FEN trap.
|
||||
*/
|
||||
void
|
||||
alpha_fpstate_save(struct proc *p, int write)
|
||||
alpha_fpstate_save(struct thread *td, int write)
|
||||
{
|
||||
critical_t s;
|
||||
|
||||
s = critical_enter();
|
||||
if (p != NULL && p == PCPU_GET(fpcurproc)) {
|
||||
if (td != NULL && td == PCPU_GET(fpcurthread)) {
|
||||
/*
|
||||
* If curproc != fpcurproc, then we need to enable FEN
|
||||
* If curthread != fpcurthread, then we need to enable FEN
|
||||
* so that we can dump the fp state.
|
||||
*/
|
||||
alpha_pal_wrfen(1);
|
||||
@ -2021,27 +2032,27 @@ alpha_fpstate_save(struct proc *p, int write)
|
||||
/*
|
||||
* Save the state in the pcb.
|
||||
*/
|
||||
savefpstate(&p->p_addr->u_pcb.pcb_fp);
|
||||
savefpstate(&td->td_pcb->pcb_fp);
|
||||
|
||||
if (write) {
|
||||
/*
|
||||
* If fpcurproc == curproc, just ask the
|
||||
* If fpcurthread == curthread, just ask the
|
||||
* PALcode to disable FEN, otherwise we must
|
||||
* clear the FEN bit in fpcurproc's pcb.
|
||||
* clear the FEN bit in fpcurthread's pcb.
|
||||
*/
|
||||
if (PCPU_GET(fpcurproc) == curproc)
|
||||
if (PCPU_GET(fpcurthread) == curthread)
|
||||
alpha_pal_wrfen(0);
|
||||
else
|
||||
CLEAR_FEN(PCPU_GET(fpcurproc));
|
||||
PCPU_SET(fpcurproc, NULL);
|
||||
CLEAR_FEN(PCPU_GET(fpcurthread));
|
||||
PCPU_SET(fpcurthread, NULL);
|
||||
} else {
|
||||
/*
|
||||
* Make sure that we leave FEN enabled if
|
||||
* curproc == fpcurproc. We must have at most
|
||||
* curthread == fpcurthread. We must have at most
|
||||
* one process with FEN enabled. Note that FEN
|
||||
* must already be set in fpcurproc's pcb.
|
||||
* must already be set in fpcurthread's pcb.
|
||||
*/
|
||||
if (curproc != PCPU_GET(fpcurproc))
|
||||
if (curthread != PCPU_GET(fpcurthread))
|
||||
alpha_pal_wrfen(0);
|
||||
}
|
||||
}
|
||||
@ -2054,13 +2065,13 @@ alpha_fpstate_save(struct proc *p, int write)
|
||||
* (e.g. on sigreturn).
|
||||
*/
|
||||
void
|
||||
alpha_fpstate_drop(struct proc *p)
|
||||
alpha_fpstate_drop(struct thread *td)
|
||||
{
|
||||
critical_t s;
|
||||
|
||||
s = critical_enter();
|
||||
if (p == PCPU_GET(fpcurproc)) {
|
||||
if (p == curproc) {
|
||||
if (td == PCPU_GET(fpcurthread)) {
|
||||
if (td == curthread) {
|
||||
/*
|
||||
* Disable FEN via the PALcode. This will
|
||||
* clear the bit in the pcb as well.
|
||||
@ -2070,9 +2081,9 @@ alpha_fpstate_drop(struct proc *p)
|
||||
/*
|
||||
* Clear the FEN bit of the pcb.
|
||||
*/
|
||||
CLEAR_FEN(p);
|
||||
CLEAR_FEN(td);
|
||||
}
|
||||
PCPU_SET(fpcurproc, NULL);
|
||||
PCPU_SET(fpcurthread, NULL);
|
||||
}
|
||||
critical_exit(s);
|
||||
}
|
||||
@ -2082,7 +2093,7 @@ alpha_fpstate_drop(struct proc *p)
|
||||
* from the pcb.
|
||||
*/
|
||||
void
|
||||
alpha_fpstate_switch(struct proc *p)
|
||||
alpha_fpstate_switch(struct thread *td)
|
||||
{
|
||||
critical_t s;
|
||||
|
||||
@ -2091,31 +2102,31 @@ alpha_fpstate_switch(struct proc *p)
|
||||
*/
|
||||
s = critical_enter();
|
||||
alpha_pal_wrfen(1);
|
||||
if (PCPU_GET(fpcurproc)) {
|
||||
if (PCPU_GET(fpcurthread)) {
|
||||
/*
|
||||
* Dump the old fp state if its valid.
|
||||
*/
|
||||
savefpstate(&PCPU_GET(fpcurproc)->p_addr->u_pcb.pcb_fp);
|
||||
CLEAR_FEN(PCPU_GET(fpcurproc));
|
||||
savefpstate(&PCPU_GET(fpcurthread)->td_pcb->pcb_fp);
|
||||
CLEAR_FEN(PCPU_GET(fpcurthread));
|
||||
}
|
||||
|
||||
/*
|
||||
* Remember the new FP owner and reload its state.
|
||||
*/
|
||||
PCPU_SET(fpcurproc, p);
|
||||
restorefpstate(&PCPU_GET(fpcurproc)->p_addr->u_pcb.pcb_fp);
|
||||
PCPU_SET(fpcurthread, td);
|
||||
restorefpstate(&PCPU_GET(fpcurthread)->td_pcb->pcb_fp);
|
||||
|
||||
/*
|
||||
* If the new owner is curproc, leave FEN enabled, otherwise
|
||||
* If the new owner is curthread, leave FEN enabled, otherwise
|
||||
* mark its PCB so that it gets FEN when we context switch to
|
||||
* it later.
|
||||
*/
|
||||
if (p != curproc) {
|
||||
if (td != curthread) {
|
||||
alpha_pal_wrfen(0);
|
||||
SET_FEN(p);
|
||||
SET_FEN(td);
|
||||
}
|
||||
|
||||
p->p_md.md_flags |= MDP_FPUSED;
|
||||
td->td_md.md_flags |= MDP_FPUSED;
|
||||
critical_exit(s);
|
||||
}
|
||||
|
||||
@ -2129,7 +2140,7 @@ globaldata_init(struct globaldata *globaldata, int cpuid, size_t sz)
|
||||
globaldata->gd_idlepcbphys = vtophys((vm_offset_t) &globaldata->gd_idlepcb);
|
||||
globaldata->gd_idlepcb.apcb_ksp = (u_int64_t)
|
||||
((caddr_t) globaldata + sz - sizeof(struct trapframe));
|
||||
globaldata->gd_idlepcb.apcb_ptbr = proc0.p_addr->u_pcb.pcb_hw.apcb_ptbr;
|
||||
globaldata->gd_idlepcb.apcb_ptbr = thread0->td_pcb->pcb_hw.apcb_ptbr;
|
||||
globaldata->gd_cpuid = cpuid;
|
||||
globaldata->gd_next_asn = 0;
|
||||
globaldata->gd_current_asngen = 1;
|
||||
|
@ -100,12 +100,12 @@ static struct cdevsw mem_cdevsw = {
|
||||
struct mem_range_softc mem_range_softc;
|
||||
|
||||
static int
|
||||
mmclose(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
mmclose(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
switch (minor(dev)) {
|
||||
#ifdef PERFMON
|
||||
case 32:
|
||||
return perfmon_close(dev, flags, fmt, p);
|
||||
return perfmon_close(dev, flags, fmt, td);
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
@ -114,7 +114,7 @@ mmclose(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
mmopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
mmopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
|
||||
switch (minor(dev)) {
|
||||
@ -125,7 +125,7 @@ mmopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
break;
|
||||
case 32:
|
||||
#ifdef PERFMON
|
||||
return perfmon_open(dev, flags, fmt, p);
|
||||
return perfmon_open(dev, flags, fmt, td);
|
||||
#else
|
||||
return ENODEV;
|
||||
#endif
|
||||
@ -240,12 +240,12 @@ memmmap(dev_t dev, vm_offset_t offset, int prot)
|
||||
}
|
||||
|
||||
static int
|
||||
mmioctl(dev_t dev, u_long cmd, caddr_t cmdarg, int flags, struct proc *p)
|
||||
mmioctl(dev_t dev, u_long cmd, caddr_t cmdarg, int flags, struct thread *td)
|
||||
{
|
||||
switch(minor(dev)) {
|
||||
#ifdef PERFMON
|
||||
case 32:
|
||||
return perfmon_ioctl(dev, cmd, cmdarg, flags, p);
|
||||
return perfmon_ioctl(dev, cmd, cmdarg, flags, td);
|
||||
#endif
|
||||
default:
|
||||
return ENODEV;
|
||||
|
@ -158,7 +158,7 @@ smp_init_secondary(void)
|
||||
* Set curproc to our per-cpu idleproc so that mutexes have
|
||||
* something unique to lock with.
|
||||
*/
|
||||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
PCPU_SET(curthread, PCPU_GET(idlethread));
|
||||
PCPU_SET(spinlocks, NULL);
|
||||
|
||||
/*
|
||||
@ -175,12 +175,12 @@ smp_init_secondary(void)
|
||||
*
|
||||
* cache idleproc's physical address.
|
||||
*/
|
||||
curproc->p_md.md_pcbpaddr = (struct pcb *)PCPU_GET(idlepcbphys);
|
||||
curthread->td_md.md_pcbpaddr = (struct pcb *)PCPU_GET(idlepcbphys);
|
||||
/*
|
||||
* and make idleproc's trapframe pointer point to its
|
||||
* stack pointer for sanity.
|
||||
*/
|
||||
curproc->p_frame =
|
||||
curthread->td_frame =
|
||||
(struct trapframe *)globalp->gd_idlepcb.apcb_ksp;
|
||||
|
||||
mtx_lock_spin(&ap_boot_mtx);
|
||||
@ -232,7 +232,7 @@ smp_start_secondary(int cpuid)
|
||||
if (bootverbose)
|
||||
printf("smp_start_secondary: starting cpu %d\n", cpuid);
|
||||
|
||||
sz = round_page(UPAGES * PAGE_SIZE);
|
||||
sz = round_page((UAREA_PAGES + KSTACK_PAGES) * PAGE_SIZE);
|
||||
globaldata = malloc(sz, M_TEMP, M_NOWAIT);
|
||||
if (!globaldata) {
|
||||
printf("smp_start_secondary: can't allocate memory\n");
|
||||
|
@ -337,7 +337,7 @@ static pmap_t pmap_active[MAXCPU];
|
||||
static vm_zone_t pvzone;
|
||||
static struct vm_zone pvzone_store;
|
||||
static struct vm_object pvzone_obj;
|
||||
static int pv_entry_count=0, pv_entry_max=0, pv_entry_high_water=0;
|
||||
static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0;
|
||||
static int pmap_pagedaemon_waken = 0;
|
||||
static struct pv_entry *pvinit;
|
||||
|
||||
@ -564,9 +564,9 @@ pmap_bootstrap(vm_offset_t ptaddr, u_int maxasn)
|
||||
* Set up proc0's PCB such that the ptbr points to the right place
|
||||
* and has the kernel pmap's.
|
||||
*/
|
||||
proc0.p_addr->u_pcb.pcb_hw.apcb_ptbr =
|
||||
thread0->td_pcb->pcb_hw.apcb_ptbr =
|
||||
ALPHA_K0SEG_TO_PHYS((vm_offset_t)Lev1map) >> PAGE_SHIFT;
|
||||
proc0.p_addr->u_pcb.pcb_hw.apcb_asn = 0;
|
||||
thread0->td_pcb->pcb_hw.apcb_asn = 0;
|
||||
}
|
||||
|
||||
int
|
||||
@ -934,22 +934,22 @@ pmap_new_proc(struct proc *p)
|
||||
*/
|
||||
upobj = p->p_upages_obj;
|
||||
if (upobj == NULL) {
|
||||
upobj = vm_object_allocate(OBJT_DEFAULT, UPAGES);
|
||||
upobj = vm_object_allocate(OBJT_DEFAULT, UAREA_PAGES);
|
||||
p->p_upages_obj = upobj;
|
||||
}
|
||||
|
||||
/* get a kernel virtual address for the UPAGES for this proc */
|
||||
up = (vm_offset_t)p->p_addr;
|
||||
up = (vm_offset_t)p->p_uarea;
|
||||
if (up == 0) {
|
||||
up = kmem_alloc_nofault(kernel_map, UPAGES * PAGE_SIZE);
|
||||
up = kmem_alloc_nofault(kernel_map, UAREA_PAGES * PAGE_SIZE);
|
||||
if (up == 0)
|
||||
panic("pmap_new_proc: upage allocation failed");
|
||||
p->p_addr = (struct user *)up;
|
||||
p->p_uarea = (struct user *)up;
|
||||
}
|
||||
|
||||
ptek = vtopte(up);
|
||||
|
||||
for (i = 0; i < UPAGES; i++) {
|
||||
for (i = 0; i < UAREA_PAGES; i++) {
|
||||
/*
|
||||
* Get a kernel stack page
|
||||
*/
|
||||
@ -992,9 +992,9 @@ pmap_dispose_proc(p)
|
||||
pt_entry_t *ptek, oldpte;
|
||||
|
||||
upobj = p->p_upages_obj;
|
||||
up = (vm_offset_t)p->p_addr;
|
||||
up = (vm_offset_t)p->p_uarea;
|
||||
ptek = vtopte(up);
|
||||
for (i = 0; i < UPAGES; i++) {
|
||||
for (i = 0; i < UAREA_PAGES; i++) {
|
||||
m = vm_page_lookup(upobj, i);
|
||||
if (m == NULL)
|
||||
panic("pmap_dispose_proc: upage already missing?");
|
||||
@ -1019,14 +1019,9 @@ pmap_swapout_proc(p)
|
||||
vm_offset_t up;
|
||||
vm_page_t m;
|
||||
|
||||
/*
|
||||
* Make sure we aren't fpcurproc.
|
||||
*/
|
||||
alpha_fpstate_save(p, 1);
|
||||
|
||||
upobj = p->p_upages_obj;
|
||||
up = (vm_offset_t)p->p_addr;
|
||||
for (i = 0; i < UPAGES; i++) {
|
||||
up = (vm_offset_t)p->p_uarea;
|
||||
for (i = 0; i < UAREA_PAGES; i++) {
|
||||
m = vm_page_lookup(upobj, i);
|
||||
if (m == NULL)
|
||||
panic("pmap_swapout_proc: upage already missing?");
|
||||
@ -1049,8 +1044,8 @@ pmap_swapin_proc(p)
|
||||
vm_page_t m;
|
||||
|
||||
upobj = p->p_upages_obj;
|
||||
up = (vm_offset_t)p->p_addr;
|
||||
for (i = 0; i < UPAGES; i++) {
|
||||
up = (vm_offset_t)p->p_uarea;
|
||||
for (i = 0; i < UAREA_PAGES; i++) {
|
||||
m = vm_page_grab(upobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
|
||||
pmap_kenter(up + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m));
|
||||
if (m->valid != VM_PAGE_BITS_ALL) {
|
||||
@ -1064,12 +1059,180 @@ pmap_swapin_proc(p)
|
||||
vm_page_wakeup(m);
|
||||
vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the kernel stack for a new thread.
|
||||
* This routine directly affects the fork perf for a process and thread.
|
||||
*/
|
||||
void
|
||||
pmap_new_thread(struct thread *td)
|
||||
{
|
||||
int i;
|
||||
vm_object_t ksobj;
|
||||
vm_offset_t ks;
|
||||
vm_page_t m;
|
||||
pt_entry_t *ptek, oldpte;
|
||||
|
||||
/*
|
||||
* allocate object for the upages
|
||||
*/
|
||||
ksobj = td->td_kstack_obj;
|
||||
if (ksobj == NULL) {
|
||||
ksobj = vm_object_allocate(OBJT_DEFAULT, KSTACK_PAGES);
|
||||
td->td_kstack_obj = ksobj;
|
||||
}
|
||||
|
||||
#ifdef KSTACK_GUARD
|
||||
/* get a kernel virtual address for the kstack for this thread */
|
||||
ks = td->td_kstack;
|
||||
if (ks == 0) {
|
||||
ks = kmem_alloc_nofault(kernel_map,
|
||||
(KSTACK_PAGES + 1) * PAGE_SIZE);
|
||||
if (ks == NULL)
|
||||
panic("pmap_new_thread: kstack allocation failed");
|
||||
ks += PAGE_SIZE;
|
||||
td->td_kstack = ks;
|
||||
}
|
||||
|
||||
ptek = vtopte(ks - PAGE_SIZE);
|
||||
oldpte = *ptek;
|
||||
*ptek = 0;
|
||||
if (oldpte)
|
||||
pmap_invalidate_page(kernel_pmap, ks - PAGE_SIZE);
|
||||
ptek++;
|
||||
#else
|
||||
/* get a kernel virtual address for the kstack for this thread */
|
||||
ks = td->td_kstack;
|
||||
if (ks == 0) {
|
||||
ks = kmem_alloc_nofault(kernel_map, KSTACK_PAGES * PAGE_SIZE);
|
||||
if (ks == NULL)
|
||||
panic("pmap_new_thread: kstack allocation failed");
|
||||
td->td_kstack = ks;
|
||||
}
|
||||
ptek = vtopte(ks);
|
||||
#endif
|
||||
for (i = 0; i < KSTACK_PAGES; i++) {
|
||||
/*
|
||||
* Get a kernel stack page
|
||||
*/
|
||||
m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
|
||||
|
||||
/*
|
||||
* Wire the page
|
||||
*/
|
||||
m->wire_count++;
|
||||
cnt.v_wire_count++;
|
||||
|
||||
oldpte = *(ptek + i);
|
||||
/*
|
||||
* Enter the page into the kernel address space.
|
||||
*/
|
||||
*(ptek + i) = pmap_phys_to_pte(VM_PAGE_TO_PHYS(m))
|
||||
| PG_ASM | PG_KRE | PG_KWE | PG_V;
|
||||
if (oldpte)
|
||||
pmap_invalidate_page(kernel_pmap, ks + i * PAGE_SIZE);
|
||||
|
||||
vm_page_wakeup(m);
|
||||
vm_page_flag_clear(m, PG_ZERO);
|
||||
vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE);
|
||||
m->valid = VM_PAGE_BITS_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dispose the kernel stack for a thread that has exited.
|
||||
* This routine directly impacts the exit perf of a thread.
|
||||
*/
|
||||
void
|
||||
pmap_dispose_thread(td)
|
||||
struct thread *td;
|
||||
{
|
||||
int i;
|
||||
vm_object_t ksobj;
|
||||
vm_offset_t ks;
|
||||
vm_page_t m;
|
||||
pt_entry_t *ptek, oldpte;
|
||||
|
||||
ksobj = td->td_kstack_obj;
|
||||
ks = td->td_kstack;
|
||||
ptek = vtopte(ks);
|
||||
for (i = 0; i < KSTACK_PAGES; i++) {
|
||||
m = vm_page_lookup(ksobj, i);
|
||||
if (m == NULL)
|
||||
panic("pmap_dispose_thread: kstack already missing?");
|
||||
vm_page_busy(m);
|
||||
oldpte = *(ptek + i);
|
||||
*(ptek + i) = 0;
|
||||
pmap_invalidate_page(kernel_pmap, ks + i * PAGE_SIZE);
|
||||
vm_page_unwire(m, 0);
|
||||
vm_page_free(m);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Allow the kernel stack for a thread to be prejudicially paged out.
|
||||
*/
|
||||
void
|
||||
pmap_swapout_thread(td)
|
||||
struct thread *td;
|
||||
{
|
||||
int i;
|
||||
vm_object_t ksobj;
|
||||
vm_offset_t ks;
|
||||
vm_page_t m;
|
||||
|
||||
/*
|
||||
* Make sure we aren't fpcurthread.
|
||||
*/
|
||||
alpha_fpstate_save(td, 1);
|
||||
|
||||
ksobj = td->td_kstack_obj;
|
||||
ks = td->td_kstack;
|
||||
for (i = 0; i < KSTACK_PAGES; i++) {
|
||||
m = vm_page_lookup(ksobj, i);
|
||||
if (m == NULL)
|
||||
panic("pmap_swapout_thread: kstack already missing?");
|
||||
vm_page_dirty(m);
|
||||
vm_page_unwire(m, 0);
|
||||
pmap_kremove(ks + i * PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Bring the kernel stack for a specified thread back in.
|
||||
*/
|
||||
void
|
||||
pmap_swapin_thread(td)
|
||||
struct thread *td;
|
||||
{
|
||||
int i, rv;
|
||||
vm_object_t ksobj;
|
||||
vm_offset_t ks;
|
||||
vm_page_t m;
|
||||
|
||||
ksobj = td->td_kstack_obj;
|
||||
ks = td->td_kstack;
|
||||
for (i = 0; i < KSTACK_PAGES; i++) {
|
||||
m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
|
||||
pmap_kenter(ks + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m));
|
||||
if (m->valid != VM_PAGE_BITS_ALL) {
|
||||
rv = vm_pager_get_pages(ksobj, &m, 1, 0);
|
||||
if (rv != VM_PAGER_OK)
|
||||
panic("pmap_swapin_thread: cannot get kstack for proc: %d\n", td->td_proc->p_pid);
|
||||
m = vm_page_lookup(ksobj, i);
|
||||
m->valid = VM_PAGE_BITS_ALL;
|
||||
}
|
||||
vm_page_wire(m);
|
||||
vm_page_wakeup(m);
|
||||
vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE);
|
||||
}
|
||||
|
||||
/*
|
||||
* The pcb may be at a different physical address now so cache the
|
||||
* new address.
|
||||
*/
|
||||
p->p_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)&p->p_addr->u_pcb);
|
||||
td->td_md.md_pcbpaddr = (void *)vtophys((vm_offset_t)td->td_pcb);
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
@ -1677,7 +1840,7 @@ pmap_collect()
|
||||
{
|
||||
int i;
|
||||
vm_page_t m;
|
||||
static int warningdone=0;
|
||||
static int warningdone = 0;
|
||||
|
||||
if (pmap_pagedaemon_waken == 0)
|
||||
return;
|
||||
@ -2917,7 +3080,7 @@ pmap_clear_reference(vm_page_t m)
|
||||
* From NetBSD
|
||||
*/
|
||||
void
|
||||
pmap_emulate_reference(struct proc *p, vm_offset_t v, int user, int write)
|
||||
pmap_emulate_reference(struct vmspace *vm, vm_offset_t v, int user, int write)
|
||||
{
|
||||
pt_entry_t faultoff, *pte;
|
||||
vm_offset_t pa;
|
||||
@ -2932,9 +3095,8 @@ pmap_emulate_reference(struct proc *p, vm_offset_t v, int user, int write)
|
||||
pte = vtopte(v);
|
||||
user_addr = 0;
|
||||
} else {
|
||||
KASSERT(p != NULL, ("pmap_emulate_reference: bad proc"));
|
||||
KASSERT(p->p_vmspace != NULL, ("pmap_emulate_reference: bad p_vmspace"));
|
||||
pte = pmap_lev3pte(p->p_vmspace->vm_map.pmap, v);
|
||||
KASSERT(vm != NULL, ("pmap_emulate_reference: bad vmspace"));
|
||||
pte = pmap_lev3pte(vm->vm_map.pmap, v);
|
||||
user_addr = 1;
|
||||
}
|
||||
#ifdef DEBUG /* These checks are more expensive */
|
||||
@ -2964,7 +3126,7 @@ pmap_emulate_reference(struct proc *p, vm_offset_t v, int user, int write)
|
||||
|
||||
KASSERT((*pte & PG_MANAGED) != 0,
|
||||
("pmap_emulate_reference(%p, 0x%lx, %d, %d): pa 0x%lx not managed",
|
||||
p, v, user, write, pa));
|
||||
curthread, v, user, write, pa));
|
||||
|
||||
/*
|
||||
* Twiddle the appropriate bits to reflect the reference
|
||||
@ -3092,11 +3254,11 @@ pmap_mincore(pmap, addr)
|
||||
}
|
||||
|
||||
void
|
||||
pmap_activate(struct proc *p)
|
||||
pmap_activate(struct thread *td)
|
||||
{
|
||||
pmap_t pmap;
|
||||
|
||||
pmap = vmspace_pmap(p->p_vmspace);
|
||||
pmap = vmspace_pmap(td->td_proc->p_vmspace);
|
||||
|
||||
if (pmap_active[PCPU_GET(cpuid)] && pmap != pmap_active[PCPU_GET(cpuid)]) {
|
||||
atomic_clear_32(&pmap_active[PCPU_GET(cpuid)]->pm_active,
|
||||
@ -3104,7 +3266,7 @@ pmap_activate(struct proc *p)
|
||||
pmap_active[PCPU_GET(cpuid)] = 0;
|
||||
}
|
||||
|
||||
p->p_addr->u_pcb.pcb_hw.apcb_ptbr =
|
||||
td->td_pcb->pcb_hw.apcb_ptbr =
|
||||
ALPHA_K0SEG_TO_PHYS((vm_offset_t) pmap->pm_lev1) >> PAGE_SHIFT;
|
||||
|
||||
if (pmap->pm_asn[PCPU_GET(cpuid)].gen != PCPU_GET(current_asngen))
|
||||
@ -3113,18 +3275,19 @@ pmap_activate(struct proc *p)
|
||||
pmap_active[PCPU_GET(cpuid)] = pmap;
|
||||
atomic_set_32(&pmap->pm_active, 1 << PCPU_GET(cpuid));
|
||||
|
||||
p->p_addr->u_pcb.pcb_hw.apcb_asn = pmap->pm_asn[PCPU_GET(cpuid)].asn;
|
||||
td->td_pcb->pcb_hw.apcb_asn = pmap->pm_asn[PCPU_GET(cpuid)].asn;
|
||||
|
||||
if (p == curproc) {
|
||||
alpha_pal_swpctx((u_long)p->p_md.md_pcbpaddr);
|
||||
if (td == curthread) {
|
||||
alpha_pal_swpctx((u_long)td->td_md.md_pcbpaddr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pmap_deactivate(struct proc *p)
|
||||
pmap_deactivate(struct thread *td)
|
||||
{
|
||||
pmap_t pmap;
|
||||
pmap = vmspace_pmap(p->p_vmspace);
|
||||
|
||||
pmap = vmspace_pmap(td->td_proc->p_vmspace);
|
||||
atomic_clear_32(&pmap->pm_active, 1 << PCPU_GET(cpuid));
|
||||
pmap_active[PCPU_GET(cpuid)] = 0;
|
||||
}
|
||||
@ -3154,14 +3317,14 @@ pmap_pid_dump(int pid)
|
||||
int i,j;
|
||||
index = 0;
|
||||
pmap = vmspace_pmap(p->p_vmspace);
|
||||
for(i=0;i<1024;i++) {
|
||||
for (i = 0; i < 1024; i++) {
|
||||
pd_entry_t *pde;
|
||||
pt_entry_t *pte;
|
||||
unsigned base = i << PDRSHIFT;
|
||||
|
||||
pde = &pmap->pm_pdir[i];
|
||||
if (pde && pmap_pde_v(pde)) {
|
||||
for(j=0;j<1024;j++) {
|
||||
for (j = 0; j < 1024; j++) {
|
||||
unsigned va = base + (j << PAGE_SHIFT);
|
||||
if (va >= (vm_offset_t) VM_MIN_KERNEL_ADDRESS) {
|
||||
if (index) {
|
||||
|
@ -85,7 +85,7 @@
|
||||
int error; \
|
||||
\
|
||||
mtx_lock_spin(&sched_lock); \
|
||||
if ((p->p_sflag & PS_INMEM) == 0) \
|
||||
if ((td->td_proc->p_sflag & PS_INMEM) == 0) \
|
||||
error = EIO; \
|
||||
else \
|
||||
error = (action); \
|
||||
@ -94,21 +94,21 @@
|
||||
} while(0)
|
||||
|
||||
int
|
||||
procfs_read_regs(p, regs)
|
||||
struct proc *p;
|
||||
procfs_read_regs(td, regs)
|
||||
struct thread *td;
|
||||
struct reg *regs;
|
||||
{
|
||||
|
||||
PROCFS_ACTION(fill_regs(p, regs));
|
||||
PROCFS_ACTION(fill_regs(td, regs));
|
||||
}
|
||||
|
||||
int
|
||||
procfs_write_regs(p, regs)
|
||||
struct proc *p;
|
||||
procfs_write_regs(td, regs)
|
||||
struct thread *td;
|
||||
struct reg *regs;
|
||||
{
|
||||
|
||||
PROCFS_ACTION(set_regs(p, regs));
|
||||
PROCFS_ACTION(set_regs(td, regs));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -117,26 +117,26 @@ procfs_write_regs(p, regs)
|
||||
*/
|
||||
|
||||
int
|
||||
procfs_read_fpregs(p, fpregs)
|
||||
struct proc *p;
|
||||
procfs_read_fpregs(td, fpregs)
|
||||
struct thread *td;
|
||||
struct fpreg *fpregs;
|
||||
{
|
||||
|
||||
PROCFS_ACTION(fill_fpregs(p, fpregs));
|
||||
PROCFS_ACTION(fill_fpregs(td, fpregs));
|
||||
}
|
||||
|
||||
int
|
||||
procfs_write_fpregs(p, fpregs)
|
||||
struct proc *p;
|
||||
procfs_write_fpregs(td, fpregs)
|
||||
struct thread *td;
|
||||
struct fpreg *fpregs;
|
||||
{
|
||||
|
||||
PROCFS_ACTION(set_fpregs(p, fpregs));
|
||||
PROCFS_ACTION(set_fpregs(td, fpregs));
|
||||
}
|
||||
|
||||
int
|
||||
procfs_sstep(p)
|
||||
struct proc *p;
|
||||
procfs_sstep(td)
|
||||
struct thread *td;
|
||||
{
|
||||
return (EINVAL);
|
||||
}
|
||||
@ -145,16 +145,16 @@ procfs_sstep(p)
|
||||
* Placeholders
|
||||
*/
|
||||
int
|
||||
procfs_read_dbregs(p, dbregs)
|
||||
struct proc *p;
|
||||
procfs_read_dbregs(td, dbregs)
|
||||
struct thread *td;
|
||||
struct dbreg *dbregs;
|
||||
{
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
int
|
||||
procfs_write_dbregs(p, dbregs)
|
||||
struct proc *p;
|
||||
procfs_write_dbregs(td, dbregs)
|
||||
struct thread *td;
|
||||
struct dbreg *dbregs;
|
||||
{
|
||||
return (EIO);
|
||||
|
@ -315,8 +315,8 @@ hwrpb_restart_setup()
|
||||
p = (struct pcs *)((char *)hwrpb + hwrpb->rpb_pcs_off);
|
||||
p->pcs_flags &= ~PCS_BIP;
|
||||
|
||||
bcopy(&proc0.p_addr->u_pcb.pcb_hw, p->pcs_hwpcb,
|
||||
sizeof proc0.p_addr->u_pcb.pcb_hw);
|
||||
bcopy(&thread0->td_pcb->pcb_hw, p->pcs_hwpcb,
|
||||
sizeof thread0->td_pcb->pcb_hw);
|
||||
hwrpb->rpb_vptb = VPTBASE;
|
||||
|
||||
/* when 'c'ontinuing from console halt, do a dump */
|
||||
|
@ -92,10 +92,10 @@ int promparam __P((struct tty *, struct termios *));
|
||||
void promstop __P((struct tty *, int));
|
||||
|
||||
int
|
||||
promopen(dev, flag, mode, p)
|
||||
promopen(dev, flag, mode, td)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
struct tty *tp;
|
||||
int unit = minor(dev);
|
||||
@ -124,7 +124,7 @@ promopen(dev, flag, mode, p)
|
||||
ttsetwater(tp);
|
||||
|
||||
setuptimeout = 1;
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(p)) {
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(td->td_proc)) {
|
||||
splx(s);
|
||||
return EBUSY;
|
||||
}
|
||||
@ -143,10 +143,10 @@ promopen(dev, flag, mode, p)
|
||||
}
|
||||
|
||||
int
|
||||
promclose(dev, flag, mode, p)
|
||||
promclose(dev, flag, mode, td)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
int unit = minor(dev);
|
||||
struct tty *tp = prom_tp;
|
||||
@ -161,12 +161,12 @@ promclose(dev, flag, mode, p)
|
||||
}
|
||||
|
||||
int
|
||||
promioctl(dev, cmd, data, flag, p)
|
||||
promioctl(dev, cmd, data, flag, td)
|
||||
dev_t dev;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
int unit = minor(dev);
|
||||
struct tty *tp = prom_tp;
|
||||
@ -175,7 +175,7 @@ promioctl(dev, cmd, data, flag, p)
|
||||
if (unit != 0)
|
||||
return ENXIO;
|
||||
|
||||
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
|
||||
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td);
|
||||
if (error != ENOIOCTL)
|
||||
return error;
|
||||
error = ttioctl(tp, cmd, data, flag);
|
||||
|
@ -72,13 +72,13 @@
|
||||
beq t1, fusufault
|
||||
|
||||
lda t0, fusufault /* trap faults */
|
||||
ldq t2, GD_CURPROC(globalp)
|
||||
ldq t2, P_ADDR(t2)
|
||||
stq t0, U_PCB_ONFAULT(t2)
|
||||
ldq t2, GD_CURTHREAD(globalp)
|
||||
ldq t2, TD_PCB(t2)
|
||||
stq t0, PCB_ONFAULT(t2)
|
||||
|
||||
stq a1, 0(a0) /* try the store */
|
||||
|
||||
stq zero, U_PCB_ONFAULT(t2) /* clean up */
|
||||
stq zero, PCB_ONFAULT(t2) /* clean up */
|
||||
|
||||
mov zero, v0
|
||||
RET
|
||||
@ -92,9 +92,9 @@
|
||||
beq t1, fusufault
|
||||
|
||||
lda t0, fusufault /* trap faults */
|
||||
ldq t2, GD_CURPROC(globalp)
|
||||
ldq t2, P_ADDR(t2)
|
||||
stq t0, U_PCB_ONFAULT(t2)
|
||||
ldq t2, GD_CURTHREAD(globalp)
|
||||
ldq t2, TD_PCB(t2)
|
||||
stq t0, PCB_ONFAULT(t2)
|
||||
|
||||
zap a1, 0xfe, a1 /* mask off the byte to store */
|
||||
insbl a1, a0, a1 /* shift it to the right place */
|
||||
@ -103,7 +103,7 @@
|
||||
or a1, t0, a1 /* move it in */
|
||||
stq_u a1, 0(a0) /* and put the byte back */
|
||||
|
||||
stq zero, U_PCB_ONFAULT(t2) /* clean up */
|
||||
stq zero, PCB_ONFAULT(t2) /* clean up */
|
||||
|
||||
mov zero, v0
|
||||
RET
|
||||
@ -117,13 +117,13 @@
|
||||
beq t1, fusufault
|
||||
|
||||
lda t0, fusufault /* trap faults */
|
||||
ldq t2, GD_CURPROC(globalp)
|
||||
ldq t2, P_ADDR(t2)
|
||||
stq t0, U_PCB_ONFAULT(t2)
|
||||
ldq t2, GD_CURTHREAD(globalp)
|
||||
ldq t2, TD_PCB(t2)
|
||||
stq t0, PCB_ONFAULT(t2)
|
||||
|
||||
ldq v0, 0(a0) /* try the fetch */
|
||||
|
||||
stq zero, U_PCB_ONFAULT(t2) /* clean up */
|
||||
stq zero, PCB_ONFAULT(t2) /* clean up */
|
||||
|
||||
RET
|
||||
END(fuword)
|
||||
@ -136,14 +136,14 @@
|
||||
beq t1, fusufault
|
||||
|
||||
lda t0, fusufault /* trap faults */
|
||||
ldq t2, GD_CURPROC(globalp)
|
||||
ldq t2, P_ADDR(t2)
|
||||
stq t0, U_PCB_ONFAULT(t2)
|
||||
ldq t2, GD_CURTHREAD(globalp)
|
||||
ldq t2, TD_PCB(t2)
|
||||
stq t0, PCB_ONFAULT(t2)
|
||||
|
||||
ldq_u v0, 0(a0) /* get the word containing our byte */
|
||||
extbl v0, a0, v0 /* extract the byte */
|
||||
|
||||
stq zero, U_PCB_ONFAULT(t2) /* clean up */
|
||||
stq zero, PCB_ONFAULT(t2) /* clean up */
|
||||
|
||||
RET
|
||||
END(fubyte)
|
||||
@ -154,9 +154,9 @@
|
||||
END(suibyte)
|
||||
|
||||
LEAF(fusufault, 0)
|
||||
ldq t0, GD_CURPROC(globalp)
|
||||
ldq t0, P_ADDR(t0)
|
||||
stq zero, U_PCB_ONFAULT(t0)
|
||||
ldq t0, GD_CURTHREAD(globalp)
|
||||
ldq t0, TD_PCB(t0)
|
||||
stq zero, PCB_ONFAULT(t0)
|
||||
ldiq v0, -1
|
||||
RET
|
||||
END(fusufault)
|
||||
@ -222,15 +222,15 @@ NESTED(copyinstr, 4, 16, ra, 0, 0)
|
||||
beq t1, copyerr /* if it's not, error out. */
|
||||
lda v0, copyerr /* set up fault handler. */
|
||||
.set noat
|
||||
ldq at_reg, GD_CURPROC(globalp)
|
||||
ldq at_reg, P_ADDR(at_reg)
|
||||
stq v0, U_PCB_ONFAULT(at_reg)
|
||||
ldq at_reg, GD_CURTHREAD(globalp)
|
||||
ldq at_reg, TD_PCB(at_reg)
|
||||
stq v0, PCB_ONFAULT(at_reg)
|
||||
.set at
|
||||
CALL(copystr) /* do the copy. */
|
||||
.set noat
|
||||
ldq at_reg, GD_CURPROC(globalp) /* kill the fault handler. */
|
||||
ldq at_reg, P_ADDR(at_reg)
|
||||
stq zero, U_PCB_ONFAULT(at_reg)
|
||||
ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */
|
||||
ldq at_reg, TD_PCB(at_reg)
|
||||
stq zero, PCB_ONFAULT(at_reg)
|
||||
.set at
|
||||
ldq ra, (16-8)(sp) /* restore ra. */
|
||||
lda sp, 16(sp) /* kill stack frame. */
|
||||
@ -246,15 +246,15 @@ NESTED(copyoutstr, 4, 16, ra, 0, 0)
|
||||
beq t1, copyerr /* if it's not, error out. */
|
||||
lda v0, copyerr /* set up fault handler. */
|
||||
.set noat
|
||||
ldq at_reg, GD_CURPROC(globalp)
|
||||
ldq at_reg, P_ADDR(at_reg)
|
||||
stq v0, U_PCB_ONFAULT(at_reg)
|
||||
ldq at_reg, GD_CURTHREAD(globalp)
|
||||
ldq at_reg, TD_PCB(at_reg)
|
||||
stq v0, PCB_ONFAULT(at_reg)
|
||||
.set at
|
||||
CALL(copystr) /* do the copy. */
|
||||
.set noat
|
||||
ldq at_reg, GD_CURPROC(globalp) /* kill the fault handler. */
|
||||
ldq at_reg, P_ADDR(at_reg)
|
||||
stq zero, U_PCB_ONFAULT(at_reg)
|
||||
ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */
|
||||
ldq at_reg, TD_PCB(at_reg)
|
||||
stq zero, PCB_ONFAULT(at_reg)
|
||||
.set at
|
||||
ldq ra, (16-8)(sp) /* restore ra. */
|
||||
lda sp, 16(sp) /* kill stack frame. */
|
||||
@ -514,15 +514,15 @@ NESTED(copyin, 3, 16, ra, 0, 0)
|
||||
beq t1, copyerr /* if it's not, error out. */
|
||||
lda v0, copyerr /* set up fault handler. */
|
||||
.set noat
|
||||
ldq at_reg, GD_CURPROC(globalp)
|
||||
ldq at_reg, P_ADDR(at_reg)
|
||||
stq v0, U_PCB_ONFAULT(at_reg)
|
||||
ldq at_reg, GD_CURTHREAD(globalp)
|
||||
ldq at_reg, TD_PCB(at_reg)
|
||||
stq v0, PCB_ONFAULT(at_reg)
|
||||
.set at
|
||||
CALL(bcopy) /* do the copy. */
|
||||
.set noat
|
||||
ldq at_reg, GD_CURPROC(globalp) /* kill the fault handler. */
|
||||
ldq at_reg, P_ADDR(at_reg)
|
||||
stq zero, U_PCB_ONFAULT(at_reg)
|
||||
ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */
|
||||
ldq at_reg, TD_PCB(at_reg)
|
||||
stq zero, PCB_ONFAULT(at_reg)
|
||||
.set at
|
||||
ldq ra, (16-8)(sp) /* restore ra. */
|
||||
lda sp, 16(sp) /* kill stack frame. */
|
||||
@ -539,15 +539,15 @@ NESTED(copyout, 3, 16, ra, 0, 0)
|
||||
beq t1, copyerr /* if it's not, error out. */
|
||||
lda v0, copyerr /* set up fault handler. */
|
||||
.set noat
|
||||
ldq at_reg, GD_CURPROC(globalp)
|
||||
ldq at_reg, P_ADDR(at_reg)
|
||||
stq v0, U_PCB_ONFAULT(at_reg)
|
||||
ldq at_reg, GD_CURTHREAD(globalp)
|
||||
ldq at_reg, TD_PCB(at_reg)
|
||||
stq v0, PCB_ONFAULT(at_reg)
|
||||
.set at
|
||||
CALL(bcopy) /* do the copy. */
|
||||
.set noat
|
||||
ldq at_reg, GD_CURPROC(globalp) /* kill the fault handler. */
|
||||
ldq at_reg, P_ADDR(at_reg)
|
||||
stq zero, U_PCB_ONFAULT(at_reg)
|
||||
ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */
|
||||
ldq at_reg, TD_PCB(at_reg)
|
||||
stq zero, PCB_ONFAULT(at_reg)
|
||||
.set at
|
||||
ldq ra, (16-8)(sp) /* restore ra. */
|
||||
lda sp, 16(sp) /* kill stack frame. */
|
||||
@ -556,9 +556,9 @@ NESTED(copyout, 3, 16, ra, 0, 0)
|
||||
END(copyout)
|
||||
|
||||
LEAF(copyerr, 0)
|
||||
ldq t0, GD_CURPROC(globalp)
|
||||
ldq t0, P_ADDR(t0)
|
||||
stq zero, U_PCB_ONFAULT(t0) /* reset fault handler. */
|
||||
ldq t0, GD_CURTHREAD(globalp)
|
||||
ldq t0, TD_PCB(t0)
|
||||
stq zero, PCB_ONFAULT(t0) /* reset fault handler. */
|
||||
ldq ra, (16-8)(sp) /* restore ra. */
|
||||
lda sp, 16(sp) /* kill stack frame. */
|
||||
ldiq v0, EFAULT /* return EFAULT. */
|
||||
|
@ -49,13 +49,13 @@
|
||||
/*
|
||||
* savectx: save process context, i.e. callee-saved registers
|
||||
*
|
||||
* Note that savectx() only works for processes other than curproc,
|
||||
* Note that savectx() only works for processes other than curthread,
|
||||
* since cpu_switch will copy over the info saved here. (It _can_
|
||||
* sanely be used for curproc iff cpu_switch won't be called again, e.g.
|
||||
* sanely be used for curthread iff cpu_switch won't be called again, e.g.
|
||||
* from if called from boot().)
|
||||
*
|
||||
* Arguments:
|
||||
* a0 'struct user *' of the process that needs its context saved
|
||||
* a0 'struct pcb *' of the process that needs its context saved
|
||||
*
|
||||
* Return:
|
||||
* v0 0. (note that for child processes, it seems
|
||||
@ -66,17 +66,17 @@
|
||||
LEAF(savectx, 1)
|
||||
br pv, Lsavectx1
|
||||
Lsavectx1: LDGP(pv)
|
||||
stq sp, U_PCB_HWPCB_KSP(a0) /* store sp */
|
||||
stq s0, U_PCB_CONTEXT+(0 * 8)(a0) /* store s0 - s6 */
|
||||
stq s1, U_PCB_CONTEXT+(1 * 8)(a0)
|
||||
stq s2, U_PCB_CONTEXT+(2 * 8)(a0)
|
||||
stq s3, U_PCB_CONTEXT+(3 * 8)(a0)
|
||||
stq s4, U_PCB_CONTEXT+(4 * 8)(a0)
|
||||
stq s5, U_PCB_CONTEXT+(5 * 8)(a0)
|
||||
stq s6, U_PCB_CONTEXT+(6 * 8)(a0)
|
||||
stq ra, U_PCB_CONTEXT+(7 * 8)(a0) /* store ra */
|
||||
stq sp, PCB_HWPCB_KSP(a0) /* store sp */
|
||||
stq s0, PCB_CONTEXT+(0 * 8)(a0) /* store s0 - s6 */
|
||||
stq s1, PCB_CONTEXT+(1 * 8)(a0)
|
||||
stq s2, PCB_CONTEXT+(2 * 8)(a0)
|
||||
stq s3, PCB_CONTEXT+(3 * 8)(a0)
|
||||
stq s4, PCB_CONTEXT+(4 * 8)(a0)
|
||||
stq s5, PCB_CONTEXT+(5 * 8)(a0)
|
||||
stq s6, PCB_CONTEXT+(6 * 8)(a0)
|
||||
stq ra, PCB_CONTEXT+(7 * 8)(a0) /* store ra */
|
||||
call_pal PAL_OSF1_rdps /* NOTE: doesn't kill a0 */
|
||||
stq v0, U_PCB_CONTEXT+(8 * 8)(a0) /* store ps, for ipl */
|
||||
stq v0, PCB_CONTEXT+(8 * 8)(a0) /* store ps, for ipl */
|
||||
|
||||
mov zero, v0
|
||||
RET
|
||||
@ -103,49 +103,49 @@ LEAF(cpu_throw, 0)
|
||||
LEAF(cpu_switch, 1)
|
||||
LDGP(pv)
|
||||
/* do an inline savectx(), to save old context */
|
||||
ldq a0, GD_CURPROC(globalp)
|
||||
ldq a1, P_ADDR(a0)
|
||||
ldq a0, GD_CURTHREAD(globalp)
|
||||
ldq a1, TD_PCB(a0)
|
||||
/* NOTE: ksp is stored by the swpctx */
|
||||
stq s0, U_PCB_CONTEXT+(0 * 8)(a1) /* store s0 - s6 */
|
||||
stq s1, U_PCB_CONTEXT+(1 * 8)(a1)
|
||||
stq s2, U_PCB_CONTEXT+(2 * 8)(a1)
|
||||
stq s3, U_PCB_CONTEXT+(3 * 8)(a1)
|
||||
stq s4, U_PCB_CONTEXT+(4 * 8)(a1)
|
||||
stq s5, U_PCB_CONTEXT+(5 * 8)(a1)
|
||||
stq s6, U_PCB_CONTEXT+(6 * 8)(a1)
|
||||
stq ra, U_PCB_CONTEXT+(7 * 8)(a1) /* store ra */
|
||||
stq s0, PCB_CONTEXT+(0 * 8)(a1) /* store s0 - s6 */
|
||||
stq s1, PCB_CONTEXT+(1 * 8)(a1)
|
||||
stq s2, PCB_CONTEXT+(2 * 8)(a1)
|
||||
stq s3, PCB_CONTEXT+(3 * 8)(a1)
|
||||
stq s4, PCB_CONTEXT+(4 * 8)(a1)
|
||||
stq s5, PCB_CONTEXT+(5 * 8)(a1)
|
||||
stq s6, PCB_CONTEXT+(6 * 8)(a1)
|
||||
stq ra, PCB_CONTEXT+(7 * 8)(a1) /* store ra */
|
||||
call_pal PAL_OSF1_rdps /* NOTE: doesn't kill a0 */
|
||||
stq v0, U_PCB_CONTEXT+(8 * 8)(a1) /* store ps, for ipl */
|
||||
stq v0, PCB_CONTEXT+(8 * 8)(a1) /* store ps, for ipl */
|
||||
|
||||
mov a0, s0 /* save old curproc */
|
||||
mov a1, s1 /* save old U-area */
|
||||
mov a0, s0 /* s0 = old curthread */
|
||||
mov a1, s1 /* s1 = old pcb */
|
||||
|
||||
sw1:
|
||||
br pv, Lcs1
|
||||
Lcs1: LDGP(pv)
|
||||
CALL(chooseproc) /* can't return NULL */
|
||||
mov v0, s2
|
||||
ldq s3, P_MD_PCBPADDR(s2) /* save new pcbpaddr */
|
||||
CALL(choosethread) /* can't return NULL */
|
||||
mov v0, s2 /* s2 = new thread */
|
||||
ldq s3, TD_MD_PCBPADDR(s2) /* s3 = new pcbpaddr */
|
||||
|
||||
/*
|
||||
* Check to see if we're switching to ourself. If we are,
|
||||
* don't bother loading the new context.
|
||||
*
|
||||
* Note that even if we re-enter cpu_switch() from idle(),
|
||||
* s0 will still contain the old curproc value because any
|
||||
* s0 will still contain the old curthread value because any
|
||||
* users of that register between then and now must have
|
||||
* saved it. Also note that switch_exit() ensures that
|
||||
* s0 is clear before jumping here to find a new process.
|
||||
*/
|
||||
cmpeq s0, s2, t0 /* oldproc == newproc? */
|
||||
cmpeq s0, s2, t0 /* oldthread == newthread? */
|
||||
bne t0, Lcs7 /* Yes! Skip! */
|
||||
|
||||
#ifdef SMP
|
||||
/*
|
||||
* Save fp state if we have some.
|
||||
*/
|
||||
mov s0, a0 /* curproc */
|
||||
ldiq a1, 1 /* clear fpcurproc */
|
||||
mov s0, a0 /* curthread */
|
||||
ldiq a1, 1 /* clear fpcurthread */
|
||||
CALL(alpha_fpstate_save)
|
||||
#endif
|
||||
|
||||
@ -165,8 +165,8 @@ Lcs1: LDGP(pv)
|
||||
*/
|
||||
beq s0, Lcs6
|
||||
|
||||
mov s0, a0 /* pmap_deactivate(oldproc) */
|
||||
CALL(pmap_deactivate)
|
||||
mov s0, a0 /* pmap_deactivate(oldthread) */
|
||||
CALL(pmap_deactivate) /* XXXKSE */
|
||||
|
||||
Lcs6:
|
||||
/*
|
||||
@ -174,8 +174,8 @@ Lcs6:
|
||||
* the actual context swap.
|
||||
*/
|
||||
|
||||
mov s2, a0 /* pmap_activate(p) */
|
||||
CALL(pmap_activate)
|
||||
mov s2, a0 /* pmap_activate(newthread) */
|
||||
CALL(pmap_activate) /* XXXKSE */
|
||||
|
||||
mov s3, a0 /* swap the context */
|
||||
SWITCH_CONTEXT
|
||||
@ -183,28 +183,28 @@ Lcs6:
|
||||
Lcs7:
|
||||
|
||||
/*
|
||||
* Now that the switch is done, update curproc and other
|
||||
* Now that the switch is done, update curthread and other
|
||||
* globals. We must do this even if switching to ourselves
|
||||
* because we might have re-entered cpu_switch() from idle(),
|
||||
* in which case curproc would be NULL.
|
||||
* in which case curthread would be NULL.
|
||||
*/
|
||||
stq s2, GD_CURPROC(globalp) /* curproc = p */
|
||||
stq s2, GD_CURTHREAD(globalp) /* curthread = p */
|
||||
|
||||
/*
|
||||
* Now running on the new u struct.
|
||||
* Restore registers and return.
|
||||
*/
|
||||
ldq t0, P_ADDR(s2)
|
||||
ldq t0, TD_PCB(s2)
|
||||
|
||||
/* NOTE: ksp is restored by the swpctx */
|
||||
ldq s0, U_PCB_CONTEXT+(0 * 8)(t0) /* restore s0 - s6 */
|
||||
ldq s1, U_PCB_CONTEXT+(1 * 8)(t0)
|
||||
ldq s2, U_PCB_CONTEXT+(2 * 8)(t0)
|
||||
ldq s3, U_PCB_CONTEXT+(3 * 8)(t0)
|
||||
ldq s4, U_PCB_CONTEXT+(4 * 8)(t0)
|
||||
ldq s5, U_PCB_CONTEXT+(5 * 8)(t0)
|
||||
ldq s6, U_PCB_CONTEXT+(6 * 8)(t0)
|
||||
ldq ra, U_PCB_CONTEXT+(7 * 8)(t0) /* restore ra */
|
||||
ldq s0, PCB_CONTEXT+(0 * 8)(t0) /* restore s0 - s6 */
|
||||
ldq s1, PCB_CONTEXT+(1 * 8)(t0)
|
||||
ldq s2, PCB_CONTEXT+(2 * 8)(t0)
|
||||
ldq s3, PCB_CONTEXT+(3 * 8)(t0)
|
||||
ldq s4, PCB_CONTEXT+(4 * 8)(t0)
|
||||
ldq s5, PCB_CONTEXT+(5 * 8)(t0)
|
||||
ldq s6, PCB_CONTEXT+(6 * 8)(t0)
|
||||
ldq ra, PCB_CONTEXT+(7 * 8)(t0) /* restore ra */
|
||||
|
||||
ldiq v0, 1 /* possible ret to savectx() */
|
||||
RET
|
||||
|
@ -63,34 +63,34 @@ struct sysarch_args {
|
||||
};
|
||||
#endif
|
||||
|
||||
static int alpha_sethae(struct proc *p, char *args);
|
||||
static int alpha_get_fpmask(struct proc *p, char *args);
|
||||
static int alpha_set_fpmask(struct proc *p, char *args);
|
||||
static int alpha_set_uac(struct proc *p, char *args);
|
||||
static int alpha_get_uac(struct proc *p, char *args);
|
||||
static int alpha_sethae(struct thread *td, char *args);
|
||||
static int alpha_get_fpmask(struct thread *td, char *args);
|
||||
static int alpha_set_fpmask(struct thread *td, char *args);
|
||||
static int alpha_set_uac(struct thread *td, char *args);
|
||||
static int alpha_get_uac(struct thread *td, char *args);
|
||||
|
||||
int
|
||||
sysarch(p, uap)
|
||||
struct proc *p;
|
||||
sysarch(td, uap)
|
||||
struct thread *td;
|
||||
register struct sysarch_args *uap;
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
switch(SCARG(uap,op)) {
|
||||
case ALPHA_SETHAE:
|
||||
error = alpha_sethae(p, uap->parms);
|
||||
error = alpha_sethae(td, uap->parms);
|
||||
break;
|
||||
case ALPHA_GET_FPMASK:
|
||||
error = alpha_get_fpmask(p, uap->parms);
|
||||
error = alpha_get_fpmask(td, uap->parms);
|
||||
break;
|
||||
case ALPHA_SET_FPMASK:
|
||||
error = alpha_set_fpmask(p, uap->parms);
|
||||
error = alpha_set_fpmask(td, uap->parms);
|
||||
break;
|
||||
case ALPHA_SET_UAC:
|
||||
error = alpha_set_uac(p, uap->parms);
|
||||
error = alpha_set_uac(td, uap->parms);
|
||||
break;
|
||||
case ALPHA_GET_UAC:
|
||||
error = alpha_get_uac(p, uap->parms);
|
||||
error = alpha_get_uac(td, uap->parms);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -105,7 +105,7 @@ struct alpha_sethae_args {
|
||||
};
|
||||
|
||||
static int
|
||||
alpha_sethae(struct proc *p, char *args)
|
||||
alpha_sethae(struct thread *td, char *args)
|
||||
{
|
||||
int error;
|
||||
struct alpha_sethae_args ua;
|
||||
@ -117,12 +117,12 @@ alpha_sethae(struct proc *p, char *args)
|
||||
if (securelevel > 0)
|
||||
return (EPERM);
|
||||
|
||||
error = suser(p);
|
||||
error = suser(td->td_proc);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
p->p_md.md_flags |= MDP_HAEUSED;
|
||||
p->p_md.md_hae = ua.hae;
|
||||
td->td_md.md_flags |= MDP_HAEUSED;
|
||||
td->td_md.md_hae = ua.hae;
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -132,19 +132,19 @@ struct alpha_fpmask_args {
|
||||
};
|
||||
|
||||
static int
|
||||
alpha_get_fpmask(struct proc *p, char *args)
|
||||
alpha_get_fpmask(struct thread *td, char *args)
|
||||
{
|
||||
int error;
|
||||
struct alpha_fpmask_args ua;
|
||||
|
||||
ua.mask = p->p_addr->u_pcb.pcb_fp_control;
|
||||
ua.mask = td->td_pcb->pcb_fp_control;
|
||||
error = copyout(&ua, args, sizeof(struct alpha_fpmask_args));
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
alpha_set_fpmask(struct proc *p, char *args)
|
||||
alpha_set_fpmask(struct thread *td, char *args)
|
||||
{
|
||||
int error;
|
||||
u_int64_t oldmask, *fp_control;
|
||||
@ -154,7 +154,7 @@ alpha_set_fpmask(struct proc *p, char *args)
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
fp_control = &p->p_addr->u_pcb.pcb_fp_control;
|
||||
fp_control = &td->td_pcb->pcb_fp_control;
|
||||
oldmask = *fp_control;
|
||||
*fp_control = ua.mask & IEEE_TRAP_ENABLE_MASK;
|
||||
ua.mask = oldmask;
|
||||
@ -164,20 +164,23 @@ alpha_set_fpmask(struct proc *p, char *args)
|
||||
}
|
||||
|
||||
static int
|
||||
alpha_set_uac(struct proc *p, char *args)
|
||||
alpha_set_uac(struct thread *td, char *args)
|
||||
{
|
||||
int error;
|
||||
unsigned long uac;
|
||||
struct proc *p;
|
||||
|
||||
error = copyin(args, &uac, sizeof(uac));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
p = td->td_proc;
|
||||
PROC_LOCK(p);
|
||||
if (p->p_pptr) {
|
||||
PROC_LOCK(p->p_pptr);
|
||||
p->p_pptr->p_md.md_flags &= ~MDP_UAC_MASK;
|
||||
p->p_pptr->p_md.md_flags |= uac & MDP_UAC_MASK;
|
||||
/* XXXKSE which threads? */
|
||||
p->p_pptr->p_thread.td_md.md_flags &= ~MDP_UAC_MASK;
|
||||
p->p_pptr->p_thread.td_md.md_flags |= uac & MDP_UAC_MASK;
|
||||
PROC_UNLOCK(p->p_pptr);
|
||||
}
|
||||
PROC_UNLOCK(p);
|
||||
@ -185,16 +188,19 @@ alpha_set_uac(struct proc *p, char *args)
|
||||
}
|
||||
|
||||
static int
|
||||
alpha_get_uac(struct proc *p, char *args)
|
||||
alpha_get_uac(struct thread *td, char *args)
|
||||
{
|
||||
struct proc *p;
|
||||
int error;
|
||||
unsigned long uac;
|
||||
|
||||
p = td->td_proc;
|
||||
error = ESRCH;
|
||||
PROC_LOCK(p);
|
||||
if (p->p_pptr) {
|
||||
PROC_LOCK(p->p_pptr);
|
||||
uac = p->p_pptr->p_md.md_flags & MDP_UAC_MASK;
|
||||
/* XXXKSE which threads? */
|
||||
uac = p->p_pptr->p_thread.td_md.md_flags & MDP_UAC_MASK;
|
||||
PROC_UNLOCK(p->p_pptr);
|
||||
PROC_UNLOCK(p);
|
||||
error = copyout(&uac, args, sizeof(uac));
|
||||
|
@ -81,8 +81,8 @@ unsigned long Gfloat_reg_cvt __P((unsigned long));
|
||||
#endif
|
||||
|
||||
int unaligned_fixup __P((unsigned long, unsigned long,
|
||||
unsigned long, struct proc *));
|
||||
int handle_opdec(struct proc *p, u_int64_t *ucodep);
|
||||
unsigned long, struct thread *));
|
||||
int handle_opdec(struct thread *td, u_int64_t *ucodep);
|
||||
|
||||
static void printtrap __P((const unsigned long, const unsigned long,
|
||||
const unsigned long, const unsigned long, struct trapframe *, int, int));
|
||||
@ -256,6 +256,7 @@ trap(a0, a1, a2, entry, framep)
|
||||
const unsigned long a0, a1, a2, entry;
|
||||
struct trapframe *framep;
|
||||
{
|
||||
register struct thread *td;
|
||||
register struct proc *p;
|
||||
register int i;
|
||||
u_int64_t ucode;
|
||||
@ -272,11 +273,12 @@ trap(a0, a1, a2, entry, framep)
|
||||
s = critical_enter();
|
||||
#endif
|
||||
globalp = (struct globaldata *) alpha_pal_rdval();
|
||||
p = curproc;
|
||||
td = curthread;
|
||||
#ifdef SMP
|
||||
p->p_md.md_kernnest++;
|
||||
td->td_md.md_kernnest++;
|
||||
critical_exit(s);
|
||||
#endif
|
||||
p = td->td_proc;
|
||||
|
||||
/*
|
||||
GIANT_REQUIRED;
|
||||
@ -289,15 +291,15 @@ trap(a0, a1, a2, entry, framep)
|
||||
CTR5(KTR_TRAP, "%s trap: pid %d, (%lx, %lx, %lx)",
|
||||
user ? "user" : "kernel", p->p_pid, a0, a1, a2);
|
||||
if (user) {
|
||||
sticks = p->p_sticks;
|
||||
p->p_frame = framep;
|
||||
sticks = td->td_kse->ke_sticks;
|
||||
td->td_frame = framep;
|
||||
} else {
|
||||
sticks = 0; /* XXX bogus -Wuninitialized warning */
|
||||
}
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (user)
|
||||
alpha_fpstate_check(p);
|
||||
alpha_fpstate_check(td);
|
||||
#endif
|
||||
|
||||
switch (entry) {
|
||||
@ -309,7 +311,7 @@ trap(a0, a1, a2, entry, framep)
|
||||
*/
|
||||
if (user) {
|
||||
mtx_lock(&Giant);
|
||||
if ((i = unaligned_fixup(a0, a1, a2, p)) == 0) {
|
||||
if ((i = unaligned_fixup(a0, a1, a2, td)) == 0) {
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
@ -339,7 +341,7 @@ trap(a0, a1, a2, entry, framep)
|
||||
if (user) {
|
||||
mtx_lock(&Giant);
|
||||
if (a0 & EXCSUM_SWC)
|
||||
if (fp_software_completion(a1, p)) {
|
||||
if (fp_software_completion(a1, td)) {
|
||||
mtx_unlock(&Giant);
|
||||
goto out;
|
||||
}
|
||||
@ -391,10 +393,10 @@ trap(a0, a1, a2, entry, framep)
|
||||
/* FALLTHROUTH */
|
||||
case ALPHA_IF_CODE_BPT:
|
||||
case ALPHA_IF_CODE_BUGCHK:
|
||||
if (p->p_md.md_flags & (MDP_STEP1|MDP_STEP2)) {
|
||||
if (td->td_md.md_flags & (MDP_STEP1|MDP_STEP2)) {
|
||||
mtx_lock(&Giant);
|
||||
ptrace_clear_single_step(p);
|
||||
p->p_frame->tf_regs[FRAME_PC] -= 4;
|
||||
ptrace_clear_single_step(td);
|
||||
td->td_frame->tf_regs[FRAME_PC] -= 4;
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
ucode = a0; /* trap type */
|
||||
@ -402,23 +404,23 @@ trap(a0, a1, a2, entry, framep)
|
||||
break;
|
||||
|
||||
case ALPHA_IF_CODE_OPDEC:
|
||||
i = handle_opdec(p, &ucode);
|
||||
i = handle_opdec(td, &ucode);
|
||||
if (i == 0)
|
||||
goto out;
|
||||
break;
|
||||
|
||||
case ALPHA_IF_CODE_FEN:
|
||||
/*
|
||||
* on exit from the kernel, if proc == fpcurproc,
|
||||
* on exit from the kernel, if thread == fpcurthread,
|
||||
* FP is enabled.
|
||||
*/
|
||||
if (PCPU_GET(fpcurproc) == p) {
|
||||
printf("trap: fp disabled for fpcurproc == %p",
|
||||
p);
|
||||
if (PCPU_GET(fpcurthread) == td) {
|
||||
printf("trap: fp disabled for fpcurthread == %p",
|
||||
td);
|
||||
goto dopanic;
|
||||
}
|
||||
|
||||
alpha_fpstate_switch(p);
|
||||
alpha_fpstate_switch(td);
|
||||
goto out;
|
||||
|
||||
default:
|
||||
@ -432,7 +434,7 @@ trap(a0, a1, a2, entry, framep)
|
||||
case ALPHA_MMCSR_FOR:
|
||||
case ALPHA_MMCSR_FOE:
|
||||
case ALPHA_MMCSR_FOW:
|
||||
pmap_emulate_reference(p, a0, user,
|
||||
pmap_emulate_reference(p->p_vmspace, a0, user,
|
||||
a1 == ALPHA_MMCSR_FOW);
|
||||
goto out;
|
||||
|
||||
@ -453,13 +455,13 @@ trap(a0, a1, a2, entry, framep)
|
||||
* when they are running.
|
||||
*/
|
||||
if (!user &&
|
||||
p != NULL &&
|
||||
p->p_addr->u_pcb.pcb_onfault ==
|
||||
td != NULL &&
|
||||
td->td_pcb->pcb_onfault ==
|
||||
(unsigned long)fswintrberr &&
|
||||
p->p_addr->u_pcb.pcb_accessaddr == a0) {
|
||||
td->td_pcb->pcb_accessaddr == a0) {
|
||||
framep->tf_regs[FRAME_PC] =
|
||||
p->p_addr->u_pcb.pcb_onfault;
|
||||
p->p_addr->u_pcb.pcb_onfault = 0;
|
||||
td->td_pcb->pcb_onfault;
|
||||
td->td_pcb->pcb_onfault = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -479,8 +481,8 @@ trap(a0, a1, a2, entry, framep)
|
||||
*/
|
||||
if (!user
|
||||
&& ((a0 >= VM_MIN_KERNEL_ADDRESS)
|
||||
|| (p == NULL)
|
||||
|| (p->p_addr->u_pcb.pcb_onfault == 0))) {
|
||||
|| (td == NULL)
|
||||
|| (td->td_pcb->pcb_onfault == 0))) {
|
||||
if (a0 >= trunc_page(PS_STRINGS
|
||||
- szsigcode
|
||||
- SPARE_USRSPACE)
|
||||
@ -578,11 +580,11 @@ trap(a0, a1, a2, entry, framep)
|
||||
mtx_unlock(&Giant);
|
||||
if (!user) {
|
||||
/* Check for copyin/copyout fault */
|
||||
if (p != NULL &&
|
||||
p->p_addr->u_pcb.pcb_onfault != 0) {
|
||||
if (td != NULL &&
|
||||
td->td_pcb->pcb_onfault != 0) {
|
||||
framep->tf_regs[FRAME_PC] =
|
||||
p->p_addr->u_pcb.pcb_onfault;
|
||||
p->p_addr->u_pcb.pcb_onfault = 0;
|
||||
td->td_pcb->pcb_onfault;
|
||||
td->td_pcb->pcb_onfault = 0;
|
||||
goto out;
|
||||
}
|
||||
goto dopanic;
|
||||
@ -615,7 +617,7 @@ trap(a0, a1, a2, entry, framep)
|
||||
out:
|
||||
if (user) {
|
||||
framep->tf_regs[FRAME_SP] = alpha_pal_rdusp();
|
||||
userret(p, framep, sticks);
|
||||
userret(td, framep, sticks);
|
||||
if (mtx_owned(&Giant))
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
@ -649,6 +651,7 @@ syscall(code, framep)
|
||||
struct trapframe *framep;
|
||||
{
|
||||
struct sysent *callp;
|
||||
struct thread *td;
|
||||
struct proc *p;
|
||||
int error = 0;
|
||||
u_int64_t opc;
|
||||
@ -666,11 +669,12 @@ syscall(code, framep)
|
||||
s = critical_enter();
|
||||
#endif
|
||||
globalp = (struct globaldata *) alpha_pal_rdval();
|
||||
p = curproc;
|
||||
td = curthread;
|
||||
#ifdef SMP
|
||||
p->p_md.md_kernnest++;
|
||||
td->td_md.md_kernnest++;
|
||||
critical_exit(s);
|
||||
#endif
|
||||
p = td->td_proc;
|
||||
|
||||
framep->tf_regs[FRAME_TRAPARG_A0] = 0;
|
||||
framep->tf_regs[FRAME_TRAPARG_A1] = 0;
|
||||
@ -681,9 +685,9 @@ syscall(code, framep)
|
||||
#endif
|
||||
|
||||
cnt.v_syscall++;
|
||||
p->p_frame = framep;
|
||||
td->td_frame = framep;
|
||||
opc = framep->tf_regs[FRAME_PC] - 4;
|
||||
sticks = p->p_sticks;
|
||||
sticks = td->td_kse->ke_sticks;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
alpha_fpstate_check(p);
|
||||
@ -750,19 +754,19 @@ syscall(code, framep)
|
||||
}
|
||||
#endif
|
||||
if (error == 0) {
|
||||
p->p_retval[0] = 0;
|
||||
p->p_retval[1] = 0;
|
||||
td->td_retval[0] = 0;
|
||||
td->td_retval[1] = 0;
|
||||
|
||||
STOPEVENT(p, S_SCE, (callp->sy_narg & SYF_ARGMASK));
|
||||
|
||||
error = (*callp->sy_call)(p, args + hidden);
|
||||
error = (*callp->sy_call)(td, args + hidden);
|
||||
}
|
||||
|
||||
|
||||
switch (error) {
|
||||
case 0:
|
||||
framep->tf_regs[FRAME_V0] = p->p_retval[0];
|
||||
framep->tf_regs[FRAME_A4] = p->p_retval[1];
|
||||
framep->tf_regs[FRAME_V0] = td->td_retval[0];
|
||||
framep->tf_regs[FRAME_A4] = td->td_retval[1];
|
||||
framep->tf_regs[FRAME_A3] = 0;
|
||||
break;
|
||||
case ERESTART:
|
||||
@ -782,10 +786,10 @@ syscall(code, framep)
|
||||
break;
|
||||
}
|
||||
|
||||
userret(p, framep, sticks);
|
||||
userret(td, framep, sticks);
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSRET)) {
|
||||
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
|
||||
ktrsysret(p->p_tracep, code, error, td->td_retval[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -805,7 +809,7 @@ syscall(code, framep)
|
||||
STOPEVENT(p, S_SCX, code);
|
||||
|
||||
#ifdef WITNESS
|
||||
if (witness_list(p)) {
|
||||
if (witness_list(td)) {
|
||||
panic("system call %s returning with mutex(s) held\n",
|
||||
syscallnames[code]);
|
||||
}
|
||||
@ -829,23 +833,23 @@ const static int reg_to_framereg[32] = {
|
||||
FRAME_AT, FRAME_GP, FRAME_SP, -1,
|
||||
};
|
||||
|
||||
#define irp(p, reg) \
|
||||
#define irp(td, reg) \
|
||||
((reg_to_framereg[(reg)] == -1) ? NULL : \
|
||||
&(p)->p_frame->tf_regs[reg_to_framereg[(reg)]])
|
||||
&(td)->td_frame->tf_regs[reg_to_framereg[(reg)]])
|
||||
|
||||
#define frp(p, reg) \
|
||||
(&(p)->p_addr->u_pcb.pcb_fp.fpr_regs[(reg)])
|
||||
#define frp(td, reg) \
|
||||
(&(td)->td_pcb->pcb_fp.fpr_regs[(reg)])
|
||||
|
||||
#define unaligned_load(storage, ptrf, mod) \
|
||||
if (copyin((caddr_t)va, &(storage), sizeof (storage)) == 0 && \
|
||||
(regptr = ptrf(p, reg)) != NULL) \
|
||||
(regptr = ptrf(td, reg)) != NULL) \
|
||||
signal = 0; \
|
||||
else \
|
||||
break; \
|
||||
*regptr = mod (storage);
|
||||
|
||||
#define unaligned_store(storage, ptrf, mod) \
|
||||
if ((regptr = ptrf(p, reg)) == NULL) \
|
||||
if ((regptr = ptrf(td, reg)) == NULL) \
|
||||
(storage) = 0; \
|
||||
else \
|
||||
(storage) = mod (*regptr); \
|
||||
@ -861,11 +865,11 @@ const static int reg_to_framereg[32] = {
|
||||
unaligned_store(storage, irp, )
|
||||
|
||||
#define unaligned_load_floating(storage, mod) \
|
||||
alpha_fpstate_save(p, 1); \
|
||||
alpha_fpstate_save(td, 1); \
|
||||
unaligned_load(storage, frp, mod)
|
||||
|
||||
#define unaligned_store_floating(storage, mod) \
|
||||
alpha_fpstate_save(p, 0); \
|
||||
alpha_fpstate_save(td, 0); \
|
||||
unaligned_store(storage, frp, mod)
|
||||
|
||||
unsigned long
|
||||
@ -988,13 +992,14 @@ extern int alpha_unaligned_print, alpha_unaligned_fix;
|
||||
extern int alpha_unaligned_sigbus;
|
||||
|
||||
int
|
||||
unaligned_fixup(va, opcode, reg, p)
|
||||
unaligned_fixup(va, opcode, reg, td)
|
||||
unsigned long va, opcode, reg;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
int doprint, dofix, dosigbus;
|
||||
int signal, size;
|
||||
const char *type;
|
||||
struct proc *p;
|
||||
unsigned long *regptr, longdata, uac;
|
||||
int intdata; /* signed to get extension when storing */
|
||||
struct {
|
||||
@ -1024,10 +1029,13 @@ unaligned_fixup(va, opcode, reg, p)
|
||||
*
|
||||
*/
|
||||
|
||||
if (p)
|
||||
uac = p->p_md.md_flags & MDP_UAC_MASK;
|
||||
else
|
||||
if (td) {
|
||||
uac = td->td_md.md_flags & MDP_UAC_MASK;
|
||||
p = td->td_proc;
|
||||
} else {
|
||||
uac = 0;
|
||||
p = NULL;
|
||||
}
|
||||
|
||||
doprint = alpha_unaligned_print && !(uac & MDP_UAC_NOPRINT);
|
||||
dofix = alpha_unaligned_fix && !(uac & MDP_UAC_NOFIX);
|
||||
@ -1061,8 +1069,8 @@ unaligned_fixup(va, opcode, reg, p)
|
||||
if (doprint) {
|
||||
uprintf(
|
||||
"pid %d (%s): unaligned access: va=0x%lx pc=0x%lx ra=0x%lx op=",
|
||||
p->p_pid, p->p_comm, va, p->p_frame->tf_regs[FRAME_PC],
|
||||
p->p_frame->tf_regs[FRAME_RA]);
|
||||
p->p_pid, p->p_comm, va, td->td_frame->tf_regs[FRAME_PC],
|
||||
td->td_frame->tf_regs[FRAME_RA]);
|
||||
uprintf(type,opcode);
|
||||
uprintf("\n");
|
||||
}
|
||||
@ -1165,8 +1173,8 @@ unaligned_fixup(va, opcode, reg, p)
|
||||
* and fills in *ucodep with the code to be delivered.
|
||||
*/
|
||||
int
|
||||
handle_opdec(p, ucodep)
|
||||
struct proc *p;
|
||||
handle_opdec(td, ucodep)
|
||||
struct thread *td;
|
||||
u_int64_t *ucodep;
|
||||
{
|
||||
alpha_instruction inst;
|
||||
@ -1179,9 +1187,9 @@ handle_opdec(p, ucodep)
|
||||
* This keeps us from having to check for it in lots of places
|
||||
* later.
|
||||
*/
|
||||
p->p_frame->tf_regs[FRAME_SP] = alpha_pal_rdusp();
|
||||
td->td_frame->tf_regs[FRAME_SP] = alpha_pal_rdusp();
|
||||
|
||||
inst_pc = memaddr = p->p_frame->tf_regs[FRAME_PC] - 4;
|
||||
inst_pc = memaddr = td->td_frame->tf_regs[FRAME_PC] - 4;
|
||||
if (copyin((caddr_t)inst_pc, &inst, sizeof (inst)) != 0) {
|
||||
/*
|
||||
* really, this should never happen, but in case it
|
||||
@ -1196,21 +1204,21 @@ handle_opdec(p, ucodep)
|
||||
case op_ldwu:
|
||||
case op_stw:
|
||||
case op_stb:
|
||||
regptr = irp(p, inst.mem_format.rs);
|
||||
regptr = irp(td, inst.mem_format.rs);
|
||||
if (regptr != NULL)
|
||||
memaddr = *regptr;
|
||||
else
|
||||
memaddr = 0;
|
||||
memaddr += inst.mem_format.displacement;
|
||||
|
||||
regptr = irp(p, inst.mem_format.rd);
|
||||
regptr = irp(td, inst.mem_format.rd);
|
||||
|
||||
if (inst.mem_format.opcode == op_ldwu ||
|
||||
inst.mem_format.opcode == op_stw) {
|
||||
if (memaddr & 0x01) {
|
||||
sig = unaligned_fixup(memaddr,
|
||||
inst.mem_format.opcode,
|
||||
inst.mem_format.rd, p);
|
||||
inst.mem_format.rd, td);
|
||||
if (sig)
|
||||
goto unaligned_fixup_sig;
|
||||
break;
|
||||
@ -1260,11 +1268,11 @@ handle_opdec(p, ucodep)
|
||||
} else {
|
||||
if (inst.operate_reg_format.sbz != 0)
|
||||
goto sigill;
|
||||
regptr = irp(p, inst.operate_reg_format.rt);
|
||||
regptr = irp(td, inst.operate_reg_format.rt);
|
||||
b = (regptr != NULL) ? *regptr : 0;
|
||||
}
|
||||
|
||||
regptr = irp(p, inst.operate_generic_format.rc);
|
||||
regptr = irp(td, inst.operate_generic_format.rc);
|
||||
if (regptr != NULL)
|
||||
*regptr = b;
|
||||
break;
|
||||
@ -1278,11 +1286,11 @@ handle_opdec(p, ucodep)
|
||||
} else {
|
||||
if (inst.operate_reg_format.sbz != 0)
|
||||
goto sigill;
|
||||
regptr = irp(p, inst.operate_reg_format.rt);
|
||||
regptr = irp(td, inst.operate_reg_format.rt);
|
||||
w = (regptr != NULL) ? *regptr : 0;
|
||||
}
|
||||
|
||||
regptr = irp(p, inst.operate_generic_format.rc);
|
||||
regptr = irp(td, inst.operate_generic_format.rc);
|
||||
if (regptr != NULL)
|
||||
*regptr = w;
|
||||
break;
|
||||
@ -1298,7 +1306,7 @@ handle_opdec(p, ucodep)
|
||||
* nothing will have been successfully modified so we don't
|
||||
* have to write it out.
|
||||
*/
|
||||
alpha_pal_wrusp(p->p_frame->tf_regs[FRAME_SP]);
|
||||
alpha_pal_wrusp(td->td_frame->tf_regs[FRAME_SP]);
|
||||
|
||||
return (0);
|
||||
|
||||
@ -1308,7 +1316,7 @@ handle_opdec(p, ucodep)
|
||||
|
||||
sigsegv:
|
||||
sig = SIGSEGV;
|
||||
p->p_frame->tf_regs[FRAME_PC] = inst_pc; /* re-run instr. */
|
||||
td->td_frame->tf_regs[FRAME_PC] = inst_pc; /* re-run instr. */
|
||||
unaligned_fixup_sig:
|
||||
*ucodep = memaddr; /* faulting address */
|
||||
return (sig);
|
||||
|
@ -118,30 +118,35 @@ vm_fault_quick(v, prot)
|
||||
* ready to run and return to user mode.
|
||||
*/
|
||||
void
|
||||
cpu_fork(p1, p2, flags)
|
||||
register struct proc *p1, *p2;
|
||||
cpu_fork(td1, p2, flags)
|
||||
register struct thread *td1;
|
||||
register struct proc *p2;
|
||||
int flags;
|
||||
{
|
||||
struct user *up;
|
||||
struct proc *p1;
|
||||
struct thread *td2;
|
||||
struct trapframe *p2tf;
|
||||
|
||||
if ((flags & RFPROC) == 0)
|
||||
return;
|
||||
|
||||
p2->p_frame = p1->p_frame;
|
||||
p2->p_md.md_flags = p1->p_md.md_flags & (MDP_FPUSED | MDP_UAC_MASK);
|
||||
p1 = td1->td_proc;
|
||||
td2 = &p2->p_thread;
|
||||
td2->td_pcb = (struct pcb *)
|
||||
(td2->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
|
||||
td2->td_md.md_flags = td1->td_md.md_flags & (MDP_FPUSED | MDP_UAC_MASK);
|
||||
|
||||
/*
|
||||
* Cache the physical address of the pcb, so we can
|
||||
* swap to it easily.
|
||||
*/
|
||||
p2->p_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)&p2->p_addr->u_pcb);
|
||||
td2->td_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)td2->td_pcb);
|
||||
|
||||
/*
|
||||
* Copy floating point state from the FP chip to the PCB
|
||||
* if this process has state stored there.
|
||||
*/
|
||||
alpha_fpstate_save(p1, 0);
|
||||
alpha_fpstate_save(td1, 0);
|
||||
|
||||
/*
|
||||
* Copy pcb and stack from proc p1 to p2. We do this as
|
||||
@ -149,16 +154,16 @@ cpu_fork(p1, p2, flags)
|
||||
* stack. The stack and pcb need to agree. Make sure that the
|
||||
* new process has FEN disabled.
|
||||
*/
|
||||
p2->p_addr->u_pcb = p1->p_addr->u_pcb;
|
||||
p2->p_addr->u_pcb.pcb_hw.apcb_usp = alpha_pal_rdusp();
|
||||
p2->p_addr->u_pcb.pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN;
|
||||
bcopy(td1->td_pcb, td2->td_pcb, sizeof(struct pcb));
|
||||
td2->td_pcb->pcb_hw.apcb_usp = alpha_pal_rdusp();
|
||||
td2->td_pcb->pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN;
|
||||
|
||||
/*
|
||||
* Set the floating point state.
|
||||
*/
|
||||
if ((p2->p_addr->u_pcb.pcb_fp_control & IEEE_INHERIT) == 0) {
|
||||
p2->p_addr->u_pcb.pcb_fp_control = 0;
|
||||
p2->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL
|
||||
if ((td2->td_pcb->pcb_fp_control & IEEE_INHERIT) == 0) {
|
||||
td2->td_pcb->pcb_fp_control = 0;
|
||||
td2->td_pcb->pcb_fp.fpr_cr = (FPCR_DYN_NORMAL
|
||||
| FPCR_INVD | FPCR_DZED
|
||||
| FPCR_OVFD | FPCR_INED
|
||||
| FPCR_UNFD);
|
||||
@ -169,7 +174,7 @@ cpu_fork(p1, p2, flags)
|
||||
* is started, to resume here, returning nonzero from setjmp.
|
||||
*/
|
||||
#ifdef DIAGNOSTIC
|
||||
alpha_fpstate_check(p1);
|
||||
alpha_fpstate_check(td1);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -179,34 +184,32 @@ cpu_fork(p1, p2, flags)
|
||||
* copy trapframe from parent so return to user mode
|
||||
* will be to right address, with correct registers.
|
||||
*/
|
||||
p2->p_frame = (struct trapframe *)
|
||||
((char *)p2->p_addr + USPACE - sizeof(struct trapframe));
|
||||
bcopy(p1->p_frame, p2->p_frame, sizeof(struct trapframe));
|
||||
td2->td_frame = (struct trapframe *)td2->td_pcb - 1;
|
||||
bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe));
|
||||
|
||||
/*
|
||||
* Set up return-value registers as fork() libc stub expects.
|
||||
*/
|
||||
p2tf = p2->p_frame;
|
||||
p2tf->tf_regs[FRAME_V0] = 0; /* child's pid (linux) */
|
||||
p2tf->tf_regs[FRAME_A3] = 0; /* no error */
|
||||
p2tf->tf_regs[FRAME_A4] = 1; /* is child (FreeBSD) */
|
||||
p2tf = td2->td_frame;
|
||||
p2tf->tf_regs[FRAME_V0] = 0; /* child's pid (linux) */
|
||||
p2tf->tf_regs[FRAME_A3] = 0; /* no error */
|
||||
p2tf->tf_regs[FRAME_A4] = 1; /* is child (FreeBSD) */
|
||||
|
||||
/*
|
||||
* Arrange for continuation at fork_return(), which
|
||||
* will return to exception_return(). Note that the child
|
||||
* process doesn't stay in the kernel for long!
|
||||
*/
|
||||
up = p2->p_addr;
|
||||
up->u_pcb.pcb_hw.apcb_ksp = (u_int64_t)p2tf;
|
||||
up->u_pcb.pcb_context[0] = (u_int64_t)fork_return; /* s0: a0 */
|
||||
up->u_pcb.pcb_context[1] = (u_int64_t)exception_return; /* s1: ra */
|
||||
up->u_pcb.pcb_context[2] = (u_long) p2; /* s2: a1 */
|
||||
up->u_pcb.pcb_context[7] = (u_int64_t)fork_trampoline; /* ra: magic */
|
||||
td2->td_pcb->pcb_hw.apcb_ksp = (u_int64_t)p2tf;
|
||||
td2->td_pcb->pcb_context[0] = (u_int64_t)fork_return; /* s0: a0 */
|
||||
td2->td_pcb->pcb_context[1] = (u_int64_t)exception_return;/* s1: ra */
|
||||
td2->td_pcb->pcb_context[2] = (u_long)td2; /* s2: a1 */
|
||||
td2->td_pcb->pcb_context[7] = (u_int64_t)fork_trampoline; /* ra: magic*/
|
||||
#ifdef SMP
|
||||
/*
|
||||
* We start off at a nesting level of 1 within the kernel.
|
||||
*/
|
||||
p2->p_md.md_kernnest = 1;
|
||||
td2->td_md.md_kernnest = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -217,8 +220,8 @@ cpu_fork(p1, p2, flags)
|
||||
* This is needed to make kernel threads stay in kernel mode.
|
||||
*/
|
||||
void
|
||||
cpu_set_fork_handler(p, func, arg)
|
||||
struct proc *p;
|
||||
cpu_set_fork_handler(td, func, arg)
|
||||
struct thread *td;
|
||||
void (*func) __P((void *));
|
||||
void *arg;
|
||||
{
|
||||
@ -226,8 +229,8 @@ cpu_set_fork_handler(p, func, arg)
|
||||
* Note that the trap frame follows the args, so the function
|
||||
* is really called like this: func(arg, frame);
|
||||
*/
|
||||
p->p_addr->u_pcb.pcb_context[0] = (u_long) func;
|
||||
p->p_addr->u_pcb.pcb_context[2] = (u_long) arg;
|
||||
td->td_pcb->pcb_context[0] = (u_long) func;
|
||||
td->td_pcb->pcb_context[2] = (u_long) arg;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -238,11 +241,11 @@ cpu_set_fork_handler(p, func, arg)
|
||||
* from proc0.
|
||||
*/
|
||||
void
|
||||
cpu_exit(p)
|
||||
register struct proc *p;
|
||||
cpu_exit(td)
|
||||
register struct thread *td;
|
||||
{
|
||||
|
||||
alpha_fpstate_drop(p);
|
||||
alpha_fpstate_drop(td);
|
||||
}
|
||||
|
||||
void
|
||||
@ -255,14 +258,23 @@ cpu_wait(p)
|
||||
* Dump the machine specific header information at the start of a core dump.
|
||||
*/
|
||||
int
|
||||
cpu_coredump(p, vp, cred)
|
||||
struct proc *p;
|
||||
cpu_coredump(td, vp, cred)
|
||||
struct thread *td;
|
||||
struct vnode *vp;
|
||||
struct ucred *cred;
|
||||
{
|
||||
int error;
|
||||
|
||||
return (vn_rdwr(UIO_WRITE, vp, (caddr_t) p->p_addr, ctob(UPAGES),
|
||||
(off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p));
|
||||
/* XXXKSE this is totally bogus! (and insecure) */
|
||||
error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_proc->p_uarea,
|
||||
ctob(UAREA_PAGES), (off_t)0,
|
||||
UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td);
|
||||
if (error)
|
||||
return error;
|
||||
error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_kstack,
|
||||
ctob(KSTACK_PAGES), (off_t)ctob(UAREA_PAGES),
|
||||
UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
#include <machine/frame.h>
|
||||
|
||||
#define cpu_getstack(p) (alpha_pal_rdusp())
|
||||
#define cpu_getstack(td) (alpha_pal_rdusp())
|
||||
|
||||
/*
|
||||
* Arguments to hardclock and gatherstats encapsulate the previous
|
||||
@ -99,7 +99,7 @@ struct clockframe {
|
||||
#ifdef _KERNEL
|
||||
|
||||
struct pcb;
|
||||
struct proc;
|
||||
struct thread;
|
||||
struct reg;
|
||||
struct rpb;
|
||||
struct trapframe;
|
||||
@ -116,10 +116,10 @@ void XentSys __P((u_int64_t, u_int64_t, u_int64_t)); /* MAGIC */
|
||||
void XentUna __P((u_int64_t, u_int64_t, u_int64_t)); /* MAGIC */
|
||||
void alpha_init __P((u_long, u_long, u_long, u_long, u_long));
|
||||
int alpha_pa_access __P((u_long));
|
||||
void alpha_fpstate_check __P((struct proc *p));
|
||||
void alpha_fpstate_save __P((struct proc *p, int write));
|
||||
void alpha_fpstate_drop __P((struct proc *p));
|
||||
void alpha_fpstate_switch __P((struct proc *p));
|
||||
void alpha_fpstate_check __P((struct thread *p));
|
||||
void alpha_fpstate_save __P((struct thread *p, int write));
|
||||
void alpha_fpstate_drop __P((struct thread *p));
|
||||
void alpha_fpstate_switch __P((struct thread *p));
|
||||
int badaddr __P((void *, size_t));
|
||||
int badaddr_read __P((void *, size_t, void *));
|
||||
u_int64_t console_restart __P((u_int64_t, u_int64_t, u_int64_t));
|
||||
@ -138,7 +138,7 @@ void regdump __P((struct trapframe *));
|
||||
void regtoframe __P((struct reg *, struct trapframe *));
|
||||
void savectx __P((struct pcb *));
|
||||
void set_iointr __P((void (*)(void *, unsigned long)));
|
||||
void switch_exit __P((struct proc *)); /* MAGIC */
|
||||
void switch_exit __P((struct thread *)); /* MAGIC */
|
||||
void fork_trampoline __P((void)); /* MAGIC */
|
||||
void syscall __P((u_int64_t, struct trapframe *));
|
||||
void trap __P((unsigned long, unsigned long, unsigned long, unsigned long,
|
||||
|
@ -117,7 +117,7 @@
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
extern int fp_software_completion(u_int64_t regmask, struct proc *p);
|
||||
extern int fp_software_completion(u_int64_t regmask, struct thread *p);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -44,15 +44,15 @@
|
||||
* point at the globaldata structure.
|
||||
*/
|
||||
struct globaldata {
|
||||
struct alpha_pcb gd_idlepcb; /* pcb for idling */
|
||||
struct proc *gd_curproc; /* current process */
|
||||
struct proc *gd_idleproc; /* idle process */
|
||||
struct proc *gd_fpcurproc; /* fp state owner */
|
||||
struct pcb *gd_curpcb; /* current pcb */
|
||||
struct timeval gd_switchtime;
|
||||
int gd_switchticks;
|
||||
u_int gd_cpuid; /* this cpu number */
|
||||
u_int gd_other_cpus; /* all other cpus */
|
||||
struct alpha_pcb gd_idlepcb; /* pcb for idling */
|
||||
struct thread *gd_curthread; /* current thread */
|
||||
struct thread *gd_idlethread; /* idle thread */
|
||||
struct thread *gd_fpcurthread; /* fp state owner */
|
||||
struct pcb *gd_curpcb; /* current pcb */
|
||||
struct timeval gd_switchtime;
|
||||
int gd_switchticks;
|
||||
u_int gd_cpuid; /* this cpu number */
|
||||
u_int gd_other_cpus; /* all other cpus */
|
||||
u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */
|
||||
u_int64_t gd_pending_ipis; /* pending IPI events */
|
||||
u_int32_t gd_next_asn; /* next ASN to allocate */
|
||||
|
@ -40,9 +40,11 @@ register struct globaldata *globalp __asm__("$8");
|
||||
#define PCPU_PTR(member) (&GLOBALP->gd_ ## member)
|
||||
#define PCPU_SET(member,value) (GLOBALP->gd_ ## member = (value))
|
||||
|
||||
#define CURPROC PCPU_GET(curproc)
|
||||
#define CURTHD PCPU_GET(curproc) /* temporary */
|
||||
#define curproc PCPU_GET(curproc)
|
||||
#define curthread PCPU_GET(curthread)
|
||||
#define CURPROC (curthread->td_proc)
|
||||
#define curproc (curthread->td_proc)
|
||||
#define curksegrp (curthread->td_ksegrp)
|
||||
#define curkse (curthread->td_kse)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
@ -40,7 +40,7 @@ extern int Maxmem;
|
||||
extern int busdma_swi_pending;
|
||||
|
||||
struct fpreg;
|
||||
struct proc;
|
||||
struct thread;
|
||||
struct reg;
|
||||
struct cam_sim;
|
||||
struct pcicfg;
|
||||
@ -50,10 +50,10 @@ void cpu_halt __P((void));
|
||||
void cpu_reset __P((void));
|
||||
int is_physical_memory __P((vm_offset_t addr));
|
||||
void swi_vm __P((void *));
|
||||
int fill_regs __P((struct proc *, struct reg *));
|
||||
int set_regs __P((struct proc *, struct reg *));
|
||||
int fill_fpregs __P((struct proc *, struct fpreg *));
|
||||
int set_fpregs __P((struct proc *, struct fpreg *));
|
||||
int fill_regs __P((struct thread *, struct reg *));
|
||||
int set_regs __P((struct thread *, struct reg *));
|
||||
int fill_fpregs __P((struct thread *, struct fpreg *));
|
||||
int set_fpregs __P((struct thread *, struct fpreg *));
|
||||
void alpha_register_pci_scsi __P((int bus, int slot, struct cam_sim *sim));
|
||||
#ifdef _SYS_BUS_H_
|
||||
struct resource *alpha_platform_alloc_ide_intr(int chan);
|
||||
|
@ -58,7 +58,7 @@ extern struct mtx clock_lock;
|
||||
1: ldq_l a0, lck+MTX_LOCK; \
|
||||
cmpeq a0, MTX_UNOWNED, a1; \
|
||||
beq a1, 1b; \
|
||||
ldq a0, PC_CURPROC(globalp); \
|
||||
ldq a0, PC_CURTHREAD(globalp); \
|
||||
stq_c a0, lck+MTX_LOCK; \
|
||||
beq a0, 1b; \
|
||||
mb; \
|
||||
|
@ -133,8 +133,10 @@
|
||||
#define SSIZE 1 /* initial stack size/NBPG */
|
||||
#define SINCR 1 /* increment of stack/NBPG */
|
||||
|
||||
#define UPAGES 2 /* pages of u-area */
|
||||
#define USPACE (UPAGES * PAGE_SIZE) /* total size of u-area */
|
||||
#define KSTACK_PAGES 2 /* pages of kstack (with pcb) */
|
||||
#define UAREA_PAGES 1 /* pages of u-area */
|
||||
|
||||
#define KSTACK_GUARD /* compile in kstack guard page */
|
||||
|
||||
/*
|
||||
* Constants related to network buffer management.
|
||||
|
@ -44,15 +44,15 @@
|
||||
* point at the globaldata structure.
|
||||
*/
|
||||
struct globaldata {
|
||||
struct alpha_pcb gd_idlepcb; /* pcb for idling */
|
||||
struct proc *gd_curproc; /* current process */
|
||||
struct proc *gd_idleproc; /* idle process */
|
||||
struct proc *gd_fpcurproc; /* fp state owner */
|
||||
struct pcb *gd_curpcb; /* current pcb */
|
||||
struct timeval gd_switchtime;
|
||||
int gd_switchticks;
|
||||
u_int gd_cpuid; /* this cpu number */
|
||||
u_int gd_other_cpus; /* all other cpus */
|
||||
struct alpha_pcb gd_idlepcb; /* pcb for idling */
|
||||
struct thread *gd_curthread; /* current thread */
|
||||
struct thread *gd_idlethread; /* idle thread */
|
||||
struct thread *gd_fpcurthread; /* fp state owner */
|
||||
struct pcb *gd_curpcb; /* current pcb */
|
||||
struct timeval gd_switchtime;
|
||||
int gd_switchticks;
|
||||
u_int gd_cpuid; /* this cpu number */
|
||||
u_int gd_other_cpus; /* all other cpus */
|
||||
u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */
|
||||
u_int64_t gd_pending_ipis; /* pending IPI events */
|
||||
u_int32_t gd_next_asn; /* next ASN to allocate */
|
||||
|
@ -220,6 +220,8 @@ extern char *ptvmmap; /* poor name! */
|
||||
extern vm_offset_t virtual_avail;
|
||||
extern vm_offset_t virtual_end;
|
||||
|
||||
struct vmspace;
|
||||
|
||||
vm_offset_t pmap_steal_memory __P((vm_size_t));
|
||||
void pmap_bootstrap __P((vm_offset_t, u_int));
|
||||
void pmap_setdevram __P((unsigned long long basea, vm_offset_t sizea));
|
||||
@ -230,8 +232,8 @@ unsigned *pmap_pte __P((pmap_t, vm_offset_t)) __pure2;
|
||||
vm_page_t pmap_use_pt __P((pmap_t, vm_offset_t));
|
||||
void pmap_set_opt __P((unsigned *));
|
||||
void pmap_set_opt_bsp __P((void));
|
||||
void pmap_deactivate __P((struct proc *p));
|
||||
void pmap_emulate_reference __P((struct proc *p, vm_offset_t v, int user, int write));
|
||||
void pmap_deactivate __P((struct thread *td));
|
||||
void pmap_emulate_reference __P((struct vmspace *vm, vm_offset_t v, int user, int write));
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
@ -43,7 +43,7 @@ struct mdbpt {
|
||||
u_int32_t contents;
|
||||
};
|
||||
|
||||
struct mdproc {
|
||||
struct mdthread {
|
||||
u_long md_flags;
|
||||
struct pcb *md_pcbpaddr; /* phys addr of the pcb */
|
||||
struct mdbpt md_sstep[2]; /* two single step breakpoints */
|
||||
@ -62,4 +62,7 @@ struct mdproc {
|
||||
unaligned access */
|
||||
#define MDP_UAC_MASK (MDP_UAC_NOPRINT | MDP_UAC_NOFIX | MDP_UAC_SIGBUS)
|
||||
|
||||
struct mdproc {
|
||||
};
|
||||
|
||||
#endif /* !_MACHINE_PROC_H_ */
|
||||
|
@ -48,7 +48,7 @@
|
||||
#define FIX_SSTEP(p) ptrace_clear_single_step(p)
|
||||
|
||||
#ifdef _KERNEL
|
||||
int ptrace_clear_single_step(struct proc *_p);
|
||||
int ptrace_clear_single_step(struct thread *_p);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -110,7 +110,7 @@ struct dbreg {
|
||||
#ifdef _KERNEL
|
||||
void restorefpstate __P((struct fpreg *));
|
||||
void savefpstate __P((struct fpreg *));
|
||||
void setregs __P((struct proc *, u_long, u_long, u_long));
|
||||
void setregs __P((struct thread *, u_long, u_long, u_long));
|
||||
#endif
|
||||
|
||||
#endif /* _ALPHA_REG_H_ */
|
||||
|
@ -62,7 +62,7 @@
|
||||
* with a 32bit value. OSF1 manages to have a variable location for
|
||||
* the user stack which we should probably also support.
|
||||
*/
|
||||
#define USRSTACK (0x12000000LL - (UPAGES*PAGE_SIZE))
|
||||
#define USRSTACK (0x12000000LL)
|
||||
|
||||
/*
|
||||
* Virtual memory related constants, all in bytes
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
struct proc;
|
||||
|
||||
struct thread;
|
||||
|
||||
#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \
|
||||
0 : sizeof(register_t) - sizeof(t))
|
||||
|
||||
@ -594,144 +596,144 @@ struct linux_getdents64_args {
|
||||
char dirent_l_[PADL_(void *)]; void * dirent; char dirent_r_[PADR_(void *)];
|
||||
char count_l_[PADL_(l_uint)]; l_uint count; char count_r_[PADR_(l_uint)];
|
||||
};
|
||||
int linux_fork __P((struct proc *, struct linux_fork_args *));
|
||||
int osf1_wait4 __P((struct proc *, struct osf1_wait4_args *));
|
||||
int linux_link __P((struct proc *, struct linux_link_args *));
|
||||
int linux_unlink __P((struct proc *, struct linux_unlink_args *));
|
||||
int linux_chdir __P((struct proc *, struct linux_chdir_args *));
|
||||
int linux_mknod __P((struct proc *, struct linux_mknod_args *));
|
||||
int linux_chmod __P((struct proc *, struct linux_chmod_args *));
|
||||
int linux_chown __P((struct proc *, struct linux_chown_args *));
|
||||
int linux_brk __P((struct proc *, struct linux_brk_args *));
|
||||
int linux_lseek __P((struct proc *, struct linux_lseek_args *));
|
||||
int linux_getpid __P((struct proc *, struct linux_getpid_args *));
|
||||
int linux_umount __P((struct proc *, struct linux_umount_args *));
|
||||
int linux_getuid __P((struct proc *, struct linux_getuid_args *));
|
||||
int linux_ptrace __P((struct proc *, struct linux_ptrace_args *));
|
||||
int linux_access __P((struct proc *, struct linux_access_args *));
|
||||
int linux_kill __P((struct proc *, struct linux_kill_args *));
|
||||
int linux_open __P((struct proc *, struct linux_open_args *));
|
||||
int linux_getgid __P((struct proc *, struct linux_getgid_args *));
|
||||
int osf1_sigprocmask __P((struct proc *, struct osf1_sigprocmask_args *));
|
||||
int linux_sigpending __P((struct proc *, struct linux_sigpending_args *));
|
||||
int linux_ioctl __P((struct proc *, struct linux_ioctl_args *));
|
||||
int linux_symlink __P((struct proc *, struct linux_symlink_args *));
|
||||
int linux_readlink __P((struct proc *, struct linux_readlink_args *));
|
||||
int linux_execve __P((struct proc *, struct linux_execve_args *));
|
||||
int linux_getpagesize __P((struct proc *, struct linux_getpagesize_args *));
|
||||
int linux_vfork __P((struct proc *, struct linux_vfork_args *));
|
||||
int linux_newstat __P((struct proc *, struct linux_newstat_args *));
|
||||
int linux_newlstat __P((struct proc *, struct linux_newlstat_args *));
|
||||
int linux_mmap __P((struct proc *, struct linux_mmap_args *));
|
||||
int linux_munmap __P((struct proc *, struct linux_munmap_args *));
|
||||
int linux_mprotect __P((struct proc *, struct linux_mprotect_args *));
|
||||
int linux_madvise __P((struct proc *, struct linux_madvise_args *));
|
||||
int linux_vhangup __P((struct proc *, struct linux_vhangup_args *));
|
||||
int linux_setgroups __P((struct proc *, struct linux_setgroups_args *));
|
||||
int linux_getgroups __P((struct proc *, struct linux_getgroups_args *));
|
||||
int linux_setpgid __P((struct proc *, struct linux_setpgid_args *));
|
||||
int osf1_setitimer __P((struct proc *, struct osf1_setitimer_args *));
|
||||
int linux_gethostname __P((struct proc *, struct linux_gethostname_args *));
|
||||
int linux_getdtablesize __P((struct proc *, struct linux_getdtablesize_args *));
|
||||
int linux_newfstat __P((struct proc *, struct linux_newfstat_args *));
|
||||
int linux_fcntl __P((struct proc *, struct linux_fcntl_args *));
|
||||
int osf1_select __P((struct proc *, struct osf1_select_args *));
|
||||
int osf1_socket __P((struct proc *, struct osf1_socket_args *));
|
||||
int linux_connect __P((struct proc *, struct linux_connect_args *));
|
||||
int osf1_sigreturn __P((struct proc *, struct osf1_sigreturn_args *));
|
||||
int osf1_sigsuspend __P((struct proc *, struct osf1_sigsuspend_args *));
|
||||
int linux_recvmsg __P((struct proc *, struct linux_recvmsg_args *));
|
||||
int linux_sendmsg __P((struct proc *, struct linux_sendmsg_args *));
|
||||
int osf1_gettimeofday __P((struct proc *, struct osf1_gettimeofday_args *));
|
||||
int osf1_getrusage __P((struct proc *, struct osf1_getrusage_args *));
|
||||
int linux_rename __P((struct proc *, struct linux_rename_args *));
|
||||
int linux_truncate __P((struct proc *, struct linux_truncate_args *));
|
||||
int osf1_sendto __P((struct proc *, struct osf1_sendto_args *));
|
||||
int linux_socketpair __P((struct proc *, struct linux_socketpair_args *));
|
||||
int linux_mkdir __P((struct proc *, struct linux_mkdir_args *));
|
||||
int linux_rmdir __P((struct proc *, struct linux_rmdir_args *));
|
||||
int linux_getrlimit __P((struct proc *, struct linux_getrlimit_args *));
|
||||
int linux_setrlimit __P((struct proc *, struct linux_setrlimit_args *));
|
||||
int linux_quotactl __P((struct proc *, struct linux_quotactl_args *));
|
||||
int osf1_sigaction __P((struct proc *, struct osf1_sigaction_args *));
|
||||
int linux_msgctl __P((struct proc *, struct linux_msgctl_args *));
|
||||
int linux_msgget __P((struct proc *, struct linux_msgget_args *));
|
||||
int linux_msgrcv __P((struct proc *, struct linux_msgrcv_args *));
|
||||
int linux_msgsnd __P((struct proc *, struct linux_msgsnd_args *));
|
||||
int linux_semctl __P((struct proc *, struct linux_semctl_args *));
|
||||
int linux_semget __P((struct proc *, struct linux_semget_args *));
|
||||
int linux_semop __P((struct proc *, struct linux_semop_args *));
|
||||
int linux_lchown __P((struct proc *, struct linux_lchown_args *));
|
||||
int linux_shmat __P((struct proc *, struct linux_shmat_args *));
|
||||
int linux_shmctl __P((struct proc *, struct linux_shmctl_args *));
|
||||
int linux_shmdt __P((struct proc *, struct linux_shmdt_args *));
|
||||
int linux_shmget __P((struct proc *, struct linux_shmget_args *));
|
||||
int linux_msync __P((struct proc *, struct linux_msync_args *));
|
||||
int linux_getpgid __P((struct proc *, struct linux_getpgid_args *));
|
||||
int linux_getsid __P((struct proc *, struct linux_getsid_args *));
|
||||
int linux_sigaltstack __P((struct proc *, struct linux_sigaltstack_args *));
|
||||
int osf1_sysinfo __P((struct proc *, struct osf1_sysinfo_args *));
|
||||
int linux_sysfs __P((struct proc *, struct linux_sysfs_args *));
|
||||
int osf1_getsysinfo __P((struct proc *, struct osf1_getsysinfo_args *));
|
||||
int osf1_setsysinfo __P((struct proc *, struct osf1_setsysinfo_args *));
|
||||
int linux_bdflush __P((struct proc *, struct linux_bdflush_args *));
|
||||
int linux_sethae __P((struct proc *, struct linux_sethae_args *));
|
||||
int linux_mount __P((struct proc *, struct linux_mount_args *));
|
||||
int linux_old_adjtimex __P((struct proc *, struct linux_old_adjtimex_args *));
|
||||
int linux_swapoff __P((struct proc *, struct linux_swapoff_args *));
|
||||
int linux_getdents __P((struct proc *, struct linux_getdents_args *));
|
||||
int linux_create_module __P((struct proc *, struct linux_create_module_args *));
|
||||
int linux_init_module __P((struct proc *, struct linux_init_module_args *));
|
||||
int linux_delete_module __P((struct proc *, struct linux_delete_module_args *));
|
||||
int linux_get_kernel_syms __P((struct proc *, struct linux_get_kernel_syms_args *));
|
||||
int linux_syslog __P((struct proc *, struct linux_syslog_args *));
|
||||
int linux_reboot __P((struct proc *, struct linux_reboot_args *));
|
||||
int linux_clone __P((struct proc *, struct linux_clone_args *));
|
||||
int linux_uselib __P((struct proc *, struct linux_uselib_args *));
|
||||
int linux_sysinfo __P((struct proc *, struct linux_sysinfo_args *));
|
||||
int linux_sysctl __P((struct proc *, struct linux_sysctl_args *));
|
||||
int linux_oldumount __P((struct proc *, struct linux_oldumount_args *));
|
||||
int linux_times __P((struct proc *, struct linux_times_args *));
|
||||
int linux_personality __P((struct proc *, struct linux_personality_args *));
|
||||
int linux_setfsuid __P((struct proc *, struct linux_setfsuid_args *));
|
||||
int linux_setfsgid __P((struct proc *, struct linux_setfsgid_args *));
|
||||
int linux_ustat __P((struct proc *, struct linux_ustat_args *));
|
||||
int linux_statfs __P((struct proc *, struct linux_statfs_args *));
|
||||
int linux_fstatfs __P((struct proc *, struct linux_fstatfs_args *));
|
||||
int linux_sched_setscheduler __P((struct proc *, struct linux_sched_setscheduler_args *));
|
||||
int linux_sched_getscheduler __P((struct proc *, struct linux_sched_getscheduler_args *));
|
||||
int linux_sched_get_priority_max __P((struct proc *, struct linux_sched_get_priority_max_args *));
|
||||
int linux_sched_get_priority_min __P((struct proc *, struct linux_sched_get_priority_min_args *));
|
||||
int linux_newuname __P((struct proc *, struct linux_newuname_args *));
|
||||
int linux_mremap __P((struct proc *, struct linux_mremap_args *));
|
||||
int linux_nfsservctl __P((struct proc *, struct linux_nfsservctl_args *));
|
||||
int linux_pciconfig_read __P((struct proc *, struct linux_pciconfig_read_args *));
|
||||
int linux_pciconfig_write __P((struct proc *, struct linux_pciconfig_write_args *));
|
||||
int linux_query_module __P((struct proc *, struct linux_query_module_args *));
|
||||
int linux_prctl __P((struct proc *, struct linux_prctl_args *));
|
||||
int linux_pread __P((struct proc *, struct linux_pread_args *));
|
||||
int linux_pwrite __P((struct proc *, struct linux_pwrite_args *));
|
||||
int linux_rt_sigreturn __P((struct proc *, struct linux_rt_sigreturn_args *));
|
||||
int linux_rt_sigaction __P((struct proc *, struct linux_rt_sigaction_args *));
|
||||
int linux_rt_sigprocmask __P((struct proc *, struct linux_rt_sigprocmask_args *));
|
||||
int linux_rt_sigpending __P((struct proc *, struct linux_rt_sigpending_args *));
|
||||
int linux_rt_sigtimedwait __P((struct proc *, struct linux_rt_sigtimedwait_args *));
|
||||
int linux_rt_sigqueueinfo __P((struct proc *, struct linux_rt_sigqueueinfo_args *));
|
||||
int linux_rt_sigsuspend __P((struct proc *, struct linux_rt_sigsuspend_args *));
|
||||
int linux_select __P((struct proc *, struct linux_select_args *));
|
||||
int linux_getitimer __P((struct proc *, struct linux_getitimer_args *));
|
||||
int linux_setitimer __P((struct proc *, struct linux_setitimer_args *));
|
||||
int linux_utimes __P((struct proc *, struct linux_utimes_args *));
|
||||
int linux_wait4 __P((struct proc *, struct linux_wait4_args *));
|
||||
int linux_adjtimex __P((struct proc *, struct linux_adjtimex_args *));
|
||||
int linux_getcwd __P((struct proc *, struct linux_getcwd_args *));
|
||||
int linux_capget __P((struct proc *, struct linux_capget_args *));
|
||||
int linux_capset __P((struct proc *, struct linux_capset_args *));
|
||||
int linux_sendfile __P((struct proc *, struct linux_sendfile_args *));
|
||||
int linux_pivot_root __P((struct proc *, struct linux_pivot_root_args *));
|
||||
int linux_mincore __P((struct proc *, struct linux_mincore_args *));
|
||||
int linux_pciconfig_iobase __P((struct proc *, struct linux_pciconfig_iobase_args *));
|
||||
int linux_getdents64 __P((struct proc *, struct linux_getdents64_args *));
|
||||
int linux_fork __P((struct thread *, struct linux_fork_args *));
|
||||
int osf1_wait4 __P((struct thread *, struct osf1_wait4_args *));
|
||||
int linux_link __P((struct thread *, struct linux_link_args *));
|
||||
int linux_unlink __P((struct thread *, struct linux_unlink_args *));
|
||||
int linux_chdir __P((struct thread *, struct linux_chdir_args *));
|
||||
int linux_mknod __P((struct thread *, struct linux_mknod_args *));
|
||||
int linux_chmod __P((struct thread *, struct linux_chmod_args *));
|
||||
int linux_chown __P((struct thread *, struct linux_chown_args *));
|
||||
int linux_brk __P((struct thread *, struct linux_brk_args *));
|
||||
int linux_lseek __P((struct thread *, struct linux_lseek_args *));
|
||||
int linux_getpid __P((struct thread *, struct linux_getpid_args *));
|
||||
int linux_umount __P((struct thread *, struct linux_umount_args *));
|
||||
int linux_getuid __P((struct thread *, struct linux_getuid_args *));
|
||||
int linux_ptrace __P((struct thread *, struct linux_ptrace_args *));
|
||||
int linux_access __P((struct thread *, struct linux_access_args *));
|
||||
int linux_kill __P((struct thread *, struct linux_kill_args *));
|
||||
int linux_open __P((struct thread *, struct linux_open_args *));
|
||||
int linux_getgid __P((struct thread *, struct linux_getgid_args *));
|
||||
int osf1_sigprocmask __P((struct thread *, struct osf1_sigprocmask_args *));
|
||||
int linux_sigpending __P((struct thread *, struct linux_sigpending_args *));
|
||||
int linux_ioctl __P((struct thread *, struct linux_ioctl_args *));
|
||||
int linux_symlink __P((struct thread *, struct linux_symlink_args *));
|
||||
int linux_readlink __P((struct thread *, struct linux_readlink_args *));
|
||||
int linux_execve __P((struct thread *, struct linux_execve_args *));
|
||||
int linux_getpagesize __P((struct thread *, struct linux_getpagesize_args *));
|
||||
int linux_vfork __P((struct thread *, struct linux_vfork_args *));
|
||||
int linux_newstat __P((struct thread *, struct linux_newstat_args *));
|
||||
int linux_newlstat __P((struct thread *, struct linux_newlstat_args *));
|
||||
int linux_mmap __P((struct thread *, struct linux_mmap_args *));
|
||||
int linux_munmap __P((struct thread *, struct linux_munmap_args *));
|
||||
int linux_mprotect __P((struct thread *, struct linux_mprotect_args *));
|
||||
int linux_madvise __P((struct thread *, struct linux_madvise_args *));
|
||||
int linux_vhangup __P((struct thread *, struct linux_vhangup_args *));
|
||||
int linux_setgroups __P((struct thread *, struct linux_setgroups_args *));
|
||||
int linux_getgroups __P((struct thread *, struct linux_getgroups_args *));
|
||||
int linux_setpgid __P((struct thread *, struct linux_setpgid_args *));
|
||||
int osf1_setitimer __P((struct thread *, struct osf1_setitimer_args *));
|
||||
int linux_gethostname __P((struct thread *, struct linux_gethostname_args *));
|
||||
int linux_getdtablesize __P((struct thread *, struct linux_getdtablesize_args *));
|
||||
int linux_newfstat __P((struct thread *, struct linux_newfstat_args *));
|
||||
int linux_fcntl __P((struct thread *, struct linux_fcntl_args *));
|
||||
int osf1_select __P((struct thread *, struct osf1_select_args *));
|
||||
int osf1_socket __P((struct thread *, struct osf1_socket_args *));
|
||||
int linux_connect __P((struct thread *, struct linux_connect_args *));
|
||||
int osf1_sigreturn __P((struct thread *, struct osf1_sigreturn_args *));
|
||||
int osf1_sigsuspend __P((struct thread *, struct osf1_sigsuspend_args *));
|
||||
int linux_recvmsg __P((struct thread *, struct linux_recvmsg_args *));
|
||||
int linux_sendmsg __P((struct thread *, struct linux_sendmsg_args *));
|
||||
int osf1_gettimeofday __P((struct thread *, struct osf1_gettimeofday_args *));
|
||||
int osf1_getrusage __P((struct thread *, struct osf1_getrusage_args *));
|
||||
int linux_rename __P((struct thread *, struct linux_rename_args *));
|
||||
int linux_truncate __P((struct thread *, struct linux_truncate_args *));
|
||||
int osf1_sendto __P((struct thread *, struct osf1_sendto_args *));
|
||||
int linux_socketpair __P((struct thread *, struct linux_socketpair_args *));
|
||||
int linux_mkdir __P((struct thread *, struct linux_mkdir_args *));
|
||||
int linux_rmdir __P((struct thread *, struct linux_rmdir_args *));
|
||||
int linux_getrlimit __P((struct thread *, struct linux_getrlimit_args *));
|
||||
int linux_setrlimit __P((struct thread *, struct linux_setrlimit_args *));
|
||||
int linux_quotactl __P((struct thread *, struct linux_quotactl_args *));
|
||||
int osf1_sigaction __P((struct thread *, struct osf1_sigaction_args *));
|
||||
int linux_msgctl __P((struct thread *, struct linux_msgctl_args *));
|
||||
int linux_msgget __P((struct thread *, struct linux_msgget_args *));
|
||||
int linux_msgrcv __P((struct thread *, struct linux_msgrcv_args *));
|
||||
int linux_msgsnd __P((struct thread *, struct linux_msgsnd_args *));
|
||||
int linux_semctl __P((struct thread *, struct linux_semctl_args *));
|
||||
int linux_semget __P((struct thread *, struct linux_semget_args *));
|
||||
int linux_semop __P((struct thread *, struct linux_semop_args *));
|
||||
int linux_lchown __P((struct thread *, struct linux_lchown_args *));
|
||||
int linux_shmat __P((struct thread *, struct linux_shmat_args *));
|
||||
int linux_shmctl __P((struct thread *, struct linux_shmctl_args *));
|
||||
int linux_shmdt __P((struct thread *, struct linux_shmdt_args *));
|
||||
int linux_shmget __P((struct thread *, struct linux_shmget_args *));
|
||||
int linux_msync __P((struct thread *, struct linux_msync_args *));
|
||||
int linux_getpgid __P((struct thread *, struct linux_getpgid_args *));
|
||||
int linux_getsid __P((struct thread *, struct linux_getsid_args *));
|
||||
int linux_sigaltstack __P((struct thread *, struct linux_sigaltstack_args *));
|
||||
int osf1_sysinfo __P((struct thread *, struct osf1_sysinfo_args *));
|
||||
int linux_sysfs __P((struct thread *, struct linux_sysfs_args *));
|
||||
int osf1_getsysinfo __P((struct thread *, struct osf1_getsysinfo_args *));
|
||||
int osf1_setsysinfo __P((struct thread *, struct osf1_setsysinfo_args *));
|
||||
int linux_bdflush __P((struct thread *, struct linux_bdflush_args *));
|
||||
int linux_sethae __P((struct thread *, struct linux_sethae_args *));
|
||||
int linux_mount __P((struct thread *, struct linux_mount_args *));
|
||||
int linux_old_adjtimex __P((struct thread *, struct linux_old_adjtimex_args *));
|
||||
int linux_swapoff __P((struct thread *, struct linux_swapoff_args *));
|
||||
int linux_getdents __P((struct thread *, struct linux_getdents_args *));
|
||||
int linux_create_module __P((struct thread *, struct linux_create_module_args *));
|
||||
int linux_init_module __P((struct thread *, struct linux_init_module_args *));
|
||||
int linux_delete_module __P((struct thread *, struct linux_delete_module_args *));
|
||||
int linux_get_kernel_syms __P((struct thread *, struct linux_get_kernel_syms_args *));
|
||||
int linux_syslog __P((struct thread *, struct linux_syslog_args *));
|
||||
int linux_reboot __P((struct thread *, struct linux_reboot_args *));
|
||||
int linux_clone __P((struct thread *, struct linux_clone_args *));
|
||||
int linux_uselib __P((struct thread *, struct linux_uselib_args *));
|
||||
int linux_sysinfo __P((struct thread *, struct linux_sysinfo_args *));
|
||||
int linux_sysctl __P((struct thread *, struct linux_sysctl_args *));
|
||||
int linux_oldumount __P((struct thread *, struct linux_oldumount_args *));
|
||||
int linux_times __P((struct thread *, struct linux_times_args *));
|
||||
int linux_personality __P((struct thread *, struct linux_personality_args *));
|
||||
int linux_setfsuid __P((struct thread *, struct linux_setfsuid_args *));
|
||||
int linux_setfsgid __P((struct thread *, struct linux_setfsgid_args *));
|
||||
int linux_ustat __P((struct thread *, struct linux_ustat_args *));
|
||||
int linux_statfs __P((struct thread *, struct linux_statfs_args *));
|
||||
int linux_fstatfs __P((struct thread *, struct linux_fstatfs_args *));
|
||||
int linux_sched_setscheduler __P((struct thread *, struct linux_sched_setscheduler_args *));
|
||||
int linux_sched_getscheduler __P((struct thread *, struct linux_sched_getscheduler_args *));
|
||||
int linux_sched_get_priority_max __P((struct thread *, struct linux_sched_get_priority_max_args *));
|
||||
int linux_sched_get_priority_min __P((struct thread *, struct linux_sched_get_priority_min_args *));
|
||||
int linux_newuname __P((struct thread *, struct linux_newuname_args *));
|
||||
int linux_mremap __P((struct thread *, struct linux_mremap_args *));
|
||||
int linux_nfsservctl __P((struct thread *, struct linux_nfsservctl_args *));
|
||||
int linux_pciconfig_read __P((struct thread *, struct linux_pciconfig_read_args *));
|
||||
int linux_pciconfig_write __P((struct thread *, struct linux_pciconfig_write_args *));
|
||||
int linux_query_module __P((struct thread *, struct linux_query_module_args *));
|
||||
int linux_prctl __P((struct thread *, struct linux_prctl_args *));
|
||||
int linux_pread __P((struct thread *, struct linux_pread_args *));
|
||||
int linux_pwrite __P((struct thread *, struct linux_pwrite_args *));
|
||||
int linux_rt_sigreturn __P((struct thread *, struct linux_rt_sigreturn_args *));
|
||||
int linux_rt_sigaction __P((struct thread *, struct linux_rt_sigaction_args *));
|
||||
int linux_rt_sigprocmask __P((struct thread *, struct linux_rt_sigprocmask_args *));
|
||||
int linux_rt_sigpending __P((struct thread *, struct linux_rt_sigpending_args *));
|
||||
int linux_rt_sigtimedwait __P((struct thread *, struct linux_rt_sigtimedwait_args *));
|
||||
int linux_rt_sigqueueinfo __P((struct thread *, struct linux_rt_sigqueueinfo_args *));
|
||||
int linux_rt_sigsuspend __P((struct thread *, struct linux_rt_sigsuspend_args *));
|
||||
int linux_select __P((struct thread *, struct linux_select_args *));
|
||||
int linux_getitimer __P((struct thread *, struct linux_getitimer_args *));
|
||||
int linux_setitimer __P((struct thread *, struct linux_setitimer_args *));
|
||||
int linux_utimes __P((struct thread *, struct linux_utimes_args *));
|
||||
int linux_wait4 __P((struct thread *, struct linux_wait4_args *));
|
||||
int linux_adjtimex __P((struct thread *, struct linux_adjtimex_args *));
|
||||
int linux_getcwd __P((struct thread *, struct linux_getcwd_args *));
|
||||
int linux_capget __P((struct thread *, struct linux_capget_args *));
|
||||
int linux_capset __P((struct thread *, struct linux_capset_args *));
|
||||
int linux_sendfile __P((struct thread *, struct linux_sendfile_args *));
|
||||
int linux_pivot_root __P((struct thread *, struct linux_pivot_root_args *));
|
||||
int linux_mincore __P((struct thread *, struct linux_mincore_args *));
|
||||
int linux_pciconfig_iobase __P((struct thread *, struct linux_pciconfig_iobase_args *));
|
||||
int linux_getdents64 __P((struct thread *, struct linux_getdents64_args *));
|
||||
|
||||
#ifdef COMPAT_43
|
||||
|
||||
|
@ -264,7 +264,7 @@ zs_cnputc(dev_t dev, int c)
|
||||
|
||||
|
||||
static int
|
||||
zsopen(dev_t dev, int flag, int mode, struct proc *p)
|
||||
zsopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
{
|
||||
struct zs_softc *sc = ZS_SOFTC(minor(dev));
|
||||
struct tty *tp;
|
||||
@ -290,7 +290,7 @@ zsopen(dev_t dev, int flag, int mode, struct proc *p)
|
||||
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
|
||||
ttsetwater(tp);
|
||||
setuptimeout = 1;
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(p)) {
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(td->td_proc)) {
|
||||
splx(s);
|
||||
return EBUSY;
|
||||
}
|
||||
@ -311,7 +311,7 @@ zsopen(dev_t dev, int flag, int mode, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
zsclose(dev_t dev, int flag, int mode, struct proc *p)
|
||||
zsclose(dev_t dev, int flag, int mode, struct thread *td)
|
||||
{
|
||||
struct zs_softc *sc = ZS_SOFTC(minor(dev));
|
||||
struct tty *tp;
|
||||
@ -332,7 +332,7 @@ zsclose(dev_t dev, int flag, int mode, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
zsioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
|
||||
zsioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
{
|
||||
struct zs_softc *sc = ZS_SOFTC(minor(dev));
|
||||
struct tty *tp;
|
||||
@ -343,7 +343,7 @@ zsioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
|
||||
|
||||
tp = ZS_SOFTC(minor(dev))->tp;
|
||||
|
||||
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
|
||||
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, td);
|
||||
|
||||
if (error != ENOIOCTL)
|
||||
return (error);
|
||||
|
@ -48,10 +48,10 @@ IDTVEC(vec_name) ; \
|
||||
movl $KPSEL,%eax ; \
|
||||
mov %ax,%fs ; \
|
||||
FAKE_MCOUNT(13*4(%esp)) ; \
|
||||
movl PCPU(CURPROC),%ebx ; \
|
||||
incl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
movl PCPU(CURTHREAD),%ebx ; \
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
pushl intr_unit + (irq_num) * 4 ; \
|
||||
call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
|
||||
call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
|
||||
addl $4, %esp ; \
|
||||
movl $0, lapic+LA_EOI ; \
|
||||
lock ; \
|
||||
@ -59,7 +59,7 @@ IDTVEC(vec_name) ; \
|
||||
movl intr_countp + (irq_num) * 4, %eax ; \
|
||||
lock ; \
|
||||
incl (%eax) ; \
|
||||
decl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
MEXITCOUNT ; \
|
||||
jmp doreti
|
||||
|
||||
@ -152,8 +152,8 @@ IDTVEC(vec_name) ; \
|
||||
MASK_LEVEL_IRQ(irq_num) ; \
|
||||
EOI_IRQ(irq_num) ; \
|
||||
0: ; \
|
||||
movl PCPU(CURPROC),%ebx ; \
|
||||
incl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
movl PCPU(CURTHREAD),%ebx ; \
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
; \
|
||||
/* entry point used by doreti_unpend for HWIs. */ \
|
||||
__CONCAT(Xresume,irq_num): ; \
|
||||
@ -162,7 +162,7 @@ __CONCAT(Xresume,irq_num): ; \
|
||||
call sched_ithd ; \
|
||||
addl $4, %esp ; /* discard the parameter */ \
|
||||
; \
|
||||
decl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
MEXITCOUNT ; \
|
||||
jmp doreti
|
||||
|
||||
@ -227,10 +227,10 @@ Xhardclock:
|
||||
|
||||
movl $0, lapic+LA_EOI /* End Of Interrupt to APIC */
|
||||
|
||||
movl PCPU(CURPROC),%ebx
|
||||
incl P_INTR_NESTING_LEVEL(%ebx)
|
||||
movl PCPU(CURTHREAD),%ebx
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx)
|
||||
call forwarded_hardclock
|
||||
decl P_INTR_NESTING_LEVEL(%ebx)
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx)
|
||||
MEXITCOUNT
|
||||
jmp doreti
|
||||
|
||||
@ -252,10 +252,10 @@ Xstatclock:
|
||||
movl $0, lapic+LA_EOI /* End Of Interrupt to APIC */
|
||||
|
||||
FAKE_MCOUNT(13*4(%esp))
|
||||
movl PCPU(CURPROC),%ebx
|
||||
incl P_INTR_NESTING_LEVEL(%ebx)
|
||||
movl PCPU(CURTHREAD),%ebx
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx)
|
||||
call forwarded_statclock
|
||||
decl P_INTR_NESTING_LEVEL(%ebx)
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx)
|
||||
MEXITCOUNT
|
||||
jmp doreti
|
||||
|
||||
|
@ -77,17 +77,17 @@ ENTRY(cpu_throw)
|
||||
ENTRY(cpu_switch)
|
||||
|
||||
/* switch to new process. first, save context as needed */
|
||||
movl PCPU(CURPROC),%ecx
|
||||
movl PCPU(CURTHREAD),%ecx
|
||||
|
||||
/* if no process to save, don't bother */
|
||||
testl %ecx,%ecx
|
||||
jz sw1
|
||||
|
||||
movl P_VMSPACE(%ecx), %edx
|
||||
movl TD_PROC(%ecx), %eax
|
||||
movl P_VMSPACE(%eax), %edx
|
||||
movl PCPU(CPUID), %eax
|
||||
btrl %eax, VM_PMAP+PM_ACTIVE(%edx)
|
||||
|
||||
movl P_ADDR(%ecx),%edx
|
||||
movl TD_PCB(%ecx),%edx
|
||||
|
||||
movl (%esp),%eax /* Hardware registers */
|
||||
movl %eax,PCB_EIP(%edx)
|
||||
@ -124,7 +124,7 @@ ENTRY(cpu_switch)
|
||||
|
||||
#ifdef DEV_NPX
|
||||
/* have we used fp, and need a save? */
|
||||
cmpl %ecx,PCPU(NPXPROC)
|
||||
cmpl %ecx,PCPU(NPXTHREAD)
|
||||
jne 1f
|
||||
addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */
|
||||
pushl %edx
|
||||
@ -133,7 +133,11 @@ ENTRY(cpu_switch)
|
||||
1:
|
||||
#endif /* DEV_NPX */
|
||||
|
||||
/*##########################################################################*/
|
||||
/*##########################################################################*/
|
||||
/*##########################################################################*/
|
||||
/* save is done, now choose a new process */
|
||||
/* But still trashing space above the old "Top Of Stack".. */
|
||||
sw1:
|
||||
|
||||
#ifdef SMP
|
||||
@ -143,17 +147,17 @@ sw1:
|
||||
cmpl $0,PCPU(CPUID)
|
||||
je 1f
|
||||
|
||||
movl PCPU(IDLEPROC), %eax
|
||||
jmp sw1b
|
||||
movl PCPU(IDLETHREAD), %eax
|
||||
jmp sw1b /* Idle thread can run on any kernel context */
|
||||
1:
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Choose a new process to schedule. chooseproc() returns idleproc
|
||||
* Choose a new process to schedule. choosethread() returns idleproc
|
||||
* if it cannot find another process to run.
|
||||
*/
|
||||
sw1a:
|
||||
call chooseproc /* trash ecx, edx, ret eax*/
|
||||
call choosethread /* trash ecx, edx, ret eax*/
|
||||
|
||||
#ifdef INVARIANTS
|
||||
testl %eax,%eax /* no process? */
|
||||
@ -163,15 +167,20 @@ sw1b:
|
||||
movl %eax,%ecx
|
||||
|
||||
#ifdef INVARIANTS
|
||||
cmpb $SRUN,P_STAT(%ecx)
|
||||
movl TD_PROC(%ecx), %eax /* XXXKSE */
|
||||
cmpb $SRUN,P_STAT(%eax)
|
||||
jne badsw2
|
||||
#endif
|
||||
|
||||
movl P_ADDR(%ecx),%edx
|
||||
movl TD_PCB(%ecx),%edx
|
||||
|
||||
#if defined(SWTCH_OPTIM_STATS)
|
||||
incl swtch_optim_stats
|
||||
#endif
|
||||
|
||||
/*##########################################################################*/
|
||||
/*##########################################################################*/
|
||||
/*##########################################################################*/
|
||||
/* switch address space */
|
||||
movl %cr3,%ebx
|
||||
cmpl PCB_CR3(%edx),%ebx
|
||||
@ -181,9 +190,8 @@ sw1b:
|
||||
incl tlb_flush_count
|
||||
#endif
|
||||
movl PCB_CR3(%edx),%ebx
|
||||
movl %ebx,%cr3
|
||||
movl %ebx,%cr3 /* LOAD NEW PAGE TABLES */
|
||||
4:
|
||||
|
||||
movl PCPU(CPUID), %esi
|
||||
cmpl $0, PCB_EXT(%edx) /* has pcb extension? */
|
||||
je 1f
|
||||
@ -191,12 +199,9 @@ sw1b:
|
||||
movl PCB_EXT(%edx), %edi /* new tss descriptor */
|
||||
jmp 2f
|
||||
1:
|
||||
|
||||
/* update common_tss.tss_esp0 pointer */
|
||||
movl %edx, %ebx /* pcb */
|
||||
addl $(UPAGES * PAGE_SIZE - 16), %ebx
|
||||
movl %ebx, PCPU(COMMON_TSS) + TSS_ESP0
|
||||
|
||||
/* esp points to base of usable stack */
|
||||
movl %edx, PCPU(COMMON_TSS) + TSS_ESP0 /* stack is below pcb */
|
||||
btrl %esi, private_tss
|
||||
jae 3f
|
||||
PCPU_ADDR(COMMON_TSSD, %edi)
|
||||
@ -210,7 +215,9 @@ sw1b:
|
||||
movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */
|
||||
ltr %si
|
||||
3:
|
||||
movl P_VMSPACE(%ecx), %ebx
|
||||
/* note in a vmspace that this cpu is using it */
|
||||
movl TD_PROC(%ecx),%eax /* get proc from thread XXXKSE */
|
||||
movl P_VMSPACE(%eax), %ebx /* get vmspace of proc */
|
||||
movl PCPU(CPUID), %eax
|
||||
btsl %eax, VM_PMAP+PM_ACTIVE(%ebx)
|
||||
|
||||
@ -233,22 +240,23 @@ sw1b:
|
||||
#endif /** GRAB_LOPRIO */
|
||||
#endif /* SMP */
|
||||
movl %edx, PCPU(CURPCB)
|
||||
movl %ecx, PCPU(CURPROC) /* into next process */
|
||||
movl %ecx, PCPU(CURTHREAD) /* into next process */
|
||||
|
||||
#ifdef SMP
|
||||
/* XXX FIXME: we should be restoring the local APIC TPR */
|
||||
#endif /* SMP */
|
||||
|
||||
cmpl $0, PCB_USERLDT(%edx)
|
||||
jnz 1f
|
||||
movl _default_ldt,%eax
|
||||
cmpl PCPU(CURRENTLDT),%eax
|
||||
je 2f
|
||||
lldt _default_ldt
|
||||
movl %eax,PCPU(CURRENTLDT)
|
||||
cmpl $0, PCB_USERLDT(%edx) /* if there is one */
|
||||
jnz 1f /* then use it */
|
||||
movl _default_ldt,%eax /* We will use the default */
|
||||
cmpl PCPU(CURRENTLDT),%eax /* check to see if already loaded */
|
||||
je 2f /* if so skip reload */
|
||||
lldt _default_ldt /* load the default... we trust it. */
|
||||
movl %eax,PCPU(CURRENTLDT) /* store what we have */
|
||||
jmp 2f
|
||||
1: pushl %edx
|
||||
call set_user_ldt
|
||||
|
||||
1: pushl %edx /* call a non-trusting routine */
|
||||
call set_user_ldt /* to check and load the ldt */
|
||||
popl %edx
|
||||
2:
|
||||
|
||||
@ -275,7 +283,7 @@ cpu_switch_load_gs:
|
||||
andl $0x0000fc00,%eax /* reserved bits */
|
||||
pushl %ebx
|
||||
movl PCB_DR7(%edx),%ebx
|
||||
andl $~0x0000fc00,%ebx
|
||||
andl $~0x0000fc00,%ebx /* re-enable the restored watchpoints */
|
||||
orl %ebx,%eax
|
||||
popl %ebx
|
||||
movl %eax,%dr7
|
||||
@ -322,25 +330,25 @@ ENTRY(savectx)
|
||||
|
||||
#ifdef DEV_NPX
|
||||
/*
|
||||
* If npxproc == NULL, then the npx h/w state is irrelevant and the
|
||||
* If npxthread == NULL, then the npx h/w state is irrelevant and the
|
||||
* state had better already be in the pcb. This is true for forks
|
||||
* but not for dumps (the old book-keeping with FP flags in the pcb
|
||||
* always lost for dumps because the dump pcb has 0 flags).
|
||||
*
|
||||
* If npxproc != NULL, then we have to save the npx h/w state to
|
||||
* npxproc's pcb and copy it to the requested pcb, or save to the
|
||||
* If npxthread != NULL, then we have to save the npx h/w state to
|
||||
* npxthread's pcb and copy it to the requested pcb, or save to the
|
||||
* requested pcb and reload. Copying is easier because we would
|
||||
* have to handle h/w bugs for reloading. We used to lose the
|
||||
* parent's npx state for forks by forgetting to reload.
|
||||
*/
|
||||
pushfl
|
||||
cli
|
||||
movl PCPU(NPXPROC),%eax
|
||||
movl PCPU(NPXTHREAD),%eax
|
||||
testl %eax,%eax
|
||||
je 1f
|
||||
|
||||
pushl %ecx
|
||||
movl P_ADDR(%eax),%eax
|
||||
movl TD_PCB(%eax),%eax
|
||||
leal PCB_SAVEFPU(%eax),%eax
|
||||
pushl %eax
|
||||
pushl %eax
|
||||
|
@ -351,23 +351,24 @@ DB_SHOW_COMMAND(pcpu, db_show_pcpu)
|
||||
gd = GLOBALDATA;
|
||||
#endif
|
||||
db_printf("cpuid = %d\n", gd->gd_cpuid);
|
||||
db_printf("curproc = ");
|
||||
if (gd->gd_curproc != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_curproc,
|
||||
gd->gd_curproc->p_pid, gd->gd_curproc->p_comm);
|
||||
db_printf("curthread = ");
|
||||
if (gd->gd_curthread != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_curthread,
|
||||
gd->gd_curthread->td_proc->p_pid, gd->gd_curthread->td_proc->p_comm);
|
||||
else
|
||||
db_printf("none\n");
|
||||
db_printf("curpcb = %p\n", gd->gd_curpcb);
|
||||
db_printf("npxproc = ");
|
||||
if (gd->gd_npxproc != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_npxproc,
|
||||
gd->gd_npxproc->p_pid, gd->gd_npxproc->p_comm);
|
||||
db_printf("npxthread = ");
|
||||
if (gd->gd_npxthread != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_npxthread,
|
||||
gd->gd_npxthread->td_proc->p_pid, gd->gd_npxthread->td_proc->p_comm);
|
||||
else
|
||||
db_printf("none\n");
|
||||
db_printf("idleproc = ");
|
||||
if (gd->gd_idleproc != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_idleproc,
|
||||
gd->gd_idleproc->p_pid, gd->gd_idleproc->p_comm);
|
||||
db_printf("idlethread = ");
|
||||
if (gd->gd_idlethread != NULL)
|
||||
db_printf("%p: pid %d \"%s\"\n", gd->gd_idlethread,
|
||||
gd->gd_idlethread->td_proc->p_pid,
|
||||
gd->gd_idlethread->td_proc->p_comm);
|
||||
else
|
||||
db_printf("none\n");
|
||||
|
||||
|
@ -291,13 +291,15 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
|
||||
boolean_t first;
|
||||
struct pcb *pcb;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
pid_t pid;
|
||||
|
||||
if (count == -1)
|
||||
count = 1024;
|
||||
|
||||
if (!have_addr) {
|
||||
p = curproc;
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
frame = (struct i386_frame *)ddb_regs.tf_ebp;
|
||||
if (frame == NULL)
|
||||
frame = (struct i386_frame *)(ddb_regs.tf_esp - 4);
|
||||
@ -310,8 +312,9 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
|
||||
* The pcb for curproc is not valid at this point,
|
||||
* so fall back to the default case.
|
||||
*/
|
||||
if (pid == curproc->p_pid) {
|
||||
p = curproc;
|
||||
if (pid == curthread->td_proc->p_pid) {
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
frame = (struct i386_frame *)ddb_regs.tf_ebp;
|
||||
if (frame == NULL)
|
||||
frame = (struct i386_frame *)
|
||||
@ -333,7 +336,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
|
||||
db_printf("pid %d swapped out\n", pid);
|
||||
return;
|
||||
}
|
||||
pcb = &p->p_addr->u_pcb;
|
||||
pcb = p->p_thread.td_pcb; /* XXXKSE */
|
||||
frame = (struct i386_frame *)pcb->pcb_ebp;
|
||||
if (frame == NULL)
|
||||
frame = (struct i386_frame *)
|
||||
|
@ -128,23 +128,23 @@ void stop_emulating __P((void));
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#ifdef CPU_ENABLE_SSE
|
||||
#define GET_FPU_CW(proc) \
|
||||
#define GET_FPU_CW(thread) \
|
||||
(cpu_fxsr ? \
|
||||
(proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_cw : \
|
||||
(proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw)
|
||||
#define GET_FPU_SW(proc) \
|
||||
(thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_cw : \
|
||||
(thread)->td_pcb->pcb_save.sv_87.sv_env.en_cw)
|
||||
#define GET_FPU_SW(thread) \
|
||||
(cpu_fxsr ? \
|
||||
(proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_sw : \
|
||||
(proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw)
|
||||
(thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_sw : \
|
||||
(thread)->td_pcb->pcb_save.sv_87.sv_env.en_sw)
|
||||
#define GET_FPU_EXSW_PTR(pcb) \
|
||||
(cpu_fxsr ? \
|
||||
&(pcb)->pcb_save.sv_xmm.sv_ex_sw : \
|
||||
&(pcb)->pcb_save.sv_87.sv_ex_sw)
|
||||
#else /* CPU_ENABLE_SSE */
|
||||
#define GET_FPU_CW(proc) \
|
||||
(proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw)
|
||||
#define GET_FPU_SW(proc) \
|
||||
(proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw)
|
||||
#define GET_FPU_CW(thread) \
|
||||
(thread->td_pcb->pcb_save.sv_87.sv_env.en_cw)
|
||||
#define GET_FPU_SW(thread) \
|
||||
(thread->td_pcb->pcb_save.sv_87.sv_env.en_sw)
|
||||
#define GET_FPU_EXSW_PTR(pcb) \
|
||||
(&(pcb)->pcb_save.sv_87.sv_ex_sw)
|
||||
#endif /* CPU_ENABLE_SSE */
|
||||
@ -241,7 +241,7 @@ static void
|
||||
npx_intr(dummy)
|
||||
void *dummy;
|
||||
{
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
|
||||
/*
|
||||
* The BUSY# latch must be cleared in all cases so that the next
|
||||
@ -250,22 +250,22 @@ npx_intr(dummy)
|
||||
outb(0xf0, 0);
|
||||
|
||||
/*
|
||||
* npxproc is normally non-null here. In that case, schedule an
|
||||
* npxthread is normally non-null here. In that case, schedule an
|
||||
* AST to finish the exception handling in the correct context
|
||||
* (this interrupt may occur after the process has entered the
|
||||
* (this interrupt may occur after the thread has entered the
|
||||
* kernel via a syscall or an interrupt). Otherwise, the npx
|
||||
* state of the process that caused this interrupt must have been
|
||||
* pushed to the process' pcb, and clearing of the busy latch
|
||||
* state of the thread that caused this interrupt must have been
|
||||
* pushed to the thread' pcb, and clearing of the busy latch
|
||||
* above has finished the (essentially null) handling of this
|
||||
* interrupt. Control will eventually return to the instruction
|
||||
* that caused it and it will repeat. We will eventually (usually
|
||||
* soon) win the race to handle the interrupt properly.
|
||||
*/
|
||||
p = PCPU_GET(npxproc);
|
||||
if (p != NULL) {
|
||||
p->p_addr->u_pcb.pcb_flags |= PCB_NPXTRAP;
|
||||
td = PCPU_GET(npxthread);
|
||||
if (td != NULL) {
|
||||
td->td_pcb->pcb_flags |= PCB_NPXTRAP;
|
||||
mtx_lock_spin(&sched_lock);
|
||||
p->p_sflag |= PS_ASTPENDING;
|
||||
td->td_kse->ke_flags |= KEF_ASTPENDING;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
@ -570,7 +570,7 @@ npxinit(control)
|
||||
/*
|
||||
* fninit has the same h/w bugs as fnsave. Use the detoxified
|
||||
* fnsave to throw away any junk in the fpu. npxsave() initializes
|
||||
* the fpu and sets npxproc = NULL as important side effects.
|
||||
* the fpu and sets npxthread = NULL as important side effects.
|
||||
*/
|
||||
savecrit = critical_enter();
|
||||
npxsave(&dummy);
|
||||
@ -586,13 +586,13 @@ npxinit(control)
|
||||
* Free coprocessor (if we have it).
|
||||
*/
|
||||
void
|
||||
npxexit(p)
|
||||
struct proc *p;
|
||||
npxexit(td)
|
||||
struct thread *td;
|
||||
{
|
||||
critical_t savecrit;
|
||||
|
||||
savecrit = critical_enter();
|
||||
if (p == PCPU_GET(npxproc))
|
||||
if (td == PCPU_GET(npxthread))
|
||||
npxsave(&PCPU_GET(curpcb)->pcb_save);
|
||||
critical_exit(savecrit);
|
||||
#ifdef NPX_DEBUG
|
||||
@ -607,8 +607,9 @@ npxexit(p)
|
||||
*/
|
||||
if (masked_exceptions & 0x0d)
|
||||
log(LOG_ERR,
|
||||
"pid %d (%s) exited with masked floating point exceptions 0x%02x\n",
|
||||
p->p_pid, p->p_comm, masked_exceptions);
|
||||
"pid %d (%s) exited with masked floating"
|
||||
" point exceptions 0x%02x\n",
|
||||
td->td_proc->p_pid, td->td_proc->p_comm, masked_exceptions);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -809,8 +810,8 @@ npxtrap()
|
||||
u_long *exstat;
|
||||
|
||||
if (!npx_exists) {
|
||||
printf("npxtrap: npxproc = %p, curproc = %p, npx_exists = %d\n",
|
||||
PCPU_GET(npxproc), curproc, npx_exists);
|
||||
printf("npxtrap: npxthread = %p, curthread = %p, npx_exists = %d\n",
|
||||
PCPU_GET(npxthread), curthread, npx_exists);
|
||||
panic("npxtrap from nowhere");
|
||||
}
|
||||
savecrit = critical_enter();
|
||||
@ -820,18 +821,18 @@ npxtrap()
|
||||
* state to memory. Fetch the relevant parts of the state from
|
||||
* wherever they are.
|
||||
*/
|
||||
if (PCPU_GET(npxproc) != curproc) {
|
||||
control = GET_FPU_CW(curproc);
|
||||
status = GET_FPU_SW(curproc);
|
||||
if (PCPU_GET(npxthread) != curthread) {
|
||||
control = GET_FPU_CW(curthread);
|
||||
status = GET_FPU_SW(curthread);
|
||||
} else {
|
||||
fnstcw(&control);
|
||||
fnstsw(&status);
|
||||
}
|
||||
|
||||
exstat = GET_FPU_EXSW_PTR(&curproc->p_addr->u_pcb);
|
||||
exstat = GET_FPU_EXSW_PTR(curthread->td_pcb);
|
||||
*exstat = status;
|
||||
if (PCPU_GET(npxproc) != curproc)
|
||||
GET_FPU_SW(curproc) &= ~0x80bf;
|
||||
if (PCPU_GET(npxthread) != curthread)
|
||||
GET_FPU_SW(curthread) &= ~0x80bf;
|
||||
else
|
||||
fnclex();
|
||||
critical_exit(savecrit);
|
||||
@ -841,7 +842,7 @@ npxtrap()
|
||||
/*
|
||||
* Implement device not available (DNA) exception
|
||||
*
|
||||
* It would be better to switch FP context here (if curproc != npxproc)
|
||||
* It would be better to switch FP context here (if curthread != npxthread)
|
||||
* and not necessarily for every context switch, but it is too hard to
|
||||
* access foreign pcb's.
|
||||
*/
|
||||
@ -853,9 +854,9 @@ npxdna()
|
||||
|
||||
if (!npx_exists)
|
||||
return (0);
|
||||
if (PCPU_GET(npxproc) != NULL) {
|
||||
printf("npxdna: npxproc = %p, curproc = %p\n",
|
||||
PCPU_GET(npxproc), curproc);
|
||||
if (PCPU_GET(npxthread) != NULL) {
|
||||
printf("npxdna: npxthread = %p, curthread = %p\n",
|
||||
PCPU_GET(npxthread), curthread);
|
||||
panic("npxdna");
|
||||
}
|
||||
s = critical_enter();
|
||||
@ -863,7 +864,7 @@ npxdna()
|
||||
/*
|
||||
* Record new context early in case frstor causes an IRQ13.
|
||||
*/
|
||||
PCPU_SET(npxproc, CURPROC);
|
||||
PCPU_SET(npxthread, curthread);
|
||||
|
||||
exstat = GET_FPU_EXSW_PTR(PCPU_GET(curpcb));
|
||||
*exstat = 0;
|
||||
@ -895,13 +896,13 @@ npxdna()
|
||||
* after the process has entered the kernel. It may even be delivered after
|
||||
* the fnsave here completes. A spurious IRQ13 for the fnsave is handled in
|
||||
* the same way as a very-late-arriving non-spurious IRQ13 from user mode:
|
||||
* it is normally ignored at first because we set npxproc to NULL; it is
|
||||
* it is normally ignored at first because we set npxthread to NULL; it is
|
||||
* normally retriggered in npxdna() after return to user mode.
|
||||
*
|
||||
* npxsave() must be called with interrupts disabled, so that it clears
|
||||
* npxproc atomically with saving the state. We require callers to do the
|
||||
* npxthread atomically with saving the state. We require callers to do the
|
||||
* disabling, since most callers need to disable interrupts anyway to call
|
||||
* npxsave() atomically with checking npxproc.
|
||||
* npxsave() atomically with checking npxthread.
|
||||
*
|
||||
* A previous version of npxsave() went to great lengths to excecute fnsave
|
||||
* with interrupts enabled in case executing it froze the CPU. This case
|
||||
@ -917,7 +918,7 @@ npxsave(addr)
|
||||
fpusave(addr);
|
||||
|
||||
start_emulating();
|
||||
PCPU_SET(npxproc, NULL);
|
||||
PCPU_SET(npxthread, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -37,7 +37,7 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include "opt_upages.h"
|
||||
#include "opt_kstack_pages.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -50,6 +50,7 @@
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/user.h>
|
||||
/* XXX */
|
||||
#ifdef KTR_PERCPU
|
||||
#include <sys/ktr.h>
|
||||
@ -79,21 +80,31 @@
|
||||
ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
|
||||
ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
|
||||
ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
|
||||
ASSYM(P_ADDR, offsetof(struct proc, p_addr));
|
||||
ASSYM(P_INTR_NESTING_LEVEL, offsetof(struct proc, p_intr_nesting_level));
|
||||
ASSYM(P_SFLAG, offsetof(struct proc, p_sflag));
|
||||
ASSYM(P_STAT, offsetof(struct proc, p_stat));
|
||||
ASSYM(P_WCHAN, offsetof(struct proc, p_wchan));
|
||||
ASSYM(P_UAREA, offsetof(struct proc, p_uarea));
|
||||
|
||||
ASSYM(PS_ASTPENDING, PS_ASTPENDING);
|
||||
ASSYM(PS_NEEDRESCHED, PS_NEEDRESCHED);
|
||||
/*ASSYM(TD_STAT, offsetof(struct thread, td__stat));*/
|
||||
ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
|
||||
ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan));
|
||||
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
|
||||
ASSYM(TD_KSE, offsetof(struct thread, td_kse));
|
||||
ASSYM(TD_PROC, offsetof(struct thread, td_proc));
|
||||
ASSYM(TD_INTR_NESTING_LEVEL, offsetof(struct thread, td_intr_nesting_level));
|
||||
|
||||
ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags));
|
||||
|
||||
ASSYM(KEF_ASTPENDING, KEF_ASTPENDING);
|
||||
ASSYM(KEF_NEEDRESCHED, KEF_NEEDRESCHED);
|
||||
|
||||
ASSYM(SSLEEP, SSLEEP);
|
||||
ASSYM(SRUN, SRUN);
|
||||
ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
|
||||
ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
|
||||
ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
|
||||
ASSYM(UPAGES, UPAGES);
|
||||
/* ASSYM(UPAGES, UPAGES);*/
|
||||
ASSYM(UAREA_PAGES, UAREA_PAGES);
|
||||
ASSYM(KSTACK_PAGES, KSTACK_PAGES);
|
||||
ASSYM(PAGE_SIZE, PAGE_SIZE);
|
||||
ASSYM(NPTEPG, NPTEPG);
|
||||
ASSYM(NPDEPG, NPDEPG);
|
||||
@ -133,9 +144,7 @@ ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu));
|
||||
ASSYM(PCB_SAVE87_SIZE, sizeof(struct save87));
|
||||
ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
|
||||
|
||||
#ifdef SMP
|
||||
ASSYM(PCB_SIZE, sizeof(struct pcb));
|
||||
#endif
|
||||
|
||||
ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
|
||||
ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
|
||||
@ -166,9 +175,9 @@ ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab));
|
||||
ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend));
|
||||
ASSYM(GD_SIZEOF, sizeof(struct globaldata));
|
||||
ASSYM(GD_PRVSPACE, offsetof(struct globaldata, gd_prvspace));
|
||||
ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc));
|
||||
ASSYM(GD_NPXPROC, offsetof(struct globaldata, gd_npxproc));
|
||||
ASSYM(GD_IDLEPROC, offsetof(struct globaldata, gd_idleproc));
|
||||
ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread));
|
||||
ASSYM(GD_NPXTHREAD, offsetof(struct globaldata, gd_npxthread));
|
||||
ASSYM(GD_IDLETHREAD, offsetof(struct globaldata, gd_idlethread));
|
||||
ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb));
|
||||
ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss));
|
||||
ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime));
|
||||
|
@ -147,9 +147,11 @@ IdlePTD: .long 0 /* phys addr of kernel PTD */
|
||||
#endif
|
||||
KPTphys: .long 0 /* phys addr of kernel page tables */
|
||||
|
||||
.globl proc0paddr
|
||||
proc0paddr: .long 0 /* address of proc 0 address space */
|
||||
p0upa: .long 0 /* phys addr of proc0's UPAGES */
|
||||
.globl proc0uarea, proc0kstack
|
||||
proc0uarea: .long 0 /* address of proc 0 uarea space */
|
||||
proc0kstack: .long 0 /* address of proc 0 kstack space */
|
||||
p0upa: .long 0 /* phys addr of proc0's UAREA */
|
||||
p0kpa: .long 0 /* phys addr of proc0's STACK */
|
||||
|
||||
vm86phystk: .long 0 /* PA of vm86/bios stack */
|
||||
|
||||
@ -369,13 +371,14 @@ NON_GPROF_ENTRY(btext)
|
||||
/* now running relocated at KERNBASE where the system is linked to run */
|
||||
begin:
|
||||
/* set up bootstrap stack */
|
||||
movl proc0paddr,%eax /* location of in-kernel pages */
|
||||
leal UPAGES*PAGE_SIZE(%eax),%esp /* bootstrap stack end location */
|
||||
movl proc0kstack,%eax /* location of in-kernel stack */
|
||||
/* bootstrap stack end location */
|
||||
leal (KSTACK_PAGES*PAGE_SIZE-PCB_SIZE)(%eax),%esp
|
||||
|
||||
xorl %ebp,%ebp /* mark end of frames */
|
||||
|
||||
movl IdlePTD,%esi
|
||||
movl %esi,PCB_CR3(%eax)
|
||||
movl %esi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%eax)
|
||||
|
||||
testl $CPUID_PGE, R(cpu_feature)
|
||||
jz 1f
|
||||
@ -762,10 +765,15 @@ no_kernend:
|
||||
movl %esi,R(IdlePTD)
|
||||
|
||||
/* Allocate UPAGES */
|
||||
ALLOCPAGES(UPAGES)
|
||||
ALLOCPAGES(UAREA_PAGES)
|
||||
movl %esi,R(p0upa)
|
||||
addl $KERNBASE, %esi
|
||||
movl %esi, R(proc0paddr)
|
||||
movl %esi, R(proc0uarea)
|
||||
|
||||
ALLOCPAGES(KSTACK_PAGES)
|
||||
movl %esi,R(p0kpa)
|
||||
addl $KERNBASE, %esi
|
||||
movl %esi, R(proc0kstack)
|
||||
|
||||
ALLOCPAGES(1) /* vm86/bios stack */
|
||||
movl %esi,R(vm86phystk)
|
||||
@ -833,7 +841,12 @@ map_read_write:
|
||||
|
||||
/* Map proc0's UPAGES in the physical way ... */
|
||||
movl R(p0upa), %eax
|
||||
movl $UPAGES, %ecx
|
||||
movl $(UAREA_PAGES), %ecx
|
||||
fillkptphys($PG_RW)
|
||||
|
||||
/* Map proc0's KSTACK in the physical way ... */
|
||||
movl R(p0kpa), %eax
|
||||
movl $(KSTACK_PAGES), %ecx
|
||||
fillkptphys($PG_RW)
|
||||
|
||||
/* Map ISA hole */
|
||||
|
@ -147,9 +147,11 @@ IdlePTD: .long 0 /* phys addr of kernel PTD */
|
||||
#endif
|
||||
KPTphys: .long 0 /* phys addr of kernel page tables */
|
||||
|
||||
.globl proc0paddr
|
||||
proc0paddr: .long 0 /* address of proc 0 address space */
|
||||
p0upa: .long 0 /* phys addr of proc0's UPAGES */
|
||||
.globl proc0uarea, proc0kstack
|
||||
proc0uarea: .long 0 /* address of proc 0 uarea space */
|
||||
proc0kstack: .long 0 /* address of proc 0 kstack space */
|
||||
p0upa: .long 0 /* phys addr of proc0's UAREA */
|
||||
p0kpa: .long 0 /* phys addr of proc0's STACK */
|
||||
|
||||
vm86phystk: .long 0 /* PA of vm86/bios stack */
|
||||
|
||||
@ -369,13 +371,14 @@ NON_GPROF_ENTRY(btext)
|
||||
/* now running relocated at KERNBASE where the system is linked to run */
|
||||
begin:
|
||||
/* set up bootstrap stack */
|
||||
movl proc0paddr,%eax /* location of in-kernel pages */
|
||||
leal UPAGES*PAGE_SIZE(%eax),%esp /* bootstrap stack end location */
|
||||
movl proc0kstack,%eax /* location of in-kernel stack */
|
||||
/* bootstrap stack end location */
|
||||
leal (KSTACK_PAGES*PAGE_SIZE-PCB_SIZE)(%eax),%esp
|
||||
|
||||
xorl %ebp,%ebp /* mark end of frames */
|
||||
|
||||
movl IdlePTD,%esi
|
||||
movl %esi,PCB_CR3(%eax)
|
||||
movl %esi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%eax)
|
||||
|
||||
testl $CPUID_PGE, R(cpu_feature)
|
||||
jz 1f
|
||||
@ -762,10 +765,15 @@ no_kernend:
|
||||
movl %esi,R(IdlePTD)
|
||||
|
||||
/* Allocate UPAGES */
|
||||
ALLOCPAGES(UPAGES)
|
||||
ALLOCPAGES(UAREA_PAGES)
|
||||
movl %esi,R(p0upa)
|
||||
addl $KERNBASE, %esi
|
||||
movl %esi, R(proc0paddr)
|
||||
movl %esi, R(proc0uarea)
|
||||
|
||||
ALLOCPAGES(KSTACK_PAGES)
|
||||
movl %esi,R(p0kpa)
|
||||
addl $KERNBASE, %esi
|
||||
movl %esi, R(proc0kstack)
|
||||
|
||||
ALLOCPAGES(1) /* vm86/bios stack */
|
||||
movl %esi,R(vm86phystk)
|
||||
@ -833,7 +841,12 @@ map_read_write:
|
||||
|
||||
/* Map proc0's UPAGES in the physical way ... */
|
||||
movl R(p0upa), %eax
|
||||
movl $UPAGES, %ecx
|
||||
movl $(UAREA_PAGES), %ecx
|
||||
fillkptphys($PG_RW)
|
||||
|
||||
/* Map proc0's KSTACK in the physical way ... */
|
||||
movl R(p0kpa), %eax
|
||||
movl $(KSTACK_PAGES), %ecx
|
||||
fillkptphys($PG_RW)
|
||||
|
||||
/* Map ISA hole */
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "opt_msgbuf.h"
|
||||
#include "opt_npx.h"
|
||||
#include "opt_perfmon.h"
|
||||
#include "opt_upages.h"
|
||||
#include "opt_kstack_pages.h"
|
||||
/* #include "opt_userconfig.h" */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -289,14 +289,16 @@ osendsig(catcher, sig, mask, code)
|
||||
struct osigframe sf;
|
||||
struct osigframe *fp;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
struct sigacts *psp;
|
||||
struct trapframe *regs;
|
||||
int oonstack;
|
||||
|
||||
p = curproc;
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
PROC_LOCK_ASSERT(p, MA_OWNED);
|
||||
psp = p->p_sigacts;
|
||||
regs = p->p_frame;
|
||||
regs = td->td_frame;
|
||||
oonstack = sigonstack(regs->tf_esp);
|
||||
|
||||
/* Allocate and validate space for the signal handler context. */
|
||||
@ -386,7 +388,7 @@ osendsig(catcher, sig, mask, code)
|
||||
if (regs->tf_eflags & PSL_VM) {
|
||||
/* XXX confusing names: `tf' isn't a trapframe; `regs' is. */
|
||||
struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
|
||||
struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
|
||||
struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86;
|
||||
|
||||
sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs;
|
||||
sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs;
|
||||
@ -409,7 +411,7 @@ osendsig(catcher, sig, mask, code)
|
||||
* ...Kill the process.
|
||||
*/
|
||||
PROC_LOCK(p);
|
||||
sigexit(p, SIGILL);
|
||||
sigexit(td, SIGILL);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
@ -434,12 +436,14 @@ sendsig(catcher, sig, mask, code)
|
||||
{
|
||||
struct sigframe sf;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
struct sigacts *psp;
|
||||
struct trapframe *regs;
|
||||
struct sigframe *sfp;
|
||||
int oonstack;
|
||||
|
||||
p = curproc;
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
PROC_LOCK_ASSERT(p, MA_OWNED);
|
||||
psp = p->p_sigacts;
|
||||
#ifdef COMPAT_43
|
||||
@ -448,7 +452,7 @@ sendsig(catcher, sig, mask, code)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
regs = p->p_frame;
|
||||
regs = td->td_frame;
|
||||
oonstack = sigonstack(regs->tf_esp);
|
||||
|
||||
/* Save user context. */
|
||||
@ -528,7 +532,7 @@ sendsig(catcher, sig, mask, code)
|
||||
*/
|
||||
if (regs->tf_eflags & PSL_VM) {
|
||||
struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
|
||||
struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
|
||||
struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86;
|
||||
|
||||
sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs;
|
||||
sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs;
|
||||
@ -561,7 +565,7 @@ sendsig(catcher, sig, mask, code)
|
||||
* ...Kill the process.
|
||||
*/
|
||||
PROC_LOCK(p);
|
||||
sigexit(p, SIGILL);
|
||||
sigexit(td, SIGILL);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
@ -586,17 +590,18 @@ sendsig(catcher, sig, mask, code)
|
||||
*/
|
||||
#ifdef COMPAT_43
|
||||
int
|
||||
osigreturn(p, uap)
|
||||
struct proc *p;
|
||||
osigreturn(td, uap)
|
||||
struct thread *td;
|
||||
struct osigreturn_args /* {
|
||||
struct osigcontext *sigcntxp;
|
||||
} */ *uap;
|
||||
{
|
||||
struct trapframe *regs;
|
||||
struct osigcontext *scp;
|
||||
struct proc *p = td->td_proc;
|
||||
int eflags;
|
||||
|
||||
regs = p->p_frame;
|
||||
regs = td->td_frame;
|
||||
scp = uap->sigcntxp;
|
||||
if (!useracc((caddr_t)scp, sizeof(*scp), VM_PROT_READ))
|
||||
return (EFAULT);
|
||||
@ -609,9 +614,9 @@ osigreturn(p, uap)
|
||||
* if pcb_ext == 0 or vm86_inited == 0, the user hasn't
|
||||
* set up the vm86 area, and we can't enter vm86 mode.
|
||||
*/
|
||||
if (p->p_addr->u_pcb.pcb_ext == 0)
|
||||
if (td->td_pcb->pcb_ext == 0)
|
||||
return (EINVAL);
|
||||
vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
|
||||
vm86 = &td->td_pcb->pcb_ext->ext_vm86;
|
||||
if (vm86->vm86_inited == 0)
|
||||
return (EINVAL);
|
||||
|
||||
@ -697,12 +702,13 @@ osigreturn(p, uap)
|
||||
#endif
|
||||
|
||||
int
|
||||
sigreturn(p, uap)
|
||||
struct proc *p;
|
||||
sigreturn(td, uap)
|
||||
struct thread *td;
|
||||
struct sigreturn_args /* {
|
||||
ucontext_t *sigcntxp;
|
||||
} */ *uap;
|
||||
{
|
||||
struct proc *p = td->td_proc;
|
||||
struct trapframe *regs;
|
||||
ucontext_t *ucp;
|
||||
int cs, eflags;
|
||||
@ -712,7 +718,7 @@ sigreturn(p, uap)
|
||||
if (!useracc((caddr_t)ucp, sizeof(struct osigcontext), VM_PROT_READ))
|
||||
return (EFAULT);
|
||||
if (((struct osigcontext *)ucp)->sc_trapno == 0x01d516)
|
||||
return (osigreturn(p, (struct osigreturn_args *)uap));
|
||||
return (osigreturn(td, (struct osigreturn_args *)uap));
|
||||
/*
|
||||
* Since ucp is not an osigcontext but a ucontext_t, we have to
|
||||
* check again if all of it is accessible. A ucontext_t is
|
||||
@ -724,7 +730,7 @@ sigreturn(p, uap)
|
||||
if (!useracc((caddr_t)ucp, sizeof(*ucp), VM_PROT_READ))
|
||||
return (EFAULT);
|
||||
|
||||
regs = p->p_frame;
|
||||
regs = td->td_frame;
|
||||
eflags = ucp->uc_mcontext.mc_eflags;
|
||||
if (eflags & PSL_VM) {
|
||||
struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
|
||||
@ -734,9 +740,9 @@ sigreturn(p, uap)
|
||||
* if pcb_ext == 0 or vm86_inited == 0, the user hasn't
|
||||
* set up the vm86 area, and we can't enter vm86 mode.
|
||||
*/
|
||||
if (p->p_addr->u_pcb.pcb_ext == 0)
|
||||
if (td->td_pcb->pcb_ext == 0)
|
||||
return (EINVAL);
|
||||
vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
|
||||
vm86 = &td->td_pcb->pcb_ext->ext_vm86;
|
||||
if (vm86->vm86_inited == 0)
|
||||
return (EINVAL);
|
||||
|
||||
@ -865,14 +871,14 @@ cpu_idle(void)
|
||||
* Clear registers on exec
|
||||
*/
|
||||
void
|
||||
setregs(p, entry, stack, ps_strings)
|
||||
struct proc *p;
|
||||
setregs(td, entry, stack, ps_strings)
|
||||
struct thread *td;
|
||||
u_long entry;
|
||||
u_long stack;
|
||||
u_long ps_strings;
|
||||
{
|
||||
struct trapframe *regs = p->p_frame;
|
||||
struct pcb *pcb = &p->p_addr->u_pcb;
|
||||
struct trapframe *regs = td->td_frame;
|
||||
struct pcb *pcb = td->td_pcb;
|
||||
|
||||
if (pcb->pcb_ldt)
|
||||
user_ldt_free(pcb);
|
||||
@ -925,7 +931,7 @@ setregs(p, entry, stack, ps_strings)
|
||||
* traps to the emulator (if it is done at all) mainly because
|
||||
* emulators don't provide an entry point for initialization.
|
||||
*/
|
||||
p->p_addr->u_pcb.pcb_flags &= ~FP_SOFTFP;
|
||||
td->td_pcb->pcb_flags &= ~FP_SOFTFP;
|
||||
|
||||
/*
|
||||
* Arrange to trap the next npx or `fwait' instruction (see npx.c
|
||||
@ -948,7 +954,7 @@ setregs(p, entry, stack, ps_strings)
|
||||
* Make sure sure edx is 0x0 on entry. Linux binaries depend
|
||||
* on it.
|
||||
*/
|
||||
p->p_retval[1] = 0;
|
||||
td->td_retval[1] = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@ -1016,7 +1022,8 @@ extern int has_f00f_bug;
|
||||
static struct i386tss dblfault_tss;
|
||||
static char dblfault_stack[PAGE_SIZE];
|
||||
|
||||
extern struct user *proc0paddr;
|
||||
extern struct user *proc0uarea;
|
||||
extern vm_offset_t proc0kstack;
|
||||
|
||||
|
||||
/* software prototypes -- in more palatable form */
|
||||
@ -1661,8 +1668,12 @@ init386(first)
|
||||
struct region_descriptor r_gdt, r_idt;
|
||||
#endif
|
||||
|
||||
proc0.p_addr = proc0paddr;
|
||||
|
||||
proc_linkup(&proc0);
|
||||
proc0.p_uarea = proc0uarea;
|
||||
thread0 = &proc0.p_thread;
|
||||
thread0->td_kstack = proc0kstack;
|
||||
thread0->td_pcb = (struct pcb *)
|
||||
(thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
|
||||
atdevbase = ISA_HOLE_START + KERNBASE;
|
||||
|
||||
metadata_missing = 0;
|
||||
@ -1721,10 +1732,11 @@ init386(first)
|
||||
lgdt(&r_gdt);
|
||||
|
||||
/* setup curproc so that mutexes work */
|
||||
PCPU_SET(curproc, &proc0);
|
||||
|
||||
PCPU_SET(curthread, thread0);
|
||||
PCPU_SET(spinlocks, NULL);
|
||||
|
||||
LIST_INIT(&proc0.p_contested);
|
||||
LIST_INIT(&thread0->td_contested);
|
||||
|
||||
/*
|
||||
* Initialize mutexes.
|
||||
@ -1828,8 +1840,9 @@ init386(first)
|
||||
initializecpu(); /* Initialize CPU registers */
|
||||
|
||||
/* make an initial tss so cpu can get interrupt stack on syscall! */
|
||||
PCPU_SET(common_tss.tss_esp0,
|
||||
(int) proc0.p_addr + UPAGES*PAGE_SIZE - 16);
|
||||
/* Note: -16 is so we can grow the trapframe if we came from vm86 */
|
||||
PCPU_SET(common_tss.tss_esp0, thread0->td_kstack +
|
||||
KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb) - 16);
|
||||
PCPU_SET(common_tss.tss_ss0, GSEL(GDATA_SEL, SEL_KPL));
|
||||
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
|
||||
private_tss = 0;
|
||||
@ -1884,10 +1897,10 @@ init386(first)
|
||||
_udatasel = LSEL(LUDATA_SEL, SEL_UPL);
|
||||
|
||||
/* setup proc 0's pcb */
|
||||
proc0.p_addr->u_pcb.pcb_flags = 0;
|
||||
proc0.p_addr->u_pcb.pcb_cr3 = (int)IdlePTD;
|
||||
proc0.p_addr->u_pcb.pcb_ext = 0;
|
||||
proc0.p_frame = &proc0_tf;
|
||||
thread0->td_pcb->pcb_flags = 0; /* XXXKSE */
|
||||
thread0->td_pcb->pcb_cr3 = (int)IdlePTD;
|
||||
thread0->td_pcb->pcb_ext = 0;
|
||||
thread0->td_frame = &proc0_tf;
|
||||
}
|
||||
|
||||
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
|
||||
@ -1930,31 +1943,26 @@ f00f_hack(void *unused) {
|
||||
#endif /* defined(I586_CPU) && !NO_F00F_HACK */
|
||||
|
||||
int
|
||||
ptrace_set_pc(p, addr)
|
||||
struct proc *p;
|
||||
unsigned long addr;
|
||||
ptrace_set_pc(struct thread *td, unsigned long addr)
|
||||
{
|
||||
p->p_frame->tf_eip = addr;
|
||||
td->td_frame->tf_eip = addr;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_single_step(p)
|
||||
struct proc *p;
|
||||
ptrace_single_step(struct thread *td)
|
||||
{
|
||||
p->p_frame->tf_eflags |= PSL_T;
|
||||
td->td_frame->tf_eflags |= PSL_T;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
fill_regs(p, regs)
|
||||
struct proc *p;
|
||||
struct reg *regs;
|
||||
fill_regs(struct thread *td, struct reg *regs)
|
||||
{
|
||||
struct pcb *pcb;
|
||||
struct trapframe *tp;
|
||||
|
||||
tp = p->p_frame;
|
||||
tp = td->td_frame;
|
||||
regs->r_fs = tp->tf_fs;
|
||||
regs->r_es = tp->tf_es;
|
||||
regs->r_ds = tp->tf_ds;
|
||||
@ -1970,20 +1978,18 @@ fill_regs(p, regs)
|
||||
regs->r_eflags = tp->tf_eflags;
|
||||
regs->r_esp = tp->tf_esp;
|
||||
regs->r_ss = tp->tf_ss;
|
||||
pcb = &p->p_addr->u_pcb;
|
||||
pcb = td->td_pcb;
|
||||
regs->r_gs = pcb->pcb_gs;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
set_regs(p, regs)
|
||||
struct proc *p;
|
||||
struct reg *regs;
|
||||
set_regs(struct thread *td, struct reg *regs)
|
||||
{
|
||||
struct pcb *pcb;
|
||||
struct trapframe *tp;
|
||||
|
||||
tp = p->p_frame;
|
||||
tp = td->td_frame;
|
||||
if (!EFL_SECURE(regs->r_eflags, tp->tf_eflags) ||
|
||||
!CS_SECURE(regs->r_cs))
|
||||
return (EINVAL);
|
||||
@ -2002,7 +2008,7 @@ set_regs(p, regs)
|
||||
tp->tf_eflags = regs->r_eflags;
|
||||
tp->tf_esp = regs->r_esp;
|
||||
tp->tf_ss = regs->r_ss;
|
||||
pcb = &p->p_addr->u_pcb;
|
||||
pcb = td->td_pcb;
|
||||
pcb->pcb_gs = regs->r_gs;
|
||||
return (0);
|
||||
}
|
||||
@ -2062,45 +2068,39 @@ set_fpregs_xmm(sv_87, sv_xmm)
|
||||
#endif /* CPU_ENABLE_SSE */
|
||||
|
||||
int
|
||||
fill_fpregs(p, fpregs)
|
||||
struct proc *p;
|
||||
struct fpreg *fpregs;
|
||||
fill_fpregs(struct thread *td, struct fpreg *fpregs)
|
||||
{
|
||||
#ifdef CPU_ENABLE_SSE
|
||||
if (cpu_fxsr) {
|
||||
fill_fpregs_xmm(&p->p_addr->u_pcb.pcb_save.sv_xmm,
|
||||
fill_fpregs_xmm(&td->td_pcb->pcb_save.sv_xmm,
|
||||
(struct save87 *)fpregs);
|
||||
return (0);
|
||||
}
|
||||
#endif /* CPU_ENABLE_SSE */
|
||||
bcopy(&p->p_addr->u_pcb.pcb_save.sv_87, fpregs, sizeof *fpregs);
|
||||
bcopy(&td->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
set_fpregs(p, fpregs)
|
||||
struct proc *p;
|
||||
struct fpreg *fpregs;
|
||||
set_fpregs(struct thread *td, struct fpreg *fpregs)
|
||||
{
|
||||
#ifdef CPU_ENABLE_SSE
|
||||
if (cpu_fxsr) {
|
||||
set_fpregs_xmm((struct save87 *)fpregs,
|
||||
&p->p_addr->u_pcb.pcb_save.sv_xmm);
|
||||
&td->td_pcb->pcb_save.sv_xmm);
|
||||
return (0);
|
||||
}
|
||||
#endif /* CPU_ENABLE_SSE */
|
||||
bcopy(fpregs, &p->p_addr->u_pcb.pcb_save.sv_87, sizeof *fpregs);
|
||||
bcopy(fpregs, &td->td_pcb->pcb_save.sv_87, sizeof *fpregs);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
fill_dbregs(p, dbregs)
|
||||
struct proc *p;
|
||||
struct dbreg *dbregs;
|
||||
fill_dbregs(struct thread *td, struct dbreg *dbregs)
|
||||
{
|
||||
struct pcb *pcb;
|
||||
|
||||
if (p == NULL) {
|
||||
if (td == NULL) {
|
||||
dbregs->dr0 = rdr0();
|
||||
dbregs->dr1 = rdr1();
|
||||
dbregs->dr2 = rdr2();
|
||||
@ -2109,9 +2109,8 @@ fill_dbregs(p, dbregs)
|
||||
dbregs->dr5 = rdr5();
|
||||
dbregs->dr6 = rdr6();
|
||||
dbregs->dr7 = rdr7();
|
||||
}
|
||||
else {
|
||||
pcb = &p->p_addr->u_pcb;
|
||||
} else {
|
||||
pcb = td->td_pcb;
|
||||
dbregs->dr0 = pcb->pcb_dr0;
|
||||
dbregs->dr1 = pcb->pcb_dr1;
|
||||
dbregs->dr2 = pcb->pcb_dr2;
|
||||
@ -2125,15 +2124,13 @@ fill_dbregs(p, dbregs)
|
||||
}
|
||||
|
||||
int
|
||||
set_dbregs(p, dbregs)
|
||||
struct proc *p;
|
||||
struct dbreg *dbregs;
|
||||
set_dbregs(struct thread *td, struct dbreg *dbregs)
|
||||
{
|
||||
struct pcb *pcb;
|
||||
int i;
|
||||
u_int32_t mask1, mask2;
|
||||
|
||||
if (p == NULL) {
|
||||
if (td == NULL) {
|
||||
load_dr0(dbregs->dr0);
|
||||
load_dr1(dbregs->dr1);
|
||||
load_dr2(dbregs->dr2);
|
||||
@ -2142,8 +2139,7 @@ set_dbregs(p, dbregs)
|
||||
load_dr5(dbregs->dr5);
|
||||
load_dr6(dbregs->dr6);
|
||||
load_dr7(dbregs->dr7);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/*
|
||||
* Don't let an illegal value for dr7 get set. Specifically,
|
||||
* check for undefined settings. Setting these bit patterns
|
||||
@ -2155,7 +2151,7 @@ set_dbregs(p, dbregs)
|
||||
if ((dbregs->dr7 & mask1) == mask2)
|
||||
return (EINVAL);
|
||||
|
||||
pcb = &p->p_addr->u_pcb;
|
||||
pcb = td->td_pcb;
|
||||
|
||||
/*
|
||||
* Don't let a process set a breakpoint that is not within the
|
||||
@ -2172,7 +2168,7 @@ set_dbregs(p, dbregs)
|
||||
* from within kernel mode?
|
||||
*/
|
||||
|
||||
if (suser(p) != 0) {
|
||||
if (suser_td(td) != 0) {
|
||||
if (dbregs->dr7 & 0x3) {
|
||||
/* dr0 is enabled */
|
||||
if (dbregs->dr0 >= VM_MAXUSER_ADDRESS)
|
||||
|
@ -98,17 +98,17 @@ MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
|
||||
struct mem_range_softc mem_range_softc;
|
||||
|
||||
static int
|
||||
mmclose(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
mmclose(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
switch (minor(dev)) {
|
||||
case 14:
|
||||
p->p_frame->tf_eflags &= ~PSL_IOPL;
|
||||
td->td_frame->tf_eflags &= ~PSL_IOPL;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
mmopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
mmopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
int error;
|
||||
|
||||
@ -119,12 +119,12 @@ mmopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
return (EPERM);
|
||||
break;
|
||||
case 14:
|
||||
error = suser(p);
|
||||
error = suser_td(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
if (securelevel > 0)
|
||||
return (EPERM);
|
||||
p->p_frame->tf_eflags |= PSL_IOPL;
|
||||
td->td_frame->tf_eflags |= PSL_IOPL;
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
@ -235,7 +235,7 @@ memmmap(dev_t dev, vm_offset_t offset, int prot)
|
||||
* and mem_range_attr_set.
|
||||
*/
|
||||
static int
|
||||
mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
|
||||
mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td)
|
||||
{
|
||||
int nd, error = 0;
|
||||
struct mem_range_op *mo = (struct mem_range_op *)data;
|
||||
|
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "opt_cpu.h"
|
||||
#include "opt_upages.h"
|
||||
#include "opt_kstack_pages.h"
|
||||
|
||||
#ifdef SMP
|
||||
#include <machine/smptests.h>
|
||||
@ -1960,8 +1960,8 @@ start_all_aps(u_int boot_addr)
|
||||
SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
|
||||
|
||||
/* allocate and set up an idle stack data page */
|
||||
stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
|
||||
for (i = 0; i < UPAGES; i++)
|
||||
stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */
|
||||
for (i = 0; i < KSTACK_PAGES; i++)
|
||||
SMPpt[pg + 1 + i] = (pt_entry_t)
|
||||
(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
|
||||
|
||||
@ -1977,7 +1977,7 @@ start_all_aps(u_int boot_addr)
|
||||
outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
|
||||
#endif
|
||||
|
||||
bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
|
||||
bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE];
|
||||
bootAP = x;
|
||||
|
||||
/* attempt to start the Application Processor */
|
||||
@ -2019,8 +2019,8 @@ start_all_aps(u_int boot_addr)
|
||||
*/
|
||||
|
||||
/* Allocate and setup BSP idle stack */
|
||||
stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
|
||||
for (i = 0; i < UPAGES; i++)
|
||||
stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE);
|
||||
for (i = 0; i < KSTACK_PAGES; i++)
|
||||
SMPpt[1 + i] = (pt_entry_t)
|
||||
(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
|
||||
|
||||
@ -2241,7 +2241,7 @@ ap_init(void)
|
||||
* Set curproc to our per-cpu idleproc so that mutexes have
|
||||
* something unique to lock with.
|
||||
*/
|
||||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
PCPU_SET(curthread, PCPU_GET(idlethread));
|
||||
PCPU_SET(spinlocks, NULL);
|
||||
|
||||
/* lock against other AP's that are waking up */
|
||||
@ -2323,7 +2323,7 @@ forwarded_statclock(struct trapframe frame)
|
||||
{
|
||||
|
||||
mtx_lock_spin(&sched_lock);
|
||||
statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame));
|
||||
statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame));
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
@ -2354,7 +2354,7 @@ forwarded_hardclock(struct trapframe frame)
|
||||
{
|
||||
|
||||
mtx_lock_spin(&sched_lock);
|
||||
hardclock_process(curproc, TRAPF_USERMODE(&frame));
|
||||
hardclock_process(curthread, TRAPF_USERMODE(&frame));
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "opt_cpu.h"
|
||||
#include "opt_upages.h"
|
||||
#include "opt_kstack_pages.h"
|
||||
|
||||
#ifdef SMP
|
||||
#include <machine/smptests.h>
|
||||
@ -1960,8 +1960,8 @@ start_all_aps(u_int boot_addr)
|
||||
SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
|
||||
|
||||
/* allocate and set up an idle stack data page */
|
||||
stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
|
||||
for (i = 0; i < UPAGES; i++)
|
||||
stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */
|
||||
for (i = 0; i < KSTACK_PAGES; i++)
|
||||
SMPpt[pg + 1 + i] = (pt_entry_t)
|
||||
(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
|
||||
|
||||
@ -1977,7 +1977,7 @@ start_all_aps(u_int boot_addr)
|
||||
outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
|
||||
#endif
|
||||
|
||||
bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
|
||||
bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE];
|
||||
bootAP = x;
|
||||
|
||||
/* attempt to start the Application Processor */
|
||||
@ -2019,8 +2019,8 @@ start_all_aps(u_int boot_addr)
|
||||
*/
|
||||
|
||||
/* Allocate and setup BSP idle stack */
|
||||
stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
|
||||
for (i = 0; i < UPAGES; i++)
|
||||
stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE);
|
||||
for (i = 0; i < KSTACK_PAGES; i++)
|
||||
SMPpt[1 + i] = (pt_entry_t)
|
||||
(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
|
||||
|
||||
@ -2241,7 +2241,7 @@ ap_init(void)
|
||||
* Set curproc to our per-cpu idleproc so that mutexes have
|
||||
* something unique to lock with.
|
||||
*/
|
||||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
PCPU_SET(curthread, PCPU_GET(idlethread));
|
||||
PCPU_SET(spinlocks, NULL);
|
||||
|
||||
/* lock against other AP's that are waking up */
|
||||
@ -2323,7 +2323,7 @@ forwarded_statclock(struct trapframe frame)
|
||||
{
|
||||
|
||||
mtx_lock_spin(&sched_lock);
|
||||
statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame));
|
||||
statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame));
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
@ -2354,7 +2354,7 @@ forwarded_hardclock(struct trapframe frame)
|
||||
{
|
||||
|
||||
mtx_lock_spin(&sched_lock);
|
||||
hardclock_process(curproc, TRAPF_USERMODE(&frame));
|
||||
hardclock_process(curthread, TRAPF_USERMODE(&frame));
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@
|
||||
#include "opt_disable_pse.h"
|
||||
#include "opt_pmap.h"
|
||||
#include "opt_msgbuf.h"
|
||||
#include "opt_upages.h"
|
||||
#include "opt_kstack_pages.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -171,7 +171,7 @@ vm_offset_t kernel_vm_end;
|
||||
static vm_zone_t pvzone;
|
||||
static struct vm_zone pvzone_store;
|
||||
static struct vm_object pvzone_obj;
|
||||
static int pv_entry_count=0, pv_entry_max=0, pv_entry_high_water=0;
|
||||
static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0;
|
||||
static int pmap_pagedaemon_waken = 0;
|
||||
static struct pv_entry *pvinit;
|
||||
|
||||
@ -183,7 +183,7 @@ static pt_entry_t *CMAP2, *ptmmap;
|
||||
caddr_t CADDR1 = 0, ptvmmap = 0;
|
||||
static caddr_t CADDR2;
|
||||
static pt_entry_t *msgbufmap;
|
||||
struct msgbuf *msgbufp=0;
|
||||
struct msgbuf *msgbufp = 0;
|
||||
|
||||
/*
|
||||
* Crashdump maps.
|
||||
@ -819,7 +819,7 @@ pmap_page_lookup(object, pindex)
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the UPAGES for a new process.
|
||||
* Create the Uarea stack for a new process.
|
||||
* This routine directly affects the fork perf for a process.
|
||||
*/
|
||||
void
|
||||
@ -840,22 +840,22 @@ pmap_new_proc(p)
|
||||
*/
|
||||
upobj = p->p_upages_obj;
|
||||
if (upobj == NULL) {
|
||||
upobj = vm_object_allocate(OBJT_DEFAULT, UPAGES);
|
||||
upobj = vm_object_allocate(OBJT_DEFAULT, UAREA_PAGES);
|
||||
p->p_upages_obj = upobj;
|
||||
}
|
||||
|
||||
/* get a kernel virtual address for the UPAGES for this proc */
|
||||
up = (vm_offset_t)p->p_addr;
|
||||
/* get a kernel virtual address for the U area for this proc */
|
||||
up = (vm_offset_t)p->p_uarea;
|
||||
if (up == 0) {
|
||||
up = kmem_alloc_nofault(kernel_map, UPAGES * PAGE_SIZE);
|
||||
up = kmem_alloc_nofault(kernel_map, UAREA_PAGES * PAGE_SIZE);
|
||||
if (up == 0)
|
||||
panic("pmap_new_proc: upage allocation failed");
|
||||
p->p_addr = (struct user *)up;
|
||||
p->p_uarea = (struct user *)up;
|
||||
}
|
||||
|
||||
ptek = (unsigned *)vtopte(up);
|
||||
|
||||
for (i = 0; i < UPAGES; i++) {
|
||||
for (i = 0; i < UAREA_PAGES; i++) {
|
||||
/*
|
||||
* Get a kernel stack page
|
||||
*/
|
||||
@ -892,7 +892,7 @@ pmap_new_proc(p)
|
||||
}
|
||||
|
||||
/*
|
||||
* Dispose the UPAGES for a process that has exited.
|
||||
* Dispose the U-Area for a process that has exited.
|
||||
* This routine directly impacts the exit perf of a process.
|
||||
*/
|
||||
void
|
||||
@ -906,9 +906,9 @@ pmap_dispose_proc(p)
|
||||
unsigned *ptek, oldpte;
|
||||
|
||||
upobj = p->p_upages_obj;
|
||||
up = (vm_offset_t)p->p_addr;
|
||||
up = (vm_offset_t)p->p_uarea;
|
||||
ptek = (unsigned *)vtopte(up);
|
||||
for (i = 0; i < UPAGES; i++) {
|
||||
for (i = 0; i < UAREA_PAGES; i++) {
|
||||
m = vm_page_lookup(upobj, i);
|
||||
if (m == NULL)
|
||||
panic("pmap_dispose_proc: upage already missing?");
|
||||
@ -927,7 +927,7 @@ pmap_dispose_proc(p)
|
||||
}
|
||||
|
||||
/*
|
||||
* Allow the UPAGES for a process to be prejudicially paged out.
|
||||
* Allow the U_AREA for a process to be prejudicially paged out.
|
||||
*/
|
||||
void
|
||||
pmap_swapout_proc(p)
|
||||
@ -939,8 +939,8 @@ pmap_swapout_proc(p)
|
||||
vm_page_t m;
|
||||
|
||||
upobj = p->p_upages_obj;
|
||||
up = (vm_offset_t)p->p_addr;
|
||||
for (i = 0; i < UPAGES; i++) {
|
||||
up = (vm_offset_t)p->p_uarea;
|
||||
for (i = 0; i < UAREA_PAGES; i++) {
|
||||
m = vm_page_lookup(upobj, i);
|
||||
if (m == NULL)
|
||||
panic("pmap_swapout_proc: upage already missing?");
|
||||
@ -951,7 +951,7 @@ pmap_swapout_proc(p)
|
||||
}
|
||||
|
||||
/*
|
||||
* Bring the UPAGES for a specified process back in.
|
||||
* Bring the U-Area for a specified process back in.
|
||||
*/
|
||||
void
|
||||
pmap_swapin_proc(p)
|
||||
@ -963,8 +963,8 @@ pmap_swapin_proc(p)
|
||||
vm_page_t m;
|
||||
|
||||
upobj = p->p_upages_obj;
|
||||
up = (vm_offset_t)p->p_addr;
|
||||
for (i = 0; i < UPAGES; i++) {
|
||||
up = (vm_offset_t)p->p_uarea;
|
||||
for (i = 0; i < UAREA_PAGES; i++) {
|
||||
m = vm_page_grab(upobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
|
||||
pmap_kenter(up + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m));
|
||||
if (m->valid != VM_PAGE_BITS_ALL) {
|
||||
@ -980,6 +980,191 @@ pmap_swapin_proc(p)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the kernel stack (including pcb for i386) for a new thread.
|
||||
* This routine directly affects the fork perf for a process and
|
||||
* create performance for a thread.
|
||||
*/
|
||||
void
|
||||
pmap_new_thread(td)
|
||||
struct thread *td;
|
||||
{
|
||||
#ifdef I386_CPU
|
||||
int updateneeded = 0;
|
||||
#endif
|
||||
int i;
|
||||
vm_object_t ksobj;
|
||||
vm_page_t m;
|
||||
vm_offset_t ks;
|
||||
unsigned *ptek, oldpte;
|
||||
|
||||
/*
|
||||
* allocate object for the kstack
|
||||
*/
|
||||
ksobj = td->td_kstack_obj;
|
||||
if (ksobj == NULL) {
|
||||
ksobj = vm_object_allocate(OBJT_DEFAULT, KSTACK_PAGES);
|
||||
td->td_kstack_obj = ksobj;
|
||||
}
|
||||
|
||||
#ifdef KSTACK_GUARD
|
||||
/* get a kernel virtual address for the kstack for this proc */
|
||||
ks = (vm_offset_t)td->td_kstack;
|
||||
if (ks == 0) {
|
||||
ks = kmem_alloc_nofault(kernel_map,
|
||||
(KSTACK_PAGES + 1) * PAGE_SIZE);
|
||||
if (ks == 0)
|
||||
panic("pmap_new_thread: kstack allocation failed");
|
||||
ks += PAGE_SIZE;
|
||||
td->td_kstack = ks;
|
||||
}
|
||||
|
||||
ptek = (unsigned *)vtopte(ks - PAGE_SIZE);
|
||||
oldpte = *ptek;
|
||||
*ptek = 0;
|
||||
if (oldpte) {
|
||||
#ifdef I386_CPU
|
||||
updateneeded = 1;
|
||||
#else
|
||||
invlpg(ks - PAGE_SIZE);
|
||||
#endif
|
||||
}
|
||||
ptek++;
|
||||
#else
|
||||
/* get a kernel virtual address for the kstack for this proc */
|
||||
ks = (vm_offset_t)td->td_kstack;
|
||||
if (ks == 0) {
|
||||
ks = kmem_alloc_nofault(kernel_map, KSTACK_PAGES * PAGE_SIZE);
|
||||
if (ks == 0)
|
||||
panic("pmap_new_thread: kstack allocation failed");
|
||||
td->td_kstack = ks;
|
||||
}
|
||||
#endif
|
||||
for (i = 0; i < KSTACK_PAGES; i++) {
|
||||
/*
|
||||
* Get a kernel stack page
|
||||
*/
|
||||
m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
|
||||
|
||||
/*
|
||||
* Wire the page
|
||||
*/
|
||||
m->wire_count++;
|
||||
cnt.v_wire_count++;
|
||||
|
||||
oldpte = *(ptek + i);
|
||||
/*
|
||||
* Enter the page into the kernel address space.
|
||||
*/
|
||||
*(ptek + i) = VM_PAGE_TO_PHYS(m) | PG_RW | PG_V | pgeflag;
|
||||
if (oldpte) {
|
||||
#ifdef I386_CPU
|
||||
updateneeded = 1;
|
||||
#else
|
||||
invlpg(ks + i * PAGE_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
vm_page_wakeup(m);
|
||||
vm_page_flag_clear(m, PG_ZERO);
|
||||
vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE);
|
||||
m->valid = VM_PAGE_BITS_ALL;
|
||||
}
|
||||
#ifdef I386_CPU
|
||||
if (updateneeded)
|
||||
invltlb();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Dispose the kernel stack for a thread that has exited.
|
||||
* This routine directly impacts the exit perf of a process and thread.
|
||||
*/
|
||||
void
|
||||
pmap_dispose_thread(td)
|
||||
struct thread *td;
|
||||
{
|
||||
int i;
|
||||
vm_object_t ksobj;
|
||||
vm_offset_t ks;
|
||||
vm_page_t m;
|
||||
unsigned *ptek, oldpte;
|
||||
|
||||
ksobj = td->td_kstack_obj;
|
||||
ks = td->td_kstack;
|
||||
ptek = (unsigned *)vtopte(ks);
|
||||
for (i = 0; i < KSTACK_PAGES; i++) {
|
||||
m = vm_page_lookup(ksobj, i);
|
||||
if (m == NULL)
|
||||
panic("pmap_dispose_thread: kstack already missing?");
|
||||
vm_page_busy(m);
|
||||
oldpte = *(ptek + i);
|
||||
*(ptek + i) = 0;
|
||||
#ifndef I386_CPU
|
||||
invlpg(ks + i * PAGE_SIZE);
|
||||
#endif
|
||||
vm_page_unwire(m, 0);
|
||||
vm_page_free(m);
|
||||
}
|
||||
#ifdef I386_CPU
|
||||
invltlb();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Allow the Kernel stack for a thread to be prejudicially paged out.
|
||||
*/
|
||||
void
|
||||
pmap_swapout_thread(td)
|
||||
struct thread *td;
|
||||
{
|
||||
int i;
|
||||
vm_object_t ksobj;
|
||||
vm_offset_t ks;
|
||||
vm_page_t m;
|
||||
|
||||
ksobj = td->td_kstack_obj;
|
||||
ks = td->td_kstack;
|
||||
for (i = 0; i < KSTACK_PAGES; i++) {
|
||||
m = vm_page_lookup(ksobj, i);
|
||||
if (m == NULL)
|
||||
panic("pmap_swapout_thread: kstack already missing?");
|
||||
vm_page_dirty(m);
|
||||
vm_page_unwire(m, 0);
|
||||
pmap_kremove(ks + i * PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Bring the kernel stack for a specified thread back in.
|
||||
*/
|
||||
void
|
||||
pmap_swapin_thread(td)
|
||||
struct thread *td;
|
||||
{
|
||||
int i, rv;
|
||||
vm_object_t ksobj;
|
||||
vm_offset_t ks;
|
||||
vm_page_t m;
|
||||
|
||||
ksobj = td->td_kstack_obj;
|
||||
ks = td->td_kstack;
|
||||
for (i = 0; i < KSTACK_PAGES; i++) {
|
||||
m = vm_page_grab(ksobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
|
||||
pmap_kenter(ks + i * PAGE_SIZE, VM_PAGE_TO_PHYS(m));
|
||||
if (m->valid != VM_PAGE_BITS_ALL) {
|
||||
rv = vm_pager_get_pages(ksobj, &m, 1, 0);
|
||||
if (rv != VM_PAGER_OK)
|
||||
panic("pmap_swapin_thread: cannot get kstack for proc: %d\n", td->td_proc->p_pid);
|
||||
m = vm_page_lookup(ksobj, i);
|
||||
m->valid = VM_PAGE_BITS_ALL;
|
||||
}
|
||||
vm_page_wire(m);
|
||||
vm_page_wakeup(m);
|
||||
vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
* Page table page management routines.....
|
||||
***************************************************/
|
||||
@ -1517,7 +1702,7 @@ pmap_collect()
|
||||
{
|
||||
int i;
|
||||
vm_page_t m;
|
||||
static int warningdone=0;
|
||||
static int warningdone = 0;
|
||||
|
||||
if (pmap_pagedaemon_waken == 0)
|
||||
return;
|
||||
@ -2333,7 +2518,7 @@ pmap_object_init_pt(pmap, addr, object, pindex, size, limit)
|
||||
|
||||
pmap->pm_stats.resident_count += size >> PAGE_SHIFT;
|
||||
npdes = size >> PDRSHIFT;
|
||||
for(i=0;i<npdes;i++) {
|
||||
for(i = 0; i < npdes; i++) {
|
||||
pmap->pm_pdir[ptepindex] =
|
||||
(pd_entry_t) (ptepa | PG_U | PG_RW | PG_V | PG_PS);
|
||||
ptepa += NBPDR;
|
||||
@ -2444,7 +2629,7 @@ pmap_prefault(pmap, addra, entry)
|
||||
vm_page_t m, mpte;
|
||||
vm_object_t object;
|
||||
|
||||
if (!curproc || (pmap != vmspace_pmap(curproc->p_vmspace)))
|
||||
if (!curthread || (pmap != vmspace_pmap(curthread->td_proc->p_vmspace)))
|
||||
return;
|
||||
|
||||
object = entry->object.vm_object;
|
||||
@ -2561,6 +2746,7 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr)
|
||||
vm_offset_t pdnxt;
|
||||
unsigned src_frame, dst_frame;
|
||||
vm_page_t m;
|
||||
pd_entry_t saved_pde;
|
||||
|
||||
if (dst_addr != src_addr)
|
||||
return;
|
||||
@ -2580,7 +2766,7 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr)
|
||||
invltlb();
|
||||
#endif
|
||||
}
|
||||
|
||||
saved_pde = (pd_entry_t)((u_int32_t)APTDpde & (PG_FRAME|PG_RW | PG_V));
|
||||
for(addr = src_addr; addr < end_addr; addr = pdnxt) {
|
||||
unsigned *src_pte, *dst_pte;
|
||||
vm_page_t dstmpte, srcmpte;
|
||||
@ -2637,6 +2823,16 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr)
|
||||
* block.
|
||||
*/
|
||||
dstmpte = pmap_allocpte(dst_pmap, addr);
|
||||
if (((u_int32_t)APTDpde & PG_FRAME) !=
|
||||
((u_int32_t)saved_pde & PG_FRAME)) {
|
||||
APTDpde = saved_pde;
|
||||
printf ("IT HAPPENNED!");
|
||||
#if defined(SMP)
|
||||
cpu_invltlb();
|
||||
#else
|
||||
invltlb();
|
||||
#endif
|
||||
}
|
||||
if ((*dst_pte == 0) && (ptetemp = *src_pte)) {
|
||||
/*
|
||||
* Clear the modified and
|
||||
@ -2831,7 +3027,7 @@ pmap_remove_pages(pmap, sva, eva)
|
||||
vm_page_t m;
|
||||
|
||||
#ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY
|
||||
if (!curproc || (pmap != vmspace_pmap(curproc->p_vmspace))) {
|
||||
if (!curthread || (pmap != vmspace_pmap(curthread->td_proc->p_vmspace))) {
|
||||
printf("warning: pmap_remove_pages called with non-current pmap\n");
|
||||
return;
|
||||
}
|
||||
@ -2839,8 +3035,8 @@ pmap_remove_pages(pmap, sva, eva)
|
||||
|
||||
s = splvm();
|
||||
for(pv = TAILQ_FIRST(&pmap->pm_pvlist);
|
||||
pv;
|
||||
pv = npv) {
|
||||
pv;
|
||||
pv = npv) {
|
||||
|
||||
if (pv->pv_va >= eva || pv->pv_va < sva) {
|
||||
npv = TAILQ_NEXT(pv, pv_plist);
|
||||
@ -2854,6 +3050,12 @@ pmap_remove_pages(pmap, sva, eva)
|
||||
#endif
|
||||
tpte = *pte;
|
||||
|
||||
if (tpte == 0) {
|
||||
printf("TPTE at %p IS ZERO @ VA %08x\n",
|
||||
pte, pv->pv_va);
|
||||
panic("bad pte");
|
||||
}
|
||||
|
||||
/*
|
||||
* We cannot remove wired pages from a process' mapping at this time
|
||||
*/
|
||||
@ -2861,15 +3063,19 @@ pmap_remove_pages(pmap, sva, eva)
|
||||
npv = TAILQ_NEXT(pv, pv_plist);
|
||||
continue;
|
||||
}
|
||||
*pte = 0;
|
||||
|
||||
m = PHYS_TO_VM_PAGE(tpte);
|
||||
KASSERT(m->phys_addr == (tpte & PG_FRAME),
|
||||
("vm_page_t %p phys_addr mismatch %08x %08x",
|
||||
m, m->phys_addr, tpte));
|
||||
|
||||
KASSERT(m < &vm_page_array[vm_page_array_size],
|
||||
("pmap_remove_pages: bad tpte %x", tpte));
|
||||
|
||||
pv->pv_pmap->pm_stats.resident_count--;
|
||||
|
||||
*pte = 0;
|
||||
|
||||
/*
|
||||
* Update the vm_page_t clean and reference bits.
|
||||
*/
|
||||
@ -2877,7 +3083,6 @@ pmap_remove_pages(pmap, sva, eva)
|
||||
vm_page_dirty(m);
|
||||
}
|
||||
|
||||
|
||||
npv = TAILQ_NEXT(pv, pv_plist);
|
||||
TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist);
|
||||
|
||||
@ -3255,11 +3460,13 @@ pmap_mincore(pmap, addr)
|
||||
}
|
||||
|
||||
void
|
||||
pmap_activate(struct proc *p)
|
||||
pmap_activate(struct thread *td)
|
||||
{
|
||||
struct proc *p = td->td_proc;
|
||||
pmap_t pmap;
|
||||
u_int32_t cr3;
|
||||
|
||||
pmap = vmspace_pmap(p->p_vmspace);
|
||||
pmap = vmspace_pmap(td->td_proc->p_vmspace);
|
||||
#if defined(SMP)
|
||||
pmap->pm_active |= 1 << PCPU_GET(cpuid);
|
||||
#else
|
||||
@ -3268,7 +3475,20 @@ pmap_activate(struct proc *p)
|
||||
#if defined(SWTCH_OPTIM_STATS)
|
||||
tlb_flush_count++;
|
||||
#endif
|
||||
load_cr3(p->p_addr->u_pcb.pcb_cr3 = vtophys(pmap->pm_pdir));
|
||||
cr3 = vtophys(pmap->pm_pdir);
|
||||
/* XXXKSE this is wrong.
|
||||
* pmap_activate is for the current thread on the current cpu
|
||||
*/
|
||||
if (p->p_flag & P_KSES) {
|
||||
/* Make sure all other cr3 entries are updated. */
|
||||
/* what if they are running? XXXKSE (maybe abort them) */
|
||||
FOREACH_THREAD_IN_PROC(p, td) {
|
||||
td->td_pcb->pcb_cr3 = cr3;
|
||||
}
|
||||
} else {
|
||||
td->td_pcb->pcb_cr3 = cr3;
|
||||
}
|
||||
load_cr3(cr3);
|
||||
}
|
||||
|
||||
vm_offset_t
|
||||
@ -3301,14 +3521,14 @@ pmap_pid_dump(int pid)
|
||||
int i,j;
|
||||
index = 0;
|
||||
pmap = vmspace_pmap(p->p_vmspace);
|
||||
for(i=0;i<1024;i++) {
|
||||
for(i = 0; i < 1024; i++) {
|
||||
pd_entry_t *pde;
|
||||
unsigned *pte;
|
||||
unsigned base = i << PDRSHIFT;
|
||||
|
||||
pde = &pmap->pm_pdir[i];
|
||||
if (pde && pmap_pde_v(pde)) {
|
||||
for(j=0;j<1024;j++) {
|
||||
for(j = 0; j < 1024; j++) {
|
||||
unsigned va = base + (j << PAGE_SHIFT);
|
||||
if (va >= (vm_offset_t) VM_MIN_KERNEL_ADDRESS) {
|
||||
if (index) {
|
||||
|
@ -216,8 +216,8 @@ ENTRY(i586_bzero)
|
||||
* complicated since we avoid it if possible at all levels. We
|
||||
* want to localize the complications even when that increases them.
|
||||
* Here the extra work involves preserving CR0_TS in TS.
|
||||
* `npxproc != NULL' is supposed to be the condition that all the
|
||||
* FPU resources belong to an application, but npxproc and CR0_TS
|
||||
* `npxthread != NULL' is supposed to be the condition that all the
|
||||
* FPU resources belong to an application, but npxthread and CR0_TS
|
||||
* aren't set atomically enough for this condition to work in
|
||||
* interrupt handlers.
|
||||
*
|
||||
@ -241,7 +241,7 @@ ENTRY(i586_bzero)
|
||||
* method. CR0_TS must be preserved although it is very likely to
|
||||
* always end up as clear.
|
||||
*/
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je i586_bz1
|
||||
|
||||
/*
|
||||
@ -303,7 +303,7 @@ fpureg_i586_bzero_loop:
|
||||
cmpl $8,%ecx
|
||||
jae fpureg_i586_bzero_loop
|
||||
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je i586_bz3
|
||||
|
||||
/* XXX check that the condition for cases 1-2 stayed false. */
|
||||
@ -517,7 +517,7 @@ ENTRY(i586_bcopy)
|
||||
|
||||
sarb $1,kernel_fpu_lock
|
||||
jc small_i586_bcopy
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je i586_bc1
|
||||
|
||||
/* XXX turn off handling of cases 1-2, as above. */
|
||||
@ -593,7 +593,7 @@ large_i586_bcopy_loop:
|
||||
cmpl $64,%ecx
|
||||
jae 4b
|
||||
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je i586_bc2
|
||||
|
||||
/* XXX check that the condition for cases 1-2 stayed false. */
|
||||
@ -991,14 +991,14 @@ ENTRY(fastmove)
|
||||
/* XXX grab FPU context atomically. */
|
||||
cli
|
||||
|
||||
/* if (npxproc != NULL) { */
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
/* if (npxthread != NULL) { */
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je 6f
|
||||
/* fnsave(&curpcb->pcb_savefpu); */
|
||||
movl PCPU(CURPCB),%eax
|
||||
fnsave PCB_SAVEFPU(%eax)
|
||||
/* npxproc = NULL; */
|
||||
movl $0,PCPU(NPXPROC)
|
||||
/* NPXTHREAD = NULL; */
|
||||
movl $0,PCPU(NPXTHREAD)
|
||||
/* } */
|
||||
6:
|
||||
/* now we own the FPU. */
|
||||
@ -1026,9 +1026,9 @@ ENTRY(fastmove)
|
||||
movl -4(%ebp),%edi
|
||||
/* stop_emulating(); */
|
||||
clts
|
||||
/* npxproc = curproc; */
|
||||
movl PCPU(CURPROC),%eax
|
||||
movl %eax,PCPU(NPXPROC)
|
||||
/* npxthread = curthread; */
|
||||
movl PCPU(CURTHREAD),%eax
|
||||
movl %eax,PCPU(NPXTHREAD)
|
||||
movl PCPU(CURPCB),%eax
|
||||
|
||||
/* XXX end of atomic FPU context grab. */
|
||||
@ -1113,8 +1113,8 @@ fastmove_loop:
|
||||
smsw %ax
|
||||
orb $CR0_TS,%al
|
||||
lmsw %ax
|
||||
/* npxproc = NULL; */
|
||||
movl $0,PCPU(NPXPROC)
|
||||
/* npxthread = NULL; */
|
||||
movl $0,PCPU(NPXTHREAD)
|
||||
|
||||
/* XXX end of atomic FPU context ungrab. */
|
||||
sti
|
||||
@ -1154,7 +1154,7 @@ fastmove_fault:
|
||||
smsw %ax
|
||||
orb $CR0_TS,%al
|
||||
lmsw %ax
|
||||
movl $0,PCPU(NPXPROC)
|
||||
movl $0,PCPU(NPXTHREAD)
|
||||
|
||||
/* XXX end of atomic FPU context ungrab. */
|
||||
sti
|
||||
|
@ -216,8 +216,8 @@ ENTRY(i586_bzero)
|
||||
* complicated since we avoid it if possible at all levels. We
|
||||
* want to localize the complications even when that increases them.
|
||||
* Here the extra work involves preserving CR0_TS in TS.
|
||||
* `npxproc != NULL' is supposed to be the condition that all the
|
||||
* FPU resources belong to an application, but npxproc and CR0_TS
|
||||
* `npxthread != NULL' is supposed to be the condition that all the
|
||||
* FPU resources belong to an application, but npxthread and CR0_TS
|
||||
* aren't set atomically enough for this condition to work in
|
||||
* interrupt handlers.
|
||||
*
|
||||
@ -241,7 +241,7 @@ ENTRY(i586_bzero)
|
||||
* method. CR0_TS must be preserved although it is very likely to
|
||||
* always end up as clear.
|
||||
*/
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je i586_bz1
|
||||
|
||||
/*
|
||||
@ -303,7 +303,7 @@ fpureg_i586_bzero_loop:
|
||||
cmpl $8,%ecx
|
||||
jae fpureg_i586_bzero_loop
|
||||
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je i586_bz3
|
||||
|
||||
/* XXX check that the condition for cases 1-2 stayed false. */
|
||||
@ -517,7 +517,7 @@ ENTRY(i586_bcopy)
|
||||
|
||||
sarb $1,kernel_fpu_lock
|
||||
jc small_i586_bcopy
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je i586_bc1
|
||||
|
||||
/* XXX turn off handling of cases 1-2, as above. */
|
||||
@ -593,7 +593,7 @@ large_i586_bcopy_loop:
|
||||
cmpl $64,%ecx
|
||||
jae 4b
|
||||
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je i586_bc2
|
||||
|
||||
/* XXX check that the condition for cases 1-2 stayed false. */
|
||||
@ -991,14 +991,14 @@ ENTRY(fastmove)
|
||||
/* XXX grab FPU context atomically. */
|
||||
cli
|
||||
|
||||
/* if (npxproc != NULL) { */
|
||||
cmpl $0,PCPU(NPXPROC)
|
||||
/* if (npxthread != NULL) { */
|
||||
cmpl $0,PCPU(NPXTHREAD)
|
||||
je 6f
|
||||
/* fnsave(&curpcb->pcb_savefpu); */
|
||||
movl PCPU(CURPCB),%eax
|
||||
fnsave PCB_SAVEFPU(%eax)
|
||||
/* npxproc = NULL; */
|
||||
movl $0,PCPU(NPXPROC)
|
||||
/* NPXTHREAD = NULL; */
|
||||
movl $0,PCPU(NPXTHREAD)
|
||||
/* } */
|
||||
6:
|
||||
/* now we own the FPU. */
|
||||
@ -1026,9 +1026,9 @@ ENTRY(fastmove)
|
||||
movl -4(%ebp),%edi
|
||||
/* stop_emulating(); */
|
||||
clts
|
||||
/* npxproc = curproc; */
|
||||
movl PCPU(CURPROC),%eax
|
||||
movl %eax,PCPU(NPXPROC)
|
||||
/* npxthread = curthread; */
|
||||
movl PCPU(CURTHREAD),%eax
|
||||
movl %eax,PCPU(NPXTHREAD)
|
||||
movl PCPU(CURPCB),%eax
|
||||
|
||||
/* XXX end of atomic FPU context grab. */
|
||||
@ -1113,8 +1113,8 @@ fastmove_loop:
|
||||
smsw %ax
|
||||
orb $CR0_TS,%al
|
||||
lmsw %ax
|
||||
/* npxproc = NULL; */
|
||||
movl $0,PCPU(NPXPROC)
|
||||
/* npxthread = NULL; */
|
||||
movl $0,PCPU(NPXTHREAD)
|
||||
|
||||
/* XXX end of atomic FPU context ungrab. */
|
||||
sti
|
||||
@ -1154,7 +1154,7 @@ fastmove_fault:
|
||||
smsw %ax
|
||||
orb $CR0_TS,%al
|
||||
lmsw %ax
|
||||
movl $0,PCPU(NPXPROC)
|
||||
movl $0,PCPU(NPXTHREAD)
|
||||
|
||||
/* XXX end of atomic FPU context ungrab. */
|
||||
sti
|
||||
|
@ -77,17 +77,17 @@ ENTRY(cpu_throw)
|
||||
ENTRY(cpu_switch)
|
||||
|
||||
/* switch to new process. first, save context as needed */
|
||||
movl PCPU(CURPROC),%ecx
|
||||
movl PCPU(CURTHREAD),%ecx
|
||||
|
||||
/* if no process to save, don't bother */
|
||||
testl %ecx,%ecx
|
||||
jz sw1
|
||||
|
||||
movl P_VMSPACE(%ecx), %edx
|
||||
movl TD_PROC(%ecx), %eax
|
||||
movl P_VMSPACE(%eax), %edx
|
||||
movl PCPU(CPUID), %eax
|
||||
btrl %eax, VM_PMAP+PM_ACTIVE(%edx)
|
||||
|
||||
movl P_ADDR(%ecx),%edx
|
||||
movl TD_PCB(%ecx),%edx
|
||||
|
||||
movl (%esp),%eax /* Hardware registers */
|
||||
movl %eax,PCB_EIP(%edx)
|
||||
@ -124,7 +124,7 @@ ENTRY(cpu_switch)
|
||||
|
||||
#ifdef DEV_NPX
|
||||
/* have we used fp, and need a save? */
|
||||
cmpl %ecx,PCPU(NPXPROC)
|
||||
cmpl %ecx,PCPU(NPXTHREAD)
|
||||
jne 1f
|
||||
addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */
|
||||
pushl %edx
|
||||
@ -133,7 +133,11 @@ ENTRY(cpu_switch)
|
||||
1:
|
||||
#endif /* DEV_NPX */
|
||||
|
||||
/*##########################################################################*/
|
||||
/*##########################################################################*/
|
||||
/*##########################################################################*/
|
||||
/* save is done, now choose a new process */
|
||||
/* But still trashing space above the old "Top Of Stack".. */
|
||||
sw1:
|
||||
|
||||
#ifdef SMP
|
||||
@ -143,17 +147,17 @@ sw1:
|
||||
cmpl $0,PCPU(CPUID)
|
||||
je 1f
|
||||
|
||||
movl PCPU(IDLEPROC), %eax
|
||||
jmp sw1b
|
||||
movl PCPU(IDLETHREAD), %eax
|
||||
jmp sw1b /* Idle thread can run on any kernel context */
|
||||
1:
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Choose a new process to schedule. chooseproc() returns idleproc
|
||||
* Choose a new process to schedule. choosethread() returns idleproc
|
||||
* if it cannot find another process to run.
|
||||
*/
|
||||
sw1a:
|
||||
call chooseproc /* trash ecx, edx, ret eax*/
|
||||
call choosethread /* trash ecx, edx, ret eax*/
|
||||
|
||||
#ifdef INVARIANTS
|
||||
testl %eax,%eax /* no process? */
|
||||
@ -163,15 +167,20 @@ sw1b:
|
||||
movl %eax,%ecx
|
||||
|
||||
#ifdef INVARIANTS
|
||||
cmpb $SRUN,P_STAT(%ecx)
|
||||
movl TD_PROC(%ecx), %eax /* XXXKSE */
|
||||
cmpb $SRUN,P_STAT(%eax)
|
||||
jne badsw2
|
||||
#endif
|
||||
|
||||
movl P_ADDR(%ecx),%edx
|
||||
movl TD_PCB(%ecx),%edx
|
||||
|
||||
#if defined(SWTCH_OPTIM_STATS)
|
||||
incl swtch_optim_stats
|
||||
#endif
|
||||
|
||||
/*##########################################################################*/
|
||||
/*##########################################################################*/
|
||||
/*##########################################################################*/
|
||||
/* switch address space */
|
||||
movl %cr3,%ebx
|
||||
cmpl PCB_CR3(%edx),%ebx
|
||||
@ -181,9 +190,8 @@ sw1b:
|
||||
incl tlb_flush_count
|
||||
#endif
|
||||
movl PCB_CR3(%edx),%ebx
|
||||
movl %ebx,%cr3
|
||||
movl %ebx,%cr3 /* LOAD NEW PAGE TABLES */
|
||||
4:
|
||||
|
||||
movl PCPU(CPUID), %esi
|
||||
cmpl $0, PCB_EXT(%edx) /* has pcb extension? */
|
||||
je 1f
|
||||
@ -191,12 +199,9 @@ sw1b:
|
||||
movl PCB_EXT(%edx), %edi /* new tss descriptor */
|
||||
jmp 2f
|
||||
1:
|
||||
|
||||
/* update common_tss.tss_esp0 pointer */
|
||||
movl %edx, %ebx /* pcb */
|
||||
addl $(UPAGES * PAGE_SIZE - 16), %ebx
|
||||
movl %ebx, PCPU(COMMON_TSS) + TSS_ESP0
|
||||
|
||||
/* esp points to base of usable stack */
|
||||
movl %edx, PCPU(COMMON_TSS) + TSS_ESP0 /* stack is below pcb */
|
||||
btrl %esi, private_tss
|
||||
jae 3f
|
||||
PCPU_ADDR(COMMON_TSSD, %edi)
|
||||
@ -210,7 +215,9 @@ sw1b:
|
||||
movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */
|
||||
ltr %si
|
||||
3:
|
||||
movl P_VMSPACE(%ecx), %ebx
|
||||
/* note in a vmspace that this cpu is using it */
|
||||
movl TD_PROC(%ecx),%eax /* get proc from thread XXXKSE */
|
||||
movl P_VMSPACE(%eax), %ebx /* get vmspace of proc */
|
||||
movl PCPU(CPUID), %eax
|
||||
btsl %eax, VM_PMAP+PM_ACTIVE(%ebx)
|
||||
|
||||
@ -233,22 +240,23 @@ sw1b:
|
||||
#endif /** GRAB_LOPRIO */
|
||||
#endif /* SMP */
|
||||
movl %edx, PCPU(CURPCB)
|
||||
movl %ecx, PCPU(CURPROC) /* into next process */
|
||||
movl %ecx, PCPU(CURTHREAD) /* into next process */
|
||||
|
||||
#ifdef SMP
|
||||
/* XXX FIXME: we should be restoring the local APIC TPR */
|
||||
#endif /* SMP */
|
||||
|
||||
cmpl $0, PCB_USERLDT(%edx)
|
||||
jnz 1f
|
||||
movl _default_ldt,%eax
|
||||
cmpl PCPU(CURRENTLDT),%eax
|
||||
je 2f
|
||||
lldt _default_ldt
|
||||
movl %eax,PCPU(CURRENTLDT)
|
||||
cmpl $0, PCB_USERLDT(%edx) /* if there is one */
|
||||
jnz 1f /* then use it */
|
||||
movl _default_ldt,%eax /* We will use the default */
|
||||
cmpl PCPU(CURRENTLDT),%eax /* check to see if already loaded */
|
||||
je 2f /* if so skip reload */
|
||||
lldt _default_ldt /* load the default... we trust it. */
|
||||
movl %eax,PCPU(CURRENTLDT) /* store what we have */
|
||||
jmp 2f
|
||||
1: pushl %edx
|
||||
call set_user_ldt
|
||||
|
||||
1: pushl %edx /* call a non-trusting routine */
|
||||
call set_user_ldt /* to check and load the ldt */
|
||||
popl %edx
|
||||
2:
|
||||
|
||||
@ -275,7 +283,7 @@ cpu_switch_load_gs:
|
||||
andl $0x0000fc00,%eax /* reserved bits */
|
||||
pushl %ebx
|
||||
movl PCB_DR7(%edx),%ebx
|
||||
andl $~0x0000fc00,%ebx
|
||||
andl $~0x0000fc00,%ebx /* re-enable the restored watchpoints */
|
||||
orl %ebx,%eax
|
||||
popl %ebx
|
||||
movl %eax,%dr7
|
||||
@ -322,25 +330,25 @@ ENTRY(savectx)
|
||||
|
||||
#ifdef DEV_NPX
|
||||
/*
|
||||
* If npxproc == NULL, then the npx h/w state is irrelevant and the
|
||||
* If npxthread == NULL, then the npx h/w state is irrelevant and the
|
||||
* state had better already be in the pcb. This is true for forks
|
||||
* but not for dumps (the old book-keeping with FP flags in the pcb
|
||||
* always lost for dumps because the dump pcb has 0 flags).
|
||||
*
|
||||
* If npxproc != NULL, then we have to save the npx h/w state to
|
||||
* npxproc's pcb and copy it to the requested pcb, or save to the
|
||||
* If npxthread != NULL, then we have to save the npx h/w state to
|
||||
* npxthread's pcb and copy it to the requested pcb, or save to the
|
||||
* requested pcb and reload. Copying is easier because we would
|
||||
* have to handle h/w bugs for reloading. We used to lose the
|
||||
* parent's npx state for forks by forgetting to reload.
|
||||
*/
|
||||
pushfl
|
||||
cli
|
||||
movl PCPU(NPXPROC),%eax
|
||||
movl PCPU(NPXTHREAD),%eax
|
||||
testl %eax,%eax
|
||||
je 1f
|
||||
|
||||
pushl %ecx
|
||||
movl P_ADDR(%eax),%eax
|
||||
movl TD_PCB(%eax),%eax
|
||||
leal PCB_SAVEFPU(%eax),%eax
|
||||
pushl %eax
|
||||
pushl %eax
|
||||
|
@ -35,7 +35,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opt_upages.h"
|
||||
#include "opt_kstack_pages.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -65,10 +65,10 @@
|
||||
|
||||
|
||||
|
||||
static int i386_get_ldt __P((struct proc *, char *));
|
||||
static int i386_set_ldt __P((struct proc *, char *));
|
||||
static int i386_get_ioperm __P((struct proc *, char *));
|
||||
static int i386_set_ioperm __P((struct proc *, char *));
|
||||
static int i386_get_ldt __P((struct thread *, char *));
|
||||
static int i386_set_ldt __P((struct thread *, char *));
|
||||
static int i386_get_ioperm __P((struct thread *, char *));
|
||||
static int i386_set_ioperm __P((struct thread *, char *));
|
||||
#ifdef SMP
|
||||
static void set_user_ldt_rv __P((struct pcb *));
|
||||
#endif
|
||||
@ -81,28 +81,28 @@ struct sysarch_args {
|
||||
#endif
|
||||
|
||||
int
|
||||
sysarch(p, uap)
|
||||
struct proc *p;
|
||||
sysarch(td, uap)
|
||||
struct thread *td;
|
||||
register struct sysarch_args *uap;
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
switch(uap->op) {
|
||||
case I386_GET_LDT:
|
||||
error = i386_get_ldt(p, uap->parms);
|
||||
error = i386_get_ldt(td, uap->parms);
|
||||
break;
|
||||
|
||||
case I386_SET_LDT:
|
||||
error = i386_set_ldt(p, uap->parms);
|
||||
error = i386_set_ldt(td, uap->parms);
|
||||
break;
|
||||
case I386_GET_IOPERM:
|
||||
error = i386_get_ioperm(p, uap->parms);
|
||||
error = i386_get_ioperm(td, uap->parms);
|
||||
break;
|
||||
case I386_SET_IOPERM:
|
||||
error = i386_set_ioperm(p, uap->parms);
|
||||
error = i386_set_ioperm(td, uap->parms);
|
||||
break;
|
||||
case I386_VM86:
|
||||
error = vm86_sysarch(p, uap->parms);
|
||||
error = vm86_sysarch(td, uap->parms);
|
||||
break;
|
||||
default:
|
||||
error = EOPNOTSUPP;
|
||||
@ -112,7 +112,7 @@ sysarch(p, uap)
|
||||
}
|
||||
|
||||
int
|
||||
i386_extend_pcb(struct proc *p)
|
||||
i386_extend_pcb(struct thread *td)
|
||||
{
|
||||
int i, offset;
|
||||
u_long *addr;
|
||||
@ -127,12 +127,18 @@ i386_extend_pcb(struct proc *p)
|
||||
0, /* default 32 size */
|
||||
0 /* granularity */
|
||||
};
|
||||
struct proc *p = td->td_proc;
|
||||
|
||||
if (td->td_proc->p_flag & P_KSES)
|
||||
return (EINVAL); /* XXXKSE */
|
||||
/* XXXKSE All the code below only works in 1:1 needs changing */
|
||||
ext = (struct pcb_ext *)kmem_alloc(kernel_map, ctob(IOPAGES+1));
|
||||
if (ext == 0)
|
||||
return (ENOMEM);
|
||||
bzero(ext, sizeof(struct pcb_ext));
|
||||
ext->ext_tss.tss_esp0 = (unsigned)p->p_addr + ctob(UPAGES) - 16;
|
||||
/* -16 is so we can convert a trapframe into vm86trapframe inplace */
|
||||
ext->ext_tss.tss_esp0 = td->td_kstack + ctob(KSTACK_PAGES) -
|
||||
sizeof(struct pcb) - 16;
|
||||
ext->ext_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
|
||||
/*
|
||||
* The last byte of the i/o map must be followed by an 0xff byte.
|
||||
@ -153,21 +159,21 @@ i386_extend_pcb(struct proc *p)
|
||||
ssd.ssd_limit -= ((unsigned)&ext->ext_tss - (unsigned)ext);
|
||||
ssdtosd(&ssd, &ext->ext_tssd);
|
||||
|
||||
KASSERT(p == curproc, ("giving a TSS to non-curproc"));
|
||||
KASSERT(p->p_addr->u_pcb.pcb_ext == 0, ("already have a TSS!"));
|
||||
KASSERT(p == curthread->td_proc, ("giving a TSS to non-curproc"));
|
||||
KASSERT(td->td_pcb->pcb_ext == 0, ("already have a TSS!"));
|
||||
mtx_lock_spin(&sched_lock);
|
||||
p->p_addr->u_pcb.pcb_ext = ext;
|
||||
td->td_pcb->pcb_ext = ext;
|
||||
|
||||
/* switch to the new TSS after syscall completes */
|
||||
p->p_sflag |= PS_NEEDRESCHED;
|
||||
td->td_kse->ke_flags |= KEF_NEEDRESCHED;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
i386_set_ioperm(p, args)
|
||||
struct proc *p;
|
||||
i386_set_ioperm(td, args)
|
||||
struct thread *td;
|
||||
char *args;
|
||||
{
|
||||
int i, error;
|
||||
@ -177,7 +183,7 @@ i386_set_ioperm(p, args)
|
||||
if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0)
|
||||
return (error);
|
||||
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser_td(td)) != 0)
|
||||
return (error);
|
||||
if (securelevel > 0)
|
||||
return (EPERM);
|
||||
@ -188,10 +194,10 @@ i386_set_ioperm(p, args)
|
||||
* cause confusion. This probably requires a global 'usage registry'.
|
||||
*/
|
||||
|
||||
if (p->p_addr->u_pcb.pcb_ext == 0)
|
||||
if ((error = i386_extend_pcb(p)) != 0)
|
||||
if (td->td_pcb->pcb_ext == 0)
|
||||
if ((error = i386_extend_pcb(td)) != 0)
|
||||
return (error);
|
||||
iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap;
|
||||
iomap = (char *)td->td_pcb->pcb_ext->ext_iomap;
|
||||
|
||||
if (ua.start + ua.length > IOPAGES * PAGE_SIZE * NBBY)
|
||||
return (EINVAL);
|
||||
@ -206,8 +212,8 @@ i386_set_ioperm(p, args)
|
||||
}
|
||||
|
||||
static int
|
||||
i386_get_ioperm(p, args)
|
||||
struct proc *p;
|
||||
i386_get_ioperm(td, args)
|
||||
struct thread *td;
|
||||
char *args;
|
||||
{
|
||||
int i, state, error;
|
||||
@ -219,12 +225,12 @@ i386_get_ioperm(p, args)
|
||||
if (ua.start >= IOPAGES * PAGE_SIZE * NBBY)
|
||||
return (EINVAL);
|
||||
|
||||
if (p->p_addr->u_pcb.pcb_ext == 0) {
|
||||
if (td->td_pcb->pcb_ext == 0) {
|
||||
ua.length = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap;
|
||||
iomap = (char *)td->td_pcb->pcb_ext->ext_iomap;
|
||||
|
||||
i = ua.start;
|
||||
state = (iomap[i >> 3] >> (i & 7)) & 1;
|
||||
@ -351,12 +357,12 @@ user_ldt_free(struct pcb *pcb)
|
||||
}
|
||||
|
||||
static int
|
||||
i386_get_ldt(p, args)
|
||||
struct proc *p;
|
||||
i386_get_ldt(td, args)
|
||||
struct thread *td;
|
||||
char *args;
|
||||
{
|
||||
int error = 0;
|
||||
struct pcb *pcb = &p->p_addr->u_pcb;
|
||||
struct pcb *pcb = td->td_pcb;
|
||||
struct pcb_ldt *pcb_ldt = pcb->pcb_ldt;
|
||||
int nldt, num;
|
||||
union descriptor *lp;
|
||||
@ -388,19 +394,19 @@ i386_get_ldt(p, args)
|
||||
|
||||
error = copyout(lp, uap->descs, num * sizeof(union descriptor));
|
||||
if (!error)
|
||||
p->p_retval[0] = num;
|
||||
td->td_retval[0] = num;
|
||||
|
||||
return(error);
|
||||
}
|
||||
|
||||
static int
|
||||
i386_set_ldt(p, args)
|
||||
struct proc *p;
|
||||
i386_set_ldt(td, args)
|
||||
struct thread *td;
|
||||
char *args;
|
||||
{
|
||||
int error = 0, i, n;
|
||||
int largest_ld;
|
||||
struct pcb *pcb = &p->p_addr->u_pcb;
|
||||
struct pcb *pcb = td->td_pcb;
|
||||
struct pcb_ldt *pcb_ldt = pcb->pcb_ldt;
|
||||
struct i386_ldt_args ua, *uap = &ua;
|
||||
caddr_t old_ldt_base;
|
||||
@ -530,7 +536,7 @@ i386_set_ldt(p, args)
|
||||
&((union descriptor *)(pcb_ldt->ldt_base))[uap->start],
|
||||
uap->num * sizeof(union descriptor));
|
||||
if (!error)
|
||||
p->p_retval[0] = uap->start;
|
||||
td->td_retval[0] = uap->start;
|
||||
critical_exit(savecrit);
|
||||
|
||||
return(error);
|
||||
|
@ -173,7 +173,8 @@ void
|
||||
trap(frame)
|
||||
struct trapframe frame;
|
||||
{
|
||||
struct proc *p = curproc;
|
||||
struct thread *td = curthread;
|
||||
struct proc *p = td->td_proc;
|
||||
u_int sticks = 0;
|
||||
int i = 0, ucode = 0, type, code;
|
||||
vm_offset_t eva;
|
||||
@ -225,8 +226,8 @@ trap(frame)
|
||||
((frame.tf_eflags & PSL_VM) && !in_vm86call)) {
|
||||
/* user trap */
|
||||
|
||||
sticks = p->p_sticks;
|
||||
p->p_frame = &frame;
|
||||
sticks = td->td_kse->ke_sticks;
|
||||
td->td_frame = &frame;
|
||||
|
||||
switch (type) {
|
||||
case T_PRIVINFLT: /* privileged instruction fault */
|
||||
@ -444,7 +445,7 @@ trap(frame)
|
||||
if (in_vm86call)
|
||||
break;
|
||||
|
||||
if (p->p_intr_nesting_level != 0)
|
||||
if (td->td_intr_nesting_level != 0)
|
||||
break;
|
||||
|
||||
/*
|
||||
@ -620,7 +621,7 @@ trap(frame)
|
||||
#endif
|
||||
|
||||
user:
|
||||
userret(p, &frame, sticks);
|
||||
userret(td, &frame, sticks);
|
||||
if (mtx_owned(&Giant)) /* XXX why would Giant be owned here? */
|
||||
mtx_unlock(&Giant);
|
||||
out:
|
||||
@ -660,7 +661,7 @@ trap_pfault(frame, usermode, eva)
|
||||
|
||||
if (p == NULL ||
|
||||
(!usermode && va < VM_MAXUSER_ADDRESS &&
|
||||
(p->p_intr_nesting_level != 0 ||
|
||||
(td->td_intr_nesting_level != 0 ||
|
||||
PCPU_GET(curpcb) == NULL ||
|
||||
PCPU_GET(curpcb)->pcb_onfault == NULL))) {
|
||||
trap_fatal(frame, eva);
|
||||
@ -696,7 +697,7 @@ trap_pfault(frame, usermode, eva)
|
||||
* a growable stack region, or if the stack
|
||||
* growth succeeded.
|
||||
*/
|
||||
if (!grow_stack (p, va))
|
||||
if (!grow_stack (td, va))
|
||||
rv = KERN_FAILURE;
|
||||
else
|
||||
/* Fault in the user page: */
|
||||
@ -728,7 +729,7 @@ trap_pfault(frame, usermode, eva)
|
||||
return (0);
|
||||
nogo:
|
||||
if (!usermode) {
|
||||
if (p->p_intr_nesting_level == 0 &&
|
||||
if (td->td_intr_nesting_level == 0 &&
|
||||
PCPU_GET(curpcb) != NULL &&
|
||||
PCPU_GET(curpcb)->pcb_onfault != NULL) {
|
||||
frame->tf_eip = (int)PCPU_GET(curpcb)->pcb_onfault;
|
||||
@ -756,7 +757,8 @@ trap_pfault(frame, usermode, eva)
|
||||
vm_map_t map = 0;
|
||||
int rv = 0;
|
||||
vm_prot_t ftype;
|
||||
struct proc *p = curproc;
|
||||
struct thread *td = curthread;
|
||||
struct proc *p = td->td_proc;
|
||||
|
||||
va = trunc_page(eva);
|
||||
if (va >= KERNBASE) {
|
||||
@ -839,7 +841,7 @@ trap_pfault(frame, usermode, eva)
|
||||
return (0);
|
||||
nogo:
|
||||
if (!usermode) {
|
||||
if (p->p_intr_nesting_level == 0 &&
|
||||
if (td->td_intr_nesting_level == 0 &&
|
||||
PCPU_GET(curpcb) != NULL &&
|
||||
PCPU_GET(curpcb)->pcb_onfault != NULL) {
|
||||
frame->tf_eip = (int)PCPU_GET(curpcb)->pcb_onfault;
|
||||
@ -972,6 +974,7 @@ dblfault_handler()
|
||||
int trapwrite(addr)
|
||||
unsigned addr;
|
||||
{
|
||||
struct thread *td;
|
||||
struct proc *p;
|
||||
vm_offset_t va;
|
||||
struct vmspace *vm;
|
||||
@ -984,7 +987,8 @@ int trapwrite(addr)
|
||||
if (va >= VM_MAXUSER_ADDRESS)
|
||||
return (1);
|
||||
|
||||
p = curproc;
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
vm = p->p_vmspace;
|
||||
|
||||
PROC_LOCK(p);
|
||||
@ -1021,7 +1025,8 @@ syscall(frame)
|
||||
caddr_t params;
|
||||
int i;
|
||||
struct sysent *callp;
|
||||
struct proc *p = curproc;
|
||||
struct thread *td = curthread;
|
||||
struct proc *p = td->td_proc;
|
||||
u_int sticks;
|
||||
int error;
|
||||
int narg;
|
||||
@ -1039,8 +1044,8 @@ syscall(frame)
|
||||
}
|
||||
#endif
|
||||
|
||||
sticks = p->p_sticks;
|
||||
p->p_frame = &frame;
|
||||
sticks = td->td_kse->ke_sticks;
|
||||
td->td_frame = &frame;
|
||||
params = (caddr_t)frame.tf_esp + sizeof(int);
|
||||
code = frame.tf_eax;
|
||||
|
||||
@ -1109,17 +1114,17 @@ syscall(frame)
|
||||
ktrsyscall(p->p_tracep, code, narg, args);
|
||||
}
|
||||
#endif
|
||||
p->p_retval[0] = 0;
|
||||
p->p_retval[1] = frame.tf_edx;
|
||||
td->td_retval[0] = 0;
|
||||
td->td_retval[1] = frame.tf_edx;
|
||||
|
||||
STOPEVENT(p, S_SCE, narg);
|
||||
|
||||
error = (*callp->sy_call)(p, args);
|
||||
error = (*callp->sy_call)(td, args);
|
||||
|
||||
switch (error) {
|
||||
case 0:
|
||||
frame.tf_eax = p->p_retval[0];
|
||||
frame.tf_edx = p->p_retval[1];
|
||||
frame.tf_eax = td->td_retval[0];
|
||||
frame.tf_edx = td->td_retval[1];
|
||||
frame.tf_eflags &= ~PSL_C;
|
||||
break;
|
||||
|
||||
@ -1158,11 +1163,11 @@ syscall(frame)
|
||||
/*
|
||||
* Handle reschedule and other end-of-syscall issues
|
||||
*/
|
||||
userret(p, &frame, sticks);
|
||||
userret(td, &frame, sticks);
|
||||
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSRET)) {
|
||||
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
|
||||
ktrsysret(p->p_tracep, code, error, td->td_retval[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1183,7 +1188,7 @@ syscall(frame)
|
||||
STOPEVENT(p, S_SCX, code);
|
||||
|
||||
#ifdef WITNESS
|
||||
if (witness_list(p)) {
|
||||
if (witness_list(td)) {
|
||||
panic("system call %s returning with mutex(s) held\n",
|
||||
syscallnames[code]);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
#endif
|
||||
#include "opt_reset.h"
|
||||
#include "opt_isa.h"
|
||||
#include "opt_upages.h"
|
||||
#include "opt_kstack_pages.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -117,19 +117,24 @@ vm_fault_quick(v, prot)
|
||||
* ready to run and return to user mode.
|
||||
*/
|
||||
void
|
||||
cpu_fork(p1, p2, flags)
|
||||
register struct proc *p1, *p2;
|
||||
cpu_fork(td1, p2, flags)
|
||||
register struct thread *td1;
|
||||
register struct proc *p2;
|
||||
int flags;
|
||||
{
|
||||
register struct proc *p1;
|
||||
struct thread *td2;
|
||||
struct pcb *pcb2;
|
||||
#ifdef DEV_NPX
|
||||
int savecrit;
|
||||
#endif
|
||||
|
||||
p1 = td1->td_proc;
|
||||
td2 = &p2->p_thread;
|
||||
if ((flags & RFPROC) == 0) {
|
||||
if ((flags & RFMEM) == 0) {
|
||||
/* unshare user LDT */
|
||||
struct pcb *pcb1 = &p1->p_addr->u_pcb;
|
||||
struct pcb *pcb1 = td1->td_pcb;
|
||||
struct pcb_ldt *pcb_ldt = pcb1->pcb_ldt;
|
||||
if (pcb_ldt && pcb_ldt->ldt_refcnt > 1) {
|
||||
pcb_ldt = user_ldt_alloc(pcb1,pcb_ldt->ldt_len);
|
||||
@ -145,30 +150,32 @@ cpu_fork(p1, p2, flags)
|
||||
|
||||
/* Ensure that p1's pcb is up to date. */
|
||||
#ifdef DEV_NPX
|
||||
if (p1 == curproc)
|
||||
p1->p_addr->u_pcb.pcb_gs = rgs();
|
||||
if (td1 == curthread)
|
||||
td1->td_pcb->pcb_gs = rgs();
|
||||
savecrit = critical_enter();
|
||||
if (PCPU_GET(npxproc) == p1)
|
||||
npxsave(&p1->p_addr->u_pcb.pcb_save);
|
||||
if (PCPU_GET(npxthread) == td1)
|
||||
npxsave(&td1->td_pcb->pcb_save);
|
||||
critical_exit(savecrit);
|
||||
#endif
|
||||
|
||||
/* Point the pcb to the top of the stack */
|
||||
pcb2 = (struct pcb *)(td2->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
|
||||
td2->td_pcb = pcb2;
|
||||
|
||||
/* Copy p1's pcb. */
|
||||
p2->p_addr->u_pcb = p1->p_addr->u_pcb;
|
||||
pcb2 = &p2->p_addr->u_pcb;
|
||||
bcopy(td1->td_pcb, pcb2, sizeof(*pcb2));
|
||||
|
||||
/*
|
||||
* Create a new fresh stack for the new process.
|
||||
* Copy the trap frame for the return to user mode as if from a
|
||||
* syscall. This copies most of the user mode register values.
|
||||
*/
|
||||
p2->p_frame = (struct trapframe *)
|
||||
((int)p2->p_addr + UPAGES * PAGE_SIZE - 16) - 1;
|
||||
bcopy(p1->p_frame, p2->p_frame, sizeof(struct trapframe));
|
||||
td2->td_frame = (struct trapframe *)td2->td_pcb - 1;
|
||||
bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe));
|
||||
|
||||
p2->p_frame->tf_eax = 0; /* Child returns zero */
|
||||
p2->p_frame->tf_eflags &= ~PSL_C; /* success */
|
||||
p2->p_frame->tf_edx = 1;
|
||||
td2->td_frame->tf_eax = 0; /* Child returns zero */
|
||||
td2->td_frame->tf_eflags &= ~PSL_C; /* success */
|
||||
td2->td_frame->tf_edx = 1;
|
||||
|
||||
/*
|
||||
* Set registers for trampoline to user mode. Leave space for the
|
||||
@ -178,8 +185,8 @@ cpu_fork(p1, p2, flags)
|
||||
pcb2->pcb_edi = 0;
|
||||
pcb2->pcb_esi = (int)fork_return; /* fork_trampoline argument */
|
||||
pcb2->pcb_ebp = 0;
|
||||
pcb2->pcb_esp = (int)p2->p_frame - sizeof(void *);
|
||||
pcb2->pcb_ebx = (int)p2; /* fork_trampoline argument */
|
||||
pcb2->pcb_esp = (int)td2->td_frame - sizeof(void *);
|
||||
pcb2->pcb_ebx = (int)td2; /* fork_trampoline argument */
|
||||
pcb2->pcb_eip = (int)fork_trampoline;
|
||||
/*-
|
||||
* pcb2->pcb_dr*: cloned above.
|
||||
@ -228,8 +235,8 @@ cpu_fork(p1, p2, flags)
|
||||
* This is needed to make kernel threads stay in kernel mode.
|
||||
*/
|
||||
void
|
||||
cpu_set_fork_handler(p, func, arg)
|
||||
struct proc *p;
|
||||
cpu_set_fork_handler(td, func, arg)
|
||||
struct thread *td;
|
||||
void (*func) __P((void *));
|
||||
void *arg;
|
||||
{
|
||||
@ -237,18 +244,18 @@ cpu_set_fork_handler(p, func, arg)
|
||||
* Note that the trap frame follows the args, so the function
|
||||
* is really called like this: func(arg, frame);
|
||||
*/
|
||||
p->p_addr->u_pcb.pcb_esi = (int) func; /* function */
|
||||
p->p_addr->u_pcb.pcb_ebx = (int) arg; /* first arg */
|
||||
td->td_pcb->pcb_esi = (int) func; /* function */
|
||||
td->td_pcb->pcb_ebx = (int) arg; /* first arg */
|
||||
}
|
||||
|
||||
void
|
||||
cpu_exit(p)
|
||||
register struct proc *p;
|
||||
cpu_exit(td)
|
||||
register struct thread *td;
|
||||
{
|
||||
struct pcb *pcb = &p->p_addr->u_pcb;
|
||||
struct pcb *pcb = td->td_pcb;
|
||||
|
||||
#ifdef DEV_NPX
|
||||
npxexit(p);
|
||||
npxexit(td);
|
||||
#endif
|
||||
if (pcb->pcb_ext != 0) {
|
||||
/*
|
||||
@ -280,25 +287,29 @@ cpu_wait(p)
|
||||
* Dump the machine specific header information at the start of a core dump.
|
||||
*/
|
||||
int
|
||||
cpu_coredump(p, vp, cred)
|
||||
struct proc *p;
|
||||
cpu_coredump(td, vp, cred)
|
||||
struct thread *td;
|
||||
struct vnode *vp;
|
||||
struct ucred *cred;
|
||||
{
|
||||
struct proc *p = td->td_proc;
|
||||
int error;
|
||||
caddr_t tempuser;
|
||||
|
||||
tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK | M_ZERO);
|
||||
tempuser = malloc(ctob(UAREA_PAGES + KSTACK_PAGES), M_TEMP, M_WAITOK | M_ZERO);
|
||||
if (!tempuser)
|
||||
return EINVAL;
|
||||
|
||||
bcopy(p->p_addr, tempuser, sizeof(struct user));
|
||||
bcopy(p->p_frame,
|
||||
tempuser + ((caddr_t) p->p_frame - (caddr_t) p->p_addr),
|
||||
bcopy(p->p_uarea, tempuser, sizeof(struct user));
|
||||
#if 0 /* XXXKSE - broken, fixme!!!!! td_frame is in kstack! */
|
||||
bcopy(td->td_frame,
|
||||
tempuser + ((caddr_t) td->td_frame - (caddr_t) p->p_uarea),
|
||||
sizeof(struct trapframe));
|
||||
#endif
|
||||
|
||||
error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, ctob(UPAGES),
|
||||
(off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p);
|
||||
error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser,
|
||||
ctob(UAREA_PAGES + KSTACK_PAGES),
|
||||
(off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, td);
|
||||
|
||||
free(tempuser, M_TEMP);
|
||||
|
||||
|
@ -56,8 +56,8 @@
|
||||
|
||||
#define cpu_exec(p) /* nothing */
|
||||
#define cpu_swapin(p) /* nothing */
|
||||
#define cpu_getstack(p) ((p)->p_frame->tf_esp)
|
||||
#define cpu_setstack(p, ap) ((p)->p_frame->tf_esp = (ap))
|
||||
#define cpu_getstack(td) ((td)->td_frame->tf_esp)
|
||||
#define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap))
|
||||
|
||||
#define TRAPF_USERMODE(framep) \
|
||||
((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM))
|
||||
|
@ -142,7 +142,7 @@ union savefpu {
|
||||
|
||||
#ifdef _KERNEL
|
||||
int npxdna __P((void));
|
||||
void npxexit __P((struct proc *p));
|
||||
void npxexit __P((struct thread *td));
|
||||
void npxinit __P((int control));
|
||||
void npxsave __P((union savefpu *addr));
|
||||
int npxtrap __P((void));
|
||||
|
@ -61,7 +61,7 @@ extern char sigcode[];
|
||||
extern int szsigcode, szosigcode;
|
||||
|
||||
typedef void alias_for_inthand_t __P((u_int cs, u_int ef, u_int esp, u_int ss));
|
||||
struct proc;
|
||||
struct thread;
|
||||
struct reg;
|
||||
struct fpreg;
|
||||
struct dbreg;
|
||||
@ -80,9 +80,9 @@ void doreti_popl_es __P((void)) __asm(__STRING(doreti_popl_es));
|
||||
void doreti_popl_es_fault __P((void)) __asm(__STRING(doreti_popl_es_fault));
|
||||
void doreti_popl_fs __P((void)) __asm(__STRING(doreti_popl_fs));
|
||||
void doreti_popl_fs_fault __P((void)) __asm(__STRING(doreti_popl_fs_fault));
|
||||
int fill_fpregs __P((struct proc *, struct fpreg *));
|
||||
int fill_regs __P((struct proc *p, struct reg *regs));
|
||||
int fill_dbregs __P((struct proc *p, struct dbreg *dbregs));
|
||||
int fill_fpregs __P((struct thread *, struct fpreg *));
|
||||
int fill_regs __P((struct thread *p, struct reg *regs));
|
||||
int fill_dbregs __P((struct thread *p, struct dbreg *dbregs));
|
||||
void fillw __P((int /*u_short*/ pat, void *base, size_t cnt));
|
||||
void i486_bzero __P((void *buf, size_t len));
|
||||
void i586_bcopy __P((const void *from, void *to, size_t len));
|
||||
|
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "opt_cpu.h"
|
||||
#include "opt_upages.h"
|
||||
#include "opt_kstack_pages.h"
|
||||
|
||||
#ifdef SMP
|
||||
#include <machine/smptests.h>
|
||||
@ -1960,8 +1960,8 @@ start_all_aps(u_int boot_addr)
|
||||
SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
|
||||
|
||||
/* allocate and set up an idle stack data page */
|
||||
stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
|
||||
for (i = 0; i < UPAGES; i++)
|
||||
stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */
|
||||
for (i = 0; i < KSTACK_PAGES; i++)
|
||||
SMPpt[pg + 1 + i] = (pt_entry_t)
|
||||
(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
|
||||
|
||||
@ -1977,7 +1977,7 @@ start_all_aps(u_int boot_addr)
|
||||
outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
|
||||
#endif
|
||||
|
||||
bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
|
||||
bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE];
|
||||
bootAP = x;
|
||||
|
||||
/* attempt to start the Application Processor */
|
||||
@ -2019,8 +2019,8 @@ start_all_aps(u_int boot_addr)
|
||||
*/
|
||||
|
||||
/* Allocate and setup BSP idle stack */
|
||||
stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
|
||||
for (i = 0; i < UPAGES; i++)
|
||||
stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE);
|
||||
for (i = 0; i < KSTACK_PAGES; i++)
|
||||
SMPpt[1 + i] = (pt_entry_t)
|
||||
(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
|
||||
|
||||
@ -2241,7 +2241,7 @@ ap_init(void)
|
||||
* Set curproc to our per-cpu idleproc so that mutexes have
|
||||
* something unique to lock with.
|
||||
*/
|
||||
PCPU_SET(curproc, PCPU_GET(idleproc));
|
||||
PCPU_SET(curthread, PCPU_GET(idlethread));
|
||||
PCPU_SET(spinlocks, NULL);
|
||||
|
||||
/* lock against other AP's that are waking up */
|
||||
@ -2323,7 +2323,7 @@ forwarded_statclock(struct trapframe frame)
|
||||
{
|
||||
|
||||
mtx_lock_spin(&sched_lock);
|
||||
statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame));
|
||||
statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame));
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
@ -2354,7 +2354,7 @@ forwarded_hardclock(struct trapframe frame)
|
||||
{
|
||||
|
||||
mtx_lock_spin(&sched_lock);
|
||||
hardclock_process(curproc, TRAPF_USERMODE(&frame));
|
||||
hardclock_process(curthread, TRAPF_USERMODE(&frame));
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ extern struct mtx clock_lock;
|
||||
pushl %ecx ; \
|
||||
pushl %ebx ; \
|
||||
movl $(MTX_UNOWNED) , %eax ; \
|
||||
movl PCPU(CURPROC), %ebx ; \
|
||||
movl PCPU(CURTHREAD), %ebx ; \
|
||||
pushfl ; \
|
||||
popl %ecx ; \
|
||||
cli ; \
|
||||
|
@ -142,7 +142,7 @@ union savefpu {
|
||||
|
||||
#ifdef _KERNEL
|
||||
int npxdna __P((void));
|
||||
void npxexit __P((struct proc *p));
|
||||
void npxexit __P((struct thread *td));
|
||||
void npxinit __P((int control));
|
||||
void npxsave __P((union savefpu *addr));
|
||||
int npxtrap __P((void));
|
||||
|
@ -53,7 +53,7 @@ struct pcb_ldt {
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
int i386_extend_pcb __P((struct proc *));
|
||||
int i386_extend_pcb __P((struct thread *));
|
||||
void set_user_ldt __P((struct pcb *));
|
||||
struct pcb_ldt *user_ldt_alloc __P((struct pcb *, int));
|
||||
void user_ldt_free __P((struct pcb *));
|
||||
|
@ -52,19 +52,19 @@
|
||||
* other processors"
|
||||
*/
|
||||
struct globaldata {
|
||||
struct globaldata *gd_prvspace; /* self-reference */
|
||||
struct proc *gd_curproc; /* current process */
|
||||
struct proc *gd_idleproc; /* idle process */
|
||||
struct proc *gd_npxproc;
|
||||
struct pcb *gd_curpcb; /* current pcb */
|
||||
struct timeval gd_switchtime;
|
||||
struct i386tss gd_common_tss;
|
||||
int gd_switchticks;
|
||||
struct segment_descriptor gd_common_tssd;
|
||||
struct segment_descriptor *gd_tss_gdt;
|
||||
int gd_currentldt;
|
||||
u_int gd_cpuid; /* this cpu number */
|
||||
u_int gd_other_cpus; /* all other cpus */
|
||||
struct globaldata *gd_prvspace; /* self-reference */
|
||||
struct thread *gd_curthread;
|
||||
struct thread *gd_npxthread;
|
||||
struct pcb *gd_curpcb;
|
||||
struct thread *gd_idlethread;
|
||||
struct timeval gd_switchtime;
|
||||
struct i386tss gd_common_tss;
|
||||
int gd_switchticks;
|
||||
struct segment_descriptor gd_common_tssd;
|
||||
struct segment_descriptor *gd_tss_gdt;
|
||||
int gd_currentldt;
|
||||
u_int gd_cpuid;
|
||||
u_int gd_other_cpus;
|
||||
SLIST_ENTRY(globaldata) gd_allcpu;
|
||||
struct lock_list_entry *gd_spinlocks;
|
||||
#ifdef KTR_PERCPU
|
||||
|
@ -42,6 +42,9 @@
|
||||
/*
|
||||
* Machine-dependent part of the proc structure for i386.
|
||||
*/
|
||||
struct mdthread {
|
||||
};
|
||||
|
||||
struct mdproc {
|
||||
};
|
||||
|
||||
|
@ -143,10 +143,10 @@ struct dbreg {
|
||||
/*
|
||||
* XXX these interfaces are MI, so they should be declared in a MI place.
|
||||
*/
|
||||
int set_fpregs __P((struct proc *, struct fpreg *));
|
||||
int set_regs __P((struct proc *p, struct reg *regs));
|
||||
void setregs __P((struct proc *, u_long, u_long, u_long));
|
||||
int set_dbregs __P((struct proc *p, struct dbreg *dbregs));
|
||||
int set_fpregs __P((struct thread *, struct fpreg *));
|
||||
int set_regs __P((struct thread *p, struct reg *regs));
|
||||
void setregs __P((struct thread *, u_long, u_long, u_long));
|
||||
int set_dbregs __P((struct thread *p, struct dbreg *dbregs));
|
||||
#endif
|
||||
|
||||
#endif /* !_MACHINE_REG_H_ */
|
||||
|
@ -61,8 +61,8 @@ IDTVEC(vec_name) ; \
|
||||
mov $KPSEL,%ax ; \
|
||||
mov %ax,%fs ; \
|
||||
FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%esp)) ; \
|
||||
movl PCPU(CURPROC),%ebx ; \
|
||||
incl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
movl PCPU(CURTHREAD),%ebx ; \
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
pushl intr_unit + (irq_num) * 4 ; \
|
||||
call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
|
||||
enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \
|
||||
@ -70,7 +70,7 @@ IDTVEC(vec_name) ; \
|
||||
incl cnt+V_INTR ; /* book-keeping can wait */ \
|
||||
movl intr_countp + (irq_num) * 4,%eax ; \
|
||||
incl (%eax) ; \
|
||||
decl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
MEXITCOUNT ; \
|
||||
jmp doreti
|
||||
|
||||
@ -104,14 +104,14 @@ IDTVEC(vec_name) ; \
|
||||
movb %al,imen + IRQ_BYTE(irq_num) ; \
|
||||
outb %al,$icu+ICU_IMR_OFFSET ; \
|
||||
enable_icus ; \
|
||||
movl PCPU(CURPROC),%ebx ; \
|
||||
incl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
movl PCPU(CURTHREAD),%ebx ; \
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
__CONCAT(Xresume,irq_num): ; \
|
||||
FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \
|
||||
pushl $irq_num; /* pass the IRQ */ \
|
||||
call sched_ithd ; \
|
||||
addl $4, %esp ; /* discard the parameter */ \
|
||||
decl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
MEXITCOUNT ; \
|
||||
/* We could usually avoid the following jmp by inlining some of */ \
|
||||
/* doreti, but it's probably better to use less cache. */ \
|
||||
|
@ -61,8 +61,8 @@ IDTVEC(vec_name) ; \
|
||||
mov $KPSEL,%ax ; \
|
||||
mov %ax,%fs ; \
|
||||
FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%esp)) ; \
|
||||
movl PCPU(CURPROC),%ebx ; \
|
||||
incl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
movl PCPU(CURTHREAD),%ebx ; \
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
pushl intr_unit + (irq_num) * 4 ; \
|
||||
call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
|
||||
enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \
|
||||
@ -70,7 +70,7 @@ IDTVEC(vec_name) ; \
|
||||
incl cnt+V_INTR ; /* book-keeping can wait */ \
|
||||
movl intr_countp + (irq_num) * 4,%eax ; \
|
||||
incl (%eax) ; \
|
||||
decl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
MEXITCOUNT ; \
|
||||
jmp doreti
|
||||
|
||||
@ -104,14 +104,14 @@ IDTVEC(vec_name) ; \
|
||||
movb %al,imen + IRQ_BYTE(irq_num) ; \
|
||||
outb %al,$icu+ICU_IMR_OFFSET ; \
|
||||
enable_icus ; \
|
||||
movl PCPU(CURPROC),%ebx ; \
|
||||
incl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
movl PCPU(CURTHREAD),%ebx ; \
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
__CONCAT(Xresume,irq_num): ; \
|
||||
FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \
|
||||
pushl $irq_num; /* pass the IRQ */ \
|
||||
call sched_ithd ; \
|
||||
addl $4, %esp ; /* discard the parameter */ \
|
||||
decl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
MEXITCOUNT ; \
|
||||
/* We could usually avoid the following jmp by inlining some of */ \
|
||||
/* doreti, but it's probably better to use less cache. */ \
|
||||
|
@ -61,8 +61,8 @@ IDTVEC(vec_name) ; \
|
||||
mov $KPSEL,%ax ; \
|
||||
mov %ax,%fs ; \
|
||||
FAKE_MCOUNT((12+ACTUALLY_PUSHED)*4(%esp)) ; \
|
||||
movl PCPU(CURPROC),%ebx ; \
|
||||
incl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
movl PCPU(CURTHREAD),%ebx ; \
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
pushl intr_unit + (irq_num) * 4 ; \
|
||||
call *intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
|
||||
enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \
|
||||
@ -70,7 +70,7 @@ IDTVEC(vec_name) ; \
|
||||
incl cnt+V_INTR ; /* book-keeping can wait */ \
|
||||
movl intr_countp + (irq_num) * 4,%eax ; \
|
||||
incl (%eax) ; \
|
||||
decl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
MEXITCOUNT ; \
|
||||
jmp doreti
|
||||
|
||||
@ -104,14 +104,14 @@ IDTVEC(vec_name) ; \
|
||||
movb %al,imen + IRQ_BYTE(irq_num) ; \
|
||||
outb %al,$icu+ICU_IMR_OFFSET ; \
|
||||
enable_icus ; \
|
||||
movl PCPU(CURPROC),%ebx ; \
|
||||
incl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
movl PCPU(CURTHREAD),%ebx ; \
|
||||
incl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
__CONCAT(Xresume,irq_num): ; \
|
||||
FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \
|
||||
pushl $irq_num; /* pass the IRQ */ \
|
||||
call sched_ithd ; \
|
||||
addl $4, %esp ; /* discard the parameter */ \
|
||||
decl P_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
decl TD_INTR_NESTING_LEVEL(%ebx) ; \
|
||||
MEXITCOUNT ; \
|
||||
/* We could usually avoid the following jmp by inlining some of */ \
|
||||
/* doreti, but it's probably better to use less cache. */ \
|
||||
|
@ -128,23 +128,23 @@ void stop_emulating __P((void));
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#ifdef CPU_ENABLE_SSE
|
||||
#define GET_FPU_CW(proc) \
|
||||
#define GET_FPU_CW(thread) \
|
||||
(cpu_fxsr ? \
|
||||
(proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_cw : \
|
||||
(proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw)
|
||||
#define GET_FPU_SW(proc) \
|
||||
(thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_cw : \
|
||||
(thread)->td_pcb->pcb_save.sv_87.sv_env.en_cw)
|
||||
#define GET_FPU_SW(thread) \
|
||||
(cpu_fxsr ? \
|
||||
(proc)->p_addr->u_pcb.pcb_save.sv_xmm.sv_env.en_sw : \
|
||||
(proc)->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw)
|
||||
(thread)->td_pcb->pcb_save.sv_xmm.sv_env.en_sw : \
|
||||
(thread)->td_pcb->pcb_save.sv_87.sv_env.en_sw)
|
||||
#define GET_FPU_EXSW_PTR(pcb) \
|
||||
(cpu_fxsr ? \
|
||||
&(pcb)->pcb_save.sv_xmm.sv_ex_sw : \
|
||||
&(pcb)->pcb_save.sv_87.sv_ex_sw)
|
||||
#else /* CPU_ENABLE_SSE */
|
||||
#define GET_FPU_CW(proc) \
|
||||
(proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_cw)
|
||||
#define GET_FPU_SW(proc) \
|
||||
(proc->p_addr->u_pcb.pcb_save.sv_87.sv_env.en_sw)
|
||||
#define GET_FPU_CW(thread) \
|
||||
(thread->td_pcb->pcb_save.sv_87.sv_env.en_cw)
|
||||
#define GET_FPU_SW(thread) \
|
||||
(thread->td_pcb->pcb_save.sv_87.sv_env.en_sw)
|
||||
#define GET_FPU_EXSW_PTR(pcb) \
|
||||
(&(pcb)->pcb_save.sv_87.sv_ex_sw)
|
||||
#endif /* CPU_ENABLE_SSE */
|
||||
@ -241,7 +241,7 @@ static void
|
||||
npx_intr(dummy)
|
||||
void *dummy;
|
||||
{
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
|
||||
/*
|
||||
* The BUSY# latch must be cleared in all cases so that the next
|
||||
@ -250,22 +250,22 @@ npx_intr(dummy)
|
||||
outb(0xf0, 0);
|
||||
|
||||
/*
|
||||
* npxproc is normally non-null here. In that case, schedule an
|
||||
* npxthread is normally non-null here. In that case, schedule an
|
||||
* AST to finish the exception handling in the correct context
|
||||
* (this interrupt may occur after the process has entered the
|
||||
* (this interrupt may occur after the thread has entered the
|
||||
* kernel via a syscall or an interrupt). Otherwise, the npx
|
||||
* state of the process that caused this interrupt must have been
|
||||
* pushed to the process' pcb, and clearing of the busy latch
|
||||
* state of the thread that caused this interrupt must have been
|
||||
* pushed to the thread' pcb, and clearing of the busy latch
|
||||
* above has finished the (essentially null) handling of this
|
||||
* interrupt. Control will eventually return to the instruction
|
||||
* that caused it and it will repeat. We will eventually (usually
|
||||
* soon) win the race to handle the interrupt properly.
|
||||
*/
|
||||
p = PCPU_GET(npxproc);
|
||||
if (p != NULL) {
|
||||
p->p_addr->u_pcb.pcb_flags |= PCB_NPXTRAP;
|
||||
td = PCPU_GET(npxthread);
|
||||
if (td != NULL) {
|
||||
td->td_pcb->pcb_flags |= PCB_NPXTRAP;
|
||||
mtx_lock_spin(&sched_lock);
|
||||
p->p_sflag |= PS_ASTPENDING;
|
||||
td->td_kse->ke_flags |= KEF_ASTPENDING;
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
}
|
||||
}
|
||||
@ -570,7 +570,7 @@ npxinit(control)
|
||||
/*
|
||||
* fninit has the same h/w bugs as fnsave. Use the detoxified
|
||||
* fnsave to throw away any junk in the fpu. npxsave() initializes
|
||||
* the fpu and sets npxproc = NULL as important side effects.
|
||||
* the fpu and sets npxthread = NULL as important side effects.
|
||||
*/
|
||||
savecrit = critical_enter();
|
||||
npxsave(&dummy);
|
||||
@ -586,13 +586,13 @@ npxinit(control)
|
||||
* Free coprocessor (if we have it).
|
||||
*/
|
||||
void
|
||||
npxexit(p)
|
||||
struct proc *p;
|
||||
npxexit(td)
|
||||
struct thread *td;
|
||||
{
|
||||
critical_t savecrit;
|
||||
|
||||
savecrit = critical_enter();
|
||||
if (p == PCPU_GET(npxproc))
|
||||
if (td == PCPU_GET(npxthread))
|
||||
npxsave(&PCPU_GET(curpcb)->pcb_save);
|
||||
critical_exit(savecrit);
|
||||
#ifdef NPX_DEBUG
|
||||
@ -607,8 +607,9 @@ npxexit(p)
|
||||
*/
|
||||
if (masked_exceptions & 0x0d)
|
||||
log(LOG_ERR,
|
||||
"pid %d (%s) exited with masked floating point exceptions 0x%02x\n",
|
||||
p->p_pid, p->p_comm, masked_exceptions);
|
||||
"pid %d (%s) exited with masked floating"
|
||||
" point exceptions 0x%02x\n",
|
||||
td->td_proc->p_pid, td->td_proc->p_comm, masked_exceptions);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -809,8 +810,8 @@ npxtrap()
|
||||
u_long *exstat;
|
||||
|
||||
if (!npx_exists) {
|
||||
printf("npxtrap: npxproc = %p, curproc = %p, npx_exists = %d\n",
|
||||
PCPU_GET(npxproc), curproc, npx_exists);
|
||||
printf("npxtrap: npxthread = %p, curthread = %p, npx_exists = %d\n",
|
||||
PCPU_GET(npxthread), curthread, npx_exists);
|
||||
panic("npxtrap from nowhere");
|
||||
}
|
||||
savecrit = critical_enter();
|
||||
@ -820,18 +821,18 @@ npxtrap()
|
||||
* state to memory. Fetch the relevant parts of the state from
|
||||
* wherever they are.
|
||||
*/
|
||||
if (PCPU_GET(npxproc) != curproc) {
|
||||
control = GET_FPU_CW(curproc);
|
||||
status = GET_FPU_SW(curproc);
|
||||
if (PCPU_GET(npxthread) != curthread) {
|
||||
control = GET_FPU_CW(curthread);
|
||||
status = GET_FPU_SW(curthread);
|
||||
} else {
|
||||
fnstcw(&control);
|
||||
fnstsw(&status);
|
||||
}
|
||||
|
||||
exstat = GET_FPU_EXSW_PTR(&curproc->p_addr->u_pcb);
|
||||
exstat = GET_FPU_EXSW_PTR(curthread->td_pcb);
|
||||
*exstat = status;
|
||||
if (PCPU_GET(npxproc) != curproc)
|
||||
GET_FPU_SW(curproc) &= ~0x80bf;
|
||||
if (PCPU_GET(npxthread) != curthread)
|
||||
GET_FPU_SW(curthread) &= ~0x80bf;
|
||||
else
|
||||
fnclex();
|
||||
critical_exit(savecrit);
|
||||
@ -841,7 +842,7 @@ npxtrap()
|
||||
/*
|
||||
* Implement device not available (DNA) exception
|
||||
*
|
||||
* It would be better to switch FP context here (if curproc != npxproc)
|
||||
* It would be better to switch FP context here (if curthread != npxthread)
|
||||
* and not necessarily for every context switch, but it is too hard to
|
||||
* access foreign pcb's.
|
||||
*/
|
||||
@ -853,9 +854,9 @@ npxdna()
|
||||
|
||||
if (!npx_exists)
|
||||
return (0);
|
||||
if (PCPU_GET(npxproc) != NULL) {
|
||||
printf("npxdna: npxproc = %p, curproc = %p\n",
|
||||
PCPU_GET(npxproc), curproc);
|
||||
if (PCPU_GET(npxthread) != NULL) {
|
||||
printf("npxdna: npxthread = %p, curthread = %p\n",
|
||||
PCPU_GET(npxthread), curthread);
|
||||
panic("npxdna");
|
||||
}
|
||||
s = critical_enter();
|
||||
@ -863,7 +864,7 @@ npxdna()
|
||||
/*
|
||||
* Record new context early in case frstor causes an IRQ13.
|
||||
*/
|
||||
PCPU_SET(npxproc, CURPROC);
|
||||
PCPU_SET(npxthread, curthread);
|
||||
|
||||
exstat = GET_FPU_EXSW_PTR(PCPU_GET(curpcb));
|
||||
*exstat = 0;
|
||||
@ -895,13 +896,13 @@ npxdna()
|
||||
* after the process has entered the kernel. It may even be delivered after
|
||||
* the fnsave here completes. A spurious IRQ13 for the fnsave is handled in
|
||||
* the same way as a very-late-arriving non-spurious IRQ13 from user mode:
|
||||
* it is normally ignored at first because we set npxproc to NULL; it is
|
||||
* it is normally ignored at first because we set npxthread to NULL; it is
|
||||
* normally retriggered in npxdna() after return to user mode.
|
||||
*
|
||||
* npxsave() must be called with interrupts disabled, so that it clears
|
||||
* npxproc atomically with saving the state. We require callers to do the
|
||||
* npxthread atomically with saving the state. We require callers to do the
|
||||
* disabling, since most callers need to disable interrupts anyway to call
|
||||
* npxsave() atomically with checking npxproc.
|
||||
* npxsave() atomically with checking npxthread.
|
||||
*
|
||||
* A previous version of npxsave() went to great lengths to excecute fnsave
|
||||
* with interrupts enabled in case executing it froze the CPU. This case
|
||||
@ -917,7 +918,7 @@ npxsave(addr)
|
||||
fpusave(addr);
|
||||
|
||||
start_emulating();
|
||||
PCPU_SET(npxproc, NULL);
|
||||
PCPU_SET(npxthread, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -909,7 +909,7 @@ xptdone(struct cam_periph *periph, union ccb *done_ccb)
|
||||
}
|
||||
|
||||
static int
|
||||
xptopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
xptopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
int unit;
|
||||
|
||||
@ -946,7 +946,7 @@ xptopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
xptclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
xptclose(dev_t dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
int unit;
|
||||
|
||||
@ -969,7 +969,7 @@ xptclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
xptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
||||
xptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
{
|
||||
int unit, error;
|
||||
|
||||
|
@ -873,7 +873,7 @@ cdregister(struct cam_periph *periph, void *arg)
|
||||
}
|
||||
|
||||
static int
|
||||
cdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
cdopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
struct disklabel *label;
|
||||
struct cam_periph *periph;
|
||||
@ -985,7 +985,7 @@ cdopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
cdclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
cdclose(dev_t dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct cd_softc *softc;
|
||||
@ -1806,7 +1806,7 @@ cddone(struct cam_periph *periph, union ccb *done_ccb)
|
||||
}
|
||||
|
||||
static int
|
||||
cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
||||
cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
{
|
||||
|
||||
struct cam_periph *periph;
|
||||
|
@ -424,7 +424,7 @@ chregister(struct cam_periph *periph, void *arg)
|
||||
}
|
||||
|
||||
static int
|
||||
chopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
chopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct ch_softc *softc;
|
||||
@ -474,7 +474,7 @@ chopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
chclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
chclose(dev_t dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct ch_softc *softc;
|
||||
@ -724,7 +724,7 @@ cherror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
|
||||
}
|
||||
|
||||
static int
|
||||
chioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
||||
chioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct ch_softc *softc;
|
||||
|
@ -378,7 +378,7 @@ static SLIST_HEAD(,da_softc) softc_list;
|
||||
static struct extend_array *daperiphs;
|
||||
|
||||
static int
|
||||
daopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
daopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct da_softc *softc;
|
||||
@ -501,7 +501,7 @@ daopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
daclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
daclose(dev_t dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct da_softc *softc;
|
||||
@ -651,7 +651,7 @@ dastrategy(struct bio *bp)
|
||||
#endif
|
||||
|
||||
static int
|
||||
daioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
||||
daioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct da_softc *softc;
|
||||
|
@ -341,7 +341,7 @@ passregister(struct cam_periph *periph, void *arg)
|
||||
}
|
||||
|
||||
static int
|
||||
passopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
passopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct pass_softc *softc;
|
||||
@ -412,7 +412,7 @@ passopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
passclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
passclose(dev_t dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct pass_softc *softc;
|
||||
@ -478,7 +478,7 @@ passdone(struct cam_periph *periph, union ccb *done_ccb)
|
||||
}
|
||||
|
||||
static int
|
||||
passioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
||||
passioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct pass_softc *softc;
|
||||
|
@ -141,7 +141,7 @@ static struct extend_array *ptperiphs;
|
||||
#endif
|
||||
|
||||
static int
|
||||
ptopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
ptopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct pt_softc *softc;
|
||||
@ -185,7 +185,7 @@ ptopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
ptclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
ptclose(dev_t dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct pt_softc *softc;
|
||||
@ -678,7 +678,7 @@ pterror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
|
||||
}
|
||||
|
||||
static int
|
||||
ptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
||||
ptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct pt_softc *softc;
|
||||
|
@ -440,7 +440,7 @@ static struct cdevsw sa_cdevsw = {
|
||||
static struct extend_array *saperiphs;
|
||||
|
||||
static int
|
||||
saopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
saopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct sa_softc *softc;
|
||||
@ -504,7 +504,7 @@ saopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
saclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
saclose(dev_t dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct sa_softc *softc;
|
||||
@ -761,7 +761,7 @@ sastrategy(struct bio *bp)
|
||||
}
|
||||
|
||||
static int
|
||||
saioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p)
|
||||
saioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct sa_softc *softc;
|
||||
|
@ -426,7 +426,7 @@ sesregister(struct cam_periph *periph, void *arg)
|
||||
}
|
||||
|
||||
static int
|
||||
sesopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
sesopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct ses_softc *softc;
|
||||
@ -482,7 +482,7 @@ sesopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
sesclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
sesclose(dev_t dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct ses_softc *softc;
|
||||
@ -539,7 +539,7 @@ seserror(union ccb *ccb, u_int32_t cflags, u_int32_t sflags)
|
||||
}
|
||||
|
||||
static int
|
||||
sesioctl(dev_t dev, u_long cmd, caddr_t arg_addr, int flag, struct proc *p)
|
||||
sesioctl(dev_t dev, u_long cmd, caddr_t arg_addr, int flag, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
ses_encstat tmp;
|
||||
|
@ -551,7 +551,7 @@ targdtor(struct cam_periph *periph)
|
||||
}
|
||||
|
||||
static int
|
||||
targopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
targopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct targ_softc *softc;
|
||||
@ -610,7 +610,7 @@ targopen(dev_t dev, int flags, int fmt, struct proc *p)
|
||||
}
|
||||
|
||||
static int
|
||||
targclose(dev_t dev, int flag, int fmt, struct proc *p)
|
||||
targclose(dev_t dev, int flag, int fmt, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct targ_softc *softc;
|
||||
@ -807,7 +807,7 @@ targfreeinstance(struct ioc_alloc_unit *alloc_unit)
|
||||
}
|
||||
|
||||
static int
|
||||
targioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
|
||||
targioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct targ_softc *softc;
|
||||
@ -1080,7 +1080,7 @@ targsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb)
|
||||
|
||||
|
||||
static int
|
||||
targpoll(dev_t dev, int poll_events, struct proc *p)
|
||||
targpoll(dev_t dev, int poll_events, struct thread *td)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct targ_softc *softc;
|
||||
@ -1117,9 +1117,9 @@ targpoll(dev_t dev, int poll_events, struct proc *p)
|
||||
|
||||
if (revents == 0) {
|
||||
if (poll_events & (POLLOUT | POLLWRNORM))
|
||||
selrecord(p, &softc->rcv_select);
|
||||
selrecord(td, &softc->rcv_select);
|
||||
if (poll_events & (POLLIN | POLLRDNORM))
|
||||
selrecord(p, &softc->snd_select);
|
||||
selrecord(td, &softc->snd_select);
|
||||
}
|
||||
splx(s);
|
||||
return (revents);
|
||||
|
@ -117,11 +117,11 @@ vcodaattach(n)
|
||||
}
|
||||
|
||||
int
|
||||
vc_nb_open(dev, flag, mode, p)
|
||||
vc_nb_open(dev, flag, mode, td)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
int mode;
|
||||
struct proc *p; /* NetBSD only */
|
||||
struct thread *td; /* NetBSD only */
|
||||
{
|
||||
register struct vcomm *vcp;
|
||||
|
||||
@ -149,11 +149,11 @@ vc_nb_open(dev, flag, mode, p)
|
||||
}
|
||||
|
||||
int
|
||||
vc_nb_close (dev, flag, mode, p)
|
||||
vc_nb_close (dev, flag, mode, td)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
int mode;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
register struct vcomm *vcp;
|
||||
register struct vmsg *vmp, *nvmp = NULL;
|
||||
@ -225,7 +225,7 @@ vc_nb_close (dev, flag, mode, p)
|
||||
#endif
|
||||
}
|
||||
|
||||
err = dounmount(mi->mi_vfsp, flag, p);
|
||||
err = dounmount(mi->mi_vfsp, flag, td);
|
||||
if (err)
|
||||
myprintf(("Error %d unmounting vfs in vcclose(%d)\n",
|
||||
err, minor(dev)));
|
||||
@ -387,12 +387,12 @@ vc_nb_write(dev, uiop, flag)
|
||||
}
|
||||
|
||||
int
|
||||
vc_nb_ioctl(dev, cmd, addr, flag, p)
|
||||
vc_nb_ioctl(dev, cmd, addr, flag, td)
|
||||
dev_t dev;
|
||||
u_long cmd;
|
||||
caddr_t addr;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
ENTRY;
|
||||
|
||||
@ -441,10 +441,10 @@ vc_nb_ioctl(dev, cmd, addr, flag, p)
|
||||
}
|
||||
|
||||
int
|
||||
vc_nb_poll(dev, events, p)
|
||||
vc_nb_poll(dev, events, td)
|
||||
dev_t dev;
|
||||
int events;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
register struct vcomm *vcp;
|
||||
int event_msk = 0;
|
||||
@ -463,7 +463,7 @@ vc_nb_poll(dev, events, p)
|
||||
if (!EMPTY(vcp->vc_requests))
|
||||
return(events & (POLLIN|POLLRDNORM));
|
||||
|
||||
selrecord(p, &(vcp->vc_selproc));
|
||||
selrecord(curthread, &(vcp->vc_selproc));
|
||||
|
||||
return(0);
|
||||
}
|
||||
@ -490,7 +490,8 @@ coda_call(mntinfo, inSize, outSize, buffer)
|
||||
struct vmsg *vmp;
|
||||
int error;
|
||||
#ifdef CTL_C
|
||||
struct proc *p = curproc;
|
||||
struct thread *td = curthread;
|
||||
struct proc *p = td->td_proc;
|
||||
sigset_t psig_omask;
|
||||
sigset_t tempset;
|
||||
int i;
|
||||
|
@ -31,9 +31,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
int vc_nb_open(dev_t dev, int flag, int mode, struct proc *p);
|
||||
int vc_nb_close (dev_t dev, int flag, int mode, struct proc *p);
|
||||
int vc_nb_open(dev_t dev, int flag, int mode, struct thread *p);
|
||||
int vc_nb_close (dev_t dev, int flag, int mode, struct thread *p);
|
||||
int vc_nb_read(dev_t dev, struct uio *uiop, int flag);
|
||||
int vc_nb_write(dev_t dev, struct uio *uiop, int flag);
|
||||
int vc_nb_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p);
|
||||
int vc_nb_poll(dev_t dev, int events, struct proc *p);
|
||||
int vc_nb_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *p);
|
||||
int vc_nb_poll(dev_t dev, int events, struct thread *p);
|
||||
|
@ -83,7 +83,7 @@ struct coda_op_stats coda_vfsopstats[CODA_VFSOPS_SIZE];
|
||||
#define MRAK_INT_GEN(op) (coda_vfsopstats[op].gen_intrn++)
|
||||
|
||||
extern int coda_nc_initialized; /* Set if cache has been initialized */
|
||||
extern int vc_nb_open __P((dev_t, int, int, struct proc *));
|
||||
extern int vc_nb_open __P((dev_t, int, int, struct thread *));
|
||||
|
||||
int
|
||||
coda_vfsopstats_init(void)
|
||||
@ -107,12 +107,12 @@ coda_vfsopstats_init(void)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
coda_mount(vfsp, path, data, ndp, p)
|
||||
coda_mount(vfsp, path, data, ndp, td)
|
||||
struct mount *vfsp; /* Allocated and initialized by mount(2) */
|
||||
char *path; /* path covered: ignored by the fs-layer */
|
||||
caddr_t data; /* Need to define a data type for this in netbsd? */
|
||||
struct nameidata *ndp; /* Clobber this to lookup the device name */
|
||||
struct proc *p; /* The ever-famous proc pointer */
|
||||
struct thread *td; /* The ever-famous proc pointer */
|
||||
{
|
||||
struct vnode *dvp;
|
||||
struct cnode *cp;
|
||||
@ -135,7 +135,7 @@ coda_mount(vfsp, path, data, ndp, p)
|
||||
}
|
||||
|
||||
/* Validate mount device. Similar to getmdev(). */
|
||||
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, p);
|
||||
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, td);
|
||||
error = namei(ndp);
|
||||
dvp = ndp->ni_vp;
|
||||
|
||||
@ -233,10 +233,10 @@ coda_mount(vfsp, path, data, ndp, p)
|
||||
}
|
||||
|
||||
int
|
||||
coda_unmount(vfsp, mntflags, p)
|
||||
coda_unmount(vfsp, mntflags, td)
|
||||
struct mount *vfsp;
|
||||
int mntflags;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
struct coda_mntinfo *mi = vftomi(vfsp);
|
||||
int active, error = 0;
|
||||
@ -292,8 +292,12 @@ coda_root(vfsp, vpp)
|
||||
struct coda_mntinfo *mi = vftomi(vfsp);
|
||||
struct vnode **result;
|
||||
int error;
|
||||
struct proc *p = curproc; /* XXX - bnoble */
|
||||
struct thread *td = curthread; /* XXX - bnoble */
|
||||
struct proc *p = td->td_proc;
|
||||
ViceFid VFid;
|
||||
|
||||
ENTRY;
|
||||
|
||||
|
||||
ENTRY;
|
||||
MARK_ENTRY(CODA_ROOT_STATS);
|
||||
@ -308,9 +312,9 @@ coda_root(vfsp, vpp)
|
||||
/* On Mach, this is vref. On NetBSD, VOP_LOCK */
|
||||
#if 1
|
||||
vref(*vpp);
|
||||
vn_lock(*vpp, LK_EXCLUSIVE, p);
|
||||
vn_lock(*vpp, LK_EXCLUSIVE, td);
|
||||
#else
|
||||
vget(*vpp, LK_EXCLUSIVE, p);
|
||||
vget(*vpp, LK_EXCLUSIVE, td);
|
||||
#endif
|
||||
MARK_INT_SAT(CODA_ROOT_STATS);
|
||||
return(0);
|
||||
@ -331,9 +335,9 @@ coda_root(vfsp, vpp)
|
||||
*vpp = mi->mi_rootvp;
|
||||
#if 1
|
||||
vref(*vpp);
|
||||
vn_lock(*vpp, LK_EXCLUSIVE, p);
|
||||
vn_lock(*vpp, LK_EXCLUSIVE, td);
|
||||
#else
|
||||
vget(*vpp, LK_EXCLUSIVE, p);
|
||||
vget(*vpp, LK_EXCLUSIVE, td);
|
||||
#endif
|
||||
|
||||
MARK_INT_SAT(CODA_ROOT_STATS);
|
||||
@ -351,9 +355,9 @@ coda_root(vfsp, vpp)
|
||||
*vpp = mi->mi_rootvp;
|
||||
#if 1
|
||||
vref(*vpp);
|
||||
vn_lock(*vpp, LK_EXCLUSIVE, p);
|
||||
vn_lock(*vpp, LK_EXCLUSIVE, td);
|
||||
#else
|
||||
vget(*vpp, LK_EXCLUSIVE, p);
|
||||
vget(*vpp, LK_EXCLUSIVE, td);
|
||||
#endif
|
||||
|
||||
MARK_INT_FAIL(CODA_ROOT_STATS);
|
||||
@ -374,10 +378,10 @@ coda_root(vfsp, vpp)
|
||||
* Get file system statistics.
|
||||
*/
|
||||
int
|
||||
coda_nb_statfs(vfsp, sbp, p)
|
||||
coda_nb_statfs(vfsp, sbp, td)
|
||||
register struct mount *vfsp;
|
||||
struct statfs *sbp;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
ENTRY;
|
||||
/* MARK_ENTRY(CODA_STATFS_STATS); */
|
||||
@ -412,11 +416,11 @@ coda_nb_statfs(vfsp, sbp, p)
|
||||
* Flush any pending I/O.
|
||||
*/
|
||||
int
|
||||
coda_sync(vfsp, waitfor, cred, p)
|
||||
coda_sync(vfsp, waitfor, cred, td)
|
||||
struct mount *vfsp;
|
||||
int waitfor;
|
||||
struct ucred *cred;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
ENTRY;
|
||||
MARK_ENTRY(CODA_SYNC_STATS);
|
||||
@ -441,7 +445,8 @@ coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp)
|
||||
struct cfid *cfid = (struct cfid *)fhp;
|
||||
struct cnode *cp = 0;
|
||||
int error;
|
||||
struct proc *p = curproc; /* XXX -mach */
|
||||
struct thread *td = curthread; /* XXX -mach */
|
||||
struct proc *p = td->td_proc;
|
||||
ViceFid VFid;
|
||||
int vtype;
|
||||
|
||||
|
@ -48,13 +48,13 @@ struct mount;
|
||||
|
||||
int coda_vfsopstats_init(void);
|
||||
int coda_mount(struct mount *, char *, caddr_t, struct nameidata *,
|
||||
struct proc *);
|
||||
int coda_start(struct mount *, int, struct proc *);
|
||||
int coda_unmount(struct mount *, int, struct proc *);
|
||||
struct thread *);
|
||||
int coda_start(struct mount *, int, struct thread *);
|
||||
int coda_unmount(struct mount *, int, struct thread *);
|
||||
int coda_root(struct mount *, struct vnode **);
|
||||
int coda_quotactl(struct mount *, int, uid_t, caddr_t, struct proc *);
|
||||
int coda_nb_statfs(struct mount *, struct statfs *, struct proc *);
|
||||
int coda_sync(struct mount *, int, struct ucred *, struct proc *);
|
||||
int coda_quotactl(struct mount *, int, uid_t, caddr_t, struct thread *);
|
||||
int coda_nb_statfs(struct mount *, struct statfs *, struct thread *);
|
||||
int coda_sync(struct mount *, int, struct ucred *, struct thread *);
|
||||
int coda_vget(struct mount *, ino_t, struct vnode **);
|
||||
int coda_fhtovp(struct mount *, struct fid *, struct mbuf *, struct vnode **,
|
||||
int *, struct ucred **);
|
||||
|
@ -235,7 +235,7 @@ coda_open(v)
|
||||
struct cnode *cp = VTOC(*vpp);
|
||||
int flag = ap->a_mode & (~O_EXCL);
|
||||
struct ucred *cred = ap->a_cred;
|
||||
struct proc *p = ap->a_p;
|
||||
struct thread *td = ap->a_td;
|
||||
/* locals */
|
||||
int error;
|
||||
struct vnode *vp;
|
||||
@ -256,7 +256,7 @@ coda_open(v)
|
||||
return(0);
|
||||
}
|
||||
|
||||
error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, p, &dev, &inode);
|
||||
error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, td->td_proc, &dev, &inode);
|
||||
if (error)
|
||||
return (error);
|
||||
if (!error) {
|
||||
@ -272,7 +272,7 @@ coda_open(v)
|
||||
return (error);
|
||||
|
||||
/* We get the vnode back locked. Needs unlocked */
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
VOP_UNLOCK(vp, 0, td);
|
||||
/* Keep a reference until the close comes in. */
|
||||
vref(*vpp);
|
||||
|
||||
@ -297,14 +297,14 @@ coda_open(v)
|
||||
cp->c_inode = inode;
|
||||
|
||||
/* Open the cache file. */
|
||||
error = VOP_OPEN(vp, flag, cred, p);
|
||||
error = VOP_OPEN(vp, flag, cred, td);
|
||||
if (error) {
|
||||
printf("coda_open: VOP_OPEN on container failed %d\n", error);
|
||||
return (error);
|
||||
}
|
||||
/* grab (above) does this when it calls newvnode unless it's in the cache*/
|
||||
if (vp->v_type == VREG) {
|
||||
error = vfs_object_create(vp, p, cred);
|
||||
error = vfs_object_create(vp, td, cred);
|
||||
if (error != 0) {
|
||||
printf("coda_open: vfs_object_create() returns %d\n", error);
|
||||
vput(vp);
|
||||
@ -327,7 +327,7 @@ coda_close(v)
|
||||
struct cnode *cp = VTOC(vp);
|
||||
int flag = ap->a_fflag;
|
||||
struct ucred *cred = ap->a_cred;
|
||||
struct proc *p = ap->a_p;
|
||||
struct thread *td = ap->a_td;
|
||||
/* locals */
|
||||
int error;
|
||||
|
||||
@ -348,7 +348,7 @@ coda_close(v)
|
||||
#ifdef hmm
|
||||
vgone(cp->c_ovp);
|
||||
#else
|
||||
VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */
|
||||
VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */
|
||||
vrele(cp->c_ovp);
|
||||
#endif
|
||||
} else {
|
||||
@ -358,7 +358,7 @@ coda_close(v)
|
||||
}
|
||||
return ENODEV;
|
||||
} else {
|
||||
VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */
|
||||
VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */
|
||||
vrele(cp->c_ovp);
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ coda_close(v)
|
||||
if (flag & FWRITE) /* file was opened for write */
|
||||
--cp->c_owrite;
|
||||
|
||||
error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, p);
|
||||
error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, td->td_proc);
|
||||
vrele(CTOV(cp));
|
||||
|
||||
CODADEBUG(CODA_CLOSE, myprintf(("close: result %d\n",error)); )
|
||||
@ -383,7 +383,7 @@ coda_read(v)
|
||||
|
||||
ENTRY;
|
||||
return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_READ,
|
||||
ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp));
|
||||
ap->a_ioflag, ap->a_cred, ap->a_uio->uio_td));
|
||||
}
|
||||
|
||||
int
|
||||
@ -394,24 +394,25 @@ coda_write(v)
|
||||
|
||||
ENTRY;
|
||||
return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_WRITE,
|
||||
ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp));
|
||||
ap->a_ioflag, ap->a_cred, ap->a_uio->uio_td));
|
||||
}
|
||||
|
||||
int
|
||||
coda_rdwr(vp, uiop, rw, ioflag, cred, p)
|
||||
coda_rdwr(vp, uiop, rw, ioflag, cred, td)
|
||||
struct vnode *vp;
|
||||
struct uio *uiop;
|
||||
enum uio_rw rw;
|
||||
int ioflag;
|
||||
struct ucred *cred;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
/* upcall decl */
|
||||
/* NOTE: container file operation!!! */
|
||||
/* locals */
|
||||
struct cnode *cp = VTOC(vp);
|
||||
struct vnode *cfvp = cp->c_ovp;
|
||||
struct proc *lp = p;
|
||||
struct proc *p = td->td_proc;
|
||||
struct thread *ltd = td;
|
||||
int igot_internally = 0;
|
||||
int opened_internally = 0;
|
||||
int error = 0;
|
||||
@ -448,7 +449,7 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p)
|
||||
PROC_UNLOCK(p);
|
||||
}
|
||||
else
|
||||
lp = curproc;
|
||||
ltd = curthread;
|
||||
|
||||
if (cp->c_inode != 0 && !iscore) {
|
||||
igot_internally = 1;
|
||||
@ -458,23 +459,23 @@ coda_rdwr(vp, uiop, rw, ioflag, cred, p)
|
||||
return(error);
|
||||
}
|
||||
/*
|
||||
* We get the vnode back locked by curproc in both Mach and
|
||||
* We get the vnode back locked by curthread in both Mach and
|
||||
* NetBSD. Needs unlocked
|
||||
*/
|
||||
VOP_UNLOCK(cfvp, 0, lp);
|
||||
VOP_UNLOCK(cfvp, 0, ltd);
|
||||
}
|
||||
else {
|
||||
opened_internally = 1;
|
||||
MARK_INT_GEN(CODA_OPEN_STATS);
|
||||
error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE),
|
||||
cred, p);
|
||||
cred, td);
|
||||
printf("coda_rdwr: Internally Opening %p\n", vp);
|
||||
if (error) {
|
||||
printf("coda_rdwr: VOP_OPEN on container failed %d\n", error);
|
||||
return (error);
|
||||
}
|
||||
if (vp->v_type == VREG) {
|
||||
error = vfs_object_create(vp, p, cred);
|
||||
error = vfs_object_create(vp, td, cred);
|
||||
if (error != 0) {
|
||||
printf("coda_rdwr: vfs_object_create() returns %d\n", error);
|
||||
vput(vp);
|
||||
@ -501,7 +502,7 @@ printf("coda_rdwr: Internally Opening %p\n", vp);
|
||||
|
||||
{ struct vattr attr;
|
||||
|
||||
if (VOP_GETATTR(cfvp, &attr, cred, p) == 0) {
|
||||
if (VOP_GETATTR(cfvp, &attr, cred, td) == 0) {
|
||||
vnode_pager_setsize(vp, attr.va_size);
|
||||
}
|
||||
}
|
||||
@ -515,7 +516,7 @@ printf("coda_rdwr: Internally Opening %p\n", vp);
|
||||
/* Do an internal close if necessary. */
|
||||
if (opened_internally) {
|
||||
MARK_INT_GEN(CODA_CLOSE_STATS);
|
||||
(void)VOP_CLOSE(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, p);
|
||||
(void)VOP_CLOSE(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, td);
|
||||
}
|
||||
|
||||
/* Invalidate cached attributes if writing. */
|
||||
@ -537,7 +538,7 @@ coda_ioctl(v)
|
||||
caddr_t data = ap->a_data;
|
||||
int flag = ap->a_fflag;
|
||||
struct ucred *cred = ap->a_cred;
|
||||
struct proc *p = ap->a_p;
|
||||
struct thread *td = ap->a_td;
|
||||
/* locals */
|
||||
int error;
|
||||
struct vnode *tvp;
|
||||
@ -562,7 +563,7 @@ coda_ioctl(v)
|
||||
/* Should we use the name cache here? It would get it from
|
||||
lookupname sooner or later anyway, right? */
|
||||
|
||||
NDINIT(&ndp, LOOKUP, (iap->follow ? FOLLOW : NOFOLLOW), UIO_USERSPACE, iap->path, p);
|
||||
NDINIT(&ndp, LOOKUP, (iap->follow ? FOLLOW : NOFOLLOW), UIO_USERSPACE, iap->path, td);
|
||||
error = namei(&ndp);
|
||||
tvp = ndp.ni_vp;
|
||||
|
||||
@ -591,7 +592,7 @@ coda_ioctl(v)
|
||||
NDFREE(&ndp, 0);
|
||||
return(EINVAL);
|
||||
}
|
||||
error = venus_ioctl(vtomi(tvp), &((VTOC(tvp))->c_fid), com, flag, data, cred, p);
|
||||
error = venus_ioctl(vtomi(tvp), &((VTOC(tvp))->c_fid), com, flag, data, cred, td->td_proc);
|
||||
|
||||
if (error)
|
||||
MARK_INT_FAIL(CODA_IOCTL_STATS);
|
||||
@ -622,7 +623,7 @@ coda_getattr(v)
|
||||
struct cnode *cp = VTOC(vp);
|
||||
struct vattr *vap = ap->a_vap;
|
||||
struct ucred *cred = ap->a_cred;
|
||||
struct proc *p = ap->a_p;
|
||||
struct thread *td = ap->a_td;
|
||||
/* locals */
|
||||
int error;
|
||||
|
||||
@ -651,7 +652,7 @@ coda_getattr(v)
|
||||
return(0);
|
||||
}
|
||||
|
||||
error = venus_getattr(vtomi(vp), &cp->c_fid, cred, p, vap);
|
||||
error = venus_getattr(vtomi(vp), &cp->c_fid, cred, td->td_proc, vap);
|
||||
|
||||
if (!error) {
|
||||
CODADEBUG(CODA_GETATTR, myprintf(("getattr miss (%lx.%lx.%lx): result %d\n",
|
||||
@ -689,7 +690,7 @@ coda_setattr(v)
|
||||
struct cnode *cp = VTOC(vp);
|
||||
register struct vattr *vap = ap->a_vap;
|
||||
struct ucred *cred = ap->a_cred;
|
||||
struct proc *p = ap->a_p;
|
||||
struct thread *td = ap->a_td;
|
||||
/* locals */
|
||||
int error;
|
||||
|
||||
@ -704,7 +705,7 @@ coda_setattr(v)
|
||||
if (codadebug & CODADBGMSK(CODA_SETATTR)) {
|
||||
print_vattr(vap);
|
||||
}
|
||||
error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, p);
|
||||
error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, td->td_proc);
|
||||
|
||||
if (!error)
|
||||
cp->c_flags &= ~C_VATTR;
|
||||
@ -729,7 +730,7 @@ coda_access(v)
|
||||
struct cnode *cp = VTOC(vp);
|
||||
int mode = ap->a_mode;
|
||||
struct ucred *cred = ap->a_cred;
|
||||
struct proc *p = ap->a_p;
|
||||
struct thread *td = ap->a_td;
|
||||
/* locals */
|
||||
int error;
|
||||
|
||||
@ -758,7 +759,7 @@ coda_access(v)
|
||||
}
|
||||
}
|
||||
|
||||
error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, p);
|
||||
error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, td->td_proc);
|
||||
|
||||
return(error);
|
||||
}
|
||||
@ -773,7 +774,7 @@ coda_readlink(v)
|
||||
struct cnode *cp = VTOC(vp);
|
||||
struct uio *uiop = ap->a_uio;
|
||||
struct ucred *cred = ap->a_cred;
|
||||
struct proc *p = ap->a_uio->uio_procp;
|
||||
struct thread *td = ap->a_uio->uio_td;
|
||||
/* locals */
|
||||
int error;
|
||||
char *str;
|
||||
@ -797,7 +798,7 @@ coda_readlink(v)
|
||||
return(error);
|
||||
}
|
||||
|
||||
error = venus_readlink(vtomi(vp), &cp->c_fid, cred, p, &str, &len);
|
||||
error = venus_readlink(vtomi(vp), &cp->c_fid, cred, td->td_proc, &str, &len);
|
||||
|
||||
if (!error) {
|
||||
uiop->uio_rw = UIO_READ;
|
||||
@ -824,7 +825,7 @@ coda_fsync(v)
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct cnode *cp = VTOC(vp);
|
||||
struct ucred *cred = ap->a_cred;
|
||||
struct proc *p = ap->a_p;
|
||||
struct thread *td = ap->a_td;
|
||||
/* locals */
|
||||
struct vnode *convp = cp->c_ovp;
|
||||
int error;
|
||||
@ -847,7 +848,7 @@ coda_fsync(v)
|
||||
}
|
||||
|
||||
if (convp)
|
||||
VOP_FSYNC(convp, cred, MNT_WAIT, p);
|
||||
VOP_FSYNC(convp, cred, MNT_WAIT, td);
|
||||
|
||||
/*
|
||||
* We see fsyncs with usecount == 1 then usecount == 0.
|
||||
@ -873,7 +874,7 @@ coda_fsync(v)
|
||||
|
||||
/* needs research */
|
||||
return 0;
|
||||
error = venus_fsync(vtomi(vp), &cp->c_fid, cred, p);
|
||||
error = venus_fsync(vtomi(vp), &cp->c_fid, cred, td->td_proc);
|
||||
|
||||
CODADEBUG(CODA_FSYNC, myprintf(("in fsync result %d\n",error)); );
|
||||
return(error);
|
||||
@ -890,7 +891,7 @@ coda_inactive(v)
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct cnode *cp = VTOC(vp);
|
||||
struct ucred *cred __attribute__((unused)) = NULL;
|
||||
struct proc *p __attribute__((unused)) = curproc;
|
||||
struct thread *td __attribute__((unused)) = curthread;
|
||||
/* upcall decl */
|
||||
/* locals */
|
||||
|
||||
@ -930,7 +931,7 @@ coda_inactive(v)
|
||||
printf("coda_inactive: cp->ovp != NULL use %d: vp %p, cp %p\n",
|
||||
vp->v_usecount, vp, cp);
|
||||
#endif
|
||||
lockmgr(&cp->c_lock, LK_RELEASE, &vp->v_interlock, p);
|
||||
lockmgr(&cp->c_lock, LK_RELEASE, &vp->v_interlock, td);
|
||||
} else {
|
||||
#ifdef OLD_DIAGNOSTIC
|
||||
if (CTOV(cp)->v_usecount) {
|
||||
@ -940,7 +941,7 @@ coda_inactive(v)
|
||||
panic("coda_inactive: cp->ovp != NULL");
|
||||
}
|
||||
#endif
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
VOP_UNLOCK(vp, 0, td);
|
||||
vgone(vp);
|
||||
}
|
||||
|
||||
@ -972,7 +973,7 @@ coda_lookup(v)
|
||||
*/
|
||||
struct componentname *cnp = ap->a_cnp;
|
||||
struct ucred *cred = cnp->cn_cred;
|
||||
struct proc *p = cnp->cn_proc;
|
||||
struct thread *td = cnp->cn_thread;
|
||||
/* locals */
|
||||
struct cnode *cp;
|
||||
const char *nm = cnp->cn_nameptr;
|
||||
@ -1015,7 +1016,7 @@ coda_lookup(v)
|
||||
} else {
|
||||
|
||||
/* The name wasn't cached, so we need to contact Venus */
|
||||
error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, p, &VFid, &vtype);
|
||||
error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, td->td_proc, &VFid, &vtype);
|
||||
|
||||
if (error) {
|
||||
MARK_INT_FAIL(CODA_LOOKUP_STATS);
|
||||
@ -1086,7 +1087,7 @@ coda_lookup(v)
|
||||
*/
|
||||
if (!error || (error == EJUSTRETURN)) {
|
||||
if (!(cnp->cn_flags & LOCKPARENT) || !(cnp->cn_flags & ISLASTCN)) {
|
||||
if ((error = VOP_UNLOCK(dvp, 0, p))) {
|
||||
if ((error = VOP_UNLOCK(dvp, 0, td))) {
|
||||
return error;
|
||||
}
|
||||
/*
|
||||
@ -1094,7 +1095,7 @@ coda_lookup(v)
|
||||
* lock it without bothering to check anything else.
|
||||
*/
|
||||
if (*ap->a_vpp) {
|
||||
if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) {
|
||||
if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) {
|
||||
printf("coda_lookup: ");
|
||||
panic("unlocked parent but couldn't lock child");
|
||||
}
|
||||
@ -1103,7 +1104,7 @@ coda_lookup(v)
|
||||
/* The parent is locked, and may be the same as the child */
|
||||
if (*ap->a_vpp && (*ap->a_vpp != dvp)) {
|
||||
/* Different, go ahead and lock it. */
|
||||
if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) {
|
||||
if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) {
|
||||
printf("coda_lookup: ");
|
||||
panic("unlocked parent but couldn't lock child");
|
||||
}
|
||||
@ -1132,7 +1133,7 @@ coda_create(v)
|
||||
struct vnode **vpp = ap->a_vpp;
|
||||
struct componentname *cnp = ap->a_cnp;
|
||||
struct ucred *cred = cnp->cn_cred;
|
||||
struct proc *p = cnp->cn_proc;
|
||||
struct thread *td = cnp->cn_thread;
|
||||
/* locals */
|
||||
int error;
|
||||
struct cnode *cp;
|
||||
@ -1153,7 +1154,7 @@ coda_create(v)
|
||||
return(EACCES);
|
||||
}
|
||||
|
||||
error = venus_create(vtomi(dvp), &dcp->c_fid, nm, len, exclusive, mode, va, cred, p, &VFid, &attr);
|
||||
error = venus_create(vtomi(dvp), &dcp->c_fid, nm, len, exclusive, mode, va, cred, td->td_proc, &VFid, &attr);
|
||||
|
||||
if (!error) {
|
||||
|
||||
@ -1192,7 +1193,7 @@ coda_create(v)
|
||||
|
||||
if (!error) {
|
||||
if (cnp->cn_flags & LOCKLEAF) {
|
||||
if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) {
|
||||
if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) {
|
||||
printf("coda_create: ");
|
||||
panic("unlocked parent but couldn't lock child");
|
||||
}
|
||||
@ -1216,7 +1217,7 @@ coda_remove(v)
|
||||
struct cnode *cp = VTOC(dvp);
|
||||
struct componentname *cnp = ap->a_cnp;
|
||||
struct ucred *cred = cnp->cn_cred;
|
||||
struct proc *p = cnp->cn_proc;
|
||||
struct thread *td = cnp->cn_thread;
|
||||
/* locals */
|
||||
int error;
|
||||
const char *nm = cnp->cn_nameptr;
|
||||
@ -1259,7 +1260,7 @@ coda_remove(v)
|
||||
return(ENOENT);
|
||||
}
|
||||
|
||||
error = venus_remove(vtomi(dvp), &cp->c_fid, nm, len, cred, p);
|
||||
error = venus_remove(vtomi(dvp), &cp->c_fid, nm, len, cred, td->td_proc);
|
||||
|
||||
CODADEBUG(CODA_REMOVE, myprintf(("in remove result %d\n",error)); )
|
||||
|
||||
@ -1278,7 +1279,7 @@ coda_link(v)
|
||||
struct cnode *tdcp = VTOC(tdvp);
|
||||
struct componentname *cnp = ap->a_cnp;
|
||||
struct ucred *cred = cnp->cn_cred;
|
||||
struct proc *p = cnp->cn_proc;
|
||||
struct thread *td = cnp->cn_thread;
|
||||
/* locals */
|
||||
int error;
|
||||
const char *nm = cnp->cn_nameptr;
|
||||
@ -1308,7 +1309,7 @@ coda_link(v)
|
||||
return(EACCES);
|
||||
}
|
||||
|
||||
error = venus_link(vtomi(vp), &cp->c_fid, &tdcp->c_fid, nm, len, cred, p);
|
||||
error = venus_link(vtomi(vp), &cp->c_fid, &tdcp->c_fid, nm, len, cred, td->td_proc);
|
||||
|
||||
/* Invalidate the parent's attr cache, the modification time has changed */
|
||||
VTOC(tdvp)->c_flags &= ~C_VATTR;
|
||||
@ -1332,7 +1333,7 @@ coda_rename(v)
|
||||
struct cnode *ndcp = VTOC(ndvp);
|
||||
struct componentname *tcnp = ap->a_tcnp;
|
||||
struct ucred *cred = fcnp->cn_cred;
|
||||
struct proc *p = fcnp->cn_proc;
|
||||
struct thread *td = fcnp->cn_thread;
|
||||
/* true args */
|
||||
int error;
|
||||
const char *fnm = fcnp->cn_nameptr;
|
||||
@ -1346,7 +1347,7 @@ coda_rename(v)
|
||||
This could be Bad. XXX */
|
||||
#ifdef OLD_DIAGNOSTIC
|
||||
if ((fcnp->cn_cred != tcnp->cn_cred)
|
||||
|| (fcnp->cn_proc != tcnp->cn_proc))
|
||||
|| (fcnp->cn_thread != tcnp->cn_thread))
|
||||
{
|
||||
panic("coda_rename: component names don't agree");
|
||||
}
|
||||
@ -1389,7 +1390,7 @@ coda_rename(v)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
error = venus_rename(vtomi(odvp), &odcp->c_fid, &ndcp->c_fid, fnm, flen, tnm, tlen, cred, p);
|
||||
error = venus_rename(vtomi(odvp), &odcp->c_fid, &ndcp->c_fid, fnm, flen, tnm, tlen, cred, td->td_proc);
|
||||
|
||||
exit:
|
||||
CODADEBUG(CODA_RENAME, myprintf(("in rename result %d\n",error));)
|
||||
@ -1426,7 +1427,7 @@ coda_mkdir(v)
|
||||
register struct vattr *va = ap->a_vap;
|
||||
struct vnode **vpp = ap->a_vpp;
|
||||
struct ucred *cred = cnp->cn_cred;
|
||||
struct proc *p = cnp->cn_proc;
|
||||
struct thread *td = cnp->cn_thread;
|
||||
/* locals */
|
||||
int error;
|
||||
const char *nm = cnp->cn_nameptr;
|
||||
@ -1450,7 +1451,7 @@ coda_mkdir(v)
|
||||
return(EACCES);
|
||||
}
|
||||
|
||||
error = venus_mkdir(vtomi(dvp), &dcp->c_fid, nm, len, va, cred, p, &VFid, &ova);
|
||||
error = venus_mkdir(vtomi(dvp), &dcp->c_fid, nm, len, va, cred, td->td_proc, &VFid, &ova);
|
||||
|
||||
if (!error) {
|
||||
if (coda_find(&VFid) != NULL)
|
||||
@ -1495,7 +1496,7 @@ coda_rmdir(v)
|
||||
struct cnode *dcp = VTOC(dvp);
|
||||
struct componentname *cnp = ap->a_cnp;
|
||||
struct ucred *cred = cnp->cn_cred;
|
||||
struct proc *p = cnp->cn_proc;
|
||||
struct thread *td = cnp->cn_thread;
|
||||
/* true args */
|
||||
int error;
|
||||
const char *nm = cnp->cn_nameptr;
|
||||
@ -1527,7 +1528,7 @@ coda_rmdir(v)
|
||||
/* Invalidate the parent's attr cache, the modification time has changed */
|
||||
dcp->c_flags &= ~C_VATTR;
|
||||
|
||||
error = venus_rmdir(vtomi(dvp), &dcp->c_fid, nm, len, cred, p);
|
||||
error = venus_rmdir(vtomi(dvp), &dcp->c_fid, nm, len, cred, td->td_proc);
|
||||
|
||||
CODADEBUG(CODA_RMDIR, myprintf(("in rmdir result %d\n", error)); )
|
||||
|
||||
@ -1546,7 +1547,7 @@ coda_symlink(v)
|
||||
struct vattr *tva = ap->a_vap;
|
||||
char *path = ap->a_target;
|
||||
struct ucred *cred = cnp->cn_cred;
|
||||
struct proc *p = cnp->cn_proc;
|
||||
struct thread *td = cnp->cn_thread;
|
||||
struct vnode **vpp = ap->a_vpp;
|
||||
/* locals */
|
||||
int error;
|
||||
@ -1589,7 +1590,7 @@ coda_symlink(v)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
error = venus_symlink(vtomi(tdvp), &tdcp->c_fid, path, plen, nm, len, tva, cred, p);
|
||||
error = venus_symlink(vtomi(tdvp), &tdcp->c_fid, path, plen, nm, len, tva, cred, td->td_proc);
|
||||
|
||||
/* Invalidate the parent's attr cache, the modification time has changed */
|
||||
tdcp->c_flags &= ~C_VATTR;
|
||||
@ -1618,7 +1619,7 @@ coda_readdir(v)
|
||||
int *eofflag = ap->a_eofflag;
|
||||
u_long **cookies = ap->a_cookies;
|
||||
int *ncookies = ap->a_ncookies;
|
||||
struct proc *p = ap->a_uio->uio_procp;
|
||||
struct thread *td = ap->a_uio->uio_td;
|
||||
/* upcall decl */
|
||||
/* locals */
|
||||
int error = 0;
|
||||
@ -1643,14 +1644,14 @@ coda_readdir(v)
|
||||
if (cp->c_ovp == NULL) {
|
||||
opened_internally = 1;
|
||||
MARK_INT_GEN(CODA_OPEN_STATS);
|
||||
error = VOP_OPEN(vp, FREAD, cred, p);
|
||||
error = VOP_OPEN(vp, FREAD, cred, td);
|
||||
printf("coda_readdir: Internally Opening %p\n", vp);
|
||||
if (error) {
|
||||
printf("coda_readdir: VOP_OPEN on container failed %d\n", error);
|
||||
return (error);
|
||||
}
|
||||
if (vp->v_type == VREG) {
|
||||
error = vfs_object_create(vp, p, cred);
|
||||
error = vfs_object_create(vp, td, cred);
|
||||
if (error != 0) {
|
||||
printf("coda_readdir: vfs_object_create() returns %d\n", error);
|
||||
vput(vp);
|
||||
@ -1672,7 +1673,7 @@ printf("coda_readdir: Internally Opening %p\n", vp);
|
||||
/* Do an "internal close" if necessary. */
|
||||
if (opened_internally) {
|
||||
MARK_INT_GEN(CODA_CLOSE_STATS);
|
||||
(void)VOP_CLOSE(vp, FREAD, cred, p);
|
||||
(void)VOP_CLOSE(vp, FREAD, cred, td);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1693,7 +1694,7 @@ coda_bmap(v)
|
||||
daddr_t bn __attribute__((unused)) = ap->a_bn; /* fs block number */
|
||||
struct vnode **vpp = ap->a_vpp; /* RETURN vp of device */
|
||||
daddr_t *bnp __attribute__((unused)) = ap->a_bnp; /* RETURN device block number */
|
||||
struct proc *p __attribute__((unused)) = curproc;
|
||||
struct thread *td __attribute__((unused)) = curthread;
|
||||
/* upcall decl */
|
||||
/* locals */
|
||||
|
||||
@ -1731,7 +1732,7 @@ coda_strategy(v)
|
||||
/* true args */
|
||||
struct vop_strategy_args *ap = v;
|
||||
register struct buf *bp __attribute__((unused)) = ap->a_bp;
|
||||
struct proc *p __attribute__((unused)) = curproc;
|
||||
struct thread *td __attribute__((unused)) = curthread;
|
||||
/* upcall decl */
|
||||
/* locals */
|
||||
|
||||
@ -1786,7 +1787,7 @@ coda_lock(v)
|
||||
struct vop_lock_args *ap = v;
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct cnode *cp = VTOC(vp);
|
||||
struct proc *p = ap->a_p;
|
||||
struct thread *td = ap->a_td;
|
||||
/* upcall decl */
|
||||
/* locals */
|
||||
|
||||
@ -1798,9 +1799,9 @@ coda_lock(v)
|
||||
}
|
||||
|
||||
#ifndef DEBUG_LOCKS
|
||||
return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p));
|
||||
return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td));
|
||||
#else
|
||||
return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p,
|
||||
return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td,
|
||||
"coda_lock", vp->filename, vp->line));
|
||||
#endif
|
||||
}
|
||||
@ -1813,7 +1814,7 @@ coda_unlock(v)
|
||||
struct vop_unlock_args *ap = v;
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct cnode *cp = VTOC(vp);
|
||||
struct proc *p = ap->a_p;
|
||||
struct thread *td = ap->a_td;
|
||||
/* upcall decl */
|
||||
/* locals */
|
||||
|
||||
@ -1823,7 +1824,7 @@ coda_unlock(v)
|
||||
cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
|
||||
}
|
||||
|
||||
return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, p));
|
||||
return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, td));
|
||||
}
|
||||
|
||||
int
|
||||
@ -1835,7 +1836,7 @@ coda_islocked(v)
|
||||
struct cnode *cp = VTOC(ap->a_vp);
|
||||
ENTRY;
|
||||
|
||||
return (lockstatus(&cp->c_lock, ap->a_p));
|
||||
return (lockstatus(&cp->c_lock, ap->a_td));
|
||||
}
|
||||
|
||||
/* How one looks up a vnode given a device/inode pair: */
|
||||
|
@ -82,7 +82,7 @@ int coda_fbsd_getpages __P((void *));
|
||||
int (**coda_vnodeop_p)(void *);
|
||||
|
||||
int coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw,
|
||||
int ioflag, struct ucred *cred, struct proc *p);
|
||||
int ioflag, struct ucred *cred, struct thread *td);
|
||||
int coda_grab_vnode(dev_t dev, ino_t ino, struct vnode **vpp);
|
||||
void print_vattr(struct vattr *attr);
|
||||
void print_cred(struct ucred *cred);
|
||||
|
@ -376,8 +376,8 @@ linprocfs_doversion(PFS_FILL_ARGS)
|
||||
sbuf_printf(sb,
|
||||
"%s version %s (des@freebsd.org) (gcc version " __VERSION__ ")"
|
||||
" #4 Sun Dec 18 04:30:00 CET 1977\n",
|
||||
linux_get_osname(curp),
|
||||
linux_get_osrelease(curp));
|
||||
linux_get_osname(td->td_proc),
|
||||
linux_get_osrelease(td->td_proc));
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -581,7 +581,7 @@ linprocfs_doprocstatus(PFS_FILL_ARGS)
|
||||
static int
|
||||
linprocfs_doselflink(PFS_FILL_ARGS)
|
||||
{
|
||||
sbuf_printf(sb, "%ld", (long)curp->p_pid);
|
||||
sbuf_printf(sb, "%ld", (long)td->td_proc->p_pid);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -604,9 +604,9 @@ linprocfs_doproccmdline(PFS_FILL_ARGS)
|
||||
* Linux behaviour is to return zero-length in this case.
|
||||
*/
|
||||
|
||||
if (p->p_args && (ps_argsopen || !p_cansee(curp, p))) {
|
||||
if (p->p_args && (ps_argsopen || !p_cansee(td->td_proc, p))) {
|
||||
sbuf_bcpy(sb, p->p_args->ar_args, p->p_args->ar_length);
|
||||
} else if (p != curp) {
|
||||
} else if (p != td->td_proc) {
|
||||
sbuf_printf(sb, "%.*s", MAXCOMLEN, p->p_comm);
|
||||
} else {
|
||||
error = copyin((void*)PS_STRINGS, &pstr, sizeof(pstr));
|
||||
@ -663,8 +663,8 @@ linprocfs_donetdev(PFS_FILL_ARGS)
|
||||
sbuf_printf(sb,
|
||||
"%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
|
||||
"%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0);
|
||||
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
|
||||
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L);
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
@ -56,7 +56,7 @@
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_creat(struct proc *p, struct linux_creat_args *args)
|
||||
linux_creat(struct thread *td, struct linux_creat_args *args)
|
||||
{
|
||||
struct open_args /* {
|
||||
char *path;
|
||||
@ -66,7 +66,7 @@ linux_creat(struct proc *p, struct linux_creat_args *args)
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTCREAT(p, &sg, args->path);
|
||||
CHECKALTCREAT(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(creat))
|
||||
@ -75,27 +75,28 @@ linux_creat(struct proc *p, struct linux_creat_args *args)
|
||||
bsd_open_args.path = args->path;
|
||||
bsd_open_args.mode = args->mode;
|
||||
bsd_open_args.flags = O_WRONLY | O_CREAT | O_TRUNC;
|
||||
return open(p, &bsd_open_args);
|
||||
return open(td, &bsd_open_args);
|
||||
}
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
int
|
||||
linux_open(struct proc *p, struct linux_open_args *args)
|
||||
linux_open(struct thread *td, struct linux_open_args *args)
|
||||
{
|
||||
struct open_args /* {
|
||||
char *path;
|
||||
int flags;
|
||||
int mode;
|
||||
} */ bsd_open_args;
|
||||
struct proc *p = td->td_proc;
|
||||
int error;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
|
||||
if (args->flags & LINUX_O_CREAT)
|
||||
CHECKALTCREAT(p, &sg, args->path);
|
||||
CHECKALTCREAT(td, &sg, args->path);
|
||||
else
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(open))
|
||||
@ -130,16 +131,16 @@ linux_open(struct proc *p, struct linux_open_args *args)
|
||||
bsd_open_args.path = args->path;
|
||||
bsd_open_args.mode = args->mode;
|
||||
|
||||
error = open(p, &bsd_open_args);
|
||||
error = open(td, &bsd_open_args);
|
||||
PROC_LOCK(p);
|
||||
if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
|
||||
SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
|
||||
struct filedesc *fdp = p->p_fd;
|
||||
struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
|
||||
struct file *fp = fdp->fd_ofiles[td->td_retval[0]];
|
||||
|
||||
PROC_UNLOCK(p);
|
||||
if (fp->f_type == DTYPE_VNODE)
|
||||
fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
|
||||
fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td);
|
||||
} else
|
||||
PROC_UNLOCK(p);
|
||||
#ifdef DEBUG
|
||||
@ -150,7 +151,7 @@ linux_open(struct proc *p, struct linux_open_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_lseek(struct proc *p, struct linux_lseek_args *args)
|
||||
linux_lseek(struct thread *td, struct linux_lseek_args *args)
|
||||
{
|
||||
|
||||
struct lseek_args /* {
|
||||
@ -169,13 +170,13 @@ linux_lseek(struct proc *p, struct linux_lseek_args *args)
|
||||
tmp_args.fd = args->fdes;
|
||||
tmp_args.offset = (off_t)args->off;
|
||||
tmp_args.whence = args->whence;
|
||||
error = lseek(p, &tmp_args);
|
||||
error = lseek(td, &tmp_args);
|
||||
return error;
|
||||
}
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_llseek(struct proc *p, struct linux_llseek_args *args)
|
||||
linux_llseek(struct thread *td, struct linux_llseek_args *args)
|
||||
{
|
||||
struct lseek_args bsd_args;
|
||||
int error;
|
||||
@ -192,27 +193,27 @@ linux_llseek(struct proc *p, struct linux_llseek_args *args)
|
||||
bsd_args.offset = off;
|
||||
bsd_args.whence = args->whence;
|
||||
|
||||
if ((error = lseek(p, &bsd_args)))
|
||||
if ((error = lseek(td, &bsd_args)))
|
||||
return error;
|
||||
|
||||
if ((error = copyout(p->p_retval, (caddr_t)args->res, sizeof (off_t))))
|
||||
if ((error = copyout(td->td_retval, (caddr_t)args->res, sizeof (off_t))))
|
||||
return error;
|
||||
|
||||
p->p_retval[0] = 0;
|
||||
td->td_retval[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_readdir(struct proc *p, struct linux_readdir_args *args)
|
||||
linux_readdir(struct thread *td, struct linux_readdir_args *args)
|
||||
{
|
||||
struct linux_getdents_args lda;
|
||||
|
||||
lda.fd = args->fd;
|
||||
lda.dent = args->dent;
|
||||
lda.count = 1;
|
||||
return linux_getdents(p, &lda);
|
||||
return linux_getdents(td, &lda);
|
||||
}
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
@ -246,7 +247,7 @@ struct l_dirent64 {
|
||||
#define LINUX_DIRBLKSIZ 512
|
||||
|
||||
static int
|
||||
getdents_common(struct proc *p, struct linux_getdents64_args *args,
|
||||
getdents_common(struct thread *td, struct linux_getdents64_args *args,
|
||||
int is64bit)
|
||||
{
|
||||
register struct dirent *bdp;
|
||||
@ -266,7 +267,7 @@ getdents_common(struct proc *p, struct linux_getdents64_args *args,
|
||||
u_long *cookies = NULL, *cookiep;
|
||||
int ncookies;
|
||||
|
||||
if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0)
|
||||
if ((error = getvnode(td->td_proc->p_fd, args->fd, &fp)) != 0)
|
||||
return (error);
|
||||
|
||||
if ((fp->f_flag & FREAD) == 0)
|
||||
@ -276,7 +277,7 @@ getdents_common(struct proc *p, struct linux_getdents64_args *args,
|
||||
if (vp->v_type != VDIR)
|
||||
return (EINVAL);
|
||||
|
||||
if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
|
||||
if ((error = VOP_GETATTR(vp, &va, td->td_proc->p_ucred, td)))
|
||||
return (error);
|
||||
|
||||
nbytes = args->count;
|
||||
@ -294,7 +295,7 @@ getdents_common(struct proc *p, struct linux_getdents64_args *args,
|
||||
buflen = max(LINUX_DIRBLKSIZ, nbytes);
|
||||
buflen = min(buflen, MAXBSIZE);
|
||||
buf = malloc(buflen, M_TEMP, M_WAITOK);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
|
||||
again:
|
||||
aiov.iov_base = buf;
|
||||
@ -303,7 +304,7 @@ getdents_common(struct proc *p, struct linux_getdents64_args *args,
|
||||
auio.uio_iovcnt = 1;
|
||||
auio.uio_rw = UIO_READ;
|
||||
auio.uio_segflg = UIO_SYSSPACE;
|
||||
auio.uio_procp = p;
|
||||
auio.uio_td = td;
|
||||
auio.uio_resid = buflen;
|
||||
auio.uio_offset = off;
|
||||
|
||||
@ -427,19 +428,19 @@ getdents_common(struct proc *p, struct linux_getdents64_args *args,
|
||||
nbytes = resid + linuxreclen;
|
||||
|
||||
eof:
|
||||
p->p_retval[0] = nbytes - resid;
|
||||
td->td_retval[0] = nbytes - resid;
|
||||
|
||||
out:
|
||||
if (cookies)
|
||||
free(cookies, M_TEMP);
|
||||
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
VOP_UNLOCK(vp, 0, td);
|
||||
free(buf, M_TEMP);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
linux_getdents(struct proc *p, struct linux_getdents_args *args)
|
||||
linux_getdents(struct thread *td, struct linux_getdents_args *args)
|
||||
{
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -447,11 +448,11 @@ linux_getdents(struct proc *p, struct linux_getdents_args *args)
|
||||
printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count);
|
||||
#endif
|
||||
|
||||
return (getdents_common(p, (struct linux_getdents64_args*)args, 0));
|
||||
return (getdents_common(td, (struct linux_getdents64_args*)args, 0));
|
||||
}
|
||||
|
||||
int
|
||||
linux_getdents64(struct proc *p, struct linux_getdents64_args *args)
|
||||
linux_getdents64(struct thread *td, struct linux_getdents64_args *args)
|
||||
{
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -459,7 +460,7 @@ linux_getdents64(struct proc *p, struct linux_getdents64_args *args)
|
||||
printf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count);
|
||||
#endif
|
||||
|
||||
return (getdents_common(p, args, 1));
|
||||
return (getdents_common(td, args, 1));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -467,13 +468,13 @@ linux_getdents64(struct proc *p, struct linux_getdents64_args *args)
|
||||
*/
|
||||
|
||||
int
|
||||
linux_access(struct proc *p, struct linux_access_args *args)
|
||||
linux_access(struct thread *td, struct linux_access_args *args)
|
||||
{
|
||||
struct access_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(access))
|
||||
@ -482,17 +483,17 @@ linux_access(struct proc *p, struct linux_access_args *args)
|
||||
bsd.path = args->path;
|
||||
bsd.flags = args->flags;
|
||||
|
||||
return access(p, &bsd);
|
||||
return access(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_unlink(struct proc *p, struct linux_unlink_args *args)
|
||||
linux_unlink(struct thread *td, struct linux_unlink_args *args)
|
||||
{
|
||||
struct unlink_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(unlink))
|
||||
@ -500,17 +501,17 @@ linux_unlink(struct proc *p, struct linux_unlink_args *args)
|
||||
#endif
|
||||
bsd.path = args->path;
|
||||
|
||||
return unlink(p, &bsd);
|
||||
return unlink(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_chdir(struct proc *p, struct linux_chdir_args *args)
|
||||
linux_chdir(struct thread *td, struct linux_chdir_args *args)
|
||||
{
|
||||
struct chdir_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(chdir))
|
||||
@ -518,17 +519,17 @@ linux_chdir(struct proc *p, struct linux_chdir_args *args)
|
||||
#endif
|
||||
bsd.path = args->path;
|
||||
|
||||
return chdir(p, &bsd);
|
||||
return chdir(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_chmod(struct proc *p, struct linux_chmod_args *args)
|
||||
linux_chmod(struct thread *td, struct linux_chmod_args *args)
|
||||
{
|
||||
struct chmod_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(chmod))
|
||||
@ -537,17 +538,17 @@ linux_chmod(struct proc *p, struct linux_chmod_args *args)
|
||||
bsd.path = args->path;
|
||||
bsd.mode = args->mode;
|
||||
|
||||
return chmod(p, &bsd);
|
||||
return chmod(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_mkdir(struct proc *p, struct linux_mkdir_args *args)
|
||||
linux_mkdir(struct thread *td, struct linux_mkdir_args *args)
|
||||
{
|
||||
struct mkdir_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTCREAT(p, &sg, args->path);
|
||||
CHECKALTCREAT(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(mkdir))
|
||||
@ -556,17 +557,17 @@ linux_mkdir(struct proc *p, struct linux_mkdir_args *args)
|
||||
bsd.path = args->path;
|
||||
bsd.mode = args->mode;
|
||||
|
||||
return mkdir(p, &bsd);
|
||||
return mkdir(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_rmdir(struct proc *p, struct linux_rmdir_args *args)
|
||||
linux_rmdir(struct thread *td, struct linux_rmdir_args *args)
|
||||
{
|
||||
struct rmdir_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(rmdir))
|
||||
@ -574,18 +575,18 @@ linux_rmdir(struct proc *p, struct linux_rmdir_args *args)
|
||||
#endif
|
||||
bsd.path = args->path;
|
||||
|
||||
return rmdir(p, &bsd);
|
||||
return rmdir(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_rename(struct proc *p, struct linux_rename_args *args)
|
||||
linux_rename(struct thread *td, struct linux_rename_args *args)
|
||||
{
|
||||
struct rename_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->from);
|
||||
CHECKALTCREAT(p, &sg, args->to);
|
||||
CHECKALTEXIST(td, &sg, args->from);
|
||||
CHECKALTCREAT(td, &sg, args->to);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(rename))
|
||||
@ -594,18 +595,18 @@ linux_rename(struct proc *p, struct linux_rename_args *args)
|
||||
bsd.from = args->from;
|
||||
bsd.to = args->to;
|
||||
|
||||
return rename(p, &bsd);
|
||||
return rename(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_symlink(struct proc *p, struct linux_symlink_args *args)
|
||||
linux_symlink(struct thread *td, struct linux_symlink_args *args)
|
||||
{
|
||||
struct symlink_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTCREAT(p, &sg, args->to);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
CHECKALTCREAT(td, &sg, args->to);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(symlink))
|
||||
@ -614,17 +615,17 @@ linux_symlink(struct proc *p, struct linux_symlink_args *args)
|
||||
bsd.path = args->path;
|
||||
bsd.link = args->to;
|
||||
|
||||
return symlink(p, &bsd);
|
||||
return symlink(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_readlink(struct proc *p, struct linux_readlink_args *args)
|
||||
linux_readlink(struct thread *td, struct linux_readlink_args *args)
|
||||
{
|
||||
struct readlink_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->name);
|
||||
CHECKALTEXIST(td, &sg, args->name);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(readlink))
|
||||
@ -635,17 +636,17 @@ linux_readlink(struct proc *p, struct linux_readlink_args *args)
|
||||
bsd.buf = args->buf;
|
||||
bsd.count = args->count;
|
||||
|
||||
return readlink(p, &bsd);
|
||||
return readlink(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_truncate(struct proc *p, struct linux_truncate_args *args)
|
||||
linux_truncate(struct thread *td, struct linux_truncate_args *args)
|
||||
{
|
||||
struct truncate_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(truncate))
|
||||
@ -655,18 +656,18 @@ linux_truncate(struct proc *p, struct linux_truncate_args *args)
|
||||
bsd.path = args->path;
|
||||
bsd.length = args->length;
|
||||
|
||||
return truncate(p, &bsd);
|
||||
return truncate(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_link(struct proc *p, struct linux_link_args *args)
|
||||
linux_link(struct thread *td, struct linux_link_args *args)
|
||||
{
|
||||
struct link_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTCREAT(p, &sg, args->to);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
CHECKALTCREAT(td, &sg, args->to);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(link))
|
||||
@ -676,25 +677,25 @@ linux_link(struct proc *p, struct linux_link_args *args)
|
||||
bsd.path = args->path;
|
||||
bsd.link = args->to;
|
||||
|
||||
return link(p, &bsd);
|
||||
return link(td, &bsd);
|
||||
}
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_fdatasync(p, uap)
|
||||
struct proc *p;
|
||||
linux_fdatasync(td, uap)
|
||||
struct thread *td;
|
||||
struct linux_fdatasync_args *uap;
|
||||
{
|
||||
struct fsync_args bsd;
|
||||
|
||||
bsd.fd = uap->fd;
|
||||
return fsync(p, &bsd);
|
||||
return fsync(td, &bsd);
|
||||
}
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
int
|
||||
linux_pread(p, uap)
|
||||
struct proc *p;
|
||||
linux_pread(td, uap)
|
||||
struct thread *td;
|
||||
struct linux_pread_args *uap;
|
||||
{
|
||||
struct pread_args bsd;
|
||||
@ -703,12 +704,12 @@ linux_pread(p, uap)
|
||||
bsd.buf = uap->buf;
|
||||
bsd.nbyte = uap->nbyte;
|
||||
bsd.offset = uap->offset;
|
||||
return pread(p, &bsd);
|
||||
return pread(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_pwrite(p, uap)
|
||||
struct proc *p;
|
||||
linux_pwrite(td, uap)
|
||||
struct thread *td;
|
||||
struct linux_pwrite_args *uap;
|
||||
{
|
||||
struct pwrite_args bsd;
|
||||
@ -717,11 +718,11 @@ linux_pwrite(p, uap)
|
||||
bsd.buf = uap->buf;
|
||||
bsd.nbyte = uap->nbyte;
|
||||
bsd.offset = uap->offset;
|
||||
return pwrite(p, &bsd);
|
||||
return pwrite(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_mount(struct proc *p, struct linux_mount_args *args)
|
||||
linux_mount(struct thread *td, struct linux_mount_args *args)
|
||||
{
|
||||
struct ufs_args ufs;
|
||||
char fstypename[MFSNAMELEN];
|
||||
@ -782,27 +783,27 @@ linux_mount(struct proc *p, struct linux_mount_args *args)
|
||||
fsflags |= MNT_UPDATE;
|
||||
}
|
||||
|
||||
return (vfs_mount(p, fstype, mntonname, fsflags, fsdata));
|
||||
return (vfs_mount(td, fstype, mntonname, fsflags, fsdata));
|
||||
}
|
||||
|
||||
int
|
||||
linux_oldumount(struct proc *p, struct linux_oldumount_args *args)
|
||||
linux_oldumount(struct thread *td, struct linux_oldumount_args *args)
|
||||
{
|
||||
struct linux_umount_args args2;
|
||||
|
||||
args2.path = args->path;
|
||||
args2.flags = 0;
|
||||
return (linux_umount(p, &args2));
|
||||
return (linux_umount(td, &args2));
|
||||
}
|
||||
|
||||
int
|
||||
linux_umount(struct proc *p, struct linux_umount_args *args)
|
||||
linux_umount(struct thread *td, struct linux_umount_args *args)
|
||||
{
|
||||
struct unmount_args bsd;
|
||||
|
||||
bsd.path = args->path;
|
||||
bsd.flags = args->flags; /* XXX correct? */
|
||||
return (unmount(p, &bsd));
|
||||
return (unmount(td, &bsd));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -918,7 +919,7 @@ bsd_to_linux_flock64(struct flock *bsd_flock, struct l_flock64 *linux_flock)
|
||||
#endif
|
||||
|
||||
static int
|
||||
fcntl_common(struct proc *p, struct linux_fcntl64_args *args)
|
||||
fcntl_common(struct thread *td, struct linux_fcntl64_args *args)
|
||||
{
|
||||
struct fcntl_args fcntl_args;
|
||||
struct filedesc *fdp;
|
||||
@ -931,36 +932,36 @@ fcntl_common(struct proc *p, struct linux_fcntl64_args *args)
|
||||
case LINUX_F_DUPFD:
|
||||
fcntl_args.cmd = F_DUPFD;
|
||||
fcntl_args.arg = args->arg;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
|
||||
case LINUX_F_GETFD:
|
||||
fcntl_args.cmd = F_GETFD;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
|
||||
case LINUX_F_SETFD:
|
||||
fcntl_args.cmd = F_SETFD;
|
||||
fcntl_args.arg = args->arg;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
|
||||
case LINUX_F_GETFL:
|
||||
fcntl_args.cmd = F_GETFL;
|
||||
error = fcntl(p, &fcntl_args);
|
||||
result = p->p_retval[0];
|
||||
p->p_retval[0] = 0;
|
||||
error = fcntl(td, &fcntl_args);
|
||||
result = td->td_retval[0];
|
||||
td->td_retval[0] = 0;
|
||||
if (result & O_RDONLY)
|
||||
p->p_retval[0] |= LINUX_O_RDONLY;
|
||||
td->td_retval[0] |= LINUX_O_RDONLY;
|
||||
if (result & O_WRONLY)
|
||||
p->p_retval[0] |= LINUX_O_WRONLY;
|
||||
td->td_retval[0] |= LINUX_O_WRONLY;
|
||||
if (result & O_RDWR)
|
||||
p->p_retval[0] |= LINUX_O_RDWR;
|
||||
td->td_retval[0] |= LINUX_O_RDWR;
|
||||
if (result & O_NDELAY)
|
||||
p->p_retval[0] |= LINUX_O_NONBLOCK;
|
||||
td->td_retval[0] |= LINUX_O_NONBLOCK;
|
||||
if (result & O_APPEND)
|
||||
p->p_retval[0] |= LINUX_O_APPEND;
|
||||
td->td_retval[0] |= LINUX_O_APPEND;
|
||||
if (result & O_FSYNC)
|
||||
p->p_retval[0] |= LINUX_O_SYNC;
|
||||
td->td_retval[0] |= LINUX_O_SYNC;
|
||||
if (result & O_ASYNC)
|
||||
p->p_retval[0] |= LINUX_FASYNC;
|
||||
td->td_retval[0] |= LINUX_FASYNC;
|
||||
return (error);
|
||||
|
||||
case LINUX_F_SETFL:
|
||||
@ -974,11 +975,11 @@ fcntl_common(struct proc *p, struct linux_fcntl64_args *args)
|
||||
if (args->arg & LINUX_FASYNC)
|
||||
fcntl_args.arg |= O_ASYNC;
|
||||
fcntl_args.cmd = F_SETFL;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
|
||||
case LINUX_F_GETOWN:
|
||||
fcntl_args.cmd = F_GETOWN;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
|
||||
case LINUX_F_SETOWN:
|
||||
/*
|
||||
@ -986,7 +987,7 @@ fcntl_common(struct proc *p, struct linux_fcntl64_args *args)
|
||||
* significant effect for pipes (SIGIO is not delivered for
|
||||
* pipes under Linux-2.2.35 at least).
|
||||
*/
|
||||
fdp = p->p_fd;
|
||||
fdp = td->td_proc->p_fd;
|
||||
if ((u_int)args->fd >= fdp->fd_nfiles ||
|
||||
(fp = fdp->fd_ofiles[args->fd]) == NULL)
|
||||
return (EBADF);
|
||||
@ -995,14 +996,14 @@ fcntl_common(struct proc *p, struct linux_fcntl64_args *args)
|
||||
|
||||
fcntl_args.cmd = F_SETOWN;
|
||||
fcntl_args.arg = args->arg;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
}
|
||||
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
int
|
||||
linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
|
||||
linux_fcntl(struct thread *td, struct linux_fcntl_args *args)
|
||||
{
|
||||
struct linux_fcntl64_args args64;
|
||||
struct fcntl_args fcntl_args;
|
||||
@ -1029,7 +1030,7 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
|
||||
fcntl_args.fd = args->fd;
|
||||
fcntl_args.cmd = F_GETLK;
|
||||
fcntl_args.arg = (long)bsd_flock;
|
||||
error = fcntl(p, &fcntl_args);
|
||||
error = fcntl(td, &fcntl_args);
|
||||
if (error)
|
||||
return (error);
|
||||
bsd_to_linux_flock(bsd_flock, &linux_flock);
|
||||
@ -1045,7 +1046,7 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
|
||||
fcntl_args.fd = args->fd;
|
||||
fcntl_args.cmd = F_SETLK;
|
||||
fcntl_args.arg = (long)bsd_flock;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
|
||||
case LINUX_F_SETLKW:
|
||||
error = copyin((caddr_t)args->arg, &linux_flock,
|
||||
@ -1056,18 +1057,18 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
|
||||
fcntl_args.fd = args->fd;
|
||||
fcntl_args.cmd = F_SETLKW;
|
||||
fcntl_args.arg = (long)bsd_flock;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
}
|
||||
|
||||
args64.fd = args->fd;
|
||||
args64.cmd = args->cmd;
|
||||
args64.arg = args->arg;
|
||||
return (fcntl_common(p, &args64));
|
||||
return (fcntl_common(td, &args64));
|
||||
}
|
||||
|
||||
#if defined(__i386__)
|
||||
int
|
||||
linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args)
|
||||
linux_fcntl64(struct thread *td, struct linux_fcntl64_args *args)
|
||||
{
|
||||
struct fcntl_args fcntl_args;
|
||||
struct l_flock64 linux_flock;
|
||||
@ -1093,7 +1094,7 @@ linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args)
|
||||
fcntl_args.fd = args->fd;
|
||||
fcntl_args.cmd = F_GETLK;
|
||||
fcntl_args.arg = (long)bsd_flock;
|
||||
error = fcntl(p, &fcntl_args);
|
||||
error = fcntl(td, &fcntl_args);
|
||||
if (error)
|
||||
return (error);
|
||||
bsd_to_linux_flock64(bsd_flock, &linux_flock);
|
||||
@ -1109,7 +1110,7 @@ linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args)
|
||||
fcntl_args.fd = args->fd;
|
||||
fcntl_args.cmd = F_SETLK;
|
||||
fcntl_args.arg = (long)bsd_flock;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
|
||||
case LINUX_F_SETLKW:
|
||||
error = copyin((caddr_t)args->arg, &linux_flock,
|
||||
@ -1120,9 +1121,9 @@ linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args)
|
||||
fcntl_args.fd = args->fd;
|
||||
fcntl_args.cmd = F_SETLKW;
|
||||
fcntl_args.arg = (long)bsd_flock;
|
||||
return (fcntl(p, &fcntl_args));
|
||||
return (fcntl(td, &fcntl_args));
|
||||
}
|
||||
|
||||
return (fcntl_common(p, args));
|
||||
return (fcntl_common(td, args));
|
||||
}
|
||||
#endif /* __i386__ */
|
||||
|
@ -61,10 +61,10 @@
|
||||
|
||||
static int
|
||||
linux_getcwd_scandir __P((struct vnode **, struct vnode **,
|
||||
char **, char *, struct proc *));
|
||||
char **, char *, struct thread *));
|
||||
static int
|
||||
linux_getcwd_common __P((struct vnode *, struct vnode *,
|
||||
char **, char *, int, int, struct proc *));
|
||||
char **, char *, int, int, struct thread *));
|
||||
|
||||
#define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4)
|
||||
|
||||
@ -104,12 +104,12 @@ linux_getcwd_common __P((struct vnode *, struct vnode *,
|
||||
* On exit, *uvpp is either NULL or is a locked vnode reference.
|
||||
*/
|
||||
static int
|
||||
linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p)
|
||||
linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, td)
|
||||
struct vnode **lvpp;
|
||||
struct vnode **uvpp;
|
||||
char **bpp;
|
||||
char *bufp;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
int error = 0;
|
||||
int eofflag;
|
||||
@ -132,7 +132,7 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p)
|
||||
* current directory is still locked.
|
||||
*/
|
||||
if (bufp != NULL) {
|
||||
error = VOP_GETATTR(lvp, &va, p->p_ucred, p);
|
||||
error = VOP_GETATTR(lvp, &va, td->td_proc->p_ucred, td);
|
||||
if (error) {
|
||||
vput(lvp);
|
||||
*lvpp = NULL;
|
||||
@ -147,8 +147,8 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p)
|
||||
*/
|
||||
cn.cn_nameiop = LOOKUP;
|
||||
cn.cn_flags = ISLASTCN | ISDOTDOT | RDONLY;
|
||||
cn.cn_proc = p;
|
||||
cn.cn_cred = p->p_ucred;
|
||||
cn.cn_thread = td;
|
||||
cn.cn_cred = td->td_proc->p_ucred;
|
||||
cn.cn_pnbuf = NULL;
|
||||
cn.cn_nameptr = "..";
|
||||
cn.cn_namelen = 2;
|
||||
@ -196,11 +196,11 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p)
|
||||
uio.uio_resid = dirbuflen;
|
||||
uio.uio_segflg = UIO_SYSSPACE;
|
||||
uio.uio_rw = UIO_READ;
|
||||
uio.uio_procp = p;
|
||||
uio.uio_td = td;
|
||||
|
||||
eofflag = 0;
|
||||
|
||||
error = VOP_READDIR(uvp, &uio, p->p_ucred, &eofflag, 0, 0);
|
||||
error = VOP_READDIR(uvp, &uio, td->td_proc->p_ucred, &eofflag, 0, 0);
|
||||
|
||||
off = uio.uio_offset;
|
||||
|
||||
@ -274,16 +274,16 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, p)
|
||||
#define GETCWD_CHECK_ACCESS 0x0001
|
||||
|
||||
static int
|
||||
linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p)
|
||||
linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, td)
|
||||
struct vnode *lvp;
|
||||
struct vnode *rvp;
|
||||
char **bpp;
|
||||
char *bufp;
|
||||
int limit;
|
||||
int flags;
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
{
|
||||
struct filedesc *fdp = p->p_fd;
|
||||
struct filedesc *fdp = td->td_proc->p_fd;
|
||||
struct vnode *uvp = NULL;
|
||||
char *bp = NULL;
|
||||
int error;
|
||||
@ -305,7 +305,7 @@ linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p)
|
||||
* uvp is either NULL, or locked and held.
|
||||
*/
|
||||
|
||||
error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
if (error) {
|
||||
vrele(lvp);
|
||||
lvp = NULL;
|
||||
@ -335,7 +335,7 @@ linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p)
|
||||
* whether or not caller cares.
|
||||
*/
|
||||
if (flags & GETCWD_CHECK_ACCESS) {
|
||||
error = VOP_ACCESS(lvp, perms, p->p_ucred, p);
|
||||
error = VOP_ACCESS(lvp, perms, td->td_proc->p_ucred, td);
|
||||
if (error)
|
||||
goto out;
|
||||
perms = VEXEC|VREAD;
|
||||
@ -361,14 +361,14 @@ linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p)
|
||||
goto out;
|
||||
}
|
||||
VREF(lvp);
|
||||
error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
if (error != 0) {
|
||||
vrele(lvp);
|
||||
lvp = NULL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
error = linux_getcwd_scandir(&lvp, &uvp, &bp, bufp, p);
|
||||
error = linux_getcwd_scandir(&lvp, &uvp, &bp, bufp, td);
|
||||
if (error)
|
||||
goto out;
|
||||
#if DIAGNOSTIC
|
||||
@ -405,25 +405,25 @@ linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p)
|
||||
*/
|
||||
|
||||
int
|
||||
linux_getcwd(struct proc *p, struct linux_getcwd_args *args)
|
||||
linux_getcwd(struct thread *td, struct linux_getcwd_args *args)
|
||||
{
|
||||
struct __getcwd_args bsd;
|
||||
caddr_t sg, bp, bend, path;
|
||||
int error, len, lenused;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)p->p_pid,
|
||||
printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)td->td_proc->p_pid,
|
||||
args->buf, args->bufsize);
|
||||
#endif
|
||||
|
||||
sg = stackgap_init();
|
||||
bsd.buf = stackgap_alloc(&sg, SPARE_USRSPACE);
|
||||
bsd.buflen = SPARE_USRSPACE;
|
||||
error = __getcwd(p, &bsd);
|
||||
error = __getcwd(td, &bsd);
|
||||
if (!error) {
|
||||
lenused = strlen(bsd.buf) + 1;
|
||||
if (lenused <= args->bufsize) {
|
||||
p->p_retval[0] = lenused;
|
||||
td->td_retval[0] = lenused;
|
||||
error = copyout(bsd.buf, args->buf, lenused);
|
||||
}
|
||||
else
|
||||
@ -448,13 +448,13 @@ linux_getcwd(struct proc *p, struct linux_getcwd_args *args)
|
||||
* limit it to N/2 vnodes for an N byte buffer.
|
||||
*/
|
||||
|
||||
error = linux_getcwd_common (p->p_fd->fd_cdir, NULL,
|
||||
&bp, path, len/2, GETCWD_CHECK_ACCESS, p);
|
||||
error = linux_getcwd_common (td->td_proc->p_fd->fd_cdir, NULL,
|
||||
&bp, path, len/2, GETCWD_CHECK_ACCESS, td);
|
||||
|
||||
if (error)
|
||||
goto out;
|
||||
lenused = bend - bp;
|
||||
p->p_retval[0] = lenused;
|
||||
td->td_retval[0] = lenused;
|
||||
/* put the result into user buffer */
|
||||
error = copyout(bp, args->buf, lenused);
|
||||
|
||||
|
@ -91,7 +91,7 @@ DATA_SET(linux_ioctl_handler_set, termio_handler);
|
||||
struct handler_element
|
||||
{
|
||||
TAILQ_ENTRY(handler_element) list;
|
||||
int (*func)(struct proc *, struct linux_ioctl_args *);
|
||||
int (*func)(struct thread *, struct linux_ioctl_args *);
|
||||
int low, high, span;
|
||||
};
|
||||
|
||||
@ -99,15 +99,15 @@ static TAILQ_HEAD(, handler_element) handlers =
|
||||
TAILQ_HEAD_INITIALIZER(handlers);
|
||||
|
||||
static int
|
||||
linux_ioctl_disk(struct proc *p, struct linux_ioctl_args *args)
|
||||
linux_ioctl_disk(struct thread *td, struct linux_ioctl_args *args)
|
||||
{
|
||||
struct file *fp = p->p_fd->fd_ofiles[args->fd];
|
||||
struct file *fp = td->td_proc->p_fd->fd_ofiles[args->fd];
|
||||
int error;
|
||||
struct disklabel dl;
|
||||
|
||||
switch (args->cmd & 0xffff) {
|
||||
case LINUX_BLKGETSIZE:
|
||||
error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p);
|
||||
error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, td);
|
||||
if (error)
|
||||
return (error);
|
||||
return (copyout(&(dl.d_secperunit), (caddr_t)args->arg,
|
||||
@ -511,18 +511,18 @@ linux_to_bsd_termio(struct linux_termio *lio, struct termios *bios)
|
||||
}
|
||||
|
||||
static int
|
||||
linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
linux_ioctl_termio(struct thread *td, struct linux_ioctl_args *args)
|
||||
{
|
||||
struct termios bios;
|
||||
struct linux_termios lios;
|
||||
struct linux_termio lio;
|
||||
struct file *fp = p->p_fd->fd_ofiles[args->fd];
|
||||
struct file *fp = td->td_proc->p_fd->fd_ofiles[args->fd];
|
||||
int error;
|
||||
|
||||
switch (args->cmd & 0xffff) {
|
||||
|
||||
case LINUX_TCGETS:
|
||||
error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p);
|
||||
error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td);
|
||||
if (error)
|
||||
return (error);
|
||||
bsd_to_linux_termios(&bios, &lios);
|
||||
@ -533,24 +533,24 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
if (error)
|
||||
return (error);
|
||||
linux_to_bsd_termios(&lios, &bios);
|
||||
return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p));
|
||||
return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, td));
|
||||
|
||||
case LINUX_TCSETSW:
|
||||
error = copyin((caddr_t)args->arg, &lios, sizeof(lios));
|
||||
if (error)
|
||||
return (error);
|
||||
linux_to_bsd_termios(&lios, &bios);
|
||||
return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p));
|
||||
return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, td));
|
||||
|
||||
case LINUX_TCSETSF:
|
||||
error = copyin((caddr_t)args->arg, &lios, sizeof(lios));
|
||||
if (error)
|
||||
return (error);
|
||||
linux_to_bsd_termios(&lios, &bios);
|
||||
return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p));
|
||||
return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, td));
|
||||
|
||||
case LINUX_TCGETA:
|
||||
error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p);
|
||||
error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td);
|
||||
if (error)
|
||||
return (error);
|
||||
bsd_to_linux_termio(&bios, &lio);
|
||||
@ -561,21 +561,21 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
if (error)
|
||||
return (error);
|
||||
linux_to_bsd_termio(&lio, &bios);
|
||||
return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p));
|
||||
return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, td));
|
||||
|
||||
case LINUX_TCSETAW:
|
||||
error = copyin((caddr_t)args->arg, &lio, sizeof(lio));
|
||||
if (error)
|
||||
return (error);
|
||||
linux_to_bsd_termio(&lio, &bios);
|
||||
return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p));
|
||||
return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, td));
|
||||
|
||||
case LINUX_TCSETAF:
|
||||
error = copyin((caddr_t)args->arg, &lio, sizeof(lio));
|
||||
if (error)
|
||||
return (error);
|
||||
linux_to_bsd_termio(&lio, &bios);
|
||||
return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p));
|
||||
return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, td));
|
||||
|
||||
/* LINUX_TCSBRK */
|
||||
|
||||
@ -591,7 +591,7 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
case LINUX_TCION: {
|
||||
int c;
|
||||
struct write_args wr;
|
||||
error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p);
|
||||
error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, td);
|
||||
if (error)
|
||||
return (error);
|
||||
c = (args->arg == LINUX_TCIOFF) ? VSTOP : VSTART;
|
||||
@ -600,7 +600,7 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
wr.fd = args->fd;
|
||||
wr.buf = &c;
|
||||
wr.nbyte = sizeof(c);
|
||||
return (write(p, &wr));
|
||||
return (write(td, &wr));
|
||||
} else
|
||||
return (0);
|
||||
}
|
||||
@ -608,7 +608,7 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
return (EINVAL);
|
||||
}
|
||||
args->arg = 0;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
}
|
||||
|
||||
case LINUX_TCFLSH: {
|
||||
@ -626,66 +626,66 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
default:
|
||||
return (EINVAL);
|
||||
}
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
}
|
||||
|
||||
case LINUX_TIOCEXCL:
|
||||
args->cmd = TIOCEXCL;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCNXCL:
|
||||
args->cmd = TIOCNXCL;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
/* LINUX_TIOCSCTTY */
|
||||
|
||||
case LINUX_TIOCGPGRP:
|
||||
args->cmd = TIOCGPGRP;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCSPGRP:
|
||||
args->cmd = TIOCSPGRP;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
/* LINUX_TIOCOUTQ */
|
||||
/* LINUX_TIOCSTI */
|
||||
|
||||
case LINUX_TIOCGWINSZ:
|
||||
args->cmd = TIOCGWINSZ;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCSWINSZ:
|
||||
args->cmd = TIOCSWINSZ;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCMGET:
|
||||
args->cmd = TIOCMGET;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCMBIS:
|
||||
args->cmd = TIOCMBIS;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCMBIC:
|
||||
args->cmd = TIOCMBIC;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCMSET:
|
||||
args->cmd = TIOCMSET;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
/* TIOCGSOFTCAR */
|
||||
/* TIOCSSOFTCAR */
|
||||
|
||||
case LINUX_FIONREAD: /* LINUX_TIOCINQ */
|
||||
args->cmd = FIONREAD;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
/* LINUX_TIOCLINUX */
|
||||
|
||||
case LINUX_TIOCCONS:
|
||||
args->cmd = TIOCCONS;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCGSERIAL: {
|
||||
struct linux_serial_struct lss;
|
||||
@ -710,11 +710,11 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
|
||||
case LINUX_FIONBIO:
|
||||
args->cmd = FIONBIO;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCNOTTY:
|
||||
args->cmd = TIOCNOTTY;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_TIOCSETD: {
|
||||
int line;
|
||||
@ -731,13 +731,13 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
default:
|
||||
return (EINVAL);
|
||||
}
|
||||
return (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, p));
|
||||
return (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, td));
|
||||
}
|
||||
|
||||
case LINUX_TIOCGETD: {
|
||||
int linux_line;
|
||||
int bsd_line = TTYDISC;
|
||||
error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, p);
|
||||
error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, td);
|
||||
if (error)
|
||||
return (error);
|
||||
switch (bsd_line) {
|
||||
@ -761,15 +761,15 @@ linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
|
||||
|
||||
case LINUX_FIONCLEX:
|
||||
args->cmd = FIONCLEX;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_FIOCLEX:
|
||||
args->cmd = FIOCLEX;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_FIOASYNC:
|
||||
args->cmd = FIOASYNC;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
/* LINUX_TIOCSERCONFIG */
|
||||
/* LINUX_TIOCSERGWILD */
|
||||
@ -860,33 +860,33 @@ set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba)
|
||||
}
|
||||
|
||||
static int
|
||||
linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args)
|
||||
linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args)
|
||||
{
|
||||
struct file *fp = p->p_fd->fd_ofiles[args->fd];
|
||||
struct file *fp = td->td_proc->p_fd->fd_ofiles[args->fd];
|
||||
int error;
|
||||
|
||||
switch (args->cmd & 0xffff) {
|
||||
|
||||
case LINUX_CDROMPAUSE:
|
||||
args->cmd = CDIOCPAUSE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_CDROMRESUME:
|
||||
args->cmd = CDIOCRESUME;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_CDROMPLAYMSF:
|
||||
args->cmd = CDIOCPLAYMSF;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_CDROMPLAYTRKIND:
|
||||
args->cmd = CDIOCPLAYTRACKS;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_CDROMREADTOCHDR: {
|
||||
struct ioc_toc_header th;
|
||||
struct linux_cdrom_tochdr lth;
|
||||
error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, p);
|
||||
error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, td);
|
||||
if (!error) {
|
||||
lth.cdth_trk0 = th.starting_track;
|
||||
lth.cdth_trk1 = th.ending_track;
|
||||
@ -901,7 +901,7 @@ linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args)
|
||||
struct ioc_read_toc_single_entry irtse;
|
||||
irtse.address_format = ltep->cdte_format;
|
||||
irtse.track = ltep->cdte_track;
|
||||
error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, p);
|
||||
error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, td);
|
||||
if (!error) {
|
||||
lte = *ltep;
|
||||
lte.cdte_ctrl = irtse.entry.control;
|
||||
@ -915,15 +915,15 @@ linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args)
|
||||
|
||||
case LINUX_CDROMSTOP:
|
||||
args->cmd = CDIOCSTOP;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_CDROMSTART:
|
||||
args->cmd = CDIOCSTART;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_CDROMEJECT:
|
||||
args->cmd = CDIOCEJECT;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
/* LINUX_CDROMVOLCTRL */
|
||||
|
||||
@ -939,7 +939,7 @@ linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args)
|
||||
bsdsc.track = 0;
|
||||
bsdsc.data_len = sizeof(struct cd_sub_channel_info);
|
||||
bsdsc.data = bsdinfo;
|
||||
error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, p);
|
||||
error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, td);
|
||||
if (error)
|
||||
return (error);
|
||||
error = copyin((caddr_t)args->arg, &sc,
|
||||
@ -969,7 +969,7 @@ linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args)
|
||||
|
||||
case LINUX_CDROMRESET:
|
||||
args->cmd = CDIOCRESET;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
/* LINUX_CDROMVOLREAD */
|
||||
/* LINUX_CDROMREADRAW */
|
||||
@ -994,227 +994,227 @@ static u_int32_t dirbits[4] = { IOC_VOID, IOC_IN, IOC_OUT, IOC_INOUT };
|
||||
#define SETDIR(c) (((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30])
|
||||
|
||||
static int
|
||||
linux_ioctl_sound(struct proc *p, struct linux_ioctl_args *args)
|
||||
linux_ioctl_sound(struct thread *td, struct linux_ioctl_args *args)
|
||||
{
|
||||
|
||||
switch (args->cmd & 0xffff) {
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_VOLUME:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_VOLUME);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_BASS:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_BASS);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_TREBLE:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_TREBLE);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_SYNTH:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_SYNTH);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_PCM:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_PCM);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_SPEAKER:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_SPEAKER);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_LINE:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_MIC:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_MIC);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_CD:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_CD);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_IMIX:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_IMIX);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_ALTPCM:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_ALTPCM);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_RECLEV:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_RECLEV);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_IGAIN:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_IGAIN);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_OGAIN:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_OGAIN);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_LINE1:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE1);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_LINE2:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE2);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_MIXER_WRITE_LINE3:
|
||||
args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3);
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_OSS_GETVERSION: {
|
||||
int version = linux_get_oss_version(p);
|
||||
int version = linux_get_oss_version(td->td_proc);
|
||||
return (copyout(&version, (caddr_t)args->arg, sizeof(int)));
|
||||
}
|
||||
|
||||
case LINUX_SOUND_MIXER_READ_DEVMASK:
|
||||
args->cmd = SOUND_MIXER_READ_DEVMASK;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_RESET:
|
||||
args->cmd = SNDCTL_DSP_RESET;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_SYNC:
|
||||
args->cmd = SNDCTL_DSP_SYNC;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_SPEED:
|
||||
args->cmd = SNDCTL_DSP_SPEED;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_STEREO:
|
||||
args->cmd = SNDCTL_DSP_STEREO;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_GETBLKSIZE: /* LINUX_SNDCTL_DSP_SETBLKSIZE */
|
||||
args->cmd = SNDCTL_DSP_GETBLKSIZE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_SETFMT:
|
||||
args->cmd = SNDCTL_DSP_SETFMT;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_PCM_WRITE_CHANNELS:
|
||||
args->cmd = SOUND_PCM_WRITE_CHANNELS;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SOUND_PCM_WRITE_FILTER:
|
||||
args->cmd = SOUND_PCM_WRITE_FILTER;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_POST:
|
||||
args->cmd = SNDCTL_DSP_POST;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_SUBDIVIDE:
|
||||
args->cmd = SNDCTL_DSP_SUBDIVIDE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_SETFRAGMENT:
|
||||
args->cmd = SNDCTL_DSP_SETFRAGMENT;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_GETFMTS:
|
||||
args->cmd = SNDCTL_DSP_GETFMTS;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_GETOSPACE:
|
||||
args->cmd = SNDCTL_DSP_GETOSPACE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_GETISPACE:
|
||||
args->cmd = SNDCTL_DSP_GETISPACE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_NONBLOCK:
|
||||
args->cmd = SNDCTL_DSP_NONBLOCK;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_GETCAPS:
|
||||
args->cmd = SNDCTL_DSP_GETCAPS;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_SETTRIGGER: /* LINUX_SNDCTL_GETTRIGGER */
|
||||
args->cmd = SNDCTL_DSP_SETTRIGGER;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_GETIPTR:
|
||||
args->cmd = SNDCTL_DSP_GETIPTR;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_GETOPTR:
|
||||
args->cmd = SNDCTL_DSP_GETOPTR;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_DSP_GETODELAY:
|
||||
args->cmd = SNDCTL_DSP_GETODELAY;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_RESET:
|
||||
args->cmd = SNDCTL_SEQ_RESET;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_SYNC:
|
||||
args->cmd = SNDCTL_SEQ_SYNC;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SYNTH_INFO:
|
||||
args->cmd = SNDCTL_SYNTH_INFO;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_CTRLRATE:
|
||||
args->cmd = SNDCTL_SEQ_CTRLRATE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_GETOUTCOUNT:
|
||||
args->cmd = SNDCTL_SEQ_GETOUTCOUNT;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_GETINCOUNT:
|
||||
args->cmd = SNDCTL_SEQ_GETINCOUNT;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_PERCMODE:
|
||||
args->cmd = SNDCTL_SEQ_PERCMODE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_FM_LOAD_INSTR:
|
||||
args->cmd = SNDCTL_FM_LOAD_INSTR;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_TESTMIDI:
|
||||
args->cmd = SNDCTL_SEQ_TESTMIDI;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_RESETSAMPLES:
|
||||
args->cmd = SNDCTL_SEQ_RESETSAMPLES;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_NRSYNTHS:
|
||||
args->cmd = SNDCTL_SEQ_NRSYNTHS;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_NRMIDIS:
|
||||
args->cmd = SNDCTL_SEQ_NRMIDIS;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_MIDI_INFO:
|
||||
args->cmd = SNDCTL_MIDI_INFO;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SEQ_TRESHOLD:
|
||||
args->cmd = SNDCTL_SEQ_TRESHOLD;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SNDCTL_SYNTH_MEMAVL:
|
||||
args->cmd = SNDCTL_SYNTH_MEMAVL;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
}
|
||||
|
||||
@ -1228,39 +1228,39 @@ linux_ioctl_sound(struct proc *p, struct linux_ioctl_args *args)
|
||||
#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG)
|
||||
|
||||
static int
|
||||
linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args)
|
||||
linux_ioctl_console(struct thread *td, struct linux_ioctl_args *args)
|
||||
{
|
||||
struct file *fp = p->p_fd->fd_ofiles[args->fd];
|
||||
struct file *fp = td->td_proc->p_fd->fd_ofiles[args->fd];
|
||||
|
||||
switch (args->cmd & 0xffff) {
|
||||
|
||||
case LINUX_KIOCSOUND:
|
||||
args->cmd = KIOCSOUND;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_KDMKTONE:
|
||||
args->cmd = KDMKTONE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_KDGETLED:
|
||||
args->cmd = KDGETLED;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_KDSETLED:
|
||||
args->cmd = KDSETLED;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_KDSETMODE:
|
||||
args->cmd = KDSETMODE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_KDGETMODE:
|
||||
args->cmd = KDGETMODE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_KDGKBMODE:
|
||||
args->cmd = KDGKBMODE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_KDSKBMODE: {
|
||||
int kbdmode;
|
||||
@ -1277,16 +1277,16 @@ linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args)
|
||||
default:
|
||||
return (EINVAL);
|
||||
}
|
||||
return (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, p));
|
||||
return (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, td));
|
||||
}
|
||||
|
||||
case LINUX_VT_OPENQRY:
|
||||
args->cmd = VT_OPENQRY;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_VT_GETMODE:
|
||||
args->cmd = VT_GETMODE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_VT_SETMODE: {
|
||||
struct vt_mode *mode;
|
||||
@ -1294,24 +1294,24 @@ linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args)
|
||||
mode = (struct vt_mode *)args->arg;
|
||||
if (!ISSIGVALID(mode->frsig) && ISSIGVALID(mode->acqsig))
|
||||
mode->frsig = mode->acqsig;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
}
|
||||
|
||||
case LINUX_VT_GETSTATE:
|
||||
args->cmd = VT_GETACTIVE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_VT_RELDISP:
|
||||
args->cmd = VT_RELDISP;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_VT_ACTIVATE:
|
||||
args->cmd = VT_ACTIVATE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_VT_WAITACTIVE:
|
||||
args->cmd = VT_WAITACTIVE;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
}
|
||||
|
||||
@ -1323,56 +1323,56 @@ linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args)
|
||||
*/
|
||||
|
||||
static int
|
||||
linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args)
|
||||
linux_ioctl_socket(struct thread *td, struct linux_ioctl_args *args)
|
||||
{
|
||||
|
||||
switch (args->cmd & 0xffff) {
|
||||
|
||||
case LINUX_FIOSETOWN:
|
||||
args->cmd = FIOSETOWN;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCSPGRP:
|
||||
args->cmd = SIOCSPGRP;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_FIOGETOWN:
|
||||
args->cmd = FIOGETOWN;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCGPGRP:
|
||||
args->cmd = SIOCGPGRP;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCATMARK:
|
||||
args->cmd = SIOCATMARK;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
/* LINUX_SIOCGSTAMP */
|
||||
|
||||
case LINUX_SIOCGIFCONF:
|
||||
args->cmd = OSIOCGIFCONF;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCGIFFLAGS:
|
||||
args->cmd = SIOCGIFFLAGS;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCGIFADDR:
|
||||
args->cmd = OSIOCGIFADDR;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCGIFDSTADDR:
|
||||
args->cmd = OSIOCGIFDSTADDR;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCGIFBRDADDR:
|
||||
args->cmd = OSIOCGIFBRDADDR;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCGIFNETMASK:
|
||||
args->cmd = OSIOCGIFNETMASK;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCGIFHWADDR: {
|
||||
int ifn;
|
||||
@ -1406,11 +1406,11 @@ linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args)
|
||||
|
||||
case LINUX_SIOCADDMULTI:
|
||||
args->cmd = SIOCADDMULTI;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
case LINUX_SIOCDELMULTI:
|
||||
args->cmd = SIOCDELMULTI;
|
||||
return (ioctl(p, (struct ioctl_args *)args));
|
||||
return (ioctl(td, (struct ioctl_args *)args));
|
||||
|
||||
}
|
||||
|
||||
@ -1422,7 +1422,7 @@ linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args)
|
||||
*/
|
||||
|
||||
int
|
||||
linux_ioctl(struct proc *p, struct linux_ioctl_args *args)
|
||||
linux_ioctl(struct thread *td, struct linux_ioctl_args *args)
|
||||
{
|
||||
struct filedesc *fdp;
|
||||
struct file *fp;
|
||||
@ -1434,7 +1434,7 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args)
|
||||
printf(ARGS(ioctl, "%d, %04lx, *"), args->fd, args->cmd);
|
||||
#endif
|
||||
|
||||
fdp = p->p_fd;
|
||||
fdp = td->td_proc->p_fd;
|
||||
if ((unsigned)args->fd >= fdp->fd_nfiles)
|
||||
return (EBADF);
|
||||
fp = fdp->fd_ofiles[args->fd];
|
||||
@ -1445,7 +1445,7 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args)
|
||||
cmd = args->cmd & 0xffff;
|
||||
TAILQ_FOREACH(he, &handlers, list) {
|
||||
if (cmd >= he->low && cmd <= he->high) {
|
||||
error = (*he->func)(p, args);
|
||||
error = (*he->func)(td, args);
|
||||
if (error != ENOIOCTL)
|
||||
return (error);
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp)
|
||||
}
|
||||
|
||||
int
|
||||
linux_semop(struct proc *p, struct linux_semop_args *args)
|
||||
linux_semop(struct thread *td, struct linux_semop_args *args)
|
||||
{
|
||||
struct semop_args /* {
|
||||
int semid;
|
||||
@ -160,11 +160,11 @@ linux_semop(struct proc *p, struct linux_semop_args *args)
|
||||
bsd_args.semid = args->semid;
|
||||
bsd_args.sops = (struct sembuf *)args->tsops;
|
||||
bsd_args.nsops = args->nsops;
|
||||
return semop(p, &bsd_args);
|
||||
return semop(td, &bsd_args);
|
||||
}
|
||||
|
||||
int
|
||||
linux_semget(struct proc *p, struct linux_semget_args *args)
|
||||
linux_semget(struct thread *td, struct linux_semget_args *args)
|
||||
{
|
||||
struct semget_args /* {
|
||||
key_t key;
|
||||
@ -175,11 +175,11 @@ linux_semget(struct proc *p, struct linux_semget_args *args)
|
||||
bsd_args.key = args->key;
|
||||
bsd_args.nsems = args->nsems;
|
||||
bsd_args.semflg = args->semflg;
|
||||
return semget(p, &bsd_args);
|
||||
return semget(td, &bsd_args);
|
||||
}
|
||||
|
||||
int
|
||||
linux_semctl(struct proc *p, struct linux_semctl_args *args)
|
||||
linux_semctl(struct thread *td, struct linux_semctl_args *args)
|
||||
{
|
||||
struct l_semid_ds linux_semid;
|
||||
struct __semctl_args /* {
|
||||
@ -226,13 +226,13 @@ linux_semctl(struct proc *p, struct linux_semctl_args *args)
|
||||
unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds));
|
||||
linux_to_bsd_semid_ds(&linux_semid, unptr->buf);
|
||||
bsd_args.arg = unptr;
|
||||
return __semctl(p, &bsd_args);
|
||||
return __semctl(td, &bsd_args);
|
||||
case LINUX_IPC_STAT:
|
||||
bsd_args.cmd = IPC_STAT;
|
||||
unptr = stackgap_alloc(&sg, sizeof(union semun));
|
||||
unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds));
|
||||
bsd_args.arg = unptr;
|
||||
error = __semctl(p, &bsd_args);
|
||||
error = __semctl(td, &bsd_args);
|
||||
if (error)
|
||||
return error;
|
||||
bsd_to_linux_semid_ds(unptr->buf, &linux_semid);
|
||||
@ -246,11 +246,11 @@ linux_semctl(struct proc *p, struct linux_semctl_args *args)
|
||||
uprintf("linux: 'ipc' typ=%d not implemented\n", args->cmd);
|
||||
return EINVAL;
|
||||
}
|
||||
return __semctl(p, &bsd_args);
|
||||
return __semctl(td, &bsd_args);
|
||||
}
|
||||
|
||||
int
|
||||
linux_msgsnd(struct proc *p, struct linux_msgsnd_args *args)
|
||||
linux_msgsnd(struct thread *td, struct linux_msgsnd_args *args)
|
||||
{
|
||||
struct msgsnd_args /* {
|
||||
int msqid;
|
||||
@ -263,11 +263,11 @@ linux_msgsnd(struct proc *p, struct linux_msgsnd_args *args)
|
||||
bsd_args.msgp = args->msgp;
|
||||
bsd_args.msgsz = args->msgsz;
|
||||
bsd_args.msgflg = args->msgflg;
|
||||
return msgsnd(p, &bsd_args);
|
||||
return msgsnd(td, &bsd_args);
|
||||
}
|
||||
|
||||
int
|
||||
linux_msgrcv(struct proc *p, struct linux_msgrcv_args *args)
|
||||
linux_msgrcv(struct thread *td, struct linux_msgrcv_args *args)
|
||||
{
|
||||
struct msgrcv_args /* {
|
||||
int msqid;
|
||||
@ -282,11 +282,11 @@ linux_msgrcv(struct proc *p, struct linux_msgrcv_args *args)
|
||||
bsd_args.msgsz = args->msgsz;
|
||||
bsd_args.msgtyp = 0; /* XXX - args->msgtyp; */
|
||||
bsd_args.msgflg = args->msgflg;
|
||||
return msgrcv(p, &bsd_args);
|
||||
return msgrcv(td, &bsd_args);
|
||||
}
|
||||
|
||||
int
|
||||
linux_msgget(struct proc *p, struct linux_msgget_args *args)
|
||||
linux_msgget(struct thread *td, struct linux_msgget_args *args)
|
||||
{
|
||||
struct msgget_args /* {
|
||||
key_t key;
|
||||
@ -295,11 +295,11 @@ linux_msgget(struct proc *p, struct linux_msgget_args *args)
|
||||
|
||||
bsd_args.key = args->key;
|
||||
bsd_args.msgflg = args->msgflg;
|
||||
return msgget(p, &bsd_args);
|
||||
return msgget(td, &bsd_args);
|
||||
}
|
||||
|
||||
int
|
||||
linux_msgctl(struct proc *p, struct linux_msgctl_args *args)
|
||||
linux_msgctl(struct thread *td, struct linux_msgctl_args *args)
|
||||
{
|
||||
struct msgctl_args /* {
|
||||
int msqid;
|
||||
@ -311,12 +311,12 @@ linux_msgctl(struct proc *p, struct linux_msgctl_args *args)
|
||||
bsd_args.msqid = args->msqid;
|
||||
bsd_args.cmd = args->cmd;
|
||||
bsd_args.buf = (struct msqid_ds *)args->buf;
|
||||
error = msgctl(p, &bsd_args);
|
||||
error = msgctl(td, &bsd_args);
|
||||
return ((args->cmd == LINUX_IPC_RMID && error == EINVAL) ? 0 : error);
|
||||
}
|
||||
|
||||
int
|
||||
linux_shmat(struct proc *p, struct linux_shmat_args *args)
|
||||
linux_shmat(struct thread *td, struct linux_shmat_args *args)
|
||||
{
|
||||
struct shmat_args /* {
|
||||
int shmid;
|
||||
@ -328,29 +328,29 @@ linux_shmat(struct proc *p, struct linux_shmat_args *args)
|
||||
bsd_args.shmid = args->shmid;
|
||||
bsd_args.shmaddr = args->shmaddr;
|
||||
bsd_args.shmflg = args->shmflg;
|
||||
if ((error = shmat(p, &bsd_args)))
|
||||
if ((error = shmat(td, &bsd_args)))
|
||||
return error;
|
||||
#ifdef __i386__
|
||||
if ((error = copyout(p->p_retval, (caddr_t)args->raddr, sizeof(l_ulong))))
|
||||
if ((error = copyout(td->td_retval, (caddr_t)args->raddr, sizeof(l_ulong))))
|
||||
return error;
|
||||
p->p_retval[0] = 0;
|
||||
td->td_retval[0] = 0;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
linux_shmdt(struct proc *p, struct linux_shmdt_args *args)
|
||||
linux_shmdt(struct thread *td, struct linux_shmdt_args *args)
|
||||
{
|
||||
struct shmdt_args /* {
|
||||
void *shmaddr;
|
||||
} */ bsd_args;
|
||||
|
||||
bsd_args.shmaddr = args->shmaddr;
|
||||
return shmdt(p, &bsd_args);
|
||||
return shmdt(td, &bsd_args);
|
||||
}
|
||||
|
||||
int
|
||||
linux_shmget(struct proc *p, struct linux_shmget_args *args)
|
||||
linux_shmget(struct thread *td, struct linux_shmget_args *args)
|
||||
{
|
||||
struct shmget_args /* {
|
||||
key_t key;
|
||||
@ -361,11 +361,11 @@ linux_shmget(struct proc *p, struct linux_shmget_args *args)
|
||||
bsd_args.key = args->key;
|
||||
bsd_args.size = args->size;
|
||||
bsd_args.shmflg = args->shmflg;
|
||||
return shmget(p, &bsd_args);
|
||||
return shmget(td, &bsd_args);
|
||||
}
|
||||
|
||||
int
|
||||
linux_shmctl(struct proc *p, struct linux_shmctl_args *args)
|
||||
linux_shmctl(struct thread *td, struct linux_shmctl_args *args)
|
||||
{
|
||||
struct l_shmid_ds linux_shmid;
|
||||
struct shmctl_args /* {
|
||||
@ -381,7 +381,7 @@ linux_shmctl(struct proc *p, struct linux_shmctl_args *args)
|
||||
bsd_args.shmid = args->shmid;
|
||||
bsd_args.cmd = IPC_STAT;
|
||||
bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
|
||||
if ((error = shmctl(p, &bsd_args)))
|
||||
if ((error = shmctl(td, &bsd_args)))
|
||||
return error;
|
||||
bsd_to_linux_shmid_ds(bsd_args.buf, &linux_shmid);
|
||||
return copyout(&linux_shmid, (caddr_t)args->buf, sizeof(linux_shmid));
|
||||
@ -394,7 +394,7 @@ linux_shmctl(struct proc *p, struct linux_shmctl_args *args)
|
||||
linux_to_bsd_shmid_ds(&linux_shmid, bsd_args.buf);
|
||||
bsd_args.shmid = args->shmid;
|
||||
bsd_args.cmd = IPC_SET;
|
||||
return shmctl(p, &bsd_args);
|
||||
return shmctl(td, &bsd_args);
|
||||
|
||||
case LINUX_IPC_RMID:
|
||||
bsd_args.shmid = args->shmid;
|
||||
@ -408,7 +408,7 @@ linux_shmctl(struct proc *p, struct linux_shmctl_args *args)
|
||||
bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
|
||||
linux_to_bsd_shmid_ds(&linux_shmid, bsd_args.buf);
|
||||
}
|
||||
return shmctl(p, &bsd_args);
|
||||
return shmctl(td, &bsd_args);
|
||||
|
||||
case LINUX_IPC_INFO:
|
||||
case LINUX_SHM_STAT:
|
||||
|
@ -112,19 +112,19 @@ struct linux_shmget_args
|
||||
l_int shmflg;
|
||||
};
|
||||
|
||||
int linux_msgctl __P((struct proc *, struct linux_msgctl_args *));
|
||||
int linux_msgget __P((struct proc *, struct linux_msgget_args *));
|
||||
int linux_msgrcv __P((struct proc *, struct linux_msgrcv_args *));
|
||||
int linux_msgsnd __P((struct proc *, struct linux_msgsnd_args *));
|
||||
int linux_msgctl __P((struct thread *, struct linux_msgctl_args *));
|
||||
int linux_msgget __P((struct thread *, struct linux_msgget_args *));
|
||||
int linux_msgrcv __P((struct thread *, struct linux_msgrcv_args *));
|
||||
int linux_msgsnd __P((struct thread *, struct linux_msgsnd_args *));
|
||||
|
||||
int linux_semctl __P((struct proc *, struct linux_semctl_args *));
|
||||
int linux_semget __P((struct proc *, struct linux_semget_args *));
|
||||
int linux_semop __P((struct proc *, struct linux_semop_args *));
|
||||
int linux_semctl __P((struct thread *, struct linux_semctl_args *));
|
||||
int linux_semget __P((struct thread *, struct linux_semget_args *));
|
||||
int linux_semop __P((struct thread *, struct linux_semop_args *));
|
||||
|
||||
int linux_shmat __P((struct proc *, struct linux_shmat_args *));
|
||||
int linux_shmctl __P((struct proc *, struct linux_shmctl_args *));
|
||||
int linux_shmdt __P((struct proc *, struct linux_shmdt_args *));
|
||||
int linux_shmget __P((struct proc *, struct linux_shmget_args *));
|
||||
int linux_shmat __P((struct thread *, struct linux_shmat_args *));
|
||||
int linux_shmctl __P((struct thread *, struct linux_shmctl_args *));
|
||||
int linux_shmdt __P((struct thread *, struct linux_shmdt_args *));
|
||||
int linux_shmget __P((struct thread *, struct linux_shmget_args *));
|
||||
|
||||
#endif /* __i386__ */
|
||||
|
||||
|
@ -108,7 +108,7 @@ struct l_sysinfo {
|
||||
};
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_sysinfo(struct proc *p, struct linux_sysinfo_args *args)
|
||||
linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args)
|
||||
{
|
||||
struct l_sysinfo sysinfo;
|
||||
vm_object_t object;
|
||||
@ -164,7 +164,7 @@ linux_sysinfo(struct proc *p, struct linux_sysinfo_args *args)
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_alarm(struct proc *p, struct linux_alarm_args *args)
|
||||
linux_alarm(struct thread *td, struct linux_alarm_args *args)
|
||||
{
|
||||
struct itimerval it, old_it;
|
||||
struct timeval tv;
|
||||
@ -183,31 +183,31 @@ linux_alarm(struct proc *p, struct linux_alarm_args *args)
|
||||
it.it_interval.tv_sec = 0;
|
||||
it.it_interval.tv_usec = 0;
|
||||
s = splsoftclock();
|
||||
old_it = p->p_realtimer;
|
||||
old_it = td->td_proc->p_realtimer;
|
||||
getmicrouptime(&tv);
|
||||
if (timevalisset(&old_it.it_value))
|
||||
callout_stop(&p->p_itcallout);
|
||||
callout_stop(&td->td_proc->p_itcallout);
|
||||
if (it.it_value.tv_sec != 0) {
|
||||
callout_reset(&p->p_itcallout, tvtohz(&it.it_value),
|
||||
realitexpire, p);
|
||||
callout_reset(&td->td_proc->p_itcallout, tvtohz(&it.it_value),
|
||||
realitexpire, td);
|
||||
timevaladd(&it.it_value, &tv);
|
||||
}
|
||||
p->p_realtimer = it;
|
||||
td->td_proc->p_realtimer = it;
|
||||
splx(s);
|
||||
if (timevalcmp(&old_it.it_value, &tv, >)) {
|
||||
timevalsub(&old_it.it_value, &tv);
|
||||
if (old_it.it_value.tv_usec != 0)
|
||||
old_it.it_value.tv_sec++;
|
||||
p->p_retval[0] = old_it.it_value.tv_sec;
|
||||
td->td_retval[0] = old_it.it_value.tv_sec;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
int
|
||||
linux_brk(struct proc *p, struct linux_brk_args *args)
|
||||
linux_brk(struct thread *td, struct linux_brk_args *args)
|
||||
{
|
||||
struct vmspace *vm = p->p_vmspace;
|
||||
struct vmspace *vm = td->td_proc->p_vmspace;
|
||||
vm_offset_t new, old;
|
||||
struct obreak_args /* {
|
||||
char * nsize;
|
||||
@ -220,16 +220,16 @@ linux_brk(struct proc *p, struct linux_brk_args *args)
|
||||
old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize);
|
||||
new = (vm_offset_t)args->dsend;
|
||||
tmp.nsize = (char *) new;
|
||||
if (((caddr_t)new > vm->vm_daddr) && !obreak(p, &tmp))
|
||||
p->p_retval[0] = (long)new;
|
||||
if (((caddr_t)new > vm->vm_daddr) && !obreak(td, &tmp))
|
||||
td->td_retval[0] = (long)new;
|
||||
else
|
||||
p->p_retval[0] = (long)old;
|
||||
td->td_retval[0] = (long)old;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
linux_uselib(struct thread *td, struct linux_uselib_args *args)
|
||||
{
|
||||
struct nameidata ni;
|
||||
struct vnode *vp;
|
||||
@ -244,7 +244,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
int locked;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->library);
|
||||
CHECKALTEXIST(td, &sg, args->library);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(uselib))
|
||||
@ -255,7 +255,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
locked = 0;
|
||||
vp = NULL;
|
||||
|
||||
NDINIT(&ni, LOOKUP, FOLLOW|LOCKLEAF, UIO_USERSPACE, args->library, p);
|
||||
NDINIT(&ni, LOOKUP, FOLLOW|LOCKLEAF, UIO_USERSPACE, args->library, td);
|
||||
error = namei(&ni);
|
||||
if (error)
|
||||
goto cleanup;
|
||||
@ -283,7 +283,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
}
|
||||
|
||||
/* Executable? */
|
||||
error = VOP_GETATTR(vp, &attr, p->p_ucred, p);
|
||||
error = VOP_GETATTR(vp, &attr, td->td_proc->p_ucred, td);
|
||||
if (error)
|
||||
goto cleanup;
|
||||
|
||||
@ -300,18 +300,18 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
}
|
||||
|
||||
/* Can we access it? */
|
||||
error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
|
||||
error = VOP_ACCESS(vp, VEXEC, td->td_proc->p_ucred, td);
|
||||
if (error)
|
||||
goto cleanup;
|
||||
|
||||
error = VOP_OPEN(vp, FREAD, p->p_ucred, p);
|
||||
error = VOP_OPEN(vp, FREAD, td->td_proc->p_ucred, td);
|
||||
if (error)
|
||||
goto cleanup;
|
||||
|
||||
/*
|
||||
* Lock no longer needed
|
||||
*/
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
VOP_UNLOCK(vp, 0, td);
|
||||
locked = 0;
|
||||
|
||||
/* Pull in executable header into kernel_map */
|
||||
@ -357,7 +357,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* To protect p->p_rlimit in the if condition. */
|
||||
/* To protect td->td_proc->p_rlimit in the if condition. */
|
||||
mtx_assert(&Giant, MA_OWNED);
|
||||
|
||||
/*
|
||||
@ -366,7 +366,8 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
* the resources needed by this library.
|
||||
*/
|
||||
if (a_out->a_text > MAXTSIZ ||
|
||||
a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) {
|
||||
a_out->a_data + bss_size >
|
||||
td->td_proc->p_rlimit[RLIMIT_DATA].rlim_cur) {
|
||||
error = ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
@ -389,8 +390,8 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
vmaddr = trunc_page(a_out->a_entry);
|
||||
|
||||
/* get anon user mapping, read+write+execute */
|
||||
error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr,
|
||||
a_out->a_text + a_out->a_data, FALSE, VM_PROT_ALL,
|
||||
error = vm_map_find(&td->td_proc->p_vmspace->vm_map, NULL, 0,
|
||||
&vmaddr, a_out->a_text + a_out->a_data, FALSE, VM_PROT_ALL,
|
||||
VM_PROT_ALL, 0);
|
||||
if (error)
|
||||
goto cleanup;
|
||||
@ -427,7 +428,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
* Map it all into the process's space as a single
|
||||
* copy-on-write "data" segment.
|
||||
*/
|
||||
error = vm_mmap(&p->p_vmspace->vm_map, &vmaddr,
|
||||
error = vm_mmap(&td->td_proc->p_vmspace->vm_map, &vmaddr,
|
||||
a_out->a_text + a_out->a_data, VM_PROT_ALL, VM_PROT_ALL,
|
||||
MAP_PRIVATE | MAP_FIXED, (caddr_t)vp, file_offset);
|
||||
if (error)
|
||||
@ -443,8 +444,8 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
a_out->a_data;
|
||||
|
||||
/* allocate some 'anon' space */
|
||||
error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr,
|
||||
bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
|
||||
error = vm_map_find(&td->td_proc->p_vmspace->vm_map, NULL, 0,
|
||||
&vmaddr, bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
|
||||
if (error)
|
||||
goto cleanup;
|
||||
}
|
||||
@ -452,7 +453,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
cleanup:
|
||||
/* Unlock vnode if needed */
|
||||
if (locked)
|
||||
VOP_UNLOCK(vp, 0, p);
|
||||
VOP_UNLOCK(vp, 0, td);
|
||||
|
||||
/* Release the kernel mapping. */
|
||||
if (a_out)
|
||||
@ -463,7 +464,7 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_select(struct proc *p, struct linux_select_args *args)
|
||||
linux_select(struct thread *td, struct linux_select_args *args)
|
||||
{
|
||||
struct select_args bsa;
|
||||
struct timeval tv0, tv1, utv, *tvp;
|
||||
@ -520,7 +521,7 @@ linux_select(struct proc *p, struct linux_select_args *args)
|
||||
microtime(&tv0);
|
||||
}
|
||||
|
||||
error = select(p, &bsa);
|
||||
error = select(td, &bsa);
|
||||
#ifdef DEBUG
|
||||
if (ldebug(select))
|
||||
printf(LMSG("real select returns %d"), error);
|
||||
@ -536,7 +537,7 @@ linux_select(struct proc *p, struct linux_select_args *args)
|
||||
}
|
||||
|
||||
if (args->timeout) {
|
||||
if (p->p_retval[0]) {
|
||||
if (td->td_retval[0]) {
|
||||
/*
|
||||
* Compute how much time was left of the timeout,
|
||||
* by subtracting the current time and the time
|
||||
@ -569,7 +570,7 @@ linux_select(struct proc *p, struct linux_select_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_getpgid(struct proc *p, struct linux_getpgid_args *args)
|
||||
linux_getpgid(struct thread *td, struct linux_getpgid_args *args)
|
||||
{
|
||||
struct proc *curp;
|
||||
|
||||
@ -578,19 +579,19 @@ linux_getpgid(struct proc *p, struct linux_getpgid_args *args)
|
||||
printf(ARGS(getpgid, "%d"), args->pid);
|
||||
#endif
|
||||
|
||||
if (args->pid != p->p_pid) {
|
||||
if (args->pid != td->td_proc->p_pid) {
|
||||
if (!(curp = pfind(args->pid)))
|
||||
return ESRCH;
|
||||
p->p_retval[0] = curp->p_pgid;
|
||||
td->td_retval[0] = curp->p_pgid;
|
||||
PROC_UNLOCK(curp);
|
||||
} else
|
||||
p->p_retval[0] = p->p_pgid;
|
||||
td->td_retval[0] = td->td_proc->p_pgid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
linux_mremap(struct proc *p, struct linux_mremap_args *args)
|
||||
linux_mremap(struct thread *td, struct linux_mremap_args *args)
|
||||
{
|
||||
struct munmap_args /* {
|
||||
void *addr;
|
||||
@ -610,22 +611,22 @@ linux_mremap(struct proc *p, struct linux_mremap_args *args)
|
||||
args->old_len = round_page(args->old_len);
|
||||
|
||||
if (args->new_len > args->old_len) {
|
||||
p->p_retval[0] = 0;
|
||||
td->td_retval[0] = 0;
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (args->new_len < args->old_len) {
|
||||
bsd_args.addr = (caddr_t)(args->addr + args->new_len);
|
||||
bsd_args.len = args->old_len - args->new_len;
|
||||
error = munmap(p, &bsd_args);
|
||||
error = munmap(td, &bsd_args);
|
||||
}
|
||||
|
||||
p->p_retval[0] = error ? 0 : (u_long)args->addr;
|
||||
td->td_retval[0] = error ? 0 : (u_long)args->addr;
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
linux_msync(struct proc *p, struct linux_msync_args *args)
|
||||
linux_msync(struct thread *td, struct linux_msync_args *args)
|
||||
{
|
||||
struct msync_args bsd_args;
|
||||
|
||||
@ -633,12 +634,12 @@ linux_msync(struct proc *p, struct linux_msync_args *args)
|
||||
bsd_args.len = args->len;
|
||||
bsd_args.flags = 0; /* XXX ignore */
|
||||
|
||||
return msync(p, &bsd_args);
|
||||
return msync(td, &bsd_args);
|
||||
}
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_time(struct proc *p, struct linux_time_args *args)
|
||||
linux_time(struct thread *td, struct linux_time_args *args)
|
||||
{
|
||||
struct timeval tv;
|
||||
l_time_t tm;
|
||||
@ -653,7 +654,7 @@ linux_time(struct proc *p, struct linux_time_args *args)
|
||||
tm = tv.tv_sec;
|
||||
if (args->tm && (error = copyout(&tm, (caddr_t)args->tm, sizeof(tm))))
|
||||
return error;
|
||||
p->p_retval[0] = tm;
|
||||
td->td_retval[0] = tm;
|
||||
return 0;
|
||||
}
|
||||
#endif /*!__alpha__*/
|
||||
@ -674,7 +675,7 @@ struct l_times_argv {
|
||||
#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK))
|
||||
|
||||
int
|
||||
linux_times(struct proc *p, struct linux_times_args *args)
|
||||
linux_times(struct thread *td, struct linux_times_args *args)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct l_times_argv tms;
|
||||
@ -687,25 +688,25 @@ linux_times(struct proc *p, struct linux_times_args *args)
|
||||
#endif
|
||||
|
||||
mtx_lock_spin(&sched_lock);
|
||||
calcru(p, &ru.ru_utime, &ru.ru_stime, NULL);
|
||||
calcru(td->td_proc, &ru.ru_utime, &ru.ru_stime, NULL);
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
|
||||
tms.tms_utime = CONVTCK(ru.ru_utime);
|
||||
tms.tms_stime = CONVTCK(ru.ru_stime);
|
||||
|
||||
tms.tms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime);
|
||||
tms.tms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime);
|
||||
tms.tms_cutime = CONVTCK(td->td_proc->p_stats->p_cru.ru_utime);
|
||||
tms.tms_cstime = CONVTCK(td->td_proc->p_stats->p_cru.ru_stime);
|
||||
|
||||
if ((error = copyout(&tms, (caddr_t)args->buf, sizeof(tms))))
|
||||
return error;
|
||||
|
||||
microuptime(&tv);
|
||||
p->p_retval[0] = (int)CONVTCK(tv);
|
||||
td->td_retval[0] = (int)CONVTCK(tv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
linux_newuname(struct proc *p, struct linux_newuname_args *args)
|
||||
linux_newuname(struct thread *td, struct linux_newuname_args *args)
|
||||
{
|
||||
struct l_new_utsname utsname;
|
||||
char *osrelease, *osname;
|
||||
@ -715,8 +716,8 @@ linux_newuname(struct proc *p, struct linux_newuname_args *args)
|
||||
printf(ARGS(newuname, "*"));
|
||||
#endif
|
||||
|
||||
osname = linux_get_osname(p);
|
||||
osrelease = linux_get_osrelease(p);
|
||||
osname = linux_get_osname(td->td_proc);
|
||||
osrelease = linux_get_osrelease(td->td_proc);
|
||||
|
||||
bzero(&utsname, sizeof(utsname));
|
||||
strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1);
|
||||
@ -736,7 +737,7 @@ struct l_utimbuf {
|
||||
};
|
||||
|
||||
int
|
||||
linux_utime(struct proc *p, struct linux_utime_args *args)
|
||||
linux_utime(struct thread *td, struct linux_utime_args *args)
|
||||
{
|
||||
struct utimes_args /* {
|
||||
char *path;
|
||||
@ -748,7 +749,7 @@ linux_utime(struct proc *p, struct linux_utime_args *args)
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->fname);
|
||||
CHECKALTEXIST(td, &sg, args->fname);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(utime))
|
||||
@ -773,7 +774,7 @@ linux_utime(struct proc *p, struct linux_utime_args *args)
|
||||
bsdutimes.tptr = NULL;
|
||||
|
||||
bsdutimes.path = args->fname;
|
||||
return utimes(p, &bsdutimes);
|
||||
return utimes(td, &bsdutimes);
|
||||
}
|
||||
#endif /* __i386__ */
|
||||
|
||||
@ -781,7 +782,7 @@ linux_utime(struct proc *p, struct linux_utime_args *args)
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_waitpid(struct proc *p, struct linux_waitpid_args *args)
|
||||
linux_waitpid(struct thread *td, struct linux_waitpid_args *args)
|
||||
{
|
||||
struct wait_args /* {
|
||||
int pid;
|
||||
@ -805,7 +806,7 @@ linux_waitpid(struct proc *p, struct linux_waitpid_args *args)
|
||||
tmp.options |= WLINUXCLONE;
|
||||
tmp.rusage = NULL;
|
||||
|
||||
if ((error = wait4(p, &tmp)) != 0)
|
||||
if ((error = wait4(td, &tmp)) != 0)
|
||||
return error;
|
||||
|
||||
if (args->status) {
|
||||
@ -827,7 +828,7 @@ linux_waitpid(struct proc *p, struct linux_waitpid_args *args)
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
int
|
||||
linux_wait4(struct proc *p, struct linux_wait4_args *args)
|
||||
linux_wait4(struct thread *td, struct linux_wait4_args *args)
|
||||
{
|
||||
struct wait_args /* {
|
||||
int pid;
|
||||
@ -852,10 +853,10 @@ linux_wait4(struct proc *p, struct linux_wait4_args *args)
|
||||
tmp.options |= WLINUXCLONE;
|
||||
tmp.rusage = (struct rusage *)args->rusage;
|
||||
|
||||
if ((error = wait4(p, &tmp)) != 0)
|
||||
if ((error = wait4(td, &tmp)) != 0)
|
||||
return error;
|
||||
|
||||
SIGDELSET(p->p_siglist, SIGCHLD);
|
||||
SIGDELSET(td->td_proc->p_siglist, SIGCHLD);
|
||||
|
||||
if (args->status) {
|
||||
if ((error = copyin((caddr_t)args->status, &tmpstat,
|
||||
@ -875,7 +876,7 @@ linux_wait4(struct proc *p, struct linux_wait4_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_mknod(struct proc *p, struct linux_mknod_args *args)
|
||||
linux_mknod(struct thread *td, struct linux_mknod_args *args)
|
||||
{
|
||||
caddr_t sg;
|
||||
struct mknod_args bsd_mknod;
|
||||
@ -883,7 +884,7 @@ linux_mknod(struct proc *p, struct linux_mknod_args *args)
|
||||
|
||||
sg = stackgap_init();
|
||||
|
||||
CHECKALTCREAT(p, &sg, args->path);
|
||||
CHECKALTCREAT(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(mknod))
|
||||
@ -894,12 +895,12 @@ linux_mknod(struct proc *p, struct linux_mknod_args *args)
|
||||
if (args->mode & S_IFIFO) {
|
||||
bsd_mkfifo.path = args->path;
|
||||
bsd_mkfifo.mode = args->mode;
|
||||
return mkfifo(p, &bsd_mkfifo);
|
||||
return mkfifo(td, &bsd_mkfifo);
|
||||
} else {
|
||||
bsd_mknod.path = args->path;
|
||||
bsd_mknod.mode = args->mode;
|
||||
bsd_mknod.dev = args->dev;
|
||||
return mknod(p, &bsd_mknod);
|
||||
return mknod(td, &bsd_mknod);
|
||||
}
|
||||
}
|
||||
|
||||
@ -907,7 +908,7 @@ linux_mknod(struct proc *p, struct linux_mknod_args *args)
|
||||
* UGH! This is just about the dumbest idea I've ever heard!!
|
||||
*/
|
||||
int
|
||||
linux_personality(struct proc *p, struct linux_personality_args *args)
|
||||
linux_personality(struct thread *td, struct linux_personality_args *args)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (ldebug(personality))
|
||||
@ -919,7 +920,7 @@ linux_personality(struct proc *p, struct linux_personality_args *args)
|
||||
#endif
|
||||
|
||||
/* Yes Jim, it's still a Linux... */
|
||||
p->p_retval[0] = 0;
|
||||
td->td_retval[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -927,7 +928,7 @@ linux_personality(struct proc *p, struct linux_personality_args *args)
|
||||
* Wrappers for get/setitimer for debugging..
|
||||
*/
|
||||
int
|
||||
linux_setitimer(struct proc *p, struct linux_setitimer_args *args)
|
||||
linux_setitimer(struct thread *td, struct linux_setitimer_args *args)
|
||||
{
|
||||
struct setitimer_args bsa;
|
||||
struct itimerval foo;
|
||||
@ -953,11 +954,11 @@ linux_setitimer(struct proc *p, struct linux_setitimer_args *args)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return setitimer(p, &bsa);
|
||||
return setitimer(td, &bsa);
|
||||
}
|
||||
|
||||
int
|
||||
linux_getitimer(struct proc *p, struct linux_getitimer_args *args)
|
||||
linux_getitimer(struct thread *td, struct linux_getitimer_args *args)
|
||||
{
|
||||
struct getitimer_args bsa;
|
||||
#ifdef DEBUG
|
||||
@ -966,24 +967,24 @@ linux_getitimer(struct proc *p, struct linux_getitimer_args *args)
|
||||
#endif
|
||||
bsa.which = args->which;
|
||||
bsa.itv = (struct itimerval *)args->itv;
|
||||
return getitimer(p, &bsa);
|
||||
return getitimer(td, &bsa);
|
||||
}
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_nice(struct proc *p, struct linux_nice_args *args)
|
||||
linux_nice(struct thread *td, struct linux_nice_args *args)
|
||||
{
|
||||
struct setpriority_args bsd_args;
|
||||
|
||||
bsd_args.which = PRIO_PROCESS;
|
||||
bsd_args.who = 0; /* current process */
|
||||
bsd_args.prio = args->inc;
|
||||
return setpriority(p, &bsd_args);
|
||||
return setpriority(td, &bsd_args);
|
||||
}
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
int
|
||||
linux_setgroups(struct proc *p, struct linux_setgroups_args *args)
|
||||
linux_setgroups(struct thread *td, struct linux_setgroups_args *args)
|
||||
{
|
||||
struct ucred *newcred, *oldcred;
|
||||
l_gid_t linux_gidset[NGROUPS];
|
||||
@ -991,7 +992,7 @@ linux_setgroups(struct proc *p, struct linux_setgroups_args *args)
|
||||
int ngrp, error;
|
||||
|
||||
ngrp = args->gidsetsize;
|
||||
oldcred = p->p_ucred;
|
||||
oldcred = td->td_proc->p_ucred;
|
||||
|
||||
/*
|
||||
* cr_groups[0] holds egid. Setting the whole set from
|
||||
@ -1024,21 +1025,21 @@ linux_setgroups(struct proc *p, struct linux_setgroups_args *args)
|
||||
else
|
||||
newcred->cr_ngroups = 1;
|
||||
|
||||
setsugid(p);
|
||||
p->p_ucred = newcred;
|
||||
setsugid(td->td_proc);
|
||||
td->td_proc->p_ucred = newcred;
|
||||
crfree(oldcred);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_getgroups(struct proc *p, struct linux_getgroups_args *args)
|
||||
linux_getgroups(struct thread *td, struct linux_getgroups_args *args)
|
||||
{
|
||||
struct ucred *cred;
|
||||
l_gid_t linux_gidset[NGROUPS];
|
||||
gid_t *bsd_gidset;
|
||||
int bsd_gidsetsz, ngrp, error;
|
||||
|
||||
cred = p->p_ucred;
|
||||
cred = td->td_proc->p_ucred;
|
||||
bsd_gidset = cred->cr_groups;
|
||||
bsd_gidsetsz = cred->cr_ngroups - 1;
|
||||
|
||||
@ -1049,7 +1050,7 @@ linux_getgroups(struct proc *p, struct linux_getgroups_args *args)
|
||||
*/
|
||||
|
||||
if ((ngrp = args->gidsetsize) == 0) {
|
||||
p->p_retval[0] = bsd_gidsetsz;
|
||||
td->td_retval[0] = bsd_gidsetsz;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1066,13 +1067,13 @@ linux_getgroups(struct proc *p, struct linux_getgroups_args *args)
|
||||
ngrp * sizeof(l_gid_t))))
|
||||
return (error);
|
||||
|
||||
p->p_retval[0] = ngrp;
|
||||
td->td_retval[0] = ngrp;
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_setrlimit(struct proc *p, struct linux_setrlimit_args *args)
|
||||
linux_setrlimit(struct thread *td, struct linux_setrlimit_args *args)
|
||||
{
|
||||
struct __setrlimit_args bsd;
|
||||
struct l_rlimit rlim;
|
||||
@ -1099,11 +1100,11 @@ linux_setrlimit(struct proc *p, struct linux_setrlimit_args *args)
|
||||
bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit));
|
||||
bsd.rlp->rlim_cur = (rlim_t)rlim.rlim_cur;
|
||||
bsd.rlp->rlim_max = (rlim_t)rlim.rlim_max;
|
||||
return (setrlimit(p, &bsd));
|
||||
return (setrlimit(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_old_getrlimit(struct proc *p, struct linux_old_getrlimit_args *args)
|
||||
linux_old_getrlimit(struct thread *td, struct linux_old_getrlimit_args *args)
|
||||
{
|
||||
struct __getrlimit_args bsd;
|
||||
struct l_rlimit rlim;
|
||||
@ -1124,7 +1125,7 @@ linux_old_getrlimit(struct proc *p, struct linux_old_getrlimit_args *args)
|
||||
return (EINVAL);
|
||||
|
||||
bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit));
|
||||
error = getrlimit(p, &bsd);
|
||||
error = getrlimit(td, &bsd);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -1138,7 +1139,7 @@ linux_old_getrlimit(struct proc *p, struct linux_old_getrlimit_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_getrlimit(struct proc *p, struct linux_getrlimit_args *args)
|
||||
linux_getrlimit(struct thread *td, struct linux_getrlimit_args *args)
|
||||
{
|
||||
struct __getrlimit_args bsd;
|
||||
struct l_rlimit rlim;
|
||||
@ -1159,7 +1160,7 @@ linux_getrlimit(struct proc *p, struct linux_getrlimit_args *args)
|
||||
return (EINVAL);
|
||||
|
||||
bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit));
|
||||
error = getrlimit(p, &bsd);
|
||||
error = getrlimit(td, &bsd);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -1170,7 +1171,7 @@ linux_getrlimit(struct proc *p, struct linux_getrlimit_args *args)
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
int
|
||||
linux_sched_setscheduler(struct proc *p,
|
||||
linux_sched_setscheduler(struct thread *td,
|
||||
struct linux_sched_setscheduler_args *args)
|
||||
{
|
||||
struct sched_setscheduler_args bsd;
|
||||
@ -1197,11 +1198,11 @@ linux_sched_setscheduler(struct proc *p,
|
||||
|
||||
bsd.pid = args->pid;
|
||||
bsd.param = (struct sched_param *)args->param;
|
||||
return sched_setscheduler(p, &bsd);
|
||||
return sched_setscheduler(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sched_getscheduler(struct proc *p,
|
||||
linux_sched_getscheduler(struct thread *td,
|
||||
struct linux_sched_getscheduler_args *args)
|
||||
{
|
||||
struct sched_getscheduler_args bsd;
|
||||
@ -1213,17 +1214,17 @@ linux_sched_getscheduler(struct proc *p,
|
||||
#endif
|
||||
|
||||
bsd.pid = args->pid;
|
||||
error = sched_getscheduler(p, &bsd);
|
||||
error = sched_getscheduler(td, &bsd);
|
||||
|
||||
switch (p->p_retval[0]) {
|
||||
switch (td->td_retval[0]) {
|
||||
case SCHED_OTHER:
|
||||
p->p_retval[0] = LINUX_SCHED_OTHER;
|
||||
td->td_retval[0] = LINUX_SCHED_OTHER;
|
||||
break;
|
||||
case SCHED_FIFO:
|
||||
p->p_retval[0] = LINUX_SCHED_FIFO;
|
||||
td->td_retval[0] = LINUX_SCHED_FIFO;
|
||||
break;
|
||||
case SCHED_RR:
|
||||
p->p_retval[0] = LINUX_SCHED_RR;
|
||||
td->td_retval[0] = LINUX_SCHED_RR;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1231,7 +1232,7 @@ linux_sched_getscheduler(struct proc *p,
|
||||
}
|
||||
|
||||
int
|
||||
linux_sched_get_priority_max(struct proc *p,
|
||||
linux_sched_get_priority_max(struct thread *td,
|
||||
struct linux_sched_get_priority_max_args *args)
|
||||
{
|
||||
struct sched_get_priority_max_args bsd;
|
||||
@ -1254,11 +1255,11 @@ linux_sched_get_priority_max(struct proc *p,
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
return sched_get_priority_max(p, &bsd);
|
||||
return sched_get_priority_max(td, &bsd);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sched_get_priority_min(struct proc *p,
|
||||
linux_sched_get_priority_min(struct thread *td,
|
||||
struct linux_sched_get_priority_min_args *args)
|
||||
{
|
||||
struct sched_get_priority_min_args bsd;
|
||||
@ -1281,7 +1282,7 @@ linux_sched_get_priority_min(struct proc *p,
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
return sched_get_priority_min(p, &bsd);
|
||||
return sched_get_priority_min(td, &bsd);
|
||||
}
|
||||
|
||||
#define REBOOT_CAD_ON 0x89abcdef
|
||||
@ -1289,7 +1290,7 @@ linux_sched_get_priority_min(struct proc *p,
|
||||
#define REBOOT_HALT 0xcdef0123
|
||||
|
||||
int
|
||||
linux_reboot(struct proc *p, struct linux_reboot_args *args)
|
||||
linux_reboot(struct thread *td, struct linux_reboot_args *args)
|
||||
{
|
||||
struct reboot_args bsd_args;
|
||||
|
||||
@ -1300,12 +1301,12 @@ linux_reboot(struct proc *p, struct linux_reboot_args *args)
|
||||
if (args->cmd == REBOOT_CAD_ON || args->cmd == REBOOT_CAD_OFF)
|
||||
return (0);
|
||||
bsd_args.opt = (args->cmd == REBOOT_HALT) ? RB_HALT : 0;
|
||||
return (reboot(p, &bsd_args));
|
||||
return (reboot(td, &bsd_args));
|
||||
}
|
||||
|
||||
/*
|
||||
* The FreeBSD native getpid(2), getgid(2) and getuid(2) also modify
|
||||
* p->p_retval[1] when COMPAT_43 or COMPAT_SUNOS is defined. This
|
||||
* td->td_retval[1] when COMPAT_43 or COMPAT_SUNOS is defined. This
|
||||
* globbers registers that are assumed to be preserved. The following
|
||||
* lightweight syscalls fixes this. See also linux_getgid16() and
|
||||
* linux_getuid16() in linux_uid16.c.
|
||||
@ -1316,22 +1317,25 @@ linux_reboot(struct proc *p, struct linux_reboot_args *args)
|
||||
*/
|
||||
|
||||
int
|
||||
linux_getpid(struct proc *p, struct linux_getpid_args *args)
|
||||
linux_getpid(struct thread *td, struct linux_getpid_args *args)
|
||||
{
|
||||
p->p_retval[0] = p->p_pid;
|
||||
|
||||
td->td_retval[0] = td->td_proc->p_pid;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_getgid(struct proc *p, struct linux_getgid_args *args)
|
||||
linux_getgid(struct thread *td, struct linux_getgid_args *args)
|
||||
{
|
||||
p->p_retval[0] = p->p_ucred->cr_rgid;
|
||||
|
||||
td->td_retval[0] = td->td_proc->p_ucred->cr_rgid;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_getuid(struct proc *p, struct linux_getuid_args *args)
|
||||
linux_getuid(struct thread *td, struct linux_getuid_args *args)
|
||||
{
|
||||
p->p_retval[0] = p->p_ucred->cr_ruid;
|
||||
|
||||
td->td_retval[0] = td->td_proc->p_ucred->cr_ruid;
|
||||
return (0);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ bsd_to_linux_sigaction(struct sigaction *bsa, l_sigaction_t *lsa)
|
||||
}
|
||||
|
||||
int
|
||||
linux_do_sigaction(struct proc *p, int linux_sig, l_sigaction_t *linux_nsa,
|
||||
linux_do_sigaction(struct thread *td, int linux_sig, l_sigaction_t *linux_nsa,
|
||||
l_sigaction_t *linux_osa)
|
||||
{
|
||||
struct sigaction *nsa, *osa;
|
||||
@ -163,7 +163,7 @@ linux_do_sigaction(struct proc *p, int linux_sig, l_sigaction_t *linux_nsa,
|
||||
|
||||
sa_args.act = nsa;
|
||||
sa_args.oact = osa;
|
||||
error = sigaction(p, &sa_args);
|
||||
error = sigaction(td, &sa_args);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -176,7 +176,7 @@ linux_do_sigaction(struct proc *p, int linux_sig, l_sigaction_t *linux_nsa,
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_signal(struct proc *p, struct linux_signal_args *args)
|
||||
linux_signal(struct thread *td, struct linux_signal_args *args)
|
||||
{
|
||||
l_sigaction_t nsa, osa;
|
||||
int error;
|
||||
@ -191,15 +191,15 @@ linux_signal(struct proc *p, struct linux_signal_args *args)
|
||||
nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK;
|
||||
LINUX_SIGEMPTYSET(nsa.lsa_mask);
|
||||
|
||||
error = linux_do_sigaction(p, args->sig, &nsa, &osa);
|
||||
p->p_retval[0] = (int)osa.lsa_handler;
|
||||
error = linux_do_sigaction(td, args->sig, &nsa, &osa);
|
||||
td->td_retval[0] = (int)osa.lsa_handler;
|
||||
|
||||
return (error);
|
||||
}
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
int
|
||||
linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args)
|
||||
linux_rt_sigaction(struct thread *td, struct linux_rt_sigaction_args *args)
|
||||
{
|
||||
l_sigaction_t nsa, osa;
|
||||
int error;
|
||||
@ -220,7 +220,7 @@ linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args)
|
||||
return (error);
|
||||
}
|
||||
|
||||
error = linux_do_sigaction(p, args->sig,
|
||||
error = linux_do_sigaction(td, args->sig,
|
||||
args->act ? &nsa : NULL,
|
||||
args->oact ? &osa : NULL);
|
||||
|
||||
@ -232,14 +232,15 @@ linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args)
|
||||
}
|
||||
|
||||
static int
|
||||
linux_do_sigprocmask(struct proc *p, int how, l_sigset_t *new,
|
||||
linux_do_sigprocmask(struct thread *td, int how, l_sigset_t *new,
|
||||
l_sigset_t *old)
|
||||
{
|
||||
int error;
|
||||
sigset_t mask;
|
||||
struct proc *p = td->td_proc;
|
||||
|
||||
error = 0;
|
||||
p->p_retval[0] = 0;
|
||||
td->td_retval[0] = 0;
|
||||
|
||||
PROC_LOCK(p);
|
||||
if (old != NULL)
|
||||
@ -272,7 +273,7 @@ linux_do_sigprocmask(struct proc *p, int how, l_sigset_t *new,
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args)
|
||||
linux_sigprocmask(struct thread *td, struct linux_sigprocmask_args *args)
|
||||
{
|
||||
l_osigset_t mask;
|
||||
l_sigset_t set, oset;
|
||||
@ -291,7 +292,7 @@ linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args)
|
||||
set.__bits[0] = mask;
|
||||
}
|
||||
|
||||
error = linux_do_sigprocmask(p, args->how,
|
||||
error = linux_do_sigprocmask(td, args->how,
|
||||
args->mask ? &set : NULL,
|
||||
args->omask ? &oset : NULL);
|
||||
|
||||
@ -305,7 +306,7 @@ linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args)
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
int
|
||||
linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args)
|
||||
linux_rt_sigprocmask(struct thread *td, struct linux_rt_sigprocmask_args *args)
|
||||
{
|
||||
l_sigset_t set, oset;
|
||||
int error;
|
||||
@ -326,7 +327,7 @@ linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args)
|
||||
return (error);
|
||||
}
|
||||
|
||||
error = linux_do_sigprocmask(p, args->how,
|
||||
error = linux_do_sigprocmask(td, args->how,
|
||||
args->mask ? &set : NULL,
|
||||
args->omask ? &oset : NULL);
|
||||
|
||||
@ -339,8 +340,9 @@ linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args)
|
||||
|
||||
#ifndef __alpha__
|
||||
int
|
||||
linux_sgetmask(struct proc *p, struct linux_sgetmask_args *args)
|
||||
linux_sgetmask(struct thread *td, struct linux_sgetmask_args *args)
|
||||
{
|
||||
struct proc *p = td->td_proc;
|
||||
l_sigset_t mask;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -351,13 +353,14 @@ linux_sgetmask(struct proc *p, struct linux_sgetmask_args *args)
|
||||
PROC_LOCK(p);
|
||||
bsd_to_linux_sigset(&p->p_sigmask, &mask);
|
||||
PROC_UNLOCK(p);
|
||||
p->p_retval[0] = mask.__bits[0];
|
||||
td->td_retval[0] = mask.__bits[0];
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_ssetmask(struct proc *p, struct linux_ssetmask_args *args)
|
||||
linux_ssetmask(struct thread *td, struct linux_ssetmask_args *args)
|
||||
{
|
||||
struct proc *p = td->td_proc;
|
||||
l_sigset_t lset;
|
||||
sigset_t bset;
|
||||
|
||||
@ -368,7 +371,7 @@ linux_ssetmask(struct proc *p, struct linux_ssetmask_args *args)
|
||||
|
||||
PROC_LOCK(p);
|
||||
bsd_to_linux_sigset(&p->p_sigmask, &lset);
|
||||
p->p_retval[0] = lset.__bits[0];
|
||||
td->td_retval[0] = lset.__bits[0];
|
||||
LINUX_SIGEMPTYSET(lset);
|
||||
lset.__bits[0] = args->mask;
|
||||
linux_to_bsd_sigset(&lset, &bset);
|
||||
@ -379,8 +382,9 @@ linux_ssetmask(struct proc *p, struct linux_ssetmask_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_sigpending(struct proc *p, struct linux_sigpending_args *args)
|
||||
linux_sigpending(struct thread *td, struct linux_sigpending_args *args)
|
||||
{
|
||||
struct proc *p = td->td_proc;
|
||||
sigset_t bset;
|
||||
l_sigset_t lset;
|
||||
l_osigset_t mask;
|
||||
@ -401,7 +405,7 @@ linux_sigpending(struct proc *p, struct linux_sigpending_args *args)
|
||||
#endif /*!__alpha__*/
|
||||
|
||||
int
|
||||
linux_kill(struct proc *p, struct linux_kill_args *args)
|
||||
linux_kill(struct thread *td, struct linux_kill_args *args)
|
||||
{
|
||||
struct kill_args /* {
|
||||
int pid;
|
||||
@ -427,5 +431,5 @@ linux_kill(struct proc *p, struct linux_kill_args *args)
|
||||
tmp.signum = args->signum;
|
||||
|
||||
tmp.pid = args->pid;
|
||||
return (kill(p, &tmp));
|
||||
return (kill(td, &tmp));
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
void linux_to_bsd_sigset __P((l_sigset_t *, sigset_t *));
|
||||
void bsd_to_linux_sigset __P((sigset_t *, l_sigset_t *));
|
||||
int linux_do_sigaction __P((struct proc *, int, l_sigaction_t *,
|
||||
int linux_do_sigaction __P((struct thread *, int, l_sigaction_t *,
|
||||
l_sigaction_t *));
|
||||
|
||||
#endif /* _LINUX_SIGNAL_H_ */
|
||||
|
@ -187,7 +187,7 @@ linux_to_bsd_msg_flags(int flags)
|
||||
|
||||
/* Return 0 if IP_HDRINCL is set for the given socket. */
|
||||
static int
|
||||
linux_check_hdrincl(struct proc *p, int s)
|
||||
linux_check_hdrincl(struct thread *td, int s)
|
||||
{
|
||||
struct getsockopt_args /* {
|
||||
int s;
|
||||
@ -213,7 +213,7 @@ linux_check_hdrincl(struct proc *p, int s)
|
||||
bsd_args.name = IP_HDRINCL;
|
||||
bsd_args.val = val;
|
||||
bsd_args.avalsize = (int *)valsize;
|
||||
if ((error = getsockopt(p, &bsd_args)))
|
||||
if ((error = getsockopt(td, &bsd_args)))
|
||||
return (error);
|
||||
|
||||
if ((error = copyin(val, &optval, sizeof(optval))))
|
||||
@ -227,7 +227,7 @@ linux_check_hdrincl(struct proc *p, int s)
|
||||
* tweak endian-dependent fields in the IP packet.
|
||||
*/
|
||||
static int
|
||||
linux_sendto_hdrincl(struct proc *p, struct sendto_args *bsd_args)
|
||||
linux_sendto_hdrincl(struct thread *td, struct sendto_args *bsd_args)
|
||||
{
|
||||
/*
|
||||
* linux_ip_copysize defines how many bytes we should copy
|
||||
@ -288,7 +288,7 @@ linux_sendto_hdrincl(struct proc *p, struct sendto_args *bsd_args)
|
||||
sendmsg_args.s = bsd_args->s;
|
||||
sendmsg_args.msg = (caddr_t)msg;
|
||||
sendmsg_args.flags = bsd_args->flags;
|
||||
return (sendmsg(p, &sendmsg_args));
|
||||
return (sendmsg(td, &sendmsg_args));
|
||||
}
|
||||
|
||||
struct linux_socket_args {
|
||||
@ -298,7 +298,7 @@ struct linux_socket_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_socket(struct proc *p, struct linux_socket_args *args)
|
||||
linux_socket(struct thread *td, struct linux_socket_args *args)
|
||||
{
|
||||
struct linux_socket_args linux_args;
|
||||
struct socket_args /* {
|
||||
@ -318,7 +318,7 @@ linux_socket(struct proc *p, struct linux_socket_args *args)
|
||||
if (bsd_args.domain == -1)
|
||||
return (EINVAL);
|
||||
|
||||
retval_socket = socket(p, &bsd_args);
|
||||
retval_socket = socket(td, &bsd_args);
|
||||
if (bsd_args.type == SOCK_RAW
|
||||
&& (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0)
|
||||
&& bsd_args.domain == AF_INET
|
||||
@ -337,15 +337,15 @@ linux_socket(struct proc *p, struct linux_socket_args *args)
|
||||
sg = stackgap_init();
|
||||
hdrincl = (int *)stackgap_alloc(&sg, sizeof(*hdrincl));
|
||||
*hdrincl = 1;
|
||||
bsd_setsockopt_args.s = p->p_retval[0];
|
||||
bsd_setsockopt_args.s = td->td_retval[0];
|
||||
bsd_setsockopt_args.level = IPPROTO_IP;
|
||||
bsd_setsockopt_args.name = IP_HDRINCL;
|
||||
bsd_setsockopt_args.val = (caddr_t)hdrincl;
|
||||
bsd_setsockopt_args.valsize = sizeof(*hdrincl);
|
||||
/* We ignore any error returned by setsockopt() */
|
||||
setsockopt(p, &bsd_setsockopt_args);
|
||||
setsockopt(td, &bsd_setsockopt_args);
|
||||
/* Copy back the return value from socket() */
|
||||
p->p_retval[0] = bsd_setsockopt_args.s;
|
||||
td->td_retval[0] = bsd_setsockopt_args.s;
|
||||
}
|
||||
|
||||
return (retval_socket);
|
||||
@ -358,7 +358,7 @@ struct linux_bind_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_bind(struct proc *p, struct linux_bind_args *args)
|
||||
linux_bind(struct thread *td, struct linux_bind_args *args)
|
||||
{
|
||||
struct linux_bind_args linux_args;
|
||||
struct bind_args /* {
|
||||
@ -374,7 +374,7 @@ linux_bind(struct proc *p, struct linux_bind_args *args)
|
||||
bsd_args.s = linux_args.s;
|
||||
bsd_args.name = (caddr_t)linux_args.name;
|
||||
bsd_args.namelen = linux_args.namelen;
|
||||
return (bind(p, &bsd_args));
|
||||
return (bind(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_connect_args {
|
||||
@ -382,11 +382,11 @@ struct linux_connect_args {
|
||||
struct sockaddr * name;
|
||||
int namelen;
|
||||
};
|
||||
int linux_connect(struct proc *, struct linux_connect_args *);
|
||||
int linux_connect(struct thread *, struct linux_connect_args *);
|
||||
#endif /* !__alpha__*/
|
||||
|
||||
int
|
||||
linux_connect(struct proc *p, struct linux_connect_args *args)
|
||||
linux_connect(struct thread *td, struct linux_connect_args *args)
|
||||
{
|
||||
struct linux_connect_args linux_args;
|
||||
struct connect_args /* {
|
||||
@ -408,7 +408,7 @@ linux_connect(struct proc *p, struct linux_connect_args *args)
|
||||
bsd_args.s = linux_args.s;
|
||||
bsd_args.name = (caddr_t)linux_args.name;
|
||||
bsd_args.namelen = linux_args.namelen;
|
||||
error = connect(p, &bsd_args);
|
||||
error = connect(td, &bsd_args);
|
||||
if (error != EISCONN)
|
||||
return (error);
|
||||
|
||||
@ -417,7 +417,7 @@ linux_connect(struct proc *p, struct linux_connect_args *args)
|
||||
* when on a non-blocking socket. Instead it returns the
|
||||
* error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD.
|
||||
*/
|
||||
error = holdsock(p->p_fd, linux_args.s, &fp);
|
||||
error = holdsock(td->td_proc->p_fd, linux_args.s, &fp);
|
||||
if (error)
|
||||
return (error);
|
||||
error = EISCONN;
|
||||
@ -427,7 +427,7 @@ linux_connect(struct proc *p, struct linux_connect_args *args)
|
||||
error = so->so_error;
|
||||
so->so_emuldata = (void *)1;
|
||||
}
|
||||
fdrop(fp, p);
|
||||
fdrop(fp, td);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ struct linux_listen_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_listen(struct proc *p, struct linux_listen_args *args)
|
||||
linux_listen(struct thread *td, struct linux_listen_args *args)
|
||||
{
|
||||
struct linux_listen_args linux_args;
|
||||
struct listen_args /* {
|
||||
@ -453,7 +453,7 @@ linux_listen(struct proc *p, struct linux_listen_args *args)
|
||||
|
||||
bsd_args.s = linux_args.s;
|
||||
bsd_args.backlog = linux_args.backlog;
|
||||
return (listen(p, &bsd_args));
|
||||
return (listen(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_accept_args {
|
||||
@ -463,7 +463,7 @@ struct linux_accept_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_accept(struct proc *p, struct linux_accept_args *args)
|
||||
linux_accept(struct thread *td, struct linux_accept_args *args)
|
||||
{
|
||||
struct linux_accept_args linux_args;
|
||||
struct accept_args /* {
|
||||
@ -484,7 +484,7 @@ linux_accept(struct proc *p, struct linux_accept_args *args)
|
||||
bsd_args.s = linux_args.s;
|
||||
bsd_args.name = (caddr_t)linux_args.addr;
|
||||
bsd_args.anamelen = linux_args.namelen;
|
||||
error = oaccept(p, &bsd_args);
|
||||
error = oaccept(td, &bsd_args);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -493,11 +493,11 @@ linux_accept(struct proc *p, struct linux_accept_args *args)
|
||||
* accepted one, so we must clear the flags in the new descriptor.
|
||||
* Ignore any errors, because we already have an open fd.
|
||||
*/
|
||||
f_args.fd = p->p_retval[0];
|
||||
f_args.fd = td->td_retval[0];
|
||||
f_args.cmd = F_SETFL;
|
||||
f_args.arg = 0;
|
||||
(void)fcntl(p, &f_args);
|
||||
p->p_retval[0] = f_args.fd;
|
||||
(void)fcntl(td, &f_args);
|
||||
td->td_retval[0] = f_args.fd;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -508,7 +508,7 @@ struct linux_getsockname_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_getsockname(struct proc *p, struct linux_getsockname_args *args)
|
||||
linux_getsockname(struct thread *td, struct linux_getsockname_args *args)
|
||||
{
|
||||
struct linux_getsockname_args linux_args;
|
||||
struct getsockname_args /* {
|
||||
@ -524,7 +524,7 @@ linux_getsockname(struct proc *p, struct linux_getsockname_args *args)
|
||||
bsd_args.fdes = linux_args.s;
|
||||
bsd_args.asa = (caddr_t) linux_args.addr;
|
||||
bsd_args.alen = linux_args.namelen;
|
||||
return (ogetsockname(p, &bsd_args));
|
||||
return (ogetsockname(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_getpeername_args {
|
||||
@ -534,7 +534,7 @@ struct linux_getpeername_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_getpeername(struct proc *p, struct linux_getpeername_args *args)
|
||||
linux_getpeername(struct thread *td, struct linux_getpeername_args *args)
|
||||
{
|
||||
struct linux_getpeername_args linux_args;
|
||||
struct ogetpeername_args /* {
|
||||
@ -550,7 +550,7 @@ linux_getpeername(struct proc *p, struct linux_getpeername_args *args)
|
||||
bsd_args.fdes = linux_args.s;
|
||||
bsd_args.asa = (caddr_t) linux_args.addr;
|
||||
bsd_args.alen = linux_args.namelen;
|
||||
return (ogetpeername(p, &bsd_args));
|
||||
return (ogetpeername(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_socketpair_args {
|
||||
@ -561,7 +561,7 @@ struct linux_socketpair_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_socketpair(struct proc *p, struct linux_socketpair_args *args)
|
||||
linux_socketpair(struct thread *td, struct linux_socketpair_args *args)
|
||||
{
|
||||
struct linux_socketpair_args linux_args;
|
||||
struct socketpair_args /* {
|
||||
@ -582,7 +582,7 @@ linux_socketpair(struct proc *p, struct linux_socketpair_args *args)
|
||||
bsd_args.type = linux_args.type;
|
||||
bsd_args.protocol = linux_args.protocol;
|
||||
bsd_args.rsv = linux_args.rsv;
|
||||
return (socketpair(p, &bsd_args));
|
||||
return (socketpair(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_send_args {
|
||||
@ -593,7 +593,7 @@ struct linux_send_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_send(struct proc *p, struct linux_send_args *args)
|
||||
linux_send(struct thread *td, struct linux_send_args *args)
|
||||
{
|
||||
struct linux_send_args linux_args;
|
||||
struct osend_args /* {
|
||||
@ -611,7 +611,7 @@ linux_send(struct proc *p, struct linux_send_args *args)
|
||||
bsd_args.buf = linux_args.msg;
|
||||
bsd_args.len = linux_args.len;
|
||||
bsd_args.flags = linux_args.flags;
|
||||
return (osend(p, &bsd_args));
|
||||
return (osend(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_recv_args {
|
||||
@ -622,7 +622,7 @@ struct linux_recv_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_recv(struct proc *p, struct linux_recv_args *args)
|
||||
linux_recv(struct thread *td, struct linux_recv_args *args)
|
||||
{
|
||||
struct linux_recv_args linux_args;
|
||||
struct orecv_args /* {
|
||||
@ -640,7 +640,7 @@ linux_recv(struct proc *p, struct linux_recv_args *args)
|
||||
bsd_args.buf = linux_args.msg;
|
||||
bsd_args.len = linux_args.len;
|
||||
bsd_args.flags = linux_args.flags;
|
||||
return (orecv(p, &bsd_args));
|
||||
return (orecv(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_sendto_args {
|
||||
@ -653,7 +653,7 @@ struct linux_sendto_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_sendto(struct proc *p, struct linux_sendto_args *args)
|
||||
linux_sendto(struct thread *td, struct linux_sendto_args *args)
|
||||
{
|
||||
struct linux_sendto_args linux_args;
|
||||
struct sendto_args /* {
|
||||
@ -676,11 +676,11 @@ linux_sendto(struct proc *p, struct linux_sendto_args *args)
|
||||
bsd_args.to = linux_args.to;
|
||||
bsd_args.tolen = linux_args.tolen;
|
||||
|
||||
if (linux_check_hdrincl(p, linux_args.s) == 0)
|
||||
if (linux_check_hdrincl(td, linux_args.s) == 0)
|
||||
/* IP_HDRINCL set, tweak the packet before sending */
|
||||
return (linux_sendto_hdrincl(p, &bsd_args));
|
||||
return (linux_sendto_hdrincl(td, &bsd_args));
|
||||
|
||||
return (sendto(p, &bsd_args));
|
||||
return (sendto(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_recvfrom_args {
|
||||
@ -693,7 +693,7 @@ struct linux_recvfrom_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_recvfrom(struct proc *p, struct linux_recvfrom_args *args)
|
||||
linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args)
|
||||
{
|
||||
struct linux_recvfrom_args linux_args;
|
||||
struct recvfrom_args /* {
|
||||
@ -715,7 +715,7 @@ linux_recvfrom(struct proc *p, struct linux_recvfrom_args *args)
|
||||
bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags);
|
||||
bsd_args.from = linux_args.from;
|
||||
bsd_args.fromlenaddr = linux_args.fromlen;
|
||||
return (orecvfrom(p, &bsd_args));
|
||||
return (orecvfrom(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_recvmsg_args {
|
||||
@ -725,7 +725,7 @@ struct linux_recvmsg_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_recvmsg(struct proc *p, struct linux_recvmsg_args *args)
|
||||
linux_recvmsg(struct thread *td, struct linux_recvmsg_args *args)
|
||||
{
|
||||
struct linux_recvmsg_args linux_args;
|
||||
struct recvmsg_args /* {
|
||||
@ -741,7 +741,7 @@ linux_recvmsg(struct proc *p, struct linux_recvmsg_args *args)
|
||||
bsd_args.s = linux_args.s;
|
||||
bsd_args.msg = linux_args.msg;
|
||||
bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags);
|
||||
return (recvmsg(p, &bsd_args));
|
||||
return (recvmsg(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_shutdown_args {
|
||||
@ -750,7 +750,7 @@ struct linux_shutdown_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_shutdown(struct proc *p, struct linux_shutdown_args *args)
|
||||
linux_shutdown(struct thread *td, struct linux_shutdown_args *args)
|
||||
{
|
||||
struct linux_shutdown_args linux_args;
|
||||
struct shutdown_args /* {
|
||||
@ -764,7 +764,7 @@ linux_shutdown(struct proc *p, struct linux_shutdown_args *args)
|
||||
|
||||
bsd_args.s = linux_args.s;
|
||||
bsd_args.how = linux_args.how;
|
||||
return (shutdown(p, &bsd_args));
|
||||
return (shutdown(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_setsockopt_args {
|
||||
@ -776,7 +776,7 @@ struct linux_setsockopt_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_setsockopt(struct proc *p, struct linux_setsockopt_args *args)
|
||||
linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args)
|
||||
{
|
||||
struct linux_setsockopt_args linux_args;
|
||||
struct setsockopt_args /* {
|
||||
@ -814,7 +814,7 @@ linux_setsockopt(struct proc *p, struct linux_setsockopt_args *args)
|
||||
bsd_args.name = name;
|
||||
bsd_args.val = linux_args.optval;
|
||||
bsd_args.valsize = linux_args.optlen;
|
||||
return (setsockopt(p, &bsd_args));
|
||||
return (setsockopt(td, &bsd_args));
|
||||
}
|
||||
|
||||
struct linux_getsockopt_args {
|
||||
@ -826,7 +826,7 @@ struct linux_getsockopt_args {
|
||||
};
|
||||
|
||||
static int
|
||||
linux_getsockopt(struct proc *p, struct linux_getsockopt_args *args)
|
||||
linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
|
||||
{
|
||||
struct linux_getsockopt_args linux_args;
|
||||
struct getsockopt_args /* {
|
||||
@ -864,45 +864,45 @@ linux_getsockopt(struct proc *p, struct linux_getsockopt_args *args)
|
||||
bsd_args.name = name;
|
||||
bsd_args.val = linux_args.optval;
|
||||
bsd_args.avalsize = linux_args.optlen;
|
||||
return (getsockopt(p, &bsd_args));
|
||||
return (getsockopt(td, &bsd_args));
|
||||
}
|
||||
|
||||
int
|
||||
linux_socketcall(struct proc *p, struct linux_socketcall_args *args)
|
||||
linux_socketcall(struct thread *td, struct linux_socketcall_args *args)
|
||||
{
|
||||
void *arg = (void *)args->args;
|
||||
|
||||
switch (args->what) {
|
||||
case LINUX_SOCKET:
|
||||
return (linux_socket(p, arg));
|
||||
return (linux_socket(td, arg));
|
||||
case LINUX_BIND:
|
||||
return (linux_bind(p, arg));
|
||||
return (linux_bind(td, arg));
|
||||
case LINUX_CONNECT:
|
||||
return (linux_connect(p, arg));
|
||||
return (linux_connect(td, arg));
|
||||
case LINUX_LISTEN:
|
||||
return (linux_listen(p, arg));
|
||||
return (linux_listen(td, arg));
|
||||
case LINUX_ACCEPT:
|
||||
return (linux_accept(p, arg));
|
||||
return (linux_accept(td, arg));
|
||||
case LINUX_GETSOCKNAME:
|
||||
return (linux_getsockname(p, arg));
|
||||
return (linux_getsockname(td, arg));
|
||||
case LINUX_GETPEERNAME:
|
||||
return (linux_getpeername(p, arg));
|
||||
return (linux_getpeername(td, arg));
|
||||
case LINUX_SOCKETPAIR:
|
||||
return (linux_socketpair(p, arg));
|
||||
return (linux_socketpair(td, arg));
|
||||
case LINUX_SEND:
|
||||
return (linux_send(p, arg));
|
||||
return (linux_send(td, arg));
|
||||
case LINUX_RECV:
|
||||
return (linux_recv(p, arg));
|
||||
return (linux_recv(td, arg));
|
||||
case LINUX_SENDTO:
|
||||
return (linux_sendto(p, arg));
|
||||
return (linux_sendto(td, arg));
|
||||
case LINUX_RECVFROM:
|
||||
return (linux_recvfrom(p, arg));
|
||||
return (linux_recvfrom(td, arg));
|
||||
case LINUX_SHUTDOWN:
|
||||
return (linux_shutdown(p, arg));
|
||||
return (linux_shutdown(td, arg));
|
||||
case LINUX_SETSOCKOPT:
|
||||
return (linux_setsockopt(p, arg));
|
||||
return (linux_setsockopt(td, arg));
|
||||
case LINUX_GETSOCKOPT:
|
||||
return (linux_getsockopt(p, arg));
|
||||
return (linux_getsockopt(td, arg));
|
||||
case LINUX_SENDMSG:
|
||||
do {
|
||||
int error;
|
||||
@ -940,10 +940,10 @@ linux_socketcall(struct proc *p, struct linux_socketcall_args *args)
|
||||
return (error);
|
||||
}
|
||||
done:
|
||||
return (sendmsg(p, arg));
|
||||
return (sendmsg(td, arg));
|
||||
} while (0);
|
||||
case LINUX_RECVMSG:
|
||||
return (linux_recvmsg(p, arg));
|
||||
return (linux_recvmsg(td, arg));
|
||||
}
|
||||
|
||||
uprintf("LINUX: 'socket' typ=%d not implemented\n", args->what);
|
||||
|
@ -87,7 +87,7 @@ newstat_copyout(struct stat *buf, void *ubuf)
|
||||
}
|
||||
|
||||
int
|
||||
linux_newstat(struct proc *p, struct linux_newstat_args *args)
|
||||
linux_newstat(struct thread *td, struct linux_newstat_args *args)
|
||||
{
|
||||
struct stat buf;
|
||||
struct nameidata nd;
|
||||
@ -95,7 +95,7 @@ linux_newstat(struct proc *p, struct linux_newstat_args *args)
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(newstat))
|
||||
@ -103,13 +103,13 @@ linux_newstat(struct proc *p, struct linux_newstat_args *args)
|
||||
#endif
|
||||
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
|
||||
args->path, p);
|
||||
args->path, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
return (error);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
|
||||
error = vn_stat(nd.ni_vp, &buf, p);
|
||||
error = vn_stat(nd.ni_vp, &buf, td);
|
||||
vput(nd.ni_vp);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -118,7 +118,7 @@ linux_newstat(struct proc *p, struct linux_newstat_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_newlstat(struct proc *p, struct linux_newlstat_args *args)
|
||||
linux_newlstat(struct thread *td, struct linux_newlstat_args *args)
|
||||
{
|
||||
int error;
|
||||
struct stat sb;
|
||||
@ -126,7 +126,7 @@ linux_newlstat(struct proc *p, struct linux_newlstat_args *args)
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(newlstat))
|
||||
@ -134,13 +134,13 @@ linux_newlstat(struct proc *p, struct linux_newlstat_args *args)
|
||||
#endif
|
||||
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
|
||||
args->path, p);
|
||||
args->path, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
return (error);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
|
||||
error = vn_stat(nd.ni_vp, &sb, p);
|
||||
error = vn_stat(nd.ni_vp, &sb, td);
|
||||
vput(nd.ni_vp);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -149,7 +149,7 @@ linux_newlstat(struct proc *p, struct linux_newlstat_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_newfstat(struct proc *p, struct linux_newfstat_args *args)
|
||||
linux_newfstat(struct thread *td, struct linux_newfstat_args *args)
|
||||
{
|
||||
struct filedesc *fdp;
|
||||
struct file *fp;
|
||||
@ -161,12 +161,12 @@ linux_newfstat(struct proc *p, struct linux_newfstat_args *args)
|
||||
printf(ARGS(newfstat, "%d, *"), args->fd);
|
||||
#endif
|
||||
|
||||
fdp = p->p_fd;
|
||||
fdp = td->td_proc->p_fd;
|
||||
if ((unsigned)args->fd >= fdp->fd_nfiles ||
|
||||
(fp = fdp->fd_ofiles[args->fd]) == NULL)
|
||||
return (EBADF);
|
||||
|
||||
error = fo_stat(fp, &buf, p);
|
||||
error = fo_stat(fp, &buf, td);
|
||||
if (!error)
|
||||
error = newstat_copyout(&buf, args->buf);
|
||||
|
||||
@ -235,7 +235,7 @@ bsd_to_linux_ftype(int tag)
|
||||
}
|
||||
|
||||
int
|
||||
linux_statfs(struct proc *p, struct linux_statfs_args *args)
|
||||
linux_statfs(struct thread *td, struct linux_statfs_args *args)
|
||||
{
|
||||
struct mount *mp;
|
||||
struct nameidata *ndp;
|
||||
@ -246,14 +246,14 @@ linux_statfs(struct proc *p, struct linux_statfs_args *args)
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(statfs))
|
||||
printf(ARGS(statfs, "%s, *"), args->path);
|
||||
#endif
|
||||
ndp = &nd;
|
||||
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args->path, curproc);
|
||||
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args->path, curthread);
|
||||
error = namei(ndp);
|
||||
if (error)
|
||||
return error;
|
||||
@ -261,7 +261,7 @@ linux_statfs(struct proc *p, struct linux_statfs_args *args)
|
||||
mp = ndp->ni_vp->v_mount;
|
||||
bsd_statfs = &mp->mnt_stat;
|
||||
vrele(ndp->ni_vp);
|
||||
error = VFS_STATFS(mp, bsd_statfs, p);
|
||||
error = VFS_STATFS(mp, bsd_statfs, td);
|
||||
if (error)
|
||||
return error;
|
||||
bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
@ -280,7 +280,7 @@ linux_statfs(struct proc *p, struct linux_statfs_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args)
|
||||
linux_fstatfs(struct thread *td, struct linux_fstatfs_args *args)
|
||||
{
|
||||
struct file *fp;
|
||||
struct mount *mp;
|
||||
@ -292,12 +292,12 @@ linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args)
|
||||
if (ldebug(fstatfs))
|
||||
printf(ARGS(fstatfs, "%d, *"), args->fd);
|
||||
#endif
|
||||
error = getvnode(p->p_fd, args->fd, &fp);
|
||||
error = getvnode(td->td_proc->p_fd, args->fd, &fp);
|
||||
if (error)
|
||||
return error;
|
||||
mp = ((struct vnode *)fp->f_data)->v_mount;
|
||||
bsd_statfs = &mp->mnt_stat;
|
||||
error = VFS_STATFS(mp, bsd_statfs, p);
|
||||
error = VFS_STATFS(mp, bsd_statfs, td);
|
||||
if (error)
|
||||
return error;
|
||||
bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
@ -324,7 +324,7 @@ struct l_ustat
|
||||
};
|
||||
|
||||
int
|
||||
linux_ustat(struct proc *p, struct linux_ustat_args *args)
|
||||
linux_ustat(struct thread *td, struct linux_ustat_args *args)
|
||||
{
|
||||
struct l_ustat lu;
|
||||
dev_t dev;
|
||||
@ -355,7 +355,7 @@ linux_ustat(struct proc *p, struct linux_ustat_args *args)
|
||||
if (vp->v_mount == NULL)
|
||||
return (EINVAL);
|
||||
stat = &(vp->v_mount->mnt_stat);
|
||||
error = VFS_STATFS(vp->v_mount, stat, p);
|
||||
error = VFS_STATFS(vp->v_mount, stat, td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -400,7 +400,7 @@ stat64_copyout(struct stat *buf, void *ubuf)
|
||||
}
|
||||
|
||||
int
|
||||
linux_stat64(struct proc *p, struct linux_stat64_args *args)
|
||||
linux_stat64(struct thread *td, struct linux_stat64_args *args)
|
||||
{
|
||||
struct stat buf;
|
||||
struct nameidata nd;
|
||||
@ -408,7 +408,7 @@ linux_stat64(struct proc *p, struct linux_stat64_args *args)
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->filename);
|
||||
CHECKALTEXIST(td, &sg, args->filename);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(stat64))
|
||||
@ -416,13 +416,13 @@ linux_stat64(struct proc *p, struct linux_stat64_args *args)
|
||||
#endif
|
||||
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
|
||||
args->filename, p);
|
||||
args->filename, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
return (error);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
|
||||
error = vn_stat(nd.ni_vp, &buf, p);
|
||||
error = vn_stat(nd.ni_vp, &buf, td);
|
||||
vput(nd.ni_vp);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -431,7 +431,7 @@ linux_stat64(struct proc *p, struct linux_stat64_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_lstat64(struct proc *p, struct linux_lstat64_args *args)
|
||||
linux_lstat64(struct thread *td, struct linux_lstat64_args *args)
|
||||
{
|
||||
int error;
|
||||
struct stat sb;
|
||||
@ -439,7 +439,7 @@ linux_lstat64(struct proc *p, struct linux_lstat64_args *args)
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->filename);
|
||||
CHECKALTEXIST(td, &sg, args->filename);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(lstat64))
|
||||
@ -447,13 +447,13 @@ linux_lstat64(struct proc *p, struct linux_lstat64_args *args)
|
||||
#endif
|
||||
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
|
||||
args->filename, p);
|
||||
args->filename, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
return (error);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
|
||||
error = vn_stat(nd.ni_vp, &sb, p);
|
||||
error = vn_stat(nd.ni_vp, &sb, td);
|
||||
vput(nd.ni_vp);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -462,7 +462,7 @@ linux_lstat64(struct proc *p, struct linux_lstat64_args *args)
|
||||
}
|
||||
|
||||
int
|
||||
linux_fstat64(struct proc *p, struct linux_fstat64_args *args)
|
||||
linux_fstat64(struct thread *td, struct linux_fstat64_args *args)
|
||||
{
|
||||
struct filedesc *fdp;
|
||||
struct file *fp;
|
||||
@ -474,12 +474,12 @@ linux_fstat64(struct proc *p, struct linux_fstat64_args *args)
|
||||
printf(ARGS(fstat64, "%d, *"), args->fd);
|
||||
#endif
|
||||
|
||||
fdp = p->p_fd;
|
||||
fdp = td->td_proc->p_fd;
|
||||
if ((unsigned)args->fd >= fdp->fd_nfiles ||
|
||||
(fp = fdp->fd_ofiles[args->fd]) == NULL)
|
||||
return (EBADF);
|
||||
|
||||
error = fo_stat(fp, &buf, p);
|
||||
error = fo_stat(fp, &buf, td);
|
||||
if (!error)
|
||||
error = stat64_copyout(&buf, args->statbuf);
|
||||
|
||||
|
@ -75,7 +75,7 @@ handle_string(struct l___sysctl_args *la, char *value)
|
||||
}
|
||||
|
||||
int
|
||||
linux_sysctl(struct proc *p, struct linux_sysctl_args *args)
|
||||
linux_sysctl(struct thread *td, struct linux_sysctl_args *args)
|
||||
{
|
||||
struct l___sysctl_args la;
|
||||
l_int *mib;
|
||||
|
@ -43,13 +43,13 @@ DUMMY(getresuid16);
|
||||
DUMMY(getresgid16);
|
||||
|
||||
int
|
||||
linux_chown16(struct proc *p, struct linux_chown16_args *args)
|
||||
linux_chown16(struct thread *td, struct linux_chown16_args *args)
|
||||
{
|
||||
struct chown_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(chown16))
|
||||
@ -60,17 +60,17 @@ linux_chown16(struct proc *p, struct linux_chown16_args *args)
|
||||
bsd.path = args->path;
|
||||
bsd.uid = args->uid;
|
||||
bsd.gid = args->gid;
|
||||
return (chown(p, &bsd));
|
||||
return (chown(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_lchown16(struct proc *p, struct linux_lchown16_args *args)
|
||||
linux_lchown16(struct thread *td, struct linux_lchown16_args *args)
|
||||
{
|
||||
struct lchown_args bsd;
|
||||
caddr_t sg;
|
||||
|
||||
sg = stackgap_init();
|
||||
CHECKALTEXIST(p, &sg, args->path);
|
||||
CHECKALTEXIST(td, &sg, args->path);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ldebug(lchown16))
|
||||
@ -81,11 +81,11 @@ linux_lchown16(struct proc *p, struct linux_lchown16_args *args)
|
||||
bsd.path = args->path;
|
||||
bsd.uid = args->uid;
|
||||
bsd.gid = args->gid;
|
||||
return (lchown(p, &bsd));
|
||||
return (lchown(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_setgroups16(struct proc *p, struct linux_setgroups16_args *args)
|
||||
linux_setgroups16(struct thread *td, struct linux_setgroups16_args *args)
|
||||
{
|
||||
struct ucred *newcred, *oldcred;
|
||||
l_gid16_t linux_gidset[NGROUPS];
|
||||
@ -98,7 +98,7 @@ linux_setgroups16(struct proc *p, struct linux_setgroups16_args *args)
|
||||
#endif
|
||||
|
||||
ngrp = args->gidsetsize;
|
||||
oldcred = p->p_ucred;
|
||||
oldcred = td->td_proc->p_ucred;
|
||||
|
||||
/*
|
||||
* cr_groups[0] holds egid. Setting the whole set from
|
||||
@ -131,14 +131,14 @@ linux_setgroups16(struct proc *p, struct linux_setgroups16_args *args)
|
||||
else
|
||||
newcred->cr_ngroups = 1;
|
||||
|
||||
setsugid(p);
|
||||
p->p_ucred = newcred;
|
||||
setsugid(td->td_proc);
|
||||
td->td_proc->p_ucred = newcred;
|
||||
crfree(oldcred);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args)
|
||||
linux_getgroups16(struct thread *td, struct linux_getgroups16_args *args)
|
||||
{
|
||||
struct ucred *cred;
|
||||
l_gid16_t linux_gidset[NGROUPS];
|
||||
@ -150,7 +150,7 @@ linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args)
|
||||
printf(ARGS(getgroups16, "%d, *"), args->gidsetsize);
|
||||
#endif
|
||||
|
||||
cred = p->p_ucred;
|
||||
cred = td->td_proc->p_ucred;
|
||||
bsd_gidset = cred->cr_groups;
|
||||
bsd_gidsetsz = cred->cr_ngroups - 1;
|
||||
|
||||
@ -161,7 +161,7 @@ linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args)
|
||||
*/
|
||||
|
||||
if ((ngrp = args->gidsetsize) == 0) {
|
||||
p->p_retval[0] = bsd_gidsetsz;
|
||||
td->td_retval[0] = bsd_gidsetsz;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -179,12 +179,12 @@ linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args)
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
p->p_retval[0] = ngrp;
|
||||
td->td_retval[0] = ngrp;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The FreeBSD native getgid(2) and getuid(2) also modify p->p_retval[1]
|
||||
* The FreeBSD native getgid(2) and getuid(2) also modify td->td_retval[1]
|
||||
* when COMPAT_43 or COMPAT_SUNOS is defined. This globbers registers that
|
||||
* are assumed to be preserved. The following lightweight syscalls fixes
|
||||
* this. See also linux_getpid(2), linux_getgid(2) and linux_getuid(2) in
|
||||
@ -195,91 +195,93 @@ linux_getgroups16(struct proc *p, struct linux_getgroups16_args *args)
|
||||
*/
|
||||
|
||||
int
|
||||
linux_getgid16(struct proc *p, struct linux_getgid16_args *args)
|
||||
linux_getgid16(struct thread *td, struct linux_getgid16_args *args)
|
||||
{
|
||||
p->p_retval[0] = p->p_ucred->cr_rgid;
|
||||
|
||||
td->td_retval[0] = td->td_proc->p_ucred->cr_rgid;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_getuid16(struct proc *p, struct linux_getuid16_args *args)
|
||||
linux_getuid16(struct thread *td, struct linux_getuid16_args *args)
|
||||
{
|
||||
p->p_retval[0] = p->p_ucred->cr_ruid;
|
||||
|
||||
td->td_retval[0] = td->td_proc->p_ucred->cr_ruid;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_getegid16(struct proc *p, struct linux_getegid16_args *args)
|
||||
linux_getegid16(struct thread *td, struct linux_getegid16_args *args)
|
||||
{
|
||||
struct getegid_args bsd;
|
||||
|
||||
return (getegid(p, &bsd));
|
||||
return (getegid(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_geteuid16(struct proc *p, struct linux_geteuid16_args *args)
|
||||
linux_geteuid16(struct thread *td, struct linux_geteuid16_args *args)
|
||||
{
|
||||
struct geteuid_args bsd;
|
||||
|
||||
return (geteuid(p, &bsd));
|
||||
return (geteuid(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_setgid16(struct proc *p, struct linux_setgid16_args *args)
|
||||
linux_setgid16(struct thread *td, struct linux_setgid16_args *args)
|
||||
{
|
||||
struct setgid_args bsd;
|
||||
|
||||
bsd.gid = args->gid;
|
||||
return (setgid(p, &bsd));
|
||||
return (setgid(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_setuid16(struct proc *p, struct linux_setuid16_args *args)
|
||||
linux_setuid16(struct thread *td, struct linux_setuid16_args *args)
|
||||
{
|
||||
struct setuid_args bsd;
|
||||
|
||||
bsd.uid = args->uid;
|
||||
return (setuid(p, &bsd));
|
||||
return (setuid(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_setregid16(struct proc *p, struct linux_setregid16_args *args)
|
||||
linux_setregid16(struct thread *td, struct linux_setregid16_args *args)
|
||||
{
|
||||
struct setregid_args bsd;
|
||||
|
||||
bsd.rgid = args->rgid;
|
||||
bsd.egid = args->egid;
|
||||
return (setregid(p, &bsd));
|
||||
return (setregid(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_setreuid16(struct proc *p, struct linux_setreuid16_args *args)
|
||||
linux_setreuid16(struct thread *td, struct linux_setreuid16_args *args)
|
||||
{
|
||||
struct setreuid_args bsd;
|
||||
|
||||
bsd.ruid = args->ruid;
|
||||
bsd.euid = args->euid;
|
||||
return (setreuid(p, &bsd));
|
||||
return (setreuid(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_setresgid16(struct proc *p, struct linux_setresgid16_args *args)
|
||||
linux_setresgid16(struct thread *td, struct linux_setresgid16_args *args)
|
||||
{
|
||||
struct setresgid_args bsd;
|
||||
|
||||
bsd.rgid = args->rgid;
|
||||
bsd.egid = args->egid;
|
||||
bsd.sgid = args->sgid;
|
||||
return (setresgid(p, &bsd));
|
||||
return (setresgid(td, &bsd));
|
||||
}
|
||||
|
||||
int
|
||||
linux_setresuid16(struct proc *p, struct linux_setresuid16_args *args)
|
||||
linux_setresuid16(struct thread *td, struct linux_setresuid16_args *args)
|
||||
{
|
||||
struct setresuid_args bsd;
|
||||
|
||||
bsd.ruid = args->ruid;
|
||||
bsd.euid = args->euid;
|
||||
bsd.suid = args->suid;
|
||||
return (setresuid(p, &bsd));
|
||||
return (setresuid(td, &bsd));
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user