sh: allow alignment fault mode to be configured at kernel boot.
[linux-2.6-block.git] / arch / sh / include / asm / processor_32.h
CommitLineData
af3c7dfe
PM
1/*
2 * include/asm-sh/processor.h
3 *
4 * Copyright (C) 1999, 2000 Niibe Yutaka
5 * Copyright (C) 2002, 2003 Paul Mundt
6 */
7
8#ifndef __ASM_SH_PROCESSOR_32_H
9#define __ASM_SH_PROCESSOR_32_H
10#ifdef __KERNEL__
11
12#include <linux/compiler.h>
fa43972f 13#include <linux/linkage.h>
af3c7dfe
PM
14#include <asm/page.h>
15#include <asm/types.h>
af3c7dfe 16#include <asm/ptrace.h>
4352fc1b 17#include <asm/hw_breakpoint.h>
af3c7dfe
PM
18
19/*
20 * Default implementation of macro that returns current
21 * instruction pointer ("program counter").
22 */
103340cc 23#define current_text_addr() ({ void *pc; __asm__("mova 1f, %0\n.align 2\n1:":"=z" (pc)); pc; })
af3c7dfe
PM
24
25/* Core Processor Version Register */
26#define CCN_PVR 0xff000030
27#define CCN_CVR 0xff000040
28#define CCN_PRR 0xff000044
29
fa43972f
PM
30asmlinkage void __init sh_cpu_init(void);
31
af3c7dfe
PM
32/*
33 * User space process size: 2GB.
34 *
35 * Since SH7709 and SH7750 have "area 7", we can't use 0x7c000000--0x7fffffff
36 */
37#define TASK_SIZE 0x7c000000UL
38
922a70d3
DH
39#define STACK_TOP TASK_SIZE
40#define STACK_TOP_MAX STACK_TOP
41
af3c7dfe
PM
42/* This decides where the kernel will search for a free chunk of vm
43 * space during mmap's.
44 */
45#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
46
47/*
48 * Bit of SR register
49 *
50 * FD-bit:
51 * When it's set, it means the processor doesn't have right to use FPU,
52 * and it results exception when the floating operation is executed.
53 *
54 * IMASK-bit:
55 * Interrupt level mask
56 */
af3c7dfe
PM
57#define SR_DSP 0x00001000
58#define SR_IMASK 0x000000f0
9bbafce2 59#define SR_FD 0x00008000
d3ea9fa0 60#define SR_MD 0x40000000
af3c7dfe 61
01ab1039
MT
62/*
63 * DSP structure and data
64 */
65struct sh_dsp_struct {
66 unsigned long dsp_regs[14];
67 long status;
68};
69
af3c7dfe
PM
70/*
71 * FPU structure and data
72 */
73
74struct sh_fpu_hard_struct {
75 unsigned long fp_regs[16];
76 unsigned long xfp_regs[16];
77 unsigned long fpscr;
78 unsigned long fpul;
79
80 long status; /* software status information */
81};
82
83/* Dummy fpu emulator */
84struct sh_fpu_soft_struct {
85 unsigned long fp_regs[16];
86 unsigned long xfp_regs[16];
87 unsigned long fpscr;
88 unsigned long fpul;
89
90 unsigned char lookahead;
91 unsigned long entry_pc;
92};
93
0ea820cf
PM
94union thread_xstate {
95 struct sh_fpu_hard_struct hardfpu;
96 struct sh_fpu_soft_struct softfpu;
af3c7dfe
PM
97};
98
99struct thread_struct {
100 /* Saved registers when thread is descheduled */
101 unsigned long sp;
102 unsigned long pc;
103
09a07294 104 /* Save middle states of ptrace breakpoints */
4352fc1b 105 struct perf_event *ptrace_bps[HBP_NUM];
01ab1039
MT
106
107#ifdef CONFIG_SH_DSP
108 /* Dsp status information */
109 struct sh_dsp_struct dsp_status;
110#endif
af3c7dfe 111
0ea820cf
PM
112 /* Extended processor state */
113 union thread_xstate *xstate;
af3c7dfe 114};
af3c7dfe
PM
115
116#define INIT_THREAD { \
117 .sp = sizeof(init_stack) + (long) &init_stack, \
118}
119
af3c7dfe
PM
120/* Forward declaration, a strange C thing */
121struct task_struct;
70e068ee
PM
122
123extern void start_thread(struct pt_regs *regs, unsigned long new_pc, unsigned long new_sp);
af3c7dfe
PM
124
125/* Free all resources held by a thread. */
126extern void release_thread(struct task_struct *);
127
128/* Prepare to copy thread state - unlazy all lazy status */
d3ea9fa0 129void prepare_to_copy(struct task_struct *tsk);
af3c7dfe
PM
130
131/*
132 * create a kernel thread without removing it from tasklists
133 */
134extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
135
136/* Copy and release all segment info associated with a VM */
137#define copy_segments(p, mm) do { } while(0)
138#define release_segments(mm) do { } while(0)
139
140/*
141 * FPU lazy state save handling.
142 */
143
144static __inline__ void disable_fpu(void)
145{
146 unsigned long __dummy;
147
148 /* Set FD flag in SR */
149 __asm__ __volatile__("stc sr, %0\n\t"
150 "or %1, %0\n\t"
151 "ldc %0, sr"
152 : "=&r" (__dummy)
153 : "r" (SR_FD));
154}
155
156static __inline__ void enable_fpu(void)
157{
158 unsigned long __dummy;
159
160 /* Clear out FD flag in SR */
161 __asm__ __volatile__("stc sr, %0\n\t"
162 "and %1, %0\n\t"
163 "ldc %0, sr"
164 : "=&r" (__dummy)
165 : "r" (~SR_FD));
166}
167
af3c7dfe
PM
168/* Double presision, NANS as NANS, rounding to nearest, no exceptions */
169#define FPSCR_INIT 0x00080000
170
171#define FPSCR_CAUSE_MASK 0x0001f000 /* Cause bits */
172#define FPSCR_FLAG_MASK 0x0000007c /* Flag bits */
173
174/*
175 * Return saved PC of a blocked thread.
176 */
177#define thread_saved_pc(tsk) (tsk->thread.pc)
178
179void show_trace(struct task_struct *tsk, unsigned long *sp,
180 struct pt_regs *regs);
5d2685d0
PM
181
182#ifdef CONFIG_DUMP_CODE
9cfc9a9b 183void show_code(struct pt_regs *regs);
5d2685d0
PM
184#else
185static inline void show_code(struct pt_regs *regs)
186{
187}
188#endif
189
af3c7dfe
PM
190extern unsigned long get_wchan(struct task_struct *p);
191
192#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
193#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15])
194
dc66ff62 195#define user_stack_pointer(_regs) ((_regs)->regs[15])
9996b42a 196
a73090ff 197#if defined(CONFIG_CPU_SH2A) || defined(CONFIG_CPU_SH4)
af3c7dfe
PM
198#define PREFETCH_STRIDE L1_CACHE_BYTES
199#define ARCH_HAS_PREFETCH
200#define ARCH_HAS_PREFETCHW
201static inline void prefetch(void *x)
202{
203 __asm__ __volatile__ ("pref @%0\n\t" : : "r" (x) : "memory");
204}
205
206#define prefetchw(x) prefetch(x)
207#endif
208
af3c7dfe
PM
209#endif /* __KERNEL__ */
210#endif /* __ASM_SH_PROCESSOR_32_H */