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 /*
  31  * Tell us the machine setup..
  32  */
  33 #pragma char wp_works_ok = 0;           /* set if paging hardware honours WP */ 
  34 char wait_available;            /* set if the "wait" instruction available */
  35 
  36 /*
  37  * Bus types ..
  38  */
  39 int EISA_bus = 0;
  40 
  41 asmlinkage void ret_from_sys_call(void) __asm__("ret_from_sys_call");
     /* [previous][next][first][last][top][bottom][index][help] */
  42 
  43 /*
  44  * The idle loop on a MIPS..
  45  */
  46 asmlinkage int sys_idle(void)
  47 {
  48 #if 0
  49         int i;
  50 #endif
  51 
  52         if (current->pid != 0)
  53                 return -EPERM;
  54 
  55 #if 0
  56         /* Map out the low memory: it's no longer needed */
  57         for (i = 0 ; i < 512 ; i++)
  58                 swapper_pg_dir[i] = 0;
  59 #endif
  60 
  61         /* endless idle loop with no priority at all */
  62         current->counter = -100;
  63         for (;;) {
  64                 /*
  65                  * R4[26]00 have wait, R4[04]00 don't.
  66                  */
  67                 if (wait_available && !need_resched)
  68                         __asm__("wait");
  69                 schedule();
  70         }
  71 }
  72 
  73 /*
  74  * Do necessary setup to start up a newly executed thread.
  75  */
  76 void start_thread(struct pt_regs * regs, unsigned long eip, unsigned long esp)
     /* [previous][next][first][last][top][bottom][index][help] */
  77 {
  78         regs->cp0_epc = eip;
  79         regs->reg29 = esp;
  80 }
  81 
  82 /*
  83  * Free current thread data structures etc..
  84  */
  85 void exit_thread(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  86 {
  87         /*
  88          * Nothing to do
  89          */
  90 }
  91 
  92 void flush_thread(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  93 {
  94         /*
  95          * Nothing to do
  96          */
  97 }
  98 
  99 #define IS_CLONE (regs->orig_reg2 == __NR_clone)
 100 
 101 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] */
 102 {
 103         struct pt_regs * childregs;
 104 
 105         /*
 106          * set up new TSS
 107          */
 108         p->tss.fs = KERNEL_DS;
 109         p->tss.ksp = (p->kernel_stack_page + PAGE_SIZE - 4) | KSEG0;
 110         childregs = ((struct pt_regs *) (p->kernel_stack_page + PAGE_SIZE)) - 1;
 111         p->tss.reg29 = ((unsigned long) childregs) | KSEG0; /* new sp */
 112         p->tss.reg31 = (unsigned long) ret_from_sys_call;
 113         *childregs = *regs;
 114         childregs->reg2 = 0;
 115 
 116         /*
 117          * New tasks loose permission to use the fpu. This accelerates context
 118          * switching for non fp programms, which true for the most programms.
 119          */
 120         p->tss.cp0_status = regs->cp0_status &
 121                             ~(ST0_CU1|ST0_CU0|ST0_KSU|ST0_ERL|ST0_EXL);
 122         childregs->cp0_status &= ~(ST0_CU1|ST0_CU0);
 123 
 124         if (IS_CLONE) {
 125                 if (regs->reg4)
 126                         childregs->reg29 = regs->reg4;
 127                 clone_flags = regs->reg5;
 128                 if (childregs->reg29 == regs->reg29)
 129                         clone_flags |= COPYVM;
 130         }
 131 
 132         return clone_flags;
 133 }
 134 
 135 /*
 136  * fill in the user structure for a core dump..
 137  */
 138 void dump_thread(struct pt_regs * regs, struct user * dump)
     /* [previous][next][first][last][top][bottom][index][help] */
 139 {
 140         /*
 141          * Not ready yet
 142          */
 143 #if 0
 144         int i;
 145 
 146 /* changed the size calculations - should hopefully work better. lbt */
 147         dump->magic = CMAGIC;
 148         dump->start_code = 0;
 149         dump->start_stack = regs->esp & ~(PAGE_SIZE - 1);
 150         dump->u_tsize = ((unsigned long) current->mm->end_code) >> 12;
 151         dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> 12;
 152         dump->u_dsize -= dump->u_tsize;
 153         dump->u_ssize = 0;
 154         for (i = 0; i < 8; i++)
 155                 dump->u_debugreg[i] = current->debugreg[i];  
 156 
 157         if (dump->start_stack < TASK_SIZE)
 158                 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> 12;
 159 
 160         dump->regs = *regs;
 161 
 162 /* Flag indicating the math stuff is valid. We don't support this for the
 163    soft-float routines yet */
 164         if (hard_math) {
 165                 if ((dump->u_fpvalid = current->used_math) != 0) {
 166                         if (last_task_used_math == current)
 167                                 __asm__("clts ; fnsave %0": :"m" (dump->i387));
 168                         else
 169                                 memcpy(&dump->i387,&current->tss.i387.hard,sizeof(dump->i387));
 170                 }
 171         } else {
 172                 /* we should dump the emulator state here, but we need to
 173                    convert it into standard 387 format first.. */
 174                 dump->u_fpvalid = 0;
 175         }
 176 #endif
 177 }
 178 
 179 /*
 180  * sys_execve() executes a new program.
 181  */
 182 asmlinkage int sys_execve(struct pt_regs regs)
     /* [previous][next][first][last][top][bottom][index][help] */
 183 {
 184         int error;
 185         char * filename;
 186 
 187         error = getname((char *) regs.reg4, &filename);
 188         if (error)
 189                 return error;
 190         error = do_execve(filename, (char **) regs.reg5, (char **) regs.reg6, &regs);
 191         putname(filename);
 192         return error;
 193 }

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