2 * include/asm-sh/processor.h
4 * Copyright (C) 1999, 2000 Niibe Yutaka
5 * Copyright (C) 2002, 2003 Paul Mundt
8 #ifndef __ASM_SH_PROCESSOR_H
9 #define __ASM_SH_PROCESSOR_H
12 #include <asm/types.h>
13 #include <asm/cache.h>
14 #include <linux/threads.h>
15 #include <asm/ptrace.h>
18 * Default implementation of macro that returns current
19 * instruction pointer ("program counter").
21 #define current_text_addr() ({ void *pc; __asm__("mova 1f, %0\n1:":"=z" (pc)); pc; })
23 /* Core Processor Version Register */
24 #define CCN_PVR 0xff000030
25 #define CCN_CVR 0xff000040
26 #define CCN_PRR 0xff000044
29 * CPU type and hardware bug flags. Kept separately for each CPU.
31 * Each one of these also needs a CONFIG_CPU_SUBTYPE_xxx entry
32 * in arch/sh/Kconfig, as well as an entry in arch/sh/kernel/setup.c
33 * for parsing the subtype in get_cpu_subtype().
40 CPU_SH7707, CPU_SH7708, CPU_SH7708S, CPU_SH7708R, CPU_SH7709,
41 CPU_SH7709A, CPU_SH7729, CPU_SH7300,
44 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
45 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501,
54 unsigned long loops_per_jiffy;
56 unsigned int cpu_clock, master_clock, bus_clock, module_clock;
57 #ifdef CONFIG_CPU_SUBTYPE_ST40STB1
58 unsigned int memory_clock;
61 struct cache_info icache;
62 struct cache_info dcache;
67 extern struct sh_cpuinfo boot_cpu_data;
70 extern struct sh_cpuinfo cpu_data[];
71 #define current_cpu_data cpu_data[smp_processor_id()]
73 #define cpu_data (&boot_cpu_data)
74 #define current_cpu_data boot_cpu_data
78 * User space process size: 2GB.
80 * Since SH7709 and SH7750 have "area 7", we can't use 0x7c000000--0x7fffffff
82 #define TASK_SIZE 0x7c000000UL
84 /* This decides where the kernel will search for a free chunk of vm
85 * space during mmap's.
87 #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
93 * When it's set, it means the processor doesn't have right to use FPU,
94 * and it results exception when the floating operation is executed.
97 * Interrupt level mask
99 #define SR_FD 0x00008000
100 #define SR_DSP 0x00001000
101 #define SR_IMASK 0x000000f0
104 * FPU structure and data
107 struct sh_fpu_hard_struct {
108 unsigned long fp_regs[16];
109 unsigned long xfp_regs[16];
113 long status; /* software status information */
116 /* Dummy fpu emulator */
117 struct sh_fpu_soft_struct {
118 unsigned long fp_regs[16];
119 unsigned long xfp_regs[16];
123 unsigned char lookahead;
124 unsigned long entry_pc;
128 struct sh_fpu_hard_struct hard;
129 struct sh_fpu_soft_struct soft;
136 #define CPU_HAS_FPU 0x0001 /* Hardware FPU support */
137 #define CPU_HAS_P2_FLUSH_BUG 0x0002 /* Need to flush the cache in P2 area */
138 #define CPU_HAS_MMU_PAGE_ASSOC 0x0004 /* SH3: TLB way selection bit support */
139 #define CPU_HAS_DSP 0x0008 /* SH-DSP: DSP support */
141 struct thread_struct {
145 unsigned long trap_no, error_code;
146 unsigned long address;
147 /* Hardware debugging registers may come here */
148 unsigned long ubc_pc;
150 /* floating point info */
151 union sh_fpu_union fpu;
154 /* Count of active tasks with UBC settings */
155 extern int ubc_usercnt;
157 #define INIT_THREAD { \
158 sizeof(init_stack) + (long) &init_stack, /* sp */ \
163 {{{0,}},} /* fpu state */ \
167 * Do necessary setup to start up a newly executed thread.
169 #define start_thread(regs, new_pc, new_sp) \
172 regs->sr = SR_FD; /* User mode. */ \
174 regs->regs[15] = new_sp
176 /* Forward declaration, a strange C thing */
180 /* Free all resources held by a thread. */
181 extern void release_thread(struct task_struct *);
183 /* Prepare to copy thread state - unlazy all lazy status */
184 #define prepare_to_copy(tsk) do { } while (0)
187 * create a kernel thread without removing it from tasklists
189 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
195 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
197 /* Copy and release all segment info associated with a VM */
198 #define copy_segments(p, mm) do { } while(0)
199 #define release_segments(mm) do { } while(0)
202 * FPU lazy state save handling.
205 static __inline__ void disable_fpu(void)
207 unsigned long __dummy;
209 /* Set FD flag in SR */
210 __asm__ __volatile__("stc sr, %0\n\t"
217 static __inline__ void enable_fpu(void)
219 unsigned long __dummy;
221 /* Clear out FD flag in SR */
222 __asm__ __volatile__("stc sr, %0\n\t"
229 static __inline__ void release_fpu(struct pt_regs *regs)
234 static __inline__ void grab_fpu(struct pt_regs *regs)
239 #ifdef CONFIG_CPU_SH4
240 extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
242 #define save_fpu(tsk) do { } while (0)
245 #define unlazy_fpu(tsk, regs) do { \
246 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
247 save_fpu(tsk, regs); \
251 #define clear_fpu(tsk, regs) do { \
252 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
253 clear_tsk_thread_flag(tsk, TIF_USEDFPU); \
258 /* Double presision, NANS as NANS, rounding to nearest, no exceptions */
259 #define FPSCR_INIT 0x00080000
261 #define FPSCR_CAUSE_MASK 0x0001f000 /* Cause bits */
262 #define FPSCR_FLAG_MASK 0x0000007c /* Flag bits */
265 * Return saved PC of a blocked thread.
267 #define thread_saved_pc(tsk) (tsk->thread.pc)
269 extern unsigned long get_wchan(struct task_struct *p);
271 #define KSTK_EIP(tsk) ((tsk)->thread.pc)
272 #define KSTK_ESP(tsk) ((tsk)->thread.sp)
274 #define cpu_relax() __asm__ __volatile__ ("sleep" : : : "memory")
276 #endif /* __ASM_SH_PROCESSOR_H */