ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-arm26 / processor.h
1 /*
2  *  linux/include/asm-arm26/processor.h
3  *
4  *  Copyright (C) 1995 Russell King
5  *  Copyright (C) 2003 Ian Molton
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11
12 #ifndef __ASM_ARM_PROCESSOR_H
13 #define __ASM_ARM_PROCESSOR_H
14
15 /*
16  * Default implementation of macro that returns current
17  * instruction pointer ("program counter").
18  */
19 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
20
21 #ifdef __KERNEL__
22
23 #define MCA_bus 0
24 #define MCA_bus__is_a_macro
25
26 #include <asm/atomic.h>
27 #include <asm/ptrace.h>
28 #include <linux/string.h>
29
30 #define KERNEL_STACK_SIZE 4096
31
32 typedef struct {
33         void (*put_byte)(void);               /* Special calling convention */
34         void (*get_byte)(void);               /* Special calling convention */
35         void (*put_half)(void);               /* Special calling convention */
36         void (*get_half)(void);               /* Special calling convention */
37         void (*put_word)(void);               /* Special calling convention */
38         void (*get_word)(void);               /* Special calling convention */
39         void (*put_dword)(void);              /* Special calling convention */
40         unsigned long (*copy_from_user)(void *to, const void *from, unsigned long sz);
41         unsigned long (*copy_to_user)(void *to, const void *from, unsigned long sz);
42         unsigned long (*clear_user)(void *addr, unsigned long sz);
43         unsigned long (*strncpy_from_user)(char *to, const char *from, unsigned long sz);
44         unsigned long (*strnlen_user)(const char *s, long n);
45 } uaccess_t;
46
47 extern uaccess_t uaccess_user, uaccess_kernel;
48
49 #define EXTRA_THREAD_STRUCT                     \
50         uaccess_t       *uaccess;         /* User access functions*/
51
52 #define EXTRA_THREAD_STRUCT_INIT                \
53         .uaccess        = &uaccess_kernel,
54
55 // FIXME?!!
56
57 #define start_thread(regs,pc,sp)                                        \
58 ({                                                                      \
59         unsigned long *stack = (unsigned long *)sp;                     \
60         set_fs(USER_DS);                                                \
61         memzero(regs->uregs, sizeof (regs->uregs));                     \
62         regs->ARM_pc = pc | ~0xfc000003;        /* pc */                \
63         regs->ARM_sp = sp;              /* sp */                        \
64         regs->ARM_r2 = stack[2];        /* r2 (envp) */                 \
65         regs->ARM_r1 = stack[1];        /* r1 (argv) */                 \
66         regs->ARM_r0 = stack[0];        /* r0 (argc) */                 \
67 })
68
69 #define KSTK_EIP(tsk)   (((unsigned long *)(4096+(unsigned long)(tsk)))[1020])
70 #define KSTK_ESP(tsk)   (((unsigned long *)(4096+(unsigned long)(tsk)))[1018])
71
72 struct debug_entry {
73         u32                     address;
74         u32                     insn;
75 };
76
77 struct debug_info {
78         int                     nsaved;
79         struct debug_entry      bp[2];
80 };
81
82 struct thread_struct {
83                                                         /* fault info     */
84         unsigned long                   address;
85         unsigned long                   trap_no;
86         unsigned long                   error_code;
87                                                         /* debugging      */
88         struct debug_info               debug;
89         EXTRA_THREAD_STRUCT
90 };
91
92 #define INIT_THREAD  { \
93 EXTRA_THREAD_STRUCT_INIT \
94 }
95
96 /* Forward declaration, a strange C thing */
97 struct task_struct;
98
99 /* Free all resources held by a thread. */
100 extern void release_thread(struct task_struct *);
101
102 unsigned long get_wchan(struct task_struct *p);
103
104 #define cpu_relax()                     barrier()
105
106 /* Prepare to copy thread state - unlazy all lazy status */
107 #define prepare_to_copy(tsk)    do { } while (0)
108
109 /*
110  * Create a new kernel thread
111  */
112 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
113
114 #endif
115
116 #endif /* __ASM_ARM_PROCESSOR_H */