blob: 3bb06e898fdef5f0ad27d66a7144ed2e945c6d06 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/asm-parisc/processor.h
3 *
4 * Copyright (C) 1994 Linus Torvalds
5 * Copyright (C) 2001 Grant Grundler
6 */
7
8#ifndef __ASM_PARISC_PROCESSOR_H
9#define __ASM_PARISC_PROCESSOR_H
10
11#ifndef __ASSEMBLY__
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/threads.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Kyle McMartin959f4f12006-12-14 11:12:50 -050014#include <asm/prefetch.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/pdc.h>
17#include <asm/ptrace.h>
18#include <asm/types.h>
19#include <asm/system.h>
20#endif /* __ASSEMBLY__ */
21
22#define KERNEL_STACK_SIZE (4*PAGE_SIZE)
23
24/*
25 * Default implementation of macro that returns current
26 * instruction pointer ("program counter").
27 */
Kyle McMartin1b6d1b52006-05-19 20:18:17 +000028#ifdef CONFIG_PA20
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))
32#endif
33#define current_text_addr() ({ void *pc; current_ia(pc); pc; })
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Dave Hansen82455252008-02-04 22:28:59 -080035#define TASK_SIZE_OF(tsk) ((tsk)->thread.task_size)
36#define TASK_SIZE TASK_SIZE_OF(current)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#define TASK_UNMAPPED_BASE (current->thread.map_base)
38
39#define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
40#define DEFAULT_MAP_BASE32 (0x40000000UL)
41
Helge Deller513e7ec2007-01-28 15:09:20 +010042#ifdef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000)
44#define DEFAULT_MAP_BASE (0x200000000UL)
45#else
46#define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32
47#define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32
48#endif
49
50#ifndef __ASSEMBLY__
51
52/*
53 * Data detected about CPUs at boot time which is the same for all CPU's.
54 * HP boxes are SMP - ie identical processors.
55 *
56 * FIXME: some CPU rev info may be processor specific...
57 */
58struct system_cpuinfo_parisc {
59 unsigned int cpu_count;
60 unsigned int cpu_hz;
61 unsigned int hversion;
62 unsigned int sversion;
63 enum cpu_type cpu_type;
64
65 struct {
66 struct pdc_model model;
67 unsigned long versions;
68 unsigned long cpuid;
69 unsigned long capabilities;
70 char sys_model_name[81]; /* PDC-ROM returnes this model name */
71 } pdc;
72
Helge Dellere9541d02007-05-27 19:30:36 +020073 const char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */
74 const char *family_name; /* e.g. "1.1e" */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
77
78/* Per CPU data structure - ie varies per CPU. */
79struct 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 */
87#ifdef CONFIG_SMP
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 unsigned long pending_ipi; /* bitmap of type ipi_message_type */
89 unsigned long ipi_count; /* number ipi Interrupts */
90#endif
91 unsigned long bh_count; /* number of times bh was invoked */
92 unsigned long prof_counter; /* per CPU profiling support */
93 unsigned long prof_multiplier; /* per CPU profiling support */
94 unsigned long fp_rev;
95 unsigned long fp_model;
96 unsigned int state;
97 struct parisc_device *dev;
98 unsigned long loops_per_jiffy;
99};
100
101extern struct system_cpuinfo_parisc boot_cpu_data;
102extern struct cpuinfo_parisc cpu_data[NR_CPUS];
103#define current_cpu_data cpu_data[smp_processor_id()]
104
105#define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
106
107typedef struct {
108 int seg;
109} mm_segment_t;
110
111#define ARCH_MIN_TASKALIGN 8
112
113struct thread_struct {
114 struct pt_regs regs;
115 unsigned long task_size;
116 unsigned long map_base;
117 unsigned long flags;
118};
119
120/* Thread struct flags. */
Kyle McMartinf0537252005-10-21 22:43:15 -0400121#define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
122#define PARISC_UAC_SIGBUS (1UL << 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
124
Kyle McMartinf0537252005-10-21 22:43:15 -0400125#define PARISC_UAC_SHIFT 0
126#define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
127
128#define SET_UNALIGN_CTL(task,value) \
129 ({ \
130 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
131 | (((value) << PARISC_UAC_SHIFT) & \
132 PARISC_UAC_MASK)); \
133 0; \
134 })
135
136#define GET_UNALIGN_CTL(task,addr) \
137 ({ \
138 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
139 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
140 })
141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142#define INIT_THREAD { \
Alexey Dobriyan02d79802006-01-10 20:48:02 -0500143 .regs = { .gr = { 0, }, \
144 .fr = { 0, }, \
145 .sr = { 0, }, \
146 .iasq = { 0, }, \
147 .iaoq = { 0, }, \
148 .cr27 = 0, \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 }, \
Alexey Dobriyan02d79802006-01-10 20:48:02 -0500150 .task_size = DEFAULT_TASK_SIZE, \
151 .map_base = DEFAULT_MAP_BASE, \
152 .flags = 0 \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 }
154
155/*
156 * Return saved PC of a blocked thread. This is used by ps mostly.
157 */
158
159unsigned long thread_saved_pc(struct task_struct *t);
160void show_trace(struct task_struct *task, unsigned long *stack);
161
162/*
163 * Start user thread in another space.
164 *
165 * Note that we set both the iaoq and r31 to the new pc. When
166 * the kernel initially calls execve it will return through an
167 * rfi path that will use the values in the iaoq. The execve
168 * syscall path will return through the gateway page, and
169 * that uses r31 to branch to.
170 *
171 * For ELF we clear r23, because the dynamic linker uses it to pass
172 * the address of the finalizer function.
173 *
174 * We also initialize sr3 to an illegal value (illegal for our
175 * implementation, not for the architecture).
176 */
177typedef unsigned int elf_caddr_t;
178
179#define start_thread_som(regs, new_pc, new_sp) do { \
180 unsigned long *sp = (unsigned long *)new_sp; \
181 __u32 spaceid = (__u32)current->mm->context; \
182 unsigned long pc = (unsigned long)new_pc; \
183 /* offset pc for priv. level */ \
184 pc |= 3; \
185 \
186 set_fs(USER_DS); \
187 regs->iasq[0] = spaceid; \
188 regs->iasq[1] = spaceid; \
189 regs->iaoq[0] = pc; \
190 regs->iaoq[1] = pc + 4; \
191 regs->sr[2] = LINUX_GATEWAY_SPACE; \
192 regs->sr[3] = 0xffff; \
193 regs->sr[4] = spaceid; \
194 regs->sr[5] = spaceid; \
195 regs->sr[6] = spaceid; \
196 regs->sr[7] = spaceid; \
197 regs->gr[ 0] = USER_PSW; \
198 regs->gr[30] = ((new_sp)+63)&~63; \
199 regs->gr[31] = pc; \
200 \
201 get_user(regs->gr[26],&sp[0]); \
202 get_user(regs->gr[25],&sp[-1]); \
203 get_user(regs->gr[24],&sp[-2]); \
204 get_user(regs->gr[23],&sp[-3]); \
205} while(0)
206
207/* The ELF abi wants things done a "wee bit" differently than
208 * som does. Supporting this behavior here avoids
209 * having our own version of create_elf_tables.
210 *
211 * Oh, and yes, that is not a typo, we are really passing argc in r25
212 * and argv in r24 (rather than r26 and r25). This is because that's
213 * where __libc_start_main wants them.
214 *
215 * Duplicated from dl-machine.h for the benefit of readers:
216 *
217 * Our initial stack layout is rather different from everyone else's
218 * due to the unique PA-RISC ABI. As far as I know it looks like
219 * this:
220
221 ----------------------------------- (user startup code creates this frame)
222 | 32 bytes of magic |
223 |---------------------------------|
224 | 32 bytes argument/sp save area |
225 |---------------------------------| (bprm->p)
226 | ELF auxiliary info |
227 | (up to 28 words) |
228 |---------------------------------|
229 | NULL |
230 |---------------------------------|
231 | Environment pointers |
232 |---------------------------------|
233 | NULL |
234 |---------------------------------|
235 | Argument pointers |
236 |---------------------------------| <- argv
237 | argc (1 word) |
238 |---------------------------------| <- bprm->exec (HACK!)
239 | N bytes of slack |
240 |---------------------------------|
241 | filename passed to execve |
242 |---------------------------------| (mm->env_end)
243 | env strings |
244 |---------------------------------| (mm->env_start, mm->arg_end)
245 | arg strings |
246 |---------------------------------|
247 | additional faked arg strings if |
248 | we're invoked via binfmt_script |
249 |---------------------------------| (mm->arg_start)
250 stack base is at TASK_SIZE - rlim_max.
251
252on downward growing arches, it looks like this:
253 stack base at TASK_SIZE
254 | filename passed to execve
255 | env strings
256 | arg strings
257 | faked arg strings
258 | slack
259 | ELF
260 | envps
261 | argvs
262 | argc
263
264 * The pleasant part of this is that if we need to skip arguments we
265 * can just decrement argc and move argv, because the stack pointer
266 * is utterly unrelated to the location of the environment and
267 * argument vectors.
268 *
269 * Note that the S/390 people took the easy way out and hacked their
270 * GCC to make the stack grow downwards.
271 *
272 * Final Note: For entry from syscall, the W (wide) bit of the PSW
273 * is stuffed into the lowest bit of the user sp (%r30), so we fill
274 * it in here from the current->personality
275 */
276
Helge Deller513e7ec2007-01-28 15:09:20 +0100277#ifdef CONFIG_64BIT
Kyle McMartindf570b92006-08-27 11:04:26 -0400278#define USER_WIDE_MODE (!test_thread_flag(TIF_32BIT))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279#else
280#define USER_WIDE_MODE 0
281#endif
282
283#define start_thread(regs, new_pc, new_sp) do { \
284 elf_addr_t *sp = (elf_addr_t *)new_sp; \
285 __u32 spaceid = (__u32)current->mm->context; \
286 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
287 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
288 \
289 set_fs(USER_DS); \
290 regs->iasq[0] = spaceid; \
291 regs->iasq[1] = spaceid; \
292 regs->iaoq[0] = pc; \
293 regs->iaoq[1] = pc + 4; \
294 regs->sr[2] = LINUX_GATEWAY_SPACE; \
295 regs->sr[3] = 0xffff; \
296 regs->sr[4] = spaceid; \
297 regs->sr[5] = spaceid; \
298 regs->sr[6] = spaceid; \
299 regs->sr[7] = spaceid; \
300 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
301 regs->fr[ 0] = 0LL; \
302 regs->fr[ 1] = 0LL; \
303 regs->fr[ 2] = 0LL; \
304 regs->fr[ 3] = 0LL; \
305 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
306 regs->gr[31] = pc; \
307 \
308 get_user(regs->gr[25], (argv - 1)); \
309 regs->gr[24] = (long) argv; \
310 regs->gr[23] = 0; \
311} while(0)
312
313struct task_struct;
314struct mm_struct;
315
316/* Free all resources held by a thread. */
317extern void release_thread(struct task_struct *);
318extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
319
320/* Prepare to copy thread state - unlazy all lazy status */
321#define prepare_to_copy(tsk) do { } while (0)
322
323extern void map_hpux_gateway_page(struct task_struct *tsk, struct mm_struct *mm);
324
325extern unsigned long get_wchan(struct task_struct *p);
326
327#define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
328#define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
329
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330#define cpu_relax() barrier()
331
James Bottomley20f4d3c2006-08-23 09:00:04 -0700332/* Used as a macro to identify the combined VIPT/PIPT cached
333 * CPUs which require a guarantee of coherency (no inequivalent
334 * aliases with different data, whether clean or not) to operate */
335static inline int parisc_requires_coherency(void)
336{
337#ifdef CONFIG_PA8X00
Kyle McMartin2cbd42d2007-03-27 16:47:49 -0400338 return (boot_cpu_data.cpu_type == mako) ||
339 (boot_cpu_data.cpu_type == mako2);
James Bottomley20f4d3c2006-08-23 09:00:04 -0700340#else
341 return 0;
342#endif
343}
344
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345#endif /* __ASSEMBLY__ */
346
347#endif /* __ASM_PARISC_PROCESSOR_H */