Linux 4.14-rc6
[linux-2.6-block.git] / arch / parisc / include / asm / processor.h
CommitLineData
1da177e4
LT
1/*
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__
1da177e4
LT
12#include <linux/threads.h>
13
959f4f13 14#include <asm/prefetch.h>
1da177e4 15#include <asm/hardware.h>
1da177e4
LT
16#include <asm/pdc.h>
17#include <asm/ptrace.h>
18#include <asm/types.h>
ef017beb 19#include <asm/percpu.h>
1da177e4
LT
20#endif /* __ASSEMBLY__ */
21
1da177e4
LT
22/*
23 * Default implementation of macro that returns current
24 * instruction pointer ("program counter").
25 */
1b6d1b5e
KM
26#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; })
1da177e4 32
9dabf60d
HD
33#define HAVE_ARCH_PICK_MMAP_LAYOUT
34
82455257
DH
35#define TASK_SIZE_OF(tsk) ((tsk)->thread.task_size)
36#define TASK_SIZE TASK_SIZE_OF(current)
1da177e4
LT
37#define TASK_UNMAPPED_BASE (current->thread.map_base)
38
39#define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
40#define DEFAULT_MAP_BASE32 (0x40000000UL)
41
513e7ecd 42#ifdef CONFIG_64BIT
1da177e4
LT
43#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
922a70d3
DH
50#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
042d27ac
HD
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))
d71f290b 62
922a70d3
DH
63#endif
64
1da177e4
LT
65#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
e9541d0c
HD
88 const char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */
89 const char *family_name; /* e.g. "1.1e" */
1da177e4
LT
90};
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 */
1da177e4 96 unsigned long irq_count; /* number of IRQ's since boot */
1da177e4
LT
97 unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */
98 unsigned long hpa; /* Host Physical address */
99 unsigned long txn_addr; /* MMIO addr of EIR or id_eid */
100#ifdef CONFIG_SMP
1da177e4 101 unsigned long pending_ipi; /* bitmap of type ipi_message_type */
1da177e4
LT
102#endif
103 unsigned long bh_count; /* number of times bh was invoked */
1da177e4
LT
104 unsigned long fp_rev;
105 unsigned long fp_model;
c8c37359
HD
106 unsigned long cpu_num; /* CPU number from PAT firmware */
107 unsigned long cpu_loc; /* CPU location from PAT firmware */
1da177e4
LT
108 unsigned int state;
109 struct parisc_device *dev;
110 unsigned long loops_per_jiffy;
111};
112
113extern struct system_cpuinfo_parisc boot_cpu_data;
ef017beb 114DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
1da177e4
LT
115
116#define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
117
118typedef struct {
119 int seg;
120} mm_segment_t;
121
122#define ARCH_MIN_TASKALIGN 8
123
124struct thread_struct {
125 struct pt_regs regs;
126 unsigned long task_size;
127 unsigned long map_base;
128 unsigned long flags;
129};
130
abf1e11a
KM
131#define task_pt_regs(tsk) ((struct pt_regs *)&((tsk)->thread.regs))
132
1da177e4 133/* Thread struct flags. */
f053725b
KM
134#define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
135#define PARISC_UAC_SIGBUS (1UL << 1)
1da177e4
LT
136#define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
137
f053725b
KM
138#define PARISC_UAC_SHIFT 0
139#define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
140
141#define SET_UNALIGN_CTL(task,value) \
142 ({ \
143 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
144 | (((value) << PARISC_UAC_SHIFT) & \
145 PARISC_UAC_MASK)); \
146 0; \
147 })
148
149#define GET_UNALIGN_CTL(task,addr) \
150 ({ \
151 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
152 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
153 })
154
1da177e4 155#define INIT_THREAD { \
02d79800
AD
156 .regs = { .gr = { 0, }, \
157 .fr = { 0, }, \
158 .sr = { 0, }, \
159 .iasq = { 0, }, \
160 .iaoq = { 0, }, \
161 .cr27 = 0, \
1da177e4 162 }, \
02d79800
AD
163 .task_size = DEFAULT_TASK_SIZE, \
164 .map_base = DEFAULT_MAP_BASE, \
165 .flags = 0 \
1da177e4
LT
166 }
167
527dcdcc 168struct task_struct;
1da177e4
LT
169void show_trace(struct task_struct *task, unsigned long *stack);
170
171/*
172 * Start user thread in another space.
173 *
174 * Note that we set both the iaoq and r31 to the new pc. When
175 * the kernel initially calls execve it will return through an
176 * rfi path that will use the values in the iaoq. The execve
177 * syscall path will return through the gateway page, and
178 * that uses r31 to branch to.
179 *
180 * For ELF we clear r23, because the dynamic linker uses it to pass
181 * the address of the finalizer function.
182 *
183 * We also initialize sr3 to an illegal value (illegal for our
184 * implementation, not for the architecture).
185 */
186typedef unsigned int elf_caddr_t;
187
1da177e4
LT
188/* The ELF abi wants things done a "wee bit" differently than
189 * som does. Supporting this behavior here avoids
190 * having our own version of create_elf_tables.
191 *
192 * Oh, and yes, that is not a typo, we are really passing argc in r25
193 * and argv in r24 (rather than r26 and r25). This is because that's
194 * where __libc_start_main wants them.
195 *
196 * Duplicated from dl-machine.h for the benefit of readers:
197 *
198 * Our initial stack layout is rather different from everyone else's
199 * due to the unique PA-RISC ABI. As far as I know it looks like
200 * this:
201
202 ----------------------------------- (user startup code creates this frame)
203 | 32 bytes of magic |
204 |---------------------------------|
205 | 32 bytes argument/sp save area |
206 |---------------------------------| (bprm->p)
207 | ELF auxiliary info |
208 | (up to 28 words) |
209 |---------------------------------|
210 | NULL |
211 |---------------------------------|
212 | Environment pointers |
213 |---------------------------------|
214 | NULL |
215 |---------------------------------|
216 | Argument pointers |
217 |---------------------------------| <- argv
218 | argc (1 word) |
219 |---------------------------------| <- bprm->exec (HACK!)
220 | N bytes of slack |
221 |---------------------------------|
222 | filename passed to execve |
223 |---------------------------------| (mm->env_end)
224 | env strings |
225 |---------------------------------| (mm->env_start, mm->arg_end)
226 | arg strings |
227 |---------------------------------|
228 | additional faked arg strings if |
229 | we're invoked via binfmt_script |
230 |---------------------------------| (mm->arg_start)
231 stack base is at TASK_SIZE - rlim_max.
232
233on downward growing arches, it looks like this:
234 stack base at TASK_SIZE
235 | filename passed to execve
236 | env strings
237 | arg strings
238 | faked arg strings
239 | slack
240 | ELF
241 | envps
242 | argvs
243 | argc
244
245 * The pleasant part of this is that if we need to skip arguments we
246 * can just decrement argc and move argv, because the stack pointer
247 * is utterly unrelated to the location of the environment and
248 * argument vectors.
249 *
250 * Note that the S/390 people took the easy way out and hacked their
251 * GCC to make the stack grow downwards.
252 *
253 * Final Note: For entry from syscall, the W (wide) bit of the PSW
254 * is stuffed into the lowest bit of the user sp (%r30), so we fill
255 * it in here from the current->personality
256 */
257
513e7ecd 258#ifdef CONFIG_64BIT
df570b9c 259#define USER_WIDE_MODE (!test_thread_flag(TIF_32BIT))
1da177e4
LT
260#else
261#define USER_WIDE_MODE 0
262#endif
263
264#define start_thread(regs, new_pc, new_sp) do { \
265 elf_addr_t *sp = (elf_addr_t *)new_sp; \
266 __u32 spaceid = (__u32)current->mm->context; \
267 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
268 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
269 \
1da177e4
LT
270 regs->iasq[0] = spaceid; \
271 regs->iasq[1] = spaceid; \
272 regs->iaoq[0] = pc; \
273 regs->iaoq[1] = pc + 4; \
274 regs->sr[2] = LINUX_GATEWAY_SPACE; \
275 regs->sr[3] = 0xffff; \
276 regs->sr[4] = spaceid; \
277 regs->sr[5] = spaceid; \
278 regs->sr[6] = spaceid; \
279 regs->sr[7] = spaceid; \
280 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
281 regs->fr[ 0] = 0LL; \
282 regs->fr[ 1] = 0LL; \
283 regs->fr[ 2] = 0LL; \
284 regs->fr[ 3] = 0LL; \
285 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
286 regs->gr[31] = pc; \
287 \
288 get_user(regs->gr[25], (argv - 1)); \
289 regs->gr[24] = (long) argv; \
290 regs->gr[23] = 0; \
291} while(0)
292
293struct task_struct;
294struct mm_struct;
295
296/* Free all resources held by a thread. */
297extern void release_thread(struct task_struct *);
1da177e4 298
1da177e4
LT
299extern unsigned long get_wchan(struct task_struct *p);
300
301#define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
302#define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
303
1da177e4
LT
304#define cpu_relax() barrier()
305
fc632575
HD
306/*
307 * parisc_requires_coherency() is used to identify the combined VIPT/PIPT
308 * cached CPUs which require a guarantee of coherency (no inequivalent aliases
309 * with different data, whether clean or not) to operate
310 */
20f4d3cb 311#ifdef CONFIG_PA8X00
fc632575
HD
312extern int _parisc_requires_coherency;
313#define parisc_requires_coherency() _parisc_requires_coherency
20f4d3cb 314#else
fc632575 315#define parisc_requires_coherency() (0)
20f4d3cb 316#endif
20f4d3cb 317
1da177e4
LT
318#endif /* __ASSEMBLY__ */
319
320#endif /* __ASM_PARISC_PROCESSOR_H */