processor.h 11 KB

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