processor.h 9.4 KB

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