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>
14 #include <asm/prefetch.h>
15 #include <asm/hardware.h>
17 #include <asm/ptrace.h>
18 #include <asm/types.h>
19 #include <asm/percpu.h>
20 #endif /* __ASSEMBLY__ */
23 * Default implementation of macro that returns current
24 * instruction pointer ("program counter").
27 #define current_ia(x) __asm__("mfia %0" : "=r"(x))
28 #else /* mfia added in pa2.0 */
29 #define current_ia(x) __asm__("blr 0,%0\n\tnop" : "=r"(x))
31 #define current_text_addr() ({ void *pc; current_ia(pc); pc; })
33 #define HAVE_ARCH_PICK_MMAP_LAYOUT
35 #define TASK_SIZE_OF(tsk) ((tsk)->thread.task_size)
36 #define TASK_SIZE TASK_SIZE_OF(current)
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
52 /* XXX: STACK_TOP actually should be STACK_BOTTOM for parisc.
55 #define STACK_TOP TASK_SIZE
56 #define STACK_TOP_MAX DEFAULT_TASK_SIZE
58 /* Allow bigger stacks for 64-bit processes */
59 #define STACK_SIZE_MAX (USER_WIDE_MODE \
60 ? (1 << 30) /* 1 GB */ \
61 : (CONFIG_MAX_STACK_SIZE_MB*1024*1024))
68 * Data detected about CPUs at boot time which is the same for all CPU's.
69 * HP boxes are SMP - ie identical processors.
71 * FIXME: some CPU rev info may be processor specific...
73 struct system_cpuinfo_parisc
{
74 unsigned int cpu_count
;
76 unsigned int hversion
;
77 unsigned int sversion
;
78 enum cpu_type cpu_type
;
81 struct pdc_model model
;
82 unsigned long versions
;
84 unsigned long capabilities
;
85 char sys_model_name
[81]; /* PDC-ROM returnes this model name */
88 const char *cpu_name
; /* e.g. "PA7300LC (PCX-L2)" */
89 const char *family_name
; /* e.g. "1.1e" */
93 /* Per CPU data structure - ie varies per CPU. */
94 struct cpuinfo_parisc
{
95 unsigned long it_value
; /* Interval Timer at last timer Intr */
96 unsigned long it_delta
; /* Interval delta (tic_10ms / HZ * 100) */
97 unsigned long irq_count
; /* number of IRQ's since boot */
98 unsigned long irq_max_cr16
; /* longest time to handle a single IRQ */
99 unsigned long cpuid
; /* aka slot_number or set to NO_PROC_ID */
100 unsigned long hpa
; /* Host Physical address */
101 unsigned long txn_addr
; /* MMIO addr of EIR or id_eid */
103 unsigned long pending_ipi
; /* bitmap of type ipi_message_type */
105 unsigned long bh_count
; /* number of times bh was invoked */
106 unsigned long prof_counter
; /* per CPU profiling support */
107 unsigned long prof_multiplier
; /* per CPU profiling support */
108 unsigned long fp_rev
;
109 unsigned long fp_model
;
111 struct parisc_device
*dev
;
112 unsigned long loops_per_jiffy
;
115 extern struct system_cpuinfo_parisc boot_cpu_data
;
116 DECLARE_PER_CPU(struct cpuinfo_parisc
, cpu_data
);
118 #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
124 #define ARCH_MIN_TASKALIGN 8
126 struct thread_struct
{
128 unsigned long task_size
;
129 unsigned long map_base
;
133 #define task_pt_regs(tsk) ((struct pt_regs *)&((tsk)->thread.regs))
135 /* Thread struct flags. */
136 #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
137 #define PARISC_UAC_SIGBUS (1UL << 1)
138 #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
140 #define PARISC_UAC_SHIFT 0
141 #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
143 #define SET_UNALIGN_CTL(task,value) \
145 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
146 | (((value) << PARISC_UAC_SHIFT) & \
151 #define GET_UNALIGN_CTL(task,addr) \
153 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
154 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
157 #define INIT_THREAD { \
158 .regs = { .gr = { 0, }, \
165 .task_size = DEFAULT_TASK_SIZE, \
166 .map_base = DEFAULT_MAP_BASE, \
171 * Return saved PC of a blocked thread. This is used by ps mostly.
175 unsigned long thread_saved_pc(struct task_struct
*t
);
176 void show_trace(struct task_struct
*task
, unsigned long *stack
);
179 * Start user thread in another space.
181 * Note that we set both the iaoq and r31 to the new pc. When
182 * the kernel initially calls execve it will return through an
183 * rfi path that will use the values in the iaoq. The execve
184 * syscall path will return through the gateway page, and
185 * that uses r31 to branch to.
187 * For ELF we clear r23, because the dynamic linker uses it to pass
188 * the address of the finalizer function.
190 * We also initialize sr3 to an illegal value (illegal for our
191 * implementation, not for the architecture).
193 typedef unsigned int elf_caddr_t
;
195 #define start_thread_som(regs, new_pc, new_sp) do { \
196 unsigned long *sp = (unsigned long *)new_sp; \
197 __u32 spaceid = (__u32)current->mm->context; \
198 unsigned long pc = (unsigned long)new_pc; \
199 /* offset pc for priv. level */ \
202 regs->iasq[0] = spaceid; \
203 regs->iasq[1] = spaceid; \
204 regs->iaoq[0] = pc; \
205 regs->iaoq[1] = pc + 4; \
206 regs->sr[2] = LINUX_GATEWAY_SPACE; \
207 regs->sr[3] = 0xffff; \
208 regs->sr[4] = spaceid; \
209 regs->sr[5] = spaceid; \
210 regs->sr[6] = spaceid; \
211 regs->sr[7] = spaceid; \
212 regs->gr[ 0] = USER_PSW; \
213 regs->gr[30] = ((new_sp)+63)&~63; \
216 get_user(regs->gr[26],&sp[0]); \
217 get_user(regs->gr[25],&sp[-1]); \
218 get_user(regs->gr[24],&sp[-2]); \
219 get_user(regs->gr[23],&sp[-3]); \
222 /* The ELF abi wants things done a "wee bit" differently than
223 * som does. Supporting this behavior here avoids
224 * having our own version of create_elf_tables.
226 * Oh, and yes, that is not a typo, we are really passing argc in r25
227 * and argv in r24 (rather than r26 and r25). This is because that's
228 * where __libc_start_main wants them.
230 * Duplicated from dl-machine.h for the benefit of readers:
232 * Our initial stack layout is rather different from everyone else's
233 * due to the unique PA-RISC ABI. As far as I know it looks like
236 ----------------------------------- (user startup code creates this frame)
237 | 32 bytes of magic |
238 |---------------------------------|
239 | 32 bytes argument/sp save area |
240 |---------------------------------| (bprm->p)
241 | ELF auxiliary info |
243 |---------------------------------|
245 |---------------------------------|
246 | Environment pointers |
247 |---------------------------------|
249 |---------------------------------|
250 | Argument pointers |
251 |---------------------------------| <- argv
253 |---------------------------------| <- bprm->exec (HACK!)
255 |---------------------------------|
256 | filename passed to execve |
257 |---------------------------------| (mm->env_end)
259 |---------------------------------| (mm->env_start, mm->arg_end)
261 |---------------------------------|
262 | additional faked arg strings if |
263 | we're invoked via binfmt_script |
264 |---------------------------------| (mm->arg_start)
265 stack base is at TASK_SIZE - rlim_max.
267 on downward growing arches, it looks like this:
268 stack base at TASK_SIZE
269 | filename passed to execve
279 * The pleasant part of this is that if we need to skip arguments we
280 * can just decrement argc and move argv, because the stack pointer
281 * is utterly unrelated to the location of the environment and
284 * Note that the S/390 people took the easy way out and hacked their
285 * GCC to make the stack grow downwards.
287 * Final Note: For entry from syscall, the W (wide) bit of the PSW
288 * is stuffed into the lowest bit of the user sp (%r30), so we fill
289 * it in here from the current->personality
293 #define USER_WIDE_MODE (!test_thread_flag(TIF_32BIT))
295 #define USER_WIDE_MODE 0
298 #define start_thread(regs, new_pc, new_sp) do { \
299 elf_addr_t *sp = (elf_addr_t *)new_sp; \
300 __u32 spaceid = (__u32)current->mm->context; \
301 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
302 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
304 regs->iasq[0] = spaceid; \
305 regs->iasq[1] = spaceid; \
306 regs->iaoq[0] = pc; \
307 regs->iaoq[1] = pc + 4; \
308 regs->sr[2] = LINUX_GATEWAY_SPACE; \
309 regs->sr[3] = 0xffff; \
310 regs->sr[4] = spaceid; \
311 regs->sr[5] = spaceid; \
312 regs->sr[6] = spaceid; \
313 regs->sr[7] = spaceid; \
314 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
315 regs->fr[ 0] = 0LL; \
316 regs->fr[ 1] = 0LL; \
317 regs->fr[ 2] = 0LL; \
318 regs->fr[ 3] = 0LL; \
319 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
322 get_user(regs->gr[25], (argv - 1)); \
323 regs->gr[24] = (long) argv; \
330 /* Free all resources held by a thread. */
331 extern void release_thread(struct task_struct
*);
333 extern void map_hpux_gateway_page(struct task_struct
*tsk
, struct mm_struct
*mm
);
335 extern unsigned long get_wchan(struct task_struct
*p
);
337 #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
338 #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
340 #define cpu_relax() barrier()
341 #define cpu_relax_lowlatency() cpu_relax()
343 /* Used as a macro to identify the combined VIPT/PIPT cached
344 * CPUs which require a guarantee of coherency (no inequivalent
345 * aliases with different data, whether clean or not) to operate */
346 static inline int parisc_requires_coherency(void)
349 return (boot_cpu_data
.cpu_type
== mako
) ||
350 (boot_cpu_data
.cpu_type
== mako2
);
356 #endif /* __ASSEMBLY__ */
358 #endif /* __ASM_PARISC_PROCESSOR_H */