1 /* SPDX-License-Identifier: GPL-2.0 */
3 * include/asm-parisc/processor.h
5 * Copyright (C) 1994 Linus Torvalds
6 * Copyright (C) 2001 Grant Grundler
9 #ifndef __ASM_PARISC_PROCESSOR_H
10 #define __ASM_PARISC_PROCESSOR_H
13 #include <linux/threads.h>
15 #include <asm/assembly.h>
16 #include <asm/prefetch.h>
17 #include <asm/hardware.h>
19 #include <asm/ptrace.h>
20 #include <asm/types.h>
21 #include <asm/percpu.h>
22 #endif /* __ASSEMBLY__ */
24 #define HAVE_ARCH_PICK_MMAP_LAYOUT
26 #define TASK_SIZE_OF(tsk) ((tsk)->thread.task_size)
27 #define TASK_SIZE TASK_SIZE_OF(current)
28 #define TASK_UNMAPPED_BASE (current->thread.map_base)
30 #define DEFAULT_TASK_SIZE32 (0xFFF00000UL)
31 #define DEFAULT_MAP_BASE32 (0x40000000UL)
34 #define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000)
35 #define DEFAULT_MAP_BASE (0x200000000UL)
37 #define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32
38 #define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32
41 /* XXX: STACK_TOP actually should be STACK_BOTTOM for parisc.
44 #define STACK_TOP TASK_SIZE
45 #define STACK_TOP_MAX DEFAULT_TASK_SIZE
49 unsigned long calc_max_stack_size(unsigned long stack_max);
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 const char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */
73 const 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 irq_count; /* number of IRQ's since boot */
81 unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */
82 unsigned long hpa; /* Host Physical address */
83 unsigned long txn_addr; /* MMIO addr of EIR or id_eid */
85 unsigned long pending_ipi; /* bitmap of type ipi_message_type */
87 unsigned long bh_count; /* number of times bh was invoked */
89 unsigned long fp_model;
90 unsigned long cpu_num; /* CPU number from PAT firmware */
91 unsigned long cpu_loc; /* CPU location from PAT firmware */
93 struct parisc_device *dev;
96 extern struct system_cpuinfo_parisc boot_cpu_data;
97 DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
98 extern int time_keeper_id; /* CPU used for timekeeping */
100 #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
102 struct thread_struct {
104 unsigned long task_size;
105 unsigned long map_base;
109 #define task_pt_regs(tsk) ((struct pt_regs *)&((tsk)->thread.regs))
111 /* Thread struct flags. */
112 #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
113 #define PARISC_UAC_SIGBUS (1UL << 1)
114 #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
116 #define PARISC_UAC_SHIFT 0
117 #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
119 #define SET_UNALIGN_CTL(task,value) \
121 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
122 | (((value) << PARISC_UAC_SHIFT) & \
127 #define GET_UNALIGN_CTL(task,addr) \
129 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
130 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
133 #define INIT_THREAD { \
134 .regs = { .gr = { 0, }, \
141 .task_size = DEFAULT_TASK_SIZE, \
142 .map_base = DEFAULT_MAP_BASE, \
147 void show_trace(struct task_struct *task, unsigned long *stack);
150 * Start user thread in another space.
152 * Note that we set both the iaoq and r31 to the new pc. When
153 * the kernel initially calls execve it will return through an
154 * rfi path that will use the values in the iaoq. The execve
155 * syscall path will return through the gateway page, and
156 * that uses r31 to branch to.
158 * For ELF we clear r23, because the dynamic linker uses it to pass
159 * the address of the finalizer function.
161 * We also initialize sr3 to an illegal value (illegal for our
162 * implementation, not for the architecture).
164 typedef unsigned int elf_caddr_t;
166 /* The ELF abi wants things done a "wee bit" differently than
167 * som does. Supporting this behavior here avoids
168 * having our own version of create_elf_tables.
170 * Oh, and yes, that is not a typo, we are really passing argc in r25
171 * and argv in r24 (rather than r26 and r25). This is because that's
172 * where __libc_start_main wants them.
174 * Duplicated from dl-machine.h for the benefit of readers:
176 * Our initial stack layout is rather different from everyone else's
177 * due to the unique PA-RISC ABI. As far as I know it looks like
180 ----------------------------------- (user startup code creates this frame)
181 | 32 bytes of magic |
182 |---------------------------------|
183 | 32 bytes argument/sp save area |
184 |---------------------------------| (bprm->p)
185 | ELF auxiliary info |
187 |---------------------------------|
189 |---------------------------------|
190 | Environment pointers |
191 |---------------------------------|
193 |---------------------------------|
194 | Argument pointers |
195 |---------------------------------| <- argv
197 |---------------------------------| <- bprm->exec (HACK!)
199 |---------------------------------|
200 | filename passed to execve |
201 |---------------------------------| (mm->env_end)
203 |---------------------------------| (mm->env_start, mm->arg_end)
205 |---------------------------------|
206 | additional faked arg strings if |
207 | we're invoked via binfmt_script |
208 |---------------------------------| (mm->arg_start)
209 stack base is at TASK_SIZE - rlim_max.
211 on downward growing arches, it looks like this:
212 stack base at TASK_SIZE
213 | filename passed to execve
223 * The pleasant part of this is that if we need to skip arguments we
224 * can just decrement argc and move argv, because the stack pointer
225 * is utterly unrelated to the location of the environment and
228 * Note that the S/390 people took the easy way out and hacked their
229 * GCC to make the stack grow downwards.
231 * Final Note: For entry from syscall, the W (wide) bit of the PSW
232 * is stuffed into the lowest bit of the user sp (%r30), so we fill
233 * it in here from the current->personality
236 #define USER_WIDE_MODE (!is_32bit_task())
238 #define start_thread(regs, new_pc, new_sp) do { \
239 elf_addr_t *sp = (elf_addr_t *)new_sp; \
240 __u32 spaceid = (__u32)current->mm->context.space_id; \
241 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
242 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
244 regs->iasq[0] = spaceid; \
245 regs->iasq[1] = spaceid; \
246 regs->iaoq[0] = pc; \
247 regs->iaoq[1] = pc + 4; \
248 regs->sr[2] = LINUX_GATEWAY_SPACE; \
249 regs->sr[3] = 0xffff; \
250 regs->sr[4] = spaceid; \
251 regs->sr[5] = spaceid; \
252 regs->sr[6] = spaceid; \
253 regs->sr[7] = spaceid; \
254 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
255 regs->fr[ 0] = 0LL; \
256 regs->fr[ 1] = 0LL; \
257 regs->fr[ 2] = 0LL; \
258 regs->fr[ 3] = 0LL; \
259 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
262 get_user(regs->gr[25], (argv - 1)); \
263 regs->gr[24] = (long) argv; \
269 extern unsigned long __get_wchan(struct task_struct *p);
271 #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
272 #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
274 #define cpu_relax() barrier()
277 * parisc_requires_coherency() is used to identify the combined VIPT/PIPT
278 * cached CPUs which require a guarantee of coherency (no inequivalent aliases
279 * with different data, whether clean or not) to operate
282 extern int _parisc_requires_coherency;
283 #define parisc_requires_coherency() _parisc_requires_coherency
285 #define parisc_requires_coherency() (0)
288 extern int running_on_qemu;
290 extern void __noreturn toc_intr(struct pt_regs *regs);
291 extern void toc_handler(void);
292 extern unsigned int toc_handler_size;
293 extern unsigned int toc_handler_csum;
295 #endif /* __ASSEMBLY__ */
297 #endif /* __ASM_PARISC_PROCESSOR_H */