processor.h 11 KB

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