FreeBSD/sys/i386/i386/trap.c
/*
 * syscall - system call request C handler.  A system call is
 * essentially treated as a trap by reusing the frame layout.
 */
system call request C handler.  A system call is
essentially treated as a trap by reusing the frame layout.
system call request C handler . A system call is essentially treated as a trap by reusing the frame layout .
void
syscall(struct trapframe *frame)
{
	struct thread *td;
	struct syscall_args sa;
	register_t orig_tf_eflags;
	int error;
	ksiginfo_t ksi;
#ifdef DIAGNOSTIC
	if (ISPL(frame->tf_cs) != SEL_UPL) {
		panic("syscall");
	}
#endif
	orig_tf_eflags = frame->tf_eflags;
	td = curthread;
	td->td_frame = frame;
	error = syscallenter(td, &sa);
	if ((orig_tf_eflags & PSL_T) && !(orig_tf_eflags & PSL_VM)) {
		frame->tf_eflags &= ~PSL_T;
		ksiginfo_init_trap(&ksi);
		ksi.ksi_signo = SIGTRAP;
		ksi.ksi_code = TRAP_TRACE;
		ksi.ksi_addr = (void *)frame->tf_eip;
		trapsignal(td, &ksi);
	}
	KASSERT(PCB_USER_FPU(td->td_pcb),
	    ("System call %s returning with kernel FPU ctx leaked",
	     syscallname(td->td_proc, sa.code)));
	KASSERT(td->td_pcb->pcb_save == get_pcb_user_save_td(td),
	    ("System call %s returning with mangled pcb_save",
	     syscallname(td->td_proc, sa.code)));
	syscallret(td, error, &sa);
}
void syscall ( struct trapframe * frame ) { struct thread * td ; struct syscall_args sa ; register_t orig_tf_eflags ; int error ; ksiginfo_t ksi ; #ifdef DIAGNOSTIC if ( ISPL ( frame -> tf_cs ) != SEL_UPL ) { panic ( " " ) ; } #endif orig_tf_eflags = frame -> tf_eflags ; td = curthread ; td -> td_frame = frame ; error = syscallenter ( td , & sa ) ; if ( ( orig_tf_eflags & PSL_T ) && ! ( orig_tf_eflags & PSL_VM ) ) { frame -> tf_eflags &= ~ PSL_T ; ksiginfo_init_trap ( & ksi ) ; ksi . ksi_signo = SIGTRAP ; ksi . ksi_code = TRAP_TRACE ; ksi . ksi_addr = ( void * ) frame -> tf_eip ; trapsignal ( td , & ksi ) ; } KASSERT ( PCB_USER_FPU ( td -> td_pcb ) , ( " " , syscallname ( td -> td_proc , sa . code ) ) ) ; KASSERT ( td -> td_pcb -> pcb_save == get_pcb_user_save_td ( td ) , ( " " , syscallname ( td -> td_proc , sa . code ) ) ) ; syscallret ( td , error , & sa ) ; }
syscall - system call request C handler.
syscall - system call request C handler .
/* NOT REACHED */ /*
	 * Traced syscall.
	 */