Changeset View
Changeset View
Standalone View
Standalone View
sys/riscv/riscv/trap.c
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
int | int | ||||
cpu_fetch_syscall_args(struct thread *td) | cpu_fetch_syscall_args(struct thread *td) | ||||
{ | { | ||||
struct proc *p; | struct proc *p; | ||||
register_t *ap; | register_t *ap; | ||||
struct syscall_args *sa; | struct syscall_args *sa; | ||||
int nap; | bool shift_args; | ||||
mhorne: No longer needed. | |||||
nap = NARGREG; | |||||
p = td->td_proc; | p = td->td_proc; | ||||
sa = &td->td_sa; | sa = &td->td_sa; | ||||
ap = &td->td_frame->tf_a[0]; | ap = &td->td_frame->tf_a[0]; | ||||
sa->code = td->td_frame->tf_t[0]; | sa->code = td->td_frame->tf_t[0]; | ||||
if (sa->code == SYS_syscall || sa->code == SYS___syscall) { | if (__predict_false(sa->code == SYS_syscall || sa->code == SYS___syscall)) { | ||||
sa->code = *ap++; | sa->code = *ap++; | ||||
nap--; | shift_args = true; | ||||
} else { | |||||
shift_args = false; | |||||
} | } | ||||
if (sa->code >= p->p_sysent->sv_size) | if (__predict_false(sa->code >= p->p_sysent->sv_size)) | ||||
sa->callp = &p->p_sysent->sv_table[0]; | sa->callp = &p->p_sysent->sv_table[0]; | ||||
else | else | ||||
sa->callp = &p->p_sysent->sv_table[sa->code]; | sa->callp = &p->p_sysent->sv_table[sa->code]; | ||||
sa->narg = sa->callp->sy_narg; | sa->narg = sa->callp->sy_narg; | ||||
memcpy(sa->args, ap, nap * sizeof(register_t)); | KASSERT(sa->callp->sy_narg <= nitems(sa->args), ("Too many syscall arguments!")); | ||||
if (sa->narg > nap) | |||||
panic("TODO: Could we have more then %d args?", NARGREG); | if (__predict_false(shift_args)) | ||||
memcpy(sa->args, ap, (NARGREG - 1) * sizeof(register_t)); | |||||
Done Inline ActionsShould be dst_ap ? mhorne: Should be `dst_ap` ? | |||||
Done Inline ActionsSigh, you're right. It's been manually cherry-picked from another tree. trasz: Sigh, you're right. It's been manually cherry-picked from another tree. | |||||
else | |||||
memcpy(sa->args, ap, NARGREG * sizeof(register_t)); | |||||
td->td_retval[0] = 0; | td->td_retval[0] = 0; | ||||
td->td_retval[1] = 0; | td->td_retval[1] = 0; | ||||
return (0); | return (0); | ||||
} | } | ||||
#include "../../kern/subr_syscall.c" | #include "../../kern/subr_syscall.c" | ||||
▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines |
No longer needed.