Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/threads.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Kyle McMartin | 959f4f1 | 2006-12-14 11:12:50 -0500 | [diff] [blame] | 14 | #include <asm/prefetch.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/pdc.h> |
| 17 | #include <asm/ptrace.h> |
| 18 | #include <asm/types.h> |
| 19 | #include <asm/system.h> |
| 20 | #endif /* __ASSEMBLY__ */ |
| 21 | |
| 22 | #define KERNEL_STACK_SIZE (4*PAGE_SIZE) |
| 23 | |
| 24 | /* |
| 25 | * Default implementation of macro that returns current |
| 26 | * instruction pointer ("program counter"). |
| 27 | */ |
Kyle McMartin | 1b6d1b5 | 2006-05-19 20:18:17 +0000 | [diff] [blame] | 28 | #ifdef CONFIG_PA20 |
| 29 | #define current_ia(x) __asm__("mfia %0" : "=r"(x)) |
| 30 | #else /* mfia added in pa2.0 */ |
| 31 | #define current_ia(x) __asm__("blr 0,%0\n\tnop" : "=r"(x)) |
| 32 | #endif |
| 33 | #define current_text_addr() ({ void *pc; current_ia(pc); pc; }) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | #define TASK_SIZE (current->thread.task_size) |
| 36 | #define TASK_UNMAPPED_BASE (current->thread.map_base) |
| 37 | |
| 38 | #define DEFAULT_TASK_SIZE32 (0xFFF00000UL) |
| 39 | #define DEFAULT_MAP_BASE32 (0x40000000UL) |
| 40 | |
Helge Deller | 513e7ec | 2007-01-28 15:09:20 +0100 | [diff] [blame] | 41 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000) |
| 43 | #define DEFAULT_MAP_BASE (0x200000000UL) |
| 44 | #else |
| 45 | #define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32 |
| 46 | #define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32 |
| 47 | #endif |
| 48 | |
| 49 | #ifndef __ASSEMBLY__ |
| 50 | |
| 51 | /* |
| 52 | * Data detected about CPUs at boot time which is the same for all CPU's. |
| 53 | * HP boxes are SMP - ie identical processors. |
| 54 | * |
| 55 | * FIXME: some CPU rev info may be processor specific... |
| 56 | */ |
| 57 | struct system_cpuinfo_parisc { |
| 58 | unsigned int cpu_count; |
| 59 | unsigned int cpu_hz; |
| 60 | unsigned int hversion; |
| 61 | unsigned int sversion; |
| 62 | enum cpu_type cpu_type; |
| 63 | |
| 64 | struct { |
| 65 | struct pdc_model model; |
| 66 | unsigned long versions; |
| 67 | unsigned long cpuid; |
| 68 | unsigned long capabilities; |
| 69 | char sys_model_name[81]; /* PDC-ROM returnes this model name */ |
| 70 | } pdc; |
| 71 | |
| 72 | char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */ |
| 73 | char *family_name; /* e.g. "1.1e" */ |
| 74 | }; |
| 75 | |
| 76 | |
| 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 it_delta; /* Interval delta (tic_10ms / HZ * 100) */ |
| 81 | unsigned long irq_count; /* number of IRQ's since boot */ |
| 82 | unsigned long irq_max_cr16; /* longest time to handle a single IRQ */ |
| 83 | unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */ |
| 84 | unsigned long hpa; /* Host Physical address */ |
| 85 | unsigned long txn_addr; /* MMIO addr of EIR or id_eid */ |
| 86 | #ifdef CONFIG_SMP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | unsigned long pending_ipi; /* bitmap of type ipi_message_type */ |
| 88 | unsigned long ipi_count; /* number ipi Interrupts */ |
| 89 | #endif |
| 90 | unsigned long bh_count; /* number of times bh was invoked */ |
| 91 | unsigned long prof_counter; /* per CPU profiling support */ |
| 92 | unsigned long prof_multiplier; /* per CPU profiling support */ |
| 93 | unsigned long fp_rev; |
| 94 | unsigned long fp_model; |
| 95 | unsigned int state; |
| 96 | struct parisc_device *dev; |
| 97 | unsigned long loops_per_jiffy; |
| 98 | }; |
| 99 | |
| 100 | extern struct system_cpuinfo_parisc boot_cpu_data; |
| 101 | extern struct cpuinfo_parisc cpu_data[NR_CPUS]; |
| 102 | #define current_cpu_data cpu_data[smp_processor_id()] |
| 103 | |
| 104 | #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF) |
| 105 | |
| 106 | typedef struct { |
| 107 | int seg; |
| 108 | } mm_segment_t; |
| 109 | |
| 110 | #define ARCH_MIN_TASKALIGN 8 |
| 111 | |
| 112 | struct thread_struct { |
| 113 | struct pt_regs regs; |
| 114 | unsigned long task_size; |
| 115 | unsigned long map_base; |
| 116 | unsigned long flags; |
| 117 | }; |
| 118 | |
| 119 | /* Thread struct flags. */ |
Kyle McMartin | f053725 | 2005-10-21 22:43:15 -0400 | [diff] [blame] | 120 | #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */ |
| 121 | #define PARISC_UAC_SIGBUS (1UL << 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */ |
| 123 | |
Kyle McMartin | f053725 | 2005-10-21 22:43:15 -0400 | [diff] [blame] | 124 | #define PARISC_UAC_SHIFT 0 |
| 125 | #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS) |
| 126 | |
| 127 | #define SET_UNALIGN_CTL(task,value) \ |
| 128 | ({ \ |
| 129 | (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \ |
| 130 | | (((value) << PARISC_UAC_SHIFT) & \ |
| 131 | PARISC_UAC_MASK)); \ |
| 132 | 0; \ |
| 133 | }) |
| 134 | |
| 135 | #define GET_UNALIGN_CTL(task,addr) \ |
| 136 | ({ \ |
| 137 | put_user(((task)->thread.flags & PARISC_UAC_MASK) \ |
| 138 | >> PARISC_UAC_SHIFT, (int __user *) (addr)); \ |
| 139 | }) |
| 140 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | #define INIT_THREAD { \ |
Alexey Dobriyan | 02d7980 | 2006-01-10 20:48:02 -0500 | [diff] [blame] | 142 | .regs = { .gr = { 0, }, \ |
| 143 | .fr = { 0, }, \ |
| 144 | .sr = { 0, }, \ |
| 145 | .iasq = { 0, }, \ |
| 146 | .iaoq = { 0, }, \ |
| 147 | .cr27 = 0, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | }, \ |
Alexey Dobriyan | 02d7980 | 2006-01-10 20:48:02 -0500 | [diff] [blame] | 149 | .task_size = DEFAULT_TASK_SIZE, \ |
| 150 | .map_base = DEFAULT_MAP_BASE, \ |
| 151 | .flags = 0 \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | /* |
| 155 | * Return saved PC of a blocked thread. This is used by ps mostly. |
| 156 | */ |
| 157 | |
| 158 | unsigned long thread_saved_pc(struct task_struct *t); |
| 159 | void show_trace(struct task_struct *task, unsigned long *stack); |
| 160 | |
| 161 | /* |
| 162 | * Start user thread in another space. |
| 163 | * |
| 164 | * Note that we set both the iaoq and r31 to the new pc. When |
| 165 | * the kernel initially calls execve it will return through an |
| 166 | * rfi path that will use the values in the iaoq. The execve |
| 167 | * syscall path will return through the gateway page, and |
| 168 | * that uses r31 to branch to. |
| 169 | * |
| 170 | * For ELF we clear r23, because the dynamic linker uses it to pass |
| 171 | * the address of the finalizer function. |
| 172 | * |
| 173 | * We also initialize sr3 to an illegal value (illegal for our |
| 174 | * implementation, not for the architecture). |
| 175 | */ |
| 176 | typedef unsigned int elf_caddr_t; |
| 177 | |
| 178 | #define start_thread_som(regs, new_pc, new_sp) do { \ |
| 179 | unsigned long *sp = (unsigned long *)new_sp; \ |
| 180 | __u32 spaceid = (__u32)current->mm->context; \ |
| 181 | unsigned long pc = (unsigned long)new_pc; \ |
| 182 | /* offset pc for priv. level */ \ |
| 183 | pc |= 3; \ |
| 184 | \ |
| 185 | set_fs(USER_DS); \ |
| 186 | regs->iasq[0] = spaceid; \ |
| 187 | regs->iasq[1] = spaceid; \ |
| 188 | regs->iaoq[0] = pc; \ |
| 189 | regs->iaoq[1] = pc + 4; \ |
| 190 | regs->sr[2] = LINUX_GATEWAY_SPACE; \ |
| 191 | regs->sr[3] = 0xffff; \ |
| 192 | regs->sr[4] = spaceid; \ |
| 193 | regs->sr[5] = spaceid; \ |
| 194 | regs->sr[6] = spaceid; \ |
| 195 | regs->sr[7] = spaceid; \ |
| 196 | regs->gr[ 0] = USER_PSW; \ |
| 197 | regs->gr[30] = ((new_sp)+63)&~63; \ |
| 198 | regs->gr[31] = pc; \ |
| 199 | \ |
| 200 | get_user(regs->gr[26],&sp[0]); \ |
| 201 | get_user(regs->gr[25],&sp[-1]); \ |
| 202 | get_user(regs->gr[24],&sp[-2]); \ |
| 203 | get_user(regs->gr[23],&sp[-3]); \ |
| 204 | } while(0) |
| 205 | |
| 206 | /* The ELF abi wants things done a "wee bit" differently than |
| 207 | * som does. Supporting this behavior here avoids |
| 208 | * having our own version of create_elf_tables. |
| 209 | * |
| 210 | * Oh, and yes, that is not a typo, we are really passing argc in r25 |
| 211 | * and argv in r24 (rather than r26 and r25). This is because that's |
| 212 | * where __libc_start_main wants them. |
| 213 | * |
| 214 | * Duplicated from dl-machine.h for the benefit of readers: |
| 215 | * |
| 216 | * Our initial stack layout is rather different from everyone else's |
| 217 | * due to the unique PA-RISC ABI. As far as I know it looks like |
| 218 | * this: |
| 219 | |
| 220 | ----------------------------------- (user startup code creates this frame) |
| 221 | | 32 bytes of magic | |
| 222 | |---------------------------------| |
| 223 | | 32 bytes argument/sp save area | |
| 224 | |---------------------------------| (bprm->p) |
| 225 | | ELF auxiliary info | |
| 226 | | (up to 28 words) | |
| 227 | |---------------------------------| |
| 228 | | NULL | |
| 229 | |---------------------------------| |
| 230 | | Environment pointers | |
| 231 | |---------------------------------| |
| 232 | | NULL | |
| 233 | |---------------------------------| |
| 234 | | Argument pointers | |
| 235 | |---------------------------------| <- argv |
| 236 | | argc (1 word) | |
| 237 | |---------------------------------| <- bprm->exec (HACK!) |
| 238 | | N bytes of slack | |
| 239 | |---------------------------------| |
| 240 | | filename passed to execve | |
| 241 | |---------------------------------| (mm->env_end) |
| 242 | | env strings | |
| 243 | |---------------------------------| (mm->env_start, mm->arg_end) |
| 244 | | arg strings | |
| 245 | |---------------------------------| |
| 246 | | additional faked arg strings if | |
| 247 | | we're invoked via binfmt_script | |
| 248 | |---------------------------------| (mm->arg_start) |
| 249 | stack base is at TASK_SIZE - rlim_max. |
| 250 | |
| 251 | on downward growing arches, it looks like this: |
| 252 | stack base at TASK_SIZE |
| 253 | | filename passed to execve |
| 254 | | env strings |
| 255 | | arg strings |
| 256 | | faked arg strings |
| 257 | | slack |
| 258 | | ELF |
| 259 | | envps |
| 260 | | argvs |
| 261 | | argc |
| 262 | |
| 263 | * The pleasant part of this is that if we need to skip arguments we |
| 264 | * can just decrement argc and move argv, because the stack pointer |
| 265 | * is utterly unrelated to the location of the environment and |
| 266 | * argument vectors. |
| 267 | * |
| 268 | * Note that the S/390 people took the easy way out and hacked their |
| 269 | * GCC to make the stack grow downwards. |
| 270 | * |
| 271 | * Final Note: For entry from syscall, the W (wide) bit of the PSW |
| 272 | * is stuffed into the lowest bit of the user sp (%r30), so we fill |
| 273 | * it in here from the current->personality |
| 274 | */ |
| 275 | |
Helge Deller | 513e7ec | 2007-01-28 15:09:20 +0100 | [diff] [blame] | 276 | #ifdef CONFIG_64BIT |
Kyle McMartin | df570b9 | 2006-08-27 11:04:26 -0400 | [diff] [blame] | 277 | #define USER_WIDE_MODE (!test_thread_flag(TIF_32BIT)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | #else |
| 279 | #define USER_WIDE_MODE 0 |
| 280 | #endif |
| 281 | |
| 282 | #define start_thread(regs, new_pc, new_sp) do { \ |
| 283 | elf_addr_t *sp = (elf_addr_t *)new_sp; \ |
| 284 | __u32 spaceid = (__u32)current->mm->context; \ |
| 285 | elf_addr_t pc = (elf_addr_t)new_pc | 3; \ |
| 286 | elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \ |
| 287 | \ |
| 288 | set_fs(USER_DS); \ |
| 289 | regs->iasq[0] = spaceid; \ |
| 290 | regs->iasq[1] = spaceid; \ |
| 291 | regs->iaoq[0] = pc; \ |
| 292 | regs->iaoq[1] = pc + 4; \ |
| 293 | regs->sr[2] = LINUX_GATEWAY_SPACE; \ |
| 294 | regs->sr[3] = 0xffff; \ |
| 295 | regs->sr[4] = spaceid; \ |
| 296 | regs->sr[5] = spaceid; \ |
| 297 | regs->sr[6] = spaceid; \ |
| 298 | regs->sr[7] = spaceid; \ |
| 299 | regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \ |
| 300 | regs->fr[ 0] = 0LL; \ |
| 301 | regs->fr[ 1] = 0LL; \ |
| 302 | regs->fr[ 2] = 0LL; \ |
| 303 | regs->fr[ 3] = 0LL; \ |
| 304 | regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \ |
| 305 | regs->gr[31] = pc; \ |
| 306 | \ |
| 307 | get_user(regs->gr[25], (argv - 1)); \ |
| 308 | regs->gr[24] = (long) argv; \ |
| 309 | regs->gr[23] = 0; \ |
| 310 | } while(0) |
| 311 | |
| 312 | struct task_struct; |
| 313 | struct mm_struct; |
| 314 | |
| 315 | /* Free all resources held by a thread. */ |
| 316 | extern void release_thread(struct task_struct *); |
| 317 | extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); |
| 318 | |
| 319 | /* Prepare to copy thread state - unlazy all lazy status */ |
| 320 | #define prepare_to_copy(tsk) do { } while (0) |
| 321 | |
| 322 | extern void map_hpux_gateway_page(struct task_struct *tsk, struct mm_struct *mm); |
| 323 | |
| 324 | extern unsigned long get_wchan(struct task_struct *p); |
| 325 | |
| 326 | #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0]) |
| 327 | #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30]) |
| 328 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | #define cpu_relax() barrier() |
| 330 | |
James Bottomley | 20f4d3c | 2006-08-23 09:00:04 -0700 | [diff] [blame] | 331 | /* Used as a macro to identify the combined VIPT/PIPT cached |
| 332 | * CPUs which require a guarantee of coherency (no inequivalent |
| 333 | * aliases with different data, whether clean or not) to operate */ |
| 334 | static inline int parisc_requires_coherency(void) |
| 335 | { |
| 336 | #ifdef CONFIG_PA8X00 |
| 337 | /* FIXME: also pa8900 - when we see one */ |
| 338 | return boot_cpu_data.cpu_type == mako; |
| 339 | #else |
| 340 | return 0; |
| 341 | #endif |
| 342 | } |
| 343 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | #endif /* __ASSEMBLY__ */ |
| 345 | |
| 346 | #endif /* __ASM_PARISC_PROCESSOR_H */ |