1 /*
2  *  linux/include/asm-arm/processor.h
3  *
4  *  Copyright (C) 1995-2002 Russell King
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 
11 #ifndef __ASM_ARM_PROCESSOR_H
12 #define __ASM_ARM_PROCESSOR_H
13 
14 /*
15  * Default implementation of macro that returns current
16  * instruction pointer ("program counter").
17  */
18 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
19 
20 #define FP_SIZE 35
21 
22 struct fp_hard_struct {
23 	unsigned int save[FP_SIZE];		/* as yet undefined */
24 };
25 
26 struct fp_soft_struct {
27 	unsigned int save[FP_SIZE];		/* undefined information */
28 };
29 
30 union fp_state {
31 	struct fp_hard_struct	hard;
32 	struct fp_soft_struct	soft;
33 };
34 
35 typedef unsigned long mm_segment_t;		/* domain register	*/
36 
37 #ifdef __KERNEL__
38 
39 #define EISA_bus 0
40 #define MCA_bus 0
41 #define MCA_bus__is_a_macro
42 
43 #include <asm/atomic.h>
44 #include <asm/ptrace.h>
45 #include <asm/arch/memory.h>
46 #include <asm/proc/processor.h>
47 #include <asm/types.h>
48 
49 union debug_insn {
50 	u32	arm;
51 	u16	thumb;
52 };
53 
54 struct debug_entry {
55 	u32			address;
56 	union debug_insn	insn;
57 };
58 
59 struct debug_info {
60 	int			nsaved;
61 	struct debug_entry	bp[2];
62 };
63 
64 struct thread_struct {
65 	atomic_t			refcount;
66 							/* fault info	  */
67 	unsigned long			address;
68 	unsigned long			trap_no;
69 	unsigned long			error_code;
70 							/* floating point */
71 	union fp_state			fpstate;
72 							/* debugging	  */
73 	struct debug_info		debug;
74 							/* context info	  */
75 	struct context_save_struct	*save;
76 	EXTRA_THREAD_STRUCT
77 };
78 
79 #define INIT_THREAD  {					\
80 	refcount:	ATOMIC_INIT(1),			\
81 	EXTRA_THREAD_STRUCT_INIT			\
82 }
83 
84 /*
85  * Return saved PC of a blocked thread.
86  */
thread_saved_pc(struct thread_struct * t)87 static inline unsigned long thread_saved_pc(struct thread_struct *t)
88 {
89 	return t->save ? pc_pointer(t->save->pc) : 0;
90 }
91 
thread_saved_fp(struct thread_struct * t)92 static inline unsigned long thread_saved_fp(struct thread_struct *t)
93 {
94 	return t->save ? t->save->fp : 0;
95 }
96 
97 /* Forward declaration, a strange C thing */
98 struct task_struct;
99 
100 /* Free all resources held by a thread. */
101 extern void release_thread(struct task_struct *);
102 
103 /* Copy and release all segment info associated with a VM */
104 #define copy_segments(tsk, mm)		do { } while (0)
105 #define release_segments(mm)		do { } while (0)
106 
107 unsigned long get_wchan(struct task_struct *p);
108 
109 #define THREAD_SIZE	(8192)
110 
111 extern struct task_struct *alloc_task_struct(void);
112 extern void __free_task_struct(struct task_struct *);
113 #define get_task_struct(p)	atomic_inc(&(p)->thread.refcount)
114 #define free_task_struct(p)					\
115  do {								\
116 	if (atomic_dec_and_test(&(p)->thread.refcount))		\
117 		__free_task_struct((p));			\
118  } while (0)
119 
120 #define init_task	(init_task_union.task)
121 #define init_stack	(init_task_union.stack)
122 
123 #define cpu_relax()	barrier()
124 
125 /*
126  * Create a new kernel thread
127  */
128 extern int arch_kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
129 
130 #endif
131 
132 #endif /* __ASM_ARM_PROCESSOR_H */
133