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. copy_thread
  6. dump_thread
  7. 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 #define IS_CLONE (regs->orig_reg2 == __NR_clone)
  89 
  90 unsigned long copy_thread(int nr, unsigned long clone_flags, struct task_struct * p, struct pt_regs * regs)
     /* [previous][next][first][last][top][bottom][index][help] */
  91 {
  92         struct pt_regs * childregs;
  93 
  94         /*
  95          * set up new TSS
  96          */
  97         p->tss.fs = KERNEL_DS;
  98         p->tss.ksp = (p->kernel_stack_page + PAGE_SIZE - 4) | KSEG0;
  99         childregs = ((struct pt_regs *) (p->kernel_stack_page + PAGE_SIZE)) - 1;
 100         p->tss.reg29 = ((unsigned long) childregs) | KSEG0; /* new sp */
 101         p->tss.reg31 = (unsigned long) ret_from_sys_call;
 102         *childregs = *regs;
 103         childregs->reg2 = 0;
 104 
 105         /*
 106          * New tasks loose permission to use the fpu. This accelerates context
 107          * switching for non fp programs, which true for the most programs.
 108          */
 109         p->tss.cp0_status = regs->cp0_status &
 110                             ~(ST0_CU1|ST0_CU0|ST0_KSU|ST0_ERL|ST0_EXL);
 111         childregs->cp0_status &= ~(ST0_CU1|ST0_CU0);
 112 
 113         if (IS_CLONE) {
 114                 if (regs->reg4)
 115                         childregs->reg29 = regs->reg4;
 116                 clone_flags = regs->reg5;
 117                 if (childregs->reg29 == regs->reg29)
 118                         clone_flags |= COPYVM;
 119         }
 120 
 121         return clone_flags;
 122 }
 123 
 124 /*
 125  * fill in the user structure for a core dump..
 126  */
 127 void dump_thread(struct pt_regs * regs, struct user * dump)
     /* [previous][next][first][last][top][bottom][index][help] */
 128 {
 129         /*
 130          * Not ready yet
 131          */
 132 #if 0
 133         int i;
 134 
 135 /* changed the size calculations - should hopefully work better. lbt */
 136         dump->magic = CMAGIC;
 137         dump->start_code = 0;
 138         dump->start_stack = regs->esp & ~(PAGE_SIZE - 1);
 139         dump->u_tsize = ((unsigned long) current->mm->end_code) >> 12;
 140         dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> 12;
 141         dump->u_dsize -= dump->u_tsize;
 142         dump->u_ssize = 0;
 143         for (i = 0; i < 8; i++)
 144                 dump->u_debugreg[i] = current->debugreg[i];  
 145 
 146         if (dump->start_stack < TASK_SIZE)
 147                 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> 12;
 148 
 149         dump->regs = *regs;
 150 
 151 /* Flag indicating the math stuff is valid. We don't support this for the
 152    soft-float routines yet */
 153         if (hard_math) {
 154                 if ((dump->u_fpvalid = current->used_math) != 0) {
 155                         if (last_task_used_math == current)
 156                                 __asm__("clts ; fnsave %0": :"m" (dump->i387));
 157                         else
 158                                 memcpy(&dump->i387,&current->tss.i387.hard,sizeof(dump->i387));
 159                 }
 160         } else {
 161                 /* we should dump the emulator state here, but we need to
 162                    convert it into standard 387 format first.. */
 163                 dump->u_fpvalid = 0;
 164         }
 165 #endif
 166 }
 167 
 168 /*
 169  * sys_execve() executes a new program.
 170  */
 171 asmlinkage int sys_execve(struct pt_regs regs)
     /* [previous][next][first][last][top][bottom][index][help] */
 172 {
 173         int error;
 174         char * filename;
 175 
 176         error = getname((char *) regs.reg4, &filename);
 177         if (error)
 178                 return error;
 179         error = do_execve(filename, (char **) regs.reg5, (char **) regs.reg6, &regs);
 180         putname(filename);
 181         return error;
 182 }

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