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. release_thread
  7. copy_thread
  8. dump_thread
  9. sys_fork
  10. 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 void release_thread(struct task_struct *dead_task)
     /* [previous][next][first][last][top][bottom][index][help] */
  76 {
  77   halt();
  78 }
  79 
  80 extern void ret_sys_call(void);
  81 
  82 /*
  83  * Copy a Sparc thread.  The context of a process on the Sparc is
  84  * composed of the following:
  85  *  1) status registers  %psr (for condition codes + CWP) and %wim
  86  *  2) current register window (in's and global registers)
  87  *  3) the current live stack frame, it contains the register
  88  *     windows the child may 'restore' into, this is important
  89  *  4) kernel stack pointer, user stack pointer (which is %i6)
  90  *  5) The pc and npc the child returns to during a switch
  91  */
  92 
  93 void copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
     /* [previous][next][first][last][top][bottom][index][help] */
  94                  struct task_struct * p, struct pt_regs * regs)
  95 {
  96         struct pt_regs *childregs;
  97         unsigned char *old_stack;
  98         unsigned char *new_stack;
  99         int i;
 100 
 101         /* This process has no context yet. */
 102         p->tss.context = -1;
 103 
 104         /* Grrr, Sparc stack alignment restrictions make things difficult. */
 105         childregs = ((struct pt_regs *) 
 106                      ((p->kernel_stack_page + PAGE_SIZE - 80)&(~7)));
 107 
 108         *childregs = *regs;
 109 
 110         p->tss.usp = sp;    /* both processes have the same user stack */
 111         /* See entry.S */
 112 
 113         /* Allocate new processes kernel stack right under pt_regs.
 114          * Hopefully this should align things the right way.
 115          */
 116         p->tss.ksp = (unsigned long) ((p->kernel_stack_page + PAGE_SIZE - 80 - 96)&(~7));
 117         new_stack = (unsigned char *) (p->tss.ksp);
 118         old_stack = (unsigned char *) (((unsigned long) regs) - 96);
 119 
 120         /* Copy c-stack. */
 121         for(i=0; i<96; i++) *new_stack++ = *old_stack++;
 122 
 123         /* These pc values are only used when we switch to the child for
 124          * the first time, it jumps the child to ret_sys_call in entry.S
 125          * so that the child returns from the sys_call just like parent.
 126          */
 127         p->tss.pc = (((unsigned long) ret_sys_call) - 8);
 128         p->tss.npc = p->tss.pc+4;
 129 
 130         /* Set the return values for both the parent and the child */
 131         regs->u_regs[8] = p->pid;
 132         childregs->u_regs[8] = 0;
 133 
 134         return;
 135 }
 136 
 137 /*
 138  * fill in the user structure for a core dump..
 139  */
 140 void dump_thread(struct pt_regs * regs, struct user * dump)
     /* [previous][next][first][last][top][bottom][index][help] */
 141 {
 142   return; /* solaris does this enough */
 143 }
 144 
 145 asmlinkage int sys_fork(struct pt_regs *regs)
     /* [previous][next][first][last][top][bottom][index][help] */
 146 {
 147   return do_fork(SIGCHLD, regs->u_regs[14], regs);
 148 }
 149 
 150 /*
 151  * sys_execve() executes a new program.
 152  */
 153 asmlinkage int sys_execve(struct pt_regs regs)
     /* [previous][next][first][last][top][bottom][index][help] */
 154 {
 155   printk("sys_execve()... halting\n");
 156   halt();
 157   return 0;
 158 }
 159 

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