root/include/asm-mips/processor.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. thread_saved_pc
  2. start_thread

   1 /*
   2  * include/asm-mips/processor.h
   3  *
   4  * Copyright (C) 1994  Waldorf Electronics
   5  * written by Ralf Baechle
   6  */
   7 
   8 #ifndef __ASM_MIPS_PROCESSOR_H
   9 #define __ASM_MIPS_PROCESSOR_H
  10 
  11 #if !defined (__LANGUAGE_ASSEMBLY__)
  12 #include <asm/cachectl.h>
  13 #include <asm/mipsregs.h>
  14 #include <asm/reg.h>
  15 #include <asm/system.h>
  16 
  17 /*
  18  * System setup and hardware bug flags..
  19  */
  20 extern char wait_available;             /* only available on R4[26]00 */
  21 
  22 extern unsigned long intr_count;
  23 extern unsigned long event;
  24 
  25 /*
  26  * Bus types (default is ISA, but people can check others with these..)
  27  * MCA_bus hardcoded to 0 for now.
  28  *
  29  * This needs to be extended since MIPS systems are being delivered with
  30  * numerous different types of bus systems.
  31  */
  32 extern int EISA_bus;
  33 #define MCA_bus 0
  34 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
  35 
  36 /*
  37  * MIPS has no problems with write protection
  38  */
  39 #define wp_works_ok 1
  40 #define wp_works_ok__is_a_macro /* for versions in ksyms.c */
  41 
  42 /*
  43  * User space process size: 2GB. This is hardcoded into a few places,
  44  * so don't change it unless you know what you are doing.
  45  */
  46 #define TASK_SIZE       (0x80000000UL)
  47 
  48 /*
  49  * Size of io_bitmap in longwords: 32 is ports 0-0x3ff.
  50  */
  51 #define IO_BITMAP_SIZE  32
  52 
  53 #define NUM_FPU_REGS    32
  54 
  55 struct mips_fpu_hard_struct {
  56         double fp_regs[NUM_FPU_REGS];
  57         unsigned int control;
  58 };
  59 
  60 /*
  61  * FIXME: no fpu emulator yet (but who cares anyway?)
  62  */
  63 struct mips_fpu_soft_struct {
  64         long    dummy;
  65         };
  66 
  67 union mips_fpu_union {
  68         struct mips_fpu_hard_struct hard;
  69         struct mips_fpu_soft_struct soft;
  70 };
  71 
  72 #define INIT_FPU { \
  73         {{0,},} \
  74 }
  75 
  76 /*
  77  * If you change thread_struct remember to change the #defines below too!
  78  */
  79 struct thread_struct {
  80         /*
  81          * saved main processor registers
  82          */
  83         unsigned long   reg16, reg17, reg18, reg19, reg20, reg21, reg22, reg23;
  84         unsigned long                               reg28, reg29, reg30, reg31;
  85         /*
  86          * saved cp0 stuff
  87          */
  88         unsigned long cp0_status;
  89         /*
  90          * saved fpu/fpu emulator stuff
  91          */
  92         union mips_fpu_union fpu;
  93         /*
  94          * Other stuff associated with the thread
  95          */
  96         unsigned long cp0_badvaddr;
  97         unsigned long error_code;
  98         unsigned long trap_no;
  99         unsigned long ksp;              /* Top of kernel stack   */
 100         unsigned long pg_dir;           /* L1 page table pointer */
 101 #define MF_FIXADE 1
 102         unsigned long mflags;
 103 };
 104 
 105 #endif /* !defined (__LANGUAGE_ASSEMBLY__) */
 106 
 107 /*
 108  * If you change the #defines remember to change thread_struct above too!
 109  */
 110 #define TOFF_REG16              0
 111 #define TOFF_REG17              (TOFF_REG16+4)
 112 #define TOFF_REG18              (TOFF_REG17+4)
 113 #define TOFF_REG19              (TOFF_REG18+4)
 114 #define TOFF_REG20              (TOFF_REG19+4)
 115 #define TOFF_REG21              (TOFF_REG20+4)
 116 #define TOFF_REG22              (TOFF_REG21+4)
 117 #define TOFF_REG23              (TOFF_REG22+4)
 118 #define TOFF_REG28              (TOFF_REG23+4)
 119 #define TOFF_REG29              (TOFF_REG28+4)
 120 #define TOFF_REG30              (TOFF_REG29+4)
 121 #define TOFF_REG31              (TOFF_REG30+4)
 122 #define TOFF_CP0_STATUS         (TOFF_REG31+4)
 123 /*
 124  * Pad for 8 byte boundary!
 125  */
 126 #define TOFF_FPU                (((TOFF_CP0_STATUS+4)+(8-1))&~(8-1))
 127 #define TOFF_CP0_BADVADDR       (TOFF_FPU+264)
 128 #define TOFF_ERROR_CODE         (TOFF_CP0_BADVADDR+4)
 129 #define TOFF_TRAP_NO            (TOFF_ERROR_CODE+4)
 130 #define TOFF_KSP                (TOFF_TRAP_NO+4)
 131 #define TOFF_PG_DIR             (TOFF_KSP+4)
 132 #define TOFF_MFLAGS             (TOFF_PG_DIR+4)
 133 
 134 #if !defined (__LANGUAGE_ASSEMBLY__)
 135 
 136 #define INIT_MMAP { &init_mm, KSEG0, KSEG1, PAGE_SHARED, \
 137                     VM_READ | VM_WRITE | VM_EXEC }
 138 
 139 #define INIT_TSS  { \
 140         /* \
 141          * saved main processor registers \
 142          */ \
 143         0, 0, 0, 0, 0, 0, 0, 0, \
 144                     0, 0, 0, 0, \
 145         /* \
 146          * saved cp0 stuff \
 147          */ \
 148         0, \
 149         /* \
 150          * saved fpu/fpu emulator stuff \
 151          */ \
 152         INIT_FPU, \
 153         /* \
 154          * Other stuff associated with the process\
 155          */ \
 156         0, 0, 0, sizeof(init_kernel_stack) + (unsigned long)init_kernel_stack - 8, \
 157         (unsigned long) swapper_pg_dir - PT_OFFSET, 0 \
 158 }
 159 
 160 /*
 161  * Return saved PC of a blocked thread.
 162  */
 163 extern inline unsigned long thread_saved_pc(struct thread_struct *t)
     /* [previous][next][first][last][top][bottom][index][help] */
 164 {
 165         return ((unsigned long *)t->reg29)[EF_CP0_EPC];
 166 }
 167 
 168 /*
 169  * Do necessary setup to start up a newly executed thread.
 170  */
 171 static __inline__
 172 void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
     /* [previous][next][first][last][top][bottom][index][help] */
 173 {
 174         /*
 175          * Pure paranoia; probably not needed.
 176          */
 177         sys_cacheflush(0, ~0, BCACHE);
 178         sync_mem();
 179         regs->cp0_epc = pc;
 180         /*
 181          * New thread looses kernel priviledges.
 182          */
 183         regs->cp0_status = (regs->cp0_status & ~(ST0_CU0|ST0_KSU)) | KSU_USER;
 184         /*
 185          * Reserve argument save space for registers a0 - a3.
 186         regs->reg29 = sp - 4 * sizeof(unsigned long);
 187          */
 188         regs->reg29 = sp;
 189 }
 190 
 191 #ifdef __KERNEL__
 192 
 193 /*
 194  * switch_to(n) should switch tasks to task nr n, first
 195  * checking that n isn't the current task, in which case it does nothing.
 196  */
 197 asmlinkage void resume(struct task_struct *tsk, int offset);
 198 
 199 #define switch_to(n) \
 200         resume(n, ((int)(&((struct task_struct *)0)->tss)))
 201 
 202 /*
 203  * Does the process account for user or for system time?
 204  */
 205 #if defined (__R4000__)
 206 
 207 #define USES_USER_TIME(regs) (!((regs)->cp0_status & 0x18))
 208 
 209 #else /* !defined (__R4000__) */
 210 
 211 #define USES_USER_TIME(regs) (!((regs)->cp0_status & 0x4))
 212 
 213 #endif /* !defined (__R4000__) */
 214 
 215 #endif /* __KERNEL__ */
 216 
 217 #endif /* !defined (__LANGUAGE_ASSEMBLY__) */
 218 
 219 /*
 220  * ELF support
 221  *
 222  * Using EM_MIPS is actually wrong - this one is reserved for big endian
 223  * machines only
 224  */
 225 #define INCOMPATIBLE_MACHINE(m) ((m) != EM_MIPS && (m) != EM_MIPS_RS4_BE)
 226 #define ELF_EM_CPU EM_MIPS
 227 
 228 #endif /* __ASM_MIPS_PROCESSOR_H */

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