[ Pobierz całość w formacie PDF ]
.*/#ifdef __SMP__if (current->flags & PF_USEDFPU) {stts();}#elseif (last_task_used_math == current) {last_task_used_math = NULL;stts();}#endifcurrent->used_math = 0;current->flags &= ~PF_USEDFPU;}void release_thread(struct task_struct *dead_task){}void copy_thread(int nr, unsigned long clone_flags, unsigned long esp,struct task_struct * p, struct pt_regs * regs){int i;struct pt_regs * childregs;p->tss.es = KERNEL_DS;p->tss.cs = KERNEL_CS;p->tss.ss = KERNEL_DS;p->tss.ds = KERNEL_DS;p->tss.fs = USER_DS;p->tss.gs = KERNEL_DS;p->tss.ss0 = KERNEL_DS;p->tss.esp0 = p->kernel_stack_page + PAGE_SIZE;p->tss.tr = _TSS(nr);childregs = ((struct pt_regs *) (p->kernel_stack_page + PAGE_SIZE)) - 1;p->tss.esp = (unsigned long) childregs;p->tss.eip = (unsigned long) ret_from_sys_call;*childregs = *regs;childregs->eax = 0;childregs->esp = esp;p->tss.back_link = 0;p->tss.eflags = regs->eflags & 0xffffcfff; /* iopl is always 0 for a new process */p->tss.ldt = _LDT(nr);if (p->ldt) {p->ldt = (struct desc_struct*) vmalloc(LDT_ENTRIES*LDT_ENTRY_SIZE);if (p->ldt != NULL)memcpy(p->ldt, current->ldt, LDT_ENTRIES*LDT_ENTRY_SIZE);}set_tss_desc(gdt+(nr<<1)+FIRST_TSS_ENTRY,&(p->tss));if (p->ldt)set_ldt_desc(gdt+(nr<<1)+FIRST_LDT_ENTRY,p->ldt, 512);elseset_ldt_desc(gdt+(nr<<1)+FIRST_LDT_ENTRY,&default_ldt, 1);p->tss.bitmap = offsetof(struct thread_struct,io_bitmap);for (i = 0; i < IO_BITMAP_SIZE+1 ; i++) /* IO bitmap is actually SIZE+1 */p->tss.io_bitmap[i] = ~0;if (last_task_used_math == current)__asm__("clts ; fnsave %0 ; frstor %0":"=m" (p->tss.i387));}/** fill in the fpu structure for a core dump.*/int dump_fpu (struct pt_regs * regs, struct user_i387_struct* fpu){int fpvalid;/* Flag indicating the math stuff is valid.We don't support this for thesoft-float routines yet */if (hard_math) {if ((fpvalid = current->used_math) != 0) {if (last_task_used_math == current)__asm__("clts ; fnsave %0": :"m" (*fpu));elsememcpy(fpu,¤t->tss.i387.hard,sizeof(*fpu));}} else {/* we should dump the emulator state here, but we need toconvert it into standard 387 format first.*/fpvalid = 0;}return fpvalid;}/** fill in the user structure for a core dump.*/void dump_thread(struct pt_regs * regs, struct user * dump){int i;/* changed the size calculations - should hopefully work better.lbt */dump->magic = CMAGIC;dump->start_code = 0;dump->start_stack = regs->esp & ~(PAGE_SIZE - 1);dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;dump->u_dsize -= dump->u_tsize;dump->u_ssize = 0;for (i = 0; i < 8; i++)dump->u_debugreg[i] = current->debugreg[i];if (dump->start_stack < TASK_SIZE)dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;dump->regs = *regs;dump->u_fpvalid = dump_fpu (regs, &dump->i387);}asmlinkage int sys_fork(struct pt_regs regs){return do_fork(SIGCHLD, regs.esp, ®s);}asmlinkage int sys_clone(struct pt_regs regs){unsigned long clone_flags;unsigned long newsp;clone_flags = regs.ebx;newsp = regs.ecx;if (!newsp)newsp = regs.esp;return do_fork(clone_flags, newsp, ®s);}/** sys_execve() executes a new program.*/asmlinkage int sys_execve(struct pt_regs regs){int error;char * filename;error = getname((char *) regs.ebx, &filename);if (error)return error;error = do_execve(filename, (char **) regs.ecx, (char **) regs.edx, ®s);putname(filename);return error;}
[ Pobierz całość w formacie PDF ]