more debug output
[linux-2.4.git] / include / asm-cris / processor.h
1 /*
2  * include/asm-cris/processor.h
3  *
4  * Copyright (C) 2000, 2001, 2002 Axis Communications AB
5  *
6  * Authors:         Bjorn Wesen        Initial version
7  *
8  */
9
10 #ifndef __ASM_CRIS_PROCESSOR_H
11 #define __ASM_CRIS_PROCESSOR_H
12
13 #include <linux/config.h>
14 #include <asm/system.h>
15 #include <asm/page.h>
16 #include <asm/ptrace.h>
17
18 /*
19  * Default implementation of macro that returns current
20  * instruction pointer ("program counter").
21  */
22 #define current_text_addr() ({void *pc; __asm__ ("move.d $pc,%0" : "=rm" (pc)); pc; })
23
24 /* CRIS has no problems with write protection */
25
26 #define wp_works_ok 1
27
28 /*
29  * User space process size. This is hardcoded into a few places,
30  * so don't change it unless you know what you are doing.
31  */
32
33 #ifdef CONFIG_CRIS_LOW_MAP
34 #define TASK_SIZE       (0x50000000UL)   /* 1.25 GB */
35 #else
36 #define TASK_SIZE       (0xA0000000UL)   /* 2.56 GB */
37 #endif
38
39 /* This decides where the kernel will search for a free chunk of vm
40  * space during mmap's.
41  */
42 #define TASK_UNMAPPED_BASE      (TASK_SIZE / 3)
43
44 /* THREAD_SIZE is the size of the task_struct/kernel_stack combo.
45  * normally, the stack is found by doing something like p + THREAD_SIZE
46  * in CRIS, a page is 8192 bytes, which seems like a sane size
47  */
48
49 #define THREAD_SIZE       PAGE_SIZE
50 #define KERNEL_STACK_SIZE PAGE_SIZE
51
52 /* CRIS thread_struct. this really has nothing to do with the processor itself, since
53  * CRIS does not do any hardware task-switching, but it's here for legacy reasons.
54  * The thread_struct here is used when task-switching using _resume defined in entry.S.
55  * The offsets here are hardcoded into _resume - if you change this struct, you need to
56  * change them as well!!!
57 */
58
59 struct thread_struct {
60         unsigned long ksp;     /* kernel stack pointer */
61         unsigned long usp;     /* user stack pointer */
62         unsigned long dccr;    /* saved flag register */
63 };
64
65 /*
66  * At user->kernel entry, the pt_regs struct is stacked on the top of the kernel-stack.
67  * This macro allows us to find those regs for a task.
68  * Notice that subsequent pt_regs stackings, like recursive interrupts occurring while
69  * we're in the kernel, won't affect this - only the first user->kernel transition
70  * registers are reached by this.
71  */
72
73 #define user_regs(task) (((struct pt_regs *)((unsigned long)(task) + THREAD_SIZE)) - 1)
74
75 /*
76  * Dito but for the currently running task
77  */
78
79 #define current_regs() user_regs(current)
80
81 #define INIT_THREAD  { \
82    0, 0, 0x20 }  /* ccr = int enable, nothing else */
83
84 extern int arch_kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
85
86 /* give the thread a program location
87  * set user-mode (The 'U' flag (User mode flag) is CCR/DCCR bit 8) 
88  * switch user-stackpointer
89  */
90
91 #define start_thread(regs, ip, usp) do { \
92         set_fs(USER_DS);      \
93         regs->irp = ip;       \
94         regs->dccr |= 1 << U_DCCR_BITNR; \
95         wrusp(usp);           \
96 } while(0)
97
98 unsigned long get_wchan(struct task_struct *p);
99
100 #define KSTK_EIP(tsk)   \
101     ({                  \
102         unsigned long eip = 0;   \
103         unsigned long regs = (unsigned long)user_regs(tsk); \
104         if (regs > PAGE_SIZE && \
105             VALID_PAGE(virt_to_page(regs))) \
106               eip = ((struct pt_regs *)regs)->irp; \
107         eip; })
108
109 #define KSTK_ESP(tsk)   ((tsk) == current ? rdusp() : (tsk)->thread.usp)
110
111 #define copy_segments(tsk, mm)          do { } while (0)
112 #define release_segments(mm)            do { } while (0)
113 #define forget_segments()               do { } while (0)
114  
115 /*
116  * Free current thread data structures etc..
117  */
118
119 extern inline void exit_thread(void)
120 {
121         /* Nothing needs to be done.  */
122 }
123
124 /* Free all resources held by a thread. */
125 extern inline void release_thread(struct task_struct *dead_task)
126 {
127         /* Nothing needs to be done.  */
128 }
129
130 /*
131  * Return saved PC of a blocked thread.
132  */
133 extern inline unsigned long thread_saved_pc(struct thread_struct *t)
134 {
135         return (unsigned long)user_regs(t)->irp;
136 }
137
138 #define alloc_task_struct()  ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
139 #define free_task_struct(p)  free_pages((unsigned long) (p), 1)
140 #define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)
141
142 #define init_task       (init_task_union.task)
143 #define init_stack      (init_task_union.stack)
144
145 #define cpu_relax()     do { } while (0)
146
147 #endif /* __ASM_CRIS_PROCESSOR_H */