]> git.ipfire.org Git - thirdparty/kernel/stable.git/blob - arch/parisc/include/asm/processor.h
KVM: clean up directives to compile out irqfds
[thirdparty/kernel/stable.git] / arch / parisc / include / asm / processor.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * include/asm-parisc/processor.h
4 *
5 * Copyright (C) 1994 Linus Torvalds
6 * Copyright (C) 2001 Grant Grundler
7 */
8
9 #ifndef __ASM_PARISC_PROCESSOR_H
10 #define __ASM_PARISC_PROCESSOR_H
11
12 #ifndef __ASSEMBLY__
13 #include <linux/threads.h>
14 #include <linux/irqreturn.h>
15
16 #include <asm/assembly.h>
17 #include <asm/prefetch.h>
18 #include <asm/hardware.h>
19 #include <asm/pdc.h>
20 #include <asm/ptrace.h>
21 #include <asm/types.h>
22 #include <asm/percpu.h>
23 #endif /* __ASSEMBLY__ */
24
25 #define HAVE_ARCH_PICK_MMAP_LAYOUT
26
27 #define TASK_SIZE_OF(tsk) ((tsk)->thread.task_size)
28 #define TASK_SIZE TASK_SIZE_OF(current)
29 #define TASK_UNMAPPED_BASE (current->thread.map_base)
30
31 #define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
32 #define DEFAULT_MAP_BASE32 (0x40000000UL)
33
34 #ifdef CONFIG_64BIT
35 #define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000)
36 #define DEFAULT_MAP_BASE (0x200000000UL)
37 #else
38 #define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32
39 #define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32
40 #endif
41
42 /* XXX: STACK_TOP actually should be STACK_BOTTOM for parisc.
43 * prumpf */
44
45 #define STACK_TOP TASK_SIZE
46 #define STACK_TOP_MAX DEFAULT_TASK_SIZE
47
48 #ifndef __ASSEMBLY__
49
50 unsigned long calc_max_stack_size(unsigned long stack_max);
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 */
58 struct 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
73 const char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */
74 const char *family_name; /* e.g. "1.1e" */
75 };
76
77
78 /* Per CPU data structure - ie varies per CPU. */
79 struct cpuinfo_parisc {
80 unsigned long it_value; /* Interval Timer at last timer Intr */
81 unsigned long irq_count; /* number of IRQ's since boot */
82 unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */
83 unsigned long hpa; /* Host Physical address */
84 unsigned long txn_addr; /* MMIO addr of EIR or id_eid */
85 #ifdef CONFIG_SMP
86 unsigned long pending_ipi; /* bitmap of type ipi_message_type */
87 #endif
88 unsigned long bh_count; /* number of times bh was invoked */
89 unsigned long fp_rev;
90 unsigned long fp_model;
91 unsigned long cpu_num; /* CPU number from PAT firmware */
92 unsigned long cpu_loc; /* CPU location from PAT firmware */
93 unsigned int state;
94 struct parisc_device *dev;
95 };
96
97 extern struct system_cpuinfo_parisc boot_cpu_data;
98 DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
99 extern int time_keeper_id; /* CPU used for timekeeping */
100
101 #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
102
103 struct thread_struct {
104 struct pt_regs regs;
105 unsigned long task_size;
106 unsigned long map_base;
107 unsigned long flags;
108 };
109
110 #define task_pt_regs(tsk) ((struct pt_regs *)&((tsk)->thread.regs))
111
112 /* Thread struct flags. */
113 #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
114 #define PARISC_UAC_SIGBUS (1UL << 1)
115 #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
116
117 #define PARISC_UAC_SHIFT 0
118 #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
119
120 #define SET_UNALIGN_CTL(task,value) \
121 ({ \
122 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
123 | (((value) << PARISC_UAC_SHIFT) & \
124 PARISC_UAC_MASK)); \
125 0; \
126 })
127
128 #define GET_UNALIGN_CTL(task,addr) \
129 ({ \
130 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
131 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
132 })
133
134 #define INIT_THREAD { \
135 .regs = { .gr = { 0, }, \
136 .fr = { 0, }, \
137 .sr = { 0, }, \
138 .iasq = { 0, }, \
139 .iaoq = { 0, }, \
140 .cr27 = 0, \
141 }, \
142 .task_size = DEFAULT_TASK_SIZE, \
143 .map_base = DEFAULT_MAP_BASE, \
144 .flags = 0 \
145 }
146
147 struct task_struct;
148 void show_trace(struct task_struct *task, unsigned long *stack);
149
150 /*
151 * Start user thread in another space.
152 *
153 * Note that we set both the iaoq and r31 to the new pc. When
154 * the kernel initially calls execve it will return through an
155 * rfi path that will use the values in the iaoq. The execve
156 * syscall path will return through the gateway page, and
157 * that uses r31 to branch to.
158 *
159 * For ELF we clear r23, because the dynamic linker uses it to pass
160 * the address of the finalizer function.
161 *
162 * We also initialize sr3 to an illegal value (illegal for our
163 * implementation, not for the architecture).
164 */
165 typedef unsigned int elf_caddr_t;
166
167 /* The ELF abi wants things done a "wee bit" differently than
168 * som does. Supporting this behavior here avoids
169 * having our own version of create_elf_tables.
170 *
171 * Oh, and yes, that is not a typo, we are really passing argc in r25
172 * and argv in r24 (rather than r26 and r25). This is because that's
173 * where __libc_start_main wants them.
174 *
175 * Duplicated from dl-machine.h for the benefit of readers:
176 *
177 * Our initial stack layout is rather different from everyone else's
178 * due to the unique PA-RISC ABI. As far as I know it looks like
179 * this:
180
181 ----------------------------------- (user startup code creates this frame)
182 | 32 bytes of magic |
183 |---------------------------------|
184 | 32 bytes argument/sp save area |
185 |---------------------------------| (bprm->p)
186 | ELF auxiliary info |
187 | (up to 28 words) |
188 |---------------------------------|
189 | NULL |
190 |---------------------------------|
191 | Environment pointers |
192 |---------------------------------|
193 | NULL |
194 |---------------------------------|
195 | Argument pointers |
196 |---------------------------------| <- argv
197 | argc (1 word) |
198 |---------------------------------| <- bprm->exec (HACK!)
199 | N bytes of slack |
200 |---------------------------------|
201 | filename passed to execve |
202 |---------------------------------| (mm->env_end)
203 | env strings |
204 |---------------------------------| (mm->env_start, mm->arg_end)
205 | arg strings |
206 |---------------------------------|
207 | additional faked arg strings if |
208 | we're invoked via binfmt_script |
209 |---------------------------------| (mm->arg_start)
210 stack base is at TASK_SIZE - rlim_max.
211
212 on downward growing arches, it looks like this:
213 stack base at TASK_SIZE
214 | filename passed to execve
215 | env strings
216 | arg strings
217 | faked arg strings
218 | slack
219 | ELF
220 | envps
221 | argvs
222 | argc
223
224 * The pleasant part of this is that if we need to skip arguments we
225 * can just decrement argc and move argv, because the stack pointer
226 * is utterly unrelated to the location of the environment and
227 * argument vectors.
228 *
229 * Note that the S/390 people took the easy way out and hacked their
230 * GCC to make the stack grow downwards.
231 *
232 * Final Note: For entry from syscall, the W (wide) bit of the PSW
233 * is stuffed into the lowest bit of the user sp (%r30), so we fill
234 * it in here from the current->personality
235 */
236
237 #define USER_WIDE_MODE (!is_32bit_task())
238
239 #define start_thread(regs, new_pc, new_sp) do { \
240 elf_addr_t *sp = (elf_addr_t *)new_sp; \
241 __u32 spaceid = (__u32)current->mm->context.space_id; \
242 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
243 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
244 \
245 regs->iasq[0] = spaceid; \
246 regs->iasq[1] = spaceid; \
247 regs->iaoq[0] = pc; \
248 regs->iaoq[1] = pc + 4; \
249 regs->sr[2] = LINUX_GATEWAY_SPACE; \
250 regs->sr[3] = 0xffff; \
251 regs->sr[4] = spaceid; \
252 regs->sr[5] = spaceid; \
253 regs->sr[6] = spaceid; \
254 regs->sr[7] = spaceid; \
255 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
256 regs->fr[ 0] = 0LL; \
257 regs->fr[ 1] = 0LL; \
258 regs->fr[ 2] = 0LL; \
259 regs->fr[ 3] = 0LL; \
260 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
261 regs->gr[31] = pc; \
262 \
263 get_user(regs->gr[25], (argv - 1)); \
264 regs->gr[24] = (long) argv; \
265 regs->gr[23] = 0; \
266 } while(0)
267
268 struct mm_struct;
269
270 extern unsigned long __get_wchan(struct task_struct *p);
271
272 #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
273 #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
274
275 #define cpu_relax() barrier()
276
277 /*
278 * parisc_requires_coherency() is used to identify the combined VIPT/PIPT
279 * cached CPUs which require a guarantee of coherency (no inequivalent aliases
280 * with different data, whether clean or not) to operate
281 */
282 #ifdef CONFIG_PA8X00
283 extern int _parisc_requires_coherency;
284 #define parisc_requires_coherency() _parisc_requires_coherency
285 #else
286 #define parisc_requires_coherency() (0)
287 #endif
288
289 extern int running_on_qemu;
290 extern int parisc_narrow_firmware;
291
292 extern void __noreturn toc_intr(struct pt_regs *regs);
293 extern void toc_handler(void);
294 extern unsigned int toc_handler_size;
295 extern unsigned int toc_handler_csum;
296 extern void do_cpu_irq_mask(struct pt_regs *);
297 extern irqreturn_t timer_interrupt(int, void *);
298 extern irqreturn_t ipi_interrupt(int, void *);
299 extern void start_cpu_itimer(void);
300 extern void handle_interruption(int, struct pt_regs *);
301
302 /* called from assembly code: */
303 extern void start_parisc(void);
304 extern void smp_callin(unsigned long);
305 extern void sys_rt_sigreturn(struct pt_regs *, int);
306 extern void do_notify_resume(struct pt_regs *, long);
307 extern long do_syscall_trace_enter(struct pt_regs *);
308 extern void do_syscall_trace_exit(struct pt_regs *);
309
310 /* CPU startup and info */
311 struct seq_file;
312 extern void early_trap_init(void);
313 extern void collect_boot_cpu_data(void);
314 extern void btlb_init_per_cpu(void);
315 extern int show_cpuinfo (struct seq_file *m, void *v);
316
317 /* driver code in driver/parisc */
318 extern void processor_init(void);
319 struct parisc_device;
320 struct resource;
321 extern void sba_distributed_lmmio(struct parisc_device *, struct resource *);
322 extern void sba_directed_lmmio(struct parisc_device *, struct resource *);
323 extern void lba_set_iregs(struct parisc_device *lba, u32 ibase, u32 imask);
324 extern void ccio_cujo20_fixup(struct parisc_device *dev, u32 iovp);
325
326 #endif /* __ASSEMBLY__ */
327
328 #endif /* __ASM_PARISC_PROCESSOR_H */