File: /usr/src/linux/include/asm-cris/processor.h

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