blob: 02a3b167f537bd9cc454737d9a40a37a86a66685 [file] [log] [blame]
wdenk6069ff22003-02-28 00:49:47 +00001/*
wdenk6069ff22003-02-28 00:49:47 +00002 * Copyright (C) 1994 Waldorf GMBH
Shinya Kuribayashi282223a2008-03-25 11:43:17 +09003 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle
wdenk6069ff22003-02-28 00:49:47 +00004 * Copyright (C) 1996 Paul M. Antoine
Shinya Kuribayashi282223a2008-03-25 11:43:17 +09005 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
Daniel Schwierzecka3ab2ae2016-01-12 21:48:26 +01006 *
7 * SPDX-License-Identifier: GPL-2.0
wdenk6069ff22003-02-28 00:49:47 +00008 */
9#ifndef _ASM_PROCESSOR_H
10#define _ASM_PROCESSOR_H
11
wdenk6069ff22003-02-28 00:49:47 +000012#include <asm/isadep.h>
13
wdenk6069ff22003-02-28 00:49:47 +000014#include <asm/cachectl.h>
15#include <asm/mipsregs.h>
16#include <asm/reg.h>
17#include <asm/system.h>
18
Shinya Kuribayashi282223a2008-03-25 11:43:17 +090019/*
20 * Return current * instruction pointer ("program counter").
21 */
22#define current_text_addr() ({ __label__ _l; _l: &&_l;})
wdenk6069ff22003-02-28 00:49:47 +000023
24/*
25 * System setup and hardware flags..
wdenk6069ff22003-02-28 00:49:47 +000026 */
Shinya Kuribayashi282223a2008-03-25 11:43:17 +090027extern void (*cpu_wait)(void);
wdenk6069ff22003-02-28 00:49:47 +000028
wdenk6069ff22003-02-28 00:49:47 +000029extern unsigned int vced_count, vcei_count;
30
wdenk6069ff22003-02-28 00:49:47 +000031#define NUM_FPU_REGS 32
32
Shinya Kuribayashi282223a2008-03-25 11:43:17 +090033typedef __u64 fpureg_t;
wdenk6069ff22003-02-28 00:49:47 +000034
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 */
Shinya Kuribayashi282223a2008-03-25 11:43:17 +090041
42struct mips_fpu_struct {
43 fpureg_t fpr[NUM_FPU_REGS];
44 unsigned int fcr31;
wdenk6069ff22003-02-28 00:49:47 +000045};
46
Shinya Kuribayashi282223a2008-03-25 11:43:17 +090047#define NUM_DSP_REGS 6
wdenk6069ff22003-02-28 00:49:47 +000048
Shinya Kuribayashi282223a2008-03-25 11:43:17 +090049typedef __u32 dspreg_t;
50
51struct mips_dsp_state {
52 dspreg_t dspr[NUM_DSP_REGS];
53 unsigned int dspcontrol;
54};
wdenk6069ff22003-02-28 00:49:47 +000055
56typedef struct {
57 unsigned long seg;
58} mm_segment_t;
59
Shinya Kuribayashi282223a2008-03-25 11:43:17 +090060#define ARCH_MIN_TASKALIGN 8
61
62struct mips_abi;
63
wdenk6069ff22003-02-28 00:49:47 +000064/*
65 * If you change thread_struct remember to change the #defines below too!
66 */
67struct 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 Kuribayashi282223a2008-03-25 11:43:17 +090077 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;
wdenk6069ff22003-02-28 00:49:47 +000087
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;
wdenk6069ff22003-02-28 00:49:47 +000093 unsigned long irix_trampoline; /* Wheee... */
94 unsigned long irix_oldctx;
Shinya Kuribayashi282223a2008-03-25 11:43:17 +090095 struct mips_abi *abi;
wdenk6069ff22003-02-28 00:49:47 +000096};
97
Shinya Kuribayashi282223a2008-03-25 11:43:17 +090098struct task_struct;
wdenk6069ff22003-02-28 00:49:47 +000099
100/* Free all resources held by a thread. */
101#define release_thread(thread) do { } while(0)
102
Shinya Kuribayashi282223a2008-03-25 11:43:17 +0900103/* Prepare to copy thread state - unlazy all lazy status */
104#define prepare_to_copy(tsk) do { } while (0)
wdenk6069ff22003-02-28 00:49:47 +0000105
Shinya Kuribayashi282223a2008-03-25 11:43:17 +0900106#define cpu_relax() barrier()
wdenk6069ff22003-02-28 00:49:47 +0000107
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 Kuribayashi282223a2008-03-25 11:43:17 +0900122#ifdef CONFIG_CPU_HAS_PREFETCH
123
124#define ARCH_HAS_PREFETCH
125
126static 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
wdenk6069ff22003-02-28 00:49:47 +0000138#endif /* _ASM_PROCESSOR_H */