blob: 6cd4f567fcd50b914bedd6594f8ede2dbe775c81 [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001/*
2 * U-boot - processor.h
3 *
Aubrey Li155fd762007-04-05 18:31:18 +08004 * Copyright (c) 2005-2007 Analog Devices Inc.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01005 *
6 * This file is based on
7 * include/asm-m68k/processor.h
8 * Changes made by Akbar Hussain Lineo, Inc, May 2001 for BLACKFIN
9 * Copyright (C) 1995 Hamish Macdonald
10 *
11 * See file CREDITS for list of people who contributed to this
12 * project.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
Aubrey Li155fd762007-04-05 18:31:18 +080026 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
27 * MA 02110-1301 USA
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010028 */
29
30#ifndef __ASM_BLACKFIN_PROCESSOR_H
31#define __ASM_BLACKFIN_PROCESSOR_H
32
33/*
34 * Default implementation of macro that returns current
35 * instruction pointer ("program counter").
36 */
37#define current_text_addr() ({ __label__ _l; _l: &&_l;})
38
39#include <linux/config.h>
40#include <asm/segment.h>
41#include <asm/ptrace.h>
42#include <asm/current.h>
43
44extern inline unsigned long rdusp(void)
45{
46 unsigned long usp;
47
48 __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp));
49 return usp;
50}
51
52extern inline void wrusp(unsigned long usp)
53{
54 __asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
55}
56
57/*
58 * User space process size: 3.75GB. This is hardcoded into a few places,
59 * so don't change it unless you know what you are doing.
60 */
61#define TASK_SIZE (0xF0000000UL)
62
63/*
64 * Bus types
65 */
66#define EISA_bus 0
67#define MCA_bus 0
68
69/* There is no pc register avaliable for BLACKFIN, so we are going to get
70 * it indirectly
71 */
72
73#if 0
74inline unsigned long obtain_pc_indirectly(void)
75{
76 unsigned long pc;
77 __asm__ __volatile__("%0 = rets;\n":"=d"(pc));
78 return (pc - 4); /* call pcrel24 is 4 bytes long */
79}
80#endif
81
82/*
83 * if you change this structure, you must change the code and offsets
84 * in m68k/machasm.S
85 */
86
87struct thread_struct {
88 unsigned long ksp; /* kernel stack pointer */
89 unsigned long usp; /* user stack pointer */
90 unsigned short seqstat; /* saved status register */
91 unsigned long esp0; /* points to SR of stack frame pt_regs */
92 unsigned long pc; /* instruction pointer */
93};
94
95#define INIT_MMAP { &init_mm, 0, 0x40000000, NULL, __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED), VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
96
97#define INIT_THREAD { \
98 sizeof(init_stack) + (unsigned long) init_stack, 0, \
99 PS_S, 0\
100}
101
102/*
103 * Do necessary setup to start up a newly executed thread.
104 *
105 * pass the data segment into user programs if it exists,
106 * it can't hurt anything as far as I can tell
107 */
108#define start_thread(_regs, _pc, _usp) \
109do { \
110 set_fs(USER_DS); /* reads from user space */ \
111 (_regs)->pc = (_pc); \
112 if (current->mm) \
113 (_regs)->r5 = current->mm->start_data; \
114 (_regs)->seqstat &= ~0x0c00; \
115 wrusp(_usp); \
116 /* Adde by HuTao, May 26, 2003 3:39PM */\
117 if ((_regs)->ipend & 0x8000) /* check whether system in supper mode - StChen */\
118 (_regs)->ipend = 0x0;\
119} while(0)
120
121/* Forward declaration, a strange C thing */
122struct task_struct;
123
124/* Free all resources held by a thread. */
125static inline void release_thread(struct task_struct *dead_task)
126{
127}
128
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800129extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100130
131#define copy_segments(tsk, mm) do { } while (0)
132#define release_segments(mm) do { } while (0)
133#define forget_segments() do { } while (0)
134
135/*
136 * Free current thread data structures etc..
137 */
138static inline void exit_thread(void)
139{
140}
141
142/*
143 * Return saved PC of a blocked thread.
144 */
145extern inline unsigned long thread_saved_pc(struct thread_struct *t)
146{
147 extern void scheduling_functions_start_here(void);
148 extern void scheduling_functions_end_here(void);
149 return 0;
150}
151
152unsigned long get_wchan(struct task_struct *p);
153
154#define KSTK_EIP(tsk) \
155 ({ \
156 unsigned long eip = 0; \
157 if ((tsk)->thread.esp0 > PAGE_SIZE && \
158 MAP_NR((tsk)->thread.esp0) < max_mapnr) \
159 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
160 eip; })
161#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
162#define THREAD_SIZE (2*PAGE_SIZE)
163
164/* Allocation and freeing of basic task resources. */
165#define alloc_task_struct() \
166 ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
167#define free_task_struct(p) free_pages((unsigned long)(p),1)
168#define get_task_struct(tsk) atomic_inc(&mem_map[MAP_NR(tsk)].count)
169
170#define init_task (init_task_union.task)
171#define init_stack (init_task_union.stack)
172
173#endif