summaryrefslogtreecommitdiff
path: root/include/asm-cris/processor.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@athlon.transmeta.com>2002-02-04 18:14:02 -0800
committerLinus Torvalds <torvalds@athlon.transmeta.com>2002-02-04 18:14:02 -0800
commit236e6127ad942fa9712f83a2d441e0ba7c3fc190 (patch)
treec57f86b605bcd3b1c08d28a8de945cca83e4152b /include/asm-cris/processor.h
parent7216d3e927c3b6c5d28e5ffaa54afbb34649debb (diff)
v2.4.4 -> v2.4.4.1
- Al Viro: clean up driver "invalidate_device()" mess - Andries Brouwer: make sd.c work with USB Dane-Elec CompactFlash Card Reader - me: fix nasty lazy kernel page table update problem - me: undo fork changes. Too many user-level bugs and unresolved issues. - Peter Anvin: iso9660 cleanups - Alan Cox: big merge - Johannes Erdfelt: UHCI pci DMA setup fix
Diffstat (limited to 'include/asm-cris/processor.h')
-rw-r--r--include/asm-cris/processor.h52
1 files changed, 31 insertions, 21 deletions
diff --git a/include/asm-cris/processor.h b/include/asm-cris/processor.h
index 854d1d382355..89c249f220fd 100644
--- a/include/asm-cris/processor.h
+++ b/include/asm-cris/processor.h
@@ -18,7 +18,7 @@
* Default implementation of macro that returns current
* instruction pointer ("program counter").
*/
-#define current_text_addr() ({ __label__ _l; _l: &&_l;})
+#define current_text_addr() ({void *pc; __asm__ ("move.d pc,%0" : "=rm" (pc)); pc; })
/* CRIS has no problems with write protection */
@@ -40,6 +40,14 @@
*/
#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
+/* THREAD_SIZE is the size of the task_struct/kernel_stack combo.
+ * normally, the stack is found by doing something like p + THREAD_SIZE
+ * in CRIS, a page is 8192 bytes, which seems like a sane size
+ */
+
+#define THREAD_SIZE PAGE_SIZE
+#define KERNEL_STACK_SIZE PAGE_SIZE
+
/* CRIS thread_struct. this really has nothing to do with the processor itself, since
* CRIS does not do any hardware task-switching, but it's here for legacy reasons.
* The thread_struct here is used when task-switching using _resume defined in entry.S.
@@ -50,13 +58,24 @@
struct thread_struct {
unsigned long ksp; /* kernel stack pointer */
unsigned long usp; /* user stack pointer */
- unsigned long esp0; /* points to start of saved stack frame, set in entry.S */
unsigned long dccr; /* saved flag register */
};
-/* saved stack-frame upon syscall entry, points to registers */
+/*
+ * At user->kernel entry, the pt_regs struct is stacked on the top of the kernel-stack.
+ * This macro allows us to find those regs for a task.
+ * Notice that subsequent pt_regs stackings, like recursive interrupts occuring while
+ * we're in the kernel, won't affect this - only the first user->kernel transition
+ * registers are reached by this.
+ */
-#define current_regs() (current->thread.esp0)
+#define user_regs(task) (((struct pt_regs *)((unsigned long)(task) + THREAD_SIZE)) - 1)
+
+/*
+ * Dito but for the currently running task
+ */
+
+#define current_regs() user_regs(current)
/* INIT_MMAP is the kernels map of memory, between KSEG_C and KSEG_D */
@@ -69,11 +88,7 @@ struct thread_struct {
#endif
#define INIT_THREAD { \
- 0, 0, 0, 0x20 } /* ccr = int enable, nothing else */
-
-/* TODO: REMOVE */
-#define alloc_kernel_stack() __get_free_page(GFP_KERNEL)
-#define free_kernel_stack(page) free_page((page))
+ 0, 0, 0x20 } /* ccr = int enable, nothing else */
extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
@@ -94,9 +109,10 @@ unsigned long get_wchan(struct task_struct *p);
#define KSTK_EIP(tsk) \
({ \
unsigned long eip = 0; \
- if ((tsk)->thread.esp0 > PAGE_SIZE && \
- VALID_PAGE(virt_to_page((tsk)->thread.esp0))) \
- eip = ((struct pt_regs *) (tsk)->thread.esp0)->irp; \
+ unsigned long regs = (unsigned long)user_regs(tsk); \
+ if (regs > PAGE_SIZE && \
+ VALID_PAGE(virt_to_page(regs))) \
+ eip = ((struct pt_regs *)regs)->irp; \
eip; })
#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
@@ -111,11 +127,13 @@ unsigned long get_wchan(struct task_struct *p);
static inline void exit_thread(void)
{
+ /* Nothing needs to be done. */
}
/* Free all resources held by a thread. */
static inline void release_thread(struct task_struct *dead_task)
{
+ /* Nothing needs to be done. */
}
/*
@@ -123,17 +141,9 @@ static inline void release_thread(struct task_struct *dead_task)
*/
extern inline unsigned long thread_saved_pc(struct thread_struct *t)
{
- return (unsigned long)((struct pt_regs *)t->esp0)->irp;
+ return (unsigned long)user_regs(t)->irp;
}
-/* THREAD_SIZE is the size of the task_struct/kernel_stack combo.
- * normally, the stack is found by doing something like p + THREAD_SIZE
- * in CRIS, a page is 8192 bytes, which seems like a sane size
- */
-
-#define THREAD_SIZE PAGE_SIZE
-#define KERNEL_STACK_SIZE PAGE_SIZE
-
#define alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
#define free_task_struct(p) free_pages((unsigned long) (p), 1)
#define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)