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 TASK_SIZE_OF(tsk) ((tsk)->thread.task_size)
34 #define TASK_SIZE TASK_SIZE_OF(current)
35 #define TASK_UNMAPPED_BASE (current->thread.map_base)
37 #define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
38 #define DEFAULT_MAP_BASE32 (0x40000000UL)
41 #define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000)
42 #define DEFAULT_MAP_BASE (0x200000000UL)
44 #define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32
45 #define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32
50 /* XXX: STACK_TOP actually should be STACK_BOTTOM for parisc.
53 #define STACK_TOP TASK_SIZE
54 #define STACK_TOP_MAX DEFAULT_TASK_SIZE
56 #define STACK_SIZE_MAX (1 << 30) /* 1 GB */
63 * Data detected about CPUs at boot time which is the same for all CPU's.
64 * HP boxes are SMP - ie identical processors.
66 * FIXME: some CPU rev info may be processor specific...
68 struct system_cpuinfo_parisc
{
69 unsigned int cpu_count
;
71 unsigned int hversion
;
72 unsigned int sversion
;
73 enum cpu_type cpu_type
;
76 struct pdc_model model
;
77 unsigned long versions
;
79 unsigned long capabilities
;
80 char sys_model_name
[81]; /* PDC-ROM returnes this model name */
83 const char *cpu_name
; /* e.g. "PA7300LC (PCX-L2)" */
84 const char *family_name
; /* e.g. "1.1e" */
88 /* Per CPU data structure - ie varies per CPU. */
89 struct cpuinfo_parisc
{
90 unsigned long it_value
; /* Interval Timer at last timer Intr */
91 unsigned long it_delta
; /* Interval delta (tic_10ms / HZ * 100) */
92 unsigned long irq_count
; /* number of IRQ's since boot */
93 unsigned long irq_max_cr16
; /* longest time to handle a single IRQ */
94 unsigned long cpuid
; /* aka slot_number or set to NO_PROC_ID */
95 unsigned long hpa
; /* Host Physical address */
96 unsigned long txn_addr
; /* MMIO addr of EIR or id_eid */
98 unsigned long pending_ipi
; /* bitmap of type ipi_message_type */
100 unsigned long bh_count
; /* number of times bh was invoked */
101 unsigned long prof_counter
; /* per CPU profiling support */
102 unsigned long prof_multiplier
; /* per CPU profiling support */
103 unsigned long fp_rev
;
104 unsigned long fp_model
;
106 struct parisc_device
*dev
;
107 unsigned long loops_per_jiffy
;
110 extern struct system_cpuinfo_parisc boot_cpu_data
;
111 DECLARE_PER_CPU(struct cpuinfo_parisc
, cpu_data
);
113 #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
119 #define ARCH_MIN_TASKALIGN 8
121 struct thread_struct
{
123 unsigned long task_size
;
124 unsigned long map_base
;
128 #define task_pt_regs(tsk) ((struct pt_regs *)&((tsk)->thread.regs))
130 /* Thread struct flags. */
131 #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
132 #define PARISC_UAC_SIGBUS (1UL << 1)
133 #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
135 #define PARISC_UAC_SHIFT 0
136 #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
138 #define SET_UNALIGN_CTL(task,value) \
140 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
141 | (((value) << PARISC_UAC_SHIFT) & \
146 #define GET_UNALIGN_CTL(task,addr) \
148 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
149 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
152 #define INIT_THREAD { \
153 .regs = { .gr = { 0, }, \
160 .task_size = DEFAULT_TASK_SIZE, \
161 .map_base = DEFAULT_MAP_BASE, \
166 * Return saved PC of a blocked thread. This is used by ps mostly.
170 unsigned long thread_saved_pc(struct task_struct
*t
);
171 void show_trace(struct task_struct
*task
, unsigned long *stack
);
174 * Start user thread in another space.
176 * Note that we set both the iaoq and r31 to the new pc. When
177 * the kernel initially calls execve it will return through an
178 * rfi path that will use the values in the iaoq. The execve
179 * syscall path will return through the gateway page, and
180 * that uses r31 to branch to.
182 * For ELF we clear r23, because the dynamic linker uses it to pass
183 * the address of the finalizer function.
185 * We also initialize sr3 to an illegal value (illegal for our
186 * implementation, not for the architecture).
188 typedef unsigned int elf_caddr_t
;
190 #define start_thread_som(regs, new_pc, new_sp) do { \
191 unsigned long *sp = (unsigned long *)new_sp; \
192 __u32 spaceid = (__u32)current->mm->context; \
193 unsigned long pc = (unsigned long)new_pc; \
194 /* offset pc for priv. level */ \
197 regs->iasq[0] = spaceid; \
198 regs->iasq[1] = spaceid; \
199 regs->iaoq[0] = pc; \
200 regs->iaoq[1] = pc + 4; \
201 regs->sr[2] = LINUX_GATEWAY_SPACE; \
202 regs->sr[3] = 0xffff; \
203 regs->sr[4] = spaceid; \
204 regs->sr[5] = spaceid; \
205 regs->sr[6] = spaceid; \
206 regs->sr[7] = spaceid; \
207 regs->gr[ 0] = USER_PSW; \
208 regs->gr[30] = ((new_sp)+63)&~63; \
211 get_user(regs->gr[26],&sp[0]); \
212 get_user(regs->gr[25],&sp[-1]); \
213 get_user(regs->gr[24],&sp[-2]); \
214 get_user(regs->gr[23],&sp[-3]); \
217 /* The ELF abi wants things done a "wee bit" differently than
218 * som does. Supporting this behavior here avoids
219 * having our own version of create_elf_tables.
221 * Oh, and yes, that is not a typo, we are really passing argc in r25
222 * and argv in r24 (rather than r26 and r25). This is because that's
223 * where __libc_start_main wants them.
225 * Duplicated from dl-machine.h for the benefit of readers:
227 * Our initial stack layout is rather different from everyone else's
228 * due to the unique PA-RISC ABI. As far as I know it looks like
231 ----------------------------------- (user startup code creates this frame)
232 | 32 bytes of magic |
233 |---------------------------------|
234 | 32 bytes argument/sp save area |
235 |---------------------------------| (bprm->p)
236 | ELF auxiliary info |
238 |---------------------------------|
240 |---------------------------------|
241 | Environment pointers |
242 |---------------------------------|
244 |---------------------------------|
245 | Argument pointers |
246 |---------------------------------| <- argv
248 |---------------------------------| <- bprm->exec (HACK!)
250 |---------------------------------|
251 | filename passed to execve |
252 |---------------------------------| (mm->env_end)
254 |---------------------------------| (mm->env_start, mm->arg_end)
256 |---------------------------------|
257 | additional faked arg strings if |
258 | we're invoked via binfmt_script |
259 |---------------------------------| (mm->arg_start)
260 stack base is at TASK_SIZE - rlim_max.
262 on downward growing arches, it looks like this:
263 stack base at TASK_SIZE
264 | filename passed to execve
274 * The pleasant part of this is that if we need to skip arguments we
275 * can just decrement argc and move argv, because the stack pointer
276 * is utterly unrelated to the location of the environment and
279 * Note that the S/390 people took the easy way out and hacked their
280 * GCC to make the stack grow downwards.
282 * Final Note: For entry from syscall, the W (wide) bit of the PSW
283 * is stuffed into the lowest bit of the user sp (%r30), so we fill
284 * it in here from the current->personality
288 #define USER_WIDE_MODE (!test_thread_flag(TIF_32BIT))
290 #define USER_WIDE_MODE 0
293 #define start_thread(regs, new_pc, new_sp) do { \
294 elf_addr_t *sp = (elf_addr_t *)new_sp; \
295 __u32 spaceid = (__u32)current->mm->context; \
296 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
297 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
299 regs->iasq[0] = spaceid; \
300 regs->iasq[1] = spaceid; \
301 regs->iaoq[0] = pc; \
302 regs->iaoq[1] = pc + 4; \
303 regs->sr[2] = LINUX_GATEWAY_SPACE; \
304 regs->sr[3] = 0xffff; \
305 regs->sr[4] = spaceid; \
306 regs->sr[5] = spaceid; \
307 regs->sr[6] = spaceid; \
308 regs->sr[7] = spaceid; \
309 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
310 regs->fr[ 0] = 0LL; \
311 regs->fr[ 1] = 0LL; \
312 regs->fr[ 2] = 0LL; \
313 regs->fr[ 3] = 0LL; \
314 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
317 get_user(regs->gr[25], (argv - 1)); \
318 regs->gr[24] = (long) argv; \
325 /* Free all resources held by a thread. */
326 extern void release_thread(struct task_struct
*);
328 extern void map_hpux_gateway_page(struct task_struct
*tsk
, struct mm_struct
*mm
);
330 extern unsigned long get_wchan(struct task_struct
*p
);
332 #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
333 #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
335 #define cpu_relax() barrier()
337 /* Used as a macro to identify the combined VIPT/PIPT cached
338 * CPUs which require a guarantee of coherency (no inequivalent
339 * aliases with different data, whether clean or not) to operate */
340 static inline int parisc_requires_coherency(void)
343 return (boot_cpu_data
.cpu_type
== mako
) ||
344 (boot_cpu_data
.cpu_type
== mako2
);
350 #endif /* __ASSEMBLY__ */
352 #endif /* __ASM_PARISC_PROCESSOR_H */