processor.h 11 KB

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