processor.h 11 KB

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