• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  
15  #include <asm/prefetch.h>
16  #include <asm/hardware.h>
17  #include <asm/pdc.h>
18  #include <asm/ptrace.h>
19  #include <asm/types.h>
20  #include <asm/percpu.h>
21  #endif /* __ASSEMBLY__ */
22  
23  #define HAVE_ARCH_PICK_MMAP_LAYOUT
24  
25  #define TASK_SIZE_OF(tsk)       ((tsk)->thread.task_size)
26  #define TASK_SIZE	        TASK_SIZE_OF(current)
27  #define TASK_UNMAPPED_BASE      (current->thread.map_base)
28  
29  #define DEFAULT_TASK_SIZE32	(0xFFF00000UL)
30  #define DEFAULT_MAP_BASE32	(0x40000000UL)
31  
32  #ifdef CONFIG_64BIT
33  #define DEFAULT_TASK_SIZE       (MAX_ADDRESS-0xf000000)
34  #define DEFAULT_MAP_BASE        (0x200000000UL)
35  #else
36  #define DEFAULT_TASK_SIZE	DEFAULT_TASK_SIZE32
37  #define DEFAULT_MAP_BASE	DEFAULT_MAP_BASE32
38  #endif
39  
40  #ifdef __KERNEL__
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  #endif
49  
50  #ifndef __ASSEMBLY__
51  
52  unsigned long calc_max_stack_size(unsigned long stack_max);
53  
54  /*
55   * Data detected about CPUs at boot time which is the same for all CPU's.
56   * HP boxes are SMP - ie identical processors.
57   *
58   * FIXME: some CPU rev info may be processor specific...
59   */
60  struct system_cpuinfo_parisc {
61  	unsigned int	cpu_count;
62  	unsigned int	cpu_hz;
63  	unsigned int	hversion;
64  	unsigned int	sversion;
65  	enum cpu_type	cpu_type;
66  
67  	struct {
68  		struct pdc_model model;
69  		unsigned long versions;
70  		unsigned long cpuid;
71  		unsigned long capabilities;
72  		char   sys_model_name[81]; /* PDC-ROM returnes this model name */
73  	} pdc;
74  
75  	const char	*cpu_name;	/* e.g. "PA7300LC (PCX-L2)" */
76  	const char	*family_name;	/* e.g. "1.1e" */
77  };
78  
79  
80  /* Per CPU data structure - ie varies per CPU.  */
81  struct cpuinfo_parisc {
82  	unsigned long it_value;     /* Interval Timer at last timer Intr */
83  	unsigned long irq_count;    /* number of IRQ's since boot */
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
88  	unsigned long pending_ipi;  /* bitmap of type ipi_message_type */
89  #endif
90  	unsigned long bh_count;     /* number of times bh was invoked */
91  	unsigned long fp_rev;
92  	unsigned long fp_model;
93  	unsigned long cpu_num;      /* CPU number from PAT firmware */
94  	unsigned long cpu_loc;      /* CPU location from PAT firmware */
95  	unsigned int state;
96  	struct parisc_device *dev;
97  };
98  
99  extern struct system_cpuinfo_parisc boot_cpu_data;
100  DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
101  
102  #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
103  
104  #define ARCH_MIN_TASKALIGN	8
105  
106  struct thread_struct {
107  	struct pt_regs regs;
108  	unsigned long  task_size;
109  	unsigned long  map_base;
110  	unsigned long  flags;
111  };
112  
113  #define task_pt_regs(tsk) ((struct pt_regs *)&((tsk)->thread.regs))
114  
115  /* Thread struct flags. */
116  #define PARISC_UAC_NOPRINT	(1UL << 0)	/* see prctl and unaligned.c */
117  #define PARISC_UAC_SIGBUS	(1UL << 1)
118  #define PARISC_KERNEL_DEATH	(1UL << 31)	/* see die_if_kernel()... */
119  
120  #define PARISC_UAC_SHIFT	0
121  #define PARISC_UAC_MASK		(PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
122  
123  #define SET_UNALIGN_CTL(task,value)                                       \
124          ({                                                                \
125          (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
126                                  | (((value) << PARISC_UAC_SHIFT) &        \
127                                     PARISC_UAC_MASK));                     \
128          0;                                                                \
129          })
130  
131  #define GET_UNALIGN_CTL(task,addr)                                        \
132          ({                                                                \
133          put_user(((task)->thread.flags & PARISC_UAC_MASK)                 \
134                   >> PARISC_UAC_SHIFT, (int __user *) (addr));             \
135          })
136  
137  #define INIT_THREAD { \
138  	.regs = {	.gr	= { 0, }, \
139  			.fr	= { 0, }, \
140  			.sr	= { 0, }, \
141  			.iasq	= { 0, }, \
142  			.iaoq	= { 0, }, \
143  			.cr27	= 0, \
144  		}, \
145  	.task_size	= DEFAULT_TASK_SIZE, \
146  	.map_base	= DEFAULT_MAP_BASE, \
147  	.flags		= 0 \
148  	}
149  
150  struct task_struct;
151  void show_trace(struct task_struct *task, unsigned long *stack);
152  
153  /*
154   * Start user thread in another space.
155   *
156   * Note that we set both the iaoq and r31 to the new pc. When
157   * the kernel initially calls execve it will return through an
158   * rfi path that will use the values in the iaoq. The execve
159   * syscall path will return through the gateway page, and
160   * that uses r31 to branch to.
161   *
162   * For ELF we clear r23, because the dynamic linker uses it to pass
163   * the address of the finalizer function.
164   *
165   * We also initialize sr3 to an illegal value (illegal for our
166   * implementation, not for the architecture).
167   */
168  typedef unsigned int elf_caddr_t;
169  
170  /* The ELF abi wants things done a "wee bit" differently than
171   * som does.  Supporting this behavior here avoids
172   * having our own version of create_elf_tables.
173   *
174   * Oh, and yes, that is not a typo, we are really passing argc in r25
175   * and argv in r24 (rather than r26 and r25).  This is because that's
176   * where __libc_start_main wants them.
177   *
178   * Duplicated from dl-machine.h for the benefit of readers:
179   *
180   *  Our initial stack layout is rather different from everyone else's
181   *  due to the unique PA-RISC ABI.  As far as I know it looks like
182   *  this:
183  
184     -----------------------------------  (user startup code creates this frame)
185     |         32 bytes of magic       |
186     |---------------------------------|
187     | 32 bytes argument/sp save area  |
188     |---------------------------------| (bprm->p)
189     |	    ELF auxiliary info	     |
190     |         (up to 28 words)        |
191     |---------------------------------|
192     |		   NULL		     |
193     |---------------------------------|
194     |	   Environment pointers	     |
195     |---------------------------------|
196     |		   NULL		     |
197     |---------------------------------|
198     |        Argument pointers        |
199     |---------------------------------| <- argv
200     |          argc (1 word)          |
201     |---------------------------------| <- bprm->exec (HACK!)
202     |         N bytes of slack        |
203     |---------------------------------|
204     |	filename passed to execve    |
205     |---------------------------------| (mm->env_end)
206     |           env strings           |
207     |---------------------------------| (mm->env_start, mm->arg_end)
208     |           arg strings           |
209     |---------------------------------|
210     | additional faked arg strings if |
211     | we're invoked via binfmt_script |
212     |---------------------------------| (mm->arg_start)
213     stack base is at TASK_SIZE - rlim_max.
214  
215  on downward growing arches, it looks like this:
216     stack base at TASK_SIZE
217     | filename passed to execve
218     | env strings
219     | arg strings
220     | faked arg strings
221     | slack
222     | ELF
223     | envps
224     | argvs
225     | argc
226  
227   *  The pleasant part of this is that if we need to skip arguments we
228   *  can just decrement argc and move argv, because the stack pointer
229   *  is utterly unrelated to the location of the environment and
230   *  argument vectors.
231   *
232   * Note that the S/390 people took the easy way out and hacked their
233   * GCC to make the stack grow downwards.
234   *
235   * Final Note: For entry from syscall, the W (wide) bit of the PSW
236   * is stuffed into the lowest bit of the user sp (%r30), so we fill
237   * it in here from the current->personality
238   */
239  
240  #define USER_WIDE_MODE	(!is_32bit_task())
241  
242  #define start_thread(regs, new_pc, new_sp) do {		\
243  	elf_addr_t *sp = (elf_addr_t *)new_sp;		\
244  	__u32 spaceid = (__u32)current->mm->context;	\
245  	elf_addr_t pc = (elf_addr_t)new_pc | 3;		\
246  	elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1;	\
247  							\
248  	regs->iasq[0] = spaceid;			\
249  	regs->iasq[1] = spaceid;			\
250  	regs->iaoq[0] = pc;				\
251  	regs->iaoq[1] = pc + 4;                         \
252  	regs->sr[2] = LINUX_GATEWAY_SPACE;              \
253  	regs->sr[3] = 0xffff;				\
254  	regs->sr[4] = spaceid;				\
255  	regs->sr[5] = spaceid;				\
256  	regs->sr[6] = spaceid;				\
257  	regs->sr[7] = spaceid;				\
258  	regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
259  	regs->fr[ 0] = 0LL;                            	\
260  	regs->fr[ 1] = 0LL;                            	\
261  	regs->fr[ 2] = 0LL;                            	\
262  	regs->fr[ 3] = 0LL;                            	\
263  	regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
264  	regs->gr[31] = pc;				\
265  							\
266  	get_user(regs->gr[25], (argv - 1));		\
267  	regs->gr[24] = (long) argv;			\
268  	regs->gr[23] = 0;				\
269  } while(0)
270  
271  struct mm_struct;
272  
273  /* Free all resources held by a thread. */
274  extern void release_thread(struct task_struct *);
275  
276  extern unsigned long get_wchan(struct task_struct *p);
277  
278  #define KSTK_EIP(tsk)	((tsk)->thread.regs.iaoq[0])
279  #define KSTK_ESP(tsk)	((tsk)->thread.regs.gr[30])
280  
281  #define cpu_relax()	barrier()
282  
283  /*
284   * parisc_requires_coherency() is used to identify the combined VIPT/PIPT
285   * cached CPUs which require a guarantee of coherency (no inequivalent aliases
286   * with different data, whether clean or not) to operate
287   */
288  #ifdef CONFIG_PA8X00
289  extern int _parisc_requires_coherency;
290  #define parisc_requires_coherency()	_parisc_requires_coherency
291  #else
292  #define parisc_requires_coherency()	(0)
293  #endif
294  
295  extern int running_on_qemu;
296  
297  #endif /* __ASSEMBLY__ */
298  
299  #endif /* __ASM_PARISC_PROCESSOR_H */
300