blob: 7e759ecb1343692a11a16526aaff04c5eb607cec [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>
Helge Delleref017be2008-12-31 03:12:10 +000019#include <asm/percpu.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#endif /* __ASSEMBLY__ */
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022/*
23 * Default implementation of macro that returns current
24 * instruction pointer ("program counter").
25 */
Kyle McMartin1b6d1b52006-05-19 20:18:17 +000026#ifdef CONFIG_PA20
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))
30#endif
31#define current_text_addr() ({ void *pc; current_ia(pc); pc; })
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Helge Deller9dabf602014-01-31 22:19:52 +010033#define HAVE_ARCH_PICK_MMAP_LAYOUT
34
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
David Howells922a70d2008-02-08 04:19:26 -080050#ifdef __KERNEL__
51
52/* XXX: STACK_TOP actually should be STACK_BOTTOM for parisc.
53 * prumpf */
54
55#define STACK_TOP TASK_SIZE
56#define STACK_TOP_MAX DEFAULT_TASK_SIZE
57
Helge Deller042d27a2014-04-30 23:26:02 +020058/* 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))
James Hogand71f2902014-05-13 23:58:24 +010062
David Howells922a70d2008-02-08 04:19:26 -080063#endif
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#ifndef __ASSEMBLY__
66
67/*
68 * Data detected about CPUs at boot time which is the same for all CPU's.
69 * HP boxes are SMP - ie identical processors.
70 *
71 * FIXME: some CPU rev info may be processor specific...
72 */
73struct system_cpuinfo_parisc {
74 unsigned int cpu_count;
75 unsigned int cpu_hz;
76 unsigned int hversion;
77 unsigned int sversion;
78 enum cpu_type cpu_type;
79
80 struct {
81 struct pdc_model model;
82 unsigned long versions;
83 unsigned long cpuid;
84 unsigned long capabilities;
85 char sys_model_name[81]; /* PDC-ROM returnes this model name */
86 } pdc;
87
Helge Dellere9541d02007-05-27 19:30:36 +020088 const char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */
89 const char *family_name; /* e.g. "1.1e" */
Linus Torvalds1da177e2005-04-16 15:20:36 -070090};
91
92
93/* Per CPU data structure - ie varies per CPU. */
94struct 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 */
102#ifdef CONFIG_SMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 unsigned long pending_ipi; /* bitmap of type ipi_message_type */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#endif
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;
110 unsigned int state;
111 struct parisc_device *dev;
112 unsigned long loops_per_jiffy;
113};
114
115extern struct system_cpuinfo_parisc boot_cpu_data;
Helge Delleref017be2008-12-31 03:12:10 +0000116DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118#define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
119
120typedef struct {
121 int seg;
122} mm_segment_t;
123
124#define ARCH_MIN_TASKALIGN 8
125
126struct thread_struct {
127 struct pt_regs regs;
128 unsigned long task_size;
129 unsigned long map_base;
130 unsigned long flags;
131};
132
Kyle McMartinabf1e112009-06-23 21:32:18 -0400133#define task_pt_regs(tsk) ((struct pt_regs *)&((tsk)->thread.regs))
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135/* Thread struct flags. */
Kyle McMartinf0537252005-10-21 22:43:15 -0400136#define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
137#define PARISC_UAC_SIGBUS (1UL << 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138#define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
139
Kyle McMartinf0537252005-10-21 22:43:15 -0400140#define PARISC_UAC_SHIFT 0
141#define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
142
143#define SET_UNALIGN_CTL(task,value) \
144 ({ \
145 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
146 | (((value) << PARISC_UAC_SHIFT) & \
147 PARISC_UAC_MASK)); \
148 0; \
149 })
150
151#define GET_UNALIGN_CTL(task,addr) \
152 ({ \
153 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
154 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
155 })
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#define INIT_THREAD { \
Alexey Dobriyan02d79802006-01-10 20:48:02 -0500158 .regs = { .gr = { 0, }, \
159 .fr = { 0, }, \
160 .sr = { 0, }, \
161 .iasq = { 0, }, \
162 .iaoq = { 0, }, \
163 .cr27 = 0, \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 }, \
Alexey Dobriyan02d79802006-01-10 20:48:02 -0500165 .task_size = DEFAULT_TASK_SIZE, \
166 .map_base = DEFAULT_MAP_BASE, \
167 .flags = 0 \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 }
169
170/*
171 * Return saved PC of a blocked thread. This is used by ps mostly.
172 */
173
David Howells527dcdc2012-03-28 18:30:02 +0100174struct task_struct;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175unsigned long thread_saved_pc(struct task_struct *t);
176void show_trace(struct task_struct *task, unsigned long *stack);
177
178/*
179 * Start user thread in another space.
180 *
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.
186 *
187 * For ELF we clear r23, because the dynamic linker uses it to pass
188 * the address of the finalizer function.
189 *
190 * We also initialize sr3 to an illegal value (illegal for our
191 * implementation, not for the architecture).
192 */
193typedef unsigned int elf_caddr_t;
194
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195/* The ELF abi wants things done a "wee bit" differently than
196 * som does. Supporting this behavior here avoids
197 * having our own version of create_elf_tables.
198 *
199 * Oh, and yes, that is not a typo, we are really passing argc in r25
200 * and argv in r24 (rather than r26 and r25). This is because that's
201 * where __libc_start_main wants them.
202 *
203 * Duplicated from dl-machine.h for the benefit of readers:
204 *
205 * Our initial stack layout is rather different from everyone else's
206 * due to the unique PA-RISC ABI. As far as I know it looks like
207 * this:
208
209 ----------------------------------- (user startup code creates this frame)
210 | 32 bytes of magic |
211 |---------------------------------|
212 | 32 bytes argument/sp save area |
213 |---------------------------------| (bprm->p)
214 | ELF auxiliary info |
215 | (up to 28 words) |
216 |---------------------------------|
217 | NULL |
218 |---------------------------------|
219 | Environment pointers |
220 |---------------------------------|
221 | NULL |
222 |---------------------------------|
223 | Argument pointers |
224 |---------------------------------| <- argv
225 | argc (1 word) |
226 |---------------------------------| <- bprm->exec (HACK!)
227 | N bytes of slack |
228 |---------------------------------|
229 | filename passed to execve |
230 |---------------------------------| (mm->env_end)
231 | env strings |
232 |---------------------------------| (mm->env_start, mm->arg_end)
233 | arg strings |
234 |---------------------------------|
235 | additional faked arg strings if |
236 | we're invoked via binfmt_script |
237 |---------------------------------| (mm->arg_start)
238 stack base is at TASK_SIZE - rlim_max.
239
240on downward growing arches, it looks like this:
241 stack base at TASK_SIZE
242 | filename passed to execve
243 | env strings
244 | arg strings
245 | faked arg strings
246 | slack
247 | ELF
248 | envps
249 | argvs
250 | argc
251
252 * The pleasant part of this is that if we need to skip arguments we
253 * can just decrement argc and move argv, because the stack pointer
254 * is utterly unrelated to the location of the environment and
255 * argument vectors.
256 *
257 * Note that the S/390 people took the easy way out and hacked their
258 * GCC to make the stack grow downwards.
259 *
260 * Final Note: For entry from syscall, the W (wide) bit of the PSW
261 * is stuffed into the lowest bit of the user sp (%r30), so we fill
262 * it in here from the current->personality
263 */
264
Helge Deller513e7ec2007-01-28 15:09:20 +0100265#ifdef CONFIG_64BIT
Kyle McMartindf570b92006-08-27 11:04:26 -0400266#define USER_WIDE_MODE (!test_thread_flag(TIF_32BIT))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267#else
268#define USER_WIDE_MODE 0
269#endif
270
271#define start_thread(regs, new_pc, new_sp) do { \
272 elf_addr_t *sp = (elf_addr_t *)new_sp; \
273 __u32 spaceid = (__u32)current->mm->context; \
274 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
275 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
276 \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 regs->iasq[0] = spaceid; \
278 regs->iasq[1] = spaceid; \
279 regs->iaoq[0] = pc; \
280 regs->iaoq[1] = pc + 4; \
281 regs->sr[2] = LINUX_GATEWAY_SPACE; \
282 regs->sr[3] = 0xffff; \
283 regs->sr[4] = spaceid; \
284 regs->sr[5] = spaceid; \
285 regs->sr[6] = spaceid; \
286 regs->sr[7] = spaceid; \
287 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
288 regs->fr[ 0] = 0LL; \
289 regs->fr[ 1] = 0LL; \
290 regs->fr[ 2] = 0LL; \
291 regs->fr[ 3] = 0LL; \
292 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
293 regs->gr[31] = pc; \
294 \
295 get_user(regs->gr[25], (argv - 1)); \
296 regs->gr[24] = (long) argv; \
297 regs->gr[23] = 0; \
298} while(0)
299
300struct task_struct;
301struct mm_struct;
302
303/* Free all resources held by a thread. */
304extern void release_thread(struct task_struct *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306extern unsigned long get_wchan(struct task_struct *p);
307
308#define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
309#define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
310
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311#define cpu_relax() barrier()
Davidlohr Bueso3a6bfbc2014-06-29 15:09:33 -0700312#define cpu_relax_lowlatency() cpu_relax()
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
James Bottomley20f4d3c2006-08-23 09:00:04 -0700314/* Used as a macro to identify the combined VIPT/PIPT cached
315 * CPUs which require a guarantee of coherency (no inequivalent
316 * aliases with different data, whether clean or not) to operate */
317static inline int parisc_requires_coherency(void)
318{
319#ifdef CONFIG_PA8X00
Kyle McMartin2cbd42d2007-03-27 16:47:49 -0400320 return (boot_cpu_data.cpu_type == mako) ||
321 (boot_cpu_data.cpu_type == mako2);
James Bottomley20f4d3c2006-08-23 09:00:04 -0700322#else
323 return 0;
324#endif
325}
326
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327#endif /* __ASSEMBLY__ */
328
329#endif /* __ASM_PARISC_PROCESSOR_H */