wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 1 | /* |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 2 | * Copyright (C) 1994 Waldorf GMBH |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 3 | * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 4 | * Copyright (C) 1996 Paul M. Antoine |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 5 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. |
Daniel Schwierzeck | a6dae71 | 2016-01-12 21:48:26 +0100 | [diff] [blame] | 6 | * |
| 7 | * SPDX-License-Identifier: GPL-2.0 |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 8 | */ |
| 9 | #ifndef _ASM_PROCESSOR_H |
| 10 | #define _ASM_PROCESSOR_H |
| 11 | |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 12 | #include <asm/isadep.h> |
| 13 | |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 14 | #include <asm/cachectl.h> |
| 15 | #include <asm/mipsregs.h> |
| 16 | #include <asm/reg.h> |
| 17 | #include <asm/system.h> |
| 18 | |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 19 | /* |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 20 | * Return current * instruction pointer ("program counter"). |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 21 | */ |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 22 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 23 | |
| 24 | /* |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 25 | * System setup and hardware flags.. |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 26 | */ |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 27 | extern void (*cpu_wait)(void); |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 28 | |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 29 | extern unsigned int vced_count, vcei_count; |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 30 | |
| 31 | #define NUM_FPU_REGS 32 |
| 32 | |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 33 | typedef __u64 fpureg_t; |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 34 | |
| 35 | /* |
| 36 | * It would be nice to add some more fields for emulator statistics, but there |
| 37 | * are a number of fixed offsets in offset.h and elsewhere that would have to |
| 38 | * be recalculated by hand. So the additional information will be private to |
| 39 | * the FPU emulator for now. See asm-mips/fpu_emulator.h. |
| 40 | */ |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 41 | |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 42 | struct mips_fpu_struct { |
| 43 | fpureg_t fpr[NUM_FPU_REGS]; |
| 44 | unsigned int fcr31; |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 47 | #define NUM_DSP_REGS 6 |
| 48 | |
| 49 | typedef __u32 dspreg_t; |
| 50 | |
| 51 | struct mips_dsp_state { |
| 52 | dspreg_t dspr[NUM_DSP_REGS]; |
| 53 | unsigned int dspcontrol; |
| 54 | }; |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 55 | |
| 56 | typedef struct { |
| 57 | unsigned long seg; |
| 58 | } mm_segment_t; |
| 59 | |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 60 | #define ARCH_MIN_TASKALIGN 8 |
| 61 | |
| 62 | struct mips_abi; |
| 63 | |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 64 | /* |
| 65 | * If you change thread_struct remember to change the #defines below too! |
| 66 | */ |
| 67 | struct thread_struct { |
| 68 | /* Saved main processor registers. */ |
| 69 | unsigned long reg16; |
| 70 | unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23; |
| 71 | unsigned long reg29, reg30, reg31; |
| 72 | |
| 73 | /* Saved cp0 stuff. */ |
| 74 | unsigned long cp0_status; |
| 75 | |
| 76 | /* Saved fpu/fpu emulator stuff. */ |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 77 | struct mips_fpu_struct fpu; |
| 78 | #ifdef CONFIG_MIPS_MT_FPAFF |
| 79 | /* Emulated instruction count */ |
| 80 | unsigned long emulated_fp; |
| 81 | /* Saved per-thread scheduler affinity mask */ |
| 82 | cpumask_t user_cpus_allowed; |
| 83 | #endif /* CONFIG_MIPS_MT_FPAFF */ |
| 84 | |
| 85 | /* Saved state of the DSP ASE, if available. */ |
| 86 | struct mips_dsp_state dsp; |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 87 | |
| 88 | /* Other stuff associated with the thread. */ |
| 89 | unsigned long cp0_badvaddr; /* Last user fault */ |
| 90 | unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */ |
| 91 | unsigned long error_code; |
| 92 | unsigned long trap_no; |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 93 | unsigned long irix_trampoline; /* Wheee... */ |
| 94 | unsigned long irix_oldctx; |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 95 | struct mips_abi *abi; |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 98 | struct task_struct; |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 99 | |
| 100 | /* Free all resources held by a thread. */ |
| 101 | #define release_thread(thread) do { } while(0) |
| 102 | |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 103 | /* Prepare to copy thread state - unlazy all lazy status */ |
| 104 | #define prepare_to_copy(tsk) do { } while (0) |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 105 | |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 106 | #define cpu_relax() barrier() |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 107 | |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 108 | /* |
| 109 | * Return_address is a replacement for __builtin_return_address(count) |
| 110 | * which on certain architectures cannot reasonably be implemented in GCC |
| 111 | * (MIPS, Alpha) or is unuseable with -fomit-frame-pointer (i386). |
| 112 | * Note that __builtin_return_address(x>=1) is forbidden because GCC |
| 113 | * aborts compilation on some CPUs. It's simply not possible to unwind |
| 114 | * some CPU's stackframes. |
| 115 | * |
| 116 | * __builtin_return_address works only for non-leaf functions. We avoid the |
| 117 | * overhead of a function call by forcing the compiler to save the return |
| 118 | * address register on the stack. |
| 119 | */ |
| 120 | #define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);}) |
| 121 | |
Shinya Kuribayashi | c824af8 | 2008-03-25 11:43:17 +0900 | [diff] [blame] | 122 | #ifdef CONFIG_CPU_HAS_PREFETCH |
| 123 | |
| 124 | #define ARCH_HAS_PREFETCH |
| 125 | |
| 126 | static inline void prefetch(const void *addr) |
| 127 | { |
| 128 | __asm__ __volatile__( |
| 129 | " .set mips4 \n" |
| 130 | " pref %0, (%1) \n" |
| 131 | " .set mips0 \n" |
| 132 | : |
| 133 | : "i" (Pref_Load), "r" (addr)); |
| 134 | } |
| 135 | |
| 136 | #endif |
| 137 | |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 138 | #endif /* _ASM_PROCESSOR_H */ |