| 1 |
1276 |
phoenix |
/*
|
| 2 |
|
|
* include/asm-or32/processor.h
|
| 3 |
|
|
*
|
| 4 |
|
|
* Based on:
|
| 5 |
|
|
* include/asm-cris/processor.h
|
| 6 |
|
|
* Copyright (C) 2000, 2001, 2002 Axis Communications AB
|
| 7 |
|
|
*
|
| 8 |
|
|
*/
|
| 9 |
|
|
|
| 10 |
|
|
#ifndef _OR32_PROCESSOR_H
|
| 11 |
|
|
#define _OR32_PROCESSOR_H
|
| 12 |
|
|
|
| 13 |
|
|
#include <linux/config.h>
|
| 14 |
|
|
#include <asm/spr_defs.h>
|
| 15 |
|
|
#include <asm/ptrace.h>
|
| 16 |
|
|
|
| 17 |
|
|
/* Kernel and user SR register setting */
|
| 18 |
|
|
#define KERNEL_SR (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE | SPR_SR_DCE | SPR_SR_SM)
|
| 19 |
|
|
#define USER_SR (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE | SPR_SR_DCE | SPR_SR_IEE | SPR_SR_TEE)
|
| 20 |
|
|
/*
|
| 21 |
|
|
* Default implementation of macro that returns current
|
| 22 |
|
|
* instruction pointer ("program counter").
|
| 23 |
|
|
*/
|
| 24 |
|
|
#define current_text_addr() ({ __label__ _l; _l: &&_l;})
|
| 25 |
|
|
|
| 26 |
|
|
/* or32has no problems with write protection */
|
| 27 |
|
|
|
| 28 |
|
|
#define wp_works_ok 1
|
| 29 |
|
|
|
| 30 |
|
|
/*
|
| 31 |
|
|
* User space process size. This is hardcoded into a few places,
|
| 32 |
|
|
* so don't change it unless you know what you are doing.
|
| 33 |
|
|
*/
|
| 34 |
|
|
|
| 35 |
|
|
#define TASK_SIZE (0x80000000UL)
|
| 36 |
|
|
|
| 37 |
|
|
/* This decides where the kernel will search for a free chunk of vm
|
| 38 |
|
|
* space during mmap's.
|
| 39 |
|
|
*/
|
| 40 |
|
|
#define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
|
| 41 |
|
|
|
| 42 |
|
|
/* THREAD_SIZE is the size of the task_struct/kernel_stack combo.
|
| 43 |
|
|
* normally, the stack is found by doing something like p + THREAD_SIZE
|
| 44 |
|
|
* in or32, a page is 8192 bytes, which seems like a sane size
|
| 45 |
|
|
*/
|
| 46 |
|
|
|
| 47 |
|
|
#define THREAD_SIZE PAGE_SIZE
|
| 48 |
|
|
|
| 49 |
|
|
#ifndef __ASSEMBLY__
|
| 50 |
|
|
|
| 51 |
|
|
struct task_struct;
|
| 52 |
|
|
|
| 53 |
|
|
typedef struct {
|
| 54 |
|
|
unsigned long seg;
|
| 55 |
|
|
} mm_segment_t;
|
| 56 |
|
|
|
| 57 |
|
|
struct thread_struct {
|
| 58 |
|
|
unsigned long usp; /* user space pointer */
|
| 59 |
|
|
unsigned long ksp; /* kernel stack pointer */
|
| 60 |
|
|
struct pt_regs *regs; /* pointer to saved register state */
|
| 61 |
|
|
mm_segment_t fs; /* for get_fs() validation */
|
| 62 |
|
|
signed long last_syscall;
|
| 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 occuring 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 |
|
|
#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_SP (sizeof(init_stack) + (unsigned long) &init_stack)
|
| 81 |
|
|
|
| 82 |
|
|
#define INIT_THREAD { \
|
| 83 |
|
|
0, INIT_SP, NULL, KERNEL_DS, 0 }
|
| 84 |
|
|
|
| 85 |
|
|
extern int arch_kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
|
| 86 |
|
|
|
| 87 |
|
|
void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
|
| 88 |
|
|
void release_thread(struct task_struct *);
|
| 89 |
|
|
unsigned long get_wchan(struct task_struct *p);
|
| 90 |
|
|
|
| 91 |
|
|
/*
|
| 92 |
|
|
* Return saved PC of a blocked thread. For now, this is the "user" PC
|
| 93 |
|
|
*/
|
| 94 |
|
|
static inline unsigned long thread_saved_pc(struct thread_struct *t)
|
| 95 |
|
|
{
|
| 96 |
|
|
return (t->regs) ? t->regs->pc : 0;
|
| 97 |
|
|
}
|
| 98 |
|
|
|
| 99 |
|
|
#define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->pc: 0)
|
| 100 |
|
|
#define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->sp: 0)
|
| 101 |
|
|
|
| 102 |
|
|
#define copy_segments(tsk, mm) do { } while (0)
|
| 103 |
|
|
#define release_segments(mm) do { } while (0)
|
| 104 |
|
|
|
| 105 |
|
|
#define alloc_task_struct() \
|
| 106 |
|
|
((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
|
| 107 |
|
|
#define free_task_struct(p) free_pages((unsigned long)(p),1)
|
| 108 |
|
|
#define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)
|
| 109 |
|
|
|
| 110 |
|
|
#define init_task (init_task_union.task)
|
| 111 |
|
|
#define init_stack (init_task_union.stack)
|
| 112 |
|
|
|
| 113 |
|
|
#define cpu_relax() do { } while (0)
|
| 114 |
|
|
|
| 115 |
|
|
#endif /* __ASSEMBLY__ */
|
| 116 |
|
|
#endif /* _OR32_PROCESSOR_H */
|