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