processor.h 9.8 KB

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