root/arch/mips/kernel/process.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ret_from_sys_call
  2. start_thread
  3. exit_thread
  4. flush_thread
  5. release_thread
  6. copy_thread
  7. dump_thread
  8. sys_execve

   1 /*
   2  *  linux/arch/mips/kernel/process.c
   3  *
   4  *  Copyright (C) 1995  Waldorf Electronics,
   5  *  written by Ralf Baechle
   6  */
   7 
   8 /*
   9  * This file handles the architecture-dependent parts of process handling..
  10  */
  11 
  12 #include <linux/errno.h>
  13 #include <linux/sched.h>
  14 #include <linux/kernel.h>
  15 #include <linux/mm.h>
  16 #include <linux/stddef.h>
  17 #include <linux/unistd.h>
  18 #include <linux/ptrace.h>
  19 #include <linux/malloc.h>
  20 #include <linux/ldt.h>
  21 #include <linux/user.h>
  22 #include <linux/a.out.h>
  23 
  24 #include <asm/segment.h>
  25 #include <asm/system.h>
  26 #include <asm/mipsregs.h>
  27 #include <asm/mipsconfig.h>
  28 #include <asm/stackframe.h>
  29 
  30 asmlinkage void ret_from_sys_call(void) __asm__("ret_from_sys_call");
     /* [previous][next][first][last][top][bottom][index][help] */
  31 
  32 /*
  33  * The idle loop on a MIPS..
  34  */
  35 asmlinkage int sys_idle(void)
  36 {
  37 #if 0
  38         int i;
  39 #endif
  40 
  41         if (current->pid != 0)
  42                 return -EPERM;
  43 
  44 #if 0
  45         /* Map out the low memory: it's no longer needed */
  46         for (i = 0 ; i < 512 ; i++)
  47                 pgd_clear(swapper_pg_dir + i);
  48 #endif
  49 
  50         /* endless idle loop with no priority at all */
  51         current->counter = -100;
  52         for (;;) {
  53                 /*
  54                  * R4[26]00 have wait, R4[04]00 don't.
  55                  */
  56                 if (wait_available && !need_resched)
  57                         __asm__("wait");
  58                 schedule();
  59         }
  60 }
  61 
  62 /*
  63  * Do necessary setup to start up a newly executed thread.
  64  */
  65 void start_thread(struct pt_regs * regs, unsigned long eip, unsigned long esp)
     /* [previous][next][first][last][top][bottom][index][help] */
  66 {
  67         regs->cp0_epc = eip;
  68         regs->reg29 = esp;
  69 }
  70 
  71 /*
  72  * Free current thread data structures etc..
  73  */
  74 void exit_thread(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  75 {
  76         /*
  77          * Nothing to do
  78          */
  79 }
  80 
  81 void flush_thread(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  82 {
  83         /*
  84          * Nothing to do
  85          */
  86 }
  87 
  88 void release_thread(struct task_struct *dead_task)
     /* [previous][next][first][last][top][bottom][index][help] */
  89 {
  90         /*
  91          * Nothing to do
  92          */
  93 }
  94 
  95 #define IS_CLONE (regs->orig_reg2 == __NR_clone)
  96 
  97 void copy_thread(int nr, unsigned long clone_flags, struct task_struct * p, struct pt_regs * regs)
     /* [previous][next][first][last][top][bottom][index][help] */
  98 {
  99         struct pt_regs * childregs;
 100 
 101         /*
 102          * set up new TSS
 103          */
 104         p->tss.fs = KERNEL_DS;
 105         p->tss.ksp = (p->kernel_stack_page + PAGE_SIZE - 4) | KSEG0;
 106         childregs = ((struct pt_regs *) (p->kernel_stack_page + PAGE_SIZE)) - 1;
 107         p->tss.reg29 = ((unsigned long) childregs) | KSEG0; /* new sp */
 108         p->tss.reg31 = (unsigned long) ret_from_sys_call;
 109         *childregs = *regs;
 110         childregs->reg2 = 0;
 111 
 112         /*
 113          * New tasks loose permission to use the fpu. This accelerates context
 114          * switching for non fp programs, which true for the most programs.
 115          */
 116         p->tss.cp0_status = regs->cp0_status &
 117                             ~(ST0_CU1|ST0_CU0|ST0_KSU|ST0_ERL|ST0_EXL);
 118         childregs->cp0_status &= ~(ST0_CU1|ST0_CU0);
 119 }
 120 
 121 /*
 122  * fill in the user structure for a core dump..
 123  */
 124 void dump_thread(struct pt_regs * regs, struct user * dump)
     /* [previous][next][first][last][top][bottom][index][help] */
 125 {
 126         /*
 127          * Not ready yet
 128          */
 129 #if 0
 130         int i;
 131 
 132 /* changed the size calculations - should hopefully work better. lbt */
 133         dump->magic = CMAGIC;
 134         dump->start_code = 0;
 135         dump->start_stack = regs->esp & ~(PAGE_SIZE - 1);
 136         dump->u_tsize = ((unsigned long) current->mm->end_code) >> 12;
 137         dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> 12;
 138         dump->u_dsize -= dump->u_tsize;
 139         dump->u_ssize = 0;
 140         for (i = 0; i < 8; i++)
 141                 dump->u_debugreg[i] = current->debugreg[i];  
 142 
 143         if (dump->start_stack < TASK_SIZE)
 144                 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> 12;
 145 
 146         dump->regs = *regs;
 147 
 148 /* Flag indicating the math stuff is valid. We don't support this for the
 149    soft-float routines yet */
 150         if (hard_math) {
 151                 if ((dump->u_fpvalid = current->used_math) != 0) {
 152                         if (last_task_used_math == current)
 153                                 __asm__("clts ; fnsave %0": :"m" (dump->i387));
 154                         else
 155                                 memcpy(&dump->i387,&current->tss.i387.hard,sizeof(dump->i387));
 156                 }
 157         } else {
 158                 /* we should dump the emulator state here, but we need to
 159                    convert it into standard 387 format first.. */
 160                 dump->u_fpvalid = 0;
 161         }
 162 #endif
 163 }
 164 
 165 /*
 166  * sys_execve() executes a new program.
 167  */
 168 asmlinkage int sys_execve(struct pt_regs regs)
     /* [previous][next][first][last][top][bottom][index][help] */
 169 {
 170         int error;
 171         char * filename;
 172 
 173         error = getname((char *) regs.reg4, &filename);
 174         if (error)
 175                 return error;
 176         error = do_execve(filename, (char **) regs.reg5, (char **) regs.reg6, &regs);
 177         putname(filename);
 178         return error;
 179 }

/* [previous][next][first][last][top][bottom][index][help] */