processor.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #ifdef __KERNEL__
  2. #ifndef __ASM_PPC_PROCESSOR_H
  3. #define __ASM_PPC_PROCESSOR_H
  4. /*
  5. * Default implementation of macro that returns current
  6. * instruction pointer ("program counter").
  7. */
  8. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  9. #include <linux/config.h>
  10. #include <linux/stringify.h>
  11. #include <asm/ptrace.h>
  12. #include <asm/types.h>
  13. #include <asm/mpc8xx.h>
  14. #include <asm/reg.h>
  15. /* We only need to define a new _MACH_xxx for machines which are part of
  16. * a configuration which supports more than one type of different machine.
  17. * This is currently limited to CONFIG_PPC_MULTIPLATFORM and CHRP/PReP/PMac.
  18. * -- Tom
  19. */
  20. #define _MACH_prep 0x00000001
  21. #define _MACH_Pmac 0x00000002 /* pmac or pmac clone (non-chrp) */
  22. #define _MACH_chrp 0x00000004 /* chrp machine */
  23. /* see residual.h for these */
  24. #define _PREP_Motorola 0x01 /* motorola prep */
  25. #define _PREP_Firm 0x02 /* firmworks prep */
  26. #define _PREP_IBM 0x00 /* ibm prep */
  27. #define _PREP_Bull 0x03 /* bull prep */
  28. /* these are arbitrary */
  29. #define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */
  30. #define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */
  31. #define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */
  32. #define _GLOBAL(n)\
  33. .stabs __stringify(n:F-1),N_FUN,0,0,n;\
  34. .globl n;\
  35. n:
  36. /*
  37. * this is the minimum allowable io space due to the location
  38. * of the io areas on prep (first one at 0x80000000) but
  39. * as soon as I get around to remapping the io areas with the BATs
  40. * to match the mac we can raise this. -- Cort
  41. */
  42. #define TASK_SIZE (CONFIG_TASK_SIZE)
  43. #ifndef __ASSEMBLY__
  44. #ifdef CONFIG_PPC_MULTIPLATFORM
  45. extern int _machine;
  46. /* what kind of prep workstation we are */
  47. extern int _prep_type;
  48. extern int _chrp_type;
  49. /*
  50. * This is used to identify the board type from a given PReP board
  51. * vendor. Board revision is also made available.
  52. */
  53. extern unsigned char ucSystemType;
  54. extern unsigned char ucBoardRev;
  55. extern unsigned char ucBoardRevMaj, ucBoardRevMin;
  56. #else
  57. #define _machine 0
  58. #endif /* CONFIG_PPC_MULTIPLATFORM */
  59. struct task_struct;
  60. void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
  61. void release_thread(struct task_struct *);
  62. /* Prepare to copy thread state - unlazy all lazy status */
  63. extern void prepare_to_copy(struct task_struct *tsk);
  64. /*
  65. * Create a new kernel thread.
  66. */
  67. extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  68. /* Lazy FPU handling on uni-processor */
  69. extern struct task_struct *last_task_used_math;
  70. extern struct task_struct *last_task_used_altivec;
  71. extern struct task_struct *last_task_used_spe;
  72. /* This decides where the kernel will search for a free chunk of vm
  73. * space during mmap's.
  74. */
  75. #define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
  76. typedef struct {
  77. unsigned long seg;
  78. } mm_segment_t;
  79. struct thread_struct {
  80. unsigned long ksp; /* Kernel stack pointer */
  81. struct pt_regs *regs; /* Pointer to saved register state */
  82. mm_segment_t fs; /* for get_fs() validation */
  83. void *pgdir; /* root of page-table tree */
  84. int fpexc_mode; /* floating-point exception mode */
  85. signed long last_syscall;
  86. #if defined(CONFIG_4xx) || defined (CONFIG_BOOKE)
  87. unsigned long dbcr0; /* debug control register values */
  88. unsigned long dbcr1;
  89. #endif
  90. double fpr[32]; /* Complete floating point set */
  91. unsigned long fpscr_pad; /* fpr ... fpscr must be contiguous */
  92. unsigned long fpscr; /* Floating point status */
  93. #ifdef CONFIG_ALTIVEC
  94. /* Complete AltiVec register set */
  95. vector128 vr[32] __attribute((aligned(16)));
  96. /* AltiVec status */
  97. vector128 vscr __attribute((aligned(16)));
  98. unsigned long vrsave;
  99. int used_vr; /* set if process has used altivec */
  100. #endif /* CONFIG_ALTIVEC */
  101. #ifdef CONFIG_SPE
  102. unsigned long evr[32]; /* upper 32-bits of SPE regs */
  103. u64 acc; /* Accumulator */
  104. unsigned long spefscr; /* SPE & eFP status */
  105. int used_spe; /* set if process has used spe */
  106. #endif /* CONFIG_SPE */
  107. };
  108. #define ARCH_MIN_TASKALIGN 16
  109. #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
  110. #define INIT_THREAD { \
  111. .ksp = INIT_SP, \
  112. .fs = KERNEL_DS, \
  113. .pgdir = swapper_pg_dir, \
  114. .fpexc_mode = MSR_FE0 | MSR_FE1, \
  115. }
  116. /*
  117. * Return saved PC of a blocked thread. For now, this is the "user" PC
  118. */
  119. #define thread_saved_pc(tsk) \
  120. ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
  121. unsigned long get_wchan(struct task_struct *p);
  122. #define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
  123. #define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
  124. /* Get/set floating-point exception mode */
  125. #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
  126. #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
  127. extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
  128. extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
  129. static inline unsigned int __unpack_fe01(unsigned int msr_bits)
  130. {
  131. return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
  132. }
  133. static inline unsigned int __pack_fe01(unsigned int fpmode)
  134. {
  135. return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
  136. }
  137. /* in process.c - for early bootup debug -- Cort */
  138. int ll_printk(const char *, ...);
  139. void ll_puts(const char *);
  140. /* In misc.c */
  141. void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
  142. #define have_of (_machine == _MACH_chrp || _machine == _MACH_Pmac)
  143. #define cpu_relax() barrier()
  144. /*
  145. * Prefetch macros.
  146. */
  147. #define ARCH_HAS_PREFETCH
  148. #define ARCH_HAS_PREFETCHW
  149. #define ARCH_HAS_SPINLOCK_PREFETCH
  150. extern inline void prefetch(const void *x)
  151. {
  152. __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
  153. }
  154. extern inline void prefetchw(const void *x)
  155. {
  156. __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
  157. }
  158. #define spin_lock_prefetch(x) prefetchw(x)
  159. extern int emulate_altivec(struct pt_regs *regs);
  160. #endif /* !__ASSEMBLY__ */
  161. #endif /* __ASM_PPC_PROCESSOR_H */
  162. #endif /* __KERNEL__ */