root/arch/mips/kernel/process.c

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

DEFINITIONS

This source file includes following definitions.
  1. kb_wait
  2. hard_reset_now
  3. show_regs
  4. exit_thread
  5. flush_thread
  6. release_thread
  7. copy_thread
  8. dump_fpu
  9. dump_thread

   1 /*
   2  *  linux/arch/mips/kernel/process.c
   3  *
   4  *  Copyright (C) 1995 Ralf Baechle
   5  *  written by Ralf Baechle
   6  *
   7  * This file handles the architecture-dependent parts of initialization
   8  */
   9 #include <linux/errno.h>
  10 #include <linux/sched.h>
  11 #include <linux/kernel.h>
  12 #include <linux/mm.h>
  13 #include <linux/stddef.h>
  14 #include <linux/unistd.h>
  15 #include <linux/ptrace.h>
  16 #include <linux/malloc.h>
  17 #include <linux/ldt.h>
  18 #include <linux/mman.h>
  19 #include <linux/sys.h>
  20 #include <linux/user.h>
  21 #include <linux/a.out.h>
  22 
  23 #include <asm/bootinfo.h>
  24 #include <asm/segment.h>
  25 #include <asm/pgtable.h>
  26 #include <asm/system.h>
  27 #include <asm/mipsregs.h>
  28 #include <asm/processor.h>
  29 #include <asm/stackframe.h>
  30 #include <asm/io.h>
  31 
  32 asmlinkage void ret_from_sys_call(void);
  33 
  34 /*
  35  * This routine reboots the machine by asking the keyboard
  36  * controller to pulse the reset-line low. We try that for a while,
  37  * and if it doesn't work, we do some other stupid things.
  38  * Should be ok for Deskstation Tynes. Reseting others needs to be
  39  * investigated...
  40  */
  41 static inline void kb_wait(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43         int i;
  44 
  45         for (i=0; i<0x10000; i++)
  46                 if ((inb_p(0x64) & 0x02) == 0)
  47                         break;
  48 }
  49 
  50 /*
  51  * Hard reset for Deskstation Tyne
  52  * No hint how this works on Pica boards.
  53  */
  54 void hard_reset_now(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  55 {
  56         int i, j;
  57 
  58         sti();
  59         for (;;) {
  60                 for (i=0; i<100; i++) {
  61                         kb_wait();
  62                         for(j = 0; j < 100000 ; j++)
  63                                 /* nothing */;
  64                         outb(0xfe,0x64);         /* pulse reset low */
  65                 }
  66         }
  67 }
  68 
  69 void show_regs(struct pt_regs * regs)
     /* [previous][next][first][last][top][bottom][index][help] */
  70 {
  71         /*
  72          * Saved main processor registers
  73          */
  74         printk("$0 : %08x %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
  75                0, regs->reg1, regs->reg2, regs->reg3,
  76                regs->reg4, regs->reg5, regs->reg6, regs->reg7);
  77         printk("$8 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
  78                regs->reg8, regs->reg9, regs->reg10, regs->reg11,
  79                regs->reg12, regs->reg13, regs->reg14, regs->reg15);
  80         printk("$16: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
  81                regs->reg16, regs->reg17, regs->reg18, regs->reg19,
  82                regs->reg20, regs->reg21, regs->reg22, regs->reg23);
  83         printk("$24: %08lx %08lx                   %08lx %08lx %08lx %08lx\n",
  84                regs->reg24, regs->reg25, regs->reg28, regs->reg29,
  85                regs->reg30, regs->reg31);
  86 
  87         /*
  88          * Saved cp0 registers
  89          */
  90         printk("epc  : %08lx\nStatus: %08lx\nCause : %08lx\n",
  91                regs->cp0_epc, regs->cp0_status, regs->cp0_cause);
  92 }
  93 
  94 /*
  95  * Free current thread data structures etc..
  96  */
  97 void exit_thread(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  98 {
  99         /*
 100          * Nothing to do
 101          */
 102 }
 103 
 104 void flush_thread(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 105 {
 106         /*
 107          * Nothing to do
 108          */
 109 }
 110 
 111 void release_thread(struct task_struct *dead_task)
     /* [previous][next][first][last][top][bottom][index][help] */
 112 {
 113         /*
 114          * Nothing to do
 115          */
 116 }
 117   
 118 void copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
     /* [previous][next][first][last][top][bottom][index][help] */
 119                  struct task_struct * p, struct pt_regs * regs)
 120 {
 121         struct pt_regs * childregs;
 122         unsigned long childksp;
 123 
 124         childksp = p->kernel_stack_page + PAGE_SIZE - 8;
 125         /*
 126          * set up new TSS
 127          */
 128         childregs = ((struct pt_regs *) (p->kernel_stack_page + PAGE_SIZE)) - 1;
 129         *childregs = *regs;
 130         childregs->reg2 = 0;            /* Child gets zero as return value */
 131         childregs->reg7 = 0;            /* Clear error flag */
 132         regs->reg2 = p->pid;
 133         if (childregs->cp0_status & ST0_CU0)
 134                 childregs->reg29 = childksp;
 135         else
 136                 childregs->reg29 = usp;
 137         p->tss.ksp = childksp;
 138         p->tss.reg29 = (unsigned long) childregs;       /* new sp */
 139         p->tss.reg31 = (unsigned long) ret_from_sys_call;
 140 
 141         /*
 142          * New tasks loose permission to use the fpu. This accelerates context
 143          * switching for most programs since they don't use the fpu.
 144          */
 145         p->tss.cp0_status = read_32bit_cp0_register(CP0_STATUS) &
 146                             ~(ST0_CU3|ST0_CU2|ST0_CU1|ST0_KSU|ST0_ERL|ST0_EXL);
 147         childregs->cp0_status &= ~(ST0_CU3|ST0_CU2|ST0_CU1);
 148 }
 149 
 150 /*
 151  * fill in the fpu structure for a core dump..
 152  *
 153  * Actually this is "int dump_fpu (struct elf_fpregset_t *fpu)"
 154  */
 155 int dump_fpu (int shutup_the_gcc_warning_about_elf_fpregset_t)
     /* [previous][next][first][last][top][bottom][index][help] */
 156 {
 157         int fpvalid = 0;
 158         /*
 159          * To do...
 160          */
 161 
 162         return fpvalid;
 163 }
 164 
 165 /*
 166  * fill in the user structure for a core dump..
 167  */
 168 void dump_thread(struct pt_regs * regs, struct user * dump)
     /* [previous][next][first][last][top][bottom][index][help] */
 169 {
 170         /*
 171          * To do...
 172          */
 173 }

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