コード例 #1
0
ファイル: interrupt.c プロジェクト: Dennisbonke/DB-OS
static void faulted(int fuckoff, int userspace, addr_t ip, long err_code, struct registers *regs)
{
	printk(0, "Fault: %d %d\n", userspace, current_thread->system);
	if(!current_thread || current_thread->system || !userspace)
	{
		//if(fuckoff == 3)
			//debugger_enter();
		//else
			kernel_fault(fuckoff, ip, err_code, regs);
	} else
	{
		printk(5, "%s occured in task %d (ip=%x, err=%x (%d), usersp=%x): He's dead, Jim.\n", exception_messages[fuckoff], current_thread->tid, ip, err_code, err_code, regs->useresp);
		// We die for different reasons on different interrupts.
		switch(fuckoff)
		{
			case 0:
				tm_signal_send_thread(current_thread, SIGFPE);
				break;
			case 5: case 6: case 13:
				tm_signal_send_thread(current_thread, SIGILL);
				break;
			case 1: case 3: case 4:
				tm_signal_send_thread(current_thread, SIGTRAP);
				break;
			case 8: case 18:
				tm_signal_send_thread(current_thread, SIGABRT);
				break;
			default:
				tm_signal_send_thread(current_thread, SIGABRT);
				break;
		}
		tm_thread_exit(-9);
	}
}
コード例 #2
0
ファイル: thread.c プロジェクト: Dennisbonke/DB-OS
void tm_thread_enter_system(int sys)
{
	// Check for PTRACE event.
	if((current_thread->flags & THREAD_PTRACED) && (current_thread->tracee_flags & TRACEE_STOPON_SYSCALL)) {
		current_thread->tracee_flags &= ~TRACEE_STOPON_SYSCALL;
		current_thread->orig_syscall = sys;
		current_thread->syscall_return = 0;
		tm_signal_send_thread(current_thread, SIGTRAP);
		tm_schedule();
	}

	current_thread->system=(!sys ? -1 : sys);
}
コード例 #3
0
ファイル: thread.c プロジェクト: Dennisbonke/DB-OS
void tm_thread_exit_system(long sys, long ret)
{
	current_thread->system=0;
	// Check for PTRACE event.
	if((current_thread->flags & THREAD_PTRACED) && (current_thread->tracee_flags & TRACEE_STOPON_SYSCALL)) {
		current_thread->tracee_flags &= ~TRACEE_STOPON_SYSCALL;
		current_thread->orig_syscall = sys;
		current_thread->syscall_return = ret;
		tm_signal_send_thread(current_thread, SIGTRAP);
		tm_schedule();
	}

	// If we have a signal, then we've been ignoring it up until now because we were inside a syscall. Set the schedule flag so we can handle that now.
	if(tm_thread_got_signal(current_thread))
		tm_thread_raise_flag(current_thread, THREAD_SCHEDULE);
}
コード例 #4
0
ファイル: exec.c プロジェクト: AshishKumar4/seakernel
static void preexec(void)
{
	struct thread *t = current_thread;
	/* unmap all mappings, specified by POSIX */
	mm_destroy_all_mappings(t->process);
	mm_virtual_map(MEMMAP_SYSGATE_ADDRESS, sysgate_page, PAGE_PRESENT | PAGE_USER, PAGE_SIZE);
	/* we need to re-create the vmem for memory mappings */
	valloc_create(&(t->process->mmf_valloc), MEMMAP_MMAP_BEGIN, MEMMAP_MMAP_END, PAGE_SIZE, 0);
	addr_t ret = mm_mmap(t->usermode_stack_start, CONFIG_STACK_PAGES * PAGE_SIZE,
			PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, 0, 0, 0);
	mm_page_fault_test_mappings(t->usermode_stack_end - PAGE_SIZE, PF_CAUSE_USER | PF_CAUSE_WRITE);
	t->signal = t->signals_pending = 0;
	memset((void *)t->process->signal_act, 0, sizeof(struct sigaction) * NUM_SIGNALS);

	if(t->flags & THREAD_PTRACED) {
		tm_signal_send_thread(t, SIGTRAP);
	}
}