root/arch/sparc/kernel/process.c

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

DEFINITIONS

This source file includes following definitions.
  1. sys_idle
  2. hard_reset_now
  3. show_regs
  4. exit_thread
  5. flush_thread
  6. copy_thread
  7. dump_thread
  8. sys_fork
  9. sys_execve

   1 /*
   2  *  linux/arch/sparc/kernel/process.c
   3  *
   4  *  Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
   5  */
   6 
   7 /*
   8  * This file handles the architecture-dependent parts of process handling..
   9  */
  10 
  11 #include <linux/errno.h>
  12 #include <linux/sched.h>
  13 #include <linux/kernel.h>
  14 #include <linux/mm.h>
  15 #include <linux/stddef.h>
  16 #include <linux/unistd.h>
  17 #include <linux/ptrace.h>
  18 #include <linux/malloc.h>
  19 #include <linux/ldt.h>
  20 #include <linux/user.h>
  21 #include <linux/a.out.h>
  22 
  23 #include <asm/oplib.h>
  24 #include <asm/segment.h>
  25 #include <asm/system.h>
  26 #include <asm/processor.h>
  27 
  28 /*
  29  * The idle loop on a sparc... ;)
  30  */
  31 asmlinkage int sys_idle(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  32 {
  33 
  34         if (current->pid != 0)
  35                 return -EPERM;
  36 
  37         printk("in sys_idle...\n");
  38         /* Map out the low memory: it's no longer needed */
  39         /* Sparc version RSN */
  40 
  41         /* endless idle loop with no priority at all */
  42         current->counter = -100;
  43         for (;;) {
  44           printk("calling schedule() aieee!\n");
  45           schedule();
  46           printk("schedule() returned, halting...\n");
  47           halt();
  48         }
  49 }
  50 
  51 void hard_reset_now(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  52 {
  53         prom_reboot("boot vmlinux");
  54 }
  55 
  56 void show_regs(struct pt_regs * regs)
     /* [previous][next][first][last][top][bottom][index][help] */
  57 {
  58         printk("\nFP: %08lx PC: %08lx NPC: %08lx\n", regs->u_regs[14],
  59                regs->pc, regs->npc);
  60 }
  61 
  62 /*
  63  * Free current thread data structures etc..
  64  */
  65 void exit_thread(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  66 {
  67   halt();
  68 }
  69 
  70 void flush_thread(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  71 {
  72   halt();
  73 }
  74 
  75 extern void ret_sys_call(void);
  76 
  77 /*
  78  * Copy a Sparc thread.  The context of a process on the Sparc is
  79  * composed of the following:
  80  *  1) status registers  %psr (for condition codes + CWP) and %wim
  81  *  2) current register window (in's and global registers)
  82  *  3) the current live stack frame, it contains the register
  83  *     windows the child may 'restore' into, this is important
  84  *  4) kernel stack pointer, user stack pointer (which is %i6)
  85  *  5) The pc and npc the child returns to during a switch
  86  */
  87 
  88 void copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
     /* [previous][next][first][last][top][bottom][index][help] */
  89                  struct task_struct * p, struct pt_regs * regs)
  90 {
  91         struct pt_regs *childregs;
  92         unsigned char *old_stack;
  93         unsigned char *new_stack;
  94         int i;
  95 
  96         /* This process has no context yet. */
  97         p->tss.context = -1;
  98 
  99         /* Grrr, Sparc stack alignment restrictions make things difficult. */
 100         childregs = ((struct pt_regs *) 
 101                      ((p->kernel_stack_page + PAGE_SIZE - 80)&(~7)));
 102 
 103         *childregs = *regs;
 104 
 105         p->tss.usp = sp;    /* both processes have the same user stack */
 106         /* See entry.S */
 107 
 108         /* Allocate new processes kernel stack right under pt_regs.
 109          * Hopefully this should align things the right way.
 110          */
 111         p->tss.ksp = (unsigned long) ((p->kernel_stack_page + PAGE_SIZE - 80 - 96)&(~7));
 112         new_stack = (unsigned char *) (p->tss.ksp);
 113         old_stack = (unsigned char *) (((unsigned long) regs) - 96);
 114 
 115         /* Copy c-stack. */
 116         for(i=0; i<96; i++) *new_stack++ = *old_stack++;
 117 
 118         /* These pc values are only used when we switch to the child for
 119          * the first time, it jumps the child to ret_sys_call in entry.S
 120          * so that the child returns from the sys_call just like parent.
 121          */
 122         p->tss.pc = (((unsigned long) ret_sys_call) - 8);
 123         p->tss.npc = p->tss.pc+4;
 124 
 125         /* Set the return values for both the parent and the child */
 126         regs->u_regs[8] = p->pid;
 127         childregs->u_regs[8] = 0;
 128 
 129         return;
 130 }
 131 
 132 /*
 133  * fill in the user structure for a core dump..
 134  */
 135 void dump_thread(struct pt_regs * regs, struct user * dump)
     /* [previous][next][first][last][top][bottom][index][help] */
 136 {
 137   return; /* solaris does this enough */
 138 }
 139 
 140 asmlinkage int sys_fork(struct pt_regs *regs)
     /* [previous][next][first][last][top][bottom][index][help] */
 141 {
 142   return do_fork(COPYVM | SIGCHLD, regs->u_regs[14], regs);
 143 }
 144 
 145 /*
 146  * sys_execve() executes a new program.
 147  */
 148 asmlinkage int sys_execve(struct pt_regs regs)
     /* [previous][next][first][last][top][bottom][index][help] */
 149 {
 150   printk("sys_execve()... halting\n");
 151   halt();
 152   return 0;
 153 }
 154 

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