blob: 19bd72010661e47d2ade0ea72ce487a7c444e9ff [file] [log] [blame]
Wolfgang Denk97caf672006-03-12 02:12:27 +01001/*
2 * U-boot - processor.h
3 *
4 * Copyright (c) 2005 blackfin.uclinux.org
5 *
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
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * MA 02111-1307 USA
28 */
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
129extern int kernel_thread(int (*fn) (void *), void *arg,
130 unsigned long flags);
131
132#define copy_segments(tsk, mm) do { } while (0)
133#define release_segments(mm) do { } while (0)
134#define forget_segments() do { } while (0)
135
136/*
137 * Free current thread data structures etc..
138 */
139static inline void exit_thread(void)
140{
141}
142
143/*
144 * Return saved PC of a blocked thread.
145 */
146extern inline unsigned long thread_saved_pc(struct thread_struct *t)
147{
148 extern void scheduling_functions_start_here(void);
149 extern void scheduling_functions_end_here(void);
150 return 0;
151}
152
153unsigned long get_wchan(struct task_struct *p);
154
155#define KSTK_EIP(tsk) \
156 ({ \
157 unsigned long eip = 0; \
158 if ((tsk)->thread.esp0 > PAGE_SIZE && \
159 MAP_NR((tsk)->thread.esp0) < max_mapnr) \
160 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
161 eip; })
162#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
163#define THREAD_SIZE (2*PAGE_SIZE)
164
165/* Allocation and freeing of basic task resources. */
166#define alloc_task_struct() \
167 ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
168#define free_task_struct(p) free_pages((unsigned long)(p),1)
169#define get_task_struct(tsk) atomic_inc(&mem_map[MAP_NR(tsk)].count)
170
171#define init_task (init_task_union.task)
172#define init_stack (init_task_union.stack)
173
174#endif