processor.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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/config.h>
  11. #include <linux/threads.h>
  12. #include <linux/spinlock_types.h>
  13. #include <asm/hardware.h>
  14. #include <asm/page.h>
  15. #include <asm/pdc.h>
  16. #include <asm/ptrace.h>
  17. #include <asm/types.h>
  18. #include <asm/system.h>
  19. #endif /* __ASSEMBLY__ */
  20. #define KERNEL_STACK_SIZE (4*PAGE_SIZE)
  21. /*
  22. * Default implementation of macro that returns current
  23. * instruction pointer ("program counter").
  24. */
  25. /* We cannot use MFIA as it was added for PA2.0 - prumpf
  26. At one point there were no "0f/0b" type local symbols in gas for
  27. PA-RISC. This is no longer true, but this still seems like the
  28. nicest way to implement this. */
  29. #define current_text_addr() ({ void *pc; __asm__("\n\tblr 0,%0\n\tnop":"=r" (pc)); pc; })
  30. #define TASK_SIZE (current->thread.task_size)
  31. #define TASK_UNMAPPED_BASE (current->thread.map_base)
  32. #define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
  33. #define DEFAULT_MAP_BASE32 (0x40000000UL)
  34. #ifdef __LP64__
  35. #define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000)
  36. #define DEFAULT_MAP_BASE (0x200000000UL)
  37. #else
  38. #define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32
  39. #define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32
  40. #endif
  41. #ifndef __ASSEMBLY__
  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. char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */
  62. 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 it_delta; /* Interval delta (tic_10ms / HZ * 100) */
  68. unsigned long irq_count; /* number of IRQ's since boot */
  69. unsigned long irq_max_cr16; /* longest time to handle a single IRQ */
  70. unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */
  71. unsigned long hpa; /* Host Physical address */
  72. unsigned long txn_addr; /* MMIO addr of EIR or id_eid */
  73. #ifdef CONFIG_SMP
  74. spinlock_t lock; /* synchronization for ipi's */
  75. unsigned long pending_ipi; /* bitmap of type ipi_message_type */
  76. unsigned long ipi_count; /* number ipi Interrupts */
  77. #endif
  78. unsigned long bh_count; /* number of times bh was invoked */
  79. unsigned long prof_counter; /* per CPU profiling support */
  80. unsigned long prof_multiplier; /* per CPU profiling support */
  81. unsigned long fp_rev;
  82. unsigned long fp_model;
  83. unsigned int state;
  84. struct parisc_device *dev;
  85. unsigned long loops_per_jiffy;
  86. };
  87. extern struct system_cpuinfo_parisc boot_cpu_data;
  88. extern struct cpuinfo_parisc cpu_data[NR_CPUS];
  89. #define current_cpu_data cpu_data[smp_processor_id()]
  90. #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
  91. typedef struct {
  92. int seg;
  93. } mm_segment_t;
  94. #define ARCH_MIN_TASKALIGN 8
  95. struct thread_struct {
  96. struct pt_regs regs;
  97. unsigned long task_size;
  98. unsigned long map_base;
  99. unsigned long flags;
  100. };
  101. /* Thread struct flags. */
  102. #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
  103. #define PARISC_UAC_SIGBUS (1UL << 1)
  104. #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
  105. #define PARISC_UAC_SHIFT 0
  106. #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
  107. #define SET_UNALIGN_CTL(task,value) \
  108. ({ \
  109. (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
  110. | (((value) << PARISC_UAC_SHIFT) & \
  111. PARISC_UAC_MASK)); \
  112. 0; \
  113. })
  114. #define GET_UNALIGN_CTL(task,addr) \
  115. ({ \
  116. put_user(((task)->thread.flags & PARISC_UAC_MASK) \
  117. >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
  118. })
  119. #define INIT_THREAD { \
  120. .regs = { .gr = { 0, }, \
  121. .fr = { 0, }, \
  122. .sr = { 0, }, \
  123. .iasq = { 0, }, \
  124. .iaoq = { 0, }, \
  125. .cr27 = 0, \
  126. }, \
  127. .task_size = DEFAULT_TASK_SIZE, \
  128. .map_base = DEFAULT_MAP_BASE, \
  129. .flags = 0 \
  130. }
  131. /*
  132. * Return saved PC of a blocked thread. This is used by ps mostly.
  133. */
  134. unsigned long thread_saved_pc(struct task_struct *t);
  135. void show_trace(struct task_struct *task, unsigned long *stack);
  136. /*
  137. * Start user thread in another space.
  138. *
  139. * Note that we set both the iaoq and r31 to the new pc. When
  140. * the kernel initially calls execve it will return through an
  141. * rfi path that will use the values in the iaoq. The execve
  142. * syscall path will return through the gateway page, and
  143. * that uses r31 to branch to.
  144. *
  145. * For ELF we clear r23, because the dynamic linker uses it to pass
  146. * the address of the finalizer function.
  147. *
  148. * We also initialize sr3 to an illegal value (illegal for our
  149. * implementation, not for the architecture).
  150. */
  151. typedef unsigned int elf_caddr_t;
  152. #define start_thread_som(regs, new_pc, new_sp) do { \
  153. unsigned long *sp = (unsigned long *)new_sp; \
  154. __u32 spaceid = (__u32)current->mm->context; \
  155. unsigned long pc = (unsigned long)new_pc; \
  156. /* offset pc for priv. level */ \
  157. pc |= 3; \
  158. \
  159. set_fs(USER_DS); \
  160. regs->iasq[0] = spaceid; \
  161. regs->iasq[1] = spaceid; \
  162. regs->iaoq[0] = pc; \
  163. regs->iaoq[1] = pc + 4; \
  164. regs->sr[2] = LINUX_GATEWAY_SPACE; \
  165. regs->sr[3] = 0xffff; \
  166. regs->sr[4] = spaceid; \
  167. regs->sr[5] = spaceid; \
  168. regs->sr[6] = spaceid; \
  169. regs->sr[7] = spaceid; \
  170. regs->gr[ 0] = USER_PSW; \
  171. regs->gr[30] = ((new_sp)+63)&~63; \
  172. regs->gr[31] = pc; \
  173. \
  174. get_user(regs->gr[26],&sp[0]); \
  175. get_user(regs->gr[25],&sp[-1]); \
  176. get_user(regs->gr[24],&sp[-2]); \
  177. get_user(regs->gr[23],&sp[-3]); \
  178. } while(0)
  179. /* The ELF abi wants things done a "wee bit" differently than
  180. * som does. Supporting this behavior here avoids
  181. * having our own version of create_elf_tables.
  182. *
  183. * Oh, and yes, that is not a typo, we are really passing argc in r25
  184. * and argv in r24 (rather than r26 and r25). This is because that's
  185. * where __libc_start_main wants them.
  186. *
  187. * Duplicated from dl-machine.h for the benefit of readers:
  188. *
  189. * Our initial stack layout is rather different from everyone else's
  190. * due to the unique PA-RISC ABI. As far as I know it looks like
  191. * this:
  192. ----------------------------------- (user startup code creates this frame)
  193. | 32 bytes of magic |
  194. |---------------------------------|
  195. | 32 bytes argument/sp save area |
  196. |---------------------------------| (bprm->p)
  197. | ELF auxiliary info |
  198. | (up to 28 words) |
  199. |---------------------------------|
  200. | NULL |
  201. |---------------------------------|
  202. | Environment pointers |
  203. |---------------------------------|
  204. | NULL |
  205. |---------------------------------|
  206. | Argument pointers |
  207. |---------------------------------| <- argv
  208. | argc (1 word) |
  209. |---------------------------------| <- bprm->exec (HACK!)
  210. | N bytes of slack |
  211. |---------------------------------|
  212. | filename passed to execve |
  213. |---------------------------------| (mm->env_end)
  214. | env strings |
  215. |---------------------------------| (mm->env_start, mm->arg_end)
  216. | arg strings |
  217. |---------------------------------|
  218. | additional faked arg strings if |
  219. | we're invoked via binfmt_script |
  220. |---------------------------------| (mm->arg_start)
  221. stack base is at TASK_SIZE - rlim_max.
  222. on downward growing arches, it looks like this:
  223. stack base at TASK_SIZE
  224. | filename passed to execve
  225. | env strings
  226. | arg strings
  227. | faked arg strings
  228. | slack
  229. | ELF
  230. | envps
  231. | argvs
  232. | argc
  233. * The pleasant part of this is that if we need to skip arguments we
  234. * can just decrement argc and move argv, because the stack pointer
  235. * is utterly unrelated to the location of the environment and
  236. * argument vectors.
  237. *
  238. * Note that the S/390 people took the easy way out and hacked their
  239. * GCC to make the stack grow downwards.
  240. *
  241. * Final Note: For entry from syscall, the W (wide) bit of the PSW
  242. * is stuffed into the lowest bit of the user sp (%r30), so we fill
  243. * it in here from the current->personality
  244. */
  245. #ifdef __LP64__
  246. #define USER_WIDE_MODE (personality(current->personality) == PER_LINUX)
  247. #else
  248. #define USER_WIDE_MODE 0
  249. #endif
  250. #define start_thread(regs, new_pc, new_sp) do { \
  251. elf_addr_t *sp = (elf_addr_t *)new_sp; \
  252. __u32 spaceid = (__u32)current->mm->context; \
  253. elf_addr_t pc = (elf_addr_t)new_pc | 3; \
  254. elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
  255. \
  256. set_fs(USER_DS); \
  257. regs->iasq[0] = spaceid; \
  258. regs->iasq[1] = spaceid; \
  259. regs->iaoq[0] = pc; \
  260. regs->iaoq[1] = pc + 4; \
  261. regs->sr[2] = LINUX_GATEWAY_SPACE; \
  262. regs->sr[3] = 0xffff; \
  263. regs->sr[4] = spaceid; \
  264. regs->sr[5] = spaceid; \
  265. regs->sr[6] = spaceid; \
  266. regs->sr[7] = spaceid; \
  267. regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
  268. regs->fr[ 0] = 0LL; \
  269. regs->fr[ 1] = 0LL; \
  270. regs->fr[ 2] = 0LL; \
  271. regs->fr[ 3] = 0LL; \
  272. regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
  273. regs->gr[31] = pc; \
  274. \
  275. get_user(regs->gr[25], (argv - 1)); \
  276. regs->gr[24] = (long) argv; \
  277. regs->gr[23] = 0; \
  278. } while(0)
  279. struct task_struct;
  280. struct mm_struct;
  281. /* Free all resources held by a thread. */
  282. extern void release_thread(struct task_struct *);
  283. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  284. /* Prepare to copy thread state - unlazy all lazy status */
  285. #define prepare_to_copy(tsk) do { } while (0)
  286. extern void map_hpux_gateway_page(struct task_struct *tsk, struct mm_struct *mm);
  287. extern unsigned long get_wchan(struct task_struct *p);
  288. #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
  289. #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
  290. /*
  291. * PA 2.0 defines data prefetch instructions on page 6-11 of the Kane book.
  292. * In addition, many implementations do hardware prefetching of both
  293. * instructions and data.
  294. *
  295. * PA7300LC (page 14-4 of the ERS) also implements prefetching by a load
  296. * to gr0 but not in a way that Linux can use. If the load would cause an
  297. * interruption (eg due to prefetching 0), it is suppressed on PA2.0
  298. * processors, but not on 7300LC.
  299. */
  300. #ifdef CONFIG_PREFETCH
  301. #define ARCH_HAS_PREFETCH
  302. #define ARCH_HAS_PREFETCHW
  303. extern inline void prefetch(const void *addr)
  304. {
  305. __asm__("ldw 0(%0), %%r0" : : "r" (addr));
  306. }
  307. extern inline void prefetchw(const void *addr)
  308. {
  309. __asm__("ldd 0(%0), %%r0" : : "r" (addr));
  310. }
  311. #endif
  312. #define cpu_relax() barrier()
  313. #endif /* __ASSEMBLY__ */
  314. #endif /* __ASM_PARISC_PROCESSOR_H */