processor.h 10 KB

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