2 * include/asm-cris/processor.h
4 * Copyright (C) 2000, 2001 Axis Communications AB
6 * Authors: Bjorn Wesen Initial version
10 #ifndef __ASM_CRIS_PROCESSOR_H
11 #define __ASM_CRIS_PROCESSOR_H
13 #include <linux/config.h>
14 #include <asm/system.h>
15 #include <asm/ptrace.h>
18 * Default implementation of macro that returns current
19 * instruction pointer ("program counter").
21 #define current_text_addr() ({void *pc; __asm__ ("move.d pc,%0" : "=rm" (pc)); pc; })
23 /* CRIS has no problems with write protection */
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.
32 #ifdef CONFIG_CRIS_LOW_MAP
33 #define TASK_SIZE (0x50000000UL) /* 1.25 GB */
35 #define TASK_SIZE (0xB0000000UL) /* 2.75 GB */
38 /* This decides where the kernel will search for a free chunk of vm
39 * space during mmap's.
41 #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
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
48 #define THREAD_SIZE PAGE_SIZE
49 #define KERNEL_STACK_SIZE PAGE_SIZE
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!!!
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 */
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.
72 #define user_regs(task) (((struct pt_regs *)((unsigned long)(task) + THREAD_SIZE)) - 1)
75 * Dito but for the currently running task
78 #define current_regs() user_regs(current)
80 #define INIT_THREAD { \
81 0, 0, 0x20 } /* ccr = int enable, nothing else */
83 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
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
90 #define start_thread(regs, ip, usp) do { \
93 regs->dccr |= 1 << U_DCCR_BITNR; \
97 unsigned long get_wchan(struct task_struct *p);
99 #define KSTK_EIP(tsk) \
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; \
108 #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
110 #define copy_segments(tsk, mm) do { } while (0)
111 #define release_segments(mm) do { } while (0)
112 #define forget_segments() do { } while (0)
115 * Free current thread data structures etc..
118 static inline void exit_thread(void)
120 /* Nothing needs to be done. */
123 /* Free all resources held by a thread. */
124 static inline void release_thread(struct task_struct *dead_task)
126 /* Nothing needs to be done. */
130 * Return saved PC of a blocked thread.
132 extern inline unsigned long thread_saved_pc(struct thread_struct *t)
134 return (unsigned long)user_regs(t)->irp;
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)
141 #define init_task (init_task_union.task)
142 #define init_stack (init_task_union.stack)
144 #define cpu_relax() do { } while (0)
146 #endif /* __ASM_CRIS_PROCESSOR_H */