processor.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /*
  2. * include/asm-parisc/processor.h
  3. *
  4. * Copyright (C) 1994 Linus Torvalds
  5. * Copyright (C) 2001 Grant Grundler
  6. */
  7. #ifndef __ASM_PARISC_PROCESSOR_H
  8. #define __ASM_PARISC_PROCESSOR_H
  9. #ifndef __ASSEMBLY__
  10. #include <linux/threads.h>
  11. #include <asm/prefetch.h>
  12. #include <asm/hardware.h>
  13. #include <asm/pdc.h>
  14. #include <asm/ptrace.h>
  15. #include <asm/types.h>
  16. #include <asm/percpu.h>
  17. #endif /* __ASSEMBLY__ */
  18. /*
  19. * Default implementation of macro that returns current
  20. * instruction pointer ("program counter").
  21. */
  22. #ifdef CONFIG_PA20
  23. #define current_ia(x) __asm__("mfia %0" : "=r"(x))
  24. #else /* mfia added in pa2.0 */
  25. #define current_ia(x) __asm__("blr 0,%0\n\tnop" : "=r"(x))
  26. #endif
  27. #define current_text_addr() ({ void *pc; current_ia(pc); pc; })
  28. #define HAVE_ARCH_PICK_MMAP_LAYOUT
  29. #define TASK_SIZE_OF(tsk) ((tsk)->thread.task_size)
  30. #define TASK_SIZE TASK_SIZE_OF(current)
  31. #define TASK_UNMAPPED_BASE (current->thread.map_base)
  32. #define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
  33. #define DEFAULT_MAP_BASE32 (0x40000000UL)
  34. #ifdef CONFIG_64BIT
  35. #define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000)
  36. #define DEFAULT_MAP_BASE (0x200000000UL)
  37. #else
  38. #define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32
  39. #define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32
  40. #endif
  41. #ifdef __KERNEL__
  42. /* XXX: STACK_TOP actually should be STACK_BOTTOM for parisc.
  43. * prumpf */
  44. #define STACK_TOP TASK_SIZE
  45. #define STACK_TOP_MAX DEFAULT_TASK_SIZE
  46. /* Allow bigger stacks for 64-bit processes */
  47. #define STACK_SIZE_MAX (USER_WIDE_MODE \
  48. ? (1 << 30) /* 1 GB */ \
  49. : (CONFIG_MAX_STACK_SIZE_MB*1024*1024))
  50. #endif
  51. #ifndef __ASSEMBLY__
  52. /*
  53. * Data detected about CPUs at boot time which is the same for all CPU's.
  54. * HP boxes are SMP - ie identical processors.
  55. *
  56. * FIXME: some CPU rev info may be processor specific...
  57. */
  58. struct system_cpuinfo_parisc {
  59. unsigned int cpu_count;
  60. unsigned int cpu_hz;
  61. unsigned int hversion;
  62. unsigned int sversion;
  63. enum cpu_type cpu_type;
  64. struct {
  65. struct pdc_model model;
  66. unsigned long versions;
  67. unsigned long cpuid;
  68. unsigned long capabilities;
  69. char sys_model_name[81]; /* PDC-ROM returnes this model name */
  70. } pdc;
  71. const char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */
  72. const char *family_name; /* e.g. "1.1e" */
  73. };
  74. /* Per CPU data structure - ie varies per CPU. */
  75. struct cpuinfo_parisc {
  76. unsigned long it_value; /* Interval Timer at last timer Intr */
  77. unsigned long it_delta; /* Interval delta (tic_10ms / HZ * 100) */
  78. unsigned long irq_count; /* number of IRQ's since boot */
  79. unsigned long irq_max_cr16; /* longest time to handle a single IRQ */
  80. unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */
  81. unsigned long hpa; /* Host Physical address */
  82. unsigned long txn_addr; /* MMIO addr of EIR or id_eid */
  83. #ifdef CONFIG_SMP
  84. unsigned long pending_ipi; /* bitmap of type ipi_message_type */
  85. #endif
  86. unsigned long bh_count; /* number of times bh was invoked */
  87. unsigned long prof_counter; /* per CPU profiling support */
  88. unsigned long prof_multiplier; /* per CPU profiling support */
  89. unsigned long fp_rev;
  90. unsigned long fp_model;
  91. unsigned int state;
  92. struct parisc_device *dev;
  93. unsigned long loops_per_jiffy;
  94. };
  95. extern struct system_cpuinfo_parisc boot_cpu_data;
  96. DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
  97. #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
  98. typedef struct {
  99. int seg;
  100. } mm_segment_t;
  101. #define ARCH_MIN_TASKALIGN 8
  102. struct thread_struct {
  103. struct pt_regs regs;
  104. unsigned long task_size;
  105. unsigned long map_base;
  106. unsigned long flags;
  107. };
  108. #define task_pt_regs(tsk) ((struct pt_regs *)&((tsk)->thread.regs))
  109. /* Thread struct flags. */
  110. #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
  111. #define PARISC_UAC_SIGBUS (1UL << 1)
  112. #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
  113. #define PARISC_UAC_SHIFT 0
  114. #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
  115. #define SET_UNALIGN_CTL(task,value) \
  116. ({ \
  117. (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
  118. | (((value) << PARISC_UAC_SHIFT) & \
  119. PARISC_UAC_MASK)); \
  120. 0; \
  121. })
  122. #define GET_UNALIGN_CTL(task,addr) \
  123. ({ \
  124. put_user(((task)->thread.flags & PARISC_UAC_MASK) \
  125. >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
  126. })
  127. #define INIT_THREAD { \
  128. .regs = { .gr = { 0, }, \
  129. .fr = { 0, }, \
  130. .sr = { 0, }, \
  131. .iasq = { 0, }, \
  132. .iaoq = { 0, }, \
  133. .cr27 = 0, \
  134. }, \
  135. .task_size = DEFAULT_TASK_SIZE, \
  136. .map_base = DEFAULT_MAP_BASE, \
  137. .flags = 0 \
  138. }
  139. /*
  140. * Return saved PC of a blocked thread. This is used by ps mostly.
  141. */
  142. struct task_struct;
  143. unsigned long thread_saved_pc(struct task_struct *t);
  144. void show_trace(struct task_struct *task, unsigned long *stack);
  145. /*
  146. * Start user thread in another space.
  147. *
  148. * Note that we set both the iaoq and r31 to the new pc. When
  149. * the kernel initially calls execve it will return through an
  150. * rfi path that will use the values in the iaoq. The execve
  151. * syscall path will return through the gateway page, and
  152. * that uses r31 to branch to.
  153. *
  154. * For ELF we clear r23, because the dynamic linker uses it to pass
  155. * the address of the finalizer function.
  156. *
  157. * We also initialize sr3 to an illegal value (illegal for our
  158. * implementation, not for the architecture).
  159. */
  160. typedef unsigned int elf_caddr_t;
  161. /* The ELF abi wants things done a "wee bit" differently than
  162. * som does. Supporting this behavior here avoids
  163. * having our own version of create_elf_tables.
  164. *
  165. * Oh, and yes, that is not a typo, we are really passing argc in r25
  166. * and argv in r24 (rather than r26 and r25). This is because that's
  167. * where __libc_start_main wants them.
  168. *
  169. * Duplicated from dl-machine.h for the benefit of readers:
  170. *
  171. * Our initial stack layout is rather different from everyone else's
  172. * due to the unique PA-RISC ABI. As far as I know it looks like
  173. * this:
  174. ----------------------------------- (user startup code creates this frame)
  175. | 32 bytes of magic |
  176. |---------------------------------|
  177. | 32 bytes argument/sp save area |
  178. |---------------------------------| (bprm->p)
  179. | ELF auxiliary info |
  180. | (up to 28 words) |
  181. |---------------------------------|
  182. | NULL |
  183. |---------------------------------|
  184. | Environment pointers |
  185. |---------------------------------|
  186. | NULL |
  187. |---------------------------------|
  188. | Argument pointers |
  189. |---------------------------------| <- argv
  190. | argc (1 word) |
  191. |---------------------------------| <- bprm->exec (HACK!)
  192. | N bytes of slack |
  193. |---------------------------------|
  194. | filename passed to execve |
  195. |---------------------------------| (mm->env_end)
  196. | env strings |
  197. |---------------------------------| (mm->env_start, mm->arg_end)
  198. | arg strings |
  199. |---------------------------------|
  200. | additional faked arg strings if |
  201. | we're invoked via binfmt_script |
  202. |---------------------------------| (mm->arg_start)
  203. stack base is at TASK_SIZE - rlim_max.
  204. on downward growing arches, it looks like this:
  205. stack base at TASK_SIZE
  206. | filename passed to execve
  207. | env strings
  208. | arg strings
  209. | faked arg strings
  210. | slack
  211. | ELF
  212. | envps
  213. | argvs
  214. | argc
  215. * The pleasant part of this is that if we need to skip arguments we
  216. * can just decrement argc and move argv, because the stack pointer
  217. * is utterly unrelated to the location of the environment and
  218. * argument vectors.
  219. *
  220. * Note that the S/390 people took the easy way out and hacked their
  221. * GCC to make the stack grow downwards.
  222. *
  223. * Final Note: For entry from syscall, the W (wide) bit of the PSW
  224. * is stuffed into the lowest bit of the user sp (%r30), so we fill
  225. * it in here from the current->personality
  226. */
  227. #ifdef CONFIG_64BIT
  228. #define USER_WIDE_MODE (!test_thread_flag(TIF_32BIT))
  229. #else
  230. #define USER_WIDE_MODE 0
  231. #endif
  232. #define start_thread(regs, new_pc, new_sp) do { \
  233. elf_addr_t *sp = (elf_addr_t *)new_sp; \
  234. __u32 spaceid = (__u32)current->mm->context; \
  235. elf_addr_t pc = (elf_addr_t)new_pc | 3; \
  236. elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
  237. \
  238. regs->iasq[0] = spaceid; \
  239. regs->iasq[1] = spaceid; \
  240. regs->iaoq[0] = pc; \
  241. regs->iaoq[1] = pc + 4; \
  242. regs->sr[2] = LINUX_GATEWAY_SPACE; \
  243. regs->sr[3] = 0xffff; \
  244. regs->sr[4] = spaceid; \
  245. regs->sr[5] = spaceid; \
  246. regs->sr[6] = spaceid; \
  247. regs->sr[7] = spaceid; \
  248. regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
  249. regs->fr[ 0] = 0LL; \
  250. regs->fr[ 1] = 0LL; \
  251. regs->fr[ 2] = 0LL; \
  252. regs->fr[ 3] = 0LL; \
  253. regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
  254. regs->gr[31] = pc; \
  255. \
  256. get_user(regs->gr[25], (argv - 1)); \
  257. regs->gr[24] = (long) argv; \
  258. regs->gr[23] = 0; \
  259. } while(0)
  260. struct task_struct;
  261. struct mm_struct;
  262. /* Free all resources held by a thread. */
  263. extern void release_thread(struct task_struct *);
  264. extern unsigned long get_wchan(struct task_struct *p);
  265. #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
  266. #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
  267. #define cpu_relax() barrier()
  268. #define cpu_relax_lowlatency() cpu_relax()
  269. /*
  270. * parisc_requires_coherency() is used to identify the combined VIPT/PIPT
  271. * cached CPUs which require a guarantee of coherency (no inequivalent aliases
  272. * with different data, whether clean or not) to operate
  273. */
  274. #ifdef CONFIG_PA8X00
  275. extern int _parisc_requires_coherency;
  276. #define parisc_requires_coherency() _parisc_requires_coherency
  277. #else
  278. #define parisc_requires_coherency() (0)
  279. #endif
  280. #endif /* __ASSEMBLY__ */
  281. #endif /* __ASM_PARISC_PROCESSOR_H */