Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: processor.h,v 1.83 2001/10/08 09:32:13 davem Exp $ |
| 2 | * include/asm-sparc/processor.h |
| 3 | * |
| 4 | * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) |
| 5 | */ |
| 6 | |
| 7 | #ifndef __ASM_SPARC_PROCESSOR_H |
| 8 | #define __ASM_SPARC_PROCESSOR_H |
| 9 | |
| 10 | /* |
| 11 | * Sparc32 implementation of macro that returns current |
| 12 | * instruction pointer ("program counter"). |
| 13 | */ |
| 14 | #define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; }) |
| 15 | |
| 16 | #include <linux/a.out.h> |
| 17 | |
| 18 | #include <asm/psr.h> |
| 19 | #include <asm/ptrace.h> |
| 20 | #include <asm/head.h> |
| 21 | #include <asm/signal.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <asm/btfixup.h> |
| 23 | #include <asm/page.h> |
| 24 | |
| 25 | /* |
| 26 | * The sparc has no problems with write protection |
| 27 | */ |
| 28 | #define wp_works_ok 1 |
| 29 | #define wp_works_ok__is_a_macro /* for versions in ksyms.c */ |
| 30 | |
| 31 | /* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too... |
| 32 | * That one page is used to protect kernel from intruders, so that |
| 33 | * we can make our access_ok test faster |
| 34 | */ |
| 35 | #define TASK_SIZE PAGE_OFFSET |
David Howells | 922a70d | 2008-02-08 04:19:26 -0800 | [diff] [blame] | 36 | #ifdef __KERNEL__ |
| 37 | #define STACK_TOP (PAGE_OFFSET - PAGE_SIZE) |
| 38 | #define STACK_TOP_MAX STACK_TOP |
| 39 | #endif /* __KERNEL__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | struct task_struct; |
| 42 | |
| 43 | #ifdef __KERNEL__ |
| 44 | struct fpq { |
| 45 | unsigned long *insn_addr; |
| 46 | unsigned long insn; |
| 47 | }; |
| 48 | #endif |
| 49 | |
| 50 | typedef struct { |
| 51 | int seg; |
| 52 | } mm_segment_t; |
| 53 | |
| 54 | /* The Sparc processor specific thread struct. */ |
| 55 | struct thread_struct { |
| 56 | struct pt_regs *kregs; |
| 57 | unsigned int _pad1; |
| 58 | |
| 59 | /* Special child fork kpsr/kwim values. */ |
| 60 | unsigned long fork_kpsr __attribute__ ((aligned (8))); |
| 61 | unsigned long fork_kwim; |
| 62 | |
| 63 | /* Floating point regs */ |
| 64 | unsigned long float_regs[32] __attribute__ ((aligned (8))); |
| 65 | unsigned long fsr; |
| 66 | unsigned long fpqdepth; |
| 67 | struct fpq fpqueue[16]; |
| 68 | unsigned long flags; |
| 69 | mm_segment_t current_ds; |
| 70 | struct exec core_exec; /* just what it says. */ |
| 71 | int new_signal; |
| 72 | }; |
| 73 | |
| 74 | #define SPARC_FLAG_KTHREAD 0x1 /* task is a kernel thread */ |
| 75 | #define SPARC_FLAG_UNALIGNED 0x2 /* is allowed to do unaligned accesses */ |
| 76 | |
| 77 | #define INIT_THREAD { \ |
| 78 | .flags = SPARC_FLAG_KTHREAD, \ |
| 79 | .current_ds = KERNEL_DS, \ |
| 80 | } |
| 81 | |
| 82 | /* Return saved PC of a blocked thread. */ |
| 83 | extern unsigned long thread_saved_pc(struct task_struct *t); |
| 84 | |
| 85 | /* Do necessary setup to start up a newly executed thread. */ |
Adrian Bunk | 3115624 | 2005-10-03 17:37:02 -0700 | [diff] [blame] | 86 | static inline void start_thread(struct pt_regs * regs, unsigned long pc, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | unsigned long sp) |
| 88 | { |
| 89 | register unsigned long zero asm("g1"); |
| 90 | |
| 91 | regs->psr = (regs->psr & (PSR_CWP)) | PSR_S; |
| 92 | regs->pc = ((pc & (~3)) - 4); |
| 93 | regs->npc = regs->pc + 4; |
| 94 | regs->y = 0; |
| 95 | zero = 0; |
| 96 | __asm__ __volatile__("std\t%%g0, [%0 + %3 + 0x00]\n\t" |
| 97 | "std\t%%g0, [%0 + %3 + 0x08]\n\t" |
| 98 | "std\t%%g0, [%0 + %3 + 0x10]\n\t" |
| 99 | "std\t%%g0, [%0 + %3 + 0x18]\n\t" |
| 100 | "std\t%%g0, [%0 + %3 + 0x20]\n\t" |
| 101 | "std\t%%g0, [%0 + %3 + 0x28]\n\t" |
| 102 | "std\t%%g0, [%0 + %3 + 0x30]\n\t" |
| 103 | "st\t%1, [%0 + %3 + 0x38]\n\t" |
| 104 | "st\t%%g0, [%0 + %3 + 0x3c]" |
| 105 | : /* no outputs */ |
| 106 | : "r" (regs), |
| 107 | "r" (sp - sizeof(struct reg_window)), |
| 108 | "r" (zero), |
| 109 | "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0])) |
| 110 | : "memory"); |
| 111 | } |
| 112 | |
| 113 | /* Free all resources held by a thread. */ |
| 114 | #define release_thread(tsk) do { } while(0) |
| 115 | extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); |
| 116 | |
| 117 | /* Prepare to copy thread state - unlazy all lazy status */ |
| 118 | #define prepare_to_copy(tsk) do { } while (0) |
| 119 | |
| 120 | extern unsigned long get_wchan(struct task_struct *); |
| 121 | |
| 122 | #define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc) |
| 123 | #define KSTK_ESP(tsk) ((tsk)->thread.kregs->u_regs[UREG_FP]) |
| 124 | |
| 125 | #ifdef __KERNEL__ |
| 126 | |
| 127 | extern struct task_struct *last_task_used_math; |
| 128 | |
| 129 | #define cpu_relax() barrier() |
| 130 | |
| 131 | #endif |
| 132 | |
| 133 | #endif /* __ASM_SPARC_PROCESSOR_H */ |