Commit | Line | Data |
---|---|---|
b920de1b DH |
1 | /* MN10300 Processor specifics |
2 | * | |
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) | |
6 | * | |
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. | |
11 | */ | |
12 | ||
13 | #ifndef _ASM_PROCESSOR_H | |
14 | #define _ASM_PROCESSOR_H | |
15 | ||
16 | #include <asm/page.h> | |
17 | #include <asm/ptrace.h> | |
18 | #include <asm/cpu-regs.h> | |
19 | #include <linux/threads.h> | |
20 | ||
21 | /* Forward declaration, a strange C thing */ | |
22 | struct task_struct; | |
23 | struct mm_struct; | |
24 | ||
25 | /* | |
26 | * Default implementation of macro that returns current | |
27 | * instruction pointer ("program counter"). | |
28 | */ | |
29 | #define current_text_addr() \ | |
30 | ({ \ | |
31 | void *__pc; \ | |
32 | asm("mov pc,%0" : "=a"(__pc)); \ | |
33 | __pc; \ | |
34 | }) | |
35 | ||
36 | extern void show_registers(struct pt_regs *regs); | |
37 | ||
38 | /* | |
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] | |
42 | */ | |
43 | ||
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; | |
51 | }; | |
52 | ||
53 | extern struct mn10300_cpuinfo boot_cpu_data; | |
54 | ||
55 | #define cpu_data &boot_cpu_data | |
56 | #define current_cpu_data boot_cpu_data | |
57 | ||
58 | extern void identify_cpu(struct mn10300_cpuinfo *); | |
59 | extern void print_cpu_info(struct mn10300_cpuinfo *); | |
60 | extern void dodgy_tsc(void); | |
148c69b4 | 61 | #define cpu_relax() barrier() |
b920de1b DH |
62 | |
63 | /* | |
64 | * User space process size: 1.75GB (default). | |
65 | */ | |
66 | #define TASK_SIZE 0x70000000 | |
67 | ||
68 | /* | |
69 | * Where to put the userspace stack by default | |
70 | */ | |
71 | #define STACK_TOP 0x70000000 | |
72 | #define STACK_TOP_MAX STACK_TOP | |
73 | ||
74 | /* This decides where the kernel will search for a free chunk of vm | |
75 | * space during mmap's. | |
76 | */ | |
77 | #define TASK_UNMAPPED_BASE 0x30000000 | |
78 | ||
79 | typedef struct { | |
80 | unsigned long seg; | |
81 | } mm_segment_t; | |
82 | ||
83 | struct fpu_state_struct { | |
84 | unsigned long fs[32]; /* fpu registers */ | |
85 | unsigned long fpcr; /* fpu control register */ | |
86 | }; | |
87 | ||
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; | |
99 | }; | |
100 | ||
101 | #define INIT_THREAD \ | |
102 | { \ | |
103 | .uregs = init_uregs, \ | |
104 | .pc = 0, \ | |
105 | .sp = 0, \ | |
106 | .a3 = 0, \ | |
107 | .wchan = 0, \ | |
108 | .__frame = NULL, \ | |
109 | } | |
110 | ||
111 | #define INIT_MMAP \ | |
112 | { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, \ | |
113 | NULL, NULL } | |
114 | ||
115 | /* | |
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) | |
119 | */ | |
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) | |
127 | ||
128 | /* Free all resources held by a thread. */ | |
129 | extern void release_thread(struct task_struct *); | |
130 | ||
131 | /* Prepare to copy thread state - unlazy all lazy status */ | |
132 | extern void prepare_to_copy(struct task_struct *tsk); | |
133 | ||
134 | /* | |
135 | * create a kernel thread without removing it from tasklists | |
136 | */ | |
137 | extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | |
138 | ||
139 | /* | |
140 | * Return saved PC of a blocked thread. | |
141 | */ | |
142 | extern unsigned long thread_saved_pc(struct task_struct *tsk); | |
143 | ||
144 | unsigned long get_wchan(struct task_struct *p); | |
145 | ||
146 | #define task_pt_regs(task) \ | |
147 | ({ \ | |
148 | struct pt_regs *__regs__; \ | |
149 | __regs__ = (struct pt_regs *) (KSTK_TOP(task_stack_page(task)) - 8); \ | |
150 | __regs__ - 1; \ | |
151 | }) | |
152 | ||
153 | #define KSTK_EIP(task) (task_pt_regs(task)->pc) | |
154 | #define KSTK_ESP(task) (task_pt_regs(task)->sp) | |
155 | ||
156 | #define KSTK_TOP(info) \ | |
157 | ({ \ | |
158 | (unsigned long)(info) + THREAD_SIZE; \ | |
159 | }) | |
160 | ||
161 | #define ARCH_HAS_PREFETCH | |
162 | #define ARCH_HAS_PREFETCHW | |
163 | ||
164 | static inline void prefetch(const void *x) | |
165 | { | |
166 | #ifndef CONFIG_MN10300_CACHE_DISABLED | |
167 | #ifdef CONFIG_MN10300_PROC_MN103E010 | |
168 | asm volatile ("nop; nop; dcpf (%0)" : : "r"(x)); | |
169 | #else | |
170 | asm volatile ("dcpf (%0)" : : "r"(x)); | |
171 | #endif | |
172 | #endif | |
173 | } | |
174 | ||
175 | static inline void prefetchw(const void *x) | |
176 | { | |
177 | #ifndef CONFIG_MN10300_CACHE_DISABLED | |
178 | #ifdef CONFIG_MN10300_PROC_MN103E010 | |
179 | asm volatile ("nop; nop; dcpf (%0)" : : "r"(x)); | |
180 | #else | |
181 | asm volatile ("dcpf (%0)" : : "r"(x)); | |
182 | #endif | |
183 | #endif | |
184 | } | |
185 | ||
186 | #endif /* _ASM_PROCESSOR_H */ |