2 * include/asm-parisc/processor.h
4 * Copyright (C) 1994 Linus Torvalds
5 * Copyright (C) 2001 Grant Grundler
8 #ifndef __ASM_PARISC_PROCESSOR_H
9 #define __ASM_PARISC_PROCESSOR_H
12 #include <linux/threads.h>
13 #include <linux/spinlock_types.h>
15 #include <asm/hardware.h>
18 #include <asm/ptrace.h>
19 #include <asm/types.h>
20 #include <asm/system.h>
21 #endif /* __ASSEMBLY__ */
23 #define KERNEL_STACK_SIZE (4*PAGE_SIZE)
26 * Default implementation of macro that returns current
27 * instruction pointer ("program counter").
30 #define current_ia(x) __asm__("mfia %0" : "=r"(x))
31 #else /* mfia added in pa2.0 */
32 #define current_ia(x) __asm__("blr 0,%0\n\tnop" : "=r"(x))
34 #define current_text_addr() ({ void *pc; current_ia(pc); pc; })
36 #define TASK_SIZE (current->thread.task_size)
37 #define TASK_UNMAPPED_BASE (current->thread.map_base)
39 #define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
40 #define DEFAULT_MAP_BASE32 (0x40000000UL)
43 #define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000)
44 #define DEFAULT_MAP_BASE (0x200000000UL)
46 #define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32
47 #define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32
53 * Data detected about CPUs at boot time which is the same for all CPU's.
54 * HP boxes are SMP - ie identical processors.
56 * FIXME: some CPU rev info may be processor specific...
58 struct system_cpuinfo_parisc {
59 unsigned int cpu_count;
61 unsigned int hversion;
62 unsigned int sversion;
63 enum cpu_type cpu_type;
66 struct pdc_model model;
67 unsigned long versions;
69 unsigned long capabilities;
70 char sys_model_name[81]; /* PDC-ROM returnes this model name */
73 char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */
74 char *family_name; /* e.g. "1.1e" */
78 /* Per CPU data structure - ie varies per CPU. */
79 struct cpuinfo_parisc {
80 unsigned long it_value; /* Interval Timer at last timer Intr */
81 unsigned long it_delta; /* Interval delta (tic_10ms / HZ * 100) */
82 unsigned long irq_count; /* number of IRQ's since boot */
83 unsigned long irq_max_cr16; /* longest time to handle a single IRQ */
84 unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */
85 unsigned long hpa; /* Host Physical address */
86 unsigned long txn_addr; /* MMIO addr of EIR or id_eid */
88 spinlock_t lock; /* synchronization for ipi's */
89 unsigned long pending_ipi; /* bitmap of type ipi_message_type */
90 unsigned long ipi_count; /* number ipi Interrupts */
92 unsigned long bh_count; /* number of times bh was invoked */
93 unsigned long prof_counter; /* per CPU profiling support */
94 unsigned long prof_multiplier; /* per CPU profiling support */
96 unsigned long fp_model;
98 struct parisc_device *dev;
99 unsigned long loops_per_jiffy;
102 extern struct system_cpuinfo_parisc boot_cpu_data;
103 extern struct cpuinfo_parisc cpu_data[NR_CPUS];
104 #define current_cpu_data cpu_data[smp_processor_id()]
106 #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
112 #define ARCH_MIN_TASKALIGN 8
114 struct thread_struct {
116 unsigned long task_size;
117 unsigned long map_base;
121 /* Thread struct flags. */
122 #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
123 #define PARISC_UAC_SIGBUS (1UL << 1)
124 #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
126 #define PARISC_UAC_SHIFT 0
127 #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
129 #define SET_UNALIGN_CTL(task,value) \
131 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
132 | (((value) << PARISC_UAC_SHIFT) & \
137 #define GET_UNALIGN_CTL(task,addr) \
139 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
140 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
143 #define INIT_THREAD { \
144 .regs = { .gr = { 0, }, \
151 .task_size = DEFAULT_TASK_SIZE, \
152 .map_base = DEFAULT_MAP_BASE, \
157 * Return saved PC of a blocked thread. This is used by ps mostly.
160 unsigned long thread_saved_pc(struct task_struct *t);
161 void show_trace(struct task_struct *task, unsigned long *stack);
164 * Start user thread in another space.
166 * Note that we set both the iaoq and r31 to the new pc. When
167 * the kernel initially calls execve it will return through an
168 * rfi path that will use the values in the iaoq. The execve
169 * syscall path will return through the gateway page, and
170 * that uses r31 to branch to.
172 * For ELF we clear r23, because the dynamic linker uses it to pass
173 * the address of the finalizer function.
175 * We also initialize sr3 to an illegal value (illegal for our
176 * implementation, not for the architecture).
178 typedef unsigned int elf_caddr_t;
180 #define start_thread_som(regs, new_pc, new_sp) do { \
181 unsigned long *sp = (unsigned long *)new_sp; \
182 __u32 spaceid = (__u32)current->mm->context; \
183 unsigned long pc = (unsigned long)new_pc; \
184 /* offset pc for priv. level */ \
188 regs->iasq[0] = spaceid; \
189 regs->iasq[1] = spaceid; \
190 regs->iaoq[0] = pc; \
191 regs->iaoq[1] = pc + 4; \
192 regs->sr[2] = LINUX_GATEWAY_SPACE; \
193 regs->sr[3] = 0xffff; \
194 regs->sr[4] = spaceid; \
195 regs->sr[5] = spaceid; \
196 regs->sr[6] = spaceid; \
197 regs->sr[7] = spaceid; \
198 regs->gr[ 0] = USER_PSW; \
199 regs->gr[30] = ((new_sp)+63)&~63; \
202 get_user(regs->gr[26],&sp[0]); \
203 get_user(regs->gr[25],&sp[-1]); \
204 get_user(regs->gr[24],&sp[-2]); \
205 get_user(regs->gr[23],&sp[-3]); \
208 /* The ELF abi wants things done a "wee bit" differently than
209 * som does. Supporting this behavior here avoids
210 * having our own version of create_elf_tables.
212 * Oh, and yes, that is not a typo, we are really passing argc in r25
213 * and argv in r24 (rather than r26 and r25). This is because that's
214 * where __libc_start_main wants them.
216 * Duplicated from dl-machine.h for the benefit of readers:
218 * Our initial stack layout is rather different from everyone else's
219 * due to the unique PA-RISC ABI. As far as I know it looks like
222 ----------------------------------- (user startup code creates this frame)
223 | 32 bytes of magic |
224 |---------------------------------|
225 | 32 bytes argument/sp save area |
226 |---------------------------------| (bprm->p)
227 | ELF auxiliary info |
229 |---------------------------------|
231 |---------------------------------|
232 | Environment pointers |
233 |---------------------------------|
235 |---------------------------------|
236 | Argument pointers |
237 |---------------------------------| <- argv
239 |---------------------------------| <- bprm->exec (HACK!)
241 |---------------------------------|
242 | filename passed to execve |
243 |---------------------------------| (mm->env_end)
245 |---------------------------------| (mm->env_start, mm->arg_end)
247 |---------------------------------|
248 | additional faked arg strings if |
249 | we're invoked via binfmt_script |
250 |---------------------------------| (mm->arg_start)
251 stack base is at TASK_SIZE - rlim_max.
253 on downward growing arches, it looks like this:
254 stack base at TASK_SIZE
255 | filename passed to execve
265 * The pleasant part of this is that if we need to skip arguments we
266 * can just decrement argc and move argv, because the stack pointer
267 * is utterly unrelated to the location of the environment and
270 * Note that the S/390 people took the easy way out and hacked their
271 * GCC to make the stack grow downwards.
273 * Final Note: For entry from syscall, the W (wide) bit of the PSW
274 * is stuffed into the lowest bit of the user sp (%r30), so we fill
275 * it in here from the current->personality
279 #define USER_WIDE_MODE (personality(current->personality) == PER_LINUX)
281 #define USER_WIDE_MODE 0
284 #define start_thread(regs, new_pc, new_sp) do { \
285 elf_addr_t *sp = (elf_addr_t *)new_sp; \
286 __u32 spaceid = (__u32)current->mm->context; \
287 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
288 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
291 regs->iasq[0] = spaceid; \
292 regs->iasq[1] = spaceid; \
293 regs->iaoq[0] = pc; \
294 regs->iaoq[1] = pc + 4; \
295 regs->sr[2] = LINUX_GATEWAY_SPACE; \
296 regs->sr[3] = 0xffff; \
297 regs->sr[4] = spaceid; \
298 regs->sr[5] = spaceid; \
299 regs->sr[6] = spaceid; \
300 regs->sr[7] = spaceid; \
301 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
302 regs->fr[ 0] = 0LL; \
303 regs->fr[ 1] = 0LL; \
304 regs->fr[ 2] = 0LL; \
305 regs->fr[ 3] = 0LL; \
306 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
309 get_user(regs->gr[25], (argv - 1)); \
310 regs->gr[24] = (long) argv; \
317 /* Free all resources held by a thread. */
318 extern void release_thread(struct task_struct *);
319 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
321 /* Prepare to copy thread state - unlazy all lazy status */
322 #define prepare_to_copy(tsk) do { } while (0)
324 extern void map_hpux_gateway_page(struct task_struct *tsk, struct mm_struct *mm);
326 extern unsigned long get_wchan(struct task_struct *p);
328 #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
329 #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
333 * PA 2.0 defines data prefetch instructions on page 6-11 of the Kane book.
334 * In addition, many implementations do hardware prefetching of both
335 * instructions and data.
337 * PA7300LC (page 14-4 of the ERS) also implements prefetching by a load
338 * to gr0 but not in a way that Linux can use. If the load would cause an
339 * interruption (eg due to prefetching 0), it is suppressed on PA2.0
340 * processors, but not on 7300LC.
342 #ifdef CONFIG_PREFETCH
343 #define ARCH_HAS_PREFETCH
344 #define ARCH_HAS_PREFETCHW
346 extern inline void prefetch(const void *addr)
348 __asm__("ldw 0(%0), %%r0" : : "r" (addr));
351 extern inline void prefetchw(const void *addr)
353 __asm__("ldd 0(%0), %%r0" : : "r" (addr));
357 #define cpu_relax() barrier()
359 #endif /* __ASSEMBLY__ */
361 #endif /* __ASM_PARISC_PROCESSOR_H */