Linux 2.6.31.6
[linux/fpc-iii.git] / arch / mn10300 / include / asm / processor.h
blobf7d4b0d285e8dddb835781ac071898ff5d34dfe9
1 /* MN10300 Processor specifics
3 * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public Licence
9 * as published by the Free Software Foundation; either version
10 * 2 of the Licence, or (at your option) any later version.
13 #ifndef _ASM_PROCESSOR_H
14 #define _ASM_PROCESSOR_H
16 #include <asm/page.h>
17 #include <asm/ptrace.h>
18 #include <asm/cpu-regs.h>
19 #include <linux/threads.h>
21 /* Forward declaration, a strange C thing */
22 struct task_struct;
23 struct mm_struct;
26 * Default implementation of macro that returns current
27 * instruction pointer ("program counter").
29 #define current_text_addr() \
30 ({ \
31 void *__pc; \
32 asm("mov pc,%0" : "=a"(__pc)); \
33 __pc; \
36 extern void show_registers(struct pt_regs *regs);
39 * CPU type and hardware bug flags. Kept separately for each CPU.
40 * Members of this structure are referenced in head.S, so think twice
41 * before touching them. [mj]
44 struct mn10300_cpuinfo {
45 int type;
46 unsigned long loops_per_sec;
47 char hard_math;
48 unsigned long *pgd_quick;
49 unsigned long *pte_quick;
50 unsigned long pgtable_cache_sz;
53 extern struct mn10300_cpuinfo boot_cpu_data;
55 #define cpu_data &boot_cpu_data
56 #define current_cpu_data boot_cpu_data
58 extern void identify_cpu(struct mn10300_cpuinfo *);
59 extern void print_cpu_info(struct mn10300_cpuinfo *);
60 extern void dodgy_tsc(void);
61 #define cpu_relax() barrier()
64 * User space process size: 1.75GB (default).
66 #define TASK_SIZE 0x70000000
69 * Where to put the userspace stack by default
71 #define STACK_TOP 0x70000000
72 #define STACK_TOP_MAX STACK_TOP
74 /* This decides where the kernel will search for a free chunk of vm
75 * space during mmap's.
77 #define TASK_UNMAPPED_BASE 0x30000000
79 typedef struct {
80 unsigned long seg;
81 } mm_segment_t;
83 struct fpu_state_struct {
84 unsigned long fs[32]; /* fpu registers */
85 unsigned long fpcr; /* fpu control register */
88 struct thread_struct {
89 struct pt_regs *uregs; /* userspace register frame */
90 unsigned long pc; /* kernel PC */
91 unsigned long sp; /* kernel SP */
92 unsigned long a3; /* kernel FP */
93 unsigned long wchan;
94 unsigned long usp;
95 struct pt_regs *__frame;
96 unsigned long fpu_flags;
97 #define THREAD_USING_FPU 0x00000001 /* T if this task is using the FPU */
98 struct fpu_state_struct fpu_state;
101 #define INIT_THREAD \
103 .uregs = init_uregs, \
104 .pc = 0, \
105 .sp = 0, \
106 .a3 = 0, \
107 .wchan = 0, \
108 .__frame = NULL, \
111 #define INIT_MMAP \
112 { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, \
113 NULL, NULL }
116 * do necessary setup to start up a newly executed thread
117 * - need to discard the frame stacked by the kernel thread invoking the execve
118 * syscall (see RESTORE_ALL macro)
120 #define start_thread(regs, new_pc, new_sp) do { \
121 set_fs(USER_DS); \
122 __frame = current->thread.uregs; \
123 __frame->epsw = EPSW_nSL | EPSW_IE | EPSW_IM; \
124 __frame->pc = new_pc; \
125 __frame->sp = new_sp; \
126 } while (0)
128 /* Free all resources held by a thread. */
129 extern void release_thread(struct task_struct *);
131 /* Prepare to copy thread state - unlazy all lazy status */
132 extern void prepare_to_copy(struct task_struct *tsk);
135 * create a kernel thread without removing it from tasklists
137 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
140 * Return saved PC of a blocked thread.
142 extern unsigned long thread_saved_pc(struct task_struct *tsk);
144 unsigned long get_wchan(struct task_struct *p);
146 #define task_pt_regs(task) ((task)->thread.uregs)
147 #define KSTK_EIP(task) (task_pt_regs(task)->pc)
148 #define KSTK_ESP(task) (task_pt_regs(task)->sp)
150 #define KSTK_TOP(info) \
151 ({ \
152 (unsigned long)(info) + THREAD_SIZE; \
155 #define ARCH_HAS_PREFETCH
156 #define ARCH_HAS_PREFETCHW
158 static inline void prefetch(const void *x)
160 #ifndef CONFIG_MN10300_CACHE_DISABLED
161 #ifdef CONFIG_MN10300_PROC_MN103E010
162 asm volatile ("nop; nop; dcpf (%0)" : : "r"(x));
163 #else
164 asm volatile ("dcpf (%0)" : : "r"(x));
165 #endif
166 #endif
169 static inline void prefetchw(const void *x)
171 #ifndef CONFIG_MN10300_CACHE_DISABLED
172 #ifdef CONFIG_MN10300_PROC_MN103E010
173 asm volatile ("nop; nop; dcpf (%0)" : : "r"(x));
174 #else
175 asm volatile ("dcpf (%0)" : : "r"(x));
176 #endif
177 #endif
180 #endif /* _ASM_PROCESSOR_H */