unsigned exc_handler(uint32_t exc_num, volatile struct intr_ctx ctx) { static const char * const tname[] = { "UNKNOWN", "fault", "trap", "abort condition", }; if ( exc[exc_num].handler ) { (*exc[exc_num].handler)((struct intr_ctx *)&ctx); return return_from_intr(&ctx); } if ( (ctx.cs & __CPL3) == __CPL3 ) { _sys_exit(~0); } cli(); printk("%s: %s @ 0x%.8lx", tname[exc[exc_num].type], exc[exc_num].name, ctx.eip); if ( exc[exc_num].err_code ) { if ( ctx.err_code & 0x1 ) printk(" EXT"); switch ( ctx.err_code & 0x6 ) { case 0: printk(" GDT"); break; case 2: printk(" IDT"); break; case 4: printk(" LDT"); break; } printk(" selector=0x%.lx", ctx.err_code & 0xfff8); } printk("\n"); ctx_dump((struct intr_ctx *)&ctx); idle_task_func(); }
ntss->sp0 = (vaddr_t)((uint8_t *)new + PAGE_SIZE); ntss->ss0 = __KERNEL_DS; ntss->flags = ptss->flags | (1 << 9); ntss->ss = ntss->ds = ntss->es = __KERNEL_DS; ntss->cs = __KERNEL_CS; regs = parent->t.intr_ctx; stack_top = (uint8_t *)new + PAGE_SIZE; memcpy(stack_top - sizeof(*regs), regs, sizeof(*regs)); regs = (struct intr_ctx *)(stack_top - sizeof(*regs)); regs->eax = 0; ntss->esp = (vaddr_t)regs; ntss->eax = return_from_intr(regs); ntss->eip = (vaddr_t)ret_from_fork_in_child; if ( ip != MAP_INVALID ) { regs->eip = ip; } if ( sp != MAP_INVALID ) { regs->esp3 = sp; } } void task_init_exec(struct task *tsk, vaddr_t ip, vaddr_t sp) { unsigned short tr, scratch_tr; struct ia32_tss *tss; static struct ia32_tss scratch;