Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 1 | /* include/asm/processor.h |
| 2 | * |
| 3 | * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) |
| 4 | */ |
| 5 | |
| 6 | #ifndef __ASM_SPARC_PROCESSOR_H |
| 7 | #define __ASM_SPARC_PROCESSOR_H |
| 8 | |
| 9 | /* |
| 10 | * Sparc32 implementation of macro that returns current |
| 11 | * instruction pointer ("program counter"). |
| 12 | */ |
| 13 | #define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; }) |
| 14 | |
| 15 | #include <asm/psr.h> |
| 16 | #include <asm/ptrace.h> |
| 17 | #include <asm/head.h> |
| 18 | #include <asm/signal.h> |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 19 | #include <asm/page.h> |
| 20 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 21 | /* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too... |
| 22 | * That one page is used to protect kernel from intruders, so that |
| 23 | * we can make our access_ok test faster |
| 24 | */ |
| 25 | #define TASK_SIZE PAGE_OFFSET |
| 26 | #ifdef __KERNEL__ |
| 27 | #define STACK_TOP (PAGE_OFFSET - PAGE_SIZE) |
| 28 | #define STACK_TOP_MAX STACK_TOP |
| 29 | #endif /* __KERNEL__ */ |
| 30 | |
| 31 | struct task_struct; |
| 32 | |
| 33 | #ifdef __KERNEL__ |
| 34 | struct fpq { |
| 35 | unsigned long *insn_addr; |
| 36 | unsigned long insn; |
| 37 | }; |
| 38 | #endif |
| 39 | |
| 40 | typedef struct { |
| 41 | int seg; |
| 42 | } mm_segment_t; |
| 43 | |
| 44 | /* The Sparc processor specific thread struct. */ |
| 45 | struct thread_struct { |
| 46 | struct pt_regs *kregs; |
| 47 | unsigned int _pad1; |
| 48 | |
| 49 | /* Special child fork kpsr/kwim values. */ |
| 50 | unsigned long fork_kpsr __attribute__ ((aligned (8))); |
| 51 | unsigned long fork_kwim; |
| 52 | |
| 53 | /* Floating point regs */ |
| 54 | unsigned long float_regs[32] __attribute__ ((aligned (8))); |
| 55 | unsigned long fsr; |
| 56 | unsigned long fpqdepth; |
| 57 | struct fpq fpqueue[16]; |
| 58 | unsigned long flags; |
| 59 | mm_segment_t current_ds; |
| 60 | }; |
| 61 | |
| 62 | #define SPARC_FLAG_KTHREAD 0x1 /* task is a kernel thread */ |
| 63 | #define SPARC_FLAG_UNALIGNED 0x2 /* is allowed to do unaligned accesses */ |
| 64 | |
| 65 | #define INIT_THREAD { \ |
| 66 | .flags = SPARC_FLAG_KTHREAD, \ |
| 67 | .current_ds = KERNEL_DS, \ |
| 68 | } |
| 69 | |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 70 | /* Do necessary setup to start up a newly executed thread. */ |
| 71 | static inline void start_thread(struct pt_regs * regs, unsigned long pc, |
| 72 | unsigned long sp) |
| 73 | { |
| 74 | register unsigned long zero asm("g1"); |
| 75 | |
| 76 | regs->psr = (regs->psr & (PSR_CWP)) | PSR_S; |
| 77 | regs->pc = ((pc & (~3)) - 4); |
| 78 | regs->npc = regs->pc + 4; |
| 79 | regs->y = 0; |
| 80 | zero = 0; |
| 81 | __asm__ __volatile__("std\t%%g0, [%0 + %3 + 0x00]\n\t" |
| 82 | "std\t%%g0, [%0 + %3 + 0x08]\n\t" |
| 83 | "std\t%%g0, [%0 + %3 + 0x10]\n\t" |
| 84 | "std\t%%g0, [%0 + %3 + 0x18]\n\t" |
| 85 | "std\t%%g0, [%0 + %3 + 0x20]\n\t" |
| 86 | "std\t%%g0, [%0 + %3 + 0x28]\n\t" |
| 87 | "std\t%%g0, [%0 + %3 + 0x30]\n\t" |
| 88 | "st\t%1, [%0 + %3 + 0x38]\n\t" |
| 89 | "st\t%%g0, [%0 + %3 + 0x3c]" |
| 90 | : /* no outputs */ |
| 91 | : "r" (regs), |
Sam Ravnborg | 4d7b92a | 2009-01-02 19:32:59 -0800 | [diff] [blame] | 92 | "r" (sp - sizeof(struct reg_window32)), |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 93 | "r" (zero), |
| 94 | "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0])) |
| 95 | : "memory"); |
| 96 | } |
| 97 | |
| 98 | /* Free all resources held by a thread. */ |
| 99 | #define release_thread(tsk) do { } while(0) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 100 | |
Sam Ravnborg | f05a686 | 2014-05-16 23:25:50 +0200 | [diff] [blame] | 101 | unsigned long get_wchan(struct task_struct *); |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 102 | |
David S. Miller | ebd3c00 | 2008-07-27 03:43:51 -0700 | [diff] [blame] | 103 | #define task_pt_regs(tsk) ((tsk)->thread.kregs) |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 104 | #define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc) |
| 105 | #define KSTK_ESP(tsk) ((tsk)->thread.kregs->u_regs[UREG_FP]) |
| 106 | |
| 107 | #ifdef __KERNEL__ |
| 108 | |
| 109 | extern struct task_struct *last_task_used_math; |
Sam Ravnborg | 8e9f093 | 2014-05-16 23:25:48 +0200 | [diff] [blame] | 110 | int do_mathemu(struct pt_regs *regs, struct task_struct *fpt); |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 111 | |
| 112 | #define cpu_relax() barrier() |
Davidlohr Bueso | 3a6bfbc | 2014-06-29 15:09:33 -0700 | [diff] [blame] | 113 | |
Len Brown | d472ba8 | 2013-02-09 23:27:26 -0500 | [diff] [blame] | 114 | extern void (*sparc_idle)(void); |
Sam Ravnborg | a439fe5 | 2008-07-27 23:00:59 +0200 | [diff] [blame] | 115 | |
| 116 | #endif |
| 117 | |
| 118 | #endif /* __ASM_SPARC_PROCESSOR_H */ |