processor.h 9.5 KB

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