at v2.6.13 11 kB view raw
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__ 12#include <linux/config.h> 13#include <linux/threads.h> 14 15#include <asm/hardware.h> 16#include <asm/page.h> 17#include <asm/pdc.h> 18#include <asm/ptrace.h> 19#include <asm/types.h> 20#include <asm/system.h> 21#endif /* __ASSEMBLY__ */ 22 23#define KERNEL_STACK_SIZE (4*PAGE_SIZE) 24 25/* 26 * Default implementation of macro that returns current 27 * instruction pointer ("program counter"). 28 */ 29 30/* We cannot use MFIA as it was added for PA2.0 - prumpf 31 32 At one point there were no "0f/0b" type local symbols in gas for 33 PA-RISC. This is no longer true, but this still seems like the 34 nicest way to implement this. */ 35 36#define current_text_addr() ({ void *pc; __asm__("\n\tblr 0,%0\n\tnop":"=r" (pc)); pc; }) 37 38#define TASK_SIZE (current->thread.task_size) 39#define TASK_UNMAPPED_BASE (current->thread.map_base) 40 41#define DEFAULT_TASK_SIZE32 (0xFFF00000UL) 42#define DEFAULT_MAP_BASE32 (0x40000000UL) 43 44#ifdef __LP64__ 45#define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000) 46#define DEFAULT_MAP_BASE (0x200000000UL) 47#else 48#define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32 49#define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32 50#endif 51 52#ifndef __ASSEMBLY__ 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 */ 60struct 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 char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */ 76 char *family_name; /* e.g. "1.1e" */ 77}; 78 79 80/* Per CPU data structure - ie varies per CPU. */ 81struct cpuinfo_parisc { 82 unsigned long it_value; /* Interval Timer at last timer Intr */ 83 unsigned long it_delta; /* Interval delta (tic_10ms / HZ * 100) */ 84 unsigned long irq_count; /* number of IRQ's since boot */ 85 unsigned long irq_max_cr16; /* longest time to handle a single IRQ */ 86 unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */ 87 unsigned long hpa; /* Host Physical address */ 88 unsigned long txn_addr; /* MMIO addr of EIR or id_eid */ 89#ifdef CONFIG_SMP 90 spinlock_t lock; /* synchronization for ipi's */ 91 unsigned long pending_ipi; /* bitmap of type ipi_message_type */ 92 unsigned long ipi_count; /* number ipi Interrupts */ 93#endif 94 unsigned long bh_count; /* number of times bh was invoked */ 95 unsigned long prof_counter; /* per CPU profiling support */ 96 unsigned long prof_multiplier; /* per CPU profiling support */ 97 unsigned long fp_rev; 98 unsigned long fp_model; 99 unsigned int state; 100 struct parisc_device *dev; 101 unsigned long loops_per_jiffy; 102}; 103 104extern struct system_cpuinfo_parisc boot_cpu_data; 105extern struct cpuinfo_parisc cpu_data[NR_CPUS]; 106#define current_cpu_data cpu_data[smp_processor_id()] 107 108#define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF) 109 110typedef struct { 111 int seg; 112} mm_segment_t; 113 114#define ARCH_MIN_TASKALIGN 8 115 116struct thread_struct { 117 struct pt_regs regs; 118 unsigned long task_size; 119 unsigned long map_base; 120 unsigned long flags; 121}; 122 123/* Thread struct flags. */ 124#define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */ 125 126#define INIT_THREAD { \ 127 regs: { gr: { 0, }, \ 128 fr: { 0, }, \ 129 sr: { 0, }, \ 130 iasq: { 0, }, \ 131 iaoq: { 0, }, \ 132 cr27: 0, \ 133 }, \ 134 task_size: DEFAULT_TASK_SIZE, \ 135 map_base: DEFAULT_MAP_BASE, \ 136 flags: 0 \ 137 } 138 139/* 140 * Return saved PC of a blocked thread. This is used by ps mostly. 141 */ 142 143unsigned long thread_saved_pc(struct task_struct *t); 144void show_trace(struct task_struct *task, unsigned long *stack); 145 146/* 147 * Start user thread in another space. 148 * 149 * Note that we set both the iaoq and r31 to the new pc. When 150 * the kernel initially calls execve it will return through an 151 * rfi path that will use the values in the iaoq. The execve 152 * syscall path will return through the gateway page, and 153 * that uses r31 to branch to. 154 * 155 * For ELF we clear r23, because the dynamic linker uses it to pass 156 * the address of the finalizer function. 157 * 158 * We also initialize sr3 to an illegal value (illegal for our 159 * implementation, not for the architecture). 160 */ 161typedef unsigned int elf_caddr_t; 162 163#define start_thread_som(regs, new_pc, new_sp) do { \ 164 unsigned long *sp = (unsigned long *)new_sp; \ 165 __u32 spaceid = (__u32)current->mm->context; \ 166 unsigned long pc = (unsigned long)new_pc; \ 167 /* offset pc for priv. level */ \ 168 pc |= 3; \ 169 \ 170 set_fs(USER_DS); \ 171 regs->iasq[0] = spaceid; \ 172 regs->iasq[1] = spaceid; \ 173 regs->iaoq[0] = pc; \ 174 regs->iaoq[1] = pc + 4; \ 175 regs->sr[2] = LINUX_GATEWAY_SPACE; \ 176 regs->sr[3] = 0xffff; \ 177 regs->sr[4] = spaceid; \ 178 regs->sr[5] = spaceid; \ 179 regs->sr[6] = spaceid; \ 180 regs->sr[7] = spaceid; \ 181 regs->gr[ 0] = USER_PSW; \ 182 regs->gr[30] = ((new_sp)+63)&~63; \ 183 regs->gr[31] = pc; \ 184 \ 185 get_user(regs->gr[26],&sp[0]); \ 186 get_user(regs->gr[25],&sp[-1]); \ 187 get_user(regs->gr[24],&sp[-2]); \ 188 get_user(regs->gr[23],&sp[-3]); \ 189} while(0) 190 191/* The ELF abi wants things done a "wee bit" differently than 192 * som does. Supporting this behavior here avoids 193 * having our own version of create_elf_tables. 194 * 195 * Oh, and yes, that is not a typo, we are really passing argc in r25 196 * and argv in r24 (rather than r26 and r25). This is because that's 197 * where __libc_start_main wants them. 198 * 199 * Duplicated from dl-machine.h for the benefit of readers: 200 * 201 * Our initial stack layout is rather different from everyone else's 202 * due to the unique PA-RISC ABI. As far as I know it looks like 203 * this: 204 205 ----------------------------------- (user startup code creates this frame) 206 | 32 bytes of magic | 207 |---------------------------------| 208 | 32 bytes argument/sp save area | 209 |---------------------------------| (bprm->p) 210 | ELF auxiliary info | 211 | (up to 28 words) | 212 |---------------------------------| 213 | NULL | 214 |---------------------------------| 215 | Environment pointers | 216 |---------------------------------| 217 | NULL | 218 |---------------------------------| 219 | Argument pointers | 220 |---------------------------------| <- argv 221 | argc (1 word) | 222 |---------------------------------| <- bprm->exec (HACK!) 223 | N bytes of slack | 224 |---------------------------------| 225 | filename passed to execve | 226 |---------------------------------| (mm->env_end) 227 | env strings | 228 |---------------------------------| (mm->env_start, mm->arg_end) 229 | arg strings | 230 |---------------------------------| 231 | additional faked arg strings if | 232 | we're invoked via binfmt_script | 233 |---------------------------------| (mm->arg_start) 234 stack base is at TASK_SIZE - rlim_max. 235 236on downward growing arches, it looks like this: 237 stack base at TASK_SIZE 238 | filename passed to execve 239 | env strings 240 | arg strings 241 | faked arg strings 242 | slack 243 | ELF 244 | envps 245 | argvs 246 | argc 247 248 * The pleasant part of this is that if we need to skip arguments we 249 * can just decrement argc and move argv, because the stack pointer 250 * is utterly unrelated to the location of the environment and 251 * argument vectors. 252 * 253 * Note that the S/390 people took the easy way out and hacked their 254 * GCC to make the stack grow downwards. 255 * 256 * Final Note: For entry from syscall, the W (wide) bit of the PSW 257 * is stuffed into the lowest bit of the user sp (%r30), so we fill 258 * it in here from the current->personality 259 */ 260 261#ifdef __LP64__ 262#define USER_WIDE_MODE (personality(current->personality) == PER_LINUX) 263#else 264#define USER_WIDE_MODE 0 265#endif 266 267#define start_thread(regs, new_pc, new_sp) do { \ 268 elf_addr_t *sp = (elf_addr_t *)new_sp; \ 269 __u32 spaceid = (__u32)current->mm->context; \ 270 elf_addr_t pc = (elf_addr_t)new_pc | 3; \ 271 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \ 272 \ 273 set_fs(USER_DS); \ 274 regs->iasq[0] = spaceid; \ 275 regs->iasq[1] = spaceid; \ 276 regs->iaoq[0] = pc; \ 277 regs->iaoq[1] = pc + 4; \ 278 regs->sr[2] = LINUX_GATEWAY_SPACE; \ 279 regs->sr[3] = 0xffff; \ 280 regs->sr[4] = spaceid; \ 281 regs->sr[5] = spaceid; \ 282 regs->sr[6] = spaceid; \ 283 regs->sr[7] = spaceid; \ 284 regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \ 285 regs->fr[ 0] = 0LL; \ 286 regs->fr[ 1] = 0LL; \ 287 regs->fr[ 2] = 0LL; \ 288 regs->fr[ 3] = 0LL; \ 289 regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \ 290 regs->gr[31] = pc; \ 291 \ 292 get_user(regs->gr[25], (argv - 1)); \ 293 regs->gr[24] = (long) argv; \ 294 regs->gr[23] = 0; \ 295} while(0) 296 297struct task_struct; 298struct mm_struct; 299 300/* Free all resources held by a thread. */ 301extern void release_thread(struct task_struct *); 302extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); 303 304/* Prepare to copy thread state - unlazy all lazy status */ 305#define prepare_to_copy(tsk) do { } while (0) 306 307extern void map_hpux_gateway_page(struct task_struct *tsk, struct mm_struct *mm); 308 309extern unsigned long get_wchan(struct task_struct *p); 310 311#define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0]) 312#define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30]) 313 314 315/* 316 * PA 2.0 defines data prefetch instructions on page 6-11 of the Kane book. 317 * In addition, many implementations do hardware prefetching of both 318 * instructions and data. 319 * 320 * PA7300LC (page 14-4 of the ERS) also implements prefetching by a load 321 * to gr0 but not in a way that Linux can use. If the load would cause an 322 * interruption (eg due to prefetching 0), it is suppressed on PA2.0 323 * processors, but not on 7300LC. 324 */ 325#ifdef CONFIG_PREFETCH 326#define ARCH_HAS_PREFETCH 327#define ARCH_HAS_PREFETCHW 328 329extern inline void prefetch(const void *addr) 330{ 331 __asm__("ldw 0(%0), %%r0" : : "r" (addr)); 332} 333 334extern inline void prefetchw(const void *addr) 335{ 336 __asm__("ldd 0(%0), %%r0" : : "r" (addr)); 337} 338#endif 339 340#define cpu_relax() barrier() 341 342#endif /* __ASSEMBLY__ */ 343 344#endif /* __ASM_PARISC_PROCESSOR_H */