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/system.h>
20 #endif /* __ASSEMBLY__ */
22 #define KERNEL_STACK_SIZE (4*PAGE_SIZE)
25 * Default implementation of macro that returns current
26 * instruction pointer ("program counter").
29 #define current_ia(x) __asm__("mfia %0" : "=r"(x))
30 #else /* mfia added in pa2.0 */
31 #define current_ia(x) __asm__("blr 0,%0\n\tnop" : "=r"(x))
33 #define current_text_addr() ({ void *pc; current_ia(pc); pc; })
35 #define TASK_SIZE (current->thread.task_size)
36 #define TASK_UNMAPPED_BASE (current->thread.map_base)
38 #define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
39 #define DEFAULT_MAP_BASE32 (0x40000000UL)
42 #define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000)
43 #define DEFAULT_MAP_BASE (0x200000000UL)
45 #define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32
46 #define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32
52 * Data detected about CPUs at boot time which is the same for all CPU's.
53 * HP boxes are SMP - ie identical processors.
55 * FIXME: some CPU rev info may be processor specific...
57 struct system_cpuinfo_parisc
{
58 unsigned int cpu_count
;
60 unsigned int hversion
;
61 unsigned int sversion
;
62 enum cpu_type cpu_type
;
65 struct pdc_model model
;
66 unsigned long versions
;
68 unsigned long capabilities
;
69 char sys_model_name
[81]; /* PDC-ROM returnes this model name */
72 char *cpu_name
; /* e.g. "PA7300LC (PCX-L2)" */
73 char *family_name
; /* e.g. "1.1e" */
77 /* Per CPU data structure - ie varies per CPU. */
78 struct cpuinfo_parisc
{
79 unsigned long it_value
; /* Interval Timer at last timer Intr */
80 unsigned long it_delta
; /* Interval delta (tic_10ms / HZ * 100) */
81 unsigned long irq_count
; /* number of IRQ's since boot */
82 unsigned long irq_max_cr16
; /* longest time to handle a single IRQ */
83 unsigned long cpuid
; /* aka slot_number or set to NO_PROC_ID */
84 unsigned long hpa
; /* Host Physical address */
85 unsigned long txn_addr
; /* MMIO addr of EIR or id_eid */
87 unsigned long pending_ipi
; /* bitmap of type ipi_message_type */
88 unsigned long ipi_count
; /* number ipi Interrupts */
90 unsigned long bh_count
; /* number of times bh was invoked */
91 unsigned long prof_counter
; /* per CPU profiling support */
92 unsigned long prof_multiplier
; /* per CPU profiling support */
94 unsigned long fp_model
;
96 struct parisc_device
*dev
;
97 unsigned long loops_per_jiffy
;
100 extern struct system_cpuinfo_parisc boot_cpu_data
;
101 extern struct cpuinfo_parisc cpu_data
[NR_CPUS
];
102 #define current_cpu_data cpu_data[smp_processor_id()]
104 #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
110 #define ARCH_MIN_TASKALIGN 8
112 struct thread_struct
{
114 unsigned long task_size
;
115 unsigned long map_base
;
119 /* Thread struct flags. */
120 #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
121 #define PARISC_UAC_SIGBUS (1UL << 1)
122 #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
124 #define PARISC_UAC_SHIFT 0
125 #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
127 #define SET_UNALIGN_CTL(task,value) \
129 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
130 | (((value) << PARISC_UAC_SHIFT) & \
135 #define GET_UNALIGN_CTL(task,addr) \
137 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
138 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
141 #define INIT_THREAD { \
142 .regs = { .gr = { 0, }, \
149 .task_size = DEFAULT_TASK_SIZE, \
150 .map_base = DEFAULT_MAP_BASE, \
155 * Return saved PC of a blocked thread. This is used by ps mostly.
158 unsigned long thread_saved_pc(struct task_struct
*t
);
159 void show_trace(struct task_struct
*task
, unsigned long *stack
);
162 * Start user thread in another space.
164 * Note that we set both the iaoq and r31 to the new pc. When
165 * the kernel initially calls execve it will return through an
166 * rfi path that will use the values in the iaoq. The execve
167 * syscall path will return through the gateway page, and
168 * that uses r31 to branch to.
170 * For ELF we clear r23, because the dynamic linker uses it to pass
171 * the address of the finalizer function.
173 * We also initialize sr3 to an illegal value (illegal for our
174 * implementation, not for the architecture).
176 typedef unsigned int elf_caddr_t
;
178 #define start_thread_som(regs, new_pc, new_sp) do { \
179 unsigned long *sp = (unsigned long *)new_sp; \
180 __u32 spaceid = (__u32)current->mm->context; \
181 unsigned long pc = (unsigned long)new_pc; \
182 /* offset pc for priv. level */ \
186 regs->iasq[0] = spaceid; \
187 regs->iasq[1] = spaceid; \
188 regs->iaoq[0] = pc; \
189 regs->iaoq[1] = pc + 4; \
190 regs->sr[2] = LINUX_GATEWAY_SPACE; \
191 regs->sr[3] = 0xffff; \
192 regs->sr[4] = spaceid; \
193 regs->sr[5] = spaceid; \
194 regs->sr[6] = spaceid; \
195 regs->sr[7] = spaceid; \
196 regs->gr[ 0] = USER_PSW; \
197 regs->gr[30] = ((new_sp)+63)&~63; \
200 get_user(regs->gr[26],&sp[0]); \
201 get_user(regs->gr[25],&sp[-1]); \
202 get_user(regs->gr[24],&sp[-2]); \
203 get_user(regs->gr[23],&sp[-3]); \
206 /* The ELF abi wants things done a "wee bit" differently than
207 * som does. Supporting this behavior here avoids
208 * having our own version of create_elf_tables.
210 * Oh, and yes, that is not a typo, we are really passing argc in r25
211 * and argv in r24 (rather than r26 and r25). This is because that's
212 * where __libc_start_main wants them.
214 * Duplicated from dl-machine.h for the benefit of readers:
216 * Our initial stack layout is rather different from everyone else's
217 * due to the unique PA-RISC ABI. As far as I know it looks like
220 ----------------------------------- (user startup code creates this frame)
221 | 32 bytes of magic |
222 |---------------------------------|
223 | 32 bytes argument/sp save area |
224 |---------------------------------| (bprm->p)
225 | ELF auxiliary info |
227 |---------------------------------|
229 |---------------------------------|
230 | Environment pointers |
231 |---------------------------------|
233 |---------------------------------|
234 | Argument pointers |
235 |---------------------------------| <- argv
237 |---------------------------------| <- bprm->exec (HACK!)
239 |---------------------------------|
240 | filename passed to execve |
241 |---------------------------------| (mm->env_end)
243 |---------------------------------| (mm->env_start, mm->arg_end)
245 |---------------------------------|
246 | additional faked arg strings if |
247 | we're invoked via binfmt_script |
248 |---------------------------------| (mm->arg_start)
249 stack base is at TASK_SIZE - rlim_max.
251 on downward growing arches, it looks like this:
252 stack base at TASK_SIZE
253 | filename passed to execve
263 * The pleasant part of this is that if we need to skip arguments we
264 * can just decrement argc and move argv, because the stack pointer
265 * is utterly unrelated to the location of the environment and
268 * Note that the S/390 people took the easy way out and hacked their
269 * GCC to make the stack grow downwards.
271 * Final Note: For entry from syscall, the W (wide) bit of the PSW
272 * is stuffed into the lowest bit of the user sp (%r30), so we fill
273 * it in here from the current->personality
277 #define USER_WIDE_MODE (!test_thread_flag(TIF_32BIT))
279 #define USER_WIDE_MODE 0
282 #define start_thread(regs, new_pc, new_sp) do { \
283 elf_addr_t *sp = (elf_addr_t *)new_sp; \
284 __u32 spaceid = (__u32)current->mm->context; \
285 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
286 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
289 regs->iasq[0] = spaceid; \
290 regs->iasq[1] = spaceid; \
291 regs->iaoq[0] = pc; \
292 regs->iaoq[1] = pc + 4; \
293 regs->sr[2] = LINUX_GATEWAY_SPACE; \
294 regs->sr[3] = 0xffff; \
295 regs->sr[4] = spaceid; \
296 regs->sr[5] = spaceid; \
297 regs->sr[6] = spaceid; \
298 regs->sr[7] = spaceid; \
299 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
300 regs->fr[ 0] = 0LL; \
301 regs->fr[ 1] = 0LL; \
302 regs->fr[ 2] = 0LL; \
303 regs->fr[ 3] = 0LL; \
304 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
307 get_user(regs->gr[25], (argv - 1)); \
308 regs->gr[24] = (long) argv; \
315 /* Free all resources held by a thread. */
316 extern void release_thread(struct task_struct
*);
317 extern int kernel_thread(int (*fn
)(void *), void * arg
, unsigned long flags
);
319 /* Prepare to copy thread state - unlazy all lazy status */
320 #define prepare_to_copy(tsk) do { } while (0)
322 extern void map_hpux_gateway_page(struct task_struct
*tsk
, struct mm_struct
*mm
);
324 extern unsigned long get_wchan(struct task_struct
*p
);
326 #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
327 #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
329 #define cpu_relax() barrier()
331 /* Used as a macro to identify the combined VIPT/PIPT cached
332 * CPUs which require a guarantee of coherency (no inequivalent
333 * aliases with different data, whether clean or not) to operate */
334 static inline int parisc_requires_coherency(void)
337 return (boot_cpu_data
.cpu_type
== mako
) ||
338 (boot_cpu_data
.cpu_type
== mako2
);
344 #endif /* __ASSEMBLY__ */
346 #endif /* __ASM_PARISC_PROCESSOR_H */