diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-11-04 21:39:31 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-11-04 21:39:31 -0500 |
commit | c2cc87ca9561ddfe744d446789cc10f507e87db9 (patch) | |
tree | d505fc0110eb1a3d8750ba2f67648c131f0d9aca /include/asm-powerpc | |
parent | ce1eeb95fc4eb25109c00bea3e83a87eeff6b07d (diff) | |
parent | 7015faa7df829876a0f931cd18aa6d7c24a1b581 (diff) |
Merge branch 'master'
Diffstat (limited to 'include/asm-powerpc')
94 files changed, 12987 insertions, 134 deletions
diff --git a/include/asm-powerpc/a.out.h b/include/asm-powerpc/a.out.h new file mode 100644 index 000000000000..c7393a977364 --- /dev/null +++ b/include/asm-powerpc/a.out.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef _ASM_POWERPC_A_OUT_H | ||
2 | #define _ASM_POWERPC_A_OUT_H | ||
3 | |||
4 | struct exec | ||
5 | { | ||
6 | unsigned long a_info; /* Use macros N_MAGIC, etc for access */ | ||
7 | unsigned a_text; /* length of text, in bytes */ | ||
8 | unsigned a_data; /* length of data, in bytes */ | ||
9 | unsigned a_bss; /* length of uninitialized data area for file, in bytes */ | ||
10 | unsigned a_syms; /* length of symbol table data in file, in bytes */ | ||
11 | unsigned a_entry; /* start address */ | ||
12 | unsigned a_trsize; /* length of relocation info for text, in bytes */ | ||
13 | unsigned a_drsize; /* length of relocation info for data, in bytes */ | ||
14 | }; | ||
15 | |||
16 | #define N_TRSIZE(a) ((a).a_trsize) | ||
17 | #define N_DRSIZE(a) ((a).a_drsize) | ||
18 | #define N_SYMSIZE(a) ((a).a_syms) | ||
19 | |||
20 | #ifdef __KERNEL__ | ||
21 | #ifdef __powerpc64__ | ||
22 | |||
23 | #define STACK_TOP_USER64 TASK_SIZE_USER64 | ||
24 | #define STACK_TOP_USER32 TASK_SIZE_USER32 | ||
25 | |||
26 | #define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ | ||
27 | STACK_TOP_USER32 : STACK_TOP_USER64) | ||
28 | |||
29 | #else /* __powerpc64__ */ | ||
30 | |||
31 | #define STACK_TOP TASK_SIZE | ||
32 | |||
33 | #endif /* __powerpc64__ */ | ||
34 | #endif /* __KERNEL__ */ | ||
35 | |||
36 | #endif /* _ASM_POWERPC_A_OUT_H */ | ||
diff --git a/include/asm-powerpc/atomic.h b/include/asm-powerpc/atomic.h new file mode 100644 index 000000000000..ed4b345ed75d --- /dev/null +++ b/include/asm-powerpc/atomic.h | |||
@@ -0,0 +1,209 @@ | |||
1 | #ifndef _ASM_POWERPC_ATOMIC_H_ | ||
2 | #define _ASM_POWERPC_ATOMIC_H_ | ||
3 | |||
4 | /* | ||
5 | * PowerPC atomic operations | ||
6 | */ | ||
7 | |||
8 | typedef struct { volatile int counter; } atomic_t; | ||
9 | |||
10 | #ifdef __KERNEL__ | ||
11 | #include <asm/synch.h> | ||
12 | |||
13 | #define ATOMIC_INIT(i) { (i) } | ||
14 | |||
15 | #define atomic_read(v) ((v)->counter) | ||
16 | #define atomic_set(v,i) (((v)->counter) = (i)) | ||
17 | |||
18 | /* Erratum #77 on the 405 means we need a sync or dcbt before every stwcx. | ||
19 | * The old ATOMIC_SYNC_FIX covered some but not all of this. | ||
20 | */ | ||
21 | #ifdef CONFIG_IBM405_ERR77 | ||
22 | #define PPC405_ERR77(ra,rb) "dcbt " #ra "," #rb ";" | ||
23 | #else | ||
24 | #define PPC405_ERR77(ra,rb) | ||
25 | #endif | ||
26 | |||
27 | static __inline__ void atomic_add(int a, atomic_t *v) | ||
28 | { | ||
29 | int t; | ||
30 | |||
31 | __asm__ __volatile__( | ||
32 | "1: lwarx %0,0,%3 # atomic_add\n\ | ||
33 | add %0,%2,%0\n" | ||
34 | PPC405_ERR77(0,%3) | ||
35 | " stwcx. %0,0,%3 \n\ | ||
36 | bne- 1b" | ||
37 | : "=&r" (t), "=m" (v->counter) | ||
38 | : "r" (a), "r" (&v->counter), "m" (v->counter) | ||
39 | : "cc"); | ||
40 | } | ||
41 | |||
42 | static __inline__ int atomic_add_return(int a, atomic_t *v) | ||
43 | { | ||
44 | int t; | ||
45 | |||
46 | __asm__ __volatile__( | ||
47 | EIEIO_ON_SMP | ||
48 | "1: lwarx %0,0,%2 # atomic_add_return\n\ | ||
49 | add %0,%1,%0\n" | ||
50 | PPC405_ERR77(0,%2) | ||
51 | " stwcx. %0,0,%2 \n\ | ||
52 | bne- 1b" | ||
53 | ISYNC_ON_SMP | ||
54 | : "=&r" (t) | ||
55 | : "r" (a), "r" (&v->counter) | ||
56 | : "cc", "memory"); | ||
57 | |||
58 | return t; | ||
59 | } | ||
60 | |||
61 | #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0) | ||
62 | |||
63 | static __inline__ void atomic_sub(int a, atomic_t *v) | ||
64 | { | ||
65 | int t; | ||
66 | |||
67 | __asm__ __volatile__( | ||
68 | "1: lwarx %0,0,%3 # atomic_sub\n\ | ||
69 | subf %0,%2,%0\n" | ||
70 | PPC405_ERR77(0,%3) | ||
71 | " stwcx. %0,0,%3 \n\ | ||
72 | bne- 1b" | ||
73 | : "=&r" (t), "=m" (v->counter) | ||
74 | : "r" (a), "r" (&v->counter), "m" (v->counter) | ||
75 | : "cc"); | ||
76 | } | ||
77 | |||
78 | static __inline__ int atomic_sub_return(int a, atomic_t *v) | ||
79 | { | ||
80 | int t; | ||
81 | |||
82 | __asm__ __volatile__( | ||
83 | EIEIO_ON_SMP | ||
84 | "1: lwarx %0,0,%2 # atomic_sub_return\n\ | ||
85 | subf %0,%1,%0\n" | ||
86 | PPC405_ERR77(0,%2) | ||
87 | " stwcx. %0,0,%2 \n\ | ||
88 | bne- 1b" | ||
89 | ISYNC_ON_SMP | ||
90 | : "=&r" (t) | ||
91 | : "r" (a), "r" (&v->counter) | ||
92 | : "cc", "memory"); | ||
93 | |||
94 | return t; | ||
95 | } | ||
96 | |||
97 | static __inline__ void atomic_inc(atomic_t *v) | ||
98 | { | ||
99 | int t; | ||
100 | |||
101 | __asm__ __volatile__( | ||
102 | "1: lwarx %0,0,%2 # atomic_inc\n\ | ||
103 | addic %0,%0,1\n" | ||
104 | PPC405_ERR77(0,%2) | ||
105 | " stwcx. %0,0,%2 \n\ | ||
106 | bne- 1b" | ||
107 | : "=&r" (t), "=m" (v->counter) | ||
108 | : "r" (&v->counter), "m" (v->counter) | ||
109 | : "cc"); | ||
110 | } | ||
111 | |||
112 | static __inline__ int atomic_inc_return(atomic_t *v) | ||
113 | { | ||
114 | int t; | ||
115 | |||
116 | __asm__ __volatile__( | ||
117 | EIEIO_ON_SMP | ||
118 | "1: lwarx %0,0,%1 # atomic_inc_return\n\ | ||
119 | addic %0,%0,1\n" | ||
120 | PPC405_ERR77(0,%1) | ||
121 | " stwcx. %0,0,%1 \n\ | ||
122 | bne- 1b" | ||
123 | ISYNC_ON_SMP | ||
124 | : "=&r" (t) | ||
125 | : "r" (&v->counter) | ||
126 | : "cc", "memory"); | ||
127 | |||
128 | return t; | ||
129 | } | ||
130 | |||
131 | /* | ||
132 | * atomic_inc_and_test - increment and test | ||
133 | * @v: pointer of type atomic_t | ||
134 | * | ||
135 | * Atomically increments @v by 1 | ||
136 | * and returns true if the result is zero, or false for all | ||
137 | * other cases. | ||
138 | */ | ||
139 | #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) | ||
140 | |||
141 | static __inline__ void atomic_dec(atomic_t *v) | ||
142 | { | ||
143 | int t; | ||
144 | |||
145 | __asm__ __volatile__( | ||
146 | "1: lwarx %0,0,%2 # atomic_dec\n\ | ||
147 | addic %0,%0,-1\n" | ||
148 | PPC405_ERR77(0,%2)\ | ||
149 | " stwcx. %0,0,%2\n\ | ||
150 | bne- 1b" | ||
151 | : "=&r" (t), "=m" (v->counter) | ||
152 | : "r" (&v->counter), "m" (v->counter) | ||
153 | : "cc"); | ||
154 | } | ||
155 | |||
156 | static __inline__ int atomic_dec_return(atomic_t *v) | ||
157 | { | ||
158 | int t; | ||
159 | |||
160 | __asm__ __volatile__( | ||
161 | EIEIO_ON_SMP | ||
162 | "1: lwarx %0,0,%1 # atomic_dec_return\n\ | ||
163 | addic %0,%0,-1\n" | ||
164 | PPC405_ERR77(0,%1) | ||
165 | " stwcx. %0,0,%1\n\ | ||
166 | bne- 1b" | ||
167 | ISYNC_ON_SMP | ||
168 | : "=&r" (t) | ||
169 | : "r" (&v->counter) | ||
170 | : "cc", "memory"); | ||
171 | |||
172 | return t; | ||
173 | } | ||
174 | |||
175 | #define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0) | ||
176 | #define atomic_dec_and_test(v) (atomic_dec_return((v)) == 0) | ||
177 | |||
178 | /* | ||
179 | * Atomically test *v and decrement if it is greater than 0. | ||
180 | * The function returns the old value of *v minus 1. | ||
181 | */ | ||
182 | static __inline__ int atomic_dec_if_positive(atomic_t *v) | ||
183 | { | ||
184 | int t; | ||
185 | |||
186 | __asm__ __volatile__( | ||
187 | EIEIO_ON_SMP | ||
188 | "1: lwarx %0,0,%1 # atomic_dec_if_positive\n\ | ||
189 | addic. %0,%0,-1\n\ | ||
190 | blt- 2f\n" | ||
191 | PPC405_ERR77(0,%1) | ||
192 | " stwcx. %0,0,%1\n\ | ||
193 | bne- 1b" | ||
194 | ISYNC_ON_SMP | ||
195 | "\n\ | ||
196 | 2:" : "=&r" (t) | ||
197 | : "r" (&v->counter) | ||
198 | : "cc", "memory"); | ||
199 | |||
200 | return t; | ||
201 | } | ||
202 | |||
203 | #define smp_mb__before_atomic_dec() smp_mb() | ||
204 | #define smp_mb__after_atomic_dec() smp_mb() | ||
205 | #define smp_mb__before_atomic_inc() smp_mb() | ||
206 | #define smp_mb__after_atomic_inc() smp_mb() | ||
207 | |||
208 | #endif /* __KERNEL__ */ | ||
209 | #endif /* _ASM_POWERPC_ATOMIC_H_ */ | ||
diff --git a/include/asm-powerpc/auxvec.h b/include/asm-powerpc/auxvec.h new file mode 100644 index 000000000000..79d8c4732309 --- /dev/null +++ b/include/asm-powerpc/auxvec.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #ifndef _ASM_POWERPC_AUXVEC_H | ||
2 | #define _ASM_POWERPC_AUXVEC_H | ||
3 | |||
4 | /* | ||
5 | * We need to put in some extra aux table entries to tell glibc what | ||
6 | * the cache block size is, so it can use the dcbz instruction safely. | ||
7 | */ | ||
8 | #define AT_DCACHEBSIZE 19 | ||
9 | #define AT_ICACHEBSIZE 20 | ||
10 | #define AT_UCACHEBSIZE 21 | ||
11 | /* A special ignored type value for PPC, for glibc compatibility. */ | ||
12 | #define AT_IGNOREPPC 22 | ||
13 | |||
14 | /* The vDSO location. We have to use the same value as x86 for glibc's | ||
15 | * sake :-) | ||
16 | */ | ||
17 | #ifdef __powerpc64__ | ||
18 | #define AT_SYSINFO_EHDR 33 | ||
19 | #endif | ||
20 | |||
21 | #endif | ||
diff --git a/include/asm-powerpc/backlight.h b/include/asm-powerpc/backlight.h new file mode 100644 index 000000000000..1ba1f27a0b63 --- /dev/null +++ b/include/asm-powerpc/backlight.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Routines for handling backlight control on PowerBooks | ||
3 | * | ||
4 | * For now, implementation resides in | ||
5 | * arch/powerpc/platforms/powermac/pmac_support.c | ||
6 | * | ||
7 | */ | ||
8 | #ifndef __ASM_POWERPC_BACKLIGHT_H | ||
9 | #define __ASM_POWERPC_BACKLIGHT_H | ||
10 | #ifdef __KERNEL__ | ||
11 | |||
12 | /* Abstract values */ | ||
13 | #define BACKLIGHT_OFF 0 | ||
14 | #define BACKLIGHT_MIN 1 | ||
15 | #define BACKLIGHT_MAX 0xf | ||
16 | |||
17 | struct backlight_controller { | ||
18 | int (*set_enable)(int enable, int level, void *data); | ||
19 | int (*set_level)(int level, void *data); | ||
20 | }; | ||
21 | |||
22 | extern void register_backlight_controller(struct backlight_controller *ctrler, void *data, char *type); | ||
23 | extern void unregister_backlight_controller(struct backlight_controller *ctrler, void *data); | ||
24 | |||
25 | extern int set_backlight_enable(int enable); | ||
26 | extern int get_backlight_enable(void); | ||
27 | extern int set_backlight_level(int level); | ||
28 | extern int get_backlight_level(void); | ||
29 | |||
30 | #endif /* __KERNEL__ */ | ||
31 | #endif | ||
diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h new file mode 100644 index 000000000000..dc25c53704d5 --- /dev/null +++ b/include/asm-powerpc/bitops.h | |||
@@ -0,0 +1,437 @@ | |||
1 | /* | ||
2 | * PowerPC atomic bit operations. | ||
3 | * | ||
4 | * Merged version by David Gibson <david@gibson.dropbear.id.au>. | ||
5 | * Based on ppc64 versions by: Dave Engebretsen, Todd Inglett, Don | ||
6 | * Reed, Pat McCarthy, Peter Bergner, Anton Blanchard. They | ||
7 | * originally took it from the ppc32 code. | ||
8 | * | ||
9 | * Within a word, bits are numbered LSB first. Lot's of places make | ||
10 | * this assumption by directly testing bits with (val & (1<<nr)). | ||
11 | * This can cause confusion for large (> 1 word) bitmaps on a | ||
12 | * big-endian system because, unlike little endian, the number of each | ||
13 | * bit depends on the word size. | ||
14 | * | ||
15 | * The bitop functions are defined to work on unsigned longs, so for a | ||
16 | * ppc64 system the bits end up numbered: | ||
17 | * |63..............0|127............64|191...........128|255...........196| | ||
18 | * and on ppc32: | ||
19 | * |31.....0|63....31|95....64|127...96|159..128|191..160|223..192|255..224| | ||
20 | * | ||
21 | * There are a few little-endian macros used mostly for filesystem | ||
22 | * bitmaps, these work on similar bit arrays layouts, but | ||
23 | * byte-oriented: | ||
24 | * |7...0|15...8|23...16|31...24|39...32|47...40|55...48|63...56| | ||
25 | * | ||
26 | * The main difference is that bit 3-5 (64b) or 3-4 (32b) in the bit | ||
27 | * number field needs to be reversed compared to the big-endian bit | ||
28 | * fields. This can be achieved by XOR with 0x38 (64b) or 0x18 (32b). | ||
29 | * | ||
30 | * This program is free software; you can redistribute it and/or | ||
31 | * modify it under the terms of the GNU General Public License | ||
32 | * as published by the Free Software Foundation; either version | ||
33 | * 2 of the License, or (at your option) any later version. | ||
34 | */ | ||
35 | |||
36 | #ifndef _ASM_POWERPC_BITOPS_H | ||
37 | #define _ASM_POWERPC_BITOPS_H | ||
38 | |||
39 | #ifdef __KERNEL__ | ||
40 | |||
41 | #include <linux/compiler.h> | ||
42 | #include <asm/atomic.h> | ||
43 | #include <asm/synch.h> | ||
44 | |||
45 | /* | ||
46 | * clear_bit doesn't imply a memory barrier | ||
47 | */ | ||
48 | #define smp_mb__before_clear_bit() smp_mb() | ||
49 | #define smp_mb__after_clear_bit() smp_mb() | ||
50 | |||
51 | #define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
52 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | ||
53 | #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) | ||
54 | |||
55 | #ifdef CONFIG_PPC64 | ||
56 | #define LARXL "ldarx" | ||
57 | #define STCXL "stdcx." | ||
58 | #define CNTLZL "cntlzd" | ||
59 | #else | ||
60 | #define LARXL "lwarx" | ||
61 | #define STCXL "stwcx." | ||
62 | #define CNTLZL "cntlzw" | ||
63 | #endif | ||
64 | |||
65 | static __inline__ void set_bit(int nr, volatile unsigned long *addr) | ||
66 | { | ||
67 | unsigned long old; | ||
68 | unsigned long mask = BITOP_MASK(nr); | ||
69 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
70 | |||
71 | __asm__ __volatile__( | ||
72 | "1:" LARXL " %0,0,%3 # set_bit\n" | ||
73 | "or %0,%0,%2\n" | ||
74 | PPC405_ERR77(0,%3) | ||
75 | STCXL " %0,0,%3\n" | ||
76 | "bne- 1b" | ||
77 | : "=&r"(old), "=m"(*p) | ||
78 | : "r"(mask), "r"(p), "m"(*p) | ||
79 | : "cc" ); | ||
80 | } | ||
81 | |||
82 | static __inline__ void clear_bit(int nr, volatile unsigned long *addr) | ||
83 | { | ||
84 | unsigned long old; | ||
85 | unsigned long mask = BITOP_MASK(nr); | ||
86 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
87 | |||
88 | __asm__ __volatile__( | ||
89 | "1:" LARXL " %0,0,%3 # set_bit\n" | ||
90 | "andc %0,%0,%2\n" | ||
91 | PPC405_ERR77(0,%3) | ||
92 | STCXL " %0,0,%3\n" | ||
93 | "bne- 1b" | ||
94 | : "=&r"(old), "=m"(*p) | ||
95 | : "r"(mask), "r"(p), "m"(*p) | ||
96 | : "cc" ); | ||
97 | } | ||
98 | |||
99 | static __inline__ void change_bit(int nr, volatile unsigned long *addr) | ||
100 | { | ||
101 | unsigned long old; | ||
102 | unsigned long mask = BITOP_MASK(nr); | ||
103 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
104 | |||
105 | __asm__ __volatile__( | ||
106 | "1:" LARXL " %0,0,%3 # set_bit\n" | ||
107 | "xor %0,%0,%2\n" | ||
108 | PPC405_ERR77(0,%3) | ||
109 | STCXL " %0,0,%3\n" | ||
110 | "bne- 1b" | ||
111 | : "=&r"(old), "=m"(*p) | ||
112 | : "r"(mask), "r"(p), "m"(*p) | ||
113 | : "cc" ); | ||
114 | } | ||
115 | |||
116 | static __inline__ int test_and_set_bit(unsigned long nr, | ||
117 | volatile unsigned long *addr) | ||
118 | { | ||
119 | unsigned long old, t; | ||
120 | unsigned long mask = BITOP_MASK(nr); | ||
121 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
122 | |||
123 | __asm__ __volatile__( | ||
124 | EIEIO_ON_SMP | ||
125 | "1:" LARXL " %0,0,%3 # test_and_set_bit\n" | ||
126 | "or %1,%0,%2 \n" | ||
127 | PPC405_ERR77(0,%3) | ||
128 | STCXL " %1,0,%3 \n" | ||
129 | "bne- 1b" | ||
130 | ISYNC_ON_SMP | ||
131 | : "=&r" (old), "=&r" (t) | ||
132 | : "r" (mask), "r" (p) | ||
133 | : "cc", "memory"); | ||
134 | |||
135 | return (old & mask) != 0; | ||
136 | } | ||
137 | |||
138 | static __inline__ int test_and_clear_bit(unsigned long nr, | ||
139 | volatile unsigned long *addr) | ||
140 | { | ||
141 | unsigned long old, t; | ||
142 | unsigned long mask = BITOP_MASK(nr); | ||
143 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
144 | |||
145 | __asm__ __volatile__( | ||
146 | EIEIO_ON_SMP | ||
147 | "1:" LARXL " %0,0,%3 # test_and_clear_bit\n" | ||
148 | "andc %1,%0,%2 \n" | ||
149 | PPC405_ERR77(0,%3) | ||
150 | STCXL " %1,0,%3 \n" | ||
151 | "bne- 1b" | ||
152 | ISYNC_ON_SMP | ||
153 | : "=&r" (old), "=&r" (t) | ||
154 | : "r" (mask), "r" (p) | ||
155 | : "cc", "memory"); | ||
156 | |||
157 | return (old & mask) != 0; | ||
158 | } | ||
159 | |||
160 | static __inline__ int test_and_change_bit(unsigned long nr, | ||
161 | volatile unsigned long *addr) | ||
162 | { | ||
163 | unsigned long old, t; | ||
164 | unsigned long mask = BITOP_MASK(nr); | ||
165 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
166 | |||
167 | __asm__ __volatile__( | ||
168 | EIEIO_ON_SMP | ||
169 | "1:" LARXL " %0,0,%3 # test_and_change_bit\n" | ||
170 | "xor %1,%0,%2 \n" | ||
171 | PPC405_ERR77(0,%3) | ||
172 | STCXL " %1,0,%3 \n" | ||
173 | "bne- 1b" | ||
174 | ISYNC_ON_SMP | ||
175 | : "=&r" (old), "=&r" (t) | ||
176 | : "r" (mask), "r" (p) | ||
177 | : "cc", "memory"); | ||
178 | |||
179 | return (old & mask) != 0; | ||
180 | } | ||
181 | |||
182 | static __inline__ void set_bits(unsigned long mask, unsigned long *addr) | ||
183 | { | ||
184 | unsigned long old; | ||
185 | |||
186 | __asm__ __volatile__( | ||
187 | "1:" LARXL " %0,0,%3 # set_bit\n" | ||
188 | "or %0,%0,%2\n" | ||
189 | STCXL " %0,0,%3\n" | ||
190 | "bne- 1b" | ||
191 | : "=&r" (old), "=m" (*addr) | ||
192 | : "r" (mask), "r" (addr), "m" (*addr) | ||
193 | : "cc"); | ||
194 | } | ||
195 | |||
196 | /* Non-atomic versions */ | ||
197 | static __inline__ int test_bit(unsigned long nr, | ||
198 | __const__ volatile unsigned long *addr) | ||
199 | { | ||
200 | return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); | ||
201 | } | ||
202 | |||
203 | static __inline__ void __set_bit(unsigned long nr, | ||
204 | volatile unsigned long *addr) | ||
205 | { | ||
206 | unsigned long mask = BITOP_MASK(nr); | ||
207 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
208 | |||
209 | *p |= mask; | ||
210 | } | ||
211 | |||
212 | static __inline__ void __clear_bit(unsigned long nr, | ||
213 | volatile unsigned long *addr) | ||
214 | { | ||
215 | unsigned long mask = BITOP_MASK(nr); | ||
216 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
217 | |||
218 | *p &= ~mask; | ||
219 | } | ||
220 | |||
221 | static __inline__ void __change_bit(unsigned long nr, | ||
222 | volatile unsigned long *addr) | ||
223 | { | ||
224 | unsigned long mask = BITOP_MASK(nr); | ||
225 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
226 | |||
227 | *p ^= mask; | ||
228 | } | ||
229 | |||
230 | static __inline__ int __test_and_set_bit(unsigned long nr, | ||
231 | volatile unsigned long *addr) | ||
232 | { | ||
233 | unsigned long mask = BITOP_MASK(nr); | ||
234 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
235 | unsigned long old = *p; | ||
236 | |||
237 | *p = old | mask; | ||
238 | return (old & mask) != 0; | ||
239 | } | ||
240 | |||
241 | static __inline__ int __test_and_clear_bit(unsigned long nr, | ||
242 | volatile unsigned long *addr) | ||
243 | { | ||
244 | unsigned long mask = BITOP_MASK(nr); | ||
245 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
246 | unsigned long old = *p; | ||
247 | |||
248 | *p = old & ~mask; | ||
249 | return (old & mask) != 0; | ||
250 | } | ||
251 | |||
252 | static __inline__ int __test_and_change_bit(unsigned long nr, | ||
253 | volatile unsigned long *addr) | ||
254 | { | ||
255 | unsigned long mask = BITOP_MASK(nr); | ||
256 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
257 | unsigned long old = *p; | ||
258 | |||
259 | *p = old ^ mask; | ||
260 | return (old & mask) != 0; | ||
261 | } | ||
262 | |||
263 | /* | ||
264 | * Return the zero-based bit position (LE, not IBM bit numbering) of | ||
265 | * the most significant 1-bit in a double word. | ||
266 | */ | ||
267 | static __inline__ int __ilog2(unsigned long x) | ||
268 | { | ||
269 | int lz; | ||
270 | |||
271 | asm (CNTLZL " %0,%1" : "=r" (lz) : "r" (x)); | ||
272 | return BITS_PER_LONG - 1 - lz; | ||
273 | } | ||
274 | |||
275 | /* | ||
276 | * Determines the bit position of the least significant 0 bit in the | ||
277 | * specified double word. The returned bit position will be | ||
278 | * zero-based, starting from the right side (63/31 - 0). | ||
279 | */ | ||
280 | static __inline__ unsigned long ffz(unsigned long x) | ||
281 | { | ||
282 | /* no zero exists anywhere in the 8 byte area. */ | ||
283 | if ((x = ~x) == 0) | ||
284 | return BITS_PER_LONG; | ||
285 | |||
286 | /* | ||
287 | * Calculate the bit position of the least signficant '1' bit in x | ||
288 | * (since x has been changed this will actually be the least signficant | ||
289 | * '0' bit in * the original x). Note: (x & -x) gives us a mask that | ||
290 | * is the least significant * (RIGHT-most) 1-bit of the value in x. | ||
291 | */ | ||
292 | return __ilog2(x & -x); | ||
293 | } | ||
294 | |||
295 | static __inline__ int __ffs(unsigned long x) | ||
296 | { | ||
297 | return __ilog2(x & -x); | ||
298 | } | ||
299 | |||
300 | /* | ||
301 | * ffs: find first bit set. This is defined the same way as | ||
302 | * the libc and compiler builtin ffs routines, therefore | ||
303 | * differs in spirit from the above ffz (man ffs). | ||
304 | */ | ||
305 | static __inline__ int ffs(int x) | ||
306 | { | ||
307 | unsigned long i = (unsigned long)x; | ||
308 | return __ilog2(i & -i) + 1; | ||
309 | } | ||
310 | |||
311 | /* | ||
312 | * fls: find last (most-significant) bit set. | ||
313 | * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. | ||
314 | */ | ||
315 | static __inline__ int fls(unsigned int x) | ||
316 | { | ||
317 | int lz; | ||
318 | |||
319 | asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x)); | ||
320 | return 32 - lz; | ||
321 | } | ||
322 | |||
323 | /* | ||
324 | * hweightN: returns the hamming weight (i.e. the number | ||
325 | * of bits set) of a N-bit word | ||
326 | */ | ||
327 | #define hweight64(x) generic_hweight64(x) | ||
328 | #define hweight32(x) generic_hweight32(x) | ||
329 | #define hweight16(x) generic_hweight16(x) | ||
330 | #define hweight8(x) generic_hweight8(x) | ||
331 | |||
332 | #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) | ||
333 | unsigned long find_next_zero_bit(const unsigned long *addr, | ||
334 | unsigned long size, unsigned long offset); | ||
335 | /** | ||
336 | * find_first_bit - find the first set bit in a memory region | ||
337 | * @addr: The address to start the search at | ||
338 | * @size: The maximum size to search | ||
339 | * | ||
340 | * Returns the bit-number of the first set bit, not the number of the byte | ||
341 | * containing a bit. | ||
342 | */ | ||
343 | #define find_first_bit(addr, size) find_next_bit((addr), (size), 0) | ||
344 | unsigned long find_next_bit(const unsigned long *addr, | ||
345 | unsigned long size, unsigned long offset); | ||
346 | |||
347 | /* Little-endian versions */ | ||
348 | |||
349 | static __inline__ int test_le_bit(unsigned long nr, | ||
350 | __const__ unsigned long *addr) | ||
351 | { | ||
352 | __const__ unsigned char *tmp = (__const__ unsigned char *) addr; | ||
353 | return (tmp[nr >> 3] >> (nr & 7)) & 1; | ||
354 | } | ||
355 | |||
356 | #define __set_le_bit(nr, addr) \ | ||
357 | __set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
358 | #define __clear_le_bit(nr, addr) \ | ||
359 | __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
360 | |||
361 | #define test_and_set_le_bit(nr, addr) \ | ||
362 | test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
363 | #define test_and_clear_le_bit(nr, addr) \ | ||
364 | test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
365 | |||
366 | #define __test_and_set_le_bit(nr, addr) \ | ||
367 | __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
368 | #define __test_and_clear_le_bit(nr, addr) \ | ||
369 | __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
370 | |||
371 | #define find_first_zero_le_bit(addr, size) find_next_zero_le_bit((addr), (size), 0) | ||
372 | unsigned long find_next_zero_le_bit(const unsigned long *addr, | ||
373 | unsigned long size, unsigned long offset); | ||
374 | |||
375 | /* Bitmap functions for the ext2 filesystem */ | ||
376 | |||
377 | #define ext2_set_bit(nr,addr) \ | ||
378 | __test_and_set_le_bit((nr), (unsigned long*)addr) | ||
379 | #define ext2_clear_bit(nr, addr) \ | ||
380 | __test_and_clear_le_bit((nr), (unsigned long*)addr) | ||
381 | |||
382 | #define ext2_set_bit_atomic(lock, nr, addr) \ | ||
383 | test_and_set_le_bit((nr), (unsigned long*)addr) | ||
384 | #define ext2_clear_bit_atomic(lock, nr, addr) \ | ||
385 | test_and_clear_le_bit((nr), (unsigned long*)addr) | ||
386 | |||
387 | #define ext2_test_bit(nr, addr) test_le_bit((nr),(unsigned long*)addr) | ||
388 | |||
389 | #define ext2_find_first_zero_bit(addr, size) \ | ||
390 | find_first_zero_le_bit((unsigned long*)addr, size) | ||
391 | #define ext2_find_next_zero_bit(addr, size, off) \ | ||
392 | find_next_zero_le_bit((unsigned long*)addr, size, off) | ||
393 | |||
394 | /* Bitmap functions for the minix filesystem. */ | ||
395 | |||
396 | #define minix_test_and_set_bit(nr,addr) \ | ||
397 | __test_and_set_le_bit(nr, (unsigned long *)addr) | ||
398 | #define minix_set_bit(nr,addr) \ | ||
399 | __set_le_bit(nr, (unsigned long *)addr) | ||
400 | #define minix_test_and_clear_bit(nr,addr) \ | ||
401 | __test_and_clear_le_bit(nr, (unsigned long *)addr) | ||
402 | #define minix_test_bit(nr,addr) \ | ||
403 | test_le_bit(nr, (unsigned long *)addr) | ||
404 | |||
405 | #define minix_find_first_zero_bit(addr,size) \ | ||
406 | find_first_zero_le_bit((unsigned long *)addr, size) | ||
407 | |||
408 | /* | ||
409 | * Every architecture must define this function. It's the fastest | ||
410 | * way of searching a 140-bit bitmap where the first 100 bits are | ||
411 | * unlikely to be set. It's guaranteed that at least one of the 140 | ||
412 | * bits is cleared. | ||
413 | */ | ||
414 | static inline int sched_find_first_bit(const unsigned long *b) | ||
415 | { | ||
416 | #ifdef CONFIG_PPC64 | ||
417 | if (unlikely(b[0])) | ||
418 | return __ffs(b[0]); | ||
419 | if (unlikely(b[1])) | ||
420 | return __ffs(b[1]) + 64; | ||
421 | return __ffs(b[2]) + 128; | ||
422 | #else | ||
423 | if (unlikely(b[0])) | ||
424 | return __ffs(b[0]); | ||
425 | if (unlikely(b[1])) | ||
426 | return __ffs(b[1]) + 32; | ||
427 | if (unlikely(b[2])) | ||
428 | return __ffs(b[2]) + 64; | ||
429 | if (b[3]) | ||
430 | return __ffs(b[3]) + 96; | ||
431 | return __ffs(b[4]) + 128; | ||
432 | #endif | ||
433 | } | ||
434 | |||
435 | #endif /* __KERNEL__ */ | ||
436 | |||
437 | #endif /* _ASM_POWERPC_BITOPS_H */ | ||
diff --git a/include/asm-powerpc/bug.h b/include/asm-powerpc/bug.h new file mode 100644 index 000000000000..d625ee55f957 --- /dev/null +++ b/include/asm-powerpc/bug.h | |||
@@ -0,0 +1,77 @@ | |||
1 | #ifndef _ASM_POWERPC_BUG_H | ||
2 | #define _ASM_POWERPC_BUG_H | ||
3 | |||
4 | /* | ||
5 | * Define an illegal instr to trap on the bug. | ||
6 | * We don't use 0 because that marks the end of a function | ||
7 | * in the ELF ABI. That's "Boo Boo" in case you wonder... | ||
8 | */ | ||
9 | #define BUG_OPCODE .long 0x00b00b00 /* For asm */ | ||
10 | #define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */ | ||
11 | |||
12 | #ifndef __ASSEMBLY__ | ||
13 | |||
14 | #ifdef __powerpc64__ | ||
15 | #define BUG_TABLE_ENTRY ".llong" | ||
16 | #define BUG_TRAP_OP "tdnei" | ||
17 | #else | ||
18 | #define BUG_TABLE_ENTRY ".long" | ||
19 | #define BUG_TRAP_OP "twnei" | ||
20 | #endif /* __powerpc64__ */ | ||
21 | |||
22 | struct bug_entry { | ||
23 | unsigned long bug_addr; | ||
24 | long line; | ||
25 | const char *file; | ||
26 | const char *function; | ||
27 | }; | ||
28 | |||
29 | struct bug_entry *find_bug(unsigned long bugaddr); | ||
30 | |||
31 | /* | ||
32 | * If this bit is set in the line number it means that the trap | ||
33 | * is for WARN_ON rather than BUG or BUG_ON. | ||
34 | */ | ||
35 | #define BUG_WARNING_TRAP 0x1000000 | ||
36 | |||
37 | #ifdef CONFIG_BUG | ||
38 | |||
39 | #define BUG() do { \ | ||
40 | __asm__ __volatile__( \ | ||
41 | "1: twi 31,0,0\n" \ | ||
42 | ".section __bug_table,\"a\"\n" \ | ||
43 | "\t"BUG_TABLE_ENTRY" 1b,%0,%1,%2\n" \ | ||
44 | ".previous" \ | ||
45 | : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \ | ||
46 | } while (0) | ||
47 | |||
48 | #define BUG_ON(x) do { \ | ||
49 | __asm__ __volatile__( \ | ||
50 | "1: "BUG_TRAP_OP" %0,0\n" \ | ||
51 | ".section __bug_table,\"a\"\n" \ | ||
52 | "\t"BUG_TABLE_ENTRY" 1b,%1,%2,%3\n" \ | ||
53 | ".previous" \ | ||
54 | : : "r" ((long)(x)), "i" (__LINE__), \ | ||
55 | "i" (__FILE__), "i" (__FUNCTION__)); \ | ||
56 | } while (0) | ||
57 | |||
58 | #define WARN_ON(x) do { \ | ||
59 | __asm__ __volatile__( \ | ||
60 | "1: "BUG_TRAP_OP" %0,0\n" \ | ||
61 | ".section __bug_table,\"a\"\n" \ | ||
62 | "\t"BUG_TABLE_ENTRY" 1b,%1,%2,%3\n" \ | ||
63 | ".previous" \ | ||
64 | : : "r" ((long)(x)), \ | ||
65 | "i" (__LINE__ + BUG_WARNING_TRAP), \ | ||
66 | "i" (__FILE__), "i" (__FUNCTION__)); \ | ||
67 | } while (0) | ||
68 | |||
69 | #define HAVE_ARCH_BUG | ||
70 | #define HAVE_ARCH_BUG_ON | ||
71 | #define HAVE_ARCH_WARN_ON | ||
72 | #endif /* CONFIG_BUG */ | ||
73 | #endif /* __ASSEMBLY __ */ | ||
74 | |||
75 | #include <asm-generic/bug.h> | ||
76 | |||
77 | #endif /* _ASM_POWERPC_BUG_H */ | ||
diff --git a/include/asm-powerpc/byteorder.h b/include/asm-powerpc/byteorder.h new file mode 100644 index 000000000000..b37752214a16 --- /dev/null +++ b/include/asm-powerpc/byteorder.h | |||
@@ -0,0 +1,89 @@ | |||
1 | #ifndef _ASM_POWERPC_BYTEORDER_H | ||
2 | #define _ASM_POWERPC_BYTEORDER_H | ||
3 | |||
4 | /* | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include <asm/types.h> | ||
12 | #include <linux/compiler.h> | ||
13 | |||
14 | #ifdef __GNUC__ | ||
15 | #ifdef __KERNEL__ | ||
16 | |||
17 | static __inline__ __u16 ld_le16(const volatile __u16 *addr) | ||
18 | { | ||
19 | __u16 val; | ||
20 | |||
21 | __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); | ||
22 | return val; | ||
23 | } | ||
24 | |||
25 | static __inline__ void st_le16(volatile __u16 *addr, const __u16 val) | ||
26 | { | ||
27 | __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); | ||
28 | } | ||
29 | |||
30 | static __inline__ __u32 ld_le32(const volatile __u32 *addr) | ||
31 | { | ||
32 | __u32 val; | ||
33 | |||
34 | __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr)); | ||
35 | return val; | ||
36 | } | ||
37 | |||
38 | static __inline__ void st_le32(volatile __u32 *addr, const __u32 val) | ||
39 | { | ||
40 | __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); | ||
41 | } | ||
42 | |||
43 | static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 value) | ||
44 | { | ||
45 | __u16 result; | ||
46 | |||
47 | __asm__("rlwimi %0,%1,8,16,23" | ||
48 | : "=r" (result) | ||
49 | : "r" (value), "0" (value >> 8)); | ||
50 | return result; | ||
51 | } | ||
52 | |||
53 | static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 value) | ||
54 | { | ||
55 | __u32 result; | ||
56 | |||
57 | __asm__("rlwimi %0,%1,24,16,23\n\t" | ||
58 | "rlwimi %0,%1,8,8,15\n\t" | ||
59 | "rlwimi %0,%1,24,0,7" | ||
60 | : "=r" (result) | ||
61 | : "r" (value), "0" (value >> 24)); | ||
62 | return result; | ||
63 | } | ||
64 | |||
65 | #define __arch__swab16(x) ___arch__swab16(x) | ||
66 | #define __arch__swab32(x) ___arch__swab32(x) | ||
67 | |||
68 | /* The same, but returns converted value from the location pointer by addr. */ | ||
69 | #define __arch__swab16p(addr) ld_le16(addr) | ||
70 | #define __arch__swab32p(addr) ld_le32(addr) | ||
71 | |||
72 | /* The same, but do the conversion in situ, ie. put the value back to addr. */ | ||
73 | #define __arch__swab16s(addr) st_le16(addr,*addr) | ||
74 | #define __arch__swab32s(addr) st_le32(addr,*addr) | ||
75 | |||
76 | #endif /* __KERNEL__ */ | ||
77 | |||
78 | #ifndef __STRICT_ANSI__ | ||
79 | #define __BYTEORDER_HAS_U64__ | ||
80 | #ifndef __powerpc64__ | ||
81 | #define __SWAB_64_THRU_32__ | ||
82 | #endif /* __powerpc64__ */ | ||
83 | #endif /* __STRICT_ANSI__ */ | ||
84 | |||
85 | #endif /* __GNUC__ */ | ||
86 | |||
87 | #include <linux/byteorder/big_endian.h> | ||
88 | |||
89 | #endif /* _ASM_POWERPC_BYTEORDER_H */ | ||
diff --git a/include/asm-powerpc/checksum.h b/include/asm-powerpc/checksum.h new file mode 100644 index 000000000000..d8354d8a49ce --- /dev/null +++ b/include/asm-powerpc/checksum.h | |||
@@ -0,0 +1,132 @@ | |||
1 | #ifndef _ASM_POWERPC_CHECKSUM_H | ||
2 | #define _ASM_POWERPC_CHECKSUM_H | ||
3 | |||
4 | /* | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * This is a version of ip_compute_csum() optimized for IP headers, | ||
13 | * which always checksum on 4 octet boundaries. ihl is the number | ||
14 | * of 32-bit words and is always >= 5. | ||
15 | */ | ||
16 | extern unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl); | ||
17 | |||
18 | /* | ||
19 | * computes the checksum of the TCP/UDP pseudo-header | ||
20 | * returns a 16-bit checksum, already complemented | ||
21 | */ | ||
22 | extern unsigned short csum_tcpudp_magic(unsigned long saddr, | ||
23 | unsigned long daddr, | ||
24 | unsigned short len, | ||
25 | unsigned short proto, | ||
26 | unsigned int sum); | ||
27 | |||
28 | /* | ||
29 | * computes the checksum of a memory block at buff, length len, | ||
30 | * and adds in "sum" (32-bit) | ||
31 | * | ||
32 | * returns a 32-bit number suitable for feeding into itself | ||
33 | * or csum_tcpudp_magic | ||
34 | * | ||
35 | * this function must be called with even lengths, except | ||
36 | * for the last fragment, which may be odd | ||
37 | * | ||
38 | * it's best to have buff aligned on a 32-bit boundary | ||
39 | */ | ||
40 | extern unsigned int csum_partial(const unsigned char * buff, int len, | ||
41 | unsigned int sum); | ||
42 | |||
43 | /* | ||
44 | * Computes the checksum of a memory block at src, length len, | ||
45 | * and adds in "sum" (32-bit), while copying the block to dst. | ||
46 | * If an access exception occurs on src or dst, it stores -EFAULT | ||
47 | * to *src_err or *dst_err respectively (if that pointer is not | ||
48 | * NULL), and, for an error on src, zeroes the rest of dst. | ||
49 | * | ||
50 | * Like csum_partial, this must be called with even lengths, | ||
51 | * except for the last fragment. | ||
52 | */ | ||
53 | extern unsigned int csum_partial_copy_generic(const char *src, char *dst, | ||
54 | int len, unsigned int sum, | ||
55 | int *src_err, int *dst_err); | ||
56 | /* | ||
57 | * the same as csum_partial, but copies from src to dst while it | ||
58 | * checksums. | ||
59 | */ | ||
60 | unsigned int csum_partial_copy_nocheck(const char *src, | ||
61 | char *dst, | ||
62 | int len, | ||
63 | unsigned int sum); | ||
64 | |||
65 | #define csum_partial_copy_from_user(src, dst, len, sum, errp) \ | ||
66 | csum_partial_copy_generic((src), (dst), (len), (sum), (errp), NULL) | ||
67 | |||
68 | #define csum_partial_copy_nocheck(src, dst, len, sum) \ | ||
69 | csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL) | ||
70 | |||
71 | |||
72 | /* | ||
73 | * turns a 32-bit partial checksum (e.g. from csum_partial) into a | ||
74 | * 1's complement 16-bit checksum. | ||
75 | */ | ||
76 | static inline unsigned int csum_fold(unsigned int sum) | ||
77 | { | ||
78 | unsigned int tmp; | ||
79 | |||
80 | /* swap the two 16-bit halves of sum */ | ||
81 | __asm__("rlwinm %0,%1,16,0,31" : "=r" (tmp) : "r" (sum)); | ||
82 | /* if there is a carry from adding the two 16-bit halves, | ||
83 | it will carry from the lower half into the upper half, | ||
84 | giving us the correct sum in the upper half. */ | ||
85 | sum = ~(sum + tmp) >> 16; | ||
86 | return sum; | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * this routine is used for miscellaneous IP-like checksums, mainly | ||
91 | * in icmp.c | ||
92 | */ | ||
93 | static inline unsigned short ip_compute_csum(unsigned char * buff, int len) | ||
94 | { | ||
95 | return csum_fold(csum_partial(buff, len, 0)); | ||
96 | } | ||
97 | |||
98 | #ifdef __powerpc64__ | ||
99 | static inline u32 csum_tcpudp_nofold(u32 saddr, | ||
100 | u32 daddr, | ||
101 | unsigned short len, | ||
102 | unsigned short proto, | ||
103 | unsigned int sum) | ||
104 | { | ||
105 | unsigned long s = sum; | ||
106 | |||
107 | s += saddr; | ||
108 | s += daddr; | ||
109 | s += (proto << 16) + len; | ||
110 | s += (s >> 32); | ||
111 | return (u32) s; | ||
112 | } | ||
113 | #else | ||
114 | static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, | ||
115 | unsigned long daddr, | ||
116 | unsigned short len, | ||
117 | unsigned short proto, | ||
118 | unsigned int sum) | ||
119 | { | ||
120 | __asm__("\n\ | ||
121 | addc %0,%0,%1 \n\ | ||
122 | adde %0,%0,%2 \n\ | ||
123 | adde %0,%0,%3 \n\ | ||
124 | addze %0,%0 \n\ | ||
125 | " | ||
126 | : "=r" (sum) | ||
127 | : "r" (daddr), "r"(saddr), "r"((proto<<16)+len), "0"(sum)); | ||
128 | return sum; | ||
129 | } | ||
130 | |||
131 | #endif | ||
132 | #endif | ||
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h new file mode 100644 index 000000000000..c019501daceb --- /dev/null +++ b/include/asm-powerpc/cputable.h | |||
@@ -0,0 +1,427 @@ | |||
1 | #ifndef __ASM_POWERPC_CPUTABLE_H | ||
2 | #define __ASM_POWERPC_CPUTABLE_H | ||
3 | |||
4 | #include <linux/config.h> | ||
5 | #include <asm/ppc_asm.h> /* for ASM_CONST */ | ||
6 | |||
7 | #define PPC_FEATURE_32 0x80000000 | ||
8 | #define PPC_FEATURE_64 0x40000000 | ||
9 | #define PPC_FEATURE_601_INSTR 0x20000000 | ||
10 | #define PPC_FEATURE_HAS_ALTIVEC 0x10000000 | ||
11 | #define PPC_FEATURE_HAS_FPU 0x08000000 | ||
12 | #define PPC_FEATURE_HAS_MMU 0x04000000 | ||
13 | #define PPC_FEATURE_HAS_4xxMAC 0x02000000 | ||
14 | #define PPC_FEATURE_UNIFIED_CACHE 0x01000000 | ||
15 | #define PPC_FEATURE_HAS_SPE 0x00800000 | ||
16 | #define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 | ||
17 | #define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 | ||
18 | #define PPC_FEATURE_NO_TB 0x00100000 | ||
19 | |||
20 | #ifdef __KERNEL__ | ||
21 | #ifndef __ASSEMBLY__ | ||
22 | |||
23 | /* This structure can grow, it's real size is used by head.S code | ||
24 | * via the mkdefs mechanism. | ||
25 | */ | ||
26 | struct cpu_spec; | ||
27 | struct op_powerpc_model; | ||
28 | |||
29 | typedef void (*cpu_setup_t)(unsigned long offset, struct cpu_spec* spec); | ||
30 | |||
31 | struct cpu_spec { | ||
32 | /* CPU is matched via (PVR & pvr_mask) == pvr_value */ | ||
33 | unsigned int pvr_mask; | ||
34 | unsigned int pvr_value; | ||
35 | |||
36 | char *cpu_name; | ||
37 | unsigned long cpu_features; /* Kernel features */ | ||
38 | unsigned int cpu_user_features; /* Userland features */ | ||
39 | |||
40 | /* cache line sizes */ | ||
41 | unsigned int icache_bsize; | ||
42 | unsigned int dcache_bsize; | ||
43 | |||
44 | /* number of performance monitor counters */ | ||
45 | unsigned int num_pmcs; | ||
46 | |||
47 | /* this is called to initialize various CPU bits like L1 cache, | ||
48 | * BHT, SPD, etc... from head.S before branching to identify_machine | ||
49 | */ | ||
50 | cpu_setup_t cpu_setup; | ||
51 | |||
52 | /* Used by oprofile userspace to select the right counters */ | ||
53 | char *oprofile_cpu_type; | ||
54 | |||
55 | /* Processor specific oprofile operations */ | ||
56 | struct op_powerpc_model *oprofile_model; | ||
57 | }; | ||
58 | |||
59 | extern struct cpu_spec *cur_cpu_spec; | ||
60 | |||
61 | extern void identify_cpu(unsigned long offset, unsigned long cpu); | ||
62 | extern void do_cpu_ftr_fixups(unsigned long offset); | ||
63 | |||
64 | #endif /* __ASSEMBLY__ */ | ||
65 | |||
66 | /* CPU kernel features */ | ||
67 | |||
68 | /* Retain the 32b definitions all use bottom half of word */ | ||
69 | #define CPU_FTR_SPLIT_ID_CACHE ASM_CONST(0x0000000000000001) | ||
70 | #define CPU_FTR_L2CR ASM_CONST(0x0000000000000002) | ||
71 | #define CPU_FTR_SPEC7450 ASM_CONST(0x0000000000000004) | ||
72 | #define CPU_FTR_ALTIVEC ASM_CONST(0x0000000000000008) | ||
73 | #define CPU_FTR_TAU ASM_CONST(0x0000000000000010) | ||
74 | #define CPU_FTR_CAN_DOZE ASM_CONST(0x0000000000000020) | ||
75 | #define CPU_FTR_USE_TB ASM_CONST(0x0000000000000040) | ||
76 | #define CPU_FTR_604_PERF_MON ASM_CONST(0x0000000000000080) | ||
77 | #define CPU_FTR_601 ASM_CONST(0x0000000000000100) | ||
78 | #define CPU_FTR_HPTE_TABLE ASM_CONST(0x0000000000000200) | ||
79 | #define CPU_FTR_CAN_NAP ASM_CONST(0x0000000000000400) | ||
80 | #define CPU_FTR_L3CR ASM_CONST(0x0000000000000800) | ||
81 | #define CPU_FTR_L3_DISABLE_NAP ASM_CONST(0x0000000000001000) | ||
82 | #define CPU_FTR_NAP_DISABLE_L2_PR ASM_CONST(0x0000000000002000) | ||
83 | #define CPU_FTR_DUAL_PLL_750FX ASM_CONST(0x0000000000004000) | ||
84 | #define CPU_FTR_NO_DPM ASM_CONST(0x0000000000008000) | ||
85 | #define CPU_FTR_HAS_HIGH_BATS ASM_CONST(0x0000000000010000) | ||
86 | #define CPU_FTR_NEED_COHERENT ASM_CONST(0x0000000000020000) | ||
87 | #define CPU_FTR_NO_BTIC ASM_CONST(0x0000000000040000) | ||
88 | #define CPU_FTR_BIG_PHYS ASM_CONST(0x0000000000080000) | ||
89 | |||
90 | #ifdef __powerpc64__ | ||
91 | /* Add the 64b processor unique features in the top half of the word */ | ||
92 | #define CPU_FTR_SLB ASM_CONST(0x0000000100000000) | ||
93 | #define CPU_FTR_16M_PAGE ASM_CONST(0x0000000200000000) | ||
94 | #define CPU_FTR_TLBIEL ASM_CONST(0x0000000400000000) | ||
95 | #define CPU_FTR_NOEXECUTE ASM_CONST(0x0000000800000000) | ||
96 | #define CPU_FTR_NODSISRALIGN ASM_CONST(0x0000001000000000) | ||
97 | #define CPU_FTR_IABR ASM_CONST(0x0000002000000000) | ||
98 | #define CPU_FTR_MMCRA ASM_CONST(0x0000004000000000) | ||
99 | #define CPU_FTR_CTRL ASM_CONST(0x0000008000000000) | ||
100 | #define CPU_FTR_SMT ASM_CONST(0x0000010000000000) | ||
101 | #define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0000020000000000) | ||
102 | #define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0000040000000000) | ||
103 | #define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0000080000000000) | ||
104 | #else | ||
105 | /* ensure on 32b processors the flags are available for compiling but | ||
106 | * don't do anything */ | ||
107 | #define CPU_FTR_SLB ASM_CONST(0x0) | ||
108 | #define CPU_FTR_16M_PAGE ASM_CONST(0x0) | ||
109 | #define CPU_FTR_TLBIEL ASM_CONST(0x0) | ||
110 | #define CPU_FTR_NOEXECUTE ASM_CONST(0x0) | ||
111 | #define CPU_FTR_NODSISRALIGN ASM_CONST(0x0) | ||
112 | #define CPU_FTR_IABR ASM_CONST(0x0) | ||
113 | #define CPU_FTR_MMCRA ASM_CONST(0x0) | ||
114 | #define CPU_FTR_CTRL ASM_CONST(0x0) | ||
115 | #define CPU_FTR_SMT ASM_CONST(0x0) | ||
116 | #define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0) | ||
117 | #define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0) | ||
118 | #define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0) | ||
119 | #endif | ||
120 | |||
121 | #ifndef __ASSEMBLY__ | ||
122 | |||
123 | #define CPU_FTR_PPCAS_ARCH_V2_BASE (CPU_FTR_SLB | \ | ||
124 | CPU_FTR_TLBIEL | CPU_FTR_NOEXECUTE | \ | ||
125 | CPU_FTR_NODSISRALIGN | CPU_FTR_CTRL) | ||
126 | |||
127 | /* iSeries doesn't support large pages */ | ||
128 | #ifdef CONFIG_PPC_ISERIES | ||
129 | #define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE) | ||
130 | #else | ||
131 | #define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE | CPU_FTR_16M_PAGE) | ||
132 | #endif /* CONFIG_PPC_ISERIES */ | ||
133 | |||
134 | /* We only set the altivec features if the kernel was compiled with altivec | ||
135 | * support | ||
136 | */ | ||
137 | #ifdef CONFIG_ALTIVEC | ||
138 | #define CPU_FTR_ALTIVEC_COMP CPU_FTR_ALTIVEC | ||
139 | #define PPC_FEATURE_HAS_ALTIVEC_COMP PPC_FEATURE_HAS_ALTIVEC | ||
140 | #else | ||
141 | #define CPU_FTR_ALTIVEC_COMP 0 | ||
142 | #define PPC_FEATURE_HAS_ALTIVEC_COMP 0 | ||
143 | #endif | ||
144 | |||
145 | /* We need to mark all pages as being coherent if we're SMP or we | ||
146 | * have a 74[45]x and an MPC107 host bridge. | ||
147 | */ | ||
148 | #if defined(CONFIG_SMP) || defined(CONFIG_MPC10X_BRIDGE) | ||
149 | #define CPU_FTR_COMMON CPU_FTR_NEED_COHERENT | ||
150 | #else | ||
151 | #define CPU_FTR_COMMON 0 | ||
152 | #endif | ||
153 | |||
154 | /* The powersave features NAP & DOZE seems to confuse BDI when | ||
155 | debugging. So if a BDI is used, disable theses | ||
156 | */ | ||
157 | #ifndef CONFIG_BDI_SWITCH | ||
158 | #define CPU_FTR_MAYBE_CAN_DOZE CPU_FTR_CAN_DOZE | ||
159 | #define CPU_FTR_MAYBE_CAN_NAP CPU_FTR_CAN_NAP | ||
160 | #else | ||
161 | #define CPU_FTR_MAYBE_CAN_DOZE 0 | ||
162 | #define CPU_FTR_MAYBE_CAN_NAP 0 | ||
163 | #endif | ||
164 | |||
165 | #define CLASSIC_PPC (!defined(CONFIG_8xx) && !defined(CONFIG_4xx) && \ | ||
166 | !defined(CONFIG_POWER3) && !defined(CONFIG_POWER4) && \ | ||
167 | !defined(CONFIG_BOOKE)) | ||
168 | |||
169 | enum { | ||
170 | CPU_FTRS_PPC601 = CPU_FTR_COMMON | CPU_FTR_601 | CPU_FTR_HPTE_TABLE, | ||
171 | CPU_FTRS_603 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
172 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | | ||
173 | CPU_FTR_MAYBE_CAN_NAP, | ||
174 | CPU_FTRS_604 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
175 | CPU_FTR_USE_TB | CPU_FTR_604_PERF_MON | CPU_FTR_HPTE_TABLE, | ||
176 | CPU_FTRS_740_NOTAU = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
177 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | | ||
178 | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP, | ||
179 | CPU_FTRS_740 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
180 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | | ||
181 | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP, | ||
182 | CPU_FTRS_750 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
183 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | | ||
184 | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP, | ||
185 | CPU_FTRS_750FX1 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
186 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | | ||
187 | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | | ||
188 | CPU_FTR_DUAL_PLL_750FX | CPU_FTR_NO_DPM, | ||
189 | CPU_FTRS_750FX2 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
190 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | | ||
191 | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | | ||
192 | CPU_FTR_NO_DPM, | ||
193 | CPU_FTRS_750FX = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
194 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | | ||
195 | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | | ||
196 | CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS, | ||
197 | CPU_FTRS_750GX = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | | ||
198 | CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU | | ||
199 | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | | ||
200 | CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS, | ||
201 | CPU_FTRS_7400_NOTAU = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
202 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | | ||
203 | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE | | ||
204 | CPU_FTR_MAYBE_CAN_NAP, | ||
205 | CPU_FTRS_7400 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
206 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | | ||
207 | CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE | | ||
208 | CPU_FTR_MAYBE_CAN_NAP, | ||
209 | CPU_FTRS_7450_20 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
210 | CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | | ||
211 | CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | | ||
212 | CPU_FTR_NEED_COHERENT, | ||
213 | CPU_FTRS_7450_21 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
214 | CPU_FTR_USE_TB | | ||
215 | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | | ||
216 | CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | | ||
217 | CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP | | ||
218 | CPU_FTR_NEED_COHERENT, | ||
219 | CPU_FTRS_7450_23 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
220 | CPU_FTR_USE_TB | | ||
221 | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | | ||
222 | CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | | ||
223 | CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_NEED_COHERENT, | ||
224 | CPU_FTRS_7455_1 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
225 | CPU_FTR_USE_TB | | ||
226 | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR | | ||
227 | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_HAS_HIGH_BATS | | ||
228 | CPU_FTR_NEED_COHERENT, | ||
229 | CPU_FTRS_7455_20 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
230 | CPU_FTR_USE_TB | | ||
231 | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | | ||
232 | CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | | ||
233 | CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP | | ||
234 | CPU_FTR_NEED_COHERENT | CPU_FTR_HAS_HIGH_BATS, | ||
235 | CPU_FTRS_7455 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
236 | CPU_FTR_USE_TB | | ||
237 | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | | ||
238 | CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | | ||
239 | CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | | ||
240 | CPU_FTR_NEED_COHERENT, | ||
241 | CPU_FTRS_7447_10 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
242 | CPU_FTR_USE_TB | | ||
243 | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | | ||
244 | CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | | ||
245 | CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | | ||
246 | CPU_FTR_NEED_COHERENT | CPU_FTR_NO_BTIC, | ||
247 | CPU_FTRS_7447 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
248 | CPU_FTR_USE_TB | | ||
249 | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | | ||
250 | CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | | ||
251 | CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | | ||
252 | CPU_FTR_NEED_COHERENT, | ||
253 | CPU_FTRS_7447A = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
254 | CPU_FTR_USE_TB | | ||
255 | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | | ||
256 | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | | ||
257 | CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | | ||
258 | CPU_FTR_NEED_COHERENT, | ||
259 | CPU_FTRS_82XX = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
260 | CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB, | ||
261 | CPU_FTRS_G2_LE = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | | ||
262 | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_HAS_HIGH_BATS, | ||
263 | CPU_FTRS_E300 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | | ||
264 | CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_HAS_HIGH_BATS, | ||
265 | CPU_FTRS_CLASSIC32 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
266 | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE, | ||
267 | CPU_FTRS_POWER3_32 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
268 | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE, | ||
269 | CPU_FTRS_POWER4_32 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
270 | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE, | ||
271 | CPU_FTRS_970_32 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | | ||
272 | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_ALTIVEC_COMP | | ||
273 | CPU_FTR_MAYBE_CAN_NAP, | ||
274 | CPU_FTRS_8XX = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB, | ||
275 | CPU_FTRS_40X = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB, | ||
276 | CPU_FTRS_44X = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB, | ||
277 | CPU_FTRS_E200 = CPU_FTR_USE_TB, | ||
278 | CPU_FTRS_E500 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB, | ||
279 | CPU_FTRS_E500_2 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | | ||
280 | CPU_FTR_BIG_PHYS, | ||
281 | CPU_FTRS_GENERIC_32 = CPU_FTR_COMMON, | ||
282 | #ifdef __powerpc64__ | ||
283 | CPU_FTRS_POWER3 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | | ||
284 | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR, | ||
285 | CPU_FTRS_RS64 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | | ||
286 | CPU_FTR_HPTE_TABLE | CPU_FTR_IABR | | ||
287 | CPU_FTR_MMCRA | CPU_FTR_CTRL, | ||
288 | CPU_FTRS_POWER4 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | | ||
289 | CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_MMCRA, | ||
290 | CPU_FTRS_PPC970 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | | ||
291 | CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | | ||
292 | CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA, | ||
293 | CPU_FTRS_POWER5 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | | ||
294 | CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | | ||
295 | CPU_FTR_MMCRA | CPU_FTR_SMT | | ||
296 | CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | | ||
297 | CPU_FTR_MMCRA_SIHV, | ||
298 | CPU_FTRS_CELL = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | | ||
299 | CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | | ||
300 | CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT, | ||
301 | CPU_FTRS_COMPATIBLE = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | | ||
302 | CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2, | ||
303 | #endif | ||
304 | |||
305 | CPU_FTRS_POSSIBLE = | ||
306 | #if CLASSIC_PPC | ||
307 | CPU_FTRS_PPC601 | CPU_FTRS_603 | CPU_FTRS_604 | CPU_FTRS_740_NOTAU | | ||
308 | CPU_FTRS_740 | CPU_FTRS_750 | CPU_FTRS_750FX1 | | ||
309 | CPU_FTRS_750FX2 | CPU_FTRS_750FX | CPU_FTRS_750GX | | ||
310 | CPU_FTRS_7400_NOTAU | CPU_FTRS_7400 | CPU_FTRS_7450_20 | | ||
311 | CPU_FTRS_7450_21 | CPU_FTRS_7450_23 | CPU_FTRS_7455_1 | | ||
312 | CPU_FTRS_7455_20 | CPU_FTRS_7455 | CPU_FTRS_7447_10 | | ||
313 | CPU_FTRS_7447 | CPU_FTRS_7447A | CPU_FTRS_82XX | | ||
314 | CPU_FTRS_G2_LE | CPU_FTRS_E300 | CPU_FTRS_CLASSIC32 | | ||
315 | #else | ||
316 | CPU_FTRS_GENERIC_32 | | ||
317 | #endif | ||
318 | #ifdef CONFIG_PPC64BRIDGE | ||
319 | CPU_FTRS_POWER3_32 | | ||
320 | #endif | ||
321 | #ifdef CONFIG_POWER4 | ||
322 | CPU_FTRS_POWER4_32 | CPU_FTRS_970_32 | | ||
323 | #endif | ||
324 | #ifdef CONFIG_8xx | ||
325 | CPU_FTRS_8XX | | ||
326 | #endif | ||
327 | #ifdef CONFIG_40x | ||
328 | CPU_FTRS_40X | | ||
329 | #endif | ||
330 | #ifdef CONFIG_44x | ||
331 | CPU_FTRS_44X | | ||
332 | #endif | ||
333 | #ifdef CONFIG_E200 | ||
334 | CPU_FTRS_E200 | | ||
335 | #endif | ||
336 | #ifdef CONFIG_E500 | ||
337 | CPU_FTRS_E500 | CPU_FTRS_E500_2 | | ||
338 | #endif | ||
339 | #ifdef __powerpc64__ | ||
340 | CPU_FTRS_POWER3 | CPU_FTRS_RS64 | CPU_FTRS_POWER4 | | ||
341 | CPU_FTRS_PPC970 | CPU_FTRS_POWER5 | CPU_FTRS_CELL | | ||
342 | #endif | ||
343 | 0, | ||
344 | |||
345 | CPU_FTRS_ALWAYS = | ||
346 | #if CLASSIC_PPC | ||
347 | CPU_FTRS_PPC601 & CPU_FTRS_603 & CPU_FTRS_604 & CPU_FTRS_740_NOTAU & | ||
348 | CPU_FTRS_740 & CPU_FTRS_750 & CPU_FTRS_750FX1 & | ||
349 | CPU_FTRS_750FX2 & CPU_FTRS_750FX & CPU_FTRS_750GX & | ||
350 | CPU_FTRS_7400_NOTAU & CPU_FTRS_7400 & CPU_FTRS_7450_20 & | ||
351 | CPU_FTRS_7450_21 & CPU_FTRS_7450_23 & CPU_FTRS_7455_1 & | ||
352 | CPU_FTRS_7455_20 & CPU_FTRS_7455 & CPU_FTRS_7447_10 & | ||
353 | CPU_FTRS_7447 & CPU_FTRS_7447A & CPU_FTRS_82XX & | ||
354 | CPU_FTRS_G2_LE & CPU_FTRS_E300 & CPU_FTRS_CLASSIC32 & | ||
355 | #else | ||
356 | CPU_FTRS_GENERIC_32 & | ||
357 | #endif | ||
358 | #ifdef CONFIG_PPC64BRIDGE | ||
359 | CPU_FTRS_POWER3_32 & | ||
360 | #endif | ||
361 | #ifdef CONFIG_POWER4 | ||
362 | CPU_FTRS_POWER4_32 & CPU_FTRS_970_32 & | ||
363 | #endif | ||
364 | #ifdef CONFIG_8xx | ||
365 | CPU_FTRS_8XX & | ||
366 | #endif | ||
367 | #ifdef CONFIG_40x | ||
368 | CPU_FTRS_40X & | ||
369 | #endif | ||
370 | #ifdef CONFIG_44x | ||
371 | CPU_FTRS_44X & | ||
372 | #endif | ||
373 | #ifdef CONFIG_E200 | ||
374 | CPU_FTRS_E200 & | ||
375 | #endif | ||
376 | #ifdef CONFIG_E500 | ||
377 | CPU_FTRS_E500 & CPU_FTRS_E500_2 & | ||
378 | #endif | ||
379 | #ifdef __powerpc64__ | ||
380 | CPU_FTRS_POWER3 & CPU_FTRS_RS64 & CPU_FTRS_POWER4 & | ||
381 | CPU_FTRS_PPC970 & CPU_FTRS_POWER5 & CPU_FTRS_CELL & | ||
382 | #endif | ||
383 | CPU_FTRS_POSSIBLE, | ||
384 | }; | ||
385 | |||
386 | static inline int cpu_has_feature(unsigned long feature) | ||
387 | { | ||
388 | return (CPU_FTRS_ALWAYS & feature) || | ||
389 | (CPU_FTRS_POSSIBLE | ||
390 | & cur_cpu_spec->cpu_features | ||
391 | & feature); | ||
392 | } | ||
393 | |||
394 | #endif /* !__ASSEMBLY__ */ | ||
395 | |||
396 | #ifdef __ASSEMBLY__ | ||
397 | |||
398 | #define BEGIN_FTR_SECTION 98: | ||
399 | |||
400 | #ifndef __powerpc64__ | ||
401 | #define END_FTR_SECTION(msk, val) \ | ||
402 | 99: \ | ||
403 | .section __ftr_fixup,"a"; \ | ||
404 | .align 2; \ | ||
405 | .long msk; \ | ||
406 | .long val; \ | ||
407 | .long 98b; \ | ||
408 | .long 99b; \ | ||
409 | .previous | ||
410 | #else /* __powerpc64__ */ | ||
411 | #define END_FTR_SECTION(msk, val) \ | ||
412 | 99: \ | ||
413 | .section __ftr_fixup,"a"; \ | ||
414 | .align 3; \ | ||
415 | .llong msk; \ | ||
416 | .llong val; \ | ||
417 | .llong 98b; \ | ||
418 | .llong 99b; \ | ||
419 | .previous | ||
420 | #endif /* __powerpc64__ */ | ||
421 | |||
422 | #define END_FTR_SECTION_IFSET(msk) END_FTR_SECTION((msk), (msk)) | ||
423 | #define END_FTR_SECTION_IFCLR(msk) END_FTR_SECTION((msk), 0) | ||
424 | #endif /* __ASSEMBLY__ */ | ||
425 | |||
426 | #endif /* __KERNEL__ */ | ||
427 | #endif /* __ASM_POWERPC_CPUTABLE_H */ | ||
diff --git a/include/asm-powerpc/dbdma.h b/include/asm-powerpc/dbdma.h new file mode 100644 index 000000000000..8973565f95d3 --- /dev/null +++ b/include/asm-powerpc/dbdma.h | |||
@@ -0,0 +1,102 @@ | |||
1 | /* | ||
2 | * Definitions for using the Apple Descriptor-Based DMA controller | ||
3 | * in Power Macintosh computers. | ||
4 | * | ||
5 | * Copyright (C) 1996 Paul Mackerras. | ||
6 | */ | ||
7 | |||
8 | #ifdef __KERNEL__ | ||
9 | #ifndef _ASM_DBDMA_H_ | ||
10 | #define _ASM_DBDMA_H_ | ||
11 | /* | ||
12 | * DBDMA control/status registers. All little-endian. | ||
13 | */ | ||
14 | struct dbdma_regs { | ||
15 | unsigned int control; /* lets you change bits in status */ | ||
16 | unsigned int status; /* DMA and device status bits (see below) */ | ||
17 | unsigned int cmdptr_hi; /* upper 32 bits of command address */ | ||
18 | unsigned int cmdptr; /* (lower 32 bits of) command address (phys) */ | ||
19 | unsigned int intr_sel; /* select interrupt condition bit */ | ||
20 | unsigned int br_sel; /* select branch condition bit */ | ||
21 | unsigned int wait_sel; /* select wait condition bit */ | ||
22 | unsigned int xfer_mode; | ||
23 | unsigned int data2ptr_hi; | ||
24 | unsigned int data2ptr; | ||
25 | unsigned int res1; | ||
26 | unsigned int address_hi; | ||
27 | unsigned int br_addr_hi; | ||
28 | unsigned int res2[3]; | ||
29 | }; | ||
30 | |||
31 | /* Bits in control and status registers */ | ||
32 | #define RUN 0x8000 | ||
33 | #define PAUSE 0x4000 | ||
34 | #define FLUSH 0x2000 | ||
35 | #define WAKE 0x1000 | ||
36 | #define DEAD 0x0800 | ||
37 | #define ACTIVE 0x0400 | ||
38 | #define BT 0x0100 | ||
39 | #define DEVSTAT 0x00ff | ||
40 | |||
41 | /* | ||
42 | * DBDMA command structure. These fields are all little-endian! | ||
43 | */ | ||
44 | struct dbdma_cmd { | ||
45 | unsigned short req_count; /* requested byte transfer count */ | ||
46 | unsigned short command; /* command word (has bit-fields) */ | ||
47 | unsigned int phy_addr; /* physical data address */ | ||
48 | unsigned int cmd_dep; /* command-dependent field */ | ||
49 | unsigned short res_count; /* residual count after completion */ | ||
50 | unsigned short xfer_status; /* transfer status */ | ||
51 | }; | ||
52 | |||
53 | /* DBDMA command values in command field */ | ||
54 | #define OUTPUT_MORE 0 /* transfer memory data to stream */ | ||
55 | #define OUTPUT_LAST 0x1000 /* ditto followed by end marker */ | ||
56 | #define INPUT_MORE 0x2000 /* transfer stream data to memory */ | ||
57 | #define INPUT_LAST 0x3000 /* ditto, expect end marker */ | ||
58 | #define STORE_WORD 0x4000 /* write word (4 bytes) to device reg */ | ||
59 | #define LOAD_WORD 0x5000 /* read word (4 bytes) from device reg */ | ||
60 | #define DBDMA_NOP 0x6000 /* do nothing */ | ||
61 | #define DBDMA_STOP 0x7000 /* suspend processing */ | ||
62 | |||
63 | /* Key values in command field */ | ||
64 | #define KEY_STREAM0 0 /* usual data stream */ | ||
65 | #define KEY_STREAM1 0x100 /* control/status stream */ | ||
66 | #define KEY_STREAM2 0x200 /* device-dependent stream */ | ||
67 | #define KEY_STREAM3 0x300 /* device-dependent stream */ | ||
68 | #define KEY_REGS 0x500 /* device register space */ | ||
69 | #define KEY_SYSTEM 0x600 /* system memory-mapped space */ | ||
70 | #define KEY_DEVICE 0x700 /* device memory-mapped space */ | ||
71 | |||
72 | /* Interrupt control values in command field */ | ||
73 | #define INTR_NEVER 0 /* don't interrupt */ | ||
74 | #define INTR_IFSET 0x10 /* intr if condition bit is 1 */ | ||
75 | #define INTR_IFCLR 0x20 /* intr if condition bit is 0 */ | ||
76 | #define INTR_ALWAYS 0x30 /* always interrupt */ | ||
77 | |||
78 | /* Branch control values in command field */ | ||
79 | #define BR_NEVER 0 /* don't branch */ | ||
80 | #define BR_IFSET 0x4 /* branch if condition bit is 1 */ | ||
81 | #define BR_IFCLR 0x8 /* branch if condition bit is 0 */ | ||
82 | #define BR_ALWAYS 0xc /* always branch */ | ||
83 | |||
84 | /* Wait control values in command field */ | ||
85 | #define WAIT_NEVER 0 /* don't wait */ | ||
86 | #define WAIT_IFSET 1 /* wait if condition bit is 1 */ | ||
87 | #define WAIT_IFCLR 2 /* wait if condition bit is 0 */ | ||
88 | #define WAIT_ALWAYS 3 /* always wait */ | ||
89 | |||
90 | /* Align an address for a DBDMA command structure */ | ||
91 | #define DBDMA_ALIGN(x) (((unsigned long)(x) + sizeof(struct dbdma_cmd) - 1) \ | ||
92 | & -sizeof(struct dbdma_cmd)) | ||
93 | |||
94 | /* Useful macros */ | ||
95 | #define DBDMA_DO_STOP(regs) do { \ | ||
96 | out_le32(&((regs)->control), (RUN|FLUSH)<<16); \ | ||
97 | while(in_le32(&((regs)->status)) & (ACTIVE|FLUSH)) \ | ||
98 | ; \ | ||
99 | } while(0) | ||
100 | |||
101 | #endif /* _ASM_DBDMA_H_ */ | ||
102 | #endif /* __KERNEL__ */ | ||
diff --git a/include/asm-powerpc/dma.h b/include/asm-powerpc/dma.h new file mode 100644 index 000000000000..926378d2cd94 --- /dev/null +++ b/include/asm-powerpc/dma.h | |||
@@ -0,0 +1,390 @@ | |||
1 | #ifndef _ASM_POWERPC_DMA_H | ||
2 | #define _ASM_POWERPC_DMA_H | ||
3 | |||
4 | /* | ||
5 | * Defines for using and allocating dma channels. | ||
6 | * Written by Hennus Bergman, 1992. | ||
7 | * High DMA channel support & info by Hannu Savolainen | ||
8 | * and John Boyd, Nov. 1992. | ||
9 | * Changes for ppc sound by Christoph Nadig | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * Note: Adapted for PowerPC by Gary Thomas | ||
14 | * Modified by Cort Dougan <cort@cs.nmt.edu> | ||
15 | * | ||
16 | * None of this really applies for Power Macintoshes. There is | ||
17 | * basically just enough here to get kernel/dma.c to compile. | ||
18 | * | ||
19 | * There may be some comments or restrictions made here which are | ||
20 | * not valid for the PReP platform. Take what you read | ||
21 | * with a grain of salt. | ||
22 | */ | ||
23 | |||
24 | #include <linux/config.h> | ||
25 | #include <asm/io.h> | ||
26 | #include <linux/spinlock.h> | ||
27 | #include <asm/system.h> | ||
28 | |||
29 | #ifndef MAX_DMA_CHANNELS | ||
30 | #define MAX_DMA_CHANNELS 8 | ||
31 | #endif | ||
32 | |||
33 | /* The maximum address that we can perform a DMA transfer to on this platform */ | ||
34 | /* Doesn't really apply... */ | ||
35 | #define MAX_DMA_ADDRESS (~0UL) | ||
36 | |||
37 | #if !defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI) | ||
38 | |||
39 | #ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER | ||
40 | #define dma_outb outb_p | ||
41 | #else | ||
42 | #define dma_outb outb | ||
43 | #endif | ||
44 | |||
45 | #define dma_inb inb | ||
46 | |||
47 | /* | ||
48 | * NOTES about DMA transfers: | ||
49 | * | ||
50 | * controller 1: channels 0-3, byte operations, ports 00-1F | ||
51 | * controller 2: channels 4-7, word operations, ports C0-DF | ||
52 | * | ||
53 | * - ALL registers are 8 bits only, regardless of transfer size | ||
54 | * - channel 4 is not used - cascades 1 into 2. | ||
55 | * - channels 0-3 are byte - addresses/counts are for physical bytes | ||
56 | * - channels 5-7 are word - addresses/counts are for physical words | ||
57 | * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries | ||
58 | * - transfer count loaded to registers is 1 less than actual count | ||
59 | * - controller 2 offsets are all even (2x offsets for controller 1) | ||
60 | * - page registers for 5-7 don't use data bit 0, represent 128K pages | ||
61 | * - page registers for 0-3 use bit 0, represent 64K pages | ||
62 | * | ||
63 | * On PReP, DMA transfers are limited to the lower 16MB of _physical_ memory. | ||
64 | * On CHRP, the W83C553F (and VLSI Tollgate?) support full 32 bit addressing. | ||
65 | * Note that addresses loaded into registers must be _physical_ addresses, | ||
66 | * not logical addresses (which may differ if paging is active). | ||
67 | * | ||
68 | * Address mapping for channels 0-3: | ||
69 | * | ||
70 | * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses) | ||
71 | * | ... | | ... | | ... | | ||
72 | * | ... | | ... | | ... | | ||
73 | * | ... | | ... | | ... | | ||
74 | * P7 ... P0 A7 ... A0 A7 ... A0 | ||
75 | * | Page | Addr MSB | Addr LSB | (DMA registers) | ||
76 | * | ||
77 | * Address mapping for channels 5-7: | ||
78 | * | ||
79 | * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses) | ||
80 | * | ... | \ \ ... \ \ \ ... \ \ | ||
81 | * | ... | \ \ ... \ \ \ ... \ (not used) | ||
82 | * | ... | \ \ ... \ \ \ ... \ | ||
83 | * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0 | ||
84 | * | Page | Addr MSB | Addr LSB | (DMA registers) | ||
85 | * | ||
86 | * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses | ||
87 | * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at | ||
88 | * the hardware level, so odd-byte transfers aren't possible). | ||
89 | * | ||
90 | * Transfer count (_not # bytes_) is limited to 64K, represented as actual | ||
91 | * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more, | ||
92 | * and up to 128K bytes may be transferred on channels 5-7 in one operation. | ||
93 | * | ||
94 | */ | ||
95 | |||
96 | /* see prep_setup_arch() for detailed informations */ | ||
97 | #if defined(CONFIG_SOUND_CS4232) && defined(CONFIG_PPC_PREP) | ||
98 | extern long ppc_cs4232_dma, ppc_cs4232_dma2; | ||
99 | #define SND_DMA1 ppc_cs4232_dma | ||
100 | #define SND_DMA2 ppc_cs4232_dma2 | ||
101 | #else | ||
102 | #define SND_DMA1 -1 | ||
103 | #define SND_DMA2 -1 | ||
104 | #endif | ||
105 | |||
106 | /* 8237 DMA controllers */ | ||
107 | #define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ | ||
108 | #define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ | ||
109 | |||
110 | /* DMA controller registers */ | ||
111 | #define DMA1_CMD_REG 0x08 /* command register (w) */ | ||
112 | #define DMA1_STAT_REG 0x08 /* status register (r) */ | ||
113 | #define DMA1_REQ_REG 0x09 /* request register (w) */ | ||
114 | #define DMA1_MASK_REG 0x0A /* single-channel mask (w) */ | ||
115 | #define DMA1_MODE_REG 0x0B /* mode register (w) */ | ||
116 | #define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */ | ||
117 | #define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */ | ||
118 | #define DMA1_RESET_REG 0x0D /* Master Clear (w) */ | ||
119 | #define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ | ||
120 | #define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ | ||
121 | |||
122 | #define DMA2_CMD_REG 0xD0 /* command register (w) */ | ||
123 | #define DMA2_STAT_REG 0xD0 /* status register (r) */ | ||
124 | #define DMA2_REQ_REG 0xD2 /* request register (w) */ | ||
125 | #define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */ | ||
126 | #define DMA2_MODE_REG 0xD6 /* mode register (w) */ | ||
127 | #define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */ | ||
128 | #define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */ | ||
129 | #define DMA2_RESET_REG 0xDA /* Master Clear (w) */ | ||
130 | #define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ | ||
131 | #define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ | ||
132 | |||
133 | #define DMA_ADDR_0 0x00 /* DMA address registers */ | ||
134 | #define DMA_ADDR_1 0x02 | ||
135 | #define DMA_ADDR_2 0x04 | ||
136 | #define DMA_ADDR_3 0x06 | ||
137 | #define DMA_ADDR_4 0xC0 | ||
138 | #define DMA_ADDR_5 0xC4 | ||
139 | #define DMA_ADDR_6 0xC8 | ||
140 | #define DMA_ADDR_7 0xCC | ||
141 | |||
142 | #define DMA_CNT_0 0x01 /* DMA count registers */ | ||
143 | #define DMA_CNT_1 0x03 | ||
144 | #define DMA_CNT_2 0x05 | ||
145 | #define DMA_CNT_3 0x07 | ||
146 | #define DMA_CNT_4 0xC2 | ||
147 | #define DMA_CNT_5 0xC6 | ||
148 | #define DMA_CNT_6 0xCA | ||
149 | #define DMA_CNT_7 0xCE | ||
150 | |||
151 | #define DMA_LO_PAGE_0 0x87 /* DMA page registers */ | ||
152 | #define DMA_LO_PAGE_1 0x83 | ||
153 | #define DMA_LO_PAGE_2 0x81 | ||
154 | #define DMA_LO_PAGE_3 0x82 | ||
155 | #define DMA_LO_PAGE_5 0x8B | ||
156 | #define DMA_LO_PAGE_6 0x89 | ||
157 | #define DMA_LO_PAGE_7 0x8A | ||
158 | |||
159 | #define DMA_HI_PAGE_0 0x487 /* DMA page registers */ | ||
160 | #define DMA_HI_PAGE_1 0x483 | ||
161 | #define DMA_HI_PAGE_2 0x481 | ||
162 | #define DMA_HI_PAGE_3 0x482 | ||
163 | #define DMA_HI_PAGE_5 0x48B | ||
164 | #define DMA_HI_PAGE_6 0x489 | ||
165 | #define DMA_HI_PAGE_7 0x48A | ||
166 | |||
167 | #define DMA1_EXT_REG 0x40B | ||
168 | #define DMA2_EXT_REG 0x4D6 | ||
169 | |||
170 | #ifndef __powerpc64__ | ||
171 | /* in arch/ppc/kernel/setup.c -- Cort */ | ||
172 | extern unsigned int DMA_MODE_WRITE; | ||
173 | extern unsigned int DMA_MODE_READ; | ||
174 | extern unsigned long ISA_DMA_THRESHOLD; | ||
175 | #else | ||
176 | #define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ | ||
177 | #define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ | ||
178 | #endif | ||
179 | |||
180 | #define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ | ||
181 | |||
182 | #define DMA_AUTOINIT 0x10 | ||
183 | |||
184 | extern spinlock_t dma_spin_lock; | ||
185 | |||
186 | static __inline__ unsigned long claim_dma_lock(void) | ||
187 | { | ||
188 | unsigned long flags; | ||
189 | spin_lock_irqsave(&dma_spin_lock, flags); | ||
190 | return flags; | ||
191 | } | ||
192 | |||
193 | static __inline__ void release_dma_lock(unsigned long flags) | ||
194 | { | ||
195 | spin_unlock_irqrestore(&dma_spin_lock, flags); | ||
196 | } | ||
197 | |||
198 | /* enable/disable a specific DMA channel */ | ||
199 | static __inline__ void enable_dma(unsigned int dmanr) | ||
200 | { | ||
201 | unsigned char ucDmaCmd = 0x00; | ||
202 | |||
203 | if (dmanr != 4) { | ||
204 | dma_outb(0, DMA2_MASK_REG); /* This may not be enabled */ | ||
205 | dma_outb(ucDmaCmd, DMA2_CMD_REG); /* Enable group */ | ||
206 | } | ||
207 | if (dmanr <= 3) { | ||
208 | dma_outb(dmanr, DMA1_MASK_REG); | ||
209 | dma_outb(ucDmaCmd, DMA1_CMD_REG); /* Enable group */ | ||
210 | } else { | ||
211 | dma_outb(dmanr & 3, DMA2_MASK_REG); | ||
212 | } | ||
213 | } | ||
214 | |||
215 | static __inline__ void disable_dma(unsigned int dmanr) | ||
216 | { | ||
217 | if (dmanr <= 3) | ||
218 | dma_outb(dmanr | 4, DMA1_MASK_REG); | ||
219 | else | ||
220 | dma_outb((dmanr & 3) | 4, DMA2_MASK_REG); | ||
221 | } | ||
222 | |||
223 | /* Clear the 'DMA Pointer Flip Flop'. | ||
224 | * Write 0 for LSB/MSB, 1 for MSB/LSB access. | ||
225 | * Use this once to initialize the FF to a known state. | ||
226 | * After that, keep track of it. :-) | ||
227 | * --- In order to do that, the DMA routines below should --- | ||
228 | * --- only be used while interrupts are disabled! --- | ||
229 | */ | ||
230 | static __inline__ void clear_dma_ff(unsigned int dmanr) | ||
231 | { | ||
232 | if (dmanr <= 3) | ||
233 | dma_outb(0, DMA1_CLEAR_FF_REG); | ||
234 | else | ||
235 | dma_outb(0, DMA2_CLEAR_FF_REG); | ||
236 | } | ||
237 | |||
238 | /* set mode (above) for a specific DMA channel */ | ||
239 | static __inline__ void set_dma_mode(unsigned int dmanr, char mode) | ||
240 | { | ||
241 | if (dmanr <= 3) | ||
242 | dma_outb(mode | dmanr, DMA1_MODE_REG); | ||
243 | else | ||
244 | dma_outb(mode | (dmanr & 3), DMA2_MODE_REG); | ||
245 | } | ||
246 | |||
247 | /* Set only the page register bits of the transfer address. | ||
248 | * This is used for successive transfers when we know the contents of | ||
249 | * the lower 16 bits of the DMA current address register, but a 64k boundary | ||
250 | * may have been crossed. | ||
251 | */ | ||
252 | static __inline__ void set_dma_page(unsigned int dmanr, int pagenr) | ||
253 | { | ||
254 | switch (dmanr) { | ||
255 | case 0: | ||
256 | dma_outb(pagenr, DMA_LO_PAGE_0); | ||
257 | dma_outb(pagenr >> 8, DMA_HI_PAGE_0); | ||
258 | break; | ||
259 | case 1: | ||
260 | dma_outb(pagenr, DMA_LO_PAGE_1); | ||
261 | dma_outb(pagenr >> 8, DMA_HI_PAGE_1); | ||
262 | break; | ||
263 | case 2: | ||
264 | dma_outb(pagenr, DMA_LO_PAGE_2); | ||
265 | dma_outb(pagenr >> 8, DMA_HI_PAGE_2); | ||
266 | break; | ||
267 | case 3: | ||
268 | dma_outb(pagenr, DMA_LO_PAGE_3); | ||
269 | dma_outb(pagenr >> 8, DMA_HI_PAGE_3); | ||
270 | break; | ||
271 | case 5: | ||
272 | if (SND_DMA1 == 5 || SND_DMA2 == 5) | ||
273 | dma_outb(pagenr, DMA_LO_PAGE_5); | ||
274 | else | ||
275 | dma_outb(pagenr & 0xfe, DMA_LO_PAGE_5); | ||
276 | dma_outb(pagenr >> 8, DMA_HI_PAGE_5); | ||
277 | break; | ||
278 | case 6: | ||
279 | if (SND_DMA1 == 6 || SND_DMA2 == 6) | ||
280 | dma_outb(pagenr, DMA_LO_PAGE_6); | ||
281 | else | ||
282 | dma_outb(pagenr & 0xfe, DMA_LO_PAGE_6); | ||
283 | dma_outb(pagenr >> 8, DMA_HI_PAGE_6); | ||
284 | break; | ||
285 | case 7: | ||
286 | if (SND_DMA1 == 7 || SND_DMA2 == 7) | ||
287 | dma_outb(pagenr, DMA_LO_PAGE_7); | ||
288 | else | ||
289 | dma_outb(pagenr & 0xfe, DMA_LO_PAGE_7); | ||
290 | dma_outb(pagenr >> 8, DMA_HI_PAGE_7); | ||
291 | break; | ||
292 | } | ||
293 | } | ||
294 | |||
295 | /* Set transfer address & page bits for specific DMA channel. | ||
296 | * Assumes dma flipflop is clear. | ||
297 | */ | ||
298 | static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int phys) | ||
299 | { | ||
300 | if (dmanr <= 3) { | ||
301 | dma_outb(phys & 0xff, | ||
302 | ((dmanr & 3) << 1) + IO_DMA1_BASE); | ||
303 | dma_outb((phys >> 8) & 0xff, | ||
304 | ((dmanr & 3) << 1) + IO_DMA1_BASE); | ||
305 | } else if (dmanr == SND_DMA1 || dmanr == SND_DMA2) { | ||
306 | dma_outb(phys & 0xff, | ||
307 | ((dmanr & 3) << 2) + IO_DMA2_BASE); | ||
308 | dma_outb((phys >> 8) & 0xff, | ||
309 | ((dmanr & 3) << 2) + IO_DMA2_BASE); | ||
310 | dma_outb((dmanr & 3), DMA2_EXT_REG); | ||
311 | } else { | ||
312 | dma_outb((phys >> 1) & 0xff, | ||
313 | ((dmanr & 3) << 2) + IO_DMA2_BASE); | ||
314 | dma_outb((phys >> 9) & 0xff, | ||
315 | ((dmanr & 3) << 2) + IO_DMA2_BASE); | ||
316 | } | ||
317 | set_dma_page(dmanr, phys >> 16); | ||
318 | } | ||
319 | |||
320 | |||
321 | /* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for | ||
322 | * a specific DMA channel. | ||
323 | * You must ensure the parameters are valid. | ||
324 | * NOTE: from a manual: "the number of transfers is one more | ||
325 | * than the initial word count"! This is taken into account. | ||
326 | * Assumes dma flip-flop is clear. | ||
327 | * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7. | ||
328 | */ | ||
329 | static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count) | ||
330 | { | ||
331 | count--; | ||
332 | if (dmanr <= 3) { | ||
333 | dma_outb(count & 0xff, | ||
334 | ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE); | ||
335 | dma_outb((count >> 8) & 0xff, | ||
336 | ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE); | ||
337 | } else if (dmanr == SND_DMA1 || dmanr == SND_DMA2) { | ||
338 | dma_outb(count & 0xff, | ||
339 | ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE); | ||
340 | dma_outb((count >> 8) & 0xff, | ||
341 | ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE); | ||
342 | } else { | ||
343 | dma_outb((count >> 1) & 0xff, | ||
344 | ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE); | ||
345 | dma_outb((count >> 9) & 0xff, | ||
346 | ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE); | ||
347 | } | ||
348 | } | ||
349 | |||
350 | |||
351 | /* Get DMA residue count. After a DMA transfer, this | ||
352 | * should return zero. Reading this while a DMA transfer is | ||
353 | * still in progress will return unpredictable results. | ||
354 | * If called before the channel has been used, it may return 1. | ||
355 | * Otherwise, it returns the number of _bytes_ left to transfer. | ||
356 | * | ||
357 | * Assumes DMA flip-flop is clear. | ||
358 | */ | ||
359 | static __inline__ int get_dma_residue(unsigned int dmanr) | ||
360 | { | ||
361 | unsigned int io_port = (dmanr <= 3) | ||
362 | ? ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE | ||
363 | : ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE; | ||
364 | |||
365 | /* using short to get 16-bit wrap around */ | ||
366 | unsigned short count; | ||
367 | |||
368 | count = 1 + dma_inb(io_port); | ||
369 | count += dma_inb(io_port) << 8; | ||
370 | |||
371 | return (dmanr <= 3 || dmanr == SND_DMA1 || dmanr == SND_DMA2) | ||
372 | ? count : (count << 1); | ||
373 | } | ||
374 | |||
375 | /* These are in kernel/dma.c: */ | ||
376 | |||
377 | /* reserve a DMA channel */ | ||
378 | extern int request_dma(unsigned int dmanr, const char *device_id); | ||
379 | /* release it again */ | ||
380 | extern void free_dma(unsigned int dmanr); | ||
381 | |||
382 | #ifdef CONFIG_PCI | ||
383 | extern int isa_dma_bridge_buggy; | ||
384 | #else | ||
385 | #define isa_dma_bridge_buggy (0) | ||
386 | #endif | ||
387 | |||
388 | #endif /* !defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI) */ | ||
389 | |||
390 | #endif /* _ASM_POWERPC_DMA_H */ | ||
diff --git a/include/asm-powerpc/elf.h b/include/asm-powerpc/elf.h new file mode 100644 index 000000000000..d140577d0a05 --- /dev/null +++ b/include/asm-powerpc/elf.h | |||
@@ -0,0 +1,415 @@ | |||
1 | #ifndef _ASM_POWERPC_ELF_H | ||
2 | #define _ASM_POWERPC_ELF_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <asm/ptrace.h> | ||
6 | #include <asm/cputable.h> | ||
7 | #include <asm/auxvec.h> | ||
8 | #include <asm/page.h> | ||
9 | |||
10 | /* PowerPC relocations defined by the ABIs */ | ||
11 | #define R_PPC_NONE 0 | ||
12 | #define R_PPC_ADDR32 1 /* 32bit absolute address */ | ||
13 | #define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ | ||
14 | #define R_PPC_ADDR16 3 /* 16bit absolute address */ | ||
15 | #define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ | ||
16 | #define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ | ||
17 | #define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ | ||
18 | #define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ | ||
19 | #define R_PPC_ADDR14_BRTAKEN 8 | ||
20 | #define R_PPC_ADDR14_BRNTAKEN 9 | ||
21 | #define R_PPC_REL24 10 /* PC relative 26 bit */ | ||
22 | #define R_PPC_REL14 11 /* PC relative 16 bit */ | ||
23 | #define R_PPC_REL14_BRTAKEN 12 | ||
24 | #define R_PPC_REL14_BRNTAKEN 13 | ||
25 | #define R_PPC_GOT16 14 | ||
26 | #define R_PPC_GOT16_LO 15 | ||
27 | #define R_PPC_GOT16_HI 16 | ||
28 | #define R_PPC_GOT16_HA 17 | ||
29 | #define R_PPC_PLTREL24 18 | ||
30 | #define R_PPC_COPY 19 | ||
31 | #define R_PPC_GLOB_DAT 20 | ||
32 | #define R_PPC_JMP_SLOT 21 | ||
33 | #define R_PPC_RELATIVE 22 | ||
34 | #define R_PPC_LOCAL24PC 23 | ||
35 | #define R_PPC_UADDR32 24 | ||
36 | #define R_PPC_UADDR16 25 | ||
37 | #define R_PPC_REL32 26 | ||
38 | #define R_PPC_PLT32 27 | ||
39 | #define R_PPC_PLTREL32 28 | ||
40 | #define R_PPC_PLT16_LO 29 | ||
41 | #define R_PPC_PLT16_HI 30 | ||
42 | #define R_PPC_PLT16_HA 31 | ||
43 | #define R_PPC_SDAREL16 32 | ||
44 | #define R_PPC_SECTOFF 33 | ||
45 | #define R_PPC_SECTOFF_LO 34 | ||
46 | #define R_PPC_SECTOFF_HI 35 | ||
47 | #define R_PPC_SECTOFF_HA 36 | ||
48 | |||
49 | /* PowerPC relocations defined for the TLS access ABI. */ | ||
50 | #define R_PPC_TLS 67 /* none (sym+add)@tls */ | ||
51 | #define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ | ||
52 | #define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ | ||
53 | #define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ | ||
54 | #define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ | ||
55 | #define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ | ||
56 | #define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ | ||
57 | #define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ | ||
58 | #define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ | ||
59 | #define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ | ||
60 | #define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ | ||
61 | #define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ | ||
62 | #define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ | ||
63 | #define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ | ||
64 | #define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ | ||
65 | #define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ | ||
66 | #define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ | ||
67 | #define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ | ||
68 | #define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ | ||
69 | #define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ | ||
70 | #define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ | ||
71 | #define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ | ||
72 | #define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ | ||
73 | #define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ | ||
74 | #define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ | ||
75 | #define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ | ||
76 | #define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ | ||
77 | #define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ | ||
78 | |||
79 | /* keep this the last entry. */ | ||
80 | #define R_PPC_NUM 95 | ||
81 | |||
82 | /* | ||
83 | * ELF register definitions.. | ||
84 | * | ||
85 | * This program is free software; you can redistribute it and/or | ||
86 | * modify it under the terms of the GNU General Public License | ||
87 | * as published by the Free Software Foundation; either version | ||
88 | * 2 of the License, or (at your option) any later version. | ||
89 | */ | ||
90 | #include <asm/ptrace.h> | ||
91 | |||
92 | #define ELF_NGREG 48 /* includes nip, msr, lr, etc. */ | ||
93 | #define ELF_NFPREG 33 /* includes fpscr */ | ||
94 | |||
95 | typedef unsigned long elf_greg_t64; | ||
96 | typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG]; | ||
97 | |||
98 | typedef unsigned int elf_greg_t32; | ||
99 | typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG]; | ||
100 | |||
101 | /* | ||
102 | * ELF_ARCH, CLASS, and DATA are used to set parameters in the core dumps. | ||
103 | */ | ||
104 | #ifdef __powerpc64__ | ||
105 | # define ELF_NVRREG32 33 /* includes vscr & vrsave stuffed together */ | ||
106 | # define ELF_NVRREG 34 /* includes vscr & vrsave in split vectors */ | ||
107 | # define ELF_GREG_TYPE elf_greg_t64 | ||
108 | #else | ||
109 | # define ELF_NEVRREG 34 /* includes acc (as 2) */ | ||
110 | # define ELF_NVRREG 33 /* includes vscr */ | ||
111 | # define ELF_GREG_TYPE elf_greg_t32 | ||
112 | # define ELF_ARCH EM_PPC | ||
113 | # define ELF_CLASS ELFCLASS32 | ||
114 | # define ELF_DATA ELFDATA2MSB | ||
115 | #endif /* __powerpc64__ */ | ||
116 | |||
117 | #ifndef ELF_ARCH | ||
118 | # define ELF_ARCH EM_PPC64 | ||
119 | # define ELF_CLASS ELFCLASS64 | ||
120 | # define ELF_DATA ELFDATA2MSB | ||
121 | typedef elf_greg_t64 elf_greg_t; | ||
122 | typedef elf_gregset_t64 elf_gregset_t; | ||
123 | # define elf_addr_t unsigned long | ||
124 | #else | ||
125 | /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */ | ||
126 | typedef elf_greg_t32 elf_greg_t; | ||
127 | typedef elf_gregset_t32 elf_gregset_t; | ||
128 | # define elf_addr_t u32 | ||
129 | #endif /* ELF_ARCH */ | ||
130 | |||
131 | /* Floating point registers */ | ||
132 | typedef double elf_fpreg_t; | ||
133 | typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; | ||
134 | |||
135 | /* Altivec registers */ | ||
136 | /* | ||
137 | * The entries with indexes 0-31 contain the corresponding vector registers. | ||
138 | * The entry with index 32 contains the vscr as the last word (offset 12) | ||
139 | * within the quadword. This allows the vscr to be stored as either a | ||
140 | * quadword (since it must be copied via a vector register to/from storage) | ||
141 | * or as a word. | ||
142 | * | ||
143 | * 64-bit kernel notes: The entry at index 33 contains the vrsave as the first | ||
144 | * word (offset 0) within the quadword. | ||
145 | * | ||
146 | * This definition of the VMX state is compatible with the current PPC32 | ||
147 | * ptrace interface. This allows signal handling and ptrace to use the same | ||
148 | * structures. This also simplifies the implementation of a bi-arch | ||
149 | * (combined (32- and 64-bit) gdb. | ||
150 | * | ||
151 | * Note that it's _not_ compatible with 32 bits ucontext which stuffs the | ||
152 | * vrsave along with vscr and so only uses 33 vectors for the register set | ||
153 | */ | ||
154 | typedef __vector128 elf_vrreg_t; | ||
155 | typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG]; | ||
156 | #ifdef __powerpc64__ | ||
157 | typedef elf_vrreg_t elf_vrregset_t32[ELF_NVRREG32]; | ||
158 | #endif | ||
159 | |||
160 | /* | ||
161 | * This is used to ensure we don't load something for the wrong architecture. | ||
162 | */ | ||
163 | #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) | ||
164 | |||
165 | #define USE_ELF_CORE_DUMP | ||
166 | #define ELF_EXEC_PAGESIZE PAGE_SIZE | ||
167 | |||
168 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical | ||
169 | use of this is to invoke "./ld.so someprog" to test out a new version of | ||
170 | the loader. We need to make sure that it is out of the way of the program | ||
171 | that it will "exec", and that there is sufficient room for the brk. */ | ||
172 | |||
173 | #define ELF_ET_DYN_BASE (0x08000000) | ||
174 | |||
175 | #ifdef __KERNEL__ | ||
176 | |||
177 | /* Common routine for both 32-bit and 64-bit processes */ | ||
178 | static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs, | ||
179 | struct pt_regs *regs) | ||
180 | { | ||
181 | int i, nregs; | ||
182 | |||
183 | memset((void *)elf_regs, 0, sizeof(elf_gregset_t)); | ||
184 | |||
185 | /* Our registers are always unsigned longs, whether we're a 32 bit | ||
186 | * process or 64 bit, on either a 64 bit or 32 bit kernel. | ||
187 | * Don't use ELF_GREG_TYPE here. */ | ||
188 | nregs = sizeof(struct pt_regs) / sizeof(unsigned long); | ||
189 | if (nregs > ELF_NGREG) | ||
190 | nregs = ELF_NGREG; | ||
191 | |||
192 | for (i = 0; i < nregs; i++) { | ||
193 | /* This will correctly truncate 64 bit registers to 32 bits | ||
194 | * for a 32 bit process on a 64 bit kernel. */ | ||
195 | elf_regs[i] = (elf_greg_t)((ELF_GREG_TYPE *)regs)[i]; | ||
196 | } | ||
197 | } | ||
198 | #define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs); | ||
199 | |||
200 | static inline int dump_task_regs(struct task_struct *tsk, | ||
201 | elf_gregset_t *elf_regs) | ||
202 | { | ||
203 | struct pt_regs *regs = tsk->thread.regs; | ||
204 | if (regs) | ||
205 | ppc_elf_core_copy_regs(*elf_regs, regs); | ||
206 | |||
207 | return 1; | ||
208 | } | ||
209 | #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) | ||
210 | |||
211 | extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *); | ||
212 | #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) | ||
213 | |||
214 | #endif /* __KERNEL__ */ | ||
215 | |||
216 | /* ELF_HWCAP yields a mask that user programs can use to figure out what | ||
217 | instruction set this cpu supports. This could be done in userspace, | ||
218 | but it's not easy, and we've already done it here. */ | ||
219 | # define ELF_HWCAP (cur_cpu_spec->cpu_user_features) | ||
220 | #ifdef __powerpc64__ | ||
221 | # define ELF_PLAT_INIT(_r, load_addr) do { \ | ||
222 | _r->gpr[2] = load_addr; \ | ||
223 | } while (0) | ||
224 | #endif /* __powerpc64__ */ | ||
225 | |||
226 | /* This yields a string that ld.so will use to load implementation | ||
227 | specific libraries for optimization. This is more specific in | ||
228 | intent than poking at uname or /proc/cpuinfo. | ||
229 | |||
230 | For the moment, we have only optimizations for the Intel generations, | ||
231 | but that could change... */ | ||
232 | |||
233 | #define ELF_PLATFORM (NULL) | ||
234 | |||
235 | #ifdef __KERNEL__ | ||
236 | |||
237 | #ifdef __powerpc64__ | ||
238 | # define SET_PERSONALITY(ex, ibcs2) \ | ||
239 | do { \ | ||
240 | unsigned long new_flags = 0; \ | ||
241 | if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ | ||
242 | new_flags = _TIF_32BIT; \ | ||
243 | if ((current_thread_info()->flags & _TIF_32BIT) \ | ||
244 | != new_flags) \ | ||
245 | set_thread_flag(TIF_ABI_PENDING); \ | ||
246 | else \ | ||
247 | clear_thread_flag(TIF_ABI_PENDING); \ | ||
248 | if (personality(current->personality) != PER_LINUX32) \ | ||
249 | set_personality(PER_LINUX); \ | ||
250 | } while (0) | ||
251 | /* | ||
252 | * An executable for which elf_read_implies_exec() returns TRUE will | ||
253 | * have the READ_IMPLIES_EXEC personality flag set automatically. This | ||
254 | * is only required to work around bugs in old 32bit toolchains. Since | ||
255 | * the 64bit ABI has never had these issues dont enable the workaround | ||
256 | * even if we have an executable stack. | ||
257 | */ | ||
258 | # define elf_read_implies_exec(ex, exec_stk) (test_thread_flag(TIF_32BIT) ? \ | ||
259 | (exec_stk != EXSTACK_DISABLE_X) : 0) | ||
260 | #else | ||
261 | # define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) | ||
262 | #endif /* __powerpc64__ */ | ||
263 | |||
264 | #endif /* __KERNEL__ */ | ||
265 | |||
266 | extern int dcache_bsize; | ||
267 | extern int icache_bsize; | ||
268 | extern int ucache_bsize; | ||
269 | |||
270 | #ifdef __powerpc64__ | ||
271 | struct linux_binprm; | ||
272 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES /* vDSO has arch_setup_additional_pages */ | ||
273 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, int executable_stack); | ||
274 | #define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b); | ||
275 | #else | ||
276 | #define VDSO_AUX_ENT(a,b) | ||
277 | #endif /* __powerpc64__ */ | ||
278 | |||
279 | /* | ||
280 | * The requirements here are: | ||
281 | * - keep the final alignment of sp (sp & 0xf) | ||
282 | * - make sure the 32-bit value at the first 16 byte aligned position of | ||
283 | * AUXV is greater than 16 for glibc compatibility. | ||
284 | * AT_IGNOREPPC is used for that. | ||
285 | * - for compatibility with glibc ARCH_DLINFO must always be defined on PPC, | ||
286 | * even if DLINFO_ARCH_ITEMS goes to zero or is undefined. | ||
287 | */ | ||
288 | #define ARCH_DLINFO \ | ||
289 | do { \ | ||
290 | /* Handle glibc compatibility. */ \ | ||
291 | NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \ | ||
292 | NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \ | ||
293 | /* Cache size items */ \ | ||
294 | NEW_AUX_ENT(AT_DCACHEBSIZE, dcache_bsize); \ | ||
295 | NEW_AUX_ENT(AT_ICACHEBSIZE, icache_bsize); \ | ||
296 | NEW_AUX_ENT(AT_UCACHEBSIZE, ucache_bsize); \ | ||
297 | VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->thread.vdso_base) \ | ||
298 | } while (0) | ||
299 | |||
300 | /* PowerPC64 relocations defined by the ABIs */ | ||
301 | #define R_PPC64_NONE R_PPC_NONE | ||
302 | #define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address. */ | ||
303 | #define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned. */ | ||
304 | #define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address. */ | ||
305 | #define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of abs. address. */ | ||
306 | #define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of abs. address. */ | ||
307 | #define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ | ||
308 | #define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned. */ | ||
309 | #define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN | ||
310 | #define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN | ||
311 | #define R_PPC64_REL24 R_PPC_REL24 /* PC relative 26 bit, word aligned. */ | ||
312 | #define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit. */ | ||
313 | #define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN | ||
314 | #define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN | ||
315 | #define R_PPC64_GOT16 R_PPC_GOT16 | ||
316 | #define R_PPC64_GOT16_LO R_PPC_GOT16_LO | ||
317 | #define R_PPC64_GOT16_HI R_PPC_GOT16_HI | ||
318 | #define R_PPC64_GOT16_HA R_PPC_GOT16_HA | ||
319 | |||
320 | #define R_PPC64_COPY R_PPC_COPY | ||
321 | #define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT | ||
322 | #define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT | ||
323 | #define R_PPC64_RELATIVE R_PPC_RELATIVE | ||
324 | |||
325 | #define R_PPC64_UADDR32 R_PPC_UADDR32 | ||
326 | #define R_PPC64_UADDR16 R_PPC_UADDR16 | ||
327 | #define R_PPC64_REL32 R_PPC_REL32 | ||
328 | #define R_PPC64_PLT32 R_PPC_PLT32 | ||
329 | #define R_PPC64_PLTREL32 R_PPC_PLTREL32 | ||
330 | #define R_PPC64_PLT16_LO R_PPC_PLT16_LO | ||
331 | #define R_PPC64_PLT16_HI R_PPC_PLT16_HI | ||
332 | #define R_PPC64_PLT16_HA R_PPC_PLT16_HA | ||
333 | |||
334 | #define R_PPC64_SECTOFF R_PPC_SECTOFF | ||
335 | #define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO | ||
336 | #define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI | ||
337 | #define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA | ||
338 | #define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2. */ | ||
339 | #define R_PPC64_ADDR64 38 /* doubleword64 S + A. */ | ||
340 | #define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A). */ | ||
341 | #define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A). */ | ||
342 | #define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A). */ | ||
343 | #define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A). */ | ||
344 | #define R_PPC64_UADDR64 43 /* doubleword64 S + A. */ | ||
345 | #define R_PPC64_REL64 44 /* doubleword64 S + A - P. */ | ||
346 | #define R_PPC64_PLT64 45 /* doubleword64 L + A. */ | ||
347 | #define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P. */ | ||
348 | #define R_PPC64_TOC16 47 /* half16* S + A - .TOC. */ | ||
349 | #define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.). */ | ||
350 | #define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.). */ | ||
351 | #define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.). */ | ||
352 | #define R_PPC64_TOC 51 /* doubleword64 .TOC. */ | ||
353 | #define R_PPC64_PLTGOT16 52 /* half16* M + A. */ | ||
354 | #define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A). */ | ||
355 | #define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A). */ | ||
356 | #define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A). */ | ||
357 | |||
358 | #define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2. */ | ||
359 | #define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2. */ | ||
360 | #define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2. */ | ||
361 | #define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2. */ | ||
362 | #define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2. */ | ||
363 | #define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2. */ | ||
364 | #define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2. */ | ||
365 | #define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2. */ | ||
366 | #define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2. */ | ||
367 | #define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2. */ | ||
368 | #define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2. */ | ||
369 | |||
370 | /* PowerPC64 relocations defined for the TLS access ABI. */ | ||
371 | #define R_PPC64_TLS 67 /* none (sym+add)@tls */ | ||
372 | #define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ | ||
373 | #define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ | ||
374 | #define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ | ||
375 | #define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ | ||
376 | #define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ | ||
377 | #define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ | ||
378 | #define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ | ||
379 | #define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ | ||
380 | #define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ | ||
381 | #define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ | ||
382 | #define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ | ||
383 | #define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ | ||
384 | #define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ | ||
385 | #define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ | ||
386 | #define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ | ||
387 | #define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ | ||
388 | #define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ | ||
389 | #define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ | ||
390 | #define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ | ||
391 | #define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ | ||
392 | #define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ | ||
393 | #define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ | ||
394 | #define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ | ||
395 | #define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ | ||
396 | #define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ | ||
397 | #define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ | ||
398 | #define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ | ||
399 | #define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ | ||
400 | #define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ | ||
401 | #define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ | ||
402 | #define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ | ||
403 | #define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ | ||
404 | #define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ | ||
405 | #define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ | ||
406 | #define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ | ||
407 | #define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ | ||
408 | #define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ | ||
409 | #define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ | ||
410 | #define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ | ||
411 | |||
412 | /* Keep this the last entry. */ | ||
413 | #define R_PPC64_NUM 107 | ||
414 | |||
415 | #endif /* _ASM_POWERPC_ELF_H */ | ||
diff --git a/include/asm-powerpc/firmware.h b/include/asm-powerpc/firmware.h new file mode 100644 index 000000000000..806c142ae9ea --- /dev/null +++ b/include/asm-powerpc/firmware.h | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org) | ||
3 | * | ||
4 | * Modifications for ppc64: | ||
5 | * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | #ifndef __ASM_POWERPC_FIRMWARE_H | ||
13 | #define __ASM_POWERPC_FIRMWARE_H | ||
14 | |||
15 | #ifdef __KERNEL__ | ||
16 | |||
17 | #ifndef __ASSEMBLY__ | ||
18 | |||
19 | /* firmware feature bitmask values */ | ||
20 | #define FIRMWARE_MAX_FEATURES 63 | ||
21 | |||
22 | #define FW_FEATURE_PFT (1UL<<0) | ||
23 | #define FW_FEATURE_TCE (1UL<<1) | ||
24 | #define FW_FEATURE_SPRG0 (1UL<<2) | ||
25 | #define FW_FEATURE_DABR (1UL<<3) | ||
26 | #define FW_FEATURE_COPY (1UL<<4) | ||
27 | #define FW_FEATURE_ASR (1UL<<5) | ||
28 | #define FW_FEATURE_DEBUG (1UL<<6) | ||
29 | #define FW_FEATURE_TERM (1UL<<7) | ||
30 | #define FW_FEATURE_PERF (1UL<<8) | ||
31 | #define FW_FEATURE_DUMP (1UL<<9) | ||
32 | #define FW_FEATURE_INTERRUPT (1UL<<10) | ||
33 | #define FW_FEATURE_MIGRATE (1UL<<11) | ||
34 | #define FW_FEATURE_PERFMON (1UL<<12) | ||
35 | #define FW_FEATURE_CRQ (1UL<<13) | ||
36 | #define FW_FEATURE_VIO (1UL<<14) | ||
37 | #define FW_FEATURE_RDMA (1UL<<15) | ||
38 | #define FW_FEATURE_LLAN (1UL<<16) | ||
39 | #define FW_FEATURE_BULK (1UL<<17) | ||
40 | #define FW_FEATURE_XDABR (1UL<<18) | ||
41 | #define FW_FEATURE_MULTITCE (1UL<<19) | ||
42 | #define FW_FEATURE_SPLPAR (1UL<<20) | ||
43 | #define FW_FEATURE_ISERIES (1UL<<21) | ||
44 | |||
45 | enum { | ||
46 | FW_FEATURE_PSERIES_POSSIBLE = FW_FEATURE_PFT | FW_FEATURE_TCE | | ||
47 | FW_FEATURE_SPRG0 | FW_FEATURE_DABR | FW_FEATURE_COPY | | ||
48 | FW_FEATURE_ASR | FW_FEATURE_DEBUG | FW_FEATURE_TERM | | ||
49 | FW_FEATURE_PERF | FW_FEATURE_DUMP | FW_FEATURE_INTERRUPT | | ||
50 | FW_FEATURE_MIGRATE | FW_FEATURE_PERFMON | FW_FEATURE_CRQ | | ||
51 | FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN | | ||
52 | FW_FEATURE_BULK | FW_FEATURE_XDABR | FW_FEATURE_MULTITCE | | ||
53 | FW_FEATURE_SPLPAR, | ||
54 | FW_FEATURE_PSERIES_ALWAYS = 0, | ||
55 | FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES, | ||
56 | FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES, | ||
57 | FW_FEATURE_POSSIBLE = | ||
58 | #ifdef CONFIG_PPC_PSERIES | ||
59 | FW_FEATURE_PSERIES_POSSIBLE | | ||
60 | #endif | ||
61 | #ifdef CONFIG_PPC_ISERIES | ||
62 | FW_FEATURE_ISERIES_POSSIBLE | | ||
63 | #endif | ||
64 | 0, | ||
65 | FW_FEATURE_ALWAYS = | ||
66 | #ifdef CONFIG_PPC_PSERIES | ||
67 | FW_FEATURE_PSERIES_ALWAYS & | ||
68 | #endif | ||
69 | #ifdef CONFIG_PPC_ISERIES | ||
70 | FW_FEATURE_ISERIES_ALWAYS & | ||
71 | #endif | ||
72 | FW_FEATURE_POSSIBLE, | ||
73 | }; | ||
74 | |||
75 | /* This is used to identify firmware features which are available | ||
76 | * to the kernel. | ||
77 | */ | ||
78 | extern unsigned long ppc64_firmware_features; | ||
79 | |||
80 | static inline unsigned long firmware_has_feature(unsigned long feature) | ||
81 | { | ||
82 | return (FW_FEATURE_ALWAYS & feature) || | ||
83 | (FW_FEATURE_POSSIBLE & ppc64_firmware_features & feature); | ||
84 | } | ||
85 | |||
86 | #ifdef CONFIG_PPC_PSERIES | ||
87 | typedef struct { | ||
88 | unsigned long val; | ||
89 | char * name; | ||
90 | } firmware_feature_t; | ||
91 | |||
92 | extern firmware_feature_t firmware_features_table[]; | ||
93 | #endif | ||
94 | |||
95 | #endif /* __ASSEMBLY__ */ | ||
96 | #endif /* __KERNEL__ */ | ||
97 | #endif /* __ASM_POWERPC_FIRMWARE_H */ | ||
diff --git a/include/asm-powerpc/futex.h b/include/asm-powerpc/futex.h new file mode 100644 index 000000000000..37c94e52ab6d --- /dev/null +++ b/include/asm-powerpc/futex.h | |||
@@ -0,0 +1,84 @@ | |||
1 | #ifndef _ASM_POWERPC_FUTEX_H | ||
2 | #define _ASM_POWERPC_FUTEX_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | #include <linux/futex.h> | ||
7 | #include <asm/errno.h> | ||
8 | #include <asm/synch.h> | ||
9 | #include <asm/uaccess.h> | ||
10 | #include <asm/ppc_asm.h> | ||
11 | |||
12 | #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ | ||
13 | __asm__ __volatile ( \ | ||
14 | SYNC_ON_SMP \ | ||
15 | "1: lwarx %0,0,%2\n" \ | ||
16 | insn \ | ||
17 | "2: stwcx. %1,0,%2\n" \ | ||
18 | "bne- 1b\n" \ | ||
19 | "li %1,0\n" \ | ||
20 | "3: .section .fixup,\"ax\"\n" \ | ||
21 | "4: li %1,%3\n" \ | ||
22 | "b 3b\n" \ | ||
23 | ".previous\n" \ | ||
24 | ".section __ex_table,\"a\"\n" \ | ||
25 | ".align 3\n" \ | ||
26 | DATAL " 1b,4b,2b,4b\n" \ | ||
27 | ".previous" \ | ||
28 | : "=&r" (oldval), "=&r" (ret) \ | ||
29 | : "b" (uaddr), "i" (-EFAULT), "1" (oparg) \ | ||
30 | : "cr0", "memory") | ||
31 | |||
32 | static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | ||
33 | { | ||
34 | int op = (encoded_op >> 28) & 7; | ||
35 | int cmp = (encoded_op >> 24) & 15; | ||
36 | int oparg = (encoded_op << 8) >> 20; | ||
37 | int cmparg = (encoded_op << 20) >> 20; | ||
38 | int oldval = 0, ret; | ||
39 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | ||
40 | oparg = 1 << oparg; | ||
41 | |||
42 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) | ||
43 | return -EFAULT; | ||
44 | |||
45 | inc_preempt_count(); | ||
46 | |||
47 | switch (op) { | ||
48 | case FUTEX_OP_SET: | ||
49 | __futex_atomic_op("", ret, oldval, uaddr, oparg); | ||
50 | break; | ||
51 | case FUTEX_OP_ADD: | ||
52 | __futex_atomic_op("add %1,%0,%1\n", ret, oldval, uaddr, oparg); | ||
53 | break; | ||
54 | case FUTEX_OP_OR: | ||
55 | __futex_atomic_op("or %1,%0,%1\n", ret, oldval, uaddr, oparg); | ||
56 | break; | ||
57 | case FUTEX_OP_ANDN: | ||
58 | __futex_atomic_op("andc %1,%0,%1\n", ret, oldval, uaddr, oparg); | ||
59 | break; | ||
60 | case FUTEX_OP_XOR: | ||
61 | __futex_atomic_op("xor %1,%0,%1\n", ret, oldval, uaddr, oparg); | ||
62 | break; | ||
63 | default: | ||
64 | ret = -ENOSYS; | ||
65 | } | ||
66 | |||
67 | dec_preempt_count(); | ||
68 | |||
69 | if (!ret) { | ||
70 | switch (cmp) { | ||
71 | case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break; | ||
72 | case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break; | ||
73 | case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break; | ||
74 | case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break; | ||
75 | case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break; | ||
76 | case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break; | ||
77 | default: ret = -ENOSYS; | ||
78 | } | ||
79 | } | ||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | #endif /* __KERNEL__ */ | ||
84 | #endif /* _ASM_POWERPC_FUTEX_H */ | ||
diff --git a/include/asm-powerpc/grackle.h b/include/asm-powerpc/grackle.h new file mode 100644 index 000000000000..563c7a5e64c9 --- /dev/null +++ b/include/asm-powerpc/grackle.h | |||
@@ -0,0 +1,7 @@ | |||
1 | /* | ||
2 | * Functions for setting up and using a MPC106 northbridge | ||
3 | */ | ||
4 | |||
5 | #include <asm/pci-bridge.h> | ||
6 | |||
7 | extern void setup_grackle(struct pci_controller *hose); | ||
diff --git a/include/asm-powerpc/hardirq.h b/include/asm-powerpc/hardirq.h new file mode 100644 index 000000000000..3b3e3b49ec12 --- /dev/null +++ b/include/asm-powerpc/hardirq.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef _ASM_POWERPC_HARDIRQ_H | ||
2 | #define _ASM_POWERPC_HARDIRQ_H | ||
3 | |||
4 | #include <asm/irq.h> | ||
5 | #include <asm/bug.h> | ||
6 | |||
7 | /* The __last_jiffy_stamp field is needed to ensure that no decrementer | ||
8 | * interrupt is lost on SMP machines. Since on most CPUs it is in the same | ||
9 | * cache line as local_irq_count, it is cheap to access and is also used on UP | ||
10 | * for uniformity. | ||
11 | */ | ||
12 | typedef struct { | ||
13 | unsigned int __softirq_pending; /* set_bit is used on this */ | ||
14 | unsigned int __last_jiffy_stamp; | ||
15 | } ____cacheline_aligned irq_cpustat_t; | ||
16 | |||
17 | #include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ | ||
18 | |||
19 | #define last_jiffy_stamp(cpu) __IRQ_STAT((cpu), __last_jiffy_stamp) | ||
20 | |||
21 | static inline void ack_bad_irq(int irq) | ||
22 | { | ||
23 | printk(KERN_CRIT "illegal vector %d received!\n", irq); | ||
24 | BUG(); | ||
25 | } | ||
26 | |||
27 | #endif /* _ASM_POWERPC_HARDIRQ_H */ | ||
diff --git a/include/asm-powerpc/heathrow.h b/include/asm-powerpc/heathrow.h new file mode 100644 index 000000000000..22ac179856b9 --- /dev/null +++ b/include/asm-powerpc/heathrow.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * heathrow.h: definitions for using the "Heathrow" I/O controller chip. | ||
3 | * | ||
4 | * Grabbed from Open Firmware definitions on a PowerBook G3 Series | ||
5 | * | ||
6 | * Copyright (C) 1997 Paul Mackerras. | ||
7 | */ | ||
8 | |||
9 | /* Front light color on Yikes/B&W G3. 32 bits */ | ||
10 | #define HEATHROW_FRONT_LIGHT 0x32 /* (set to 0 or 0xffffffff) */ | ||
11 | |||
12 | /* Brightness/contrast (gossamer iMac ?). 8 bits */ | ||
13 | #define HEATHROW_BRIGHTNESS_CNTL 0x32 | ||
14 | #define HEATHROW_CONTRAST_CNTL 0x33 | ||
15 | |||
16 | /* offset from ohare base for feature control register */ | ||
17 | #define HEATHROW_MBCR 0x34 /* Media bay control */ | ||
18 | #define HEATHROW_FCR 0x38 /* Feature control */ | ||
19 | #define HEATHROW_AUX_CNTL_REG 0x3c /* Aux control */ | ||
20 | |||
21 | /* | ||
22 | * Bits in feature control register. | ||
23 | * Bits postfixed with a _N are in inverse logic | ||
24 | */ | ||
25 | #define HRW_SCC_TRANS_EN_N 0x00000001 /* Also controls modem power */ | ||
26 | #define HRW_BAY_POWER_N 0x00000002 | ||
27 | #define HRW_BAY_PCI_ENABLE 0x00000004 | ||
28 | #define HRW_BAY_IDE_ENABLE 0x00000008 | ||
29 | #define HRW_BAY_FLOPPY_ENABLE 0x00000010 | ||
30 | #define HRW_IDE0_ENABLE 0x00000020 | ||
31 | #define HRW_IDE0_RESET_N 0x00000040 | ||
32 | #define HRW_BAY_DEV_MASK 0x0000001c | ||
33 | #define HRW_BAY_RESET_N 0x00000080 | ||
34 | #define HRW_IOBUS_ENABLE 0x00000100 /* Internal IDE ? */ | ||
35 | #define HRW_SCC_ENABLE 0x00000200 | ||
36 | #define HRW_MESH_ENABLE 0x00000400 | ||
37 | #define HRW_SWIM_ENABLE 0x00000800 | ||
38 | #define HRW_SOUND_POWER_N 0x00001000 | ||
39 | #define HRW_SOUND_CLK_ENABLE 0x00002000 | ||
40 | #define HRW_SCCA_IO 0x00004000 | ||
41 | #define HRW_SCCB_IO 0x00008000 | ||
42 | #define HRW_PORT_OR_DESK_VIA_N 0x00010000 /* This one is 0 on PowerBook */ | ||
43 | #define HRW_PWM_MON_ID_N 0x00020000 /* ??? (0) */ | ||
44 | #define HRW_HOOK_MB_CNT_N 0x00040000 /* ??? (0) */ | ||
45 | #define HRW_SWIM_CLONE_FLOPPY 0x00080000 /* ??? (0) */ | ||
46 | #define HRW_AUD_RUN22 0x00100000 /* ??? (1) */ | ||
47 | #define HRW_SCSI_LINK_MODE 0x00200000 /* Read ??? (1) */ | ||
48 | #define HRW_ARB_BYPASS 0x00400000 /* Disable internal PCI arbitrer */ | ||
49 | #define HRW_IDE1_RESET_N 0x00800000 /* Media bay */ | ||
50 | #define HRW_SLOW_SCC_PCLK 0x01000000 /* ??? (0) */ | ||
51 | #define HRW_RESET_SCC 0x02000000 | ||
52 | #define HRW_MFDC_CELL_ENABLE 0x04000000 /* ??? (0) */ | ||
53 | #define HRW_USE_MFDC 0x08000000 /* ??? (0) */ | ||
54 | #define HRW_BMAC_IO_ENABLE 0x60000000 /* two bits, not documented in OF */ | ||
55 | #define HRW_BMAC_RESET 0x80000000 /* not documented in OF */ | ||
56 | |||
57 | /* We OR those features at boot on desktop G3s */ | ||
58 | #define HRW_DEFAULTS (HRW_SCCA_IO | HRW_SCCB_IO | HRW_SCC_ENABLE) | ||
59 | |||
60 | /* Looks like Heathrow has some sort of GPIOs as well... */ | ||
61 | #define HRW_GPIO_MODEM_RESET 0x6d | ||
62 | |||
diff --git a/include/asm-powerpc/hw_irq.h b/include/asm-powerpc/hw_irq.h new file mode 100644 index 000000000000..c37b31b96337 --- /dev/null +++ b/include/asm-powerpc/hw_irq.h | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu> | ||
3 | */ | ||
4 | #ifndef _ASM_POWERPC_HW_IRQ_H | ||
5 | #define _ASM_POWERPC_HW_IRQ_H | ||
6 | |||
7 | #ifdef __KERNEL__ | ||
8 | |||
9 | #include <linux/config.h> | ||
10 | #include <linux/errno.h> | ||
11 | #include <asm/ptrace.h> | ||
12 | #include <asm/processor.h> | ||
13 | |||
14 | extern void timer_interrupt(struct pt_regs *); | ||
15 | extern void ppc_irq_dispatch_handler(struct pt_regs *regs, int irq); | ||
16 | |||
17 | #ifdef CONFIG_PPC_ISERIES | ||
18 | |||
19 | extern unsigned long local_get_flags(void); | ||
20 | extern unsigned long local_irq_disable(void); | ||
21 | extern void local_irq_restore(unsigned long); | ||
22 | |||
23 | #define local_irq_enable() local_irq_restore(1) | ||
24 | #define local_save_flags(flags) ((flags) = local_get_flags()) | ||
25 | #define local_irq_save(flags) ((flags) = local_irq_disable()) | ||
26 | |||
27 | #define irqs_disabled() (local_get_flags() == 0) | ||
28 | |||
29 | #else | ||
30 | |||
31 | #if defined(CONFIG_BOOKE) | ||
32 | #define SET_MSR_EE(x) mtmsr(x) | ||
33 | #define local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory") | ||
34 | #elif defined(__powerpc64__) | ||
35 | #define SET_MSR_EE(x) __mtmsrd(x, 1) | ||
36 | #define local_irq_restore(flags) do { \ | ||
37 | __asm__ __volatile__("": : :"memory"); \ | ||
38 | __mtmsrd((flags), 1); \ | ||
39 | } while(0) | ||
40 | #else | ||
41 | #define SET_MSR_EE(x) mtmsr(x) | ||
42 | #define local_irq_restore(flags) mtmsr(flags) | ||
43 | #endif | ||
44 | |||
45 | static inline void local_irq_disable(void) | ||
46 | { | ||
47 | #ifdef CONFIG_BOOKE | ||
48 | __asm__ __volatile__("wrteei 0": : :"memory"); | ||
49 | #else | ||
50 | unsigned long msr; | ||
51 | __asm__ __volatile__("": : :"memory"); | ||
52 | msr = mfmsr(); | ||
53 | SET_MSR_EE(msr & ~MSR_EE); | ||
54 | #endif | ||
55 | } | ||
56 | |||
57 | static inline void local_irq_enable(void) | ||
58 | { | ||
59 | #ifdef CONFIG_BOOKE | ||
60 | __asm__ __volatile__("wrteei 1": : :"memory"); | ||
61 | #else | ||
62 | unsigned long msr; | ||
63 | __asm__ __volatile__("": : :"memory"); | ||
64 | msr = mfmsr(); | ||
65 | SET_MSR_EE(msr | MSR_EE); | ||
66 | #endif | ||
67 | } | ||
68 | |||
69 | static inline void local_irq_save_ptr(unsigned long *flags) | ||
70 | { | ||
71 | unsigned long msr; | ||
72 | msr = mfmsr(); | ||
73 | *flags = msr; | ||
74 | #ifdef CONFIG_BOOKE | ||
75 | __asm__ __volatile__("wrteei 0": : :"memory"); | ||
76 | #else | ||
77 | SET_MSR_EE(msr & ~MSR_EE); | ||
78 | #endif | ||
79 | __asm__ __volatile__("": : :"memory"); | ||
80 | } | ||
81 | |||
82 | #define local_save_flags(flags) ((flags) = mfmsr()) | ||
83 | #define local_irq_save(flags) local_irq_save_ptr(&flags) | ||
84 | #define irqs_disabled() ((mfmsr() & MSR_EE) == 0) | ||
85 | |||
86 | #endif /* CONFIG_PPC_ISERIES */ | ||
87 | |||
88 | #define mask_irq(irq) \ | ||
89 | ({ \ | ||
90 | irq_desc_t *desc = get_irq_desc(irq); \ | ||
91 | if (desc->handler && desc->handler->disable) \ | ||
92 | desc->handler->disable(irq); \ | ||
93 | }) | ||
94 | #define unmask_irq(irq) \ | ||
95 | ({ \ | ||
96 | irq_desc_t *desc = get_irq_desc(irq); \ | ||
97 | if (desc->handler && desc->handler->enable) \ | ||
98 | desc->handler->enable(irq); \ | ||
99 | }) | ||
100 | #define ack_irq(irq) \ | ||
101 | ({ \ | ||
102 | irq_desc_t *desc = get_irq_desc(irq); \ | ||
103 | if (desc->handler && desc->handler->ack) \ | ||
104 | desc->handler->ack(irq); \ | ||
105 | }) | ||
106 | |||
107 | /* Should we handle this via lost interrupts and IPIs or should we don't care like | ||
108 | * we do now ? --BenH. | ||
109 | */ | ||
110 | struct hw_interrupt_type; | ||
111 | static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {} | ||
112 | |||
113 | #endif /* __KERNEL__ */ | ||
114 | #endif /* _ASM_POWERPC_HW_IRQ_H */ | ||
diff --git a/include/asm-powerpc/i8259.h b/include/asm-powerpc/i8259.h new file mode 100644 index 000000000000..fc4bfee124d7 --- /dev/null +++ b/include/asm-powerpc/i8259.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _ASM_POWERPC_I8259_H | ||
2 | #define _ASM_POWERPC_I8259_H | ||
3 | |||
4 | #include <linux/irq.h> | ||
5 | |||
6 | extern struct hw_interrupt_type i8259_pic; | ||
7 | |||
8 | extern void i8259_init(unsigned long intack_addr, int offset); | ||
9 | extern int i8259_irq(struct pt_regs *regs); | ||
10 | extern int i8259_irq_cascade(struct pt_regs *regs, void *unused); | ||
11 | |||
12 | #endif /* _ASM_POWERPC_I8259_H */ | ||
diff --git a/include/asm-powerpc/ioctls.h b/include/asm-powerpc/ioctls.h index 5b94ff489b8b..279a6229584b 100644 --- a/include/asm-powerpc/ioctls.h +++ b/include/asm-powerpc/ioctls.h | |||
@@ -62,6 +62,9 @@ | |||
62 | # define TIOCM_DSR 0x100 | 62 | # define TIOCM_DSR 0x100 |
63 | # define TIOCM_CD TIOCM_CAR | 63 | # define TIOCM_CD TIOCM_CAR |
64 | # define TIOCM_RI TIOCM_RNG | 64 | # define TIOCM_RI TIOCM_RNG |
65 | #define TIOCM_OUT1 0x2000 | ||
66 | #define TIOCM_OUT2 0x4000 | ||
67 | #define TIOCM_LOOP 0x8000 | ||
65 | 68 | ||
66 | #define TIOCGSOFTCAR 0x5419 | 69 | #define TIOCGSOFTCAR 0x5419 |
67 | #define TIOCSSOFTCAR 0x541A | 70 | #define TIOCSSOFTCAR 0x541A |
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h new file mode 100644 index 000000000000..9d91bdd667ae --- /dev/null +++ b/include/asm-powerpc/iommu.h | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation | ||
3 | * Rewrite, cleanup: | ||
4 | * Copyright (C) 2004 Olof Johansson <olof@austin.ibm.com>, IBM Corporation | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef _ASM_IOMMU_H | ||
22 | #define _ASM_IOMMU_H | ||
23 | |||
24 | #include <linux/config.h> | ||
25 | #include <asm/types.h> | ||
26 | #include <linux/spinlock.h> | ||
27 | #include <linux/device.h> | ||
28 | #include <linux/dma-mapping.h> | ||
29 | |||
30 | /* | ||
31 | * IOMAP_MAX_ORDER defines the largest contiguous block | ||
32 | * of dma space we can get. IOMAP_MAX_ORDER = 13 | ||
33 | * allows up to 2**12 pages (4096 * 4096) = 16 MB | ||
34 | */ | ||
35 | #define IOMAP_MAX_ORDER 13 | ||
36 | |||
37 | struct iommu_table { | ||
38 | unsigned long it_busno; /* Bus number this table belongs to */ | ||
39 | unsigned long it_size; /* Size of iommu table in entries */ | ||
40 | unsigned long it_offset; /* Offset into global table */ | ||
41 | unsigned long it_base; /* mapped address of tce table */ | ||
42 | unsigned long it_index; /* which iommu table this is */ | ||
43 | unsigned long it_type; /* type: PCI or Virtual Bus */ | ||
44 | unsigned long it_blocksize; /* Entries in each block (cacheline) */ | ||
45 | unsigned long it_hint; /* Hint for next alloc */ | ||
46 | unsigned long it_largehint; /* Hint for large allocs */ | ||
47 | unsigned long it_halfpoint; /* Breaking point for small/large allocs */ | ||
48 | spinlock_t it_lock; /* Protects it_map */ | ||
49 | unsigned long *it_map; /* A simple allocation bitmap for now */ | ||
50 | }; | ||
51 | |||
52 | struct scatterlist; | ||
53 | struct device_node; | ||
54 | |||
55 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
56 | |||
57 | /* Walks all buses and creates iommu tables */ | ||
58 | extern void iommu_setup_pSeries(void); | ||
59 | extern void iommu_setup_u3(void); | ||
60 | |||
61 | /* Frees table for an individual device node */ | ||
62 | extern void iommu_free_table(struct device_node *dn); | ||
63 | |||
64 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | ||
65 | |||
66 | #ifdef CONFIG_PPC_PSERIES | ||
67 | |||
68 | /* Creates table for an individual device node */ | ||
69 | extern void iommu_devnode_init_pSeries(struct device_node *dn); | ||
70 | |||
71 | #endif /* CONFIG_PPC_PSERIES */ | ||
72 | |||
73 | #ifdef CONFIG_PPC_ISERIES | ||
74 | |||
75 | /* Creates table for an individual device node */ | ||
76 | extern void iommu_devnode_init_iSeries(struct device_node *dn); | ||
77 | |||
78 | #endif /* CONFIG_PPC_ISERIES */ | ||
79 | |||
80 | /* Initializes an iommu_table based in values set in the passed-in | ||
81 | * structure | ||
82 | */ | ||
83 | extern struct iommu_table *iommu_init_table(struct iommu_table * tbl); | ||
84 | |||
85 | extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl, | ||
86 | struct scatterlist *sglist, int nelems, | ||
87 | enum dma_data_direction direction); | ||
88 | extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist, | ||
89 | int nelems, enum dma_data_direction direction); | ||
90 | |||
91 | extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size, | ||
92 | dma_addr_t *dma_handle, gfp_t flag); | ||
93 | extern void iommu_free_coherent(struct iommu_table *tbl, size_t size, | ||
94 | void *vaddr, dma_addr_t dma_handle); | ||
95 | extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr, | ||
96 | size_t size, enum dma_data_direction direction); | ||
97 | extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle, | ||
98 | size_t size, enum dma_data_direction direction); | ||
99 | |||
100 | extern void iommu_init_early_pSeries(void); | ||
101 | extern void iommu_init_early_iSeries(void); | ||
102 | extern void iommu_init_early_u3(void); | ||
103 | |||
104 | #ifdef CONFIG_PCI | ||
105 | extern void pci_iommu_init(void); | ||
106 | extern void pci_direct_iommu_init(void); | ||
107 | #else | ||
108 | static inline void pci_iommu_init(void) { } | ||
109 | #endif | ||
110 | |||
111 | extern void alloc_u3_dart_table(void); | ||
112 | |||
113 | #endif /* _ASM_IOMMU_H */ | ||
diff --git a/include/asm-powerpc/ipcbuf.h b/include/asm-powerpc/ipcbuf.h new file mode 100644 index 000000000000..2c3e1d94db1d --- /dev/null +++ b/include/asm-powerpc/ipcbuf.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef _ASM_POWERPC_IPCBUF_H | ||
2 | #define _ASM_POWERPC_IPCBUF_H | ||
3 | |||
4 | /* | ||
5 | * The ipc64_perm structure for the powerpc is identical to | ||
6 | * kern_ipc_perm as we have always had 32-bit UIDs and GIDs in the | ||
7 | * kernel. Note extra padding because this structure is passed back | ||
8 | * and forth between kernel and user space. Pad space is left for: | ||
9 | * - 1 32-bit value to fill up for 8-byte alignment | ||
10 | * - 2 miscellaneous 64-bit values | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version | ||
15 | * 2 of the License, or (at your option) any later version. | ||
16 | */ | ||
17 | |||
18 | #include <linux/types.h> | ||
19 | |||
20 | struct ipc64_perm | ||
21 | { | ||
22 | __kernel_key_t key; | ||
23 | __kernel_uid_t uid; | ||
24 | __kernel_gid_t gid; | ||
25 | __kernel_uid_t cuid; | ||
26 | __kernel_gid_t cgid; | ||
27 | __kernel_mode_t mode; | ||
28 | unsigned int seq; | ||
29 | unsigned int __pad1; | ||
30 | unsigned long long __unused1; | ||
31 | unsigned long long __unused2; | ||
32 | }; | ||
33 | |||
34 | #endif /* _ASM_POWERPC_IPCBUF_H */ | ||
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h new file mode 100644 index 000000000000..b3935ea28fff --- /dev/null +++ b/include/asm-powerpc/irq.h | |||
@@ -0,0 +1,504 @@ | |||
1 | #ifdef __KERNEL__ | ||
2 | #ifndef _ASM_POWERPC_IRQ_H | ||
3 | #define _ASM_POWERPC_IRQ_H | ||
4 | |||
5 | /* | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/config.h> | ||
13 | #include <linux/threads.h> | ||
14 | |||
15 | #include <asm/types.h> | ||
16 | #include <asm/atomic.h> | ||
17 | |||
18 | /* this number is used when no interrupt has been assigned */ | ||
19 | #define NO_IRQ (-1) | ||
20 | |||
21 | /* | ||
22 | * These constants are used for passing information about interrupt | ||
23 | * signal polarity and level/edge sensing to the low-level PIC chip | ||
24 | * drivers. | ||
25 | */ | ||
26 | #define IRQ_SENSE_MASK 0x1 | ||
27 | #define IRQ_SENSE_LEVEL 0x1 /* interrupt on active level */ | ||
28 | #define IRQ_SENSE_EDGE 0x0 /* interrupt triggered by edge */ | ||
29 | |||
30 | #define IRQ_POLARITY_MASK 0x2 | ||
31 | #define IRQ_POLARITY_POSITIVE 0x2 /* high level or low->high edge */ | ||
32 | #define IRQ_POLARITY_NEGATIVE 0x0 /* low level or high->low edge */ | ||
33 | |||
34 | /* | ||
35 | * IRQ line status macro IRQ_PER_CPU is used | ||
36 | */ | ||
37 | #define ARCH_HAS_IRQ_PER_CPU | ||
38 | |||
39 | #define get_irq_desc(irq) (&irq_desc[(irq)]) | ||
40 | |||
41 | /* Define a way to iterate across irqs. */ | ||
42 | #define for_each_irq(i) \ | ||
43 | for ((i) = 0; (i) < NR_IRQS; ++(i)) | ||
44 | |||
45 | #ifdef CONFIG_PPC64 | ||
46 | |||
47 | /* | ||
48 | * Maximum number of interrupt sources that we can handle. | ||
49 | */ | ||
50 | #define NR_IRQS 512 | ||
51 | |||
52 | /* Interrupt numbers are virtual in case they are sparsely | ||
53 | * distributed by the hardware. | ||
54 | */ | ||
55 | extern unsigned int virt_irq_to_real_map[NR_IRQS]; | ||
56 | |||
57 | /* Create a mapping for a real_irq if it doesn't already exist. | ||
58 | * Return the virtual irq as a convenience. | ||
59 | */ | ||
60 | int virt_irq_create_mapping(unsigned int real_irq); | ||
61 | void virt_irq_init(void); | ||
62 | |||
63 | static inline unsigned int virt_irq_to_real(unsigned int virt_irq) | ||
64 | { | ||
65 | return virt_irq_to_real_map[virt_irq]; | ||
66 | } | ||
67 | |||
68 | extern unsigned int real_irq_to_virt_slowpath(unsigned int real_irq); | ||
69 | |||
70 | /* | ||
71 | * List of interrupt controllers. | ||
72 | */ | ||
73 | #define IC_INVALID 0 | ||
74 | #define IC_OPEN_PIC 1 | ||
75 | #define IC_PPC_XIC 2 | ||
76 | #define IC_CELL_PIC 3 | ||
77 | #define IC_ISERIES 4 | ||
78 | |||
79 | extern u64 ppc64_interrupt_controller; | ||
80 | |||
81 | #else /* 32-bit */ | ||
82 | |||
83 | #if defined(CONFIG_40x) | ||
84 | #include <asm/ibm4xx.h> | ||
85 | |||
86 | #ifndef NR_BOARD_IRQS | ||
87 | #define NR_BOARD_IRQS 0 | ||
88 | #endif | ||
89 | |||
90 | #ifndef UIC_WIDTH /* Number of interrupts per device */ | ||
91 | #define UIC_WIDTH 32 | ||
92 | #endif | ||
93 | |||
94 | #ifndef NR_UICS /* number of UIC devices */ | ||
95 | #define NR_UICS 1 | ||
96 | #endif | ||
97 | |||
98 | #if defined (CONFIG_403) | ||
99 | /* | ||
100 | * The PowerPC 403 cores' Asynchronous Interrupt Controller (AIC) has | ||
101 | * 32 possible interrupts, a majority of which are not implemented on | ||
102 | * all cores. There are six configurable, external interrupt pins and | ||
103 | * there are eight internal interrupts for the on-chip serial port | ||
104 | * (SPU), DMA controller, and JTAG controller. | ||
105 | * | ||
106 | */ | ||
107 | |||
108 | #define NR_AIC_IRQS 32 | ||
109 | #define NR_IRQS (NR_AIC_IRQS + NR_BOARD_IRQS) | ||
110 | |||
111 | #elif !defined (CONFIG_403) | ||
112 | |||
113 | /* | ||
114 | * The PowerPC 405 cores' Universal Interrupt Controller (UIC) has 32 | ||
115 | * possible interrupts as well. There are seven, configurable external | ||
116 | * interrupt pins and there are 17 internal interrupts for the on-chip | ||
117 | * serial port, DMA controller, on-chip Ethernet controller, PCI, etc. | ||
118 | * | ||
119 | */ | ||
120 | |||
121 | |||
122 | #define NR_UIC_IRQS UIC_WIDTH | ||
123 | #define NR_IRQS ((NR_UIC_IRQS * NR_UICS) + NR_BOARD_IRQS) | ||
124 | #endif | ||
125 | |||
126 | #elif defined(CONFIG_44x) | ||
127 | #include <asm/ibm44x.h> | ||
128 | |||
129 | #define NR_UIC_IRQS 32 | ||
130 | #define NR_IRQS ((NR_UIC_IRQS * NR_UICS) + NR_BOARD_IRQS) | ||
131 | |||
132 | #elif defined(CONFIG_8xx) | ||
133 | |||
134 | /* Now include the board configuration specific associations. | ||
135 | */ | ||
136 | #include <asm/mpc8xx.h> | ||
137 | |||
138 | /* The MPC8xx cores have 16 possible interrupts. There are eight | ||
139 | * possible level sensitive interrupts assigned and generated internally | ||
140 | * from such devices as CPM, PCMCIA, RTC, PIT, TimeBase and Decrementer. | ||
141 | * There are eight external interrupts (IRQs) that can be configured | ||
142 | * as either level or edge sensitive. | ||
143 | * | ||
144 | * On some implementations, there is also the possibility of an 8259 | ||
145 | * through the PCI and PCI-ISA bridges. | ||
146 | * | ||
147 | * We are "flattening" the interrupt vectors of the cascaded CPM | ||
148 | * and 8259 interrupt controllers so that we can uniquely identify | ||
149 | * any interrupt source with a single integer. | ||
150 | */ | ||
151 | #define NR_SIU_INTS 16 | ||
152 | #define NR_CPM_INTS 32 | ||
153 | #ifndef NR_8259_INTS | ||
154 | #define NR_8259_INTS 0 | ||
155 | #endif | ||
156 | |||
157 | #define SIU_IRQ_OFFSET 0 | ||
158 | #define CPM_IRQ_OFFSET (SIU_IRQ_OFFSET + NR_SIU_INTS) | ||
159 | #define I8259_IRQ_OFFSET (CPM_IRQ_OFFSET + NR_CPM_INTS) | ||
160 | |||
161 | #define NR_IRQS (NR_SIU_INTS + NR_CPM_INTS + NR_8259_INTS) | ||
162 | |||
163 | /* These values must be zero-based and map 1:1 with the SIU configuration. | ||
164 | * They are used throughout the 8xx I/O subsystem to generate | ||
165 | * interrupt masks, flags, and other control patterns. This is why the | ||
166 | * current kernel assumption of the 8259 as the base controller is such | ||
167 | * a pain in the butt. | ||
168 | */ | ||
169 | #define SIU_IRQ0 (0) /* Highest priority */ | ||
170 | #define SIU_LEVEL0 (1) | ||
171 | #define SIU_IRQ1 (2) | ||
172 | #define SIU_LEVEL1 (3) | ||
173 | #define SIU_IRQ2 (4) | ||
174 | #define SIU_LEVEL2 (5) | ||
175 | #define SIU_IRQ3 (6) | ||
176 | #define SIU_LEVEL3 (7) | ||
177 | #define SIU_IRQ4 (8) | ||
178 | #define SIU_LEVEL4 (9) | ||
179 | #define SIU_IRQ5 (10) | ||
180 | #define SIU_LEVEL5 (11) | ||
181 | #define SIU_IRQ6 (12) | ||
182 | #define SIU_LEVEL6 (13) | ||
183 | #define SIU_IRQ7 (14) | ||
184 | #define SIU_LEVEL7 (15) | ||
185 | |||
186 | #define MPC8xx_INT_FEC1 SIU_LEVEL1 | ||
187 | #define MPC8xx_INT_FEC2 SIU_LEVEL3 | ||
188 | |||
189 | #define MPC8xx_INT_SCC1 (CPM_IRQ_OFFSET + CPMVEC_SCC1) | ||
190 | #define MPC8xx_INT_SCC2 (CPM_IRQ_OFFSET + CPMVEC_SCC2) | ||
191 | #define MPC8xx_INT_SCC3 (CPM_IRQ_OFFSET + CPMVEC_SCC3) | ||
192 | #define MPC8xx_INT_SCC4 (CPM_IRQ_OFFSET + CPMVEC_SCC4) | ||
193 | #define MPC8xx_INT_SMC1 (CPM_IRQ_OFFSET + CPMVEC_SMC1) | ||
194 | #define MPC8xx_INT_SMC2 (CPM_IRQ_OFFSET + CPMVEC_SMC2) | ||
195 | |||
196 | /* The internal interrupts we can configure as we see fit. | ||
197 | * My personal preference is CPM at level 2, which puts it above the | ||
198 | * MBX PCI/ISA/IDE interrupts. | ||
199 | */ | ||
200 | #ifndef PIT_INTERRUPT | ||
201 | #define PIT_INTERRUPT SIU_LEVEL0 | ||
202 | #endif | ||
203 | #ifndef CPM_INTERRUPT | ||
204 | #define CPM_INTERRUPT SIU_LEVEL2 | ||
205 | #endif | ||
206 | #ifndef PCMCIA_INTERRUPT | ||
207 | #define PCMCIA_INTERRUPT SIU_LEVEL6 | ||
208 | #endif | ||
209 | #ifndef DEC_INTERRUPT | ||
210 | #define DEC_INTERRUPT SIU_LEVEL7 | ||
211 | #endif | ||
212 | |||
213 | /* Some internal interrupt registers use an 8-bit mask for the interrupt | ||
214 | * level instead of a number. | ||
215 | */ | ||
216 | #define mk_int_int_mask(IL) (1 << (7 - (IL/2))) | ||
217 | |||
218 | #elif defined(CONFIG_83xx) | ||
219 | #include <asm/mpc83xx.h> | ||
220 | |||
221 | #define NR_IRQS (NR_IPIC_INTS) | ||
222 | |||
223 | #elif defined(CONFIG_85xx) | ||
224 | /* Now include the board configuration specific associations. | ||
225 | */ | ||
226 | #include <asm/mpc85xx.h> | ||
227 | |||
228 | /* The MPC8548 openpic has 48 internal interrupts and 12 external | ||
229 | * interrupts. | ||
230 | * | ||
231 | * We are "flattening" the interrupt vectors of the cascaded CPM | ||
232 | * so that we can uniquely identify any interrupt source with a | ||
233 | * single integer. | ||
234 | */ | ||
235 | #define NR_CPM_INTS 64 | ||
236 | #define NR_EPIC_INTS 60 | ||
237 | #ifndef NR_8259_INTS | ||
238 | #define NR_8259_INTS 0 | ||
239 | #endif | ||
240 | #define NUM_8259_INTERRUPTS NR_8259_INTS | ||
241 | |||
242 | #ifndef CPM_IRQ_OFFSET | ||
243 | #define CPM_IRQ_OFFSET 0 | ||
244 | #endif | ||
245 | |||
246 | #define NR_IRQS (NR_EPIC_INTS + NR_CPM_INTS + NR_8259_INTS) | ||
247 | |||
248 | /* Internal IRQs on MPC85xx OpenPIC */ | ||
249 | |||
250 | #ifndef MPC85xx_OPENPIC_IRQ_OFFSET | ||
251 | #ifdef CONFIG_CPM2 | ||
252 | #define MPC85xx_OPENPIC_IRQ_OFFSET (CPM_IRQ_OFFSET + NR_CPM_INTS) | ||
253 | #else | ||
254 | #define MPC85xx_OPENPIC_IRQ_OFFSET 0 | ||
255 | #endif | ||
256 | #endif | ||
257 | |||
258 | /* Not all of these exist on all MPC85xx implementations */ | ||
259 | #define MPC85xx_IRQ_L2CACHE ( 0 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
260 | #define MPC85xx_IRQ_ECM ( 1 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
261 | #define MPC85xx_IRQ_DDR ( 2 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
262 | #define MPC85xx_IRQ_LBIU ( 3 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
263 | #define MPC85xx_IRQ_DMA0 ( 4 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
264 | #define MPC85xx_IRQ_DMA1 ( 5 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
265 | #define MPC85xx_IRQ_DMA2 ( 6 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
266 | #define MPC85xx_IRQ_DMA3 ( 7 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
267 | #define MPC85xx_IRQ_PCI1 ( 8 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
268 | #define MPC85xx_IRQ_PCI2 ( 9 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
269 | #define MPC85xx_IRQ_RIO_ERROR ( 9 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
270 | #define MPC85xx_IRQ_RIO_BELL (10 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
271 | #define MPC85xx_IRQ_RIO_TX (11 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
272 | #define MPC85xx_IRQ_RIO_RX (12 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
273 | #define MPC85xx_IRQ_TSEC1_TX (13 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
274 | #define MPC85xx_IRQ_TSEC1_RX (14 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
275 | #define MPC85xx_IRQ_TSEC3_TX (15 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
276 | #define MPC85xx_IRQ_TSEC3_RX (16 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
277 | #define MPC85xx_IRQ_TSEC3_ERROR (17 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
278 | #define MPC85xx_IRQ_TSEC1_ERROR (18 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
279 | #define MPC85xx_IRQ_TSEC2_TX (19 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
280 | #define MPC85xx_IRQ_TSEC2_RX (20 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
281 | #define MPC85xx_IRQ_TSEC4_TX (21 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
282 | #define MPC85xx_IRQ_TSEC4_RX (22 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
283 | #define MPC85xx_IRQ_TSEC4_ERROR (23 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
284 | #define MPC85xx_IRQ_TSEC2_ERROR (24 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
285 | #define MPC85xx_IRQ_FEC (25 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
286 | #define MPC85xx_IRQ_DUART (26 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
287 | #define MPC85xx_IRQ_IIC1 (27 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
288 | #define MPC85xx_IRQ_PERFMON (28 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
289 | #define MPC85xx_IRQ_SEC2 (29 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
290 | #define MPC85xx_IRQ_CPM (30 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
291 | |||
292 | /* The 12 external interrupt lines */ | ||
293 | #define MPC85xx_IRQ_EXT0 (48 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
294 | #define MPC85xx_IRQ_EXT1 (49 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
295 | #define MPC85xx_IRQ_EXT2 (50 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
296 | #define MPC85xx_IRQ_EXT3 (51 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
297 | #define MPC85xx_IRQ_EXT4 (52 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
298 | #define MPC85xx_IRQ_EXT5 (53 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
299 | #define MPC85xx_IRQ_EXT6 (54 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
300 | #define MPC85xx_IRQ_EXT7 (55 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
301 | #define MPC85xx_IRQ_EXT8 (56 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
302 | #define MPC85xx_IRQ_EXT9 (57 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
303 | #define MPC85xx_IRQ_EXT10 (58 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
304 | #define MPC85xx_IRQ_EXT11 (59 + MPC85xx_OPENPIC_IRQ_OFFSET) | ||
305 | |||
306 | /* CPM related interrupts */ | ||
307 | #define SIU_INT_ERROR ((uint)0x00+CPM_IRQ_OFFSET) | ||
308 | #define SIU_INT_I2C ((uint)0x01+CPM_IRQ_OFFSET) | ||
309 | #define SIU_INT_SPI ((uint)0x02+CPM_IRQ_OFFSET) | ||
310 | #define SIU_INT_RISC ((uint)0x03+CPM_IRQ_OFFSET) | ||
311 | #define SIU_INT_SMC1 ((uint)0x04+CPM_IRQ_OFFSET) | ||
312 | #define SIU_INT_SMC2 ((uint)0x05+CPM_IRQ_OFFSET) | ||
313 | #define SIU_INT_USB ((uint)0x0b+CPM_IRQ_OFFSET) | ||
314 | #define SIU_INT_TIMER1 ((uint)0x0c+CPM_IRQ_OFFSET) | ||
315 | #define SIU_INT_TIMER2 ((uint)0x0d+CPM_IRQ_OFFSET) | ||
316 | #define SIU_INT_TIMER3 ((uint)0x0e+CPM_IRQ_OFFSET) | ||
317 | #define SIU_INT_TIMER4 ((uint)0x0f+CPM_IRQ_OFFSET) | ||
318 | #define SIU_INT_FCC1 ((uint)0x20+CPM_IRQ_OFFSET) | ||
319 | #define SIU_INT_FCC2 ((uint)0x21+CPM_IRQ_OFFSET) | ||
320 | #define SIU_INT_FCC3 ((uint)0x22+CPM_IRQ_OFFSET) | ||
321 | #define SIU_INT_MCC1 ((uint)0x24+CPM_IRQ_OFFSET) | ||
322 | #define SIU_INT_MCC2 ((uint)0x25+CPM_IRQ_OFFSET) | ||
323 | #define SIU_INT_SCC1 ((uint)0x28+CPM_IRQ_OFFSET) | ||
324 | #define SIU_INT_SCC2 ((uint)0x29+CPM_IRQ_OFFSET) | ||
325 | #define SIU_INT_SCC3 ((uint)0x2a+CPM_IRQ_OFFSET) | ||
326 | #define SIU_INT_SCC4 ((uint)0x2b+CPM_IRQ_OFFSET) | ||
327 | #define SIU_INT_PC15 ((uint)0x30+CPM_IRQ_OFFSET) | ||
328 | #define SIU_INT_PC14 ((uint)0x31+CPM_IRQ_OFFSET) | ||
329 | #define SIU_INT_PC13 ((uint)0x32+CPM_IRQ_OFFSET) | ||
330 | #define SIU_INT_PC12 ((uint)0x33+CPM_IRQ_OFFSET) | ||
331 | #define SIU_INT_PC11 ((uint)0x34+CPM_IRQ_OFFSET) | ||
332 | #define SIU_INT_PC10 ((uint)0x35+CPM_IRQ_OFFSET) | ||
333 | #define SIU_INT_PC9 ((uint)0x36+CPM_IRQ_OFFSET) | ||
334 | #define SIU_INT_PC8 ((uint)0x37+CPM_IRQ_OFFSET) | ||
335 | #define SIU_INT_PC7 ((uint)0x38+CPM_IRQ_OFFSET) | ||
336 | #define SIU_INT_PC6 ((uint)0x39+CPM_IRQ_OFFSET) | ||
337 | #define SIU_INT_PC5 ((uint)0x3a+CPM_IRQ_OFFSET) | ||
338 | #define SIU_INT_PC4 ((uint)0x3b+CPM_IRQ_OFFSET) | ||
339 | #define SIU_INT_PC3 ((uint)0x3c+CPM_IRQ_OFFSET) | ||
340 | #define SIU_INT_PC2 ((uint)0x3d+CPM_IRQ_OFFSET) | ||
341 | #define SIU_INT_PC1 ((uint)0x3e+CPM_IRQ_OFFSET) | ||
342 | #define SIU_INT_PC0 ((uint)0x3f+CPM_IRQ_OFFSET) | ||
343 | |||
344 | #else /* CONFIG_40x + CONFIG_8xx */ | ||
345 | /* | ||
346 | * this is the # irq's for all ppc arch's (pmac/chrp/prep) | ||
347 | * so it is the max of them all | ||
348 | */ | ||
349 | #define NR_IRQS 256 | ||
350 | #define __DO_IRQ_CANON 1 | ||
351 | |||
352 | #ifndef CONFIG_8260 | ||
353 | |||
354 | #define NUM_8259_INTERRUPTS 16 | ||
355 | |||
356 | #else /* CONFIG_8260 */ | ||
357 | |||
358 | /* The 8260 has an internal interrupt controller with a maximum of | ||
359 | * 64 IRQs. We will use NR_IRQs from above since it is large enough. | ||
360 | * Don't be confused by the 8260 documentation where they list an | ||
361 | * "interrupt number" and "interrupt vector". We are only interested | ||
362 | * in the interrupt vector. There are "reserved" holes where the | ||
363 | * vector number increases, but the interrupt number in the table does not. | ||
364 | * (Document errata updates have fixed this...make sure you have up to | ||
365 | * date processor documentation -- Dan). | ||
366 | */ | ||
367 | |||
368 | #ifndef CPM_IRQ_OFFSET | ||
369 | #define CPM_IRQ_OFFSET 0 | ||
370 | #endif | ||
371 | |||
372 | #define NR_CPM_INTS 64 | ||
373 | |||
374 | #define SIU_INT_ERROR ((uint)0x00 + CPM_IRQ_OFFSET) | ||
375 | #define SIU_INT_I2C ((uint)0x01 + CPM_IRQ_OFFSET) | ||
376 | #define SIU_INT_SPI ((uint)0x02 + CPM_IRQ_OFFSET) | ||
377 | #define SIU_INT_RISC ((uint)0x03 + CPM_IRQ_OFFSET) | ||
378 | #define SIU_INT_SMC1 ((uint)0x04 + CPM_IRQ_OFFSET) | ||
379 | #define SIU_INT_SMC2 ((uint)0x05 + CPM_IRQ_OFFSET) | ||
380 | #define SIU_INT_IDMA1 ((uint)0x06 + CPM_IRQ_OFFSET) | ||
381 | #define SIU_INT_IDMA2 ((uint)0x07 + CPM_IRQ_OFFSET) | ||
382 | #define SIU_INT_IDMA3 ((uint)0x08 + CPM_IRQ_OFFSET) | ||
383 | #define SIU_INT_IDMA4 ((uint)0x09 + CPM_IRQ_OFFSET) | ||
384 | #define SIU_INT_SDMA ((uint)0x0a + CPM_IRQ_OFFSET) | ||
385 | #define SIU_INT_USB ((uint)0x0b + CPM_IRQ_OFFSET) | ||
386 | #define SIU_INT_TIMER1 ((uint)0x0c + CPM_IRQ_OFFSET) | ||
387 | #define SIU_INT_TIMER2 ((uint)0x0d + CPM_IRQ_OFFSET) | ||
388 | #define SIU_INT_TIMER3 ((uint)0x0e + CPM_IRQ_OFFSET) | ||
389 | #define SIU_INT_TIMER4 ((uint)0x0f + CPM_IRQ_OFFSET) | ||
390 | #define SIU_INT_TMCNT ((uint)0x10 + CPM_IRQ_OFFSET) | ||
391 | #define SIU_INT_PIT ((uint)0x11 + CPM_IRQ_OFFSET) | ||
392 | #define SIU_INT_IRQ1 ((uint)0x13 + CPM_IRQ_OFFSET) | ||
393 | #define SIU_INT_IRQ2 ((uint)0x14 + CPM_IRQ_OFFSET) | ||
394 | #define SIU_INT_IRQ3 ((uint)0x15 + CPM_IRQ_OFFSET) | ||
395 | #define SIU_INT_IRQ4 ((uint)0x16 + CPM_IRQ_OFFSET) | ||
396 | #define SIU_INT_IRQ5 ((uint)0x17 + CPM_IRQ_OFFSET) | ||
397 | #define SIU_INT_IRQ6 ((uint)0x18 + CPM_IRQ_OFFSET) | ||
398 | #define SIU_INT_IRQ7 ((uint)0x19 + CPM_IRQ_OFFSET) | ||
399 | #define SIU_INT_FCC1 ((uint)0x20 + CPM_IRQ_OFFSET) | ||
400 | #define SIU_INT_FCC2 ((uint)0x21 + CPM_IRQ_OFFSET) | ||
401 | #define SIU_INT_FCC3 ((uint)0x22 + CPM_IRQ_OFFSET) | ||
402 | #define SIU_INT_MCC1 ((uint)0x24 + CPM_IRQ_OFFSET) | ||
403 | #define SIU_INT_MCC2 ((uint)0x25 + CPM_IRQ_OFFSET) | ||
404 | #define SIU_INT_SCC1 ((uint)0x28 + CPM_IRQ_OFFSET) | ||
405 | #define SIU_INT_SCC2 ((uint)0x29 + CPM_IRQ_OFFSET) | ||
406 | #define SIU_INT_SCC3 ((uint)0x2a + CPM_IRQ_OFFSET) | ||
407 | #define SIU_INT_SCC4 ((uint)0x2b + CPM_IRQ_OFFSET) | ||
408 | #define SIU_INT_PC15 ((uint)0x30 + CPM_IRQ_OFFSET) | ||
409 | #define SIU_INT_PC14 ((uint)0x31 + CPM_IRQ_OFFSET) | ||
410 | #define SIU_INT_PC13 ((uint)0x32 + CPM_IRQ_OFFSET) | ||
411 | #define SIU_INT_PC12 ((uint)0x33 + CPM_IRQ_OFFSET) | ||
412 | #define SIU_INT_PC11 ((uint)0x34 + CPM_IRQ_OFFSET) | ||
413 | #define SIU_INT_PC10 ((uint)0x35 + CPM_IRQ_OFFSET) | ||
414 | #define SIU_INT_PC9 ((uint)0x36 + CPM_IRQ_OFFSET) | ||
415 | #define SIU_INT_PC8 ((uint)0x37 + CPM_IRQ_OFFSET) | ||
416 | #define SIU_INT_PC7 ((uint)0x38 + CPM_IRQ_OFFSET) | ||
417 | #define SIU_INT_PC6 ((uint)0x39 + CPM_IRQ_OFFSET) | ||
418 | #define SIU_INT_PC5 ((uint)0x3a + CPM_IRQ_OFFSET) | ||
419 | #define SIU_INT_PC4 ((uint)0x3b + CPM_IRQ_OFFSET) | ||
420 | #define SIU_INT_PC3 ((uint)0x3c + CPM_IRQ_OFFSET) | ||
421 | #define SIU_INT_PC2 ((uint)0x3d + CPM_IRQ_OFFSET) | ||
422 | #define SIU_INT_PC1 ((uint)0x3e + CPM_IRQ_OFFSET) | ||
423 | #define SIU_INT_PC0 ((uint)0x3f + CPM_IRQ_OFFSET) | ||
424 | |||
425 | #endif /* CONFIG_8260 */ | ||
426 | |||
427 | #endif | ||
428 | |||
429 | #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) | ||
430 | /* pedantic: these are long because they are used with set_bit --RR */ | ||
431 | extern unsigned long ppc_cached_irq_mask[NR_MASK_WORDS]; | ||
432 | extern unsigned long ppc_lost_interrupts[NR_MASK_WORDS]; | ||
433 | extern atomic_t ppc_n_lost_interrupts; | ||
434 | |||
435 | #define virt_irq_create_mapping(x) (x) | ||
436 | |||
437 | #endif | ||
438 | |||
439 | /* | ||
440 | * Because many systems have two overlapping names spaces for | ||
441 | * interrupts (ISA and XICS for example), and the ISA interrupts | ||
442 | * have historically not been easy to renumber, we allow ISA | ||
443 | * interrupts to take values 0 - 15, and shift up the remaining | ||
444 | * interrupts by 0x10. | ||
445 | */ | ||
446 | #define NUM_ISA_INTERRUPTS 0x10 | ||
447 | extern int __irq_offset_value; | ||
448 | |||
449 | static inline int irq_offset_up(int irq) | ||
450 | { | ||
451 | return(irq + __irq_offset_value); | ||
452 | } | ||
453 | |||
454 | static inline int irq_offset_down(int irq) | ||
455 | { | ||
456 | return(irq - __irq_offset_value); | ||
457 | } | ||
458 | |||
459 | static inline int irq_offset_value(void) | ||
460 | { | ||
461 | return __irq_offset_value; | ||
462 | } | ||
463 | |||
464 | #ifdef __DO_IRQ_CANON | ||
465 | extern int ppc_do_canonicalize_irqs; | ||
466 | #else | ||
467 | #define ppc_do_canonicalize_irqs 0 | ||
468 | #endif | ||
469 | |||
470 | static __inline__ int irq_canonicalize(int irq) | ||
471 | { | ||
472 | if (ppc_do_canonicalize_irqs && irq == 2) | ||
473 | irq = 9; | ||
474 | return irq; | ||
475 | } | ||
476 | |||
477 | extern int distribute_irqs; | ||
478 | |||
479 | struct irqaction; | ||
480 | struct pt_regs; | ||
481 | |||
482 | #ifdef CONFIG_IRQSTACKS | ||
483 | /* | ||
484 | * Per-cpu stacks for handling hard and soft interrupts. | ||
485 | */ | ||
486 | extern struct thread_info *hardirq_ctx[NR_CPUS]; | ||
487 | extern struct thread_info *softirq_ctx[NR_CPUS]; | ||
488 | |||
489 | extern void irq_ctx_init(void); | ||
490 | extern void call_do_softirq(struct thread_info *tp); | ||
491 | extern int call_handle_IRQ_event(int irq, struct pt_regs *regs, | ||
492 | struct irqaction *action, struct thread_info *tp); | ||
493 | |||
494 | #define __ARCH_HAS_DO_SOFTIRQ | ||
495 | |||
496 | #else | ||
497 | #define irq_ctx_init() | ||
498 | |||
499 | #endif /* CONFIG_IRQSTACKS */ | ||
500 | |||
501 | extern void do_IRQ(struct pt_regs *regs); | ||
502 | |||
503 | #endif /* _ASM_IRQ_H */ | ||
504 | #endif /* __KERNEL__ */ | ||
diff --git a/include/asm-powerpc/iseries/hv_call.h b/include/asm-powerpc/iseries/hv_call.h new file mode 100644 index 000000000000..e9f831c9a5e5 --- /dev/null +++ b/include/asm-powerpc/iseries/hv_call.h | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * HvCall.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | /* | ||
20 | * This file contains the "hypervisor call" interface which is used to | ||
21 | * drive the hypervisor from the OS. | ||
22 | */ | ||
23 | #ifndef _ASM_POWERPC_ISERIES_HV_CALL_H | ||
24 | #define _ASM_POWERPC_ISERIES_HV_CALL_H | ||
25 | |||
26 | #include <asm/iseries/hv_call_sc.h> | ||
27 | #include <asm/iseries/hv_types.h> | ||
28 | #include <asm/paca.h> | ||
29 | |||
30 | /* Type of yield for HvCallBaseYieldProcessor */ | ||
31 | #define HvCall_YieldTimed 0 /* Yield until specified time (tb) */ | ||
32 | #define HvCall_YieldToActive 1 /* Yield until all active procs have run */ | ||
33 | #define HvCall_YieldToProc 2 /* Yield until the specified processor has run */ | ||
34 | |||
35 | /* interrupt masks for setEnabledInterrupts */ | ||
36 | #define HvCall_MaskIPI 0x00000001 | ||
37 | #define HvCall_MaskLpEvent 0x00000002 | ||
38 | #define HvCall_MaskLpProd 0x00000004 | ||
39 | #define HvCall_MaskTimeout 0x00000008 | ||
40 | |||
41 | /* Log buffer formats */ | ||
42 | #define HvCall_LogBuffer_ASCII 0 | ||
43 | #define HvCall_LogBuffer_EBCDIC 1 | ||
44 | |||
45 | #define HvCallBaseAckDeferredInts HvCallBase + 0 | ||
46 | #define HvCallBaseCpmPowerOff HvCallBase + 1 | ||
47 | #define HvCallBaseGetHwPatch HvCallBase + 2 | ||
48 | #define HvCallBaseReIplSpAttn HvCallBase + 3 | ||
49 | #define HvCallBaseSetASR HvCallBase + 4 | ||
50 | #define HvCallBaseSetASRAndRfi HvCallBase + 5 | ||
51 | #define HvCallBaseSetIMR HvCallBase + 6 | ||
52 | #define HvCallBaseSendIPI HvCallBase + 7 | ||
53 | #define HvCallBaseTerminateMachine HvCallBase + 8 | ||
54 | #define HvCallBaseTerminateMachineSrc HvCallBase + 9 | ||
55 | #define HvCallBaseProcessPlicInterrupts HvCallBase + 10 | ||
56 | #define HvCallBaseIsPrimaryCpmOrMsdIpl HvCallBase + 11 | ||
57 | #define HvCallBaseSetVirtualSIT HvCallBase + 12 | ||
58 | #define HvCallBaseVaryOffThisProcessor HvCallBase + 13 | ||
59 | #define HvCallBaseVaryOffMemoryChunk HvCallBase + 14 | ||
60 | #define HvCallBaseVaryOffInteractivePercentage HvCallBase + 15 | ||
61 | #define HvCallBaseSendLpProd HvCallBase + 16 | ||
62 | #define HvCallBaseSetEnabledInterrupts HvCallBase + 17 | ||
63 | #define HvCallBaseYieldProcessor HvCallBase + 18 | ||
64 | #define HvCallBaseVaryOffSharedProcUnits HvCallBase + 19 | ||
65 | #define HvCallBaseSetVirtualDecr HvCallBase + 20 | ||
66 | #define HvCallBaseClearLogBuffer HvCallBase + 21 | ||
67 | #define HvCallBaseGetLogBufferCodePage HvCallBase + 22 | ||
68 | #define HvCallBaseGetLogBufferFormat HvCallBase + 23 | ||
69 | #define HvCallBaseGetLogBufferLength HvCallBase + 24 | ||
70 | #define HvCallBaseReadLogBuffer HvCallBase + 25 | ||
71 | #define HvCallBaseSetLogBufferFormatAndCodePage HvCallBase + 26 | ||
72 | #define HvCallBaseWriteLogBuffer HvCallBase + 27 | ||
73 | #define HvCallBaseRouter28 HvCallBase + 28 | ||
74 | #define HvCallBaseRouter29 HvCallBase + 29 | ||
75 | #define HvCallBaseRouter30 HvCallBase + 30 | ||
76 | #define HvCallBaseSetDebugBus HvCallBase + 31 | ||
77 | |||
78 | #define HvCallCcSetDABR HvCallCc + 7 | ||
79 | |||
80 | static inline void HvCall_setVirtualDecr(void) | ||
81 | { | ||
82 | /* | ||
83 | * Ignore any error return codes - most likely means that the | ||
84 | * target value for the LP has been increased and this vary off | ||
85 | * would bring us below the new target. | ||
86 | */ | ||
87 | HvCall0(HvCallBaseSetVirtualDecr); | ||
88 | } | ||
89 | |||
90 | static inline void HvCall_yieldProcessor(unsigned typeOfYield, u64 yieldParm) | ||
91 | { | ||
92 | HvCall2(HvCallBaseYieldProcessor, typeOfYield, yieldParm); | ||
93 | } | ||
94 | |||
95 | static inline void HvCall_setEnabledInterrupts(u64 enabledInterrupts) | ||
96 | { | ||
97 | HvCall1(HvCallBaseSetEnabledInterrupts, enabledInterrupts); | ||
98 | } | ||
99 | |||
100 | static inline void HvCall_setLogBufferFormatAndCodepage(int format, | ||
101 | u32 codePage) | ||
102 | { | ||
103 | HvCall2(HvCallBaseSetLogBufferFormatAndCodePage, format, codePage); | ||
104 | } | ||
105 | |||
106 | extern void HvCall_writeLogBuffer(const void *buffer, u64 bufLen); | ||
107 | |||
108 | static inline void HvCall_sendIPI(struct paca_struct *targetPaca) | ||
109 | { | ||
110 | HvCall1(HvCallBaseSendIPI, targetPaca->paca_index); | ||
111 | } | ||
112 | |||
113 | #endif /* _ASM_POWERPC_ISERIES_HV_CALL_H */ | ||
diff --git a/include/asm-powerpc/iseries/hv_call_event.h b/include/asm-powerpc/iseries/hv_call_event.h new file mode 100644 index 000000000000..46763a30590a --- /dev/null +++ b/include/asm-powerpc/iseries/hv_call_event.h | |||
@@ -0,0 +1,253 @@ | |||
1 | /* | ||
2 | * HvCallEvent.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | /* | ||
20 | * This file contains the "hypervisor call" interface which is used to | ||
21 | * drive the hypervisor from the OS. | ||
22 | */ | ||
23 | #ifndef _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H | ||
24 | #define _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H | ||
25 | |||
26 | #include <asm/iseries/hv_call_sc.h> | ||
27 | #include <asm/iseries/hv_types.h> | ||
28 | #include <asm/abs_addr.h> | ||
29 | |||
30 | struct HvLpEvent; | ||
31 | |||
32 | typedef u8 HvLpEvent_Type; | ||
33 | typedef u8 HvLpEvent_AckInd; | ||
34 | typedef u8 HvLpEvent_AckType; | ||
35 | |||
36 | struct HvCallEvent_PackedParms { | ||
37 | u8 xAckType:1; | ||
38 | u8 xAckInd:1; | ||
39 | u8 xRsvd:1; | ||
40 | u8 xTargetLp:5; | ||
41 | u8 xType; | ||
42 | u16 xSubtype; | ||
43 | HvLpInstanceId xSourceInstId; | ||
44 | HvLpInstanceId xTargetInstId; | ||
45 | }; | ||
46 | |||
47 | typedef u8 HvLpDma_Direction; | ||
48 | typedef u8 HvLpDma_AddressType; | ||
49 | |||
50 | struct HvCallEvent_PackedDmaParms { | ||
51 | u8 xDirection:1; | ||
52 | u8 xLocalAddrType:1; | ||
53 | u8 xRemoteAddrType:1; | ||
54 | u8 xRsvd1:5; | ||
55 | HvLpIndex xRemoteLp; | ||
56 | u8 xType; | ||
57 | u8 xRsvd2; | ||
58 | HvLpInstanceId xLocalInstId; | ||
59 | HvLpInstanceId xRemoteInstId; | ||
60 | }; | ||
61 | |||
62 | typedef u64 HvLpEvent_Rc; | ||
63 | typedef u64 HvLpDma_Rc; | ||
64 | |||
65 | #define HvCallEventAckLpEvent HvCallEvent + 0 | ||
66 | #define HvCallEventCancelLpEvent HvCallEvent + 1 | ||
67 | #define HvCallEventCloseLpEventPath HvCallEvent + 2 | ||
68 | #define HvCallEventDmaBufList HvCallEvent + 3 | ||
69 | #define HvCallEventDmaSingle HvCallEvent + 4 | ||
70 | #define HvCallEventDmaToSp HvCallEvent + 5 | ||
71 | #define HvCallEventGetOverflowLpEvents HvCallEvent + 6 | ||
72 | #define HvCallEventGetSourceLpInstanceId HvCallEvent + 7 | ||
73 | #define HvCallEventGetTargetLpInstanceId HvCallEvent + 8 | ||
74 | #define HvCallEventOpenLpEventPath HvCallEvent + 9 | ||
75 | #define HvCallEventSetLpEventStack HvCallEvent + 10 | ||
76 | #define HvCallEventSignalLpEvent HvCallEvent + 11 | ||
77 | #define HvCallEventSignalLpEventParms HvCallEvent + 12 | ||
78 | #define HvCallEventSetInterLpQueueIndex HvCallEvent + 13 | ||
79 | #define HvCallEventSetLpEventQueueInterruptProc HvCallEvent + 14 | ||
80 | #define HvCallEventRouter15 HvCallEvent + 15 | ||
81 | |||
82 | static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex) | ||
83 | { | ||
84 | HvCall1(HvCallEventGetOverflowLpEvents, queueIndex); | ||
85 | } | ||
86 | |||
87 | static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex) | ||
88 | { | ||
89 | HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex); | ||
90 | } | ||
91 | |||
92 | static inline void HvCallEvent_setLpEventStack(u8 queueIndex, | ||
93 | char *eventStackAddr, u32 eventStackSize) | ||
94 | { | ||
95 | u64 abs_addr; | ||
96 | |||
97 | abs_addr = virt_to_abs(eventStackAddr); | ||
98 | HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr, | ||
99 | eventStackSize); | ||
100 | } | ||
101 | |||
102 | static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex, | ||
103 | u16 lpLogicalProcIndex) | ||
104 | { | ||
105 | HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex, | ||
106 | lpLogicalProcIndex); | ||
107 | } | ||
108 | |||
109 | static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event) | ||
110 | { | ||
111 | u64 abs_addr; | ||
112 | |||
113 | #ifdef DEBUG_SENDEVENT | ||
114 | printk("HvCallEvent_signalLpEvent: *event = %016lx\n ", | ||
115 | (unsigned long)event); | ||
116 | #endif | ||
117 | abs_addr = virt_to_abs(event); | ||
118 | return HvCall1(HvCallEventSignalLpEvent, abs_addr); | ||
119 | } | ||
120 | |||
121 | static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp, | ||
122 | HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd, | ||
123 | HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId, | ||
124 | HvLpInstanceId targetInstanceId, u64 correlationToken, | ||
125 | u64 eventData1, u64 eventData2, u64 eventData3, | ||
126 | u64 eventData4, u64 eventData5) | ||
127 | { | ||
128 | /* Pack the misc bits into a single Dword to pass to PLIC */ | ||
129 | union { | ||
130 | struct HvCallEvent_PackedParms parms; | ||
131 | u64 dword; | ||
132 | } packed; | ||
133 | packed.parms.xAckType = ackType; | ||
134 | packed.parms.xAckInd = ackInd; | ||
135 | packed.parms.xRsvd = 0; | ||
136 | packed.parms.xTargetLp = targetLp; | ||
137 | packed.parms.xType = type; | ||
138 | packed.parms.xSubtype = subtype; | ||
139 | packed.parms.xSourceInstId = sourceInstanceId; | ||
140 | packed.parms.xTargetInstId = targetInstanceId; | ||
141 | |||
142 | return HvCall7(HvCallEventSignalLpEventParms, packed.dword, | ||
143 | correlationToken, eventData1, eventData2, | ||
144 | eventData3, eventData4, eventData5); | ||
145 | } | ||
146 | |||
147 | static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event) | ||
148 | { | ||
149 | u64 abs_addr; | ||
150 | |||
151 | abs_addr = virt_to_abs(event); | ||
152 | return HvCall1(HvCallEventAckLpEvent, abs_addr); | ||
153 | } | ||
154 | |||
155 | static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event) | ||
156 | { | ||
157 | u64 abs_addr; | ||
158 | |||
159 | abs_addr = virt_to_abs(event); | ||
160 | return HvCall1(HvCallEventCancelLpEvent, abs_addr); | ||
161 | } | ||
162 | |||
163 | static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId( | ||
164 | HvLpIndex targetLp, HvLpEvent_Type type) | ||
165 | { | ||
166 | return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type); | ||
167 | } | ||
168 | |||
169 | static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId( | ||
170 | HvLpIndex targetLp, HvLpEvent_Type type) | ||
171 | { | ||
172 | return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type); | ||
173 | } | ||
174 | |||
175 | static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp, | ||
176 | HvLpEvent_Type type) | ||
177 | { | ||
178 | HvCall2(HvCallEventOpenLpEventPath, targetLp, type); | ||
179 | } | ||
180 | |||
181 | static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp, | ||
182 | HvLpEvent_Type type) | ||
183 | { | ||
184 | HvCall2(HvCallEventCloseLpEventPath, targetLp, type); | ||
185 | } | ||
186 | |||
187 | static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type, | ||
188 | HvLpIndex remoteLp, HvLpDma_Direction direction, | ||
189 | HvLpInstanceId localInstanceId, | ||
190 | HvLpInstanceId remoteInstanceId, | ||
191 | HvLpDma_AddressType localAddressType, | ||
192 | HvLpDma_AddressType remoteAddressType, | ||
193 | /* Do these need to be converted to absolute addresses? */ | ||
194 | u64 localBufList, u64 remoteBufList, u32 transferLength) | ||
195 | { | ||
196 | /* Pack the misc bits into a single Dword to pass to PLIC */ | ||
197 | union { | ||
198 | struct HvCallEvent_PackedDmaParms parms; | ||
199 | u64 dword; | ||
200 | } packed; | ||
201 | |||
202 | packed.parms.xDirection = direction; | ||
203 | packed.parms.xLocalAddrType = localAddressType; | ||
204 | packed.parms.xRemoteAddrType = remoteAddressType; | ||
205 | packed.parms.xRsvd1 = 0; | ||
206 | packed.parms.xRemoteLp = remoteLp; | ||
207 | packed.parms.xType = type; | ||
208 | packed.parms.xRsvd2 = 0; | ||
209 | packed.parms.xLocalInstId = localInstanceId; | ||
210 | packed.parms.xRemoteInstId = remoteInstanceId; | ||
211 | |||
212 | return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList, | ||
213 | remoteBufList, transferLength); | ||
214 | } | ||
215 | |||
216 | static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type, | ||
217 | HvLpIndex remoteLp, HvLpDma_Direction direction, | ||
218 | HvLpInstanceId localInstanceId, | ||
219 | HvLpInstanceId remoteInstanceId, | ||
220 | HvLpDma_AddressType localAddressType, | ||
221 | HvLpDma_AddressType remoteAddressType, | ||
222 | u64 localAddrOrTce, u64 remoteAddrOrTce, u32 transferLength) | ||
223 | { | ||
224 | /* Pack the misc bits into a single Dword to pass to PLIC */ | ||
225 | union { | ||
226 | struct HvCallEvent_PackedDmaParms parms; | ||
227 | u64 dword; | ||
228 | } packed; | ||
229 | |||
230 | packed.parms.xDirection = direction; | ||
231 | packed.parms.xLocalAddrType = localAddressType; | ||
232 | packed.parms.xRemoteAddrType = remoteAddressType; | ||
233 | packed.parms.xRsvd1 = 0; | ||
234 | packed.parms.xRemoteLp = remoteLp; | ||
235 | packed.parms.xType = type; | ||
236 | packed.parms.xRsvd2 = 0; | ||
237 | packed.parms.xLocalInstId = localInstanceId; | ||
238 | packed.parms.xRemoteInstId = remoteInstanceId; | ||
239 | |||
240 | return (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle, packed.dword, | ||
241 | localAddrOrTce, remoteAddrOrTce, transferLength); | ||
242 | } | ||
243 | |||
244 | static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote, | ||
245 | u32 length, HvLpDma_Direction dir) | ||
246 | { | ||
247 | u64 abs_addr; | ||
248 | |||
249 | abs_addr = virt_to_abs(local); | ||
250 | return HvCall4(HvCallEventDmaToSp, abs_addr, remote, length, dir); | ||
251 | } | ||
252 | |||
253 | #endif /* _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H */ | ||
diff --git a/include/asm-powerpc/iseries/hv_call_sc.h b/include/asm-powerpc/iseries/hv_call_sc.h new file mode 100644 index 000000000000..dec7e9d9ab78 --- /dev/null +++ b/include/asm-powerpc/iseries/hv_call_sc.h | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | * HvCallSc.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | #ifndef _ASM_POWERPC_ISERIES_HV_CALL_SC_H | ||
20 | #define _ASM_POWERPC_ISERIES_HV_CALL_SC_H | ||
21 | |||
22 | #include <linux/types.h> | ||
23 | |||
24 | #define HvCallBase 0x8000000000000000ul | ||
25 | #define HvCallCc 0x8001000000000000ul | ||
26 | #define HvCallCfg 0x8002000000000000ul | ||
27 | #define HvCallEvent 0x8003000000000000ul | ||
28 | #define HvCallHpt 0x8004000000000000ul | ||
29 | #define HvCallPci 0x8005000000000000ul | ||
30 | #define HvCallSm 0x8007000000000000ul | ||
31 | #define HvCallXm 0x8009000000000000ul | ||
32 | |||
33 | extern u64 HvCall0(u64); | ||
34 | extern u64 HvCall1(u64, u64); | ||
35 | extern u64 HvCall2(u64, u64, u64); | ||
36 | extern u64 HvCall3(u64, u64, u64, u64); | ||
37 | extern u64 HvCall4(u64, u64, u64, u64, u64); | ||
38 | extern u64 HvCall5(u64, u64, u64, u64, u64, u64); | ||
39 | extern u64 HvCall6(u64, u64, u64, u64, u64, u64, u64); | ||
40 | extern u64 HvCall7(u64, u64, u64, u64, u64, u64, u64, u64); | ||
41 | |||
42 | extern u64 HvCall0Ret16(u64, void *); | ||
43 | extern u64 HvCall1Ret16(u64, void *, u64); | ||
44 | extern u64 HvCall2Ret16(u64, void *, u64, u64); | ||
45 | extern u64 HvCall3Ret16(u64, void *, u64, u64, u64); | ||
46 | extern u64 HvCall4Ret16(u64, void *, u64, u64, u64, u64); | ||
47 | extern u64 HvCall5Ret16(u64, void *, u64, u64, u64, u64, u64); | ||
48 | extern u64 HvCall6Ret16(u64, void *, u64, u64, u64, u64, u64, u64); | ||
49 | extern u64 HvCall7Ret16(u64, void *, u64, u64 ,u64 ,u64 ,u64 ,u64 ,u64); | ||
50 | |||
51 | #endif /* _ASM_POWERPC_ISERIES_HV_CALL_SC_H */ | ||
diff --git a/include/asm-powerpc/iseries/hv_call_xm.h b/include/asm-powerpc/iseries/hv_call_xm.h new file mode 100644 index 000000000000..ca9202cb01ed --- /dev/null +++ b/include/asm-powerpc/iseries/hv_call_xm.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * This file contains the "hypervisor call" interface which is used to | ||
3 | * drive the hypervisor from SLIC. | ||
4 | */ | ||
5 | #ifndef _ASM_POWERPC_ISERIES_HV_CALL_XM_H | ||
6 | #define _ASM_POWERPC_ISERIES_HV_CALL_XM_H | ||
7 | |||
8 | #include <asm/iseries/hv_call_sc.h> | ||
9 | #include <asm/iseries/hv_types.h> | ||
10 | |||
11 | #define HvCallXmGetTceTableParms HvCallXm + 0 | ||
12 | #define HvCallXmTestBus HvCallXm + 1 | ||
13 | #define HvCallXmConnectBusUnit HvCallXm + 2 | ||
14 | #define HvCallXmLoadTod HvCallXm + 8 | ||
15 | #define HvCallXmTestBusUnit HvCallXm + 9 | ||
16 | #define HvCallXmSetTce HvCallXm + 11 | ||
17 | #define HvCallXmSetTces HvCallXm + 13 | ||
18 | |||
19 | /* | ||
20 | * Structure passed to HvCallXm_getTceTableParms | ||
21 | */ | ||
22 | struct iommu_table_cb { | ||
23 | unsigned long itc_busno; /* Bus number for this tce table */ | ||
24 | unsigned long itc_start; /* Will be NULL for secondary */ | ||
25 | unsigned long itc_totalsize; /* Size (in pages) of whole table */ | ||
26 | unsigned long itc_offset; /* Index into real tce table of the | ||
27 | start of our section */ | ||
28 | unsigned long itc_size; /* Size (in pages) of our section */ | ||
29 | unsigned long itc_index; /* Index of this tce table */ | ||
30 | unsigned short itc_maxtables; /* Max num of tables for partition */ | ||
31 | unsigned char itc_virtbus; /* Flag to indicate virtual bus */ | ||
32 | unsigned char itc_slotno; /* IOA Tce Slot Index */ | ||
33 | unsigned char itc_rsvd[4]; | ||
34 | }; | ||
35 | |||
36 | static inline void HvCallXm_getTceTableParms(u64 cb) | ||
37 | { | ||
38 | HvCall1(HvCallXmGetTceTableParms, cb); | ||
39 | } | ||
40 | |||
41 | static inline u64 HvCallXm_setTce(u64 tceTableToken, u64 tceOffset, u64 tce) | ||
42 | { | ||
43 | return HvCall3(HvCallXmSetTce, tceTableToken, tceOffset, tce); | ||
44 | } | ||
45 | |||
46 | static inline u64 HvCallXm_setTces(u64 tceTableToken, u64 tceOffset, | ||
47 | u64 numTces, u64 tce1, u64 tce2, u64 tce3, u64 tce4) | ||
48 | { | ||
49 | return HvCall7(HvCallXmSetTces, tceTableToken, tceOffset, numTces, | ||
50 | tce1, tce2, tce3, tce4); | ||
51 | } | ||
52 | |||
53 | static inline u64 HvCallXm_testBus(u16 busNumber) | ||
54 | { | ||
55 | return HvCall1(HvCallXmTestBus, busNumber); | ||
56 | } | ||
57 | |||
58 | static inline u64 HvCallXm_testBusUnit(u16 busNumber, u8 subBusNumber, | ||
59 | u8 deviceId) | ||
60 | { | ||
61 | return HvCall2(HvCallXmTestBusUnit, busNumber, | ||
62 | (subBusNumber << 8) | deviceId); | ||
63 | } | ||
64 | |||
65 | static inline u64 HvCallXm_connectBusUnit(u16 busNumber, u8 subBusNumber, | ||
66 | u8 deviceId, u64 interruptToken) | ||
67 | { | ||
68 | return HvCall5(HvCallXmConnectBusUnit, busNumber, | ||
69 | (subBusNumber << 8) | deviceId, interruptToken, 0, | ||
70 | 0 /* HvLpConfig::mapDsaToQueueIndex(HvLpDSA(busNumber, xBoard, xCard)) */); | ||
71 | } | ||
72 | |||
73 | static inline u64 HvCallXm_loadTod(void) | ||
74 | { | ||
75 | return HvCall0(HvCallXmLoadTod); | ||
76 | } | ||
77 | |||
78 | #endif /* _ASM_POWERPC_ISERIES_HV_CALL_XM_H */ | ||
diff --git a/include/asm-powerpc/iseries/hv_lp_config.h b/include/asm-powerpc/iseries/hv_lp_config.h new file mode 100644 index 000000000000..bc00f036bca0 --- /dev/null +++ b/include/asm-powerpc/iseries/hv_lp_config.h | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * HvLpConfig.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | #ifndef _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H | ||
20 | #define _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H | ||
21 | |||
22 | /* | ||
23 | * This file contains the interface to the LPAR configuration data | ||
24 | * to determine which resources should be allocated to each partition. | ||
25 | */ | ||
26 | |||
27 | #include <asm/iseries/hv_call_sc.h> | ||
28 | #include <asm/iseries/hv_types.h> | ||
29 | #include <asm/iseries/it_lp_naca.h> | ||
30 | |||
31 | enum { | ||
32 | HvCallCfg_Cur = 0, | ||
33 | HvCallCfg_Init = 1, | ||
34 | HvCallCfg_Max = 2, | ||
35 | HvCallCfg_Min = 3 | ||
36 | }; | ||
37 | |||
38 | #define HvCallCfgGetSystemPhysicalProcessors HvCallCfg + 6 | ||
39 | #define HvCallCfgGetPhysicalProcessors HvCallCfg + 7 | ||
40 | #define HvCallCfgGetMsChunks HvCallCfg + 9 | ||
41 | #define HvCallCfgGetSharedPoolIndex HvCallCfg + 20 | ||
42 | #define HvCallCfgGetSharedProcUnits HvCallCfg + 21 | ||
43 | #define HvCallCfgGetNumProcsInSharedPool HvCallCfg + 22 | ||
44 | #define HvCallCfgGetVirtualLanIndexMap HvCallCfg + 30 | ||
45 | #define HvCallCfgGetHostingLpIndex HvCallCfg + 32 | ||
46 | |||
47 | extern HvLpIndex HvLpConfig_getLpIndex_outline(void); | ||
48 | |||
49 | static inline HvLpIndex HvLpConfig_getLpIndex(void) | ||
50 | { | ||
51 | return itLpNaca.xLpIndex; | ||
52 | } | ||
53 | |||
54 | static inline HvLpIndex HvLpConfig_getPrimaryLpIndex(void) | ||
55 | { | ||
56 | return itLpNaca.xPrimaryLpIndex; | ||
57 | } | ||
58 | |||
59 | static inline u64 HvLpConfig_getMsChunks(void) | ||
60 | { | ||
61 | return HvCall2(HvCallCfgGetMsChunks, HvLpConfig_getLpIndex(), | ||
62 | HvCallCfg_Cur); | ||
63 | } | ||
64 | |||
65 | static inline u64 HvLpConfig_getSystemPhysicalProcessors(void) | ||
66 | { | ||
67 | return HvCall0(HvCallCfgGetSystemPhysicalProcessors); | ||
68 | } | ||
69 | |||
70 | static inline u64 HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI) | ||
71 | { | ||
72 | return (u16)HvCall1(HvCallCfgGetNumProcsInSharedPool, sPI); | ||
73 | } | ||
74 | |||
75 | static inline u64 HvLpConfig_getPhysicalProcessors(void) | ||
76 | { | ||
77 | return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(), | ||
78 | HvCallCfg_Cur); | ||
79 | } | ||
80 | |||
81 | static inline HvLpSharedPoolIndex HvLpConfig_getSharedPoolIndex(void) | ||
82 | { | ||
83 | return HvCall1(HvCallCfgGetSharedPoolIndex, HvLpConfig_getLpIndex()); | ||
84 | } | ||
85 | |||
86 | static inline u64 HvLpConfig_getSharedProcUnits(void) | ||
87 | { | ||
88 | return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(), | ||
89 | HvCallCfg_Cur); | ||
90 | } | ||
91 | |||
92 | static inline u64 HvLpConfig_getMaxSharedProcUnits(void) | ||
93 | { | ||
94 | return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(), | ||
95 | HvCallCfg_Max); | ||
96 | } | ||
97 | |||
98 | static inline u64 HvLpConfig_getMaxPhysicalProcessors(void) | ||
99 | { | ||
100 | return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(), | ||
101 | HvCallCfg_Max); | ||
102 | } | ||
103 | |||
104 | static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMapForLp( | ||
105 | HvLpIndex lp) | ||
106 | { | ||
107 | /* | ||
108 | * This is a new function in V5R1 so calls to this on older | ||
109 | * hypervisors will return -1 | ||
110 | */ | ||
111 | u64 retVal = HvCall1(HvCallCfgGetVirtualLanIndexMap, lp); | ||
112 | if (retVal == -1) | ||
113 | retVal = 0; | ||
114 | return retVal; | ||
115 | } | ||
116 | |||
117 | static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMap(void) | ||
118 | { | ||
119 | return HvLpConfig_getVirtualLanIndexMapForLp( | ||
120 | HvLpConfig_getLpIndex_outline()); | ||
121 | } | ||
122 | |||
123 | static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1, | ||
124 | HvLpIndex lp2) | ||
125 | { | ||
126 | HvLpVirtualLanIndexMap virtualLanIndexMap1 = | ||
127 | HvLpConfig_getVirtualLanIndexMapForLp(lp1); | ||
128 | HvLpVirtualLanIndexMap virtualLanIndexMap2 = | ||
129 | HvLpConfig_getVirtualLanIndexMapForLp(lp2); | ||
130 | return ((virtualLanIndexMap1 & virtualLanIndexMap2) != 0); | ||
131 | } | ||
132 | |||
133 | static inline HvLpIndex HvLpConfig_getHostingLpIndex(HvLpIndex lp) | ||
134 | { | ||
135 | return HvCall1(HvCallCfgGetHostingLpIndex, lp); | ||
136 | } | ||
137 | |||
138 | #endif /* _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H */ | ||
diff --git a/include/asm-powerpc/iseries/hv_lp_event.h b/include/asm-powerpc/iseries/hv_lp_event.h new file mode 100644 index 000000000000..499ab1ad0185 --- /dev/null +++ b/include/asm-powerpc/iseries/hv_lp_event.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | * HvLpEvent.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | /* This file contains the class for HV events in the system. */ | ||
21 | |||
22 | #ifndef _ASM_POWERPC_ISERIES_HV_LP_EVENT_H | ||
23 | #define _ASM_POWERPC_ISERIES_HV_LP_EVENT_H | ||
24 | |||
25 | #include <asm/types.h> | ||
26 | #include <asm/ptrace.h> | ||
27 | #include <asm/iseries/hv_types.h> | ||
28 | #include <asm/iseries/hv_call_event.h> | ||
29 | |||
30 | /* | ||
31 | * HvLpEvent is the structure for Lp Event messages passed between | ||
32 | * partitions through PLIC. | ||
33 | */ | ||
34 | |||
35 | struct HvEventFlags { | ||
36 | u8 xValid:1; /* Indicates a valid request x00-x00 */ | ||
37 | u8 xRsvd1:4; /* Reserved ... */ | ||
38 | u8 xAckType:1; /* Immediate or deferred ... */ | ||
39 | u8 xAckInd:1; /* Indicates if ACK required ... */ | ||
40 | u8 xFunction:1; /* Interrupt or Acknowledge ... */ | ||
41 | }; | ||
42 | |||
43 | |||
44 | struct HvLpEvent { | ||
45 | struct HvEventFlags xFlags; /* Event flags x00-x00 */ | ||
46 | u8 xType; /* Type of message x01-x01 */ | ||
47 | u16 xSubtype; /* Subtype for event x02-x03 */ | ||
48 | u8 xSourceLp; /* Source LP x04-x04 */ | ||
49 | u8 xTargetLp; /* Target LP x05-x05 */ | ||
50 | u8 xSizeMinus1; /* Size of Derived class - 1 x06-x06 */ | ||
51 | u8 xRc; /* RC for Ack flows x07-x07 */ | ||
52 | u16 xSourceInstanceId; /* Source sides instance id x08-x09 */ | ||
53 | u16 xTargetInstanceId; /* Target sides instance id x0A-x0B */ | ||
54 | union { | ||
55 | u32 xSubtypeData; /* Data usable by the subtype x0C-x0F */ | ||
56 | u16 xSubtypeDataShort[2]; /* Data as 2 shorts */ | ||
57 | u8 xSubtypeDataChar[4]; /* Data as 4 chars */ | ||
58 | } x; | ||
59 | |||
60 | u64 xCorrelationToken; /* Unique value for source/type x10-x17 */ | ||
61 | }; | ||
62 | |||
63 | typedef void (*LpEventHandler)(struct HvLpEvent *, struct pt_regs *); | ||
64 | |||
65 | /* Register a handler for an event type - returns 0 on success */ | ||
66 | extern int HvLpEvent_registerHandler(HvLpEvent_Type eventType, | ||
67 | LpEventHandler hdlr); | ||
68 | |||
69 | /* | ||
70 | * Unregister a handler for an event type | ||
71 | * | ||
72 | * This call will sleep until the handler being removed is guaranteed to | ||
73 | * be no longer executing on any CPU. Do not call with locks held. | ||
74 | * | ||
75 | * returns 0 on success | ||
76 | * Unregister will fail if there are any paths open for the type | ||
77 | */ | ||
78 | extern int HvLpEvent_unregisterHandler(HvLpEvent_Type eventType); | ||
79 | |||
80 | /* | ||
81 | * Open an Lp Event Path for an event type | ||
82 | * returns 0 on success | ||
83 | * openPath will fail if there is no handler registered for the event type. | ||
84 | * The lpIndex specified is the partition index for the target partition | ||
85 | * (for VirtualIo, VirtualLan and SessionMgr) other types specify zero) | ||
86 | */ | ||
87 | extern int HvLpEvent_openPath(HvLpEvent_Type eventType, HvLpIndex lpIndex); | ||
88 | |||
89 | /* | ||
90 | * Close an Lp Event Path for a type and partition | ||
91 | * returns 0 on sucess | ||
92 | */ | ||
93 | extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex); | ||
94 | |||
95 | #define HvLpEvent_Type_Hypervisor 0 | ||
96 | #define HvLpEvent_Type_MachineFac 1 | ||
97 | #define HvLpEvent_Type_SessionMgr 2 | ||
98 | #define HvLpEvent_Type_SpdIo 3 | ||
99 | #define HvLpEvent_Type_VirtualBus 4 | ||
100 | #define HvLpEvent_Type_PciIo 5 | ||
101 | #define HvLpEvent_Type_RioIo 6 | ||
102 | #define HvLpEvent_Type_VirtualLan 7 | ||
103 | #define HvLpEvent_Type_VirtualIo 8 | ||
104 | #define HvLpEvent_Type_NumTypes 9 | ||
105 | |||
106 | #define HvLpEvent_Rc_Good 0 | ||
107 | #define HvLpEvent_Rc_BufferNotAvailable 1 | ||
108 | #define HvLpEvent_Rc_Cancelled 2 | ||
109 | #define HvLpEvent_Rc_GenericError 3 | ||
110 | #define HvLpEvent_Rc_InvalidAddress 4 | ||
111 | #define HvLpEvent_Rc_InvalidPartition 5 | ||
112 | #define HvLpEvent_Rc_InvalidSize 6 | ||
113 | #define HvLpEvent_Rc_InvalidSubtype 7 | ||
114 | #define HvLpEvent_Rc_InvalidSubtypeData 8 | ||
115 | #define HvLpEvent_Rc_InvalidType 9 | ||
116 | #define HvLpEvent_Rc_PartitionDead 10 | ||
117 | #define HvLpEvent_Rc_PathClosed 11 | ||
118 | #define HvLpEvent_Rc_SubtypeError 12 | ||
119 | |||
120 | #define HvLpEvent_Function_Ack 0 | ||
121 | #define HvLpEvent_Function_Int 1 | ||
122 | |||
123 | #define HvLpEvent_AckInd_NoAck 0 | ||
124 | #define HvLpEvent_AckInd_DoAck 1 | ||
125 | |||
126 | #define HvLpEvent_AckType_ImmediateAck 0 | ||
127 | #define HvLpEvent_AckType_DeferredAck 1 | ||
128 | |||
129 | #define HvLpDma_Direction_LocalToRemote 0 | ||
130 | #define HvLpDma_Direction_RemoteToLocal 1 | ||
131 | |||
132 | #define HvLpDma_AddressType_TceIndex 0 | ||
133 | #define HvLpDma_AddressType_RealAddress 1 | ||
134 | |||
135 | #define HvLpDma_Rc_Good 0 | ||
136 | #define HvLpDma_Rc_Error 1 | ||
137 | #define HvLpDma_Rc_PartitionDead 2 | ||
138 | #define HvLpDma_Rc_PathClosed 3 | ||
139 | #define HvLpDma_Rc_InvalidAddress 4 | ||
140 | #define HvLpDma_Rc_InvalidLength 5 | ||
141 | |||
142 | #endif /* _ASM_POWERPC_ISERIES_HV_LP_EVENT_H */ | ||
diff --git a/include/asm-powerpc/iseries/hv_types.h b/include/asm-powerpc/iseries/hv_types.h new file mode 100644 index 000000000000..c38f7e3d01dc --- /dev/null +++ b/include/asm-powerpc/iseries/hv_types.h | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * HvTypes.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | #ifndef _ASM_POWERPC_ISERIES_HV_TYPES_H | ||
20 | #define _ASM_POWERPC_ISERIES_HV_TYPES_H | ||
21 | |||
22 | /* | ||
23 | * General typedefs for the hypervisor. | ||
24 | */ | ||
25 | |||
26 | #include <asm/types.h> | ||
27 | |||
28 | typedef u8 HvLpIndex; | ||
29 | typedef u16 HvLpInstanceId; | ||
30 | typedef u64 HvLpTOD; | ||
31 | typedef u64 HvLpSystemSerialNum; | ||
32 | typedef u8 HvLpDeviceSerialNum[12]; | ||
33 | typedef u16 HvLpSanHwSet; | ||
34 | typedef u16 HvLpBus; | ||
35 | typedef u16 HvLpBoard; | ||
36 | typedef u16 HvLpCard; | ||
37 | typedef u8 HvLpDeviceType[4]; | ||
38 | typedef u8 HvLpDeviceModel[3]; | ||
39 | typedef u64 HvIoToken; | ||
40 | typedef u8 HvLpName[8]; | ||
41 | typedef u32 HvIoId; | ||
42 | typedef u64 HvRealMemoryIndex; | ||
43 | typedef u32 HvLpIndexMap; /* Must hold HVMAXARCHITECTEDLPS bits!!! */ | ||
44 | typedef u16 HvLpVrmIndex; | ||
45 | typedef u32 HvXmGenerationId; | ||
46 | typedef u8 HvLpBusPool; | ||
47 | typedef u8 HvLpSharedPoolIndex; | ||
48 | typedef u16 HvLpSharedProcUnitsX100; | ||
49 | typedef u8 HvLpVirtualLanIndex; | ||
50 | typedef u16 HvLpVirtualLanIndexMap; /* Must hold HVMAXARCHITECTEDVIRTUALLANS bits!!! */ | ||
51 | typedef u16 HvBusNumber; /* Hypervisor Bus Number */ | ||
52 | typedef u8 HvSubBusNumber; /* Hypervisor SubBus Number */ | ||
53 | typedef u8 HvAgentId; /* Hypervisor DevFn */ | ||
54 | |||
55 | |||
56 | #define HVMAXARCHITECTEDLPS 32 | ||
57 | #define HVMAXARCHITECTEDVIRTUALLANS 16 | ||
58 | #define HVMAXARCHITECTEDVIRTUALDISKS 32 | ||
59 | #define HVMAXARCHITECTEDVIRTUALCDROMS 8 | ||
60 | #define HVMAXARCHITECTEDVIRTUALTAPES 8 | ||
61 | #define HVCHUNKSIZE (256 * 1024) | ||
62 | #define HVPAGESIZE (4 * 1024) | ||
63 | #define HVLPMINMEGSPRIMARY 256 | ||
64 | #define HVLPMINMEGSSECONDARY 64 | ||
65 | #define HVCHUNKSPERMEG 4 | ||
66 | #define HVPAGESPERMEG 256 | ||
67 | #define HVPAGESPERCHUNK 64 | ||
68 | |||
69 | #define HvLpIndexInvalid ((HvLpIndex)0xff) | ||
70 | |||
71 | /* | ||
72 | * Enums for the sub-components under PLIC | ||
73 | * Used in HvCall and HvPrimaryCall | ||
74 | */ | ||
75 | enum { | ||
76 | HvCallCompId = 0, | ||
77 | HvCallCpuCtlsCompId = 1, | ||
78 | HvCallCfgCompId = 2, | ||
79 | HvCallEventCompId = 3, | ||
80 | HvCallHptCompId = 4, | ||
81 | HvCallPciCompId = 5, | ||
82 | HvCallSlmCompId = 6, | ||
83 | HvCallSmCompId = 7, | ||
84 | HvCallSpdCompId = 8, | ||
85 | HvCallXmCompId = 9, | ||
86 | HvCallRioCompId = 10, | ||
87 | HvCallRsvd3CompId = 11, | ||
88 | HvCallRsvd2CompId = 12, | ||
89 | HvCallRsvd1CompId = 13, | ||
90 | HvCallMaxCompId = 14, | ||
91 | HvPrimaryCallCompId = 0, | ||
92 | HvPrimaryCallCfgCompId = 1, | ||
93 | HvPrimaryCallPciCompId = 2, | ||
94 | HvPrimaryCallSmCompId = 3, | ||
95 | HvPrimaryCallSpdCompId = 4, | ||
96 | HvPrimaryCallXmCompId = 5, | ||
97 | HvPrimaryCallRioCompId = 6, | ||
98 | HvPrimaryCallRsvd7CompId = 7, | ||
99 | HvPrimaryCallRsvd6CompId = 8, | ||
100 | HvPrimaryCallRsvd5CompId = 9, | ||
101 | HvPrimaryCallRsvd4CompId = 10, | ||
102 | HvPrimaryCallRsvd3CompId = 11, | ||
103 | HvPrimaryCallRsvd2CompId = 12, | ||
104 | HvPrimaryCallRsvd1CompId = 13, | ||
105 | HvPrimaryCallMaxCompId = HvCallMaxCompId | ||
106 | }; | ||
107 | |||
108 | struct HvLpBufferList { | ||
109 | u64 addr; | ||
110 | u64 len; | ||
111 | }; | ||
112 | |||
113 | #endif /* _ASM_POWERPC_ISERIES_HV_TYPES_H */ | ||
diff --git a/include/asm-powerpc/iseries/iseries_io.h b/include/asm-powerpc/iseries/iseries_io.h new file mode 100644 index 000000000000..56b2113ff0f5 --- /dev/null +++ b/include/asm-powerpc/iseries/iseries_io.h | |||
@@ -0,0 +1,49 @@ | |||
1 | #ifndef _ASM_POWERPC_ISERIES_ISERIES_IO_H | ||
2 | #define _ASM_POWERPC_ISERIES_ISERIES_IO_H | ||
3 | |||
4 | #include <linux/config.h> | ||
5 | |||
6 | #ifdef CONFIG_PPC_ISERIES | ||
7 | #include <linux/types.h> | ||
8 | /* | ||
9 | * File iSeries_io.h created by Allan Trautman on Thu Dec 28 2000. | ||
10 | * | ||
11 | * Remaps the io.h for the iSeries Io | ||
12 | * Copyright (C) 2000 Allan H Trautman, IBM Corporation | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License as published by | ||
16 | * the Free Software Foundation; either version 2 of the License, or | ||
17 | * (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the: | ||
26 | * Free Software Foundation, Inc., | ||
27 | * 59 Temple Place, Suite 330, | ||
28 | * Boston, MA 02111-1307 USA | ||
29 | * | ||
30 | * Change Activity: | ||
31 | * Created December 28, 2000 | ||
32 | * End Change Activity | ||
33 | */ | ||
34 | |||
35 | extern u8 iSeries_Read_Byte(const volatile void __iomem * IoAddress); | ||
36 | extern u16 iSeries_Read_Word(const volatile void __iomem * IoAddress); | ||
37 | extern u32 iSeries_Read_Long(const volatile void __iomem * IoAddress); | ||
38 | extern void iSeries_Write_Byte(u8 IoData, volatile void __iomem * IoAddress); | ||
39 | extern void iSeries_Write_Word(u16 IoData, volatile void __iomem * IoAddress); | ||
40 | extern void iSeries_Write_Long(u32 IoData, volatile void __iomem * IoAddress); | ||
41 | |||
42 | extern void iSeries_memset_io(volatile void __iomem *dest, char x, size_t n); | ||
43 | extern void iSeries_memcpy_toio(volatile void __iomem *dest, void *source, | ||
44 | size_t n); | ||
45 | extern void iSeries_memcpy_fromio(void *dest, | ||
46 | const volatile void __iomem *source, size_t n); | ||
47 | |||
48 | #endif /* CONFIG_PPC_ISERIES */ | ||
49 | #endif /* _ASM_POWERPC_ISERIES_ISERIES_IO_H */ | ||
diff --git a/include/asm-powerpc/iseries/it_exp_vpd_panel.h b/include/asm-powerpc/iseries/it_exp_vpd_panel.h new file mode 100644 index 000000000000..66a17a230c52 --- /dev/null +++ b/include/asm-powerpc/iseries/it_exp_vpd_panel.h | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * ItExtVpdPanel.h | ||
3 | * Copyright (C) 2002 Dave Boutcher IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | #ifndef _ASM_POWERPC_ISERIES_IT_EXT_VPD_PANEL_H | ||
20 | #define _ASM_POWERPC_ISERIES_IT_EXT_VPD_PANEL_H | ||
21 | |||
22 | /* | ||
23 | * This struct maps the panel information | ||
24 | * | ||
25 | * Warning: | ||
26 | * This data must match the architecture for the panel information | ||
27 | */ | ||
28 | |||
29 | #include <asm/types.h> | ||
30 | |||
31 | struct ItExtVpdPanel { | ||
32 | /* Definition of the Extended Vpd On Panel Data Area */ | ||
33 | char systemSerial[8]; | ||
34 | char mfgID[4]; | ||
35 | char reserved1[24]; | ||
36 | char machineType[4]; | ||
37 | char systemID[6]; | ||
38 | char somUniqueCnt[4]; | ||
39 | char serialNumberCount; | ||
40 | char reserved2[7]; | ||
41 | u16 bbu3; | ||
42 | u16 bbu2; | ||
43 | u16 bbu1; | ||
44 | char xLocationLabel[8]; | ||
45 | u8 xRsvd1[6]; | ||
46 | u16 xFrameId; | ||
47 | u8 xRsvd2[48]; | ||
48 | }; | ||
49 | |||
50 | extern struct ItExtVpdPanel xItExtVpdPanel; | ||
51 | |||
52 | #endif /* _ASM_POWERPC_ISERIES_IT_EXT_VPD_PANEL_H */ | ||
diff --git a/include/asm-powerpc/iseries/it_lp_naca.h b/include/asm-powerpc/iseries/it_lp_naca.h new file mode 100644 index 000000000000..c3ef1de45d82 --- /dev/null +++ b/include/asm-powerpc/iseries/it_lp_naca.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * ItLpNaca.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | #ifndef _ASM_POWERPC_ISERIES_IT_LP_NACA_H | ||
20 | #define _ASM_POWERPC_ISERIES_IT_LP_NACA_H | ||
21 | |||
22 | #include <linux/types.h> | ||
23 | |||
24 | /* | ||
25 | * This control block contains the data that is shared between the | ||
26 | * hypervisor (PLIC) and the OS. | ||
27 | */ | ||
28 | |||
29 | struct ItLpNaca { | ||
30 | // CACHE_LINE_1 0x0000 - 0x007F Contains read-only data | ||
31 | u32 xDesc; // Eye catcher x00-x03 | ||
32 | u16 xSize; // Size of this class x04-x05 | ||
33 | u16 xIntHdlrOffset; // Offset to IntHdlr array x06-x07 | ||
34 | u8 xMaxIntHdlrEntries; // Number of entries in array x08-x08 | ||
35 | u8 xPrimaryLpIndex; // LP Index of Primary x09-x09 | ||
36 | u8 xServiceLpIndex; // LP Ind of Service Focal Pointx0A-x0A | ||
37 | u8 xLpIndex; // LP Index x0B-x0B | ||
38 | u16 xMaxLpQueues; // Number of allocated queues x0C-x0D | ||
39 | u16 xLpQueueOffset; // Offset to start of LP queues x0E-x0F | ||
40 | u8 xPirEnvironMode:8; // Piranha or hardware x10-x10 | ||
41 | u8 xPirConsoleMode:8; // Piranha console indicator x11-x11 | ||
42 | u8 xPirDasdMode:8; // Piranha dasd indicator x12-x12 | ||
43 | u8 xRsvd1_0[5]; // Reserved for Piranha related x13-x17 | ||
44 | u8 xLparInstalled:1; // Is LPAR installed on system x18-x1F | ||
45 | u8 xSysPartitioned:1; // Is the system partitioned ... | ||
46 | u8 xHwSyncedTBs:1; // Hardware synced TBs ... | ||
47 | u8 xIntProcUtilHmt:1; // Utilize HMT for interrupts ... | ||
48 | u8 xRsvd1_1:4; // Reserved ... | ||
49 | u8 xSpVpdFormat:8; // VPD areas are in CSP format ... | ||
50 | u8 xIntProcRatio:8; // Ratio of int procs to procs ... | ||
51 | u8 xRsvd1_2[5]; // Reserved ... | ||
52 | u16 xRsvd1_3; // Reserved x20-x21 | ||
53 | u16 xPlicVrmIndex; // VRM index of PLIC x22-x23 | ||
54 | u16 xMinSupportedSlicVrmInd;// Min supported OS VRM index x24-x25 | ||
55 | u16 xMinCompatableSlicVrmInd;// Min compatible OS VRM index x26-x27 | ||
56 | u64 xLoadAreaAddr; // ER address of load area x28-x2F | ||
57 | u32 xLoadAreaChunks; // Chunks for the load area x30-x33 | ||
58 | u32 xPaseSysCallCRMask; // Mask used to test CR before x34-x37 | ||
59 | // doing an ASR switch on PASE | ||
60 | // system call. | ||
61 | u64 xSlicSegmentTablePtr; // Pointer to Slic seg table. x38-x3f | ||
62 | u8 xRsvd1_4[64]; // x40-x7F | ||
63 | |||
64 | // CACHE_LINE_2 0x0080 - 0x00FF Contains local read-write data | ||
65 | u8 xRsvd2_0[128]; // Reserved x00-x7F | ||
66 | |||
67 | // CACHE_LINE_3-6 0x0100 - 0x02FF Contains LP Queue indicators | ||
68 | // NB: Padding required to keep xInterrruptHdlr at x300 which is required | ||
69 | // for v4r4 PLIC. | ||
70 | u8 xOldLpQueue[128]; // LP Queue needed for v4r4 100-17F | ||
71 | u8 xRsvd3_0[384]; // Reserved 180-2FF | ||
72 | |||
73 | // CACHE_LINE_7-8 0x0300 - 0x03FF Contains the address of the OS interrupt | ||
74 | // handlers | ||
75 | u64 xInterruptHdlr[32]; // Interrupt handlers 300-x3FF | ||
76 | }; | ||
77 | |||
78 | extern struct ItLpNaca itLpNaca; | ||
79 | |||
80 | #endif /* _ASM_POWERPC_ISERIES_IT_LP_NACA_H */ | ||
diff --git a/include/asm-powerpc/iseries/it_lp_queue.h b/include/asm-powerpc/iseries/it_lp_queue.h new file mode 100644 index 000000000000..a60d03afbf95 --- /dev/null +++ b/include/asm-powerpc/iseries/it_lp_queue.h | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * ItLpQueue.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | #ifndef _ASM_POWERPC_ISERIES_IT_LP_QUEUE_H | ||
20 | #define _ASM_POWERPC_ISERIES_IT_LP_QUEUE_H | ||
21 | |||
22 | /* | ||
23 | * This control block defines the simple LP queue structure that is | ||
24 | * shared between the hypervisor (PLIC) and the OS in order to send | ||
25 | * events to an LP. | ||
26 | */ | ||
27 | |||
28 | #include <asm/types.h> | ||
29 | #include <asm/ptrace.h> | ||
30 | |||
31 | struct HvLpEvent; | ||
32 | |||
33 | #define ITMaxLpQueues 8 | ||
34 | |||
35 | #define NotUsed 0 // Queue will not be used by PLIC | ||
36 | #define DedicatedIo 1 // Queue dedicated to IO processor specified | ||
37 | #define DedicatedLp 2 // Queue dedicated to LP specified | ||
38 | #define Shared 3 // Queue shared for both IO and LP | ||
39 | |||
40 | #define LpEventStackSize 4096 | ||
41 | #define LpEventMaxSize 256 | ||
42 | #define LpEventAlign 64 | ||
43 | |||
44 | struct hvlpevent_queue { | ||
45 | /* | ||
46 | * The xSlicCurEventPtr is the pointer to the next event stack entry | ||
47 | * that will become valid. The OS must peek at this entry to determine | ||
48 | * if it is valid. PLIC will set the valid indicator as the very last | ||
49 | * store into that entry. | ||
50 | * | ||
51 | * When the OS has completed processing of the event then it will mark | ||
52 | * the event as invalid so that PLIC knows it can store into that event | ||
53 | * location again. | ||
54 | * | ||
55 | * If the event stack fills and there are overflow events, then PLIC | ||
56 | * will set the xPlicOverflowIntPending flag in which case the OS will | ||
57 | * have to fetch the additional LP events once they have drained the | ||
58 | * event stack. | ||
59 | * | ||
60 | * The first 16-bytes are known by both the OS and PLIC. The remainder | ||
61 | * of the cache line is for use by the OS. | ||
62 | */ | ||
63 | u8 xPlicOverflowIntPending;// 0x00 Overflow events are pending | ||
64 | u8 xPlicStatus; // 0x01 DedicatedIo or DedicatedLp or NotUsed | ||
65 | u16 xSlicLogicalProcIndex; // 0x02 Logical Proc Index for correlation | ||
66 | u8 xPlicRsvd[12]; // 0x04 | ||
67 | char *xSlicCurEventPtr; // 0x10 | ||
68 | char *xSlicLastValidEventPtr; // 0x18 | ||
69 | char *xSlicEventStackPtr; // 0x20 | ||
70 | u8 xIndex; // 0x28 unique sequential index. | ||
71 | u8 xSlicRsvd[3]; // 0x29-2b | ||
72 | spinlock_t lock; | ||
73 | }; | ||
74 | |||
75 | extern struct hvlpevent_queue hvlpevent_queue; | ||
76 | |||
77 | extern int hvlpevent_is_pending(void); | ||
78 | extern void process_hvlpevents(struct pt_regs *); | ||
79 | extern void setup_hvlpevent_queue(void); | ||
80 | |||
81 | #endif /* _ASM_POWERPC_ISERIES_IT_LP_QUEUE_H */ | ||
diff --git a/include/asm-powerpc/iseries/it_lp_reg_save.h b/include/asm-powerpc/iseries/it_lp_reg_save.h new file mode 100644 index 000000000000..288044b702de --- /dev/null +++ b/include/asm-powerpc/iseries/it_lp_reg_save.h | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * ItLpRegSave.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | #ifndef _ASM_POWERPC_ISERIES_IT_LP_REG_SAVE_H | ||
20 | #define _ASM_POWERPC_ISERIES_IT_LP_REG_SAVE_H | ||
21 | |||
22 | /* | ||
23 | * This control block contains the data that is shared between PLIC | ||
24 | * and the OS | ||
25 | */ | ||
26 | |||
27 | struct ItLpRegSave { | ||
28 | u32 xDesc; // Eye catcher "LpRS" ebcdic 000-003 | ||
29 | u16 xSize; // Size of this class 004-005 | ||
30 | u8 xInUse; // Area is live 006-007 | ||
31 | u8 xRsvd1[9]; // Reserved 007-00F | ||
32 | |||
33 | u8 xFixedRegSave[352]; // Fixed Register Save Area 010-16F | ||
34 | u32 xCTRL; // Control Register 170-173 | ||
35 | u32 xDEC; // Decrementer 174-177 | ||
36 | u32 xFPSCR; // FP Status and Control Reg 178-17B | ||
37 | u32 xPVR; // Processor Version Number 17C-17F | ||
38 | |||
39 | u64 xMMCR0; // Monitor Mode Control Reg 0 180-187 | ||
40 | u32 xPMC1; // Perf Monitor Counter 1 188-18B | ||
41 | u32 xPMC2; // Perf Monitor Counter 2 18C-18F | ||
42 | u32 xPMC3; // Perf Monitor Counter 3 190-193 | ||
43 | u32 xPMC4; // Perf Monitor Counter 4 194-197 | ||
44 | u32 xPIR; // Processor ID Reg 198-19B | ||
45 | |||
46 | u32 xMMCR1; // Monitor Mode Control Reg 1 19C-19F | ||
47 | u32 xMMCRA; // Monitor Mode Control Reg A 1A0-1A3 | ||
48 | u32 xPMC5; // Perf Monitor Counter 5 1A4-1A7 | ||
49 | u32 xPMC6; // Perf Monitor Counter 6 1A8-1AB | ||
50 | u32 xPMC7; // Perf Monitor Counter 7 1AC-1AF | ||
51 | u32 xPMC8; // Perf Monitor Counter 8 1B0-1B3 | ||
52 | u32 xTSC; // Thread Switch Control 1B4-1B7 | ||
53 | u32 xTST; // Thread Switch Timeout 1B8-1BB | ||
54 | u32 xRsvd; // Reserved 1BC-1BF | ||
55 | |||
56 | u64 xACCR; // Address Compare Control Reg 1C0-1C7 | ||
57 | u64 xIMR; // Instruction Match Register 1C8-1CF | ||
58 | u64 xSDR1; // Storage Description Reg 1 1D0-1D7 | ||
59 | u64 xSPRG0; // Special Purpose Reg General0 1D8-1DF | ||
60 | u64 xSPRG1; // Special Purpose Reg General1 1E0-1E7 | ||
61 | u64 xSPRG2; // Special Purpose Reg General2 1E8-1EF | ||
62 | u64 xSPRG3; // Special Purpose Reg General3 1F0-1F7 | ||
63 | u64 xTB; // Time Base Register 1F8-1FF | ||
64 | |||
65 | u64 xFPR[32]; // Floating Point Registers 200-2FF | ||
66 | |||
67 | u64 xMSR; // Machine State Register 300-307 | ||
68 | u64 xNIA; // Next Instruction Address 308-30F | ||
69 | |||
70 | u64 xDABR; // Data Address Breakpoint Reg 310-317 | ||
71 | u64 xIABR; // Inst Address Breakpoint Reg 318-31F | ||
72 | |||
73 | u64 xHID0; // HW Implementation Dependent0 320-327 | ||
74 | |||
75 | u64 xHID4; // HW Implementation Dependent4 328-32F | ||
76 | u64 xSCOMd; // SCON Data Reg (SPRG4) 330-337 | ||
77 | u64 xSCOMc; // SCON Command Reg (SPRG5) 338-33F | ||
78 | u64 xSDAR; // Sample Data Address Register 340-347 | ||
79 | u64 xSIAR; // Sample Inst Address Register 348-34F | ||
80 | |||
81 | u8 xRsvd3[176]; // Reserved 350-3FF | ||
82 | }; | ||
83 | |||
84 | #endif /* _ITLPREGSAVE_H */ | ||
diff --git a/include/asm-powerpc/iseries/lpar_map.h b/include/asm-powerpc/iseries/lpar_map.h new file mode 100644 index 000000000000..84fc321615bf --- /dev/null +++ b/include/asm-powerpc/iseries/lpar_map.h | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * LparMap.h | ||
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | #ifndef _ASM_POWERPC_ISERIES_LPAR_MAP_H | ||
20 | #define _ASM_POWERPC_ISERIES_LPAR_MAP_H | ||
21 | |||
22 | #ifndef __ASSEMBLY__ | ||
23 | |||
24 | #include <asm/types.h> | ||
25 | |||
26 | /* | ||
27 | * The iSeries hypervisor will set up mapping for one or more | ||
28 | * ESID/VSID pairs (in SLB/segment registers) and will set up | ||
29 | * mappings of one or more ranges of pages to VAs. | ||
30 | * We will have the hypervisor set up the ESID->VSID mapping | ||
31 | * for the four kernel segments (C-F). With shared processors, | ||
32 | * the hypervisor will clear all segment registers and reload | ||
33 | * these four whenever the processor is switched from one | ||
34 | * partition to another. | ||
35 | */ | ||
36 | |||
37 | /* The Vsid and Esid identified below will be used by the hypervisor | ||
38 | * to set up a memory mapping for part of the load area before giving | ||
39 | * control to the Linux kernel. The load area is 64 MB, but this must | ||
40 | * not attempt to map the whole load area. The Hashed Page Table may | ||
41 | * need to be located within the load area (if the total partition size | ||
42 | * is 64 MB), but cannot be mapped. Typically, this should specify | ||
43 | * to map half (32 MB) of the load area. | ||
44 | * | ||
45 | * The hypervisor will set up page table entries for the number of | ||
46 | * pages specified. | ||
47 | * | ||
48 | * In 32-bit mode, the hypervisor will load all four of the | ||
49 | * segment registers (identified by the low-order four bits of the | ||
50 | * Esid field. In 64-bit mode, the hypervisor will load one SLB | ||
51 | * entry to map the Esid to the Vsid. | ||
52 | */ | ||
53 | |||
54 | #define HvEsidsToMap 2 | ||
55 | #define HvRangesToMap 1 | ||
56 | |||
57 | /* Hypervisor initially maps 32MB of the load area */ | ||
58 | #define HvPagesToMap 8192 | ||
59 | |||
60 | struct LparMap { | ||
61 | u64 xNumberEsids; // Number of ESID/VSID pairs | ||
62 | u64 xNumberRanges; // Number of VA ranges to map | ||
63 | u64 xSegmentTableOffs; // Page number within load area of seg table | ||
64 | u64 xRsvd[5]; | ||
65 | struct { | ||
66 | u64 xKernelEsid; // Esid used to map kernel load | ||
67 | u64 xKernelVsid; // Vsid used to map kernel load | ||
68 | } xEsids[HvEsidsToMap]; | ||
69 | struct { | ||
70 | u64 xPages; // Number of pages to be mapped | ||
71 | u64 xOffset; // Offset from start of load area | ||
72 | u64 xVPN; // Virtual Page Number | ||
73 | } xRanges[HvRangesToMap]; | ||
74 | }; | ||
75 | |||
76 | extern const struct LparMap xLparMap; | ||
77 | |||
78 | #endif /* __ASSEMBLY__ */ | ||
79 | |||
80 | /* the fixed address where the LparMap exists */ | ||
81 | #define LPARMAP_PHYS 0x7000 | ||
82 | |||
83 | #endif /* _ASM_POWERPC_ISERIES_LPAR_MAP_H */ | ||
diff --git a/include/asm-powerpc/iseries/mf.h b/include/asm-powerpc/iseries/mf.h new file mode 100644 index 000000000000..e7bd57a03fb1 --- /dev/null +++ b/include/asm-powerpc/iseries/mf.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | * mf.h | ||
3 | * Copyright (C) 2001 Troy D. Armstrong IBM Corporation | ||
4 | * Copyright (C) 2004 Stephen Rothwell IBM Corporation | ||
5 | * | ||
6 | * This modules exists as an interface between a Linux secondary partition | ||
7 | * running on an iSeries and the primary partition's Virtual Service | ||
8 | * Processor (VSP) object. The VSP has final authority over powering on/off | ||
9 | * all partitions in the iSeries. It also provides miscellaneous low-level | ||
10 | * machine facility type operations. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | */ | ||
26 | #ifndef _ASM_POWERPC_ISERIES_MF_H | ||
27 | #define _ASM_POWERPC_ISERIES_MF_H | ||
28 | |||
29 | #include <linux/types.h> | ||
30 | |||
31 | #include <asm/iseries/hv_types.h> | ||
32 | #include <asm/iseries/hv_call_event.h> | ||
33 | |||
34 | struct rtc_time; | ||
35 | |||
36 | typedef void (*MFCompleteHandler)(void *clientToken, int returnCode); | ||
37 | |||
38 | extern void mf_allocate_lp_events(HvLpIndex targetLp, HvLpEvent_Type type, | ||
39 | unsigned size, unsigned amount, MFCompleteHandler hdlr, | ||
40 | void *userToken); | ||
41 | extern void mf_deallocate_lp_events(HvLpIndex targetLp, HvLpEvent_Type type, | ||
42 | unsigned count, MFCompleteHandler hdlr, void *userToken); | ||
43 | |||
44 | extern void mf_power_off(void); | ||
45 | extern void mf_reboot(void); | ||
46 | |||
47 | extern void mf_display_src(u32 word); | ||
48 | extern void mf_display_progress(u16 value); | ||
49 | extern void mf_clear_src(void); | ||
50 | |||
51 | extern void mf_init(void); | ||
52 | |||
53 | extern int mf_get_rtc(struct rtc_time *tm); | ||
54 | extern int mf_get_boot_rtc(struct rtc_time *tm); | ||
55 | extern int mf_set_rtc(struct rtc_time *tm); | ||
56 | |||
57 | #endif /* _ASM_POWERPC_ISERIES_MF_H */ | ||
diff --git a/include/asm-powerpc/iseries/vio.h b/include/asm-powerpc/iseries/vio.h new file mode 100644 index 000000000000..7e3a469420dd --- /dev/null +++ b/include/asm-powerpc/iseries/vio.h | |||
@@ -0,0 +1,130 @@ | |||
1 | /* -*- linux-c -*- | ||
2 | * drivers/char/vio.h | ||
3 | * | ||
4 | * iSeries Virtual I/O Message Path header | ||
5 | * | ||
6 | * Authors: Dave Boutcher <boutcher@us.ibm.com> | ||
7 | * Ryan Arnold <ryanarn@us.ibm.com> | ||
8 | * Colin Devilbiss <devilbis@us.ibm.com> | ||
9 | * | ||
10 | * (C) Copyright 2000 IBM Corporation | ||
11 | * | ||
12 | * This header file is used by the iSeries virtual I/O device | ||
13 | * drivers. It defines the interfaces to the common functions | ||
14 | * (implemented in drivers/char/viopath.h) as well as defining | ||
15 | * common functions and structures. Currently (at the time I | ||
16 | * wrote this comment) the iSeries virtual I/O device drivers | ||
17 | * that use this are | ||
18 | * drivers/block/viodasd.c | ||
19 | * drivers/char/viocons.c | ||
20 | * drivers/char/viotape.c | ||
21 | * drivers/cdrom/viocd.c | ||
22 | * | ||
23 | * The iSeries virtual ethernet support (veth.c) uses a whole | ||
24 | * different set of functions. | ||
25 | * | ||
26 | * This program is free software; you can redistribute it and/or | ||
27 | * modify it under the terms of the GNU General Public License as | ||
28 | * published by the Free Software Foundation; either version 2 of the | ||
29 | * License, or (at your option) anyu later version. | ||
30 | * | ||
31 | * This program is distributed in the hope that it will be useful, but | ||
32 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
33 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
34 | * General Public License for more details. | ||
35 | * | ||
36 | * You should have received a copy of the GNU General Public License | ||
37 | * along with this program; if not, write to the Free Software Foundation, | ||
38 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
39 | * | ||
40 | */ | ||
41 | #ifndef _ASM_POWERPC_ISERIES_VIO_H | ||
42 | #define _ASM_POWERPC_ISERIES_VIO_H | ||
43 | |||
44 | #include <asm/iseries/hv_types.h> | ||
45 | #include <asm/iseries/hv_lp_event.h> | ||
46 | |||
47 | /* | ||
48 | * iSeries virtual I/O events use the subtype field in | ||
49 | * HvLpEvent to figure out what kind of vio event is coming | ||
50 | * in. We use a table to route these, and this defines | ||
51 | * the maximum number of distinct subtypes | ||
52 | */ | ||
53 | #define VIO_MAX_SUBTYPES 8 | ||
54 | |||
55 | /* | ||
56 | * Each subtype can register a handler to process their events. | ||
57 | * The handler must have this interface. | ||
58 | */ | ||
59 | typedef void (vio_event_handler_t) (struct HvLpEvent * event); | ||
60 | |||
61 | extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq); | ||
62 | extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq); | ||
63 | extern int vio_setHandler(int subtype, vio_event_handler_t * beh); | ||
64 | extern int vio_clearHandler(int subtype); | ||
65 | extern int viopath_isactive(HvLpIndex lp); | ||
66 | extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp); | ||
67 | extern HvLpInstanceId viopath_targetinst(HvLpIndex lp); | ||
68 | extern void vio_set_hostlp(void); | ||
69 | extern void *vio_get_event_buffer(int subtype); | ||
70 | extern void vio_free_event_buffer(int subtype, void *buffer); | ||
71 | |||
72 | extern HvLpIndex viopath_hostLp; | ||
73 | extern HvLpIndex viopath_ourLp; | ||
74 | |||
75 | #define VIOCHAR_MAX_DATA 200 | ||
76 | |||
77 | #define VIOMAJOR_SUBTYPE_MASK 0xff00 | ||
78 | #define VIOMINOR_SUBTYPE_MASK 0x00ff | ||
79 | #define VIOMAJOR_SUBTYPE_SHIFT 8 | ||
80 | |||
81 | #define VIOVERSION 0x0101 | ||
82 | |||
83 | /* | ||
84 | * This is the general structure for VIO errors; each module should have | ||
85 | * a table of them, and each table should be terminated by an entry of | ||
86 | * { 0, 0, NULL }. Then, to find a specific error message, a module | ||
87 | * should pass its local table and the return code. | ||
88 | */ | ||
89 | struct vio_error_entry { | ||
90 | u16 rc; | ||
91 | int errno; | ||
92 | const char *msg; | ||
93 | }; | ||
94 | extern const struct vio_error_entry *vio_lookup_rc( | ||
95 | const struct vio_error_entry *local_table, u16 rc); | ||
96 | |||
97 | enum viosubtypes { | ||
98 | viomajorsubtype_monitor = 0x0100, | ||
99 | viomajorsubtype_blockio = 0x0200, | ||
100 | viomajorsubtype_chario = 0x0300, | ||
101 | viomajorsubtype_config = 0x0400, | ||
102 | viomajorsubtype_cdio = 0x0500, | ||
103 | viomajorsubtype_tape = 0x0600, | ||
104 | viomajorsubtype_scsi = 0x0700 | ||
105 | }; | ||
106 | |||
107 | enum vioconfigsubtype { | ||
108 | vioconfigget = 0x0001, | ||
109 | }; | ||
110 | |||
111 | enum viorc { | ||
112 | viorc_good = 0x0000, | ||
113 | viorc_noConnection = 0x0001, | ||
114 | viorc_noReceiver = 0x0002, | ||
115 | viorc_noBufferAvailable = 0x0003, | ||
116 | viorc_invalidMessageType = 0x0004, | ||
117 | viorc_invalidRange = 0x0201, | ||
118 | viorc_invalidToken = 0x0202, | ||
119 | viorc_DMAError = 0x0203, | ||
120 | viorc_useError = 0x0204, | ||
121 | viorc_releaseError = 0x0205, | ||
122 | viorc_invalidDisk = 0x0206, | ||
123 | viorc_openRejected = 0x0301 | ||
124 | }; | ||
125 | |||
126 | struct device; | ||
127 | |||
128 | extern struct device *iSeries_vio_dev; | ||
129 | |||
130 | #endif /* _ASM_POWERPC_ISERIES_VIO_H */ | ||
diff --git a/include/asm-powerpc/kdebug.h b/include/asm-powerpc/kdebug.h new file mode 100644 index 000000000000..9dcbac674811 --- /dev/null +++ b/include/asm-powerpc/kdebug.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef _ASM_POWERPC_KDEBUG_H | ||
2 | #define _ASM_POWERPC_KDEBUG_H | ||
3 | |||
4 | /* nearly identical to x86_64/i386 code */ | ||
5 | |||
6 | #include <linux/notifier.h> | ||
7 | |||
8 | struct pt_regs; | ||
9 | |||
10 | struct die_args { | ||
11 | struct pt_regs *regs; | ||
12 | const char *str; | ||
13 | long err; | ||
14 | int trapnr; | ||
15 | int signr; | ||
16 | }; | ||
17 | |||
18 | /* | ||
19 | Note - you should never unregister because that can race with NMIs. | ||
20 | If you really want to do it first unregister - then synchronize_sched - | ||
21 | then free. | ||
22 | */ | ||
23 | int register_die_notifier(struct notifier_block *nb); | ||
24 | extern struct notifier_block *powerpc_die_chain; | ||
25 | |||
26 | /* Grossly misnamed. */ | ||
27 | enum die_val { | ||
28 | DIE_OOPS = 1, | ||
29 | DIE_IABR_MATCH, | ||
30 | DIE_DABR_MATCH, | ||
31 | DIE_BPT, | ||
32 | DIE_SSTEP, | ||
33 | DIE_PAGE_FAULT, | ||
34 | }; | ||
35 | |||
36 | static inline int notify_die(enum die_val val,char *str,struct pt_regs *regs,long err,int trap, int sig) | ||
37 | { | ||
38 | struct die_args args = { .regs=regs, .str=str, .err=err, .trapnr=trap,.signr=sig }; | ||
39 | return notifier_call_chain(&powerpc_die_chain, val, &args); | ||
40 | } | ||
41 | |||
42 | #endif /* _ASM_POWERPC_KDEBUG_H */ | ||
diff --git a/include/asm-powerpc/kexec.h b/include/asm-powerpc/kexec.h new file mode 100644 index 000000000000..062ab9ba68eb --- /dev/null +++ b/include/asm-powerpc/kexec.h | |||
@@ -0,0 +1,49 @@ | |||
1 | #ifndef _ASM_POWERPC_KEXEC_H | ||
2 | #define _ASM_POWERPC_KEXEC_H | ||
3 | |||
4 | /* | ||
5 | * Maximum page that is mapped directly into kernel memory. | ||
6 | * XXX: Since we copy virt we can use any page we allocate | ||
7 | */ | ||
8 | #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL) | ||
9 | |||
10 | /* | ||
11 | * Maximum address we can reach in physical address mode. | ||
12 | * XXX: I want to allow initrd in highmem. Otherwise set to rmo on LPAR. | ||
13 | */ | ||
14 | #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL) | ||
15 | |||
16 | /* Maximum address we can use for the control code buffer */ | ||
17 | #ifdef __powerpc64__ | ||
18 | #define KEXEC_CONTROL_MEMORY_LIMIT (-1UL) | ||
19 | #else | ||
20 | /* TASK_SIZE, probably left over from use_mm ?? */ | ||
21 | #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE | ||
22 | #endif | ||
23 | |||
24 | #define KEXEC_CONTROL_CODE_SIZE 4096 | ||
25 | |||
26 | /* The native architecture */ | ||
27 | #ifdef __powerpc64__ | ||
28 | #define KEXEC_ARCH KEXEC_ARCH_PPC64 | ||
29 | #else | ||
30 | #define KEXEC_ARCH KEXEC_ARCH_PPC | ||
31 | #endif | ||
32 | |||
33 | #ifndef __ASSEMBLY__ | ||
34 | |||
35 | #define MAX_NOTE_BYTES 1024 | ||
36 | typedef u32 note_buf_t[MAX_NOTE_BYTES / sizeof(u32)]; | ||
37 | |||
38 | extern note_buf_t crash_notes[]; | ||
39 | |||
40 | #ifdef __powerpc64__ | ||
41 | extern void kexec_smp_wait(void); /* get and clear naca physid, wait for | ||
42 | master to copy new code to 0 */ | ||
43 | #else | ||
44 | struct kimage; | ||
45 | extern void machine_kexec_simple(struct kimage *image); | ||
46 | #endif | ||
47 | |||
48 | #endif /* ! __ASSEMBLY__ */ | ||
49 | #endif /* _ASM_POWERPC_KEXEC_H */ | ||
diff --git a/include/asm-powerpc/keylargo.h b/include/asm-powerpc/keylargo.h new file mode 100644 index 000000000000..a669a3f0f5a2 --- /dev/null +++ b/include/asm-powerpc/keylargo.h | |||
@@ -0,0 +1,248 @@ | |||
1 | /* | ||
2 | * keylargo.h: definitions for using the "KeyLargo" I/O controller chip. | ||
3 | * | ||
4 | */ | ||
5 | |||
6 | /* "Pangea" chipset has keylargo device-id 0x25 while core99 | ||
7 | * has device-id 0x22. The rev. of the pangea one is 0, so we | ||
8 | * fake an artificial rev. in keylargo_rev by oring 0x100 | ||
9 | */ | ||
10 | #define KL_PANGEA_REV 0x100 | ||
11 | |||
12 | /* offset from base for feature control registers */ | ||
13 | #define KEYLARGO_MBCR 0x34 /* KL Only, Media bay control/status */ | ||
14 | #define KEYLARGO_FCR0 0x38 | ||
15 | #define KEYLARGO_FCR1 0x3c | ||
16 | #define KEYLARGO_FCR2 0x40 | ||
17 | #define KEYLARGO_FCR3 0x44 | ||
18 | #define KEYLARGO_FCR4 0x48 | ||
19 | #define KEYLARGO_FCR5 0x4c /* Pangea only */ | ||
20 | |||
21 | /* K2 aditional FCRs */ | ||
22 | #define K2_FCR6 0x34 | ||
23 | #define K2_FCR7 0x30 | ||
24 | #define K2_FCR8 0x2c | ||
25 | #define K2_FCR9 0x28 | ||
26 | #define K2_FCR10 0x24 | ||
27 | |||
28 | /* GPIO registers */ | ||
29 | #define KEYLARGO_GPIO_LEVELS0 0x50 | ||
30 | #define KEYLARGO_GPIO_LEVELS1 0x54 | ||
31 | #define KEYLARGO_GPIO_EXTINT_0 0x58 | ||
32 | #define KEYLARGO_GPIO_EXTINT_CNT 18 | ||
33 | #define KEYLARGO_GPIO_0 0x6A | ||
34 | #define KEYLARGO_GPIO_CNT 17 | ||
35 | #define KEYLARGO_GPIO_EXTINT_DUAL_EDGE 0x80 | ||
36 | #define KEYLARGO_GPIO_OUTPUT_ENABLE 0x04 | ||
37 | #define KEYLARGO_GPIO_OUTOUT_DATA 0x01 | ||
38 | #define KEYLARGO_GPIO_INPUT_DATA 0x02 | ||
39 | |||
40 | /* K2 does only extint GPIOs and does 51 of them */ | ||
41 | #define K2_GPIO_EXTINT_0 0x58 | ||
42 | #define K2_GPIO_EXTINT_CNT 51 | ||
43 | |||
44 | /* Specific GPIO regs */ | ||
45 | |||
46 | #define KL_GPIO_MODEM_RESET (KEYLARGO_GPIO_0+0x03) | ||
47 | #define KL_GPIO_MODEM_POWER (KEYLARGO_GPIO_0+0x02) /* Pangea */ | ||
48 | |||
49 | #define KL_GPIO_SOUND_POWER (KEYLARGO_GPIO_0+0x05) | ||
50 | |||
51 | /* Hrm... this one is only to be used on Pismo. It seeem to also | ||
52 | * control the timebase enable on other machines. Still to be | ||
53 | * experimented... --BenH. | ||
54 | */ | ||
55 | #define KL_GPIO_FW_CABLE_POWER (KEYLARGO_GPIO_0+0x09) | ||
56 | #define KL_GPIO_TB_ENABLE (KEYLARGO_GPIO_0+0x09) | ||
57 | |||
58 | #define KL_GPIO_ETH_PHY_RESET (KEYLARGO_GPIO_0+0x10) | ||
59 | |||
60 | #define KL_GPIO_EXTINT_CPU1 (KEYLARGO_GPIO_0+0x0a) | ||
61 | #define KL_GPIO_EXTINT_CPU1_ASSERT 0x04 | ||
62 | #define KL_GPIO_EXTINT_CPU1_RELEASE 0x38 | ||
63 | |||
64 | #define KL_GPIO_RESET_CPU0 (KEYLARGO_GPIO_EXTINT_0+0x03) | ||
65 | #define KL_GPIO_RESET_CPU1 (KEYLARGO_GPIO_EXTINT_0+0x04) | ||
66 | #define KL_GPIO_RESET_CPU2 (KEYLARGO_GPIO_EXTINT_0+0x0f) | ||
67 | #define KL_GPIO_RESET_CPU3 (KEYLARGO_GPIO_EXTINT_0+0x10) | ||
68 | |||
69 | #define KL_GPIO_PMU_MESSAGE_IRQ (KEYLARGO_GPIO_EXTINT_0+0x09) | ||
70 | #define KL_GPIO_PMU_MESSAGE_BIT KEYLARGO_GPIO_INPUT_DATA | ||
71 | |||
72 | #define KL_GPIO_MEDIABAY_IRQ (KEYLARGO_GPIO_EXTINT_0+0x0e) | ||
73 | |||
74 | #define KL_GPIO_AIRPORT_0 (KEYLARGO_GPIO_EXTINT_0+0x0a) | ||
75 | #define KL_GPIO_AIRPORT_1 (KEYLARGO_GPIO_EXTINT_0+0x0d) | ||
76 | #define KL_GPIO_AIRPORT_2 (KEYLARGO_GPIO_0+0x0d) | ||
77 | #define KL_GPIO_AIRPORT_3 (KEYLARGO_GPIO_0+0x0e) | ||
78 | #define KL_GPIO_AIRPORT_4 (KEYLARGO_GPIO_0+0x0f) | ||
79 | |||
80 | /* | ||
81 | * Bits in feature control register. Those bits different for K2 are | ||
82 | * listed separately | ||
83 | */ | ||
84 | #define KL_MBCR_MB0_PCI_ENABLE 0x00000800 /* exist ? */ | ||
85 | #define KL_MBCR_MB0_IDE_ENABLE 0x00001000 | ||
86 | #define KL_MBCR_MB0_FLOPPY_ENABLE 0x00002000 /* exist ? */ | ||
87 | #define KL_MBCR_MB0_SOUND_ENABLE 0x00004000 /* hrm... */ | ||
88 | #define KL_MBCR_MB0_DEV_MASK 0x00007800 | ||
89 | #define KL_MBCR_MB0_DEV_POWER 0x00000400 | ||
90 | #define KL_MBCR_MB0_DEV_RESET 0x00000200 | ||
91 | #define KL_MBCR_MB0_ENABLE 0x00000100 | ||
92 | #define KL_MBCR_MB1_PCI_ENABLE 0x08000000 /* exist ? */ | ||
93 | #define KL_MBCR_MB1_IDE_ENABLE 0x10000000 | ||
94 | #define KL_MBCR_MB1_FLOPPY_ENABLE 0x20000000 /* exist ? */ | ||
95 | #define KL_MBCR_MB1_SOUND_ENABLE 0x40000000 /* hrm... */ | ||
96 | #define KL_MBCR_MB1_DEV_MASK 0x78000000 | ||
97 | #define KL_MBCR_MB1_DEV_POWER 0x04000000 | ||
98 | #define KL_MBCR_MB1_DEV_RESET 0x02000000 | ||
99 | #define KL_MBCR_MB1_ENABLE 0x01000000 | ||
100 | |||
101 | #define KL0_SCC_B_INTF_ENABLE 0x00000001 /* (KL Only) */ | ||
102 | #define KL0_SCC_A_INTF_ENABLE 0x00000002 | ||
103 | #define KL0_SCC_SLOWPCLK 0x00000004 | ||
104 | #define KL0_SCC_RESET 0x00000008 | ||
105 | #define KL0_SCCA_ENABLE 0x00000010 | ||
106 | #define KL0_SCCB_ENABLE 0x00000020 | ||
107 | #define KL0_SCC_CELL_ENABLE 0x00000040 | ||
108 | #define KL0_IRDA_HIGH_BAND 0x00000100 /* (KL Only) */ | ||
109 | #define KL0_IRDA_SOURCE2_SEL 0x00000200 /* (KL Only) */ | ||
110 | #define KL0_IRDA_SOURCE1_SEL 0x00000400 /* (KL Only) */ | ||
111 | #define KL0_PG_USB0_PMI_ENABLE 0x00000400 /* (Pangea/Intrepid Only) */ | ||
112 | #define KL0_IRDA_RESET 0x00000800 /* (KL Only) */ | ||
113 | #define KL0_PG_USB0_REF_SUSPEND_SEL 0x00000800 /* (Pangea/Intrepid Only) */ | ||
114 | #define KL0_IRDA_DEFAULT1 0x00001000 /* (KL Only) */ | ||
115 | #define KL0_PG_USB0_REF_SUSPEND 0x00001000 /* (Pangea/Intrepid Only) */ | ||
116 | #define KL0_IRDA_DEFAULT0 0x00002000 /* (KL Only) */ | ||
117 | #define KL0_PG_USB0_PAD_SUSPEND 0x00002000 /* (Pangea/Intrepid Only) */ | ||
118 | #define KL0_IRDA_FAST_CONNECT 0x00004000 /* (KL Only) */ | ||
119 | #define KL0_PG_USB1_PMI_ENABLE 0x00004000 /* (Pangea/Intrepid Only) */ | ||
120 | #define KL0_IRDA_ENABLE 0x00008000 /* (KL Only) */ | ||
121 | #define KL0_PG_USB1_REF_SUSPEND_SEL 0x00008000 /* (Pangea/Intrepid Only) */ | ||
122 | #define KL0_IRDA_CLK32_ENABLE 0x00010000 /* (KL Only) */ | ||
123 | #define KL0_PG_USB1_REF_SUSPEND 0x00010000 /* (Pangea/Intrepid Only) */ | ||
124 | #define KL0_IRDA_CLK19_ENABLE 0x00020000 /* (KL Only) */ | ||
125 | #define KL0_PG_USB1_PAD_SUSPEND 0x00020000 /* (Pangea/Intrepid Only) */ | ||
126 | #define KL0_USB0_PAD_SUSPEND0 0x00040000 | ||
127 | #define KL0_USB0_PAD_SUSPEND1 0x00080000 | ||
128 | #define KL0_USB0_CELL_ENABLE 0x00100000 | ||
129 | #define KL0_USB1_PAD_SUSPEND0 0x00400000 | ||
130 | #define KL0_USB1_PAD_SUSPEND1 0x00800000 | ||
131 | #define KL0_USB1_CELL_ENABLE 0x01000000 | ||
132 | #define KL0_USB_REF_SUSPEND 0x10000000 /* (KL Only) */ | ||
133 | |||
134 | #define KL0_SERIAL_ENABLE (KL0_SCC_B_INTF_ENABLE | \ | ||
135 | KL0_SCC_SLOWPCLK | \ | ||
136 | KL0_SCC_CELL_ENABLE | KL0_SCCA_ENABLE) | ||
137 | |||
138 | #define KL1_USB2_PMI_ENABLE 0x00000001 /* Intrepid only */ | ||
139 | #define KL1_AUDIO_SEL_22MCLK 0x00000002 /* KL/Pangea only */ | ||
140 | #define KL1_USB2_REF_SUSPEND_SEL 0x00000002 /* Intrepid only */ | ||
141 | #define KL1_USB2_REF_SUSPEND 0x00000004 /* Intrepid only */ | ||
142 | #define KL1_AUDIO_CLK_ENABLE_BIT 0x00000008 /* KL/Pangea only */ | ||
143 | #define KL1_USB2_PAD_SUSPEND_SEL 0x00000008 /* Intrepid only */ | ||
144 | #define KL1_USB2_PAD_SUSPEND0 0x00000010 /* Intrepid only */ | ||
145 | #define KL1_AUDIO_CLK_OUT_ENABLE 0x00000020 /* KL/Pangea only */ | ||
146 | #define KL1_USB2_PAD_SUSPEND1 0x00000020 /* Intrepid only */ | ||
147 | #define KL1_AUDIO_CELL_ENABLE 0x00000040 /* KL/Pangea only */ | ||
148 | #define KL1_USB2_CELL_ENABLE 0x00000040 /* Intrepid only */ | ||
149 | #define KL1_AUDIO_CHOOSE 0x00000080 /* KL/Pangea only */ | ||
150 | #define KL1_I2S0_CHOOSE 0x00000200 /* KL Only */ | ||
151 | #define KL1_I2S0_CELL_ENABLE 0x00000400 | ||
152 | #define KL1_I2S0_CLK_ENABLE_BIT 0x00001000 | ||
153 | #define KL1_I2S0_ENABLE 0x00002000 | ||
154 | #define KL1_I2S1_CELL_ENABLE 0x00020000 | ||
155 | #define KL1_I2S1_CLK_ENABLE_BIT 0x00080000 | ||
156 | #define KL1_I2S1_ENABLE 0x00100000 | ||
157 | #define KL1_EIDE0_ENABLE 0x00800000 /* KL/Intrepid Only */ | ||
158 | #define KL1_EIDE0_RESET_N 0x01000000 /* KL/Intrepid Only */ | ||
159 | #define KL1_EIDE1_ENABLE 0x04000000 /* KL Only */ | ||
160 | #define KL1_EIDE1_RESET_N 0x08000000 /* KL Only */ | ||
161 | #define KL1_UIDE_ENABLE 0x20000000 /* KL/Pangea Only */ | ||
162 | #define KL1_UIDE_RESET_N 0x40000000 /* KL/Pangea Only */ | ||
163 | |||
164 | #define KL2_IOBUS_ENABLE 0x00000002 | ||
165 | #define KL2_SLEEP_STATE_BIT 0x00000100 /* KL Only */ | ||
166 | #define KL2_PG_STOP_ALL_CLOCKS 0x00000100 /* Pangea Only */ | ||
167 | #define KL2_MPIC_ENABLE 0x00020000 | ||
168 | #define KL2_CARDSLOT_RESET 0x00040000 /* Pangea/Intrepid Only */ | ||
169 | #define KL2_ALT_DATA_OUT 0x02000000 /* KL Only ??? */ | ||
170 | #define KL2_MEM_IS_BIG 0x04000000 | ||
171 | #define KL2_CARDSEL_16 0x08000000 | ||
172 | |||
173 | #define KL3_SHUTDOWN_PLL_TOTAL 0x00000001 /* KL/Pangea only */ | ||
174 | #define KL3_SHUTDOWN_PLLKW6 0x00000002 /* KL/Pangea only */ | ||
175 | #define KL3_IT_SHUTDOWN_PLL3 0x00000002 /* Intrepid only */ | ||
176 | #define KL3_SHUTDOWN_PLLKW4 0x00000004 /* KL/Pangea only */ | ||
177 | #define KL3_IT_SHUTDOWN_PLL2 0x00000004 /* Intrepid only */ | ||
178 | #define KL3_SHUTDOWN_PLLKW35 0x00000008 /* KL/Pangea only */ | ||
179 | #define KL3_IT_SHUTDOWN_PLL1 0x00000008 /* Intrepid only */ | ||
180 | #define KL3_SHUTDOWN_PLLKW12 0x00000010 /* KL Only */ | ||
181 | #define KL3_IT_ENABLE_PLL3_SHUTDOWN 0x00000010 /* Intrepid only */ | ||
182 | #define KL3_PLL_RESET 0x00000020 /* KL/Pangea only */ | ||
183 | #define KL3_IT_ENABLE_PLL2_SHUTDOWN 0x00000020 /* Intrepid only */ | ||
184 | #define KL3_IT_ENABLE_PLL1_SHUTDOWN 0x00000010 /* Intrepid only */ | ||
185 | #define KL3_SHUTDOWN_PLL2X 0x00000080 /* KL Only */ | ||
186 | #define KL3_CLK66_ENABLE 0x00000100 /* KL Only */ | ||
187 | #define KL3_CLK49_ENABLE 0x00000200 | ||
188 | #define KL3_CLK45_ENABLE 0x00000400 | ||
189 | #define KL3_CLK31_ENABLE 0x00000800 /* KL/Pangea only */ | ||
190 | #define KL3_TIMER_CLK18_ENABLE 0x00001000 | ||
191 | #define KL3_I2S1_CLK18_ENABLE 0x00002000 | ||
192 | #define KL3_I2S0_CLK18_ENABLE 0x00004000 | ||
193 | #define KL3_VIA_CLK16_ENABLE 0x00008000 /* KL/Pangea only */ | ||
194 | #define KL3_IT_VIA_CLK32_ENABLE 0x00008000 /* Intrepid only */ | ||
195 | #define KL3_STOPPING33_ENABLED 0x00080000 /* KL Only */ | ||
196 | #define KL3_PG_PLL_ENABLE_TEST 0x00080000 /* Pangea Only */ | ||
197 | |||
198 | /* Intrepid USB bus 2, port 0,1 */ | ||
199 | #define KL3_IT_PORT_WAKEUP_ENABLE(p) (0x00080000 << ((p)<<3)) | ||
200 | #define KL3_IT_PORT_RESUME_WAKE_EN(p) (0x00040000 << ((p)<<3)) | ||
201 | #define KL3_IT_PORT_CONNECT_WAKE_EN(p) (0x00020000 << ((p)<<3)) | ||
202 | #define KL3_IT_PORT_DISCONNECT_WAKE_EN(p) (0x00010000 << ((p)<<3)) | ||
203 | #define KL3_IT_PORT_RESUME_STAT(p) (0x00300000 << ((p)<<3)) | ||
204 | #define KL3_IT_PORT_CONNECT_STAT(p) (0x00200000 << ((p)<<3)) | ||
205 | #define KL3_IT_PORT_DISCONNECT_STAT(p) (0x00100000 << ((p)<<3)) | ||
206 | |||
207 | /* Port 0,1 : bus 0, port 2,3 : bus 1 */ | ||
208 | #define KL4_PORT_WAKEUP_ENABLE(p) (0x00000008 << ((p)<<3)) | ||
209 | #define KL4_PORT_RESUME_WAKE_EN(p) (0x00000004 << ((p)<<3)) | ||
210 | #define KL4_PORT_CONNECT_WAKE_EN(p) (0x00000002 << ((p)<<3)) | ||
211 | #define KL4_PORT_DISCONNECT_WAKE_EN(p) (0x00000001 << ((p)<<3)) | ||
212 | #define KL4_PORT_RESUME_STAT(p) (0x00000040 << ((p)<<3)) | ||
213 | #define KL4_PORT_CONNECT_STAT(p) (0x00000020 << ((p)<<3)) | ||
214 | #define KL4_PORT_DISCONNECT_STAT(p) (0x00000010 << ((p)<<3)) | ||
215 | |||
216 | /* Pangea and Intrepid only */ | ||
217 | #define KL5_VIA_USE_CLK31 0000000001 /* Pangea Only */ | ||
218 | #define KL5_SCC_USE_CLK31 0x00000002 /* Pangea Only */ | ||
219 | #define KL5_PWM_CLK32_EN 0x00000004 | ||
220 | #define KL5_CLK3_68_EN 0x00000010 | ||
221 | #define KL5_CLK32_EN 0x00000020 | ||
222 | |||
223 | |||
224 | /* K2 definitions */ | ||
225 | #define K2_FCR0_USB0_SWRESET 0x00200000 | ||
226 | #define K2_FCR0_USB1_SWRESET 0x02000000 | ||
227 | #define K2_FCR0_RING_PME_DISABLE 0x08000000 | ||
228 | |||
229 | #define K2_FCR1_PCI1_BUS_RESET_N 0x00000010 | ||
230 | #define K2_FCR1_PCI1_SLEEP_RESET_EN 0x00000020 | ||
231 | #define K2_FCR1_I2S0_CELL_ENABLE 0x00000400 | ||
232 | #define K2_FCR1_I2S0_RESET 0x00000800 | ||
233 | #define K2_FCR1_I2S0_CLK_ENABLE_BIT 0x00001000 | ||
234 | #define K2_FCR1_I2S0_ENABLE 0x00002000 | ||
235 | |||
236 | #define K2_FCR1_PCI1_CLK_ENABLE 0x00004000 | ||
237 | #define K2_FCR1_FW_CLK_ENABLE 0x00008000 | ||
238 | #define K2_FCR1_FW_RESET_N 0x00010000 | ||
239 | #define K2_FCR1_GMAC_CLK_ENABLE 0x00400000 | ||
240 | #define K2_FCR1_GMAC_POWER_DOWN 0x00800000 | ||
241 | #define K2_FCR1_GMAC_RESET_N 0x01000000 | ||
242 | #define K2_FCR1_SATA_CLK_ENABLE 0x02000000 | ||
243 | #define K2_FCR1_SATA_POWER_DOWN 0x04000000 | ||
244 | #define K2_FCR1_SATA_RESET_N 0x08000000 | ||
245 | #define K2_FCR1_UATA_CLK_ENABLE 0x10000000 | ||
246 | #define K2_FCR1_UATA_RESET_N 0x40000000 | ||
247 | #define K2_FCR1_UATA_CHOOSE_CLK66 0x80000000 | ||
248 | |||
diff --git a/include/asm-powerpc/kmap_types.h b/include/asm-powerpc/kmap_types.h new file mode 100644 index 000000000000..b6bac6f61c16 --- /dev/null +++ b/include/asm-powerpc/kmap_types.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #ifndef _ASM_POWERPC_KMAP_TYPES_H | ||
2 | #define _ASM_POWERPC_KMAP_TYPES_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | /* | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | enum km_type { | ||
14 | KM_BOUNCE_READ, | ||
15 | KM_SKB_SUNRPC_DATA, | ||
16 | KM_SKB_DATA_SOFTIRQ, | ||
17 | KM_USER0, | ||
18 | KM_USER1, | ||
19 | KM_BIO_SRC_IRQ, | ||
20 | KM_BIO_DST_IRQ, | ||
21 | KM_PTE0, | ||
22 | KM_PTE1, | ||
23 | KM_IRQ0, | ||
24 | KM_IRQ1, | ||
25 | KM_SOFTIRQ0, | ||
26 | KM_SOFTIRQ1, | ||
27 | KM_PPC_SYNC_PAGE, | ||
28 | KM_PPC_SYNC_ICACHE, | ||
29 | KM_TYPE_NR | ||
30 | }; | ||
31 | |||
32 | #endif /* __KERNEL__ */ | ||
33 | #endif /* _ASM_POWERPC_KMAP_TYPES_H */ | ||
diff --git a/include/asm-powerpc/kprobes.h b/include/asm-powerpc/kprobes.h new file mode 100644 index 000000000000..b2f09f17fbe0 --- /dev/null +++ b/include/asm-powerpc/kprobes.h | |||
@@ -0,0 +1,66 @@ | |||
1 | #ifndef _ASM_POWERPC_KPROBES_H | ||
2 | #define _ASM_POWERPC_KPROBES_H | ||
3 | /* | ||
4 | * Kernel Probes (KProbes) | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | * | ||
20 | * Copyright (C) IBM Corporation, 2002, 2004 | ||
21 | * | ||
22 | * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel | ||
23 | * Probes initial implementation ( includes suggestions from | ||
24 | * Rusty Russell). | ||
25 | * 2004-Nov Modified for PPC64 by Ananth N Mavinakayanahalli | ||
26 | * <ananth@in.ibm.com> | ||
27 | */ | ||
28 | #include <linux/types.h> | ||
29 | #include <linux/ptrace.h> | ||
30 | |||
31 | struct pt_regs; | ||
32 | |||
33 | typedef unsigned int kprobe_opcode_t; | ||
34 | #define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */ | ||
35 | #define MAX_INSN_SIZE 1 | ||
36 | |||
37 | #define IS_TW(instr) (((instr) & 0xfc0007fe) == 0x7c000008) | ||
38 | #define IS_TD(instr) (((instr) & 0xfc0007fe) == 0x7c000088) | ||
39 | #define IS_TDI(instr) (((instr) & 0xfc000000) == 0x08000000) | ||
40 | #define IS_TWI(instr) (((instr) & 0xfc000000) == 0x0c000000) | ||
41 | |||
42 | #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)((func_descr_t *)pentry) | ||
43 | |||
44 | #define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \ | ||
45 | IS_TWI(instr) || IS_TDI(instr)) | ||
46 | |||
47 | #define ARCH_SUPPORTS_KRETPROBES | ||
48 | void kretprobe_trampoline(void); | ||
49 | |||
50 | /* Architecture specific copy of original instruction */ | ||
51 | struct arch_specific_insn { | ||
52 | /* copy of original instruction */ | ||
53 | kprobe_opcode_t *insn; | ||
54 | }; | ||
55 | |||
56 | #ifdef CONFIG_KPROBES | ||
57 | extern int kprobe_exceptions_notify(struct notifier_block *self, | ||
58 | unsigned long val, void *data); | ||
59 | #else /* !CONFIG_KPROBES */ | ||
60 | static inline int kprobe_exceptions_notify(struct notifier_block *self, | ||
61 | unsigned long val, void *data) | ||
62 | { | ||
63 | return 0; | ||
64 | } | ||
65 | #endif | ||
66 | #endif /* _ASM_POWERPC_KPROBES_H */ | ||
diff --git a/include/asm-powerpc/lmb.h b/include/asm-powerpc/lmb.h new file mode 100644 index 000000000000..ea0afe343545 --- /dev/null +++ b/include/asm-powerpc/lmb.h | |||
@@ -0,0 +1,81 @@ | |||
1 | #ifndef _PPC64_LMB_H | ||
2 | #define _PPC64_LMB_H | ||
3 | |||
4 | /* | ||
5 | * Definitions for talking to the Open Firmware PROM on | ||
6 | * Power Macintosh computers. | ||
7 | * | ||
8 | * Copyright (C) 2001 Peter Bergner, IBM Corp. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | */ | ||
15 | |||
16 | #include <linux/init.h> | ||
17 | #include <asm/prom.h> | ||
18 | |||
19 | #define MAX_LMB_REGIONS 128 | ||
20 | |||
21 | #define LMB_ALLOC_ANYWHERE 0 | ||
22 | |||
23 | struct lmb_property { | ||
24 | unsigned long base; | ||
25 | unsigned long size; | ||
26 | }; | ||
27 | |||
28 | struct lmb_region { | ||
29 | unsigned long cnt; | ||
30 | unsigned long size; | ||
31 | struct lmb_property region[MAX_LMB_REGIONS+1]; | ||
32 | }; | ||
33 | |||
34 | struct lmb { | ||
35 | unsigned long debug; | ||
36 | unsigned long rmo_size; | ||
37 | struct lmb_region memory; | ||
38 | struct lmb_region reserved; | ||
39 | }; | ||
40 | |||
41 | extern struct lmb lmb; | ||
42 | |||
43 | extern void __init lmb_init(void); | ||
44 | extern void __init lmb_analyze(void); | ||
45 | extern long __init lmb_add(unsigned long, unsigned long); | ||
46 | extern long __init lmb_reserve(unsigned long, unsigned long); | ||
47 | extern unsigned long __init lmb_alloc(unsigned long, unsigned long); | ||
48 | extern unsigned long __init lmb_alloc_base(unsigned long, unsigned long, | ||
49 | unsigned long); | ||
50 | extern unsigned long __init lmb_phys_mem_size(void); | ||
51 | extern unsigned long __init lmb_end_of_DRAM(void); | ||
52 | extern unsigned long __init lmb_abs_to_phys(unsigned long); | ||
53 | extern void __init lmb_enforce_memory_limit(unsigned long); | ||
54 | |||
55 | extern void lmb_dump_all(void); | ||
56 | |||
57 | extern unsigned long io_hole_start; | ||
58 | |||
59 | static inline unsigned long | ||
60 | lmb_size_bytes(struct lmb_region *type, unsigned long region_nr) | ||
61 | { | ||
62 | return type->region[region_nr].size; | ||
63 | } | ||
64 | static inline unsigned long | ||
65 | lmb_size_pages(struct lmb_region *type, unsigned long region_nr) | ||
66 | { | ||
67 | return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT; | ||
68 | } | ||
69 | static inline unsigned long | ||
70 | lmb_start_pfn(struct lmb_region *type, unsigned long region_nr) | ||
71 | { | ||
72 | return type->region[region_nr].base >> PAGE_SHIFT; | ||
73 | } | ||
74 | static inline unsigned long | ||
75 | lmb_end_pfn(struct lmb_region *type, unsigned long region_nr) | ||
76 | { | ||
77 | return lmb_start_pfn(type, region_nr) + | ||
78 | lmb_size_pages(type, region_nr); | ||
79 | } | ||
80 | |||
81 | #endif /* _PPC64_LMB_H */ | ||
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h new file mode 100644 index 000000000000..629ca964b974 --- /dev/null +++ b/include/asm-powerpc/machdep.h | |||
@@ -0,0 +1,285 @@ | |||
1 | #ifndef _ASM_POWERPC_MACHDEP_H | ||
2 | #define _ASM_POWERPC_MACHDEP_H | ||
3 | #ifdef __KERNEL__ | ||
4 | |||
5 | /* | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/config.h> | ||
13 | #include <linux/seq_file.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/dma-mapping.h> | ||
16 | |||
17 | #include <asm/setup.h> | ||
18 | |||
19 | /* We export this macro for external modules like Alsa to know if | ||
20 | * ppc_md.feature_call is implemented or not | ||
21 | */ | ||
22 | #define CONFIG_PPC_HAS_FEATURE_CALLS | ||
23 | |||
24 | struct pt_regs; | ||
25 | struct pci_bus; | ||
26 | struct device_node; | ||
27 | struct iommu_table; | ||
28 | struct rtc_time; | ||
29 | struct file; | ||
30 | |||
31 | #ifdef CONFIG_SMP | ||
32 | struct smp_ops_t { | ||
33 | void (*message_pass)(int target, int msg); | ||
34 | int (*probe)(void); | ||
35 | void (*kick_cpu)(int nr); | ||
36 | void (*setup_cpu)(int nr); | ||
37 | void (*take_timebase)(void); | ||
38 | void (*give_timebase)(void); | ||
39 | int (*cpu_enable)(unsigned int nr); | ||
40 | int (*cpu_disable)(void); | ||
41 | void (*cpu_die)(unsigned int nr); | ||
42 | int (*cpu_bootable)(unsigned int nr); | ||
43 | }; | ||
44 | #endif | ||
45 | |||
46 | struct machdep_calls { | ||
47 | #ifdef CONFIG_PPC64 | ||
48 | void (*hpte_invalidate)(unsigned long slot, | ||
49 | unsigned long va, | ||
50 | int large, | ||
51 | int local); | ||
52 | long (*hpte_updatepp)(unsigned long slot, | ||
53 | unsigned long newpp, | ||
54 | unsigned long va, | ||
55 | int large, | ||
56 | int local); | ||
57 | void (*hpte_updateboltedpp)(unsigned long newpp, | ||
58 | unsigned long ea); | ||
59 | long (*hpte_insert)(unsigned long hpte_group, | ||
60 | unsigned long va, | ||
61 | unsigned long prpn, | ||
62 | unsigned long vflags, | ||
63 | unsigned long rflags); | ||
64 | long (*hpte_remove)(unsigned long hpte_group); | ||
65 | void (*flush_hash_range)(unsigned long number, int local); | ||
66 | |||
67 | /* special for kexec, to be called in real mode, linar mapping is | ||
68 | * destroyed as well */ | ||
69 | void (*hpte_clear_all)(void); | ||
70 | |||
71 | void (*tce_build)(struct iommu_table * tbl, | ||
72 | long index, | ||
73 | long npages, | ||
74 | unsigned long uaddr, | ||
75 | enum dma_data_direction direction); | ||
76 | void (*tce_free)(struct iommu_table *tbl, | ||
77 | long index, | ||
78 | long npages); | ||
79 | void (*tce_flush)(struct iommu_table *tbl); | ||
80 | void (*iommu_dev_setup)(struct pci_dev *dev); | ||
81 | void (*iommu_bus_setup)(struct pci_bus *bus); | ||
82 | void (*irq_bus_setup)(struct pci_bus *bus); | ||
83 | int (*set_dabr)(unsigned long dabr); | ||
84 | #endif | ||
85 | |||
86 | int (*probe)(int platform); | ||
87 | void (*setup_arch)(void); | ||
88 | void (*init_early)(void); | ||
89 | /* Optional, may be NULL. */ | ||
90 | void (*show_cpuinfo)(struct seq_file *m); | ||
91 | void (*show_percpuinfo)(struct seq_file *m, int i); | ||
92 | |||
93 | void (*init_IRQ)(void); | ||
94 | int (*get_irq)(struct pt_regs *); | ||
95 | void (*cpu_irq_down)(int secondary); | ||
96 | |||
97 | /* PCI stuff */ | ||
98 | /* Called after scanning the bus, before allocating resources */ | ||
99 | void (*pcibios_fixup)(void); | ||
100 | int (*pci_probe_mode)(struct pci_bus *); | ||
101 | |||
102 | void (*restart)(char *cmd); | ||
103 | void (*power_off)(void); | ||
104 | void (*halt)(void); | ||
105 | void (*panic)(char *str); | ||
106 | void (*cpu_die)(void); | ||
107 | |||
108 | long (*time_init)(void); /* Optional, may be NULL */ | ||
109 | |||
110 | int (*set_rtc_time)(struct rtc_time *); | ||
111 | void (*get_rtc_time)(struct rtc_time *); | ||
112 | unsigned long (*get_boot_time)(void); | ||
113 | unsigned char (*rtc_read_val)(int addr); | ||
114 | void (*rtc_write_val)(int addr, unsigned char val); | ||
115 | |||
116 | void (*calibrate_decr)(void); | ||
117 | |||
118 | void (*progress)(char *, unsigned short); | ||
119 | |||
120 | /* Interface for platform error logging */ | ||
121 | void (*log_error)(char *buf, unsigned int err_type, int fatal); | ||
122 | |||
123 | unsigned char (*nvram_read_val)(int addr); | ||
124 | void (*nvram_write_val)(int addr, unsigned char val); | ||
125 | ssize_t (*nvram_write)(char *buf, size_t count, loff_t *index); | ||
126 | ssize_t (*nvram_read)(char *buf, size_t count, loff_t *index); | ||
127 | ssize_t (*nvram_size)(void); | ||
128 | void (*nvram_sync)(void); | ||
129 | |||
130 | /* Exception handlers */ | ||
131 | void (*system_reset_exception)(struct pt_regs *regs); | ||
132 | int (*machine_check_exception)(struct pt_regs *regs); | ||
133 | |||
134 | /* Motherboard/chipset features. This is a kind of general purpose | ||
135 | * hook used to control some machine specific features (like reset | ||
136 | * lines, chip power control, etc...). | ||
137 | */ | ||
138 | long (*feature_call)(unsigned int feature, ...); | ||
139 | |||
140 | /* Check availability of legacy devices like i8042 */ | ||
141 | int (*check_legacy_ioport)(unsigned int baseport); | ||
142 | |||
143 | /* Get legacy PCI/IDE interrupt mapping */ | ||
144 | int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel); | ||
145 | |||
146 | /* Get access protection for /dev/mem */ | ||
147 | pgprot_t (*phys_mem_access_prot)(struct file *file, | ||
148 | unsigned long pfn, | ||
149 | unsigned long size, | ||
150 | pgprot_t vma_prot); | ||
151 | |||
152 | /* Idle loop for this platform, leave empty for default idle loop */ | ||
153 | void (*idle_loop)(void); | ||
154 | |||
155 | /* Function to enable performance monitor counters for this | ||
156 | platform, called once per cpu. */ | ||
157 | void (*enable_pmcs)(void); | ||
158 | |||
159 | #ifdef CONFIG_PPC32 /* XXX for now */ | ||
160 | /* A general init function, called by ppc_init in init/main.c. | ||
161 | May be NULL. */ | ||
162 | void (*init)(void); | ||
163 | |||
164 | void (*idle)(void); | ||
165 | void (*power_save)(void); | ||
166 | |||
167 | void (*heartbeat)(void); | ||
168 | unsigned long heartbeat_reset; | ||
169 | unsigned long heartbeat_count; | ||
170 | |||
171 | void (*setup_io_mappings)(void); | ||
172 | |||
173 | void (*early_serial_map)(void); | ||
174 | void (*kgdb_map_scc)(void); | ||
175 | |||
176 | /* | ||
177 | * optional PCI "hooks" | ||
178 | */ | ||
179 | |||
180 | /* Called after PPC generic resource fixup to perform | ||
181 | machine specific fixups */ | ||
182 | void (*pcibios_fixup_resources)(struct pci_dev *); | ||
183 | |||
184 | /* Called for each PCI bus in the system when it's probed */ | ||
185 | void (*pcibios_fixup_bus)(struct pci_bus *); | ||
186 | |||
187 | /* Called when pci_enable_device() is called (initial=0) or | ||
188 | * when a device with no assigned resource is found (initial=1). | ||
189 | * Returns 0 to allow assignment/enabling of the device. */ | ||
190 | int (*pcibios_enable_device_hook)(struct pci_dev *, int initial); | ||
191 | |||
192 | /* For interrupt routing */ | ||
193 | unsigned char (*pci_swizzle)(struct pci_dev *, unsigned char *); | ||
194 | int (*pci_map_irq)(struct pci_dev *, unsigned char, unsigned char); | ||
195 | |||
196 | /* Called in indirect_* to avoid touching devices */ | ||
197 | int (*pci_exclude_device)(unsigned char, unsigned char); | ||
198 | |||
199 | /* Called at then very end of pcibios_init() */ | ||
200 | void (*pcibios_after_init)(void); | ||
201 | |||
202 | /* this is for modules, since _machine can be a define -- Cort */ | ||
203 | int ppc_machine; | ||
204 | |||
205 | #ifdef CONFIG_KEXEC | ||
206 | /* Called to shutdown machine specific hardware not already controlled | ||
207 | * by other drivers. | ||
208 | * XXX Should we move this one out of kexec scope? | ||
209 | */ | ||
210 | void (*machine_shutdown)(void); | ||
211 | |||
212 | /* Called to do the minimal shutdown needed to run a kexec'd kernel | ||
213 | * to run successfully. | ||
214 | * XXX Should we move this one out of kexec scope? | ||
215 | */ | ||
216 | void (*machine_crash_shutdown)(void); | ||
217 | |||
218 | /* Called to do what every setup is needed on image and the | ||
219 | * reboot code buffer. Returns 0 on success. | ||
220 | * Provide your own (maybe dummy) implementation if your platform | ||
221 | * claims to support kexec. | ||
222 | */ | ||
223 | int (*machine_kexec_prepare)(struct kimage *image); | ||
224 | |||
225 | /* Called to handle any machine specific cleanup on image */ | ||
226 | void (*machine_kexec_cleanup)(struct kimage *image); | ||
227 | |||
228 | /* Called to perform the _real_ kexec. | ||
229 | * Do NOT allocate memory or fail here. We are past the point of | ||
230 | * no return. | ||
231 | */ | ||
232 | void (*machine_kexec)(struct kimage *image); | ||
233 | #endif /* CONFIG_KEXEC */ | ||
234 | #endif /* CONFIG_PPC32 */ | ||
235 | }; | ||
236 | |||
237 | extern void default_idle(void); | ||
238 | extern void native_idle(void); | ||
239 | |||
240 | extern struct machdep_calls ppc_md; | ||
241 | extern char cmd_line[COMMAND_LINE_SIZE]; | ||
242 | |||
243 | #ifdef CONFIG_PPC_PMAC | ||
244 | /* | ||
245 | * Power macintoshes have either a CUDA, PMU or SMU controlling | ||
246 | * system reset, power, NVRAM, RTC. | ||
247 | */ | ||
248 | typedef enum sys_ctrler_kind { | ||
249 | SYS_CTRLER_UNKNOWN = 0, | ||
250 | SYS_CTRLER_CUDA = 1, | ||
251 | SYS_CTRLER_PMU = 2, | ||
252 | SYS_CTRLER_SMU = 3, | ||
253 | } sys_ctrler_t; | ||
254 | extern sys_ctrler_t sys_ctrler; | ||
255 | |||
256 | #endif /* CONFIG_PPC_PMAC */ | ||
257 | |||
258 | extern void setup_pci_ptrs(void); | ||
259 | |||
260 | #ifdef CONFIG_SMP | ||
261 | /* Poor default implementations */ | ||
262 | extern void __devinit smp_generic_give_timebase(void); | ||
263 | extern void __devinit smp_generic_take_timebase(void); | ||
264 | #endif /* CONFIG_SMP */ | ||
265 | |||
266 | |||
267 | /* Functions to produce codes on the leds. | ||
268 | * The SRC code should be unique for the message category and should | ||
269 | * be limited to the lower 24 bits (the upper 8 are set by these funcs), | ||
270 | * and (for boot & dump) should be sorted numerically in the order | ||
271 | * the events occur. | ||
272 | */ | ||
273 | /* Print a boot progress message. */ | ||
274 | void ppc64_boot_msg(unsigned int src, const char *msg); | ||
275 | /* Print a termination message (print only -- does not stop the kernel) */ | ||
276 | void ppc64_terminate_msg(unsigned int src, const char *msg); | ||
277 | |||
278 | static inline void log_error(char *buf, unsigned int err_type, int fatal) | ||
279 | { | ||
280 | if (ppc_md.log_error) | ||
281 | ppc_md.log_error(buf, err_type, fatal); | ||
282 | } | ||
283 | |||
284 | #endif /* __KERNEL__ */ | ||
285 | #endif /* _ASM_POWERPC_MACHDEP_H */ | ||
diff --git a/include/asm-powerpc/macio.h b/include/asm-powerpc/macio.h new file mode 100644 index 000000000000..b553dd4b139e --- /dev/null +++ b/include/asm-powerpc/macio.h | |||
@@ -0,0 +1,140 @@ | |||
1 | #ifndef __MACIO_ASIC_H__ | ||
2 | #define __MACIO_ASIC_H__ | ||
3 | |||
4 | #include <asm/of_device.h> | ||
5 | |||
6 | extern struct bus_type macio_bus_type; | ||
7 | |||
8 | /* MacIO device driver is defined later */ | ||
9 | struct macio_driver; | ||
10 | struct macio_chip; | ||
11 | |||
12 | #define MACIO_DEV_COUNT_RESOURCES 8 | ||
13 | #define MACIO_DEV_COUNT_IRQS 8 | ||
14 | |||
15 | /* | ||
16 | * the macio_bus structure is used to describe a "virtual" bus | ||
17 | * within a MacIO ASIC. It's typically provided by a macio_pci_asic | ||
18 | * PCI device, but could be provided differently as well (nubus | ||
19 | * machines using a fake OF tree). | ||
20 | * | ||
21 | * The pdev field can be NULL on non-PCI machines | ||
22 | */ | ||
23 | struct macio_bus | ||
24 | { | ||
25 | struct macio_chip *chip; /* macio_chip (private use) */ | ||
26 | int index; /* macio chip index in system */ | ||
27 | #ifdef CONFIG_PCI | ||
28 | struct pci_dev *pdev; /* PCI device hosting this bus */ | ||
29 | #endif | ||
30 | }; | ||
31 | |||
32 | /* | ||
33 | * the macio_dev structure is used to describe a device | ||
34 | * within an Apple MacIO ASIC. | ||
35 | */ | ||
36 | struct macio_dev | ||
37 | { | ||
38 | struct macio_bus *bus; /* macio bus this device is on */ | ||
39 | struct macio_dev *media_bay; /* Device is part of a media bay */ | ||
40 | struct of_device ofdev; | ||
41 | int n_resources; | ||
42 | struct resource resource[MACIO_DEV_COUNT_RESOURCES]; | ||
43 | int n_interrupts; | ||
44 | struct resource interrupt[MACIO_DEV_COUNT_IRQS]; | ||
45 | }; | ||
46 | #define to_macio_device(d) container_of(d, struct macio_dev, ofdev.dev) | ||
47 | #define of_to_macio_device(d) container_of(d, struct macio_dev, ofdev) | ||
48 | |||
49 | extern struct macio_dev *macio_dev_get(struct macio_dev *dev); | ||
50 | extern void macio_dev_put(struct macio_dev *dev); | ||
51 | |||
52 | /* | ||
53 | * Accessors to resources & interrupts and other device | ||
54 | * fields | ||
55 | */ | ||
56 | |||
57 | static inline int macio_resource_count(struct macio_dev *dev) | ||
58 | { | ||
59 | return dev->n_resources; | ||
60 | } | ||
61 | |||
62 | static inline unsigned long macio_resource_start(struct macio_dev *dev, int resource_no) | ||
63 | { | ||
64 | return dev->resource[resource_no].start; | ||
65 | } | ||
66 | |||
67 | static inline unsigned long macio_resource_end(struct macio_dev *dev, int resource_no) | ||
68 | { | ||
69 | return dev->resource[resource_no].end; | ||
70 | } | ||
71 | |||
72 | static inline unsigned long macio_resource_len(struct macio_dev *dev, int resource_no) | ||
73 | { | ||
74 | struct resource *res = &dev->resource[resource_no]; | ||
75 | if (res->start == 0 || res->end == 0 || res->end < res->start) | ||
76 | return 0; | ||
77 | return res->end - res->start + 1; | ||
78 | } | ||
79 | |||
80 | extern int macio_request_resource(struct macio_dev *dev, int resource_no, const char *name); | ||
81 | extern void macio_release_resource(struct macio_dev *dev, int resource_no); | ||
82 | extern int macio_request_resources(struct macio_dev *dev, const char *name); | ||
83 | extern void macio_release_resources(struct macio_dev *dev); | ||
84 | |||
85 | static inline int macio_irq_count(struct macio_dev *dev) | ||
86 | { | ||
87 | return dev->n_interrupts; | ||
88 | } | ||
89 | |||
90 | static inline int macio_irq(struct macio_dev *dev, int irq_no) | ||
91 | { | ||
92 | return dev->interrupt[irq_no].start; | ||
93 | } | ||
94 | |||
95 | static inline void macio_set_drvdata(struct macio_dev *dev, void *data) | ||
96 | { | ||
97 | dev_set_drvdata(&dev->ofdev.dev, data); | ||
98 | } | ||
99 | |||
100 | static inline void* macio_get_drvdata(struct macio_dev *dev) | ||
101 | { | ||
102 | return dev_get_drvdata(&dev->ofdev.dev); | ||
103 | } | ||
104 | |||
105 | static inline struct device_node *macio_get_of_node(struct macio_dev *mdev) | ||
106 | { | ||
107 | return mdev->ofdev.node; | ||
108 | } | ||
109 | |||
110 | #ifdef CONFIG_PCI | ||
111 | static inline struct pci_dev *macio_get_pci_dev(struct macio_dev *mdev) | ||
112 | { | ||
113 | return mdev->bus->pdev; | ||
114 | } | ||
115 | #endif | ||
116 | |||
117 | /* | ||
118 | * A driver for a mac-io chip based device | ||
119 | */ | ||
120 | struct macio_driver | ||
121 | { | ||
122 | char *name; | ||
123 | struct of_device_id *match_table; | ||
124 | struct module *owner; | ||
125 | |||
126 | int (*probe)(struct macio_dev* dev, const struct of_device_id *match); | ||
127 | int (*remove)(struct macio_dev* dev); | ||
128 | |||
129 | int (*suspend)(struct macio_dev* dev, pm_message_t state); | ||
130 | int (*resume)(struct macio_dev* dev); | ||
131 | int (*shutdown)(struct macio_dev* dev); | ||
132 | |||
133 | struct device_driver driver; | ||
134 | }; | ||
135 | #define to_macio_driver(drv) container_of(drv,struct macio_driver, driver) | ||
136 | |||
137 | extern int macio_register_driver(struct macio_driver *); | ||
138 | extern void macio_unregister_driver(struct macio_driver *); | ||
139 | |||
140 | #endif /* __MACIO_ASIC_H__ */ | ||
diff --git a/include/asm-powerpc/mediabay.h b/include/asm-powerpc/mediabay.h new file mode 100644 index 000000000000..9daa3252d7b6 --- /dev/null +++ b/include/asm-powerpc/mediabay.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * mediabay.h: definitions for using the media bay | ||
3 | * on PowerBook 3400 and similar computers. | ||
4 | * | ||
5 | * Copyright (C) 1997 Paul Mackerras. | ||
6 | */ | ||
7 | #ifndef _PPC_MEDIABAY_H | ||
8 | #define _PPC_MEDIABAY_H | ||
9 | |||
10 | #ifdef __KERNEL__ | ||
11 | |||
12 | #define MB_FD 0 /* media bay contains floppy drive (automatic eject ?) */ | ||
13 | #define MB_FD1 1 /* media bay contains floppy drive (manual eject ?) */ | ||
14 | #define MB_SOUND 2 /* sound device ? */ | ||
15 | #define MB_CD 3 /* media bay contains ATA drive such as CD or ZIP */ | ||
16 | #define MB_PCI 5 /* media bay contains a PCI device */ | ||
17 | #define MB_POWER 6 /* media bay contains a Power device (???) */ | ||
18 | #define MB_NO 7 /* media bay contains nothing */ | ||
19 | |||
20 | int check_media_bay(struct device_node *which_bay, int what); | ||
21 | int check_media_bay_by_base(unsigned long base, int what); | ||
22 | |||
23 | /* Number of bays in the machine or 0 */ | ||
24 | extern int media_bay_count; | ||
25 | |||
26 | /* called by pmac-ide.c to register IDE controller for media bay */ | ||
27 | extern int media_bay_set_ide_infos(struct device_node* which_bay, | ||
28 | unsigned long base, int irq, int index); | ||
29 | |||
30 | #endif /* __KERNEL__ */ | ||
31 | #endif /* _PPC_MEDIABAY_H */ | ||
diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h new file mode 100644 index 000000000000..7083d1f74260 --- /dev/null +++ b/include/asm-powerpc/mpic.h | |||
@@ -0,0 +1,287 @@ | |||
1 | #ifndef _ASM_POWERPC_MPIC_H | ||
2 | #define _ASM_POWERPC_MPIC_H | ||
3 | |||
4 | #include <linux/irq.h> | ||
5 | |||
6 | /* | ||
7 | * Global registers | ||
8 | */ | ||
9 | |||
10 | #define MPIC_GREG_BASE 0x01000 | ||
11 | |||
12 | #define MPIC_GREG_FEATURE_0 0x00000 | ||
13 | #define MPIC_GREG_FEATURE_LAST_SRC_MASK 0x07ff0000 | ||
14 | #define MPIC_GREG_FEATURE_LAST_SRC_SHIFT 16 | ||
15 | #define MPIC_GREG_FEATURE_LAST_CPU_MASK 0x00001f00 | ||
16 | #define MPIC_GREG_FEATURE_LAST_CPU_SHIFT 8 | ||
17 | #define MPIC_GREG_FEATURE_VERSION_MASK 0xff | ||
18 | #define MPIC_GREG_FEATURE_1 0x00010 | ||
19 | #define MPIC_GREG_GLOBAL_CONF_0 0x00020 | ||
20 | #define MPIC_GREG_GCONF_RESET 0x80000000 | ||
21 | #define MPIC_GREG_GCONF_8259_PTHROU_DIS 0x20000000 | ||
22 | #define MPIC_GREG_GCONF_BASE_MASK 0x000fffff | ||
23 | #define MPIC_GREG_GLOBAL_CONF_1 0x00030 | ||
24 | #define MPIC_GREG_VENDOR_0 0x00040 | ||
25 | #define MPIC_GREG_VENDOR_1 0x00050 | ||
26 | #define MPIC_GREG_VENDOR_2 0x00060 | ||
27 | #define MPIC_GREG_VENDOR_3 0x00070 | ||
28 | #define MPIC_GREG_VENDOR_ID 0x00080 | ||
29 | #define MPIC_GREG_VENDOR_ID_STEPPING_MASK 0x00ff0000 | ||
30 | #define MPIC_GREG_VENDOR_ID_STEPPING_SHIFT 16 | ||
31 | #define MPIC_GREG_VENDOR_ID_DEVICE_ID_MASK 0x0000ff00 | ||
32 | #define MPIC_GREG_VENDOR_ID_DEVICE_ID_SHIFT 8 | ||
33 | #define MPIC_GREG_VENDOR_ID_VENDOR_ID_MASK 0x000000ff | ||
34 | #define MPIC_GREG_PROCESSOR_INIT 0x00090 | ||
35 | #define MPIC_GREG_IPI_VECTOR_PRI_0 0x000a0 | ||
36 | #define MPIC_GREG_IPI_VECTOR_PRI_1 0x000b0 | ||
37 | #define MPIC_GREG_IPI_VECTOR_PRI_2 0x000c0 | ||
38 | #define MPIC_GREG_IPI_VECTOR_PRI_3 0x000d0 | ||
39 | #define MPIC_GREG_SPURIOUS 0x000e0 | ||
40 | #define MPIC_GREG_TIMER_FREQ 0x000f0 | ||
41 | |||
42 | /* | ||
43 | * | ||
44 | * Timer registers | ||
45 | */ | ||
46 | #define MPIC_TIMER_BASE 0x01100 | ||
47 | #define MPIC_TIMER_STRIDE 0x40 | ||
48 | |||
49 | #define MPIC_TIMER_CURRENT_CNT 0x00000 | ||
50 | #define MPIC_TIMER_BASE_CNT 0x00010 | ||
51 | #define MPIC_TIMER_VECTOR_PRI 0x00020 | ||
52 | #define MPIC_TIMER_DESTINATION 0x00030 | ||
53 | |||
54 | /* | ||
55 | * Per-Processor registers | ||
56 | */ | ||
57 | |||
58 | #define MPIC_CPU_THISBASE 0x00000 | ||
59 | #define MPIC_CPU_BASE 0x20000 | ||
60 | #define MPIC_CPU_STRIDE 0x01000 | ||
61 | |||
62 | #define MPIC_CPU_IPI_DISPATCH_0 0x00040 | ||
63 | #define MPIC_CPU_IPI_DISPATCH_1 0x00050 | ||
64 | #define MPIC_CPU_IPI_DISPATCH_2 0x00060 | ||
65 | #define MPIC_CPU_IPI_DISPATCH_3 0x00070 | ||
66 | #define MPIC_CPU_CURRENT_TASK_PRI 0x00080 | ||
67 | #define MPIC_CPU_TASKPRI_MASK 0x0000000f | ||
68 | #define MPIC_CPU_WHOAMI 0x00090 | ||
69 | #define MPIC_CPU_WHOAMI_MASK 0x0000001f | ||
70 | #define MPIC_CPU_INTACK 0x000a0 | ||
71 | #define MPIC_CPU_EOI 0x000b0 | ||
72 | |||
73 | /* | ||
74 | * Per-source registers | ||
75 | */ | ||
76 | |||
77 | #define MPIC_IRQ_BASE 0x10000 | ||
78 | #define MPIC_IRQ_STRIDE 0x00020 | ||
79 | #define MPIC_IRQ_VECTOR_PRI 0x00000 | ||
80 | #define MPIC_VECPRI_MASK 0x80000000 | ||
81 | #define MPIC_VECPRI_ACTIVITY 0x40000000 /* Read Only */ | ||
82 | #define MPIC_VECPRI_PRIORITY_MASK 0x000f0000 | ||
83 | #define MPIC_VECPRI_PRIORITY_SHIFT 16 | ||
84 | #define MPIC_VECPRI_VECTOR_MASK 0x000007ff | ||
85 | #define MPIC_VECPRI_POLARITY_POSITIVE 0x00800000 | ||
86 | #define MPIC_VECPRI_POLARITY_NEGATIVE 0x00000000 | ||
87 | #define MPIC_VECPRI_POLARITY_MASK 0x00800000 | ||
88 | #define MPIC_VECPRI_SENSE_LEVEL 0x00400000 | ||
89 | #define MPIC_VECPRI_SENSE_EDGE 0x00000000 | ||
90 | #define MPIC_VECPRI_SENSE_MASK 0x00400000 | ||
91 | #define MPIC_IRQ_DESTINATION 0x00010 | ||
92 | |||
93 | #define MPIC_MAX_IRQ_SOURCES 2048 | ||
94 | #define MPIC_MAX_CPUS 32 | ||
95 | #define MPIC_MAX_ISU 32 | ||
96 | |||
97 | /* | ||
98 | * Special vector numbers (internal use only) | ||
99 | */ | ||
100 | #define MPIC_VEC_SPURRIOUS 255 | ||
101 | #define MPIC_VEC_IPI_3 254 | ||
102 | #define MPIC_VEC_IPI_2 253 | ||
103 | #define MPIC_VEC_IPI_1 252 | ||
104 | #define MPIC_VEC_IPI_0 251 | ||
105 | |||
106 | /* unused */ | ||
107 | #define MPIC_VEC_TIMER_3 250 | ||
108 | #define MPIC_VEC_TIMER_2 249 | ||
109 | #define MPIC_VEC_TIMER_1 248 | ||
110 | #define MPIC_VEC_TIMER_0 247 | ||
111 | |||
112 | /* Type definition of the cascade handler */ | ||
113 | typedef int (*mpic_cascade_t)(struct pt_regs *regs, void *data); | ||
114 | |||
115 | #ifdef CONFIG_MPIC_BROKEN_U3 | ||
116 | /* Fixup table entry */ | ||
117 | struct mpic_irq_fixup | ||
118 | { | ||
119 | u8 __iomem *base; | ||
120 | unsigned int irq; | ||
121 | }; | ||
122 | #endif /* CONFIG_MPIC_BROKEN_U3 */ | ||
123 | |||
124 | |||
125 | /* The instance data of a given MPIC */ | ||
126 | struct mpic | ||
127 | { | ||
128 | /* The "linux" controller struct */ | ||
129 | hw_irq_controller hc_irq; | ||
130 | #ifdef CONFIG_SMP | ||
131 | hw_irq_controller hc_ipi; | ||
132 | #endif | ||
133 | const char *name; | ||
134 | /* Flags */ | ||
135 | unsigned int flags; | ||
136 | /* How many irq sources in a given ISU */ | ||
137 | unsigned int isu_size; | ||
138 | unsigned int isu_shift; | ||
139 | unsigned int isu_mask; | ||
140 | /* Offset of irq vector numbers */ | ||
141 | unsigned int irq_offset; | ||
142 | unsigned int irq_count; | ||
143 | /* Offset of ipi vector numbers */ | ||
144 | unsigned int ipi_offset; | ||
145 | /* Number of sources */ | ||
146 | unsigned int num_sources; | ||
147 | /* Number of CPUs */ | ||
148 | unsigned int num_cpus; | ||
149 | /* cascade handler */ | ||
150 | mpic_cascade_t cascade; | ||
151 | void *cascade_data; | ||
152 | unsigned int cascade_vec; | ||
153 | /* senses array */ | ||
154 | unsigned char *senses; | ||
155 | unsigned int senses_count; | ||
156 | |||
157 | #ifdef CONFIG_MPIC_BROKEN_U3 | ||
158 | /* The fixup table */ | ||
159 | struct mpic_irq_fixup *fixups; | ||
160 | spinlock_t fixup_lock; | ||
161 | #endif | ||
162 | |||
163 | /* The various ioremap'ed bases */ | ||
164 | volatile u32 __iomem *gregs; | ||
165 | volatile u32 __iomem *tmregs; | ||
166 | volatile u32 __iomem *cpuregs[MPIC_MAX_CPUS]; | ||
167 | volatile u32 __iomem *isus[MPIC_MAX_ISU]; | ||
168 | |||
169 | /* link */ | ||
170 | struct mpic *next; | ||
171 | }; | ||
172 | |||
173 | /* This is the primary controller, only that one has IPIs and | ||
174 | * has afinity control. A non-primary MPIC always uses CPU0 | ||
175 | * registers only | ||
176 | */ | ||
177 | #define MPIC_PRIMARY 0x00000001 | ||
178 | /* Set this for a big-endian MPIC */ | ||
179 | #define MPIC_BIG_ENDIAN 0x00000002 | ||
180 | /* Broken U3 MPIC */ | ||
181 | #define MPIC_BROKEN_U3 0x00000004 | ||
182 | /* Broken IPI registers (autodetected) */ | ||
183 | #define MPIC_BROKEN_IPI 0x00000008 | ||
184 | /* MPIC wants a reset */ | ||
185 | #define MPIC_WANTS_RESET 0x00000010 | ||
186 | |||
187 | /* Allocate the controller structure and setup the linux irq descs | ||
188 | * for the range if interrupts passed in. No HW initialization is | ||
189 | * actually performed. | ||
190 | * | ||
191 | * @phys_addr: physial base address of the MPIC | ||
192 | * @flags: flags, see constants above | ||
193 | * @isu_size: number of interrupts in an ISU. Use 0 to use a | ||
194 | * standard ISU-less setup (aka powermac) | ||
195 | * @irq_offset: first irq number to assign to this mpic | ||
196 | * @irq_count: number of irqs to use with this mpic IRQ sources. Pass 0 | ||
197 | * to match the number of sources | ||
198 | * @ipi_offset: first irq number to assign to this mpic IPI sources, | ||
199 | * used only on primary mpic | ||
200 | * @senses: array of sense values | ||
201 | * @senses_num: number of entries in the array | ||
202 | * | ||
203 | * Note about the sense array. If none is passed, all interrupts are | ||
204 | * setup to be level negative unless MPIC_BROKEN_U3 is set in which | ||
205 | * case they are edge positive (and the array is ignored anyway). | ||
206 | * The values in the array start at the first source of the MPIC, | ||
207 | * that is senses[0] correspond to linux irq "irq_offset". | ||
208 | */ | ||
209 | extern struct mpic *mpic_alloc(unsigned long phys_addr, | ||
210 | unsigned int flags, | ||
211 | unsigned int isu_size, | ||
212 | unsigned int irq_offset, | ||
213 | unsigned int irq_count, | ||
214 | unsigned int ipi_offset, | ||
215 | unsigned char *senses, | ||
216 | unsigned int senses_num, | ||
217 | const char *name); | ||
218 | |||
219 | /* Assign ISUs, to call before mpic_init() | ||
220 | * | ||
221 | * @mpic: controller structure as returned by mpic_alloc() | ||
222 | * @isu_num: ISU number | ||
223 | * @phys_addr: physical address of the ISU | ||
224 | */ | ||
225 | extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, | ||
226 | unsigned long phys_addr); | ||
227 | |||
228 | /* Initialize the controller. After this has been called, none of the above | ||
229 | * should be called again for this mpic | ||
230 | */ | ||
231 | extern void mpic_init(struct mpic *mpic); | ||
232 | |||
233 | /* Setup a cascade. Currently, only one cascade is supported this | ||
234 | * way, though you can always do a normal request_irq() and add | ||
235 | * other cascades this way. You should call this _after_ having | ||
236 | * added all the ISUs | ||
237 | * | ||
238 | * @irq_no: "linux" irq number of the cascade (that is offset'ed vector) | ||
239 | * @handler: cascade handler function | ||
240 | */ | ||
241 | extern void mpic_setup_cascade(unsigned int irq_no, mpic_cascade_t hanlder, | ||
242 | void *data); | ||
243 | |||
244 | /* | ||
245 | * All of the following functions must only be used after the | ||
246 | * ISUs have been assigned and the controller fully initialized | ||
247 | * with mpic_init() | ||
248 | */ | ||
249 | |||
250 | |||
251 | /* Change/Read the priority of an interrupt. Default is 8 for irqs and | ||
252 | * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the | ||
253 | * IPI number is then the offset'ed (linux irq number mapped to the IPI) | ||
254 | */ | ||
255 | extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri); | ||
256 | extern unsigned int mpic_irq_get_priority(unsigned int irq); | ||
257 | |||
258 | /* Setup a non-boot CPU */ | ||
259 | extern void mpic_setup_this_cpu(void); | ||
260 | |||
261 | /* Clean up for kexec (or cpu offline or ...) */ | ||
262 | extern void mpic_teardown_this_cpu(int secondary); | ||
263 | |||
264 | /* Get the current cpu priority for this cpu (0..15) */ | ||
265 | extern int mpic_cpu_get_priority(void); | ||
266 | |||
267 | /* Set the current cpu priority for this cpu */ | ||
268 | extern void mpic_cpu_set_priority(int prio); | ||
269 | |||
270 | /* Request IPIs on primary mpic */ | ||
271 | extern void mpic_request_ipis(void); | ||
272 | |||
273 | /* Send an IPI (non offseted number 0..3) */ | ||
274 | extern void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask); | ||
275 | |||
276 | /* Send a message (IPI) to a given target (cpu number or MSG_*) */ | ||
277 | void smp_mpic_message_pass(int target, int msg); | ||
278 | |||
279 | /* Fetch interrupt from a given mpic */ | ||
280 | extern int mpic_get_one_irq(struct mpic *mpic, struct pt_regs *regs); | ||
281 | /* This one gets to the primary mpic */ | ||
282 | extern int mpic_get_irq(struct pt_regs *regs); | ||
283 | |||
284 | /* global mpic for pSeries */ | ||
285 | extern struct mpic *pSeries_mpic; | ||
286 | |||
287 | #endif /* _ASM_POWERPC_MPIC_H */ | ||
diff --git a/include/asm-powerpc/numnodes.h b/include/asm-powerpc/numnodes.h new file mode 100644 index 000000000000..795533aca095 --- /dev/null +++ b/include/asm-powerpc/numnodes.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _ASM_POWERPC_MAX_NUMNODES_H | ||
2 | #define _ASM_POWERPC_MAX_NUMNODES_H | ||
3 | |||
4 | /* Max 16 Nodes */ | ||
5 | #define NODES_SHIFT 4 | ||
6 | |||
7 | #endif /* _ASM_POWERPC_MAX_NUMNODES_H */ | ||
diff --git a/include/asm-powerpc/of_device.h b/include/asm-powerpc/of_device.h new file mode 100644 index 000000000000..ddb16aae0bd6 --- /dev/null +++ b/include/asm-powerpc/of_device.h | |||
@@ -0,0 +1,64 @@ | |||
1 | #ifndef _ASM_POWERPC_OF_DEVICE_H | ||
2 | #define _ASM_POWERPC_OF_DEVICE_H | ||
3 | |||
4 | #include <linux/device.h> | ||
5 | #include <linux/mod_devicetable.h> | ||
6 | #include <asm/prom.h> | ||
7 | |||
8 | /* | ||
9 | * The of_platform_bus_type is a bus type used by drivers that do not | ||
10 | * attach to a macio or similar bus but still use OF probing | ||
11 | * mecanism | ||
12 | */ | ||
13 | extern struct bus_type of_platform_bus_type; | ||
14 | |||
15 | /* | ||
16 | * The of_device is a kind of "base class" that is a superset of | ||
17 | * struct device for use by devices attached to an OF node and | ||
18 | * probed using OF properties | ||
19 | */ | ||
20 | struct of_device | ||
21 | { | ||
22 | struct device_node *node; /* OF device node */ | ||
23 | u64 dma_mask; /* DMA mask */ | ||
24 | struct device dev; /* Generic device interface */ | ||
25 | }; | ||
26 | #define to_of_device(d) container_of(d, struct of_device, dev) | ||
27 | |||
28 | extern const struct of_device_id *of_match_device( | ||
29 | const struct of_device_id *matches, const struct of_device *dev); | ||
30 | |||
31 | extern struct of_device *of_dev_get(struct of_device *dev); | ||
32 | extern void of_dev_put(struct of_device *dev); | ||
33 | |||
34 | /* | ||
35 | * An of_platform_driver driver is attached to a basic of_device on | ||
36 | * the "platform bus" (of_platform_bus_type) | ||
37 | */ | ||
38 | struct of_platform_driver | ||
39 | { | ||
40 | char *name; | ||
41 | struct of_device_id *match_table; | ||
42 | struct module *owner; | ||
43 | |||
44 | int (*probe)(struct of_device* dev, const struct of_device_id *match); | ||
45 | int (*remove)(struct of_device* dev); | ||
46 | |||
47 | int (*suspend)(struct of_device* dev, pm_message_t state); | ||
48 | int (*resume)(struct of_device* dev); | ||
49 | int (*shutdown)(struct of_device* dev); | ||
50 | |||
51 | struct device_driver driver; | ||
52 | }; | ||
53 | #define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver) | ||
54 | |||
55 | extern int of_register_driver(struct of_platform_driver *drv); | ||
56 | extern void of_unregister_driver(struct of_platform_driver *drv); | ||
57 | extern int of_device_register(struct of_device *ofdev); | ||
58 | extern void of_device_unregister(struct of_device *ofdev); | ||
59 | extern struct of_device *of_platform_device_create(struct device_node *np, | ||
60 | const char *bus_id, | ||
61 | struct device *parent); | ||
62 | extern void of_release_dev(struct device *dev); | ||
63 | |||
64 | #endif /* _ASM_POWERPC_OF_DEVICE_H */ | ||
diff --git a/include/asm-powerpc/ohare.h b/include/asm-powerpc/ohare.h new file mode 100644 index 000000000000..023b59772231 --- /dev/null +++ b/include/asm-powerpc/ohare.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * ohare.h: definitions for using the "O'Hare" I/O controller chip. | ||
3 | * | ||
4 | * Copyright (C) 1997 Paul Mackerras. | ||
5 | * | ||
6 | * BenH: Changed to match those of heathrow (but not all of them). Please | ||
7 | * check if I didn't break anything (especially the media bay). | ||
8 | */ | ||
9 | |||
10 | /* offset from ohare base for feature control register */ | ||
11 | #define OHARE_MBCR 0x34 | ||
12 | #define OHARE_FCR 0x38 | ||
13 | |||
14 | /* | ||
15 | * Bits in feature control register. | ||
16 | * These were mostly derived by experiment on a powerbook 3400 | ||
17 | * and may differ for other machines. | ||
18 | */ | ||
19 | #define OH_SCC_RESET 1 | ||
20 | #define OH_BAY_POWER_N 2 /* a guess */ | ||
21 | #define OH_BAY_PCI_ENABLE 4 /* a guess */ | ||
22 | #define OH_BAY_IDE_ENABLE 8 | ||
23 | #define OH_BAY_FLOPPY_ENABLE 0x10 | ||
24 | #define OH_IDE0_ENABLE 0x20 | ||
25 | #define OH_IDE0_RESET_N 0x40 /* a guess */ | ||
26 | #define OH_BAY_DEV_MASK 0x1c | ||
27 | #define OH_BAY_RESET_N 0x80 | ||
28 | #define OH_IOBUS_ENABLE 0x100 /* IOBUS seems to be IDE */ | ||
29 | #define OH_SCC_ENABLE 0x200 | ||
30 | #define OH_MESH_ENABLE 0x400 | ||
31 | #define OH_FLOPPY_ENABLE 0x800 | ||
32 | #define OH_SCCA_IO 0x4000 | ||
33 | #define OH_SCCB_IO 0x8000 | ||
34 | #define OH_VIA_ENABLE 0x10000 /* Is apparently wrong, to be verified */ | ||
35 | #define OH_IDE1_RESET_N 0x800000 | ||
36 | |||
37 | /* | ||
38 | * Bits to set in the feature control register on PowerBooks. | ||
39 | */ | ||
40 | #define PBOOK_FEATURES (OH_IDE_ENABLE | OH_SCC_ENABLE | \ | ||
41 | OH_MESH_ENABLE | OH_SCCA_IO | OH_SCCB_IO) | ||
42 | |||
43 | /* | ||
44 | * A magic value to put into the feature control register of the | ||
45 | * "ohare" I/O controller on Starmaxes to enable the IDE CD interface. | ||
46 | * Contributed by Harry Eaton. | ||
47 | */ | ||
48 | #define STARMAX_FEATURES 0xbeff7a | ||
diff --git a/include/asm-powerpc/oprofile_impl.h b/include/asm-powerpc/oprofile_impl.h new file mode 100644 index 000000000000..8013cd273ced --- /dev/null +++ b/include/asm-powerpc/oprofile_impl.h | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM | ||
3 | * | ||
4 | * Based on alpha version. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifndef _ASM_POWERPC_OPROFILE_IMPL_H | ||
13 | #define _ASM_POWERPC_OPROFILE_IMPL_H | ||
14 | |||
15 | #define OP_MAX_COUNTER 8 | ||
16 | |||
17 | /* Per-counter configuration as set via oprofilefs. */ | ||
18 | struct op_counter_config { | ||
19 | #ifdef __powerpc64__ | ||
20 | unsigned long valid; | ||
21 | #endif | ||
22 | unsigned long enabled; | ||
23 | unsigned long event; | ||
24 | unsigned long count; | ||
25 | unsigned long kernel; | ||
26 | #ifdef __powerpc64__ | ||
27 | /* We dont support per counter user/kernel selection */ | ||
28 | #endif | ||
29 | unsigned long user; | ||
30 | unsigned long unit_mask; | ||
31 | }; | ||
32 | |||
33 | /* System-wide configuration as set via oprofilefs. */ | ||
34 | struct op_system_config { | ||
35 | #ifdef __powerpc64__ | ||
36 | unsigned long mmcr0; | ||
37 | unsigned long mmcr1; | ||
38 | unsigned long mmcra; | ||
39 | #endif | ||
40 | unsigned long enable_kernel; | ||
41 | unsigned long enable_user; | ||
42 | #ifdef __powerpc64__ | ||
43 | unsigned long backtrace_spinlocks; | ||
44 | #endif | ||
45 | }; | ||
46 | |||
47 | /* Per-arch configuration */ | ||
48 | struct op_powerpc_model { | ||
49 | void (*reg_setup) (struct op_counter_config *, | ||
50 | struct op_system_config *, | ||
51 | int num_counters); | ||
52 | #ifdef __powerpc64__ | ||
53 | void (*cpu_setup) (void *); | ||
54 | #endif | ||
55 | void (*start) (struct op_counter_config *); | ||
56 | void (*stop) (void); | ||
57 | void (*handle_interrupt) (struct pt_regs *, | ||
58 | struct op_counter_config *); | ||
59 | int num_counters; | ||
60 | }; | ||
61 | |||
62 | #ifdef __powerpc64__ | ||
63 | extern struct op_powerpc_model op_model_rs64; | ||
64 | extern struct op_powerpc_model op_model_power4; | ||
65 | |||
66 | static inline unsigned int ctr_read(unsigned int i) | ||
67 | { | ||
68 | switch(i) { | ||
69 | case 0: | ||
70 | return mfspr(SPRN_PMC1); | ||
71 | case 1: | ||
72 | return mfspr(SPRN_PMC2); | ||
73 | case 2: | ||
74 | return mfspr(SPRN_PMC3); | ||
75 | case 3: | ||
76 | return mfspr(SPRN_PMC4); | ||
77 | case 4: | ||
78 | return mfspr(SPRN_PMC5); | ||
79 | case 5: | ||
80 | return mfspr(SPRN_PMC6); | ||
81 | case 6: | ||
82 | return mfspr(SPRN_PMC7); | ||
83 | case 7: | ||
84 | return mfspr(SPRN_PMC8); | ||
85 | default: | ||
86 | return 0; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | static inline void ctr_write(unsigned int i, unsigned int val) | ||
91 | { | ||
92 | switch(i) { | ||
93 | case 0: | ||
94 | mtspr(SPRN_PMC1, val); | ||
95 | break; | ||
96 | case 1: | ||
97 | mtspr(SPRN_PMC2, val); | ||
98 | break; | ||
99 | case 2: | ||
100 | mtspr(SPRN_PMC3, val); | ||
101 | break; | ||
102 | case 3: | ||
103 | mtspr(SPRN_PMC4, val); | ||
104 | break; | ||
105 | case 4: | ||
106 | mtspr(SPRN_PMC5, val); | ||
107 | break; | ||
108 | case 5: | ||
109 | mtspr(SPRN_PMC6, val); | ||
110 | break; | ||
111 | case 6: | ||
112 | mtspr(SPRN_PMC7, val); | ||
113 | break; | ||
114 | case 7: | ||
115 | mtspr(SPRN_PMC8, val); | ||
116 | break; | ||
117 | default: | ||
118 | break; | ||
119 | } | ||
120 | } | ||
121 | #endif /* __powerpc64__ */ | ||
122 | |||
123 | #endif /* _ASM_POWERPC_OPROFILE_IMPL_H */ | ||
diff --git a/include/asm-powerpc/pSeries_reconfig.h b/include/asm-powerpc/pSeries_reconfig.h new file mode 100644 index 000000000000..c0db1ea7f7d1 --- /dev/null +++ b/include/asm-powerpc/pSeries_reconfig.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef _PPC64_PSERIES_RECONFIG_H | ||
2 | #define _PPC64_PSERIES_RECONFIG_H | ||
3 | |||
4 | #include <linux/notifier.h> | ||
5 | |||
6 | /* | ||
7 | * Use this API if your code needs to know about OF device nodes being | ||
8 | * added or removed on pSeries systems. | ||
9 | */ | ||
10 | |||
11 | #define PSERIES_RECONFIG_ADD 0x0001 | ||
12 | #define PSERIES_RECONFIG_REMOVE 0x0002 | ||
13 | |||
14 | #ifdef CONFIG_PPC_PSERIES | ||
15 | extern int pSeries_reconfig_notifier_register(struct notifier_block *); | ||
16 | extern void pSeries_reconfig_notifier_unregister(struct notifier_block *); | ||
17 | #else /* !CONFIG_PPC_PSERIES */ | ||
18 | static inline int pSeries_reconfig_notifier_register(struct notifier_block *nb) | ||
19 | { | ||
20 | return 0; | ||
21 | } | ||
22 | static inline void pSeries_reconfig_notifier_unregister(struct notifier_block *nb) { } | ||
23 | #endif /* CONFIG_PPC_PSERIES */ | ||
24 | |||
25 | #endif /* _PPC64_PSERIES_RECONFIG_H */ | ||
diff --git a/include/asm-powerpc/parport.h b/include/asm-powerpc/parport.h new file mode 100644 index 000000000000..d86b410a6f8b --- /dev/null +++ b/include/asm-powerpc/parport.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * parport.h: platform-specific PC-style parport initialisation | ||
3 | * | ||
4 | * Copyright (C) 1999, 2000 Tim Waugh <tim@cyberelk.demon.co.uk> | ||
5 | * | ||
6 | * This file should only be included by drivers/parport/parport_pc.c. | ||
7 | */ | ||
8 | |||
9 | #ifndef _ASM_POWERPC_PARPORT_H | ||
10 | #define _ASM_POWERPC_PARPORT_H | ||
11 | |||
12 | static int __devinit parport_pc_find_isa_ports (int autoirq, int autodma); | ||
13 | static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma) | ||
14 | { | ||
15 | return parport_pc_find_isa_ports (autoirq, autodma); | ||
16 | } | ||
17 | |||
18 | #endif /* !(_ASM_POWERPC_PARPORT_H) */ | ||
diff --git a/include/asm-powerpc/pmac_feature.h b/include/asm-powerpc/pmac_feature.h new file mode 100644 index 000000000000..e9683bcff19b --- /dev/null +++ b/include/asm-powerpc/pmac_feature.h | |||
@@ -0,0 +1,380 @@ | |||
1 | /* | ||
2 | * Definition of platform feature hooks for PowerMacs | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1998 Paul Mackerras & | ||
9 | * Ben. Herrenschmidt. | ||
10 | * | ||
11 | * | ||
12 | * Note: I removed media-bay details from the feature stuff, I believe it's | ||
13 | * not worth it, the media-bay driver can directly use the mac-io | ||
14 | * ASIC registers. | ||
15 | * | ||
16 | * Implementation note: Currently, none of these functions will block. | ||
17 | * However, they may internally protect themselves with a spinlock | ||
18 | * for way too long. Be prepared for at least some of these to block | ||
19 | * in the future. | ||
20 | * | ||
21 | * Unless specifically defined, the result code is assumed to be an | ||
22 | * error when negative, 0 is the default success result. Some functions | ||
23 | * may return additional positive result values. | ||
24 | * | ||
25 | * To keep implementation simple, all feature calls are assumed to have | ||
26 | * the prototype parameters (struct device_node* node, int value). | ||
27 | * When either is not used, pass 0. | ||
28 | */ | ||
29 | |||
30 | #ifdef __KERNEL__ | ||
31 | #ifndef __PPC_ASM_PMAC_FEATURE_H | ||
32 | #define __PPC_ASM_PMAC_FEATURE_H | ||
33 | |||
34 | #include <asm/macio.h> | ||
35 | #include <asm/machdep.h> | ||
36 | |||
37 | /* | ||
38 | * Known Mac motherboard models | ||
39 | * | ||
40 | * Please, report any error here to benh@kernel.crashing.org, thanks ! | ||
41 | * | ||
42 | * Note that I don't fully maintain this list for Core99 & MacRISC2 | ||
43 | * and I'm considering removing all NewWorld entries from it and | ||
44 | * entirely rely on the model string. | ||
45 | */ | ||
46 | |||
47 | /* PowerSurge are the first generation of PCI Pmacs. This include | ||
48 | * all of the Grand-Central based machines. We currently don't | ||
49 | * differenciate most of them. | ||
50 | */ | ||
51 | #define PMAC_TYPE_PSURGE 0x10 /* PowerSurge */ | ||
52 | #define PMAC_TYPE_ANS 0x11 /* Apple Network Server */ | ||
53 | |||
54 | /* Here is the infamous serie of OHare based machines | ||
55 | */ | ||
56 | #define PMAC_TYPE_COMET 0x20 /* Beleived to be PowerBook 2400 */ | ||
57 | #define PMAC_TYPE_HOOPER 0x21 /* Beleived to be PowerBook 3400 */ | ||
58 | #define PMAC_TYPE_KANGA 0x22 /* PowerBook 3500 (first G3) */ | ||
59 | #define PMAC_TYPE_ALCHEMY 0x23 /* Alchemy motherboard base */ | ||
60 | #define PMAC_TYPE_GAZELLE 0x24 /* Spartacus, some 5xxx/6xxx */ | ||
61 | #define PMAC_TYPE_UNKNOWN_OHARE 0x2f /* Unknown, but OHare based */ | ||
62 | |||
63 | /* Here are the Heathrow based machines | ||
64 | * FIXME: Differenciate wallstreet,mainstreet,wallstreetII | ||
65 | */ | ||
66 | #define PMAC_TYPE_GOSSAMER 0x30 /* Gossamer motherboard */ | ||
67 | #define PMAC_TYPE_SILK 0x31 /* Desktop PowerMac G3 */ | ||
68 | #define PMAC_TYPE_WALLSTREET 0x32 /* Wallstreet/Mainstreet PowerBook*/ | ||
69 | #define PMAC_TYPE_UNKNOWN_HEATHROW 0x3f /* Unknown but heathrow based */ | ||
70 | |||
71 | /* Here are newworld machines based on Paddington (heathrow derivative) | ||
72 | */ | ||
73 | #define PMAC_TYPE_101_PBOOK 0x40 /* 101 PowerBook (aka Lombard) */ | ||
74 | #define PMAC_TYPE_ORIG_IMAC 0x41 /* First generation iMac */ | ||
75 | #define PMAC_TYPE_YOSEMITE 0x42 /* B&W G3 */ | ||
76 | #define PMAC_TYPE_YIKES 0x43 /* Yikes G4 (PCI graphics) */ | ||
77 | #define PMAC_TYPE_UNKNOWN_PADDINGTON 0x4f /* Unknown but paddington based */ | ||
78 | |||
79 | /* Core99 machines based on UniNorth 1.0 and 1.5 | ||
80 | * | ||
81 | * Note: A single entry here may cover several actual models according | ||
82 | * to the device-tree. (Sawtooth is most tower G4s, FW_IMAC is most | ||
83 | * FireWire based iMacs, etc...). Those machines are too similar to be | ||
84 | * distinguished here, when they need to be differencied, use the | ||
85 | * device-tree "model" or "compatible" property. | ||
86 | */ | ||
87 | #define PMAC_TYPE_ORIG_IBOOK 0x40 /* First iBook model (no firewire) */ | ||
88 | #define PMAC_TYPE_SAWTOOTH 0x41 /* Desktop G4s */ | ||
89 | #define PMAC_TYPE_FW_IMAC 0x42 /* FireWire iMacs (except Pangea based) */ | ||
90 | #define PMAC_TYPE_FW_IBOOK 0x43 /* FireWire iBooks (except iBook2) */ | ||
91 | #define PMAC_TYPE_CUBE 0x44 /* Cube PowerMac */ | ||
92 | #define PMAC_TYPE_QUICKSILVER 0x45 /* QuickSilver G4s */ | ||
93 | #define PMAC_TYPE_PISMO 0x46 /* Pismo PowerBook */ | ||
94 | #define PMAC_TYPE_TITANIUM 0x47 /* Titanium PowerBook */ | ||
95 | #define PMAC_TYPE_TITANIUM2 0x48 /* Titanium II PowerBook (no L3, M6) */ | ||
96 | #define PMAC_TYPE_TITANIUM3 0x49 /* Titanium III PowerBook (with L3 & M7) */ | ||
97 | #define PMAC_TYPE_TITANIUM4 0x50 /* Titanium IV PowerBook (with L3 & M9) */ | ||
98 | #define PMAC_TYPE_EMAC 0x50 /* eMac */ | ||
99 | #define PMAC_TYPE_UNKNOWN_CORE99 0x5f | ||
100 | |||
101 | /* MacRisc2 with UniNorth 2.0 */ | ||
102 | #define PMAC_TYPE_RACKMAC 0x80 /* XServe */ | ||
103 | #define PMAC_TYPE_WINDTUNNEL 0x81 | ||
104 | |||
105 | /* MacRISC2 machines based on the Pangea chipset | ||
106 | */ | ||
107 | #define PMAC_TYPE_PANGEA_IMAC 0x100 /* Flower Power iMac */ | ||
108 | #define PMAC_TYPE_IBOOK2 0x101 /* iBook2 (polycarbonate) */ | ||
109 | #define PMAC_TYPE_FLAT_PANEL_IMAC 0x102 /* Flat panel iMac */ | ||
110 | #define PMAC_TYPE_UNKNOWN_PANGEA 0x10f | ||
111 | |||
112 | /* MacRISC2 machines based on the Intrepid chipset | ||
113 | */ | ||
114 | #define PMAC_TYPE_UNKNOWN_INTREPID 0x11f /* Generic */ | ||
115 | |||
116 | /* MacRISC4 / G5 machines. We don't have per-machine selection here anymore, | ||
117 | * but rather machine families | ||
118 | */ | ||
119 | #define PMAC_TYPE_POWERMAC_G5 0x150 /* U3 & U3H based */ | ||
120 | #define PMAC_TYPE_POWERMAC_G5_U3L 0x151 /* U3L based desktop */ | ||
121 | #define PMAC_TYPE_IMAC_G5 0x152 /* iMac G5 */ | ||
122 | #define PMAC_TYPE_XSERVE_G5 0x153 /* Xserve G5 */ | ||
123 | #define PMAC_TYPE_UNKNOWN_K2 0x19f /* Any other K2 based */ | ||
124 | |||
125 | /* | ||
126 | * Motherboard flags | ||
127 | */ | ||
128 | |||
129 | #define PMAC_MB_CAN_SLEEP 0x00000001 | ||
130 | #define PMAC_MB_HAS_FW_POWER 0x00000002 | ||
131 | #define PMAC_MB_OLD_CORE99 0x00000004 | ||
132 | #define PMAC_MB_MOBILE 0x00000008 | ||
133 | #define PMAC_MB_MAY_SLEEP 0x00000010 | ||
134 | |||
135 | /* | ||
136 | * Feature calls supported on pmac | ||
137 | * | ||
138 | */ | ||
139 | |||
140 | /* | ||
141 | * Use this inline wrapper | ||
142 | */ | ||
143 | struct device_node; | ||
144 | |||
145 | static inline long pmac_call_feature(int selector, struct device_node* node, | ||
146 | long param, long value) | ||
147 | { | ||
148 | if (!ppc_md.feature_call) | ||
149 | return -ENODEV; | ||
150 | return ppc_md.feature_call(selector, node, param, value); | ||
151 | } | ||
152 | |||
153 | /* PMAC_FTR_SERIAL_ENABLE (struct device_node* node, int param, int value) | ||
154 | * enable/disable an SCC side. Pass the node corresponding to the | ||
155 | * channel side as a parameter. | ||
156 | * param is the type of port | ||
157 | * if param is ored with PMAC_SCC_FLAG_XMON, then the SCC is locked enabled | ||
158 | * for use by xmon. | ||
159 | */ | ||
160 | #define PMAC_FTR_SCC_ENABLE PMAC_FTR_DEF(0) | ||
161 | #define PMAC_SCC_ASYNC 0 | ||
162 | #define PMAC_SCC_IRDA 1 | ||
163 | #define PMAC_SCC_I2S1 2 | ||
164 | #define PMAC_SCC_FLAG_XMON 0x00001000 | ||
165 | |||
166 | /* PMAC_FTR_MODEM_ENABLE (struct device_node* node, 0, int value) | ||
167 | * enable/disable the internal modem. | ||
168 | */ | ||
169 | #define PMAC_FTR_MODEM_ENABLE PMAC_FTR_DEF(1) | ||
170 | |||
171 | /* PMAC_FTR_SWIM3_ENABLE (struct device_node* node, 0,int value) | ||
172 | * enable/disable the swim3 (floppy) cell of a mac-io ASIC | ||
173 | */ | ||
174 | #define PMAC_FTR_SWIM3_ENABLE PMAC_FTR_DEF(2) | ||
175 | |||
176 | /* PMAC_FTR_MESH_ENABLE (struct device_node* node, 0, int value) | ||
177 | * enable/disable the mesh (scsi) cell of a mac-io ASIC | ||
178 | */ | ||
179 | #define PMAC_FTR_MESH_ENABLE PMAC_FTR_DEF(3) | ||
180 | |||
181 | /* PMAC_FTR_IDE_ENABLE (struct device_node* node, int busID, int value) | ||
182 | * enable/disable an IDE port of a mac-io ASIC | ||
183 | * pass the busID parameter | ||
184 | */ | ||
185 | #define PMAC_FTR_IDE_ENABLE PMAC_FTR_DEF(4) | ||
186 | |||
187 | /* PMAC_FTR_IDE_RESET (struct device_node* node, int busID, int value) | ||
188 | * assert(1)/release(0) an IDE reset line (mac-io IDE only) | ||
189 | */ | ||
190 | #define PMAC_FTR_IDE_RESET PMAC_FTR_DEF(5) | ||
191 | |||
192 | /* PMAC_FTR_BMAC_ENABLE (struct device_node* node, 0, int value) | ||
193 | * enable/disable the bmac (ethernet) cell of a mac-io ASIC, also drive | ||
194 | * it's reset line | ||
195 | */ | ||
196 | #define PMAC_FTR_BMAC_ENABLE PMAC_FTR_DEF(6) | ||
197 | |||
198 | /* PMAC_FTR_GMAC_ENABLE (struct device_node* node, 0, int value) | ||
199 | * enable/disable the gmac (ethernet) cell of an uninorth ASIC. This | ||
200 | * control the cell's clock. | ||
201 | */ | ||
202 | #define PMAC_FTR_GMAC_ENABLE PMAC_FTR_DEF(7) | ||
203 | |||
204 | /* PMAC_FTR_GMAC_PHY_RESET (struct device_node* node, 0, 0) | ||
205 | * Perform a HW reset of the PHY connected to a gmac controller. | ||
206 | * Pass the gmac device node, not the PHY node. | ||
207 | */ | ||
208 | #define PMAC_FTR_GMAC_PHY_RESET PMAC_FTR_DEF(8) | ||
209 | |||
210 | /* PMAC_FTR_SOUND_CHIP_ENABLE (struct device_node* node, 0, int value) | ||
211 | * enable/disable the sound chip, whatever it is and provided it can | ||
212 | * acually be controlled | ||
213 | */ | ||
214 | #define PMAC_FTR_SOUND_CHIP_ENABLE PMAC_FTR_DEF(9) | ||
215 | |||
216 | /* -- add various tweaks related to sound routing -- */ | ||
217 | |||
218 | /* PMAC_FTR_AIRPORT_ENABLE (struct device_node* node, 0, int value) | ||
219 | * enable/disable the airport card | ||
220 | */ | ||
221 | #define PMAC_FTR_AIRPORT_ENABLE PMAC_FTR_DEF(10) | ||
222 | |||
223 | /* PMAC_FTR_RESET_CPU (NULL, int cpu_nr, 0) | ||
224 | * toggle the reset line of a CPU on an uninorth-based SMP machine | ||
225 | */ | ||
226 | #define PMAC_FTR_RESET_CPU PMAC_FTR_DEF(11) | ||
227 | |||
228 | /* PMAC_FTR_USB_ENABLE (struct device_node* node, 0, int value) | ||
229 | * enable/disable an USB cell, along with the power of the USB "pad" | ||
230 | * on keylargo based machines | ||
231 | */ | ||
232 | #define PMAC_FTR_USB_ENABLE PMAC_FTR_DEF(12) | ||
233 | |||
234 | /* PMAC_FTR_1394_ENABLE (struct device_node* node, 0, int value) | ||
235 | * enable/disable the firewire cell of an uninorth ASIC. | ||
236 | */ | ||
237 | #define PMAC_FTR_1394_ENABLE PMAC_FTR_DEF(13) | ||
238 | |||
239 | /* PMAC_FTR_1394_CABLE_POWER (struct device_node* node, 0, int value) | ||
240 | * enable/disable the firewire cable power supply of the uninorth | ||
241 | * firewire cell | ||
242 | */ | ||
243 | #define PMAC_FTR_1394_CABLE_POWER PMAC_FTR_DEF(14) | ||
244 | |||
245 | /* PMAC_FTR_SLEEP_STATE (struct device_node* node, 0, int value) | ||
246 | * set the sleep state of the motherboard. | ||
247 | * | ||
248 | * Pass -1 as value to query for sleep capability | ||
249 | * Pass 1 to set IOs to sleep | ||
250 | * Pass 0 to set IOs to wake | ||
251 | */ | ||
252 | #define PMAC_FTR_SLEEP_STATE PMAC_FTR_DEF(15) | ||
253 | |||
254 | /* PMAC_FTR_GET_MB_INFO (NULL, selector, 0) | ||
255 | * | ||
256 | * returns some motherboard infos. | ||
257 | * selector: 0 - model id | ||
258 | * 1 - model flags (capabilities) | ||
259 | * 2 - model name (cast to const char *) | ||
260 | */ | ||
261 | #define PMAC_FTR_GET_MB_INFO PMAC_FTR_DEF(16) | ||
262 | #define PMAC_MB_INFO_MODEL 0 | ||
263 | #define PMAC_MB_INFO_FLAGS 1 | ||
264 | #define PMAC_MB_INFO_NAME 2 | ||
265 | |||
266 | /* PMAC_FTR_READ_GPIO (NULL, int index, 0) | ||
267 | * | ||
268 | * read a GPIO from a mac-io controller of type KeyLargo or Pangea. | ||
269 | * the value returned is a byte (positive), or a negative error code | ||
270 | */ | ||
271 | #define PMAC_FTR_READ_GPIO PMAC_FTR_DEF(17) | ||
272 | |||
273 | /* PMAC_FTR_WRITE_GPIO (NULL, int index, int value) | ||
274 | * | ||
275 | * write a GPIO of a mac-io controller of type KeyLargo or Pangea. | ||
276 | */ | ||
277 | #define PMAC_FTR_WRITE_GPIO PMAC_FTR_DEF(18) | ||
278 | |||
279 | /* PMAC_FTR_ENABLE_MPIC | ||
280 | * | ||
281 | * Enable the MPIC cell | ||
282 | */ | ||
283 | #define PMAC_FTR_ENABLE_MPIC PMAC_FTR_DEF(19) | ||
284 | |||
285 | /* PMAC_FTR_AACK_DELAY_ENABLE (NULL, int enable, 0) | ||
286 | * | ||
287 | * Enable/disable the AACK delay on the northbridge for systems using DFS | ||
288 | */ | ||
289 | #define PMAC_FTR_AACK_DELAY_ENABLE PMAC_FTR_DEF(20) | ||
290 | |||
291 | /* PMAC_FTR_DEVICE_CAN_WAKE | ||
292 | * | ||
293 | * Used by video drivers to inform system that they can actually perform | ||
294 | * wakeup from sleep | ||
295 | */ | ||
296 | #define PMAC_FTR_DEVICE_CAN_WAKE PMAC_FTR_DEF(22) | ||
297 | |||
298 | |||
299 | /* Don't use those directly, they are for the sake of pmac_setup.c */ | ||
300 | extern long pmac_do_feature_call(unsigned int selector, ...); | ||
301 | extern void pmac_feature_init(void); | ||
302 | |||
303 | /* Video suspend tweak */ | ||
304 | extern void pmac_set_early_video_resume(void (*proc)(void *data), void *data); | ||
305 | extern void pmac_call_early_video_resume(void); | ||
306 | |||
307 | #define PMAC_FTR_DEF(x) ((_MACH_Pmac << 16) | (x)) | ||
308 | |||
309 | /* The AGP driver registers itself here */ | ||
310 | extern void pmac_register_agp_pm(struct pci_dev *bridge, | ||
311 | int (*suspend)(struct pci_dev *bridge), | ||
312 | int (*resume)(struct pci_dev *bridge)); | ||
313 | |||
314 | /* Those are meant to be used by video drivers to deal with AGP | ||
315 | * suspend resume properly | ||
316 | */ | ||
317 | extern void pmac_suspend_agp_for_card(struct pci_dev *dev); | ||
318 | extern void pmac_resume_agp_for_card(struct pci_dev *dev); | ||
319 | |||
320 | /* Used by the via-pmu driver for suspend/resume | ||
321 | */ | ||
322 | extern void pmac_tweak_clock_spreading(int enable); | ||
323 | |||
324 | /* | ||
325 | * The part below is for use by macio_asic.c only, do not rely | ||
326 | * on the data structures or constants below in a normal driver | ||
327 | * | ||
328 | */ | ||
329 | |||
330 | #define MAX_MACIO_CHIPS 2 | ||
331 | |||
332 | enum { | ||
333 | macio_unknown = 0, | ||
334 | macio_grand_central, | ||
335 | macio_ohare, | ||
336 | macio_ohareII, | ||
337 | macio_heathrow, | ||
338 | macio_gatwick, | ||
339 | macio_paddington, | ||
340 | macio_keylargo, | ||
341 | macio_pangea, | ||
342 | macio_intrepid, | ||
343 | macio_keylargo2, | ||
344 | }; | ||
345 | |||
346 | struct macio_chip | ||
347 | { | ||
348 | struct device_node *of_node; | ||
349 | int type; | ||
350 | const char *name; | ||
351 | int rev; | ||
352 | volatile u32 __iomem *base; | ||
353 | unsigned long flags; | ||
354 | |||
355 | /* For use by macio_asic PCI driver */ | ||
356 | struct macio_bus lbus; | ||
357 | }; | ||
358 | |||
359 | extern struct macio_chip macio_chips[MAX_MACIO_CHIPS]; | ||
360 | |||
361 | #define MACIO_FLAG_SCCA_ON 0x00000001 | ||
362 | #define MACIO_FLAG_SCCB_ON 0x00000002 | ||
363 | #define MACIO_FLAG_SCC_LOCKED 0x00000004 | ||
364 | #define MACIO_FLAG_AIRPORT_ON 0x00000010 | ||
365 | #define MACIO_FLAG_FW_SUPPORTED 0x00000020 | ||
366 | |||
367 | extern struct macio_chip* macio_find(struct device_node* child, int type); | ||
368 | |||
369 | #define MACIO_FCR32(macio, r) ((macio)->base + ((r) >> 2)) | ||
370 | #define MACIO_FCR8(macio, r) (((volatile u8 __iomem *)((macio)->base)) + (r)) | ||
371 | |||
372 | #define MACIO_IN32(r) (in_le32(MACIO_FCR32(macio,r))) | ||
373 | #define MACIO_OUT32(r,v) (out_le32(MACIO_FCR32(macio,r), (v))) | ||
374 | #define MACIO_BIS(r,v) (MACIO_OUT32((r), MACIO_IN32(r) | (v))) | ||
375 | #define MACIO_BIC(r,v) (MACIO_OUT32((r), MACIO_IN32(r) & ~(v))) | ||
376 | #define MACIO_IN8(r) (in_8(MACIO_FCR8(macio,r))) | ||
377 | #define MACIO_OUT8(r,v) (out_8(MACIO_FCR8(macio,r), (v))) | ||
378 | |||
379 | #endif /* __PPC_ASM_PMAC_FEATURE_H */ | ||
380 | #endif /* __KERNEL__ */ | ||
diff --git a/include/asm-powerpc/pmac_low_i2c.h b/include/asm-powerpc/pmac_low_i2c.h new file mode 100644 index 000000000000..809a5963d5e7 --- /dev/null +++ b/include/asm-powerpc/pmac_low_i2c.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * include/asm-ppc/pmac_low_i2c.h | ||
3 | * | ||
4 | * Copyright (C) 2003 Ben. Herrenschmidt (benh@kernel.crashing.org) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | */ | ||
12 | #ifndef __PMAC_LOW_I2C_H__ | ||
13 | #define __PMAC_LOW_I2C_H__ | ||
14 | |||
15 | /* i2c mode (based on the platform functions format) */ | ||
16 | enum { | ||
17 | pmac_low_i2c_mode_dumb = 1, | ||
18 | pmac_low_i2c_mode_std = 2, | ||
19 | pmac_low_i2c_mode_stdsub = 3, | ||
20 | pmac_low_i2c_mode_combined = 4, | ||
21 | }; | ||
22 | |||
23 | /* RW bit in address */ | ||
24 | enum { | ||
25 | pmac_low_i2c_read = 0x01, | ||
26 | pmac_low_i2c_write = 0x00 | ||
27 | }; | ||
28 | |||
29 | /* Init, called early during boot */ | ||
30 | extern void pmac_init_low_i2c(void); | ||
31 | |||
32 | /* Locking functions exposed to i2c-keywest */ | ||
33 | int pmac_low_i2c_lock(struct device_node *np); | ||
34 | int pmac_low_i2c_unlock(struct device_node *np); | ||
35 | |||
36 | /* Access functions for platform code */ | ||
37 | int pmac_low_i2c_open(struct device_node *np, int channel); | ||
38 | int pmac_low_i2c_close(struct device_node *np); | ||
39 | int pmac_low_i2c_setmode(struct device_node *np, int mode); | ||
40 | int pmac_low_i2c_xfer(struct device_node *np, u8 addrdir, u8 subaddr, u8 *data, int len); | ||
41 | |||
42 | |||
43 | #endif /* __PMAC_LOW_I2C_H__ */ | ||
diff --git a/include/asm-powerpc/pmc.h b/include/asm-powerpc/pmc.h new file mode 100644 index 000000000000..2f3c3fc2b796 --- /dev/null +++ b/include/asm-powerpc/pmc.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * pmc.h | ||
3 | * Copyright (C) 2004 David Gibson, IBM Corporation | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | #ifndef _POWERPC_PMC_H | ||
20 | #define _POWERPC_PMC_H | ||
21 | |||
22 | #include <asm/ptrace.h> | ||
23 | |||
24 | typedef void (*perf_irq_t)(struct pt_regs *); | ||
25 | |||
26 | int reserve_pmc_hardware(perf_irq_t new_perf_irq); | ||
27 | void release_pmc_hardware(void); | ||
28 | |||
29 | #ifdef CONFIG_PPC64 | ||
30 | void power4_enable_pmcs(void); | ||
31 | #endif | ||
32 | |||
33 | #ifdef CONFIG_FSL_BOOKE | ||
34 | void init_pmc_stop(int ctr); | ||
35 | void set_pmc_event(int ctr, int event); | ||
36 | void set_pmc_user_kernel(int ctr, int user, int kernel); | ||
37 | void set_pmc_marked(int ctr, int mark0, int mark1); | ||
38 | void pmc_start_ctr(int ctr, int enable); | ||
39 | void pmc_start_ctrs(int enable); | ||
40 | void pmc_stop_ctrs(void); | ||
41 | void dump_pmcs(void); | ||
42 | |||
43 | extern struct op_powerpc_model op_model_fsl_booke; | ||
44 | #endif | ||
45 | |||
46 | #endif /* _POWERPC_PMC_H */ | ||
diff --git a/include/asm-powerpc/posix_types.h b/include/asm-powerpc/posix_types.h new file mode 100644 index 000000000000..c6391077224f --- /dev/null +++ b/include/asm-powerpc/posix_types.h | |||
@@ -0,0 +1,129 @@ | |||
1 | #ifndef _ASM_POWERPC_POSIX_TYPES_H | ||
2 | #define _ASM_POWERPC_POSIX_TYPES_H | ||
3 | |||
4 | /* | ||
5 | * This file is generally used by user-level software, so you need to | ||
6 | * be a little careful about namespace pollution etc. Also, we cannot | ||
7 | * assume GCC is being used. | ||
8 | */ | ||
9 | |||
10 | typedef unsigned long __kernel_ino_t; | ||
11 | typedef unsigned int __kernel_mode_t; | ||
12 | typedef long __kernel_off_t; | ||
13 | typedef int __kernel_pid_t; | ||
14 | typedef unsigned int __kernel_uid_t; | ||
15 | typedef unsigned int __kernel_gid_t; | ||
16 | typedef long __kernel_ptrdiff_t; | ||
17 | typedef long __kernel_time_t; | ||
18 | typedef long __kernel_clock_t; | ||
19 | typedef int __kernel_timer_t; | ||
20 | typedef int __kernel_clockid_t; | ||
21 | typedef long __kernel_suseconds_t; | ||
22 | typedef int __kernel_daddr_t; | ||
23 | typedef char * __kernel_caddr_t; | ||
24 | typedef unsigned short __kernel_uid16_t; | ||
25 | typedef unsigned short __kernel_gid16_t; | ||
26 | typedef unsigned int __kernel_uid32_t; | ||
27 | typedef unsigned int __kernel_gid32_t; | ||
28 | typedef unsigned int __kernel_old_uid_t; | ||
29 | typedef unsigned int __kernel_old_gid_t; | ||
30 | |||
31 | #ifdef __powerpc64__ | ||
32 | typedef unsigned long __kernel_nlink_t; | ||
33 | typedef int __kernel_ipc_pid_t; | ||
34 | typedef unsigned long __kernel_size_t; | ||
35 | typedef long __kernel_ssize_t; | ||
36 | typedef unsigned long __kernel_old_dev_t; | ||
37 | #else | ||
38 | typedef unsigned short __kernel_nlink_t; | ||
39 | typedef short __kernel_ipc_pid_t; | ||
40 | typedef unsigned int __kernel_size_t; | ||
41 | typedef int __kernel_ssize_t; | ||
42 | typedef unsigned int __kernel_old_dev_t; | ||
43 | #endif | ||
44 | |||
45 | #ifdef __powerpc64__ | ||
46 | typedef long long __kernel_loff_t; | ||
47 | #else | ||
48 | #ifdef __GNUC__ | ||
49 | typedef long long __kernel_loff_t; | ||
50 | #endif | ||
51 | #endif | ||
52 | |||
53 | typedef struct { | ||
54 | int val[2]; | ||
55 | } __kernel_fsid_t; | ||
56 | |||
57 | #ifndef __GNUC__ | ||
58 | |||
59 | #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) | ||
60 | #define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) | ||
61 | #define __FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0) | ||
62 | #define __FD_ZERO(set) \ | ||
63 | ((void) memset ((__ptr_t) (set), 0, sizeof (__kernel_fd_set))) | ||
64 | |||
65 | #else /* __GNUC__ */ | ||
66 | |||
67 | #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) \ | ||
68 | || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0) | ||
69 | /* With GNU C, use inline functions instead so args are evaluated only once: */ | ||
70 | |||
71 | #undef __FD_SET | ||
72 | static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) | ||
73 | { | ||
74 | unsigned long _tmp = fd / __NFDBITS; | ||
75 | unsigned long _rem = fd % __NFDBITS; | ||
76 | fdsetp->fds_bits[_tmp] |= (1UL<<_rem); | ||
77 | } | ||
78 | |||
79 | #undef __FD_CLR | ||
80 | static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) | ||
81 | { | ||
82 | unsigned long _tmp = fd / __NFDBITS; | ||
83 | unsigned long _rem = fd % __NFDBITS; | ||
84 | fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem); | ||
85 | } | ||
86 | |||
87 | #undef __FD_ISSET | ||
88 | static __inline__ int __FD_ISSET(unsigned long fd, __kernel_fd_set *p) | ||
89 | { | ||
90 | unsigned long _tmp = fd / __NFDBITS; | ||
91 | unsigned long _rem = fd % __NFDBITS; | ||
92 | return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0; | ||
93 | } | ||
94 | |||
95 | /* | ||
96 | * This will unroll the loop for the normal constant case (8 ints, | ||
97 | * for a 256-bit fd_set) | ||
98 | */ | ||
99 | #undef __FD_ZERO | ||
100 | static __inline__ void __FD_ZERO(__kernel_fd_set *p) | ||
101 | { | ||
102 | unsigned long *tmp = (unsigned long *)p->fds_bits; | ||
103 | int i; | ||
104 | |||
105 | if (__builtin_constant_p(__FDSET_LONGS)) { | ||
106 | switch (__FDSET_LONGS) { | ||
107 | case 16: | ||
108 | tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0; | ||
109 | tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0; | ||
110 | |||
111 | case 8: | ||
112 | tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; | ||
113 | |||
114 | case 4: | ||
115 | tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; | ||
116 | return; | ||
117 | } | ||
118 | } | ||
119 | i = __FDSET_LONGS; | ||
120 | while (i) { | ||
121 | i--; | ||
122 | *tmp = 0; | ||
123 | tmp++; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | #endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ | ||
128 | #endif /* __GNUC__ */ | ||
129 | #endif /* _ASM_POWERPC_POSIX_TYPES_H */ | ||
diff --git a/include/asm-powerpc/ppc-pci.h b/include/asm-powerpc/ppc-pci.h new file mode 100644 index 000000000000..a88728fba8f6 --- /dev/null +++ b/include/asm-powerpc/ppc-pci.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | * c 2001 PPC 64 Team, IBM Corp | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | */ | ||
9 | #ifndef _ASM_POWERPC_PPC_PCI_H | ||
10 | #define _ASM_POWERPC_PPC_PCI_H | ||
11 | |||
12 | #include <linux/pci.h> | ||
13 | #include <asm/pci-bridge.h> | ||
14 | |||
15 | extern unsigned long isa_io_base; | ||
16 | |||
17 | extern void pci_setup_pci_controller(struct pci_controller *hose); | ||
18 | extern void pci_setup_phb_io(struct pci_controller *hose, int primary); | ||
19 | extern void pci_setup_phb_io_dynamic(struct pci_controller *hose, int primary); | ||
20 | |||
21 | |||
22 | extern struct list_head hose_list; | ||
23 | extern int global_phb_number; | ||
24 | |||
25 | extern unsigned long find_and_init_phbs(void); | ||
26 | |||
27 | extern struct pci_dev *ppc64_isabridge_dev; /* may be NULL if no ISA bus */ | ||
28 | |||
29 | /* PCI device_node operations */ | ||
30 | struct device_node; | ||
31 | typedef void *(*traverse_func)(struct device_node *me, void *data); | ||
32 | void *traverse_pci_devices(struct device_node *start, traverse_func pre, | ||
33 | void *data); | ||
34 | |||
35 | void pci_devs_phb_init(void); | ||
36 | void pci_devs_phb_init_dynamic(struct pci_controller *phb); | ||
37 | |||
38 | /* PCI address cache management routines */ | ||
39 | void pci_addr_cache_insert_device(struct pci_dev *dev); | ||
40 | void pci_addr_cache_remove_device(struct pci_dev *dev); | ||
41 | |||
42 | /* From rtas_pci.h */ | ||
43 | void init_pci_config_tokens (void); | ||
44 | unsigned long get_phb_buid (struct device_node *); | ||
45 | |||
46 | /* From pSeries_pci.h */ | ||
47 | extern void pSeries_final_fixup(void); | ||
48 | extern void pSeries_irq_bus_setup(struct pci_bus *bus); | ||
49 | |||
50 | extern unsigned long pci_probe_only; | ||
51 | extern unsigned long pci_assign_all_buses; | ||
52 | extern int pci_read_irq_line(struct pci_dev *pci_dev); | ||
53 | |||
54 | #endif /* _ASM_POWERPC_PPC_PCI_H */ | ||
diff --git a/include/asm-powerpc/ppc_asm.h b/include/asm-powerpc/ppc_asm.h new file mode 100644 index 000000000000..c534ca41224b --- /dev/null +++ b/include/asm-powerpc/ppc_asm.h | |||
@@ -0,0 +1,518 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1995-1999 Gary Thomas, Paul Mackerras, Cort Dougan. | ||
3 | */ | ||
4 | #ifndef _ASM_POWERPC_PPC_ASM_H | ||
5 | #define _ASM_POWERPC_PPC_ASM_H | ||
6 | |||
7 | #include <linux/stringify.h> | ||
8 | #include <linux/config.h> | ||
9 | |||
10 | #ifdef __ASSEMBLY__ | ||
11 | |||
12 | /* | ||
13 | * Macros for storing registers into and loading registers from | ||
14 | * exception frames. | ||
15 | */ | ||
16 | #ifdef __powerpc64__ | ||
17 | #define SAVE_GPR(n, base) std n,GPR0+8*(n)(base) | ||
18 | #define REST_GPR(n, base) ld n,GPR0+8*(n)(base) | ||
19 | #define SAVE_NVGPRS(base) SAVE_8GPRS(14, base); SAVE_10GPRS(22, base) | ||
20 | #define REST_NVGPRS(base) REST_8GPRS(14, base); REST_10GPRS(22, base) | ||
21 | #else | ||
22 | #define SAVE_GPR(n, base) stw n,GPR0+4*(n)(base) | ||
23 | #define REST_GPR(n, base) lwz n,GPR0+4*(n)(base) | ||
24 | #define SAVE_NVGPRS(base) SAVE_GPR(13, base); SAVE_8GPRS(14, base); \ | ||
25 | SAVE_10GPRS(22, base) | ||
26 | #define REST_NVGPRS(base) REST_GPR(13, base); REST_8GPRS(14, base); \ | ||
27 | REST_10GPRS(22, base) | ||
28 | #endif | ||
29 | |||
30 | |||
31 | #define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base) | ||
32 | #define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base) | ||
33 | #define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base) | ||
34 | #define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base) | ||
35 | #define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base) | ||
36 | #define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base) | ||
37 | #define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base) | ||
38 | #define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base) | ||
39 | |||
40 | #define SAVE_FPR(n, base) stfd n,THREAD_FPR0+8*(n)(base) | ||
41 | #define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base) | ||
42 | #define SAVE_4FPRS(n, base) SAVE_2FPRS(n, base); SAVE_2FPRS(n+2, base) | ||
43 | #define SAVE_8FPRS(n, base) SAVE_4FPRS(n, base); SAVE_4FPRS(n+4, base) | ||
44 | #define SAVE_16FPRS(n, base) SAVE_8FPRS(n, base); SAVE_8FPRS(n+8, base) | ||
45 | #define SAVE_32FPRS(n, base) SAVE_16FPRS(n, base); SAVE_16FPRS(n+16, base) | ||
46 | #define REST_FPR(n, base) lfd n,THREAD_FPR0+8*(n)(base) | ||
47 | #define REST_2FPRS(n, base) REST_FPR(n, base); REST_FPR(n+1, base) | ||
48 | #define REST_4FPRS(n, base) REST_2FPRS(n, base); REST_2FPRS(n+2, base) | ||
49 | #define REST_8FPRS(n, base) REST_4FPRS(n, base); REST_4FPRS(n+4, base) | ||
50 | #define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base) | ||
51 | #define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base) | ||
52 | |||
53 | #define SAVE_VR(n,b,base) li b,THREAD_VR0+(16*(n)); stvx n,b,base | ||
54 | #define SAVE_2VRS(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base) | ||
55 | #define SAVE_4VRS(n,b,base) SAVE_2VRS(n,b,base); SAVE_2VRS(n+2,b,base) | ||
56 | #define SAVE_8VRS(n,b,base) SAVE_4VRS(n,b,base); SAVE_4VRS(n+4,b,base) | ||
57 | #define SAVE_16VRS(n,b,base) SAVE_8VRS(n,b,base); SAVE_8VRS(n+8,b,base) | ||
58 | #define SAVE_32VRS(n,b,base) SAVE_16VRS(n,b,base); SAVE_16VRS(n+16,b,base) | ||
59 | #define REST_VR(n,b,base) li b,THREAD_VR0+(16*(n)); lvx n,b,base | ||
60 | #define REST_2VRS(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base) | ||
61 | #define REST_4VRS(n,b,base) REST_2VRS(n,b,base); REST_2VRS(n+2,b,base) | ||
62 | #define REST_8VRS(n,b,base) REST_4VRS(n,b,base); REST_4VRS(n+4,b,base) | ||
63 | #define REST_16VRS(n,b,base) REST_8VRS(n,b,base); REST_8VRS(n+8,b,base) | ||
64 | #define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base) | ||
65 | |||
66 | #define SAVE_EVR(n,s,base) evmergehi s,s,n; stw s,THREAD_EVR0+4*(n)(base) | ||
67 | #define SAVE_2EVRS(n,s,base) SAVE_EVR(n,s,base); SAVE_EVR(n+1,s,base) | ||
68 | #define SAVE_4EVRS(n,s,base) SAVE_2EVRS(n,s,base); SAVE_2EVRS(n+2,s,base) | ||
69 | #define SAVE_8EVRS(n,s,base) SAVE_4EVRS(n,s,base); SAVE_4EVRS(n+4,s,base) | ||
70 | #define SAVE_16EVRS(n,s,base) SAVE_8EVRS(n,s,base); SAVE_8EVRS(n+8,s,base) | ||
71 | #define SAVE_32EVRS(n,s,base) SAVE_16EVRS(n,s,base); SAVE_16EVRS(n+16,s,base) | ||
72 | #define REST_EVR(n,s,base) lwz s,THREAD_EVR0+4*(n)(base); evmergelo n,s,n | ||
73 | #define REST_2EVRS(n,s,base) REST_EVR(n,s,base); REST_EVR(n+1,s,base) | ||
74 | #define REST_4EVRS(n,s,base) REST_2EVRS(n,s,base); REST_2EVRS(n+2,s,base) | ||
75 | #define REST_8EVRS(n,s,base) REST_4EVRS(n,s,base); REST_4EVRS(n+4,s,base) | ||
76 | #define REST_16EVRS(n,s,base) REST_8EVRS(n,s,base); REST_8EVRS(n+8,s,base) | ||
77 | #define REST_32EVRS(n,s,base) REST_16EVRS(n,s,base); REST_16EVRS(n+16,s,base) | ||
78 | |||
79 | /* Macros to adjust thread priority for hardware multithreading */ | ||
80 | #define HMT_VERY_LOW or 31,31,31 # very low priority | ||
81 | #define HMT_LOW or 1,1,1 | ||
82 | #define HMT_MEDIUM_LOW or 6,6,6 # medium low priority | ||
83 | #define HMT_MEDIUM or 2,2,2 | ||
84 | #define HMT_MEDIUM_HIGH or 5,5,5 # medium high priority | ||
85 | #define HMT_HIGH or 3,3,3 | ||
86 | |||
87 | /* handle instructions that older assemblers may not know */ | ||
88 | #define RFCI .long 0x4c000066 /* rfci instruction */ | ||
89 | #define RFDI .long 0x4c00004e /* rfdi instruction */ | ||
90 | #define RFMCI .long 0x4c00004c /* rfmci instruction */ | ||
91 | |||
92 | #ifdef CONFIG_PPC64 | ||
93 | |||
94 | #define XGLUE(a,b) a##b | ||
95 | #define GLUE(a,b) XGLUE(a,b) | ||
96 | |||
97 | #define _GLOBAL(name) \ | ||
98 | .section ".text"; \ | ||
99 | .align 2 ; \ | ||
100 | .globl name; \ | ||
101 | .globl GLUE(.,name); \ | ||
102 | .section ".opd","aw"; \ | ||
103 | name: \ | ||
104 | .quad GLUE(.,name); \ | ||
105 | .quad .TOC.@tocbase; \ | ||
106 | .quad 0; \ | ||
107 | .previous; \ | ||
108 | .type GLUE(.,name),@function; \ | ||
109 | GLUE(.,name): | ||
110 | |||
111 | #define _KPROBE(name) \ | ||
112 | .section ".kprobes.text","a"; \ | ||
113 | .align 2 ; \ | ||
114 | .globl name; \ | ||
115 | .globl GLUE(.,name); \ | ||
116 | .section ".opd","aw"; \ | ||
117 | name: \ | ||
118 | .quad GLUE(.,name); \ | ||
119 | .quad .TOC.@tocbase; \ | ||
120 | .quad 0; \ | ||
121 | .previous; \ | ||
122 | .type GLUE(.,name),@function; \ | ||
123 | GLUE(.,name): | ||
124 | |||
125 | #define _STATIC(name) \ | ||
126 | .section ".text"; \ | ||
127 | .align 2 ; \ | ||
128 | .section ".opd","aw"; \ | ||
129 | name: \ | ||
130 | .quad GLUE(.,name); \ | ||
131 | .quad .TOC.@tocbase; \ | ||
132 | .quad 0; \ | ||
133 | .previous; \ | ||
134 | .type GLUE(.,name),@function; \ | ||
135 | GLUE(.,name): | ||
136 | |||
137 | #else /* 32-bit */ | ||
138 | |||
139 | #define _GLOBAL(n) \ | ||
140 | .text; \ | ||
141 | .stabs __stringify(n:F-1),N_FUN,0,0,n;\ | ||
142 | .globl n; \ | ||
143 | n: | ||
144 | |||
145 | #define _KPROBE(n) \ | ||
146 | .section ".kprobes.text","a"; \ | ||
147 | .globl n; \ | ||
148 | n: | ||
149 | |||
150 | #endif | ||
151 | |||
152 | /* | ||
153 | * LOADADDR( rn, name ) | ||
154 | * loads the address of 'name' into 'rn' | ||
155 | * | ||
156 | * LOADBASE( rn, name ) | ||
157 | * loads the address (possibly without the low 16 bits) of 'name' into 'rn' | ||
158 | * suitable for base+disp addressing | ||
159 | */ | ||
160 | #ifdef __powerpc64__ | ||
161 | #define LOADADDR(rn,name) \ | ||
162 | lis rn,name##@highest; \ | ||
163 | ori rn,rn,name##@higher; \ | ||
164 | rldicr rn,rn,32,31; \ | ||
165 | oris rn,rn,name##@h; \ | ||
166 | ori rn,rn,name##@l | ||
167 | |||
168 | #define LOADBASE(rn,name) \ | ||
169 | ld rn,name@got(r2) | ||
170 | |||
171 | #define OFF(name) 0 | ||
172 | |||
173 | #define SET_REG_TO_CONST(reg, value) \ | ||
174 | lis reg,(((value)>>48)&0xFFFF); \ | ||
175 | ori reg,reg,(((value)>>32)&0xFFFF); \ | ||
176 | rldicr reg,reg,32,31; \ | ||
177 | oris reg,reg,(((value)>>16)&0xFFFF); \ | ||
178 | ori reg,reg,((value)&0xFFFF); | ||
179 | |||
180 | #define SET_REG_TO_LABEL(reg, label) \ | ||
181 | lis reg,(label)@highest; \ | ||
182 | ori reg,reg,(label)@higher; \ | ||
183 | rldicr reg,reg,32,31; \ | ||
184 | oris reg,reg,(label)@h; \ | ||
185 | ori reg,reg,(label)@l; | ||
186 | |||
187 | /* operations for longs and pointers */ | ||
188 | #define LDL ld | ||
189 | #define STL std | ||
190 | #define CMPI cmpdi | ||
191 | #define SZL 8 | ||
192 | |||
193 | /* offsets for stack frame layout */ | ||
194 | #define LRSAVE 16 | ||
195 | |||
196 | #else /* 32-bit */ | ||
197 | #define LOADADDR(rn,name) \ | ||
198 | lis rn,name@ha; \ | ||
199 | addi rn,rn,name@l | ||
200 | |||
201 | #define LOADBASE(rn,name) \ | ||
202 | lis rn,name@ha | ||
203 | |||
204 | #define OFF(name) name@l | ||
205 | |||
206 | /* operations for longs and pointers */ | ||
207 | #define LDL lwz | ||
208 | #define STL stw | ||
209 | #define CMPI cmpwi | ||
210 | #define SZL 4 | ||
211 | |||
212 | /* offsets for stack frame layout */ | ||
213 | #define LRSAVE 4 | ||
214 | |||
215 | #endif | ||
216 | |||
217 | /* various errata or part fixups */ | ||
218 | #ifdef CONFIG_PPC601_SYNC_FIX | ||
219 | #define SYNC \ | ||
220 | BEGIN_FTR_SECTION \ | ||
221 | sync; \ | ||
222 | isync; \ | ||
223 | END_FTR_SECTION_IFSET(CPU_FTR_601) | ||
224 | #define SYNC_601 \ | ||
225 | BEGIN_FTR_SECTION \ | ||
226 | sync; \ | ||
227 | END_FTR_SECTION_IFSET(CPU_FTR_601) | ||
228 | #define ISYNC_601 \ | ||
229 | BEGIN_FTR_SECTION \ | ||
230 | isync; \ | ||
231 | END_FTR_SECTION_IFSET(CPU_FTR_601) | ||
232 | #else | ||
233 | #define SYNC | ||
234 | #define SYNC_601 | ||
235 | #define ISYNC_601 | ||
236 | #endif | ||
237 | |||
238 | |||
239 | #ifndef CONFIG_SMP | ||
240 | #define TLBSYNC | ||
241 | #else /* CONFIG_SMP */ | ||
242 | /* tlbsync is not implemented on 601 */ | ||
243 | #define TLBSYNC \ | ||
244 | BEGIN_FTR_SECTION \ | ||
245 | tlbsync; \ | ||
246 | sync; \ | ||
247 | END_FTR_SECTION_IFCLR(CPU_FTR_601) | ||
248 | #endif | ||
249 | |||
250 | |||
251 | /* | ||
252 | * This instruction is not implemented on the PPC 603 or 601; however, on | ||
253 | * the 403GCX and 405GP tlbia IS defined and tlbie is not. | ||
254 | * All of these instructions exist in the 8xx, they have magical powers, | ||
255 | * and they must be used. | ||
256 | */ | ||
257 | |||
258 | #if !defined(CONFIG_4xx) && !defined(CONFIG_8xx) | ||
259 | #define tlbia \ | ||
260 | li r4,1024; \ | ||
261 | mtctr r4; \ | ||
262 | lis r4,KERNELBASE@h; \ | ||
263 | 0: tlbie r4; \ | ||
264 | addi r4,r4,0x1000; \ | ||
265 | bdnz 0b | ||
266 | #endif | ||
267 | |||
268 | |||
269 | #ifdef CONFIG_IBM405_ERR77 | ||
270 | #define PPC405_ERR77(ra,rb) dcbt ra, rb; | ||
271 | #define PPC405_ERR77_SYNC sync; | ||
272 | #else | ||
273 | #define PPC405_ERR77(ra,rb) | ||
274 | #define PPC405_ERR77_SYNC | ||
275 | #endif | ||
276 | |||
277 | |||
278 | #ifdef CONFIG_IBM440EP_ERR42 | ||
279 | #define PPC440EP_ERR42 isync | ||
280 | #else | ||
281 | #define PPC440EP_ERR42 | ||
282 | #endif | ||
283 | |||
284 | |||
285 | #if defined(CONFIG_BOOKE) | ||
286 | #define toreal(rd) | ||
287 | #define fromreal(rd) | ||
288 | |||
289 | #define tophys(rd,rs) \ | ||
290 | addis rd,rs,0 | ||
291 | |||
292 | #define tovirt(rd,rs) \ | ||
293 | addis rd,rs,0 | ||
294 | |||
295 | #elif defined(CONFIG_PPC64) | ||
296 | #define toreal(rd) /* we can access c000... in real mode */ | ||
297 | #define fromreal(rd) | ||
298 | |||
299 | #define tophys(rd,rs) \ | ||
300 | clrldi rd,rs,2 | ||
301 | |||
302 | #define tovirt(rd,rs) \ | ||
303 | rotldi rd,rs,16; \ | ||
304 | ori rd,rd,((KERNELBASE>>48)&0xFFFF);\ | ||
305 | rotldi rd,rd,48 | ||
306 | #else | ||
307 | /* | ||
308 | * On APUS (Amiga PowerPC cpu upgrade board), we don't know the | ||
309 | * physical base address of RAM at compile time. | ||
310 | */ | ||
311 | #define toreal(rd) tophys(rd,rd) | ||
312 | #define fromreal(rd) tovirt(rd,rd) | ||
313 | |||
314 | #define tophys(rd,rs) \ | ||
315 | 0: addis rd,rs,-KERNELBASE@h; \ | ||
316 | .section ".vtop_fixup","aw"; \ | ||
317 | .align 1; \ | ||
318 | .long 0b; \ | ||
319 | .previous | ||
320 | |||
321 | #define tovirt(rd,rs) \ | ||
322 | 0: addis rd,rs,KERNELBASE@h; \ | ||
323 | .section ".ptov_fixup","aw"; \ | ||
324 | .align 1; \ | ||
325 | .long 0b; \ | ||
326 | .previous | ||
327 | #endif | ||
328 | |||
329 | #ifdef CONFIG_PPC64 | ||
330 | #define RFI rfid | ||
331 | #define MTMSRD(r) mtmsrd r | ||
332 | |||
333 | #else | ||
334 | #define FIX_SRR1(ra, rb) | ||
335 | #ifndef CONFIG_40x | ||
336 | #define RFI rfi | ||
337 | #else | ||
338 | #define RFI rfi; b . /* Prevent prefetch past rfi */ | ||
339 | #endif | ||
340 | #define MTMSRD(r) mtmsr r | ||
341 | #define CLR_TOP32(r) | ||
342 | #endif | ||
343 | |||
344 | /* The boring bits... */ | ||
345 | |||
346 | /* Condition Register Bit Fields */ | ||
347 | |||
348 | #define cr0 0 | ||
349 | #define cr1 1 | ||
350 | #define cr2 2 | ||
351 | #define cr3 3 | ||
352 | #define cr4 4 | ||
353 | #define cr5 5 | ||
354 | #define cr6 6 | ||
355 | #define cr7 7 | ||
356 | |||
357 | |||
358 | /* General Purpose Registers (GPRs) */ | ||
359 | |||
360 | #define r0 0 | ||
361 | #define r1 1 | ||
362 | #define r2 2 | ||
363 | #define r3 3 | ||
364 | #define r4 4 | ||
365 | #define r5 5 | ||
366 | #define r6 6 | ||
367 | #define r7 7 | ||
368 | #define r8 8 | ||
369 | #define r9 9 | ||
370 | #define r10 10 | ||
371 | #define r11 11 | ||
372 | #define r12 12 | ||
373 | #define r13 13 | ||
374 | #define r14 14 | ||
375 | #define r15 15 | ||
376 | #define r16 16 | ||
377 | #define r17 17 | ||
378 | #define r18 18 | ||
379 | #define r19 19 | ||
380 | #define r20 20 | ||
381 | #define r21 21 | ||
382 | #define r22 22 | ||
383 | #define r23 23 | ||
384 | #define r24 24 | ||
385 | #define r25 25 | ||
386 | #define r26 26 | ||
387 | #define r27 27 | ||
388 | #define r28 28 | ||
389 | #define r29 29 | ||
390 | #define r30 30 | ||
391 | #define r31 31 | ||
392 | |||
393 | |||
394 | /* Floating Point Registers (FPRs) */ | ||
395 | |||
396 | #define fr0 0 | ||
397 | #define fr1 1 | ||
398 | #define fr2 2 | ||
399 | #define fr3 3 | ||
400 | #define fr4 4 | ||
401 | #define fr5 5 | ||
402 | #define fr6 6 | ||
403 | #define fr7 7 | ||
404 | #define fr8 8 | ||
405 | #define fr9 9 | ||
406 | #define fr10 10 | ||
407 | #define fr11 11 | ||
408 | #define fr12 12 | ||
409 | #define fr13 13 | ||
410 | #define fr14 14 | ||
411 | #define fr15 15 | ||
412 | #define fr16 16 | ||
413 | #define fr17 17 | ||
414 | #define fr18 18 | ||
415 | #define fr19 19 | ||
416 | #define fr20 20 | ||
417 | #define fr21 21 | ||
418 | #define fr22 22 | ||
419 | #define fr23 23 | ||
420 | #define fr24 24 | ||
421 | #define fr25 25 | ||
422 | #define fr26 26 | ||
423 | #define fr27 27 | ||
424 | #define fr28 28 | ||
425 | #define fr29 29 | ||
426 | #define fr30 30 | ||
427 | #define fr31 31 | ||
428 | |||
429 | /* AltiVec Registers (VPRs) */ | ||
430 | |||
431 | #define vr0 0 | ||
432 | #define vr1 1 | ||
433 | #define vr2 2 | ||
434 | #define vr3 3 | ||
435 | #define vr4 4 | ||
436 | #define vr5 5 | ||
437 | #define vr6 6 | ||
438 | #define vr7 7 | ||
439 | #define vr8 8 | ||
440 | #define vr9 9 | ||
441 | #define vr10 10 | ||
442 | #define vr11 11 | ||
443 | #define vr12 12 | ||
444 | #define vr13 13 | ||
445 | #define vr14 14 | ||
446 | #define vr15 15 | ||
447 | #define vr16 16 | ||
448 | #define vr17 17 | ||
449 | #define vr18 18 | ||
450 | #define vr19 19 | ||
451 | #define vr20 20 | ||
452 | #define vr21 21 | ||
453 | #define vr22 22 | ||
454 | #define vr23 23 | ||
455 | #define vr24 24 | ||
456 | #define vr25 25 | ||
457 | #define vr26 26 | ||
458 | #define vr27 27 | ||
459 | #define vr28 28 | ||
460 | #define vr29 29 | ||
461 | #define vr30 30 | ||
462 | #define vr31 31 | ||
463 | |||
464 | /* SPE Registers (EVPRs) */ | ||
465 | |||
466 | #define evr0 0 | ||
467 | #define evr1 1 | ||
468 | #define evr2 2 | ||
469 | #define evr3 3 | ||
470 | #define evr4 4 | ||
471 | #define evr5 5 | ||
472 | #define evr6 6 | ||
473 | #define evr7 7 | ||
474 | #define evr8 8 | ||
475 | #define evr9 9 | ||
476 | #define evr10 10 | ||
477 | #define evr11 11 | ||
478 | #define evr12 12 | ||
479 | #define evr13 13 | ||
480 | #define evr14 14 | ||
481 | #define evr15 15 | ||
482 | #define evr16 16 | ||
483 | #define evr17 17 | ||
484 | #define evr18 18 | ||
485 | #define evr19 19 | ||
486 | #define evr20 20 | ||
487 | #define evr21 21 | ||
488 | #define evr22 22 | ||
489 | #define evr23 23 | ||
490 | #define evr24 24 | ||
491 | #define evr25 25 | ||
492 | #define evr26 26 | ||
493 | #define evr27 27 | ||
494 | #define evr28 28 | ||
495 | #define evr29 29 | ||
496 | #define evr30 30 | ||
497 | #define evr31 31 | ||
498 | |||
499 | /* some stab codes */ | ||
500 | #define N_FUN 36 | ||
501 | #define N_RSYM 64 | ||
502 | #define N_SLINE 68 | ||
503 | #define N_SO 100 | ||
504 | |||
505 | #define ASM_CONST(x) x | ||
506 | #else | ||
507 | #define __ASM_CONST(x) x##UL | ||
508 | #define ASM_CONST(x) __ASM_CONST(x) | ||
509 | |||
510 | #ifdef CONFIG_PPC64 | ||
511 | #define DATAL ".llong" | ||
512 | #else | ||
513 | #define DATAL ".long" | ||
514 | #endif | ||
515 | |||
516 | #endif /* __ASSEMBLY__ */ | ||
517 | |||
518 | #endif /* _ASM_POWERPC_PPC_ASM_H */ | ||
diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h new file mode 100644 index 000000000000..1dc4bf7b52b3 --- /dev/null +++ b/include/asm-powerpc/processor.h | |||
@@ -0,0 +1,281 @@ | |||
1 | #ifndef _ASM_POWERPC_PROCESSOR_H | ||
2 | #define _ASM_POWERPC_PROCESSOR_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (C) 2001 PPC 64 Team, IBM Corp | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/config.h> | ||
14 | #include <asm/reg.h> | ||
15 | |||
16 | #ifndef __ASSEMBLY__ | ||
17 | #include <linux/compiler.h> | ||
18 | #include <asm/ptrace.h> | ||
19 | #include <asm/types.h> | ||
20 | #ifdef CONFIG_PPC64 | ||
21 | #include <asm/systemcfg.h> | ||
22 | #endif | ||
23 | |||
24 | #ifdef CONFIG_PPC32 | ||
25 | /* 32-bit platform types */ | ||
26 | /* We only need to define a new _MACH_xxx for machines which are part of | ||
27 | * a configuration which supports more than one type of different machine. | ||
28 | * This is currently limited to CONFIG_PPC_MULTIPLATFORM and CHRP/PReP/PMac. | ||
29 | * -- Tom | ||
30 | */ | ||
31 | #define _MACH_prep 0x00000001 | ||
32 | #define _MACH_Pmac 0x00000002 /* pmac or pmac clone (non-chrp) */ | ||
33 | #define _MACH_chrp 0x00000004 /* chrp machine */ | ||
34 | |||
35 | /* see residual.h for these */ | ||
36 | #define _PREP_Motorola 0x01 /* motorola prep */ | ||
37 | #define _PREP_Firm 0x02 /* firmworks prep */ | ||
38 | #define _PREP_IBM 0x00 /* ibm prep */ | ||
39 | #define _PREP_Bull 0x03 /* bull prep */ | ||
40 | |||
41 | /* these are arbitrary */ | ||
42 | #define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */ | ||
43 | #define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */ | ||
44 | #define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */ | ||
45 | |||
46 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
47 | extern int _machine; | ||
48 | |||
49 | /* what kind of prep workstation we are */ | ||
50 | extern int _prep_type; | ||
51 | extern int _chrp_type; | ||
52 | |||
53 | /* | ||
54 | * This is used to identify the board type from a given PReP board | ||
55 | * vendor. Board revision is also made available. | ||
56 | */ | ||
57 | extern unsigned char ucSystemType; | ||
58 | extern unsigned char ucBoardRev; | ||
59 | extern unsigned char ucBoardRevMaj, ucBoardRevMin; | ||
60 | #else | ||
61 | #define _machine 0 | ||
62 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | ||
63 | #endif /* CONFIG_PPC32 */ | ||
64 | |||
65 | #ifdef CONFIG_PPC64 | ||
66 | /* Platforms supported by PPC64 */ | ||
67 | #define PLATFORM_PSERIES 0x0100 | ||
68 | #define PLATFORM_PSERIES_LPAR 0x0101 | ||
69 | #define PLATFORM_ISERIES_LPAR 0x0201 | ||
70 | #define PLATFORM_LPAR 0x0001 | ||
71 | #define PLATFORM_POWERMAC 0x0400 | ||
72 | #define PLATFORM_MAPLE 0x0500 | ||
73 | #define PLATFORM_CELL 0x1000 | ||
74 | |||
75 | /* Compatibility with drivers coming from PPC32 world */ | ||
76 | #define _machine (systemcfg->platform) | ||
77 | #define _MACH_Pmac PLATFORM_POWERMAC | ||
78 | #endif | ||
79 | |||
80 | /* | ||
81 | * Default implementation of macro that returns current | ||
82 | * instruction pointer ("program counter"). | ||
83 | */ | ||
84 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
85 | |||
86 | /* Macros for adjusting thread priority (hardware multi-threading) */ | ||
87 | #define HMT_very_low() asm volatile("or 31,31,31 # very low priority") | ||
88 | #define HMT_low() asm volatile("or 1,1,1 # low priority") | ||
89 | #define HMT_medium_low() asm volatile("or 6,6,6 # medium low priority") | ||
90 | #define HMT_medium() asm volatile("or 2,2,2 # medium priority") | ||
91 | #define HMT_medium_high() asm volatile("or 5,5,5 # medium high priority") | ||
92 | #define HMT_high() asm volatile("or 3,3,3 # high priority") | ||
93 | |||
94 | #ifdef __KERNEL__ | ||
95 | |||
96 | extern int have_of; | ||
97 | |||
98 | struct task_struct; | ||
99 | void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp); | ||
100 | void release_thread(struct task_struct *); | ||
101 | |||
102 | /* Prepare to copy thread state - unlazy all lazy status */ | ||
103 | extern void prepare_to_copy(struct task_struct *tsk); | ||
104 | |||
105 | /* Create a new kernel thread. */ | ||
106 | extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | ||
107 | |||
108 | /* Lazy FPU handling on uni-processor */ | ||
109 | extern struct task_struct *last_task_used_math; | ||
110 | extern struct task_struct *last_task_used_altivec; | ||
111 | extern struct task_struct *last_task_used_spe; | ||
112 | |||
113 | #ifdef CONFIG_PPC32 | ||
114 | #define TASK_SIZE (CONFIG_TASK_SIZE) | ||
115 | |||
116 | /* This decides where the kernel will search for a free chunk of vm | ||
117 | * space during mmap's. | ||
118 | */ | ||
119 | #define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3) | ||
120 | #endif | ||
121 | |||
122 | #ifdef CONFIG_PPC64 | ||
123 | /* 64-bit user address space is 44-bits (16TB user VM) */ | ||
124 | #define TASK_SIZE_USER64 (0x0000100000000000UL) | ||
125 | |||
126 | /* | ||
127 | * 32-bit user address space is 4GB - 1 page | ||
128 | * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT | ||
129 | */ | ||
130 | #define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE)) | ||
131 | |||
132 | #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ | ||
133 | TASK_SIZE_USER32 : TASK_SIZE_USER64) | ||
134 | |||
135 | /* This decides where the kernel will search for a free chunk of vm | ||
136 | * space during mmap's. | ||
137 | */ | ||
138 | #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4)) | ||
139 | #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4)) | ||
140 | |||
141 | #define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)) ? \ | ||
142 | TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 ) | ||
143 | #endif | ||
144 | |||
145 | typedef struct { | ||
146 | unsigned long seg; | ||
147 | } mm_segment_t; | ||
148 | |||
149 | struct thread_struct { | ||
150 | unsigned long ksp; /* Kernel stack pointer */ | ||
151 | #ifdef CONFIG_PPC64 | ||
152 | unsigned long ksp_vsid; | ||
153 | #endif | ||
154 | struct pt_regs *regs; /* Pointer to saved register state */ | ||
155 | mm_segment_t fs; /* for get_fs() validation */ | ||
156 | #ifdef CONFIG_PPC32 | ||
157 | void *pgdir; /* root of page-table tree */ | ||
158 | signed long last_syscall; | ||
159 | #endif | ||
160 | #if defined(CONFIG_4xx) || defined (CONFIG_BOOKE) | ||
161 | unsigned long dbcr0; /* debug control register values */ | ||
162 | unsigned long dbcr1; | ||
163 | #endif | ||
164 | double fpr[32]; /* Complete floating point set */ | ||
165 | struct { /* fpr ... fpscr must be contiguous */ | ||
166 | |||
167 | unsigned int pad; | ||
168 | unsigned int val; /* Floating point status */ | ||
169 | } fpscr; | ||
170 | int fpexc_mode; /* floating-point exception mode */ | ||
171 | #ifdef CONFIG_PPC64 | ||
172 | unsigned long start_tb; /* Start purr when proc switched in */ | ||
173 | unsigned long accum_tb; /* Total accumilated purr for process */ | ||
174 | unsigned long vdso_base; /* base of the vDSO library */ | ||
175 | #endif | ||
176 | unsigned long dabr; /* Data address breakpoint register */ | ||
177 | #ifdef CONFIG_ALTIVEC | ||
178 | /* Complete AltiVec register set */ | ||
179 | vector128 vr[32] __attribute((aligned(16))); | ||
180 | /* AltiVec status */ | ||
181 | vector128 vscr __attribute((aligned(16))); | ||
182 | unsigned long vrsave; | ||
183 | int used_vr; /* set if process has used altivec */ | ||
184 | #endif /* CONFIG_ALTIVEC */ | ||
185 | #ifdef CONFIG_SPE | ||
186 | unsigned long evr[32]; /* upper 32-bits of SPE regs */ | ||
187 | u64 acc; /* Accumulator */ | ||
188 | unsigned long spefscr; /* SPE & eFP status */ | ||
189 | int used_spe; /* set if process has used spe */ | ||
190 | #endif /* CONFIG_SPE */ | ||
191 | }; | ||
192 | |||
193 | #define ARCH_MIN_TASKALIGN 16 | ||
194 | |||
195 | #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) | ||
196 | |||
197 | |||
198 | #ifdef CONFIG_PPC32 | ||
199 | #define INIT_THREAD { \ | ||
200 | .ksp = INIT_SP, \ | ||
201 | .fs = KERNEL_DS, \ | ||
202 | .pgdir = swapper_pg_dir, \ | ||
203 | .fpexc_mode = MSR_FE0 | MSR_FE1, \ | ||
204 | } | ||
205 | #else | ||
206 | #define INIT_THREAD { \ | ||
207 | .ksp = INIT_SP, \ | ||
208 | .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \ | ||
209 | .fs = KERNEL_DS, \ | ||
210 | .fpr = {0}, \ | ||
211 | .fpscr = { .val = 0, }, \ | ||
212 | .fpexc_mode = MSR_FE0|MSR_FE1, \ | ||
213 | } | ||
214 | #endif | ||
215 | |||
216 | /* | ||
217 | * Return saved PC of a blocked thread. For now, this is the "user" PC | ||
218 | */ | ||
219 | #define thread_saved_pc(tsk) \ | ||
220 | ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0) | ||
221 | |||
222 | unsigned long get_wchan(struct task_struct *p); | ||
223 | |||
224 | #define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0) | ||
225 | #define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0) | ||
226 | |||
227 | /* Get/set floating-point exception mode */ | ||
228 | #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr)) | ||
229 | #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val)) | ||
230 | |||
231 | extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr); | ||
232 | extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val); | ||
233 | |||
234 | static inline unsigned int __unpack_fe01(unsigned long msr_bits) | ||
235 | { | ||
236 | return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8); | ||
237 | } | ||
238 | |||
239 | static inline unsigned long __pack_fe01(unsigned int fpmode) | ||
240 | { | ||
241 | return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1); | ||
242 | } | ||
243 | |||
244 | #ifdef CONFIG_PPC64 | ||
245 | #define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0) | ||
246 | #else | ||
247 | #define cpu_relax() barrier() | ||
248 | #endif | ||
249 | |||
250 | /* | ||
251 | * Prefetch macros. | ||
252 | */ | ||
253 | #define ARCH_HAS_PREFETCH | ||
254 | #define ARCH_HAS_PREFETCHW | ||
255 | #define ARCH_HAS_SPINLOCK_PREFETCH | ||
256 | |||
257 | static inline void prefetch(const void *x) | ||
258 | { | ||
259 | if (unlikely(!x)) | ||
260 | return; | ||
261 | |||
262 | __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x)); | ||
263 | } | ||
264 | |||
265 | static inline void prefetchw(const void *x) | ||
266 | { | ||
267 | if (unlikely(!x)) | ||
268 | return; | ||
269 | |||
270 | __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x)); | ||
271 | } | ||
272 | |||
273 | #define spin_lock_prefetch(x) prefetchw(x) | ||
274 | |||
275 | #ifdef CONFIG_PPC64 | ||
276 | #define HAVE_ARCH_PICK_MMAP_LAYOUT | ||
277 | #endif | ||
278 | |||
279 | #endif /* __KERNEL__ */ | ||
280 | #endif /* __ASSEMBLY__ */ | ||
281 | #endif /* _ASM_POWERPC_PROCESSOR_H */ | ||
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h new file mode 100644 index 000000000000..3a0104fa0462 --- /dev/null +++ b/include/asm-powerpc/prom.h | |||
@@ -0,0 +1,219 @@ | |||
1 | #ifndef _POWERPC_PROM_H | ||
2 | #define _POWERPC_PROM_H | ||
3 | #ifdef __KERNEL__ | ||
4 | |||
5 | /* | ||
6 | * Definitions for talking to the Open Firmware PROM on | ||
7 | * Power Macintosh computers. | ||
8 | * | ||
9 | * Copyright (C) 1996-2005 Paul Mackerras. | ||
10 | * | ||
11 | * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version | ||
16 | * 2 of the License, or (at your option) any later version. | ||
17 | */ | ||
18 | #include <linux/config.h> | ||
19 | #include <linux/types.h> | ||
20 | #include <linux/proc_fs.h> | ||
21 | #include <asm/atomic.h> | ||
22 | |||
23 | /* Definitions used by the flattened device tree */ | ||
24 | #define OF_DT_HEADER 0xd00dfeed /* marker */ | ||
25 | #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ | ||
26 | #define OF_DT_END_NODE 0x2 /* End node */ | ||
27 | #define OF_DT_PROP 0x3 /* Property: name off, size, | ||
28 | * content */ | ||
29 | #define OF_DT_NOP 0x4 /* nop */ | ||
30 | #define OF_DT_END 0x9 | ||
31 | |||
32 | #define OF_DT_VERSION 0x10 | ||
33 | |||
34 | /* | ||
35 | * This is what gets passed to the kernel by prom_init or kexec | ||
36 | * | ||
37 | * The dt struct contains the device tree structure, full pathes and | ||
38 | * property contents. The dt strings contain a separate block with just | ||
39 | * the strings for the property names, and is fully page aligned and | ||
40 | * self contained in a page, so that it can be kept around by the kernel, | ||
41 | * each property name appears only once in this page (cheap compression) | ||
42 | * | ||
43 | * the mem_rsvmap contains a map of reserved ranges of physical memory, | ||
44 | * passing it here instead of in the device-tree itself greatly simplifies | ||
45 | * the job of everybody. It's just a list of u64 pairs (base/size) that | ||
46 | * ends when size is 0 | ||
47 | */ | ||
48 | struct boot_param_header | ||
49 | { | ||
50 | u32 magic; /* magic word OF_DT_HEADER */ | ||
51 | u32 totalsize; /* total size of DT block */ | ||
52 | u32 off_dt_struct; /* offset to structure */ | ||
53 | u32 off_dt_strings; /* offset to strings */ | ||
54 | u32 off_mem_rsvmap; /* offset to memory reserve map */ | ||
55 | u32 version; /* format version */ | ||
56 | u32 last_comp_version; /* last compatible version */ | ||
57 | /* version 2 fields below */ | ||
58 | u32 boot_cpuid_phys; /* Physical CPU id we're booting on */ | ||
59 | /* version 3 fields below */ | ||
60 | u32 dt_strings_size; /* size of the DT strings block */ | ||
61 | }; | ||
62 | |||
63 | |||
64 | |||
65 | typedef u32 phandle; | ||
66 | typedef u32 ihandle; | ||
67 | |||
68 | struct address_range { | ||
69 | unsigned long space; | ||
70 | unsigned long address; | ||
71 | unsigned long size; | ||
72 | }; | ||
73 | |||
74 | struct interrupt_info { | ||
75 | int line; | ||
76 | int sense; /* +ve/-ve logic, edge or level, etc. */ | ||
77 | }; | ||
78 | |||
79 | struct pci_address { | ||
80 | u32 a_hi; | ||
81 | u32 a_mid; | ||
82 | u32 a_lo; | ||
83 | }; | ||
84 | |||
85 | struct isa_address { | ||
86 | u32 a_hi; | ||
87 | u32 a_lo; | ||
88 | }; | ||
89 | |||
90 | struct isa_range { | ||
91 | struct isa_address isa_addr; | ||
92 | struct pci_address pci_addr; | ||
93 | unsigned int size; | ||
94 | }; | ||
95 | |||
96 | struct reg_property { | ||
97 | unsigned long address; | ||
98 | unsigned long size; | ||
99 | }; | ||
100 | |||
101 | struct reg_property32 { | ||
102 | unsigned int address; | ||
103 | unsigned int size; | ||
104 | }; | ||
105 | |||
106 | struct reg_property64 { | ||
107 | u64 address; | ||
108 | u64 size; | ||
109 | }; | ||
110 | |||
111 | struct property { | ||
112 | char *name; | ||
113 | int length; | ||
114 | unsigned char *value; | ||
115 | struct property *next; | ||
116 | }; | ||
117 | |||
118 | struct device_node { | ||
119 | char *name; | ||
120 | char *type; | ||
121 | phandle node; | ||
122 | phandle linux_phandle; | ||
123 | int n_addrs; | ||
124 | struct address_range *addrs; | ||
125 | int n_intrs; | ||
126 | struct interrupt_info *intrs; | ||
127 | char *full_name; | ||
128 | |||
129 | struct property *properties; | ||
130 | struct device_node *parent; | ||
131 | struct device_node *child; | ||
132 | struct device_node *sibling; | ||
133 | struct device_node *next; /* next device of same type */ | ||
134 | struct device_node *allnext; /* next in list of all nodes */ | ||
135 | struct proc_dir_entry *pde; /* this node's proc directory */ | ||
136 | struct kref kref; | ||
137 | unsigned long _flags; | ||
138 | void *data; | ||
139 | }; | ||
140 | |||
141 | extern struct device_node *of_chosen; | ||
142 | |||
143 | /* flag descriptions */ | ||
144 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ | ||
145 | |||
146 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) | ||
147 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) | ||
148 | |||
149 | #define HAVE_ARCH_DEVTREE_FIXUPS | ||
150 | |||
151 | static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de) | ||
152 | { | ||
153 | dn->pde = de; | ||
154 | } | ||
155 | |||
156 | |||
157 | /* OBSOLETE: Old style node lookup */ | ||
158 | extern struct device_node *find_devices(const char *name); | ||
159 | extern struct device_node *find_type_devices(const char *type); | ||
160 | extern struct device_node *find_path_device(const char *path); | ||
161 | extern struct device_node *find_compatible_devices(const char *type, | ||
162 | const char *compat); | ||
163 | extern struct device_node *find_all_nodes(void); | ||
164 | |||
165 | /* New style node lookup */ | ||
166 | extern struct device_node *of_find_node_by_name(struct device_node *from, | ||
167 | const char *name); | ||
168 | extern struct device_node *of_find_node_by_type(struct device_node *from, | ||
169 | const char *type); | ||
170 | extern struct device_node *of_find_compatible_node(struct device_node *from, | ||
171 | const char *type, const char *compat); | ||
172 | extern struct device_node *of_find_node_by_path(const char *path); | ||
173 | extern struct device_node *of_find_node_by_phandle(phandle handle); | ||
174 | extern struct device_node *of_find_all_nodes(struct device_node *prev); | ||
175 | extern struct device_node *of_get_parent(const struct device_node *node); | ||
176 | extern struct device_node *of_get_next_child(const struct device_node *node, | ||
177 | struct device_node *prev); | ||
178 | extern struct device_node *of_node_get(struct device_node *node); | ||
179 | extern void of_node_put(struct device_node *node); | ||
180 | |||
181 | /* For updating the device tree at runtime */ | ||
182 | extern void of_attach_node(struct device_node *); | ||
183 | extern void of_detach_node(const struct device_node *); | ||
184 | |||
185 | /* Other Prototypes */ | ||
186 | extern void finish_device_tree(void); | ||
187 | extern void unflatten_device_tree(void); | ||
188 | extern void early_init_devtree(void *); | ||
189 | extern int device_is_compatible(struct device_node *device, const char *); | ||
190 | extern int machine_is_compatible(const char *compat); | ||
191 | extern unsigned char *get_property(struct device_node *node, const char *name, | ||
192 | int *lenp); | ||
193 | extern void print_properties(struct device_node *node); | ||
194 | extern int prom_n_addr_cells(struct device_node* np); | ||
195 | extern int prom_n_size_cells(struct device_node* np); | ||
196 | extern int prom_n_intr_cells(struct device_node* np); | ||
197 | extern void prom_get_irq_senses(unsigned char *senses, int off, int max); | ||
198 | extern void prom_add_property(struct device_node* np, struct property* prop); | ||
199 | |||
200 | #ifdef CONFIG_PPC32 | ||
201 | /* | ||
202 | * PCI <-> OF matching functions | ||
203 | * (XXX should these be here?) | ||
204 | */ | ||
205 | struct pci_bus; | ||
206 | struct pci_dev; | ||
207 | extern int pci_device_from_OF_node(struct device_node *node, | ||
208 | u8* bus, u8* devfn); | ||
209 | extern struct device_node* pci_busdev_to_OF_node(struct pci_bus *, int); | ||
210 | extern struct device_node* pci_device_to_OF_node(struct pci_dev *); | ||
211 | extern void pci_create_OF_bus_map(void); | ||
212 | #endif | ||
213 | |||
214 | extern struct resource *request_OF_resource(struct device_node* node, | ||
215 | int index, const char* name_postfix); | ||
216 | extern int release_OF_resource(struct device_node* node, int index); | ||
217 | |||
218 | #endif /* __KERNEL__ */ | ||
219 | #endif /* _POWERPC_PROM_H */ | ||
diff --git a/include/asm-powerpc/ptrace.h b/include/asm-powerpc/ptrace.h new file mode 100644 index 000000000000..1f7ecdb0b6ce --- /dev/null +++ b/include/asm-powerpc/ptrace.h | |||
@@ -0,0 +1,248 @@ | |||
1 | #ifndef _ASM_POWERPC_PTRACE_H | ||
2 | #define _ASM_POWERPC_PTRACE_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (C) 2001 PPC64 Team, IBM Corp | ||
6 | * | ||
7 | * This struct defines the way the registers are stored on the | ||
8 | * kernel stack during a system call or other kernel entry. | ||
9 | * | ||
10 | * this should only contain volatile regs | ||
11 | * since we can keep non-volatile in the thread_struct | ||
12 | * should set this up when only volatiles are saved | ||
13 | * by intr code. | ||
14 | * | ||
15 | * Since this is going on the stack, *CARE MUST BE TAKEN* to insure | ||
16 | * that the overall structure is a multiple of 16 bytes in length. | ||
17 | * | ||
18 | * Note that the offsets of the fields in this struct correspond with | ||
19 | * the PT_* values below. This simplifies arch/powerpc/kernel/ptrace.c. | ||
20 | * | ||
21 | * This program is free software; you can redistribute it and/or | ||
22 | * modify it under the terms of the GNU General Public License | ||
23 | * as published by the Free Software Foundation; either version | ||
24 | * 2 of the License, or (at your option) any later version. | ||
25 | */ | ||
26 | |||
27 | #ifndef __ASSEMBLY__ | ||
28 | |||
29 | struct pt_regs { | ||
30 | unsigned long gpr[32]; | ||
31 | unsigned long nip; | ||
32 | unsigned long msr; | ||
33 | unsigned long orig_gpr3; /* Used for restarting system calls */ | ||
34 | unsigned long ctr; | ||
35 | unsigned long link; | ||
36 | unsigned long xer; | ||
37 | unsigned long ccr; | ||
38 | #ifdef __powerpc64__ | ||
39 | unsigned long softe; /* Soft enabled/disabled */ | ||
40 | #else | ||
41 | unsigned long mq; /* 601 only (not used at present) */ | ||
42 | /* Used on APUS to hold IPL value. */ | ||
43 | #endif | ||
44 | unsigned long trap; /* Reason for being here */ | ||
45 | /* N.B. for critical exceptions on 4xx, the dar and dsisr | ||
46 | fields are overloaded to hold srr0 and srr1. */ | ||
47 | unsigned long dar; /* Fault registers */ | ||
48 | unsigned long dsisr; /* on 4xx/Book-E used for ESR */ | ||
49 | unsigned long result; /* Result of a system call */ | ||
50 | }; | ||
51 | |||
52 | #endif /* __ASSEMBLY__ */ | ||
53 | |||
54 | #ifdef __KERNEL__ | ||
55 | |||
56 | #ifdef __powerpc64__ | ||
57 | |||
58 | #define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */ | ||
59 | |||
60 | /* Size of dummy stack frame allocated when calling signal handler. */ | ||
61 | #define __SIGNAL_FRAMESIZE 128 | ||
62 | #define __SIGNAL_FRAMESIZE32 64 | ||
63 | |||
64 | #else /* __powerpc64__ */ | ||
65 | |||
66 | #define STACK_FRAME_OVERHEAD 16 /* size of minimum stack frame */ | ||
67 | |||
68 | /* Size of stack frame allocated when calling signal handler. */ | ||
69 | #define __SIGNAL_FRAMESIZE 64 | ||
70 | |||
71 | #endif /* __powerpc64__ */ | ||
72 | |||
73 | #ifndef __ASSEMBLY__ | ||
74 | |||
75 | #define instruction_pointer(regs) ((regs)->nip) | ||
76 | #ifdef CONFIG_SMP | ||
77 | extern unsigned long profile_pc(struct pt_regs *regs); | ||
78 | #else | ||
79 | #define profile_pc(regs) instruction_pointer(regs) | ||
80 | #endif | ||
81 | |||
82 | #ifdef __powerpc64__ | ||
83 | #define user_mode(regs) ((((regs)->msr) >> MSR_PR_LG) & 0x1) | ||
84 | #else | ||
85 | #define user_mode(regs) (((regs)->msr & MSR_PR) != 0) | ||
86 | #endif | ||
87 | |||
88 | #define force_successful_syscall_return() \ | ||
89 | do { \ | ||
90 | current_thread_info()->syscall_noerror = 1; \ | ||
91 | } while(0) | ||
92 | |||
93 | /* | ||
94 | * We use the least-significant bit of the trap field to indicate | ||
95 | * whether we have saved the full set of registers, or only a | ||
96 | * partial set. A 1 there means the partial set. | ||
97 | * On 4xx we use the next bit to indicate whether the exception | ||
98 | * is a critical exception (1 means it is). | ||
99 | */ | ||
100 | #define FULL_REGS(regs) (((regs)->trap & 1) == 0) | ||
101 | #ifndef __powerpc64__ | ||
102 | #define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) == 0) | ||
103 | #endif /* ! __powerpc64__ */ | ||
104 | #define TRAP(regs) ((regs)->trap & ~0xF) | ||
105 | #ifdef __powerpc64__ | ||
106 | #define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1) | ||
107 | #else | ||
108 | #define CHECK_FULL_REGS(regs) \ | ||
109 | do { \ | ||
110 | if ((regs)->trap & 1) \ | ||
111 | printk(KERN_CRIT "%s: partial register set\n", __FUNCTION__); \ | ||
112 | } while (0) | ||
113 | #endif /* __powerpc64__ */ | ||
114 | |||
115 | #endif /* __ASSEMBLY__ */ | ||
116 | |||
117 | #endif /* __KERNEL__ */ | ||
118 | |||
119 | /* | ||
120 | * Offsets used by 'ptrace' system call interface. | ||
121 | * These can't be changed without breaking binary compatibility | ||
122 | * with MkLinux, etc. | ||
123 | */ | ||
124 | #define PT_R0 0 | ||
125 | #define PT_R1 1 | ||
126 | #define PT_R2 2 | ||
127 | #define PT_R3 3 | ||
128 | #define PT_R4 4 | ||
129 | #define PT_R5 5 | ||
130 | #define PT_R6 6 | ||
131 | #define PT_R7 7 | ||
132 | #define PT_R8 8 | ||
133 | #define PT_R9 9 | ||
134 | #define PT_R10 10 | ||
135 | #define PT_R11 11 | ||
136 | #define PT_R12 12 | ||
137 | #define PT_R13 13 | ||
138 | #define PT_R14 14 | ||
139 | #define PT_R15 15 | ||
140 | #define PT_R16 16 | ||
141 | #define PT_R17 17 | ||
142 | #define PT_R18 18 | ||
143 | #define PT_R19 19 | ||
144 | #define PT_R20 20 | ||
145 | #define PT_R21 21 | ||
146 | #define PT_R22 22 | ||
147 | #define PT_R23 23 | ||
148 | #define PT_R24 24 | ||
149 | #define PT_R25 25 | ||
150 | #define PT_R26 26 | ||
151 | #define PT_R27 27 | ||
152 | #define PT_R28 28 | ||
153 | #define PT_R29 29 | ||
154 | #define PT_R30 30 | ||
155 | #define PT_R31 31 | ||
156 | |||
157 | #define PT_NIP 32 | ||
158 | #define PT_MSR 33 | ||
159 | #ifdef __KERNEL__ | ||
160 | #define PT_ORIG_R3 34 | ||
161 | #endif | ||
162 | #define PT_CTR 35 | ||
163 | #define PT_LNK 36 | ||
164 | #define PT_XER 37 | ||
165 | #define PT_CCR 38 | ||
166 | #ifndef __powerpc64__ | ||
167 | #define PT_MQ 39 | ||
168 | #else | ||
169 | #define PT_SOFTE 39 | ||
170 | #define PT_TRAP 40 | ||
171 | #define PT_DAR 41 | ||
172 | #define PT_DSISR 42 | ||
173 | #define PT_RESULT 43 | ||
174 | #endif | ||
175 | |||
176 | #define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */ | ||
177 | |||
178 | #ifndef __powerpc64__ | ||
179 | |||
180 | #define PT_FPR31 (PT_FPR0 + 2*31) | ||
181 | #define PT_FPSCR (PT_FPR0 + 2*32 + 1) | ||
182 | |||
183 | #else /* __powerpc64__ */ | ||
184 | |||
185 | #define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */ | ||
186 | |||
187 | #ifdef __KERNEL__ | ||
188 | #define PT_FPSCR32 (PT_FPR0 + 2*32 + 1) /* each FP reg occupies 2 32-bit userspace slots */ | ||
189 | #endif | ||
190 | |||
191 | #define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */ | ||
192 | #define PT_VSCR (PT_VR0 + 32*2 + 1) | ||
193 | #define PT_VRSAVE (PT_VR0 + 33*2) | ||
194 | |||
195 | #ifdef __KERNEL__ | ||
196 | #define PT_VR0_32 164 /* each Vector reg occupies 4 slots in 32-bit */ | ||
197 | #define PT_VSCR_32 (PT_VR0 + 32*4 + 3) | ||
198 | #define PT_VRSAVE_32 (PT_VR0 + 33*4) | ||
199 | #endif | ||
200 | |||
201 | #endif /* __powerpc64__ */ | ||
202 | |||
203 | /* | ||
204 | * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go. | ||
205 | * The transfer totals 34 quadword. Quadwords 0-31 contain the | ||
206 | * corresponding vector registers. Quadword 32 contains the vscr as the | ||
207 | * last word (offset 12) within that quadword. Quadword 33 contains the | ||
208 | * vrsave as the first word (offset 0) within the quadword. | ||
209 | * | ||
210 | * This definition of the VMX state is compatible with the current PPC32 | ||
211 | * ptrace interface. This allows signal handling and ptrace to use the same | ||
212 | * structures. This also simplifies the implementation of a bi-arch | ||
213 | * (combined (32- and 64-bit) gdb. | ||
214 | */ | ||
215 | #define PTRACE_GETVRREGS 18 | ||
216 | #define PTRACE_SETVRREGS 19 | ||
217 | |||
218 | #ifndef __powerpc64__ | ||
219 | /* Get/set all the upper 32-bits of the SPE registers, accumulator, and | ||
220 | * spefscr, in one go */ | ||
221 | #define PTRACE_GETEVRREGS 20 | ||
222 | #define PTRACE_SETEVRREGS 21 | ||
223 | #endif /* __powerpc64__ */ | ||
224 | |||
225 | /* | ||
226 | * Get or set a debug register. The first 16 are DABR registers and the | ||
227 | * second 16 are IABR registers. | ||
228 | */ | ||
229 | #define PTRACE_GET_DEBUGREG 25 | ||
230 | #define PTRACE_SET_DEBUGREG 26 | ||
231 | |||
232 | #ifdef __powerpc64__ | ||
233 | /* Additional PTRACE requests implemented on PowerPC. */ | ||
234 | #define PPC_PTRACE_GETREGS 0x99 /* Get GPRs 0 - 31 */ | ||
235 | #define PPC_PTRACE_SETREGS 0x98 /* Set GPRs 0 - 31 */ | ||
236 | #define PPC_PTRACE_GETFPREGS 0x97 /* Get FPRs 0 - 31 */ | ||
237 | #define PPC_PTRACE_SETFPREGS 0x96 /* Set FPRs 0 - 31 */ | ||
238 | |||
239 | /* Calls to trace a 64bit program from a 32bit program */ | ||
240 | #define PPC_PTRACE_PEEKTEXT_3264 0x95 | ||
241 | #define PPC_PTRACE_PEEKDATA_3264 0x94 | ||
242 | #define PPC_PTRACE_POKETEXT_3264 0x93 | ||
243 | #define PPC_PTRACE_POKEDATA_3264 0x92 | ||
244 | #define PPC_PTRACE_PEEKUSR_3264 0x91 | ||
245 | #define PPC_PTRACE_POKEUSR_3264 0x90 | ||
246 | #endif /* __powerpc64__ */ | ||
247 | |||
248 | #endif /* _ASM_POWERPC_PTRACE_H */ | ||
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h new file mode 100644 index 000000000000..da848412f11b --- /dev/null +++ b/include/asm-powerpc/reg.h | |||
@@ -0,0 +1,613 @@ | |||
1 | /* | ||
2 | * Contains the definition of registers common to all PowerPC variants. | ||
3 | * If a register definition has been changed in a different PowerPC | ||
4 | * variant, we will case it in #ifndef XXX ... #endif, and have the | ||
5 | * number used in the Programming Environments Manual For 32-Bit | ||
6 | * Implementations of the PowerPC Architecture (a.k.a. Green Book) here. | ||
7 | */ | ||
8 | |||
9 | #ifndef _ASM_POWERPC_REG_H | ||
10 | #define _ASM_POWERPC_REG_H | ||
11 | #ifdef __KERNEL__ | ||
12 | |||
13 | #include <linux/stringify.h> | ||
14 | #include <asm/cputable.h> | ||
15 | |||
16 | /* Pickup Book E specific registers. */ | ||
17 | #if defined(CONFIG_BOOKE) || defined(CONFIG_40x) | ||
18 | #include <asm/reg_booke.h> | ||
19 | #endif | ||
20 | |||
21 | #define MSR_SF_LG 63 /* Enable 64 bit mode */ | ||
22 | #define MSR_ISF_LG 61 /* Interrupt 64b mode valid on 630 */ | ||
23 | #define MSR_HV_LG 60 /* Hypervisor state */ | ||
24 | #define MSR_VEC_LG 25 /* Enable AltiVec */ | ||
25 | #define MSR_POW_LG 18 /* Enable Power Management */ | ||
26 | #define MSR_WE_LG 18 /* Wait State Enable */ | ||
27 | #define MSR_TGPR_LG 17 /* TLB Update registers in use */ | ||
28 | #define MSR_CE_LG 17 /* Critical Interrupt Enable */ | ||
29 | #define MSR_ILE_LG 16 /* Interrupt Little Endian */ | ||
30 | #define MSR_EE_LG 15 /* External Interrupt Enable */ | ||
31 | #define MSR_PR_LG 14 /* Problem State / Privilege Level */ | ||
32 | #define MSR_FP_LG 13 /* Floating Point enable */ | ||
33 | #define MSR_ME_LG 12 /* Machine Check Enable */ | ||
34 | #define MSR_FE0_LG 11 /* Floating Exception mode 0 */ | ||
35 | #define MSR_SE_LG 10 /* Single Step */ | ||
36 | #define MSR_BE_LG 9 /* Branch Trace */ | ||
37 | #define MSR_DE_LG 9 /* Debug Exception Enable */ | ||
38 | #define MSR_FE1_LG 8 /* Floating Exception mode 1 */ | ||
39 | #define MSR_IP_LG 6 /* Exception prefix 0x000/0xFFF */ | ||
40 | #define MSR_IR_LG 5 /* Instruction Relocate */ | ||
41 | #define MSR_DR_LG 4 /* Data Relocate */ | ||
42 | #define MSR_PE_LG 3 /* Protection Enable */ | ||
43 | #define MSR_PX_LG 2 /* Protection Exclusive Mode */ | ||
44 | #define MSR_PMM_LG 2 /* Performance monitor */ | ||
45 | #define MSR_RI_LG 1 /* Recoverable Exception */ | ||
46 | #define MSR_LE_LG 0 /* Little Endian */ | ||
47 | |||
48 | #ifdef __ASSEMBLY__ | ||
49 | #define __MASK(X) (1<<(X)) | ||
50 | #else | ||
51 | #define __MASK(X) (1UL<<(X)) | ||
52 | #endif | ||
53 | |||
54 | #ifdef CONFIG_PPC64 | ||
55 | #define MSR_SF __MASK(MSR_SF_LG) /* Enable 64 bit mode */ | ||
56 | #define MSR_ISF __MASK(MSR_ISF_LG) /* Interrupt 64b mode valid on 630 */ | ||
57 | #define MSR_HV __MASK(MSR_HV_LG) /* Hypervisor state */ | ||
58 | #else | ||
59 | /* so tests for these bits fail on 32-bit */ | ||
60 | #define MSR_SF 0 | ||
61 | #define MSR_ISF 0 | ||
62 | #define MSR_HV 0 | ||
63 | #endif | ||
64 | |||
65 | #define MSR_VEC __MASK(MSR_VEC_LG) /* Enable AltiVec */ | ||
66 | #define MSR_POW __MASK(MSR_POW_LG) /* Enable Power Management */ | ||
67 | #define MSR_WE __MASK(MSR_WE_LG) /* Wait State Enable */ | ||
68 | #define MSR_TGPR __MASK(MSR_TGPR_LG) /* TLB Update registers in use */ | ||
69 | #define MSR_CE __MASK(MSR_CE_LG) /* Critical Interrupt Enable */ | ||
70 | #define MSR_ILE __MASK(MSR_ILE_LG) /* Interrupt Little Endian */ | ||
71 | #define MSR_EE __MASK(MSR_EE_LG) /* External Interrupt Enable */ | ||
72 | #define MSR_PR __MASK(MSR_PR_LG) /* Problem State / Privilege Level */ | ||
73 | #define MSR_FP __MASK(MSR_FP_LG) /* Floating Point enable */ | ||
74 | #define MSR_ME __MASK(MSR_ME_LG) /* Machine Check Enable */ | ||
75 | #define MSR_FE0 __MASK(MSR_FE0_LG) /* Floating Exception mode 0 */ | ||
76 | #define MSR_SE __MASK(MSR_SE_LG) /* Single Step */ | ||
77 | #define MSR_BE __MASK(MSR_BE_LG) /* Branch Trace */ | ||
78 | #define MSR_DE __MASK(MSR_DE_LG) /* Debug Exception Enable */ | ||
79 | #define MSR_FE1 __MASK(MSR_FE1_LG) /* Floating Exception mode 1 */ | ||
80 | #define MSR_IP __MASK(MSR_IP_LG) /* Exception prefix 0x000/0xFFF */ | ||
81 | #define MSR_IR __MASK(MSR_IR_LG) /* Instruction Relocate */ | ||
82 | #define MSR_DR __MASK(MSR_DR_LG) /* Data Relocate */ | ||
83 | #define MSR_PE __MASK(MSR_PE_LG) /* Protection Enable */ | ||
84 | #define MSR_PX __MASK(MSR_PX_LG) /* Protection Exclusive Mode */ | ||
85 | #ifndef MSR_PMM | ||
86 | #define MSR_PMM __MASK(MSR_PMM_LG) /* Performance monitor */ | ||
87 | #endif | ||
88 | #define MSR_RI __MASK(MSR_RI_LG) /* Recoverable Exception */ | ||
89 | #define MSR_LE __MASK(MSR_LE_LG) /* Little Endian */ | ||
90 | |||
91 | #ifdef CONFIG_PPC64 | ||
92 | #define MSR_ MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF | ||
93 | #define MSR_KERNEL MSR_ | MSR_SF | MSR_HV | ||
94 | |||
95 | #define MSR_USER32 MSR_ | MSR_PR | MSR_EE | ||
96 | #define MSR_USER64 MSR_USER32 | MSR_SF | ||
97 | |||
98 | #else /* 32-bit */ | ||
99 | /* Default MSR for kernel mode. */ | ||
100 | #ifndef MSR_KERNEL /* reg_booke.h also defines this */ | ||
101 | #ifdef CONFIG_APUS_FAST_EXCEPT | ||
102 | #define MSR_KERNEL (MSR_ME|MSR_IP|MSR_RI|MSR_IR|MSR_DR) | ||
103 | #else | ||
104 | #define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR) | ||
105 | #endif | ||
106 | #endif | ||
107 | |||
108 | #define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE) | ||
109 | #endif | ||
110 | |||
111 | /* Floating Point Status and Control Register (FPSCR) Fields */ | ||
112 | #define FPSCR_FX 0x80000000 /* FPU exception summary */ | ||
113 | #define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */ | ||
114 | #define FPSCR_VX 0x20000000 /* Invalid operation summary */ | ||
115 | #define FPSCR_OX 0x10000000 /* Overflow exception summary */ | ||
116 | #define FPSCR_UX 0x08000000 /* Underflow exception summary */ | ||
117 | #define FPSCR_ZX 0x04000000 /* Zero-divide exception summary */ | ||
118 | #define FPSCR_XX 0x02000000 /* Inexact exception summary */ | ||
119 | #define FPSCR_VXSNAN 0x01000000 /* Invalid op for SNaN */ | ||
120 | #define FPSCR_VXISI 0x00800000 /* Invalid op for Inv - Inv */ | ||
121 | #define FPSCR_VXIDI 0x00400000 /* Invalid op for Inv / Inv */ | ||
122 | #define FPSCR_VXZDZ 0x00200000 /* Invalid op for Zero / Zero */ | ||
123 | #define FPSCR_VXIMZ 0x00100000 /* Invalid op for Inv * Zero */ | ||
124 | #define FPSCR_VXVC 0x00080000 /* Invalid op for Compare */ | ||
125 | #define FPSCR_FR 0x00040000 /* Fraction rounded */ | ||
126 | #define FPSCR_FI 0x00020000 /* Fraction inexact */ | ||
127 | #define FPSCR_FPRF 0x0001f000 /* FPU Result Flags */ | ||
128 | #define FPSCR_FPCC 0x0000f000 /* FPU Condition Codes */ | ||
129 | #define FPSCR_VXSOFT 0x00000400 /* Invalid op for software request */ | ||
130 | #define FPSCR_VXSQRT 0x00000200 /* Invalid op for square root */ | ||
131 | #define FPSCR_VXCVI 0x00000100 /* Invalid op for integer convert */ | ||
132 | #define FPSCR_VE 0x00000080 /* Invalid op exception enable */ | ||
133 | #define FPSCR_OE 0x00000040 /* IEEE overflow exception enable */ | ||
134 | #define FPSCR_UE 0x00000020 /* IEEE underflow exception enable */ | ||
135 | #define FPSCR_ZE 0x00000010 /* IEEE zero divide exception enable */ | ||
136 | #define FPSCR_XE 0x00000008 /* FP inexact exception enable */ | ||
137 | #define FPSCR_NI 0x00000004 /* FPU non IEEE-Mode */ | ||
138 | #define FPSCR_RN 0x00000003 /* FPU rounding control */ | ||
139 | |||
140 | /* Special Purpose Registers (SPRNs)*/ | ||
141 | #define SPRN_CTR 0x009 /* Count Register */ | ||
142 | #define SPRN_CTRLF 0x088 | ||
143 | #define SPRN_CTRLT 0x098 | ||
144 | #define CTRL_RUNLATCH 0x1 | ||
145 | #define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ | ||
146 | #define DABR_TRANSLATION (1UL << 2) | ||
147 | #define SPRN_DAR 0x013 /* Data Address Register */ | ||
148 | #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ | ||
149 | #define DSISR_NOHPTE 0x40000000 /* no translation found */ | ||
150 | #define DSISR_PROTFAULT 0x08000000 /* protection fault */ | ||
151 | #define DSISR_ISSTORE 0x02000000 /* access was a store */ | ||
152 | #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */ | ||
153 | #define DSISR_NOSEGMENT 0x00200000 /* STAB/SLB miss */ | ||
154 | #define SPRN_TBRL 0x10C /* Time Base Read Lower Register (user, R/O) */ | ||
155 | #define SPRN_TBRU 0x10D /* Time Base Read Upper Register (user, R/O) */ | ||
156 | #define SPRN_TBWL 0x11C /* Time Base Lower Register (super, R/W) */ | ||
157 | #define SPRN_TBWU 0x11D /* Time Base Upper Register (super, R/W) */ | ||
158 | #define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */ | ||
159 | #define SPRN_DBAT0L 0x219 /* Data BAT 0 Lower Register */ | ||
160 | #define SPRN_DBAT0U 0x218 /* Data BAT 0 Upper Register */ | ||
161 | #define SPRN_DBAT1L 0x21B /* Data BAT 1 Lower Register */ | ||
162 | #define SPRN_DBAT1U 0x21A /* Data BAT 1 Upper Register */ | ||
163 | #define SPRN_DBAT2L 0x21D /* Data BAT 2 Lower Register */ | ||
164 | #define SPRN_DBAT2U 0x21C /* Data BAT 2 Upper Register */ | ||
165 | #define SPRN_DBAT3L 0x21F /* Data BAT 3 Lower Register */ | ||
166 | #define SPRN_DBAT3U 0x21E /* Data BAT 3 Upper Register */ | ||
167 | #define SPRN_DBAT4L 0x239 /* Data BAT 4 Lower Register */ | ||
168 | #define SPRN_DBAT4U 0x238 /* Data BAT 4 Upper Register */ | ||
169 | #define SPRN_DBAT5L 0x23B /* Data BAT 5 Lower Register */ | ||
170 | #define SPRN_DBAT5U 0x23A /* Data BAT 5 Upper Register */ | ||
171 | #define SPRN_DBAT6L 0x23D /* Data BAT 6 Lower Register */ | ||
172 | #define SPRN_DBAT6U 0x23C /* Data BAT 6 Upper Register */ | ||
173 | #define SPRN_DBAT7L 0x23F /* Data BAT 7 Lower Register */ | ||
174 | #define SPRN_DBAT7U 0x23E /* Data BAT 7 Upper Register */ | ||
175 | |||
176 | #define SPRN_DEC 0x016 /* Decrement Register */ | ||
177 | #define SPRN_DER 0x095 /* Debug Enable Regsiter */ | ||
178 | #define DER_RSTE 0x40000000 /* Reset Interrupt */ | ||
179 | #define DER_CHSTPE 0x20000000 /* Check Stop */ | ||
180 | #define DER_MCIE 0x10000000 /* Machine Check Interrupt */ | ||
181 | #define DER_EXTIE 0x02000000 /* External Interrupt */ | ||
182 | #define DER_ALIE 0x01000000 /* Alignment Interrupt */ | ||
183 | #define DER_PRIE 0x00800000 /* Program Interrupt */ | ||
184 | #define DER_FPUVIE 0x00400000 /* FP Unavailable Interrupt */ | ||
185 | #define DER_DECIE 0x00200000 /* Decrementer Interrupt */ | ||
186 | #define DER_SYSIE 0x00040000 /* System Call Interrupt */ | ||
187 | #define DER_TRE 0x00020000 /* Trace Interrupt */ | ||
188 | #define DER_SEIE 0x00004000 /* FP SW Emulation Interrupt */ | ||
189 | #define DER_ITLBMSE 0x00002000 /* Imp. Spec. Instruction TLB Miss */ | ||
190 | #define DER_ITLBERE 0x00001000 /* Imp. Spec. Instruction TLB Error */ | ||
191 | #define DER_DTLBMSE 0x00000800 /* Imp. Spec. Data TLB Miss */ | ||
192 | #define DER_DTLBERE 0x00000400 /* Imp. Spec. Data TLB Error */ | ||
193 | #define DER_LBRKE 0x00000008 /* Load/Store Breakpoint Interrupt */ | ||
194 | #define DER_IBRKE 0x00000004 /* Instruction Breakpoint Interrupt */ | ||
195 | #define DER_EBRKE 0x00000002 /* External Breakpoint Interrupt */ | ||
196 | #define DER_DPIE 0x00000001 /* Dev. Port Nonmaskable Request */ | ||
197 | #define SPRN_DMISS 0x3D0 /* Data TLB Miss Register */ | ||
198 | #define SPRN_EAR 0x11A /* External Address Register */ | ||
199 | #define SPRN_HASH1 0x3D2 /* Primary Hash Address Register */ | ||
200 | #define SPRN_HASH2 0x3D3 /* Secondary Hash Address Resgister */ | ||
201 | #define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */ | ||
202 | #define HID0_EMCP (1<<31) /* Enable Machine Check pin */ | ||
203 | #define HID0_EBA (1<<29) /* Enable Bus Address Parity */ | ||
204 | #define HID0_EBD (1<<28) /* Enable Bus Data Parity */ | ||
205 | #define HID0_SBCLK (1<<27) | ||
206 | #define HID0_EICE (1<<26) | ||
207 | #define HID0_TBEN (1<<26) /* Timebase enable - 745x */ | ||
208 | #define HID0_ECLK (1<<25) | ||
209 | #define HID0_PAR (1<<24) | ||
210 | #define HID0_STEN (1<<24) /* Software table search enable - 745x */ | ||
211 | #define HID0_HIGH_BAT (1<<23) /* Enable high BATs - 7455 */ | ||
212 | #define HID0_DOZE (1<<23) | ||
213 | #define HID0_NAP (1<<22) | ||
214 | #define HID0_SLEEP (1<<21) | ||
215 | #define HID0_DPM (1<<20) | ||
216 | #define HID0_BHTCLR (1<<18) /* Clear branch history table - 7450 */ | ||
217 | #define HID0_XAEN (1<<17) /* Extended addressing enable - 7450 */ | ||
218 | #define HID0_NHR (1<<16) /* Not hard reset (software bit-7450)*/ | ||
219 | #define HID0_ICE (1<<15) /* Instruction Cache Enable */ | ||
220 | #define HID0_DCE (1<<14) /* Data Cache Enable */ | ||
221 | #define HID0_ILOCK (1<<13) /* Instruction Cache Lock */ | ||
222 | #define HID0_DLOCK (1<<12) /* Data Cache Lock */ | ||
223 | #define HID0_ICFI (1<<11) /* Instr. Cache Flash Invalidate */ | ||
224 | #define HID0_DCI (1<<10) /* Data Cache Invalidate */ | ||
225 | #define HID0_SPD (1<<9) /* Speculative disable */ | ||
226 | #define HID0_DAPUEN (1<<8) /* Debug APU enable */ | ||
227 | #define HID0_SGE (1<<7) /* Store Gathering Enable */ | ||
228 | #define HID0_SIED (1<<7) /* Serial Instr. Execution [Disable] */ | ||
229 | #define HID0_DFCA (1<<6) /* Data Cache Flush Assist */ | ||
230 | #define HID0_LRSTK (1<<4) /* Link register stack - 745x */ | ||
231 | #define HID0_BTIC (1<<5) /* Branch Target Instr Cache Enable */ | ||
232 | #define HID0_ABE (1<<3) /* Address Broadcast Enable */ | ||
233 | #define HID0_FOLD (1<<3) /* Branch Folding enable - 745x */ | ||
234 | #define HID0_BHTE (1<<2) /* Branch History Table Enable */ | ||
235 | #define HID0_BTCD (1<<1) /* Branch target cache disable */ | ||
236 | #define HID0_NOPDST (1<<1) /* No-op dst, dstt, etc. instr. */ | ||
237 | #define HID0_NOPTI (1<<0) /* No-op dcbt and dcbst instr. */ | ||
238 | |||
239 | #define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ | ||
240 | #define HID1_EMCP (1<<31) /* 7450 Machine Check Pin Enable */ | ||
241 | #define HID1_DFS (1<<22) /* 7447A Dynamic Frequency Scaling */ | ||
242 | #define HID1_PC0 (1<<16) /* 7450 PLL_CFG[0] */ | ||
243 | #define HID1_PC1 (1<<15) /* 7450 PLL_CFG[1] */ | ||
244 | #define HID1_PC2 (1<<14) /* 7450 PLL_CFG[2] */ | ||
245 | #define HID1_PC3 (1<<13) /* 7450 PLL_CFG[3] */ | ||
246 | #define HID1_SYNCBE (1<<11) /* 7450 ABE for sync, eieio */ | ||
247 | #define HID1_ABE (1<<10) /* 7450 Address Broadcast Enable */ | ||
248 | #define HID1_PS (1<<16) /* 750FX PLL selection */ | ||
249 | #define SPRN_HID2 0x3F8 /* Hardware Implementation Register 2 */ | ||
250 | #define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ | ||
251 | #define SPRN_HID4 0x3F4 /* 970 HID4 */ | ||
252 | #define SPRN_HID5 0x3F6 /* 970 HID5 */ | ||
253 | #define SPRN_HID6 0x3F9 /* BE HID 6 */ | ||
254 | #define HID6_LB (0x0F<<12) /* Concurrent Large Page Modes */ | ||
255 | #define HID6_DLP (1<<20) /* Disable all large page modes (4K only) */ | ||
256 | #define SPRN_TSCR 0x399 /* Thread switch control on BE */ | ||
257 | #define SPRN_TTR 0x39A /* Thread switch timeout on BE */ | ||
258 | #define TSCR_DEC_ENABLE 0x200000 /* Decrementer Interrupt */ | ||
259 | #define TSCR_EE_ENABLE 0x100000 /* External Interrupt */ | ||
260 | #define TSCR_EE_BOOST 0x080000 /* External Interrupt Boost */ | ||
261 | #define SPRN_TSC 0x3FD /* Thread switch control on others */ | ||
262 | #define SPRN_TST 0x3FC /* Thread switch timeout on others */ | ||
263 | #if !defined(SPRN_IAC1) && !defined(SPRN_IAC2) | ||
264 | #define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */ | ||
265 | #define SPRN_IAC2 0x3F5 /* Instruction Address Compare 2 */ | ||
266 | #endif | ||
267 | #define SPRN_IBAT0L 0x211 /* Instruction BAT 0 Lower Register */ | ||
268 | #define SPRN_IBAT0U 0x210 /* Instruction BAT 0 Upper Register */ | ||
269 | #define SPRN_IBAT1L 0x213 /* Instruction BAT 1 Lower Register */ | ||
270 | #define SPRN_IBAT1U 0x212 /* Instruction BAT 1 Upper Register */ | ||
271 | #define SPRN_IBAT2L 0x215 /* Instruction BAT 2 Lower Register */ | ||
272 | #define SPRN_IBAT2U 0x214 /* Instruction BAT 2 Upper Register */ | ||
273 | #define SPRN_IBAT3L 0x217 /* Instruction BAT 3 Lower Register */ | ||
274 | #define SPRN_IBAT3U 0x216 /* Instruction BAT 3 Upper Register */ | ||
275 | #define SPRN_IBAT4L 0x231 /* Instruction BAT 4 Lower Register */ | ||
276 | #define SPRN_IBAT4U 0x230 /* Instruction BAT 4 Upper Register */ | ||
277 | #define SPRN_IBAT5L 0x233 /* Instruction BAT 5 Lower Register */ | ||
278 | #define SPRN_IBAT5U 0x232 /* Instruction BAT 5 Upper Register */ | ||
279 | #define SPRN_IBAT6L 0x235 /* Instruction BAT 6 Lower Register */ | ||
280 | #define SPRN_IBAT6U 0x234 /* Instruction BAT 6 Upper Register */ | ||
281 | #define SPRN_IBAT7L 0x237 /* Instruction BAT 7 Lower Register */ | ||
282 | #define SPRN_IBAT7U 0x236 /* Instruction BAT 7 Upper Register */ | ||
283 | #define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */ | ||
284 | #define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */ | ||
285 | #define SPRN_ICTRL 0x3F3 /* 1011 7450 icache and interrupt ctrl */ | ||
286 | #define ICTRL_EICE 0x08000000 /* enable icache parity errs */ | ||
287 | #define ICTRL_EDC 0x04000000 /* enable dcache parity errs */ | ||
288 | #define ICTRL_EICP 0x00000100 /* enable icache par. check */ | ||
289 | #define SPRN_IMISS 0x3D4 /* Instruction TLB Miss Register */ | ||
290 | #define SPRN_IMMR 0x27E /* Internal Memory Map Register */ | ||
291 | #define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */ | ||
292 | #define SPRN_L2CR2 0x3f8 | ||
293 | #define L2CR_L2E 0x80000000 /* L2 enable */ | ||
294 | #define L2CR_L2PE 0x40000000 /* L2 parity enable */ | ||
295 | #define L2CR_L2SIZ_MASK 0x30000000 /* L2 size mask */ | ||
296 | #define L2CR_L2SIZ_256KB 0x10000000 /* L2 size 256KB */ | ||
297 | #define L2CR_L2SIZ_512KB 0x20000000 /* L2 size 512KB */ | ||
298 | #define L2CR_L2SIZ_1MB 0x30000000 /* L2 size 1MB */ | ||
299 | #define L2CR_L2CLK_MASK 0x0e000000 /* L2 clock mask */ | ||
300 | #define L2CR_L2CLK_DISABLED 0x00000000 /* L2 clock disabled */ | ||
301 | #define L2CR_L2CLK_DIV1 0x02000000 /* L2 clock / 1 */ | ||
302 | #define L2CR_L2CLK_DIV1_5 0x04000000 /* L2 clock / 1.5 */ | ||
303 | #define L2CR_L2CLK_DIV2 0x08000000 /* L2 clock / 2 */ | ||
304 | #define L2CR_L2CLK_DIV2_5 0x0a000000 /* L2 clock / 2.5 */ | ||
305 | #define L2CR_L2CLK_DIV3 0x0c000000 /* L2 clock / 3 */ | ||
306 | #define L2CR_L2RAM_MASK 0x01800000 /* L2 RAM type mask */ | ||
307 | #define L2CR_L2RAM_FLOW 0x00000000 /* L2 RAM flow through */ | ||
308 | #define L2CR_L2RAM_PIPE 0x01000000 /* L2 RAM pipelined */ | ||
309 | #define L2CR_L2RAM_PIPE_LW 0x01800000 /* L2 RAM pipelined latewr */ | ||
310 | #define L2CR_L2DO 0x00400000 /* L2 data only */ | ||
311 | #define L2CR_L2I 0x00200000 /* L2 global invalidate */ | ||
312 | #define L2CR_L2CTL 0x00100000 /* L2 RAM control */ | ||
313 | #define L2CR_L2WT 0x00080000 /* L2 write-through */ | ||
314 | #define L2CR_L2TS 0x00040000 /* L2 test support */ | ||
315 | #define L2CR_L2OH_MASK 0x00030000 /* L2 output hold mask */ | ||
316 | #define L2CR_L2OH_0_5 0x00000000 /* L2 output hold 0.5 ns */ | ||
317 | #define L2CR_L2OH_1_0 0x00010000 /* L2 output hold 1.0 ns */ | ||
318 | #define L2CR_L2SL 0x00008000 /* L2 DLL slow */ | ||
319 | #define L2CR_L2DF 0x00004000 /* L2 differential clock */ | ||
320 | #define L2CR_L2BYP 0x00002000 /* L2 DLL bypass */ | ||
321 | #define L2CR_L2IP 0x00000001 /* L2 GI in progress */ | ||
322 | #define L2CR_L2IO_745x 0x00100000 /* L2 instr. only (745x) */ | ||
323 | #define L2CR_L2DO_745x 0x00010000 /* L2 data only (745x) */ | ||
324 | #define L2CR_L2REP_745x 0x00001000 /* L2 repl. algorithm (745x) */ | ||
325 | #define L2CR_L2HWF_745x 0x00000800 /* L2 hardware flush (745x) */ | ||
326 | #define SPRN_L3CR 0x3FA /* Level 3 Cache Control Regsiter */ | ||
327 | #define L3CR_L3E 0x80000000 /* L3 enable */ | ||
328 | #define L3CR_L3PE 0x40000000 /* L3 data parity enable */ | ||
329 | #define L3CR_L3APE 0x20000000 /* L3 addr parity enable */ | ||
330 | #define L3CR_L3SIZ 0x10000000 /* L3 size */ | ||
331 | #define L3CR_L3CLKEN 0x08000000 /* L3 clock enable */ | ||
332 | #define L3CR_L3RES 0x04000000 /* L3 special reserved bit */ | ||
333 | #define L3CR_L3CLKDIV 0x03800000 /* L3 clock divisor */ | ||
334 | #define L3CR_L3IO 0x00400000 /* L3 instruction only */ | ||
335 | #define L3CR_L3SPO 0x00040000 /* L3 sample point override */ | ||
336 | #define L3CR_L3CKSP 0x00030000 /* L3 clock sample point */ | ||
337 | #define L3CR_L3PSP 0x0000e000 /* L3 P-clock sample point */ | ||
338 | #define L3CR_L3REP 0x00001000 /* L3 replacement algorithm */ | ||
339 | #define L3CR_L3HWF 0x00000800 /* L3 hardware flush */ | ||
340 | #define L3CR_L3I 0x00000400 /* L3 global invalidate */ | ||
341 | #define L3CR_L3RT 0x00000300 /* L3 SRAM type */ | ||
342 | #define L3CR_L3NIRCA 0x00000080 /* L3 non-integer ratio clock adj. */ | ||
343 | #define L3CR_L3DO 0x00000040 /* L3 data only mode */ | ||
344 | #define L3CR_PMEN 0x00000004 /* L3 private memory enable */ | ||
345 | #define L3CR_PMSIZ 0x00000001 /* L3 private memory size */ | ||
346 | |||
347 | #define SPRN_MSSCR0 0x3f6 /* Memory Subsystem Control Register 0 */ | ||
348 | #define SPRN_MSSSR0 0x3f7 /* Memory Subsystem Status Register 1 */ | ||
349 | #define SPRN_LDSTCR 0x3f8 /* Load/Store control register */ | ||
350 | #define SPRN_LDSTDB 0x3f4 /* */ | ||
351 | #define SPRN_LR 0x008 /* Link Register */ | ||
352 | #ifndef SPRN_PIR | ||
353 | #define SPRN_PIR 0x3FF /* Processor Identification Register */ | ||
354 | #endif | ||
355 | #define SPRN_PTEHI 0x3D5 /* 981 7450 PTE HI word (S/W TLB load) */ | ||
356 | #define SPRN_PTELO 0x3D6 /* 982 7450 PTE LO word (S/W TLB load) */ | ||
357 | #define SPRN_PURR 0x135 /* Processor Utilization of Resources Reg */ | ||
358 | #define SPRN_PVR 0x11F /* Processor Version Register */ | ||
359 | #define SPRN_RPA 0x3D6 /* Required Physical Address Register */ | ||
360 | #define SPRN_SDA 0x3BF /* Sampled Data Address Register */ | ||
361 | #define SPRN_SDR1 0x019 /* MMU Hash Base Register */ | ||
362 | #define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */ | ||
363 | #define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */ | ||
364 | #define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */ | ||
365 | #define SPRN_SPRG2 0x112 /* Special Purpose Register General 2 */ | ||
366 | #define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */ | ||
367 | #define SPRN_SPRG4 0x114 /* Special Purpose Register General 4 */ | ||
368 | #define SPRN_SPRG5 0x115 /* Special Purpose Register General 5 */ | ||
369 | #define SPRN_SPRG6 0x116 /* Special Purpose Register General 6 */ | ||
370 | #define SPRN_SPRG7 0x117 /* Special Purpose Register General 7 */ | ||
371 | #define SPRN_SRR0 0x01A /* Save/Restore Register 0 */ | ||
372 | #define SPRN_SRR1 0x01B /* Save/Restore Register 1 */ | ||
373 | #ifndef SPRN_SVR | ||
374 | #define SPRN_SVR 0x11E /* System Version Register */ | ||
375 | #endif | ||
376 | #define SPRN_THRM1 0x3FC /* Thermal Management Register 1 */ | ||
377 | /* these bits were defined in inverted endian sense originally, ugh, confusing */ | ||
378 | #define THRM1_TIN (1 << 31) | ||
379 | #define THRM1_TIV (1 << 30) | ||
380 | #define THRM1_THRES(x) ((x&0x7f)<<23) | ||
381 | #define THRM3_SITV(x) ((x&0x3fff)<<1) | ||
382 | #define THRM1_TID (1<<2) | ||
383 | #define THRM1_TIE (1<<1) | ||
384 | #define THRM1_V (1<<0) | ||
385 | #define SPRN_THRM2 0x3FD /* Thermal Management Register 2 */ | ||
386 | #define SPRN_THRM3 0x3FE /* Thermal Management Register 3 */ | ||
387 | #define THRM3_E (1<<0) | ||
388 | #define SPRN_TLBMISS 0x3D4 /* 980 7450 TLB Miss Register */ | ||
389 | #define SPRN_UMMCR0 0x3A8 /* User Monitor Mode Control Register 0 */ | ||
390 | #define SPRN_UMMCR1 0x3AC /* User Monitor Mode Control Register 0 */ | ||
391 | #define SPRN_UPMC1 0x3A9 /* User Performance Counter Register 1 */ | ||
392 | #define SPRN_UPMC2 0x3AA /* User Performance Counter Register 2 */ | ||
393 | #define SPRN_UPMC3 0x3AD /* User Performance Counter Register 3 */ | ||
394 | #define SPRN_UPMC4 0x3AE /* User Performance Counter Register 4 */ | ||
395 | #define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ | ||
396 | #define SPRN_VRSAVE 0x100 /* Vector Register Save Register */ | ||
397 | #define SPRN_XER 0x001 /* Fixed Point Exception Register */ | ||
398 | |||
399 | /* Performance monitor SPRs */ | ||
400 | #ifdef CONFIG_PPC64 | ||
401 | #define SPRN_MMCR0 795 | ||
402 | #define MMCR0_FC 0x80000000UL /* freeze counters */ | ||
403 | #define MMCR0_FCS 0x40000000UL /* freeze in supervisor state */ | ||
404 | #define MMCR0_KERNEL_DISABLE MMCR0_FCS | ||
405 | #define MMCR0_FCP 0x20000000UL /* freeze in problem state */ | ||
406 | #define MMCR0_PROBLEM_DISABLE MMCR0_FCP | ||
407 | #define MMCR0_FCM1 0x10000000UL /* freeze counters while MSR mark = 1 */ | ||
408 | #define MMCR0_FCM0 0x08000000UL /* freeze counters while MSR mark = 0 */ | ||
409 | #define MMCR0_PMXE 0x04000000UL /* performance monitor exception enable */ | ||
410 | #define MMCR0_FCECE 0x02000000UL /* freeze ctrs on enabled cond or event */ | ||
411 | #define MMCR0_TBEE 0x00400000UL /* time base exception enable */ | ||
412 | #define MMCR0_PMC1CE 0x00008000UL /* PMC1 count enable*/ | ||
413 | #define MMCR0_PMCjCE 0x00004000UL /* PMCj count enable*/ | ||
414 | #define MMCR0_TRIGGER 0x00002000UL /* TRIGGER enable */ | ||
415 | #define MMCR0_PMAO 0x00000080UL /* performance monitor alert has occurred, set to 0 after handling exception */ | ||
416 | #define MMCR0_SHRFC 0x00000040UL /* SHRre freeze conditions between threads */ | ||
417 | #define MMCR0_FCTI 0x00000008UL /* freeze counters in tags inactive mode */ | ||
418 | #define MMCR0_FCTA 0x00000004UL /* freeze counters in tags active mode */ | ||
419 | #define MMCR0_FCWAIT 0x00000002UL /* freeze counter in WAIT state */ | ||
420 | #define MMCR0_FCHV 0x00000001UL /* freeze conditions in hypervisor mode */ | ||
421 | #define SPRN_MMCR1 798 | ||
422 | #define SPRN_MMCRA 0x312 | ||
423 | #define MMCRA_SIHV 0x10000000UL /* state of MSR HV when SIAR set */ | ||
424 | #define MMCRA_SIPR 0x08000000UL /* state of MSR PR when SIAR set */ | ||
425 | #define MMCRA_SAMPLE_ENABLE 0x00000001UL /* enable sampling */ | ||
426 | #define SPRN_PMC1 787 | ||
427 | #define SPRN_PMC2 788 | ||
428 | #define SPRN_PMC3 789 | ||
429 | #define SPRN_PMC4 790 | ||
430 | #define SPRN_PMC5 791 | ||
431 | #define SPRN_PMC6 792 | ||
432 | #define SPRN_PMC7 793 | ||
433 | #define SPRN_PMC8 794 | ||
434 | #define SPRN_SIAR 780 | ||
435 | #define SPRN_SDAR 781 | ||
436 | |||
437 | #else /* 32-bit */ | ||
438 | #define SPRN_MMCR0 0x3B8 /* Monitor Mode Control Register 0 */ | ||
439 | #define SPRN_MMCR1 0x3BC /* Monitor Mode Control Register 1 */ | ||
440 | #define SPRN_PMC1 0x3B9 /* Performance Counter Register 1 */ | ||
441 | #define SPRN_PMC2 0x3BA /* Performance Counter Register 2 */ | ||
442 | #define SPRN_PMC3 0x3BD /* Performance Counter Register 3 */ | ||
443 | #define SPRN_PMC4 0x3BE /* Performance Counter Register 4 */ | ||
444 | |||
445 | /* Bit definitions for MMCR0 and PMC1 / PMC2. */ | ||
446 | #define MMCR0_PMC1_CYCLES (1 << 7) | ||
447 | #define MMCR0_PMC1_ICACHEMISS (5 << 7) | ||
448 | #define MMCR0_PMC1_DTLB (6 << 7) | ||
449 | #define MMCR0_PMC2_DCACHEMISS 0x6 | ||
450 | #define MMCR0_PMC2_CYCLES 0x1 | ||
451 | #define MMCR0_PMC2_ITLB 0x7 | ||
452 | #define MMCR0_PMC2_LOADMISSTIME 0x5 | ||
453 | #define MMCR0_PMXE (1 << 26) | ||
454 | #endif | ||
455 | |||
456 | /* Processor Version Register (PVR) field extraction */ | ||
457 | |||
458 | #define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */ | ||
459 | #define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */ | ||
460 | |||
461 | #define __is_processor(pv) (PVR_VER(mfspr(SPRN_PVR)) == (pv)) | ||
462 | |||
463 | /* | ||
464 | * IBM has further subdivided the standard PowerPC 16-bit version and | ||
465 | * revision subfields of the PVR for the PowerPC 403s into the following: | ||
466 | */ | ||
467 | |||
468 | #define PVR_FAM(pvr) (((pvr) >> 20) & 0xFFF) /* Family field */ | ||
469 | #define PVR_MEM(pvr) (((pvr) >> 16) & 0xF) /* Member field */ | ||
470 | #define PVR_CORE(pvr) (((pvr) >> 12) & 0xF) /* Core field */ | ||
471 | #define PVR_CFG(pvr) (((pvr) >> 8) & 0xF) /* Configuration field */ | ||
472 | #define PVR_MAJ(pvr) (((pvr) >> 4) & 0xF) /* Major revision field */ | ||
473 | #define PVR_MIN(pvr) (((pvr) >> 0) & 0xF) /* Minor revision field */ | ||
474 | |||
475 | /* Processor Version Numbers */ | ||
476 | |||
477 | #define PVR_403GA 0x00200000 | ||
478 | #define PVR_403GB 0x00200100 | ||
479 | #define PVR_403GC 0x00200200 | ||
480 | #define PVR_403GCX 0x00201400 | ||
481 | #define PVR_405GP 0x40110000 | ||
482 | #define PVR_STB03XXX 0x40310000 | ||
483 | #define PVR_NP405H 0x41410000 | ||
484 | #define PVR_NP405L 0x41610000 | ||
485 | #define PVR_601 0x00010000 | ||
486 | #define PVR_602 0x00050000 | ||
487 | #define PVR_603 0x00030000 | ||
488 | #define PVR_603e 0x00060000 | ||
489 | #define PVR_603ev 0x00070000 | ||
490 | #define PVR_603r 0x00071000 | ||
491 | #define PVR_604 0x00040000 | ||
492 | #define PVR_604e 0x00090000 | ||
493 | #define PVR_604r 0x000A0000 | ||
494 | #define PVR_620 0x00140000 | ||
495 | #define PVR_740 0x00080000 | ||
496 | #define PVR_750 PVR_740 | ||
497 | #define PVR_740P 0x10080000 | ||
498 | #define PVR_750P PVR_740P | ||
499 | #define PVR_7400 0x000C0000 | ||
500 | #define PVR_7410 0x800C0000 | ||
501 | #define PVR_7450 0x80000000 | ||
502 | #define PVR_8540 0x80200000 | ||
503 | #define PVR_8560 0x80200000 | ||
504 | /* | ||
505 | * For the 8xx processors, all of them report the same PVR family for | ||
506 | * the PowerPC core. The various versions of these processors must be | ||
507 | * differentiated by the version number in the Communication Processor | ||
508 | * Module (CPM). | ||
509 | */ | ||
510 | #define PVR_821 0x00500000 | ||
511 | #define PVR_823 PVR_821 | ||
512 | #define PVR_850 PVR_821 | ||
513 | #define PVR_860 PVR_821 | ||
514 | #define PVR_8240 0x00810100 | ||
515 | #define PVR_8245 0x80811014 | ||
516 | #define PVR_8260 PVR_8240 | ||
517 | |||
518 | /* 64-bit processors */ | ||
519 | /* XXX the prefix should be PVR_, we'll do a global sweep to fix it one day */ | ||
520 | #define PV_NORTHSTAR 0x0033 | ||
521 | #define PV_PULSAR 0x0034 | ||
522 | #define PV_POWER4 0x0035 | ||
523 | #define PV_ICESTAR 0x0036 | ||
524 | #define PV_SSTAR 0x0037 | ||
525 | #define PV_POWER4p 0x0038 | ||
526 | #define PV_970 0x0039 | ||
527 | #define PV_POWER5 0x003A | ||
528 | #define PV_POWER5p 0x003B | ||
529 | #define PV_970FX 0x003C | ||
530 | #define PV_630 0x0040 | ||
531 | #define PV_630p 0x0041 | ||
532 | #define PV_970MP 0x0044 | ||
533 | #define PV_BE 0x0070 | ||
534 | |||
535 | /* | ||
536 | * Number of entries in the SLB. If this ever changes we should handle | ||
537 | * it with a use a cpu feature fixup. | ||
538 | */ | ||
539 | #define SLB_NUM_ENTRIES 64 | ||
540 | |||
541 | /* Macros for setting and retrieving special purpose registers */ | ||
542 | #ifndef __ASSEMBLY__ | ||
543 | #define mfmsr() ({unsigned long rval; \ | ||
544 | asm volatile("mfmsr %0" : "=r" (rval)); rval;}) | ||
545 | #ifdef CONFIG_PPC64 | ||
546 | #define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \ | ||
547 | : : "r" (v)) | ||
548 | #define mtmsrd(v) __mtmsrd((v), 0) | ||
549 | #define mtmsr(v) mtmsrd(v) | ||
550 | #else | ||
551 | #define mtmsr(v) asm volatile("mtmsr %0" : : "r" (v)) | ||
552 | #endif | ||
553 | |||
554 | #define mfspr(rn) ({unsigned long rval; \ | ||
555 | asm volatile("mfspr %0," __stringify(rn) \ | ||
556 | : "=r" (rval)); rval;}) | ||
557 | #define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v)) | ||
558 | |||
559 | #define mftb() ({unsigned long rval; \ | ||
560 | asm volatile("mftb %0" : "=r" (rval)); rval;}) | ||
561 | #define mftbl() ({unsigned long rval; \ | ||
562 | asm volatile("mftbl %0" : "=r" (rval)); rval;}) | ||
563 | |||
564 | #define mttbl(v) asm volatile("mttbl %0":: "r"(v)) | ||
565 | #define mttbu(v) asm volatile("mttbu %0":: "r"(v)) | ||
566 | |||
567 | #ifdef CONFIG_PPC32 | ||
568 | #define mfsrin(v) ({unsigned int rval; \ | ||
569 | asm volatile("mfsrin %0,%1" : "=r" (rval) : "r" (v)); \ | ||
570 | rval;}) | ||
571 | #endif | ||
572 | |||
573 | #define proc_trap() asm volatile("trap") | ||
574 | |||
575 | #ifdef CONFIG_PPC64 | ||
576 | static inline void ppc64_runlatch_on(void) | ||
577 | { | ||
578 | unsigned long ctrl; | ||
579 | |||
580 | if (cpu_has_feature(CPU_FTR_CTRL)) { | ||
581 | ctrl = mfspr(SPRN_CTRLF); | ||
582 | ctrl |= CTRL_RUNLATCH; | ||
583 | mtspr(SPRN_CTRLT, ctrl); | ||
584 | } | ||
585 | } | ||
586 | |||
587 | static inline void ppc64_runlatch_off(void) | ||
588 | { | ||
589 | unsigned long ctrl; | ||
590 | |||
591 | if (cpu_has_feature(CPU_FTR_CTRL)) { | ||
592 | ctrl = mfspr(SPRN_CTRLF); | ||
593 | ctrl &= ~CTRL_RUNLATCH; | ||
594 | mtspr(SPRN_CTRLT, ctrl); | ||
595 | } | ||
596 | } | ||
597 | #endif | ||
598 | |||
599 | #define __get_SP() ({unsigned long sp; \ | ||
600 | asm volatile("mr %0,1": "=r" (sp)); sp;}) | ||
601 | |||
602 | #else /* __ASSEMBLY__ */ | ||
603 | |||
604 | #define RUNLATCH_ON(REG) \ | ||
605 | BEGIN_FTR_SECTION \ | ||
606 | mfspr (REG),SPRN_CTRLF; \ | ||
607 | ori (REG),(REG),CTRL_RUNLATCH; \ | ||
608 | mtspr SPRN_CTRLT,(REG); \ | ||
609 | END_FTR_SECTION_IFSET(CPU_FTR_CTRL) | ||
610 | |||
611 | #endif /* __ASSEMBLY__ */ | ||
612 | #endif /* __KERNEL__ */ | ||
613 | #endif /* _ASM_POWERPC_REG_H */ | ||
diff --git a/include/asm-powerpc/rtas.h b/include/asm-powerpc/rtas.h new file mode 100644 index 000000000000..d1bb611ea626 --- /dev/null +++ b/include/asm-powerpc/rtas.h | |||
@@ -0,0 +1,232 @@ | |||
1 | #ifndef _POWERPC_RTAS_H | ||
2 | #define _POWERPC_RTAS_H | ||
3 | |||
4 | #include <linux/spinlock.h> | ||
5 | #include <asm/page.h> | ||
6 | |||
7 | /* | ||
8 | * Definitions for talking to the RTAS on CHRP machines. | ||
9 | * | ||
10 | * Copyright (C) 2001 Peter Bergner | ||
11 | * Copyright (C) 2001 PPC 64 Team, IBM Corp | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version | ||
16 | * 2 of the License, or (at your option) any later version. | ||
17 | */ | ||
18 | |||
19 | #define RTAS_UNKNOWN_SERVICE (-1) | ||
20 | #define RTAS_INSTANTIATE_MAX (1UL<<30) /* Don't instantiate rtas at/above this value */ | ||
21 | |||
22 | /* Buffer size for ppc_rtas system call. */ | ||
23 | #define RTAS_RMOBUF_MAX (64 * 1024) | ||
24 | |||
25 | /* RTAS return status codes */ | ||
26 | #define RTAS_BUSY -2 /* RTAS Busy */ | ||
27 | #define RTAS_EXTENDED_DELAY_MIN 9900 | ||
28 | #define RTAS_EXTENDED_DELAY_MAX 9905 | ||
29 | |||
30 | /* | ||
31 | * In general to call RTAS use rtas_token("string") to lookup | ||
32 | * an RTAS token for the given string (e.g. "event-scan"). | ||
33 | * To actually perform the call use | ||
34 | * ret = rtas_call(token, n_in, n_out, ...) | ||
35 | * Where n_in is the number of input parameters and | ||
36 | * n_out is the number of output parameters | ||
37 | * | ||
38 | * If the "string" is invalid on this system, RTAS_UNKNOWN_SERVICE | ||
39 | * will be returned as a token. rtas_call() does look for this | ||
40 | * token and error out gracefully so rtas_call(rtas_token("str"), ...) | ||
41 | * may be safely used for one-shot calls to RTAS. | ||
42 | * | ||
43 | */ | ||
44 | |||
45 | typedef u32 rtas_arg_t; | ||
46 | |||
47 | struct rtas_args { | ||
48 | u32 token; | ||
49 | u32 nargs; | ||
50 | u32 nret; | ||
51 | rtas_arg_t args[16]; | ||
52 | rtas_arg_t *rets; /* Pointer to return values in args[]. */ | ||
53 | }; | ||
54 | |||
55 | extern struct rtas_args rtas_stop_self_args; | ||
56 | |||
57 | struct rtas_t { | ||
58 | unsigned long entry; /* physical address pointer */ | ||
59 | unsigned long base; /* physical address pointer */ | ||
60 | unsigned long size; | ||
61 | spinlock_t lock; | ||
62 | struct rtas_args args; | ||
63 | struct device_node *dev; /* virtual address pointer */ | ||
64 | }; | ||
65 | |||
66 | /* RTAS event classes */ | ||
67 | #define RTAS_INTERNAL_ERROR 0x80000000 /* set bit 0 */ | ||
68 | #define RTAS_EPOW_WARNING 0x40000000 /* set bit 1 */ | ||
69 | #define RTAS_POWERMGM_EVENTS 0x20000000 /* set bit 2 */ | ||
70 | #define RTAS_HOTPLUG_EVENTS 0x10000000 /* set bit 3 */ | ||
71 | #define RTAS_EVENT_SCAN_ALL_EVENTS 0xf0000000 | ||
72 | |||
73 | /* RTAS event severity */ | ||
74 | #define RTAS_SEVERITY_FATAL 0x5 | ||
75 | #define RTAS_SEVERITY_ERROR 0x4 | ||
76 | #define RTAS_SEVERITY_ERROR_SYNC 0x3 | ||
77 | #define RTAS_SEVERITY_WARNING 0x2 | ||
78 | #define RTAS_SEVERITY_EVENT 0x1 | ||
79 | #define RTAS_SEVERITY_NO_ERROR 0x0 | ||
80 | |||
81 | /* RTAS event disposition */ | ||
82 | #define RTAS_DISP_FULLY_RECOVERED 0x0 | ||
83 | #define RTAS_DISP_LIMITED_RECOVERY 0x1 | ||
84 | #define RTAS_DISP_NOT_RECOVERED 0x2 | ||
85 | |||
86 | /* RTAS event initiator */ | ||
87 | #define RTAS_INITIATOR_UNKNOWN 0x0 | ||
88 | #define RTAS_INITIATOR_CPU 0x1 | ||
89 | #define RTAS_INITIATOR_PCI 0x2 | ||
90 | #define RTAS_INITIATOR_ISA 0x3 | ||
91 | #define RTAS_INITIATOR_MEMORY 0x4 | ||
92 | #define RTAS_INITIATOR_POWERMGM 0x5 | ||
93 | |||
94 | /* RTAS event target */ | ||
95 | #define RTAS_TARGET_UNKNOWN 0x0 | ||
96 | #define RTAS_TARGET_CPU 0x1 | ||
97 | #define RTAS_TARGET_PCI 0x2 | ||
98 | #define RTAS_TARGET_ISA 0x3 | ||
99 | #define RTAS_TARGET_MEMORY 0x4 | ||
100 | #define RTAS_TARGET_POWERMGM 0x5 | ||
101 | |||
102 | /* RTAS event type */ | ||
103 | #define RTAS_TYPE_RETRY 0x01 | ||
104 | #define RTAS_TYPE_TCE_ERR 0x02 | ||
105 | #define RTAS_TYPE_INTERN_DEV_FAIL 0x03 | ||
106 | #define RTAS_TYPE_TIMEOUT 0x04 | ||
107 | #define RTAS_TYPE_DATA_PARITY 0x05 | ||
108 | #define RTAS_TYPE_ADDR_PARITY 0x06 | ||
109 | #define RTAS_TYPE_CACHE_PARITY 0x07 | ||
110 | #define RTAS_TYPE_ADDR_INVALID 0x08 | ||
111 | #define RTAS_TYPE_ECC_UNCORR 0x09 | ||
112 | #define RTAS_TYPE_ECC_CORR 0x0a | ||
113 | #define RTAS_TYPE_EPOW 0x40 | ||
114 | #define RTAS_TYPE_PLATFORM 0xE0 | ||
115 | #define RTAS_TYPE_IO 0xE1 | ||
116 | #define RTAS_TYPE_INFO 0xE2 | ||
117 | #define RTAS_TYPE_DEALLOC 0xE3 | ||
118 | #define RTAS_TYPE_DUMP 0xE4 | ||
119 | /* I don't add PowerMGM events right now, this is a different topic */ | ||
120 | #define RTAS_TYPE_PMGM_POWER_SW_ON 0x60 | ||
121 | #define RTAS_TYPE_PMGM_POWER_SW_OFF 0x61 | ||
122 | #define RTAS_TYPE_PMGM_LID_OPEN 0x62 | ||
123 | #define RTAS_TYPE_PMGM_LID_CLOSE 0x63 | ||
124 | #define RTAS_TYPE_PMGM_SLEEP_BTN 0x64 | ||
125 | #define RTAS_TYPE_PMGM_WAKE_BTN 0x65 | ||
126 | #define RTAS_TYPE_PMGM_BATTERY_WARN 0x66 | ||
127 | #define RTAS_TYPE_PMGM_BATTERY_CRIT 0x67 | ||
128 | #define RTAS_TYPE_PMGM_SWITCH_TO_BAT 0x68 | ||
129 | #define RTAS_TYPE_PMGM_SWITCH_TO_AC 0x69 | ||
130 | #define RTAS_TYPE_PMGM_KBD_OR_MOUSE 0x6a | ||
131 | #define RTAS_TYPE_PMGM_ENCLOS_OPEN 0x6b | ||
132 | #define RTAS_TYPE_PMGM_ENCLOS_CLOSED 0x6c | ||
133 | #define RTAS_TYPE_PMGM_RING_INDICATE 0x6d | ||
134 | #define RTAS_TYPE_PMGM_LAN_ATTENTION 0x6e | ||
135 | #define RTAS_TYPE_PMGM_TIME_ALARM 0x6f | ||
136 | #define RTAS_TYPE_PMGM_CONFIG_CHANGE 0x70 | ||
137 | #define RTAS_TYPE_PMGM_SERVICE_PROC 0x71 | ||
138 | |||
139 | struct rtas_error_log { | ||
140 | unsigned long version:8; /* Architectural version */ | ||
141 | unsigned long severity:3; /* Severity level of error */ | ||
142 | unsigned long disposition:2; /* Degree of recovery */ | ||
143 | unsigned long extended:1; /* extended log present? */ | ||
144 | unsigned long /* reserved */ :2; /* Reserved for future use */ | ||
145 | unsigned long initiator:4; /* Initiator of event */ | ||
146 | unsigned long target:4; /* Target of failed operation */ | ||
147 | unsigned long type:8; /* General event or error*/ | ||
148 | unsigned long extended_log_length:32; /* length in bytes */ | ||
149 | unsigned char buffer[1]; | ||
150 | }; | ||
151 | |||
152 | /* | ||
153 | * This can be set by the rtas_flash module so that it can get called | ||
154 | * as the absolutely last thing before the kernel terminates. | ||
155 | */ | ||
156 | extern void (*rtas_flash_term_hook)(int); | ||
157 | |||
158 | extern struct rtas_t rtas; | ||
159 | |||
160 | extern void enter_rtas(unsigned long); | ||
161 | extern int rtas_token(const char *service); | ||
162 | extern int rtas_call(int token, int, int, int *, ...); | ||
163 | extern void call_rtas_display_status(unsigned char); | ||
164 | extern void rtas_restart(char *cmd); | ||
165 | extern void rtas_power_off(void); | ||
166 | extern void rtas_halt(void); | ||
167 | extern void rtas_os_term(char *str); | ||
168 | extern int rtas_get_sensor(int sensor, int index, int *state); | ||
169 | extern int rtas_get_power_level(int powerdomain, int *level); | ||
170 | extern int rtas_set_power_level(int powerdomain, int level, int *setlevel); | ||
171 | extern int rtas_set_indicator(int indicator, int index, int new_value); | ||
172 | extern void rtas_progress(char *s, unsigned short hex); | ||
173 | extern void rtas_initialize(void); | ||
174 | |||
175 | struct rtc_time; | ||
176 | extern unsigned long rtas_get_boot_time(void); | ||
177 | extern void rtas_get_rtc_time(struct rtc_time *rtc_time); | ||
178 | extern int rtas_set_rtc_time(struct rtc_time *rtc_time); | ||
179 | |||
180 | /* Given an RTAS status code of 9900..9905 compute the hinted delay */ | ||
181 | unsigned int rtas_extended_busy_delay_time(int status); | ||
182 | static inline int rtas_is_extended_busy(int status) | ||
183 | { | ||
184 | return status >= 9900 && status <= 9909; | ||
185 | } | ||
186 | |||
187 | extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal); | ||
188 | |||
189 | /* Error types logged. */ | ||
190 | #define ERR_FLAG_ALREADY_LOGGED 0x0 | ||
191 | #define ERR_FLAG_BOOT 0x1 /* log was pulled from NVRAM on boot */ | ||
192 | #define ERR_TYPE_RTAS_LOG 0x2 /* from rtas event-scan */ | ||
193 | #define ERR_TYPE_KERNEL_PANIC 0x4 /* from panic() */ | ||
194 | |||
195 | /* All the types and not flags */ | ||
196 | #define ERR_TYPE_MASK (ERR_TYPE_RTAS_LOG | ERR_TYPE_KERNEL_PANIC) | ||
197 | |||
198 | #define RTAS_DEBUG KERN_DEBUG "RTAS: " | ||
199 | |||
200 | #define RTAS_ERROR_LOG_MAX 2048 | ||
201 | |||
202 | /* | ||
203 | * Return the firmware-specified size of the error log buffer | ||
204 | * for all rtas calls that require an error buffer argument. | ||
205 | * This includes 'check-exception' and 'rtas-last-error'. | ||
206 | */ | ||
207 | extern int rtas_get_error_log_max(void); | ||
208 | |||
209 | /* Event Scan Parameters */ | ||
210 | #define EVENT_SCAN_ALL_EVENTS 0xf0000000 | ||
211 | #define SURVEILLANCE_TOKEN 9000 | ||
212 | #define LOG_NUMBER 64 /* must be a power of two */ | ||
213 | #define LOG_NUMBER_MASK (LOG_NUMBER-1) | ||
214 | |||
215 | /* Some RTAS ops require a data buffer and that buffer must be < 4G. | ||
216 | * Rather than having a memory allocator, just use this buffer | ||
217 | * (get the lock first), make the RTAS call. Copy the data instead | ||
218 | * of holding the buffer for long. | ||
219 | */ | ||
220 | |||
221 | #define RTAS_DATA_BUF_SIZE 4096 | ||
222 | extern spinlock_t rtas_data_buf_lock; | ||
223 | extern char rtas_data_buf[RTAS_DATA_BUF_SIZE]; | ||
224 | |||
225 | extern void rtas_stop_self(void); | ||
226 | |||
227 | /* RMO buffer reserved for user-space RTAS use */ | ||
228 | extern unsigned long rtas_rmo_buf; | ||
229 | |||
230 | #define GLOBAL_INTERRUPT_QUEUE 9005 | ||
231 | |||
232 | #endif /* _POWERPC_RTAS_H */ | ||
diff --git a/include/asm-powerpc/rtc.h b/include/asm-powerpc/rtc.h new file mode 100644 index 000000000000..f5802926b6c0 --- /dev/null +++ b/include/asm-powerpc/rtc.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * Real-time clock definitions and interfaces | ||
3 | * | ||
4 | * Author: Tom Rini <trini@mvista.com> | ||
5 | * | ||
6 | * 2002 (c) MontaVista, Software, Inc. This file is licensed under | ||
7 | * the terms of the GNU General Public License version 2. This program | ||
8 | * is licensed "as is" without any warranty of any kind, whether express | ||
9 | * or implied. | ||
10 | * | ||
11 | * Based on: | ||
12 | * include/asm-m68k/rtc.h | ||
13 | * | ||
14 | * Copyright Richard Zidlicky | ||
15 | * implementation details for genrtc/q40rtc driver | ||
16 | * | ||
17 | * And the old drivers/macintosh/rtc.c which was heavily based on: | ||
18 | * Linux/SPARC Real Time Clock Driver | ||
19 | * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu) | ||
20 | * | ||
21 | * With additional work by Paul Mackerras and Franz Sirl. | ||
22 | */ | ||
23 | |||
24 | #ifndef __ASM_POWERPC_RTC_H__ | ||
25 | #define __ASM_POWERPC_RTC_H__ | ||
26 | |||
27 | #ifdef __KERNEL__ | ||
28 | |||
29 | #include <linux/rtc.h> | ||
30 | |||
31 | #include <asm/machdep.h> | ||
32 | #include <asm/time.h> | ||
33 | |||
34 | #define RTC_PIE 0x40 /* periodic interrupt enable */ | ||
35 | #define RTC_AIE 0x20 /* alarm interrupt enable */ | ||
36 | #define RTC_UIE 0x10 /* update-finished interrupt enable */ | ||
37 | |||
38 | /* some dummy definitions */ | ||
39 | #define RTC_BATT_BAD 0x100 /* battery bad */ | ||
40 | #define RTC_SQWE 0x08 /* enable square-wave output */ | ||
41 | #define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ | ||
42 | #define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ | ||
43 | #define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ | ||
44 | |||
45 | static inline unsigned int get_rtc_time(struct rtc_time *time) | ||
46 | { | ||
47 | if (ppc_md.get_rtc_time) | ||
48 | ppc_md.get_rtc_time(time); | ||
49 | return RTC_24H; | ||
50 | } | ||
51 | |||
52 | /* Set the current date and time in the real time clock. */ | ||
53 | static inline int set_rtc_time(struct rtc_time *time) | ||
54 | { | ||
55 | if (ppc_md.set_rtc_time) | ||
56 | return ppc_md.set_rtc_time(time); | ||
57 | return -EINVAL; | ||
58 | } | ||
59 | |||
60 | static inline unsigned int get_rtc_ss(void) | ||
61 | { | ||
62 | struct rtc_time h; | ||
63 | |||
64 | get_rtc_time(&h); | ||
65 | return h.tm_sec; | ||
66 | } | ||
67 | |||
68 | static inline int get_rtc_pll(struct rtc_pll_info *pll) | ||
69 | { | ||
70 | return -EINVAL; | ||
71 | } | ||
72 | static inline int set_rtc_pll(struct rtc_pll_info *pll) | ||
73 | { | ||
74 | return -EINVAL; | ||
75 | } | ||
76 | |||
77 | #endif /* __KERNEL__ */ | ||
78 | #endif /* __ASM_POWERPC_RTC_H__ */ | ||
diff --git a/include/asm-powerpc/rwsem.h b/include/asm-powerpc/rwsem.h new file mode 100644 index 000000000000..79bae4933b73 --- /dev/null +++ b/include/asm-powerpc/rwsem.h | |||
@@ -0,0 +1,168 @@ | |||
1 | #ifndef _ASM_POWERPC_RWSEM_H | ||
2 | #define _ASM_POWERPC_RWSEM_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | /* | ||
7 | * include/asm-ppc64/rwsem.h: R/W semaphores for PPC using the stuff | ||
8 | * in lib/rwsem.c. Adapted largely from include/asm-i386/rwsem.h | ||
9 | * by Paul Mackerras <paulus@samba.org>. | ||
10 | */ | ||
11 | |||
12 | #include <linux/list.h> | ||
13 | #include <linux/spinlock.h> | ||
14 | #include <asm/atomic.h> | ||
15 | #include <asm/system.h> | ||
16 | |||
17 | /* | ||
18 | * the semaphore definition | ||
19 | */ | ||
20 | struct rw_semaphore { | ||
21 | /* XXX this should be able to be an atomic_t -- paulus */ | ||
22 | signed int count; | ||
23 | #define RWSEM_UNLOCKED_VALUE 0x00000000 | ||
24 | #define RWSEM_ACTIVE_BIAS 0x00000001 | ||
25 | #define RWSEM_ACTIVE_MASK 0x0000ffff | ||
26 | #define RWSEM_WAITING_BIAS (-0x00010000) | ||
27 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS | ||
28 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) | ||
29 | spinlock_t wait_lock; | ||
30 | struct list_head wait_list; | ||
31 | #if RWSEM_DEBUG | ||
32 | int debug; | ||
33 | #endif | ||
34 | }; | ||
35 | |||
36 | /* | ||
37 | * initialisation | ||
38 | */ | ||
39 | #if RWSEM_DEBUG | ||
40 | #define __RWSEM_DEBUG_INIT , 0 | ||
41 | #else | ||
42 | #define __RWSEM_DEBUG_INIT /* */ | ||
43 | #endif | ||
44 | |||
45 | #define __RWSEM_INITIALIZER(name) \ | ||
46 | { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \ | ||
47 | LIST_HEAD_INIT((name).wait_list) \ | ||
48 | __RWSEM_DEBUG_INIT } | ||
49 | |||
50 | #define DECLARE_RWSEM(name) \ | ||
51 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
52 | |||
53 | extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem); | ||
54 | extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem); | ||
55 | extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); | ||
56 | extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); | ||
57 | |||
58 | static inline void init_rwsem(struct rw_semaphore *sem) | ||
59 | { | ||
60 | sem->count = RWSEM_UNLOCKED_VALUE; | ||
61 | spin_lock_init(&sem->wait_lock); | ||
62 | INIT_LIST_HEAD(&sem->wait_list); | ||
63 | #if RWSEM_DEBUG | ||
64 | sem->debug = 0; | ||
65 | #endif | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * lock for reading | ||
70 | */ | ||
71 | static inline void __down_read(struct rw_semaphore *sem) | ||
72 | { | ||
73 | if (unlikely(atomic_inc_return((atomic_t *)(&sem->count)) <= 0)) | ||
74 | rwsem_down_read_failed(sem); | ||
75 | } | ||
76 | |||
77 | static inline int __down_read_trylock(struct rw_semaphore *sem) | ||
78 | { | ||
79 | int tmp; | ||
80 | |||
81 | while ((tmp = sem->count) >= 0) { | ||
82 | if (tmp == cmpxchg(&sem->count, tmp, | ||
83 | tmp + RWSEM_ACTIVE_READ_BIAS)) { | ||
84 | return 1; | ||
85 | } | ||
86 | } | ||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | /* | ||
91 | * lock for writing | ||
92 | */ | ||
93 | static inline void __down_write(struct rw_semaphore *sem) | ||
94 | { | ||
95 | int tmp; | ||
96 | |||
97 | tmp = atomic_add_return(RWSEM_ACTIVE_WRITE_BIAS, | ||
98 | (atomic_t *)(&sem->count)); | ||
99 | if (unlikely(tmp != RWSEM_ACTIVE_WRITE_BIAS)) | ||
100 | rwsem_down_write_failed(sem); | ||
101 | } | ||
102 | |||
103 | static inline int __down_write_trylock(struct rw_semaphore *sem) | ||
104 | { | ||
105 | int tmp; | ||
106 | |||
107 | tmp = cmpxchg(&sem->count, RWSEM_UNLOCKED_VALUE, | ||
108 | RWSEM_ACTIVE_WRITE_BIAS); | ||
109 | return tmp == RWSEM_UNLOCKED_VALUE; | ||
110 | } | ||
111 | |||
112 | /* | ||
113 | * unlock after reading | ||
114 | */ | ||
115 | static inline void __up_read(struct rw_semaphore *sem) | ||
116 | { | ||
117 | int tmp; | ||
118 | |||
119 | tmp = atomic_dec_return((atomic_t *)(&sem->count)); | ||
120 | if (unlikely(tmp < -1 && (tmp & RWSEM_ACTIVE_MASK) == 0)) | ||
121 | rwsem_wake(sem); | ||
122 | } | ||
123 | |||
124 | /* | ||
125 | * unlock after writing | ||
126 | */ | ||
127 | static inline void __up_write(struct rw_semaphore *sem) | ||
128 | { | ||
129 | if (unlikely(atomic_sub_return(RWSEM_ACTIVE_WRITE_BIAS, | ||
130 | (atomic_t *)(&sem->count)) < 0)) | ||
131 | rwsem_wake(sem); | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | * implement atomic add functionality | ||
136 | */ | ||
137 | static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem) | ||
138 | { | ||
139 | atomic_add(delta, (atomic_t *)(&sem->count)); | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * downgrade write lock to read lock | ||
144 | */ | ||
145 | static inline void __downgrade_write(struct rw_semaphore *sem) | ||
146 | { | ||
147 | int tmp; | ||
148 | |||
149 | tmp = atomic_add_return(-RWSEM_WAITING_BIAS, (atomic_t *)(&sem->count)); | ||
150 | if (tmp < 0) | ||
151 | rwsem_downgrade_wake(sem); | ||
152 | } | ||
153 | |||
154 | /* | ||
155 | * implement exchange and add functionality | ||
156 | */ | ||
157 | static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) | ||
158 | { | ||
159 | return atomic_add_return(delta, (atomic_t *)(&sem->count)); | ||
160 | } | ||
161 | |||
162 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
163 | { | ||
164 | return (sem->count != 0); | ||
165 | } | ||
166 | |||
167 | #endif /* __KERNEL__ */ | ||
168 | #endif /* _ASM_POWERPC_RWSEM_H */ | ||
diff --git a/include/asm-powerpc/scatterlist.h b/include/asm-powerpc/scatterlist.h new file mode 100644 index 000000000000..8c992d1491d4 --- /dev/null +++ b/include/asm-powerpc/scatterlist.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef _ASM_POWERPC_SCATTERLIST_H | ||
2 | #define _ASM_POWERPC_SCATTERLIST_H | ||
3 | /* | ||
4 | * Copyright (C) 2001 PPC64 Team, IBM Corp | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifdef __KERNEL__ | ||
13 | #include <linux/types.h> | ||
14 | #include <asm/dma.h> | ||
15 | |||
16 | struct scatterlist { | ||
17 | struct page *page; | ||
18 | unsigned int offset; | ||
19 | unsigned int length; | ||
20 | |||
21 | /* For TCE support */ | ||
22 | dma_addr_t dma_address; | ||
23 | u32 dma_length; | ||
24 | }; | ||
25 | |||
26 | /* | ||
27 | * These macros should be used after a dma_map_sg call has been done | ||
28 | * to get bus addresses of each of the SG entries and their lengths. | ||
29 | * You should only work with the number of sg entries pci_map_sg | ||
30 | * returns, or alternatively stop on the first sg_dma_len(sg) which | ||
31 | * is 0. | ||
32 | */ | ||
33 | #define sg_dma_address(sg) ((sg)->dma_address) | ||
34 | #ifdef __powerpc64__ | ||
35 | #define sg_dma_len(sg) ((sg)->dma_length) | ||
36 | #else | ||
37 | #define sg_dma_len(sg) ((sg)->length) | ||
38 | #endif | ||
39 | |||
40 | #ifdef __powerpc64__ | ||
41 | #define ISA_DMA_THRESHOLD (~0UL) | ||
42 | #endif | ||
43 | |||
44 | #endif /* __KERNEL__ */ | ||
45 | #endif /* _ASM_POWERPC_SCATTERLIST_H */ | ||
diff --git a/include/asm-powerpc/seccomp.h b/include/asm-powerpc/seccomp.h new file mode 100644 index 000000000000..1e1cfe12882b --- /dev/null +++ b/include/asm-powerpc/seccomp.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _ASM_POWERPC_SECCOMP_H | ||
2 | |||
3 | #include <linux/thread_info.h> | ||
4 | #include <linux/unistd.h> | ||
5 | |||
6 | #define __NR_seccomp_read __NR_read | ||
7 | #define __NR_seccomp_write __NR_write | ||
8 | #define __NR_seccomp_exit __NR_exit | ||
9 | #define __NR_seccomp_sigreturn __NR_rt_sigreturn | ||
10 | |||
11 | #define __NR_seccomp_read_32 __NR_read | ||
12 | #define __NR_seccomp_write_32 __NR_write | ||
13 | #define __NR_seccomp_exit_32 __NR_exit | ||
14 | #define __NR_seccomp_sigreturn_32 __NR_sigreturn | ||
15 | |||
16 | #endif /* _ASM_POWERPC_SECCOMP_H */ | ||
diff --git a/include/asm-powerpc/sections.h b/include/asm-powerpc/sections.h new file mode 100644 index 000000000000..47be2ac2a925 --- /dev/null +++ b/include/asm-powerpc/sections.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _ASM_POWERPC_SECTIONS_H | ||
2 | #define _ASM_POWERPC_SECTIONS_H | ||
3 | |||
4 | #include <asm-generic/sections.h> | ||
5 | |||
6 | #ifdef __powerpc64__ | ||
7 | |||
8 | extern char _end[]; | ||
9 | |||
10 | static inline int in_kernel_text(unsigned long addr) | ||
11 | { | ||
12 | if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end) | ||
13 | return 1; | ||
14 | |||
15 | return 0; | ||
16 | } | ||
17 | |||
18 | #endif | ||
19 | |||
20 | #endif /* _ASM_POWERPC_SECTIONS_H */ | ||
diff --git a/include/asm-powerpc/semaphore.h b/include/asm-powerpc/semaphore.h new file mode 100644 index 000000000000..57369d2cadef --- /dev/null +++ b/include/asm-powerpc/semaphore.h | |||
@@ -0,0 +1,95 @@ | |||
1 | #ifndef _ASM_POWERPC_SEMAPHORE_H | ||
2 | #define _ASM_POWERPC_SEMAPHORE_H | ||
3 | |||
4 | /* | ||
5 | * Remove spinlock-based RW semaphores; RW semaphore definitions are | ||
6 | * now in rwsem.h and we use the generic lib/rwsem.c implementation. | ||
7 | * Rework semaphores to use atomic_dec_if_positive. | ||
8 | * -- Paul Mackerras (paulus@samba.org) | ||
9 | */ | ||
10 | |||
11 | #ifdef __KERNEL__ | ||
12 | |||
13 | #include <asm/atomic.h> | ||
14 | #include <asm/system.h> | ||
15 | #include <linux/wait.h> | ||
16 | #include <linux/rwsem.h> | ||
17 | |||
18 | struct semaphore { | ||
19 | /* | ||
20 | * Note that any negative value of count is equivalent to 0, | ||
21 | * but additionally indicates that some process(es) might be | ||
22 | * sleeping on `wait'. | ||
23 | */ | ||
24 | atomic_t count; | ||
25 | wait_queue_head_t wait; | ||
26 | }; | ||
27 | |||
28 | #define __SEMAPHORE_INITIALIZER(name, n) \ | ||
29 | { \ | ||
30 | .count = ATOMIC_INIT(n), \ | ||
31 | .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \ | ||
32 | } | ||
33 | |||
34 | #define __DECLARE_SEMAPHORE_GENERIC(name, count) \ | ||
35 | struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) | ||
36 | |||
37 | #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1) | ||
38 | #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name, 0) | ||
39 | |||
40 | static inline void sema_init (struct semaphore *sem, int val) | ||
41 | { | ||
42 | atomic_set(&sem->count, val); | ||
43 | init_waitqueue_head(&sem->wait); | ||
44 | } | ||
45 | |||
46 | static inline void init_MUTEX (struct semaphore *sem) | ||
47 | { | ||
48 | sema_init(sem, 1); | ||
49 | } | ||
50 | |||
51 | static inline void init_MUTEX_LOCKED (struct semaphore *sem) | ||
52 | { | ||
53 | sema_init(sem, 0); | ||
54 | } | ||
55 | |||
56 | extern void __down(struct semaphore * sem); | ||
57 | extern int __down_interruptible(struct semaphore * sem); | ||
58 | extern void __up(struct semaphore * sem); | ||
59 | |||
60 | static inline void down(struct semaphore * sem) | ||
61 | { | ||
62 | might_sleep(); | ||
63 | |||
64 | /* | ||
65 | * Try to get the semaphore, take the slow path if we fail. | ||
66 | */ | ||
67 | if (unlikely(atomic_dec_return(&sem->count) < 0)) | ||
68 | __down(sem); | ||
69 | } | ||
70 | |||
71 | static inline int down_interruptible(struct semaphore * sem) | ||
72 | { | ||
73 | int ret = 0; | ||
74 | |||
75 | might_sleep(); | ||
76 | |||
77 | if (unlikely(atomic_dec_return(&sem->count) < 0)) | ||
78 | ret = __down_interruptible(sem); | ||
79 | return ret; | ||
80 | } | ||
81 | |||
82 | static inline int down_trylock(struct semaphore * sem) | ||
83 | { | ||
84 | return atomic_dec_if_positive(&sem->count) < 0; | ||
85 | } | ||
86 | |||
87 | static inline void up(struct semaphore * sem) | ||
88 | { | ||
89 | if (unlikely(atomic_inc_return(&sem->count) <= 0)) | ||
90 | __up(sem); | ||
91 | } | ||
92 | |||
93 | #endif /* __KERNEL__ */ | ||
94 | |||
95 | #endif /* _ASM_POWERPC_SEMAPHORE_H */ | ||
diff --git a/include/asm-powerpc/sigcontext.h b/include/asm-powerpc/sigcontext.h new file mode 100644 index 000000000000..165d630e1cf3 --- /dev/null +++ b/include/asm-powerpc/sigcontext.h | |||
@@ -0,0 +1,52 @@ | |||
1 | #ifndef _ASM_POWERPC_SIGCONTEXT_H | ||
2 | #define _ASM_POWERPC_SIGCONTEXT_H | ||
3 | |||
4 | /* | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | #include <linux/compiler.h> | ||
11 | #include <asm/ptrace.h> | ||
12 | #ifdef __powerpc64__ | ||
13 | #include <asm/elf.h> | ||
14 | #endif | ||
15 | |||
16 | struct sigcontext { | ||
17 | unsigned long _unused[4]; | ||
18 | int signal; | ||
19 | #ifdef __powerpc64__ | ||
20 | int _pad0; | ||
21 | #endif | ||
22 | unsigned long handler; | ||
23 | unsigned long oldmask; | ||
24 | struct pt_regs __user *regs; | ||
25 | #ifdef __powerpc64__ | ||
26 | elf_gregset_t gp_regs; | ||
27 | elf_fpregset_t fp_regs; | ||
28 | /* | ||
29 | * To maintain compatibility with current implementations the sigcontext is | ||
30 | * extended by appending a pointer (v_regs) to a quadword type (elf_vrreg_t) | ||
31 | * followed by an unstructured (vmx_reserve) field of 69 doublewords. This | ||
32 | * allows the array of vector registers to be quadword aligned independent of | ||
33 | * the alignment of the containing sigcontext or ucontext. It is the | ||
34 | * responsibility of the code setting the sigcontext to set this pointer to | ||
35 | * either NULL (if this processor does not support the VMX feature) or the | ||
36 | * address of the first quadword within the allocated (vmx_reserve) area. | ||
37 | * | ||
38 | * The pointer (v_regs) of vector type (elf_vrreg_t) is type compatible with | ||
39 | * an array of 34 quadword entries (elf_vrregset_t). The entries with | ||
40 | * indexes 0-31 contain the corresponding vector registers. The entry with | ||
41 | * index 32 contains the vscr as the last word (offset 12) within the | ||
42 | * quadword. This allows the vscr to be stored as either a quadword (since | ||
43 | * it must be copied via a vector register to/from storage) or as a word. | ||
44 | * The entry with index 33 contains the vrsave as the first word (offset 0) | ||
45 | * within the quadword. | ||
46 | */ | ||
47 | elf_vrreg_t __user *v_regs; | ||
48 | long vmx_reserve[ELF_NVRREG+ELF_NVRREG+1]; | ||
49 | #endif | ||
50 | }; | ||
51 | |||
52 | #endif /* _ASM_POWERPC_SIGCONTEXT_H */ | ||
diff --git a/include/asm-powerpc/smp.h b/include/asm-powerpc/smp.h new file mode 100644 index 000000000000..8bcdd0faefea --- /dev/null +++ b/include/asm-powerpc/smp.h | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | * smp.h: PowerPC-specific SMP code. | ||
3 | * | ||
4 | * Original was a copy of sparc smp.h. Now heavily modified | ||
5 | * for PPC. | ||
6 | * | ||
7 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) | ||
8 | * Copyright (C) 1996-2001 Cort Dougan <cort@fsmlabs.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | */ | ||
15 | |||
16 | #ifndef _ASM_POWERPC_SMP_H | ||
17 | #define _ASM_POWERPC_SMP_H | ||
18 | #ifdef __KERNEL__ | ||
19 | |||
20 | #include <linux/config.h> | ||
21 | #include <linux/threads.h> | ||
22 | #include <linux/cpumask.h> | ||
23 | #include <linux/kernel.h> | ||
24 | |||
25 | #ifndef __ASSEMBLY__ | ||
26 | |||
27 | #ifdef CONFIG_PPC64 | ||
28 | #include <asm/paca.h> | ||
29 | #endif | ||
30 | |||
31 | extern int boot_cpuid; | ||
32 | extern int boot_cpuid_phys; | ||
33 | |||
34 | extern void cpu_die(void); | ||
35 | |||
36 | #ifdef CONFIG_SMP | ||
37 | |||
38 | extern void smp_send_debugger_break(int cpu); | ||
39 | struct pt_regs; | ||
40 | extern void smp_message_recv(int, struct pt_regs *); | ||
41 | |||
42 | #ifdef CONFIG_HOTPLUG_CPU | ||
43 | extern void fixup_irqs(cpumask_t map); | ||
44 | int generic_cpu_disable(void); | ||
45 | int generic_cpu_enable(unsigned int cpu); | ||
46 | void generic_cpu_die(unsigned int cpu); | ||
47 | void generic_mach_cpu_die(void); | ||
48 | #endif | ||
49 | |||
50 | #ifdef CONFIG_PPC64 | ||
51 | #define raw_smp_processor_id() (get_paca()->paca_index) | ||
52 | #define hard_smp_processor_id() (get_paca()->hw_cpu_id) | ||
53 | #else | ||
54 | /* 32-bit */ | ||
55 | extern int smp_hw_index[]; | ||
56 | |||
57 | #define raw_smp_processor_id() (current_thread_info()->cpu) | ||
58 | #define hard_smp_processor_id() (smp_hw_index[smp_processor_id()]) | ||
59 | #define get_hard_smp_processor_id(cpu) (smp_hw_index[(cpu)]) | ||
60 | #define set_hard_smp_processor_id(cpu, phys)\ | ||
61 | (smp_hw_index[(cpu)] = (phys)) | ||
62 | #endif | ||
63 | |||
64 | extern cpumask_t cpu_sibling_map[NR_CPUS]; | ||
65 | |||
66 | /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers. | ||
67 | * | ||
68 | * Make sure this matches openpic_request_IPIs in open_pic.c, or what shows up | ||
69 | * in /proc/interrupts will be wrong!!! --Troy */ | ||
70 | #define PPC_MSG_CALL_FUNCTION 0 | ||
71 | #define PPC_MSG_RESCHEDULE 1 | ||
72 | /* This is unused now */ | ||
73 | #if 0 | ||
74 | #define PPC_MSG_MIGRATE_TASK 2 | ||
75 | #endif | ||
76 | #define PPC_MSG_DEBUGGER_BREAK 3 | ||
77 | |||
78 | void smp_init_iSeries(void); | ||
79 | void smp_init_pSeries(void); | ||
80 | void smp_init_cell(void); | ||
81 | void smp_setup_cpu_maps(void); | ||
82 | |||
83 | extern int __cpu_disable(void); | ||
84 | extern void __cpu_die(unsigned int cpu); | ||
85 | |||
86 | #else | ||
87 | /* for UP */ | ||
88 | #define smp_setup_cpu_maps() | ||
89 | #define smp_release_cpus() | ||
90 | |||
91 | #endif /* CONFIG_SMP */ | ||
92 | |||
93 | #ifdef CONFIG_PPC64 | ||
94 | #define get_hard_smp_processor_id(CPU) (paca[(CPU)].hw_cpu_id) | ||
95 | #define set_hard_smp_processor_id(CPU, VAL) \ | ||
96 | do { (paca[(CPU)].hw_cpu_id = (VAL)); } while (0) | ||
97 | #else | ||
98 | /* 32-bit */ | ||
99 | #ifndef CONFIG_SMP | ||
100 | #define get_hard_smp_processor_id(cpu) boot_cpuid_phys | ||
101 | #define set_hard_smp_processor_id(cpu, phys) | ||
102 | #endif | ||
103 | #endif | ||
104 | |||
105 | extern int smt_enabled_at_boot; | ||
106 | |||
107 | extern int smp_mpic_probe(void); | ||
108 | extern void smp_mpic_setup_cpu(int cpu); | ||
109 | extern void smp_generic_kick_cpu(int nr); | ||
110 | |||
111 | extern void smp_generic_give_timebase(void); | ||
112 | extern void smp_generic_take_timebase(void); | ||
113 | |||
114 | extern struct smp_ops_t *smp_ops; | ||
115 | |||
116 | #endif /* __ASSEMBLY__ */ | ||
117 | |||
118 | #endif /* __KERNEL__ */ | ||
119 | #endif /* _ASM_POWERPC_SMP_H) */ | ||
diff --git a/include/asm-powerpc/smu.h b/include/asm-powerpc/smu.h new file mode 100644 index 000000000000..dee8eefe47bc --- /dev/null +++ b/include/asm-powerpc/smu.h | |||
@@ -0,0 +1,379 @@ | |||
1 | #ifndef _SMU_H | ||
2 | #define _SMU_H | ||
3 | |||
4 | /* | ||
5 | * Definitions for talking to the SMU chip in newer G5 PowerMacs | ||
6 | */ | ||
7 | |||
8 | #include <linux/config.h> | ||
9 | #include <linux/list.h> | ||
10 | |||
11 | /* | ||
12 | * Known SMU commands | ||
13 | * | ||
14 | * Most of what is below comes from looking at the Open Firmware driver, | ||
15 | * though this is still incomplete and could use better documentation here | ||
16 | * or there... | ||
17 | */ | ||
18 | |||
19 | |||
20 | /* | ||
21 | * Partition info commands | ||
22 | * | ||
23 | * I do not know what those are for at this point | ||
24 | */ | ||
25 | #define SMU_CMD_PARTITION_COMMAND 0x3e | ||
26 | |||
27 | |||
28 | /* | ||
29 | * Fan control | ||
30 | * | ||
31 | * This is a "mux" for fan control commands, first byte is the | ||
32 | * "sub" command. | ||
33 | */ | ||
34 | #define SMU_CMD_FAN_COMMAND 0x4a | ||
35 | |||
36 | |||
37 | /* | ||
38 | * Battery access | ||
39 | * | ||
40 | * Same command number as the PMU, could it be same syntax ? | ||
41 | */ | ||
42 | #define SMU_CMD_BATTERY_COMMAND 0x6f | ||
43 | #define SMU_CMD_GET_BATTERY_INFO 0x00 | ||
44 | |||
45 | /* | ||
46 | * Real time clock control | ||
47 | * | ||
48 | * This is a "mux", first data byte contains the "sub" command. | ||
49 | * The "RTC" part of the SMU controls the date, time, powerup | ||
50 | * timer, but also a PRAM | ||
51 | * | ||
52 | * Dates are in BCD format on 7 bytes: | ||
53 | * [sec] [min] [hour] [weekday] [month day] [month] [year] | ||
54 | * with month being 1 based and year minus 100 | ||
55 | */ | ||
56 | #define SMU_CMD_RTC_COMMAND 0x8e | ||
57 | #define SMU_CMD_RTC_SET_PWRUP_TIMER 0x00 /* i: 7 bytes date */ | ||
58 | #define SMU_CMD_RTC_GET_PWRUP_TIMER 0x01 /* o: 7 bytes date */ | ||
59 | #define SMU_CMD_RTC_STOP_PWRUP_TIMER 0x02 | ||
60 | #define SMU_CMD_RTC_SET_PRAM_BYTE_ACC 0x20 /* i: 1 byte (address?) */ | ||
61 | #define SMU_CMD_RTC_SET_PRAM_AUTOINC 0x21 /* i: 1 byte (data?) */ | ||
62 | #define SMU_CMD_RTC_SET_PRAM_LO_BYTES 0x22 /* i: 10 bytes */ | ||
63 | #define SMU_CMD_RTC_SET_PRAM_HI_BYTES 0x23 /* i: 10 bytes */ | ||
64 | #define SMU_CMD_RTC_GET_PRAM_BYTE 0x28 /* i: 1 bytes (address?) */ | ||
65 | #define SMU_CMD_RTC_GET_PRAM_LO_BYTES 0x29 /* o: 10 bytes */ | ||
66 | #define SMU_CMD_RTC_GET_PRAM_HI_BYTES 0x2a /* o: 10 bytes */ | ||
67 | #define SMU_CMD_RTC_SET_DATETIME 0x80 /* i: 7 bytes date */ | ||
68 | #define SMU_CMD_RTC_GET_DATETIME 0x81 /* o: 7 bytes date */ | ||
69 | |||
70 | /* | ||
71 | * i2c commands | ||
72 | * | ||
73 | * To issue an i2c command, first is to send a parameter block to the | ||
74 | * the SMU. This is a command of type 0x9a with 9 bytes of header | ||
75 | * eventually followed by data for a write: | ||
76 | * | ||
77 | * 0: bus number (from device-tree usually, SMU has lots of busses !) | ||
78 | * 1: transfer type/format (see below) | ||
79 | * 2: device address. For combined and combined4 type transfers, this | ||
80 | * is the "write" version of the address (bit 0x01 cleared) | ||
81 | * 3: subaddress length (0..3) | ||
82 | * 4: subaddress byte 0 (or only byte for subaddress length 1) | ||
83 | * 5: subaddress byte 1 | ||
84 | * 6: subaddress byte 2 | ||
85 | * 7: combined address (device address for combined mode data phase) | ||
86 | * 8: data length | ||
87 | * | ||
88 | * The transfer types are the same good old Apple ones it seems, | ||
89 | * that is: | ||
90 | * - 0x00: Simple transfer | ||
91 | * - 0x01: Subaddress transfer (addr write + data tx, no restart) | ||
92 | * - 0x02: Combined transfer (addr write + restart + data tx) | ||
93 | * | ||
94 | * This is then followed by actual data for a write. | ||
95 | * | ||
96 | * At this point, the OF driver seems to have a limitation on transfer | ||
97 | * sizes of 0xd bytes on reads and 0x5 bytes on writes. I do not know | ||
98 | * wether this is just an OF limit due to some temporary buffer size | ||
99 | * or if this is an SMU imposed limit. This driver has the same limitation | ||
100 | * for now as I use a 0x10 bytes temporary buffer as well | ||
101 | * | ||
102 | * Once that is completed, a response is expected from the SMU. This is | ||
103 | * obtained via a command of type 0x9a with a length of 1 byte containing | ||
104 | * 0 as the data byte. OF also fills the rest of the data buffer with 0xff's | ||
105 | * though I can't tell yet if this is actually necessary. Once this command | ||
106 | * is complete, at this point, all I can tell is what OF does. OF tests | ||
107 | * byte 0 of the reply: | ||
108 | * - on read, 0xfe or 0xfc : bus is busy, wait (see below) or nak ? | ||
109 | * - on read, 0x00 or 0x01 : reply is in buffer (after the byte 0) | ||
110 | * - on write, < 0 -> failure (immediate exit) | ||
111 | * - else, OF just exists (without error, weird) | ||
112 | * | ||
113 | * So on read, there is this wait-for-busy thing when getting a 0xfc or | ||
114 | * 0xfe result. OF does a loop of up to 64 retries, waiting 20ms and | ||
115 | * doing the above again until either the retries expire or the result | ||
116 | * is no longer 0xfe or 0xfc | ||
117 | * | ||
118 | * The Darwin I2C driver is less subtle though. On any non-success status | ||
119 | * from the response command, it waits 5ms and tries again up to 20 times, | ||
120 | * it doesn't differenciate between fatal errors or "busy" status. | ||
121 | * | ||
122 | * This driver provides an asynchronous paramblock based i2c command | ||
123 | * interface to be used either directly by low level code or by a higher | ||
124 | * level driver interfacing to the linux i2c layer. The current | ||
125 | * implementation of this relies on working timers & timer interrupts | ||
126 | * though, so be careful of calling context for now. This may be "fixed" | ||
127 | * in the future by adding a polling facility. | ||
128 | */ | ||
129 | #define SMU_CMD_I2C_COMMAND 0x9a | ||
130 | /* transfer types */ | ||
131 | #define SMU_I2C_TRANSFER_SIMPLE 0x00 | ||
132 | #define SMU_I2C_TRANSFER_STDSUB 0x01 | ||
133 | #define SMU_I2C_TRANSFER_COMBINED 0x02 | ||
134 | |||
135 | /* | ||
136 | * Power supply control | ||
137 | * | ||
138 | * The "sub" command is an ASCII string in the data, the | ||
139 | * data lenght is that of the string. | ||
140 | * | ||
141 | * The VSLEW command can be used to get or set the voltage slewing. | ||
142 | * - lenght 5 (only "VSLEW") : it returns "DONE" and 3 bytes of | ||
143 | * reply at data offset 6, 7 and 8. | ||
144 | * - lenght 8 ("VSLEWxyz") has 3 additional bytes appended, and is | ||
145 | * used to set the voltage slewing point. The SMU replies with "DONE" | ||
146 | * I yet have to figure out their exact meaning of those 3 bytes in | ||
147 | * both cases. | ||
148 | * | ||
149 | */ | ||
150 | #define SMU_CMD_POWER_COMMAND 0xaa | ||
151 | #define SMU_CMD_POWER_RESTART "RESTART" | ||
152 | #define SMU_CMD_POWER_SHUTDOWN "SHUTDOWN" | ||
153 | #define SMU_CMD_POWER_VOLTAGE_SLEW "VSLEW" | ||
154 | |||
155 | /* Misc commands | ||
156 | * | ||
157 | * This command seem to be a grab bag of various things | ||
158 | */ | ||
159 | #define SMU_CMD_MISC_df_COMMAND 0xdf | ||
160 | #define SMU_CMD_MISC_df_SET_DISPLAY_LIT 0x02 /* i: 1 byte */ | ||
161 | #define SMU_CMD_MISC_df_NMI_OPTION 0x04 | ||
162 | |||
163 | /* | ||
164 | * Version info commands | ||
165 | * | ||
166 | * I haven't quite tried to figure out how these work | ||
167 | */ | ||
168 | #define SMU_CMD_VERSION_COMMAND 0xea | ||
169 | |||
170 | |||
171 | /* | ||
172 | * Misc commands | ||
173 | * | ||
174 | * This command seem to be a grab bag of various things | ||
175 | */ | ||
176 | #define SMU_CMD_MISC_ee_COMMAND 0xee | ||
177 | #define SMU_CMD_MISC_ee_GET_DATABLOCK_REC 0x02 | ||
178 | #define SMU_CMD_MISC_ee_LEDS_CTRL 0x04 /* i: 00 (00,01) [00] */ | ||
179 | #define SMU_CMD_MISC_ee_GET_DATA 0x05 /* i: 00 , o: ?? */ | ||
180 | |||
181 | |||
182 | |||
183 | /* | ||
184 | * - Kernel side interface - | ||
185 | */ | ||
186 | |||
187 | #ifdef __KERNEL__ | ||
188 | |||
189 | /* | ||
190 | * Asynchronous SMU commands | ||
191 | * | ||
192 | * Fill up this structure and submit it via smu_queue_command(), | ||
193 | * and get notified by the optional done() callback, or because | ||
194 | * status becomes != 1 | ||
195 | */ | ||
196 | |||
197 | struct smu_cmd; | ||
198 | |||
199 | struct smu_cmd | ||
200 | { | ||
201 | /* public */ | ||
202 | u8 cmd; /* command */ | ||
203 | int data_len; /* data len */ | ||
204 | int reply_len; /* reply len */ | ||
205 | void *data_buf; /* data buffer */ | ||
206 | void *reply_buf; /* reply buffer */ | ||
207 | int status; /* command status */ | ||
208 | void (*done)(struct smu_cmd *cmd, void *misc); | ||
209 | void *misc; | ||
210 | |||
211 | /* private */ | ||
212 | struct list_head link; | ||
213 | }; | ||
214 | |||
215 | /* | ||
216 | * Queues an SMU command, all fields have to be initialized | ||
217 | */ | ||
218 | extern int smu_queue_cmd(struct smu_cmd *cmd); | ||
219 | |||
220 | /* | ||
221 | * Simple command wrapper. This structure embeds a small buffer | ||
222 | * to ease sending simple SMU commands from the stack | ||
223 | */ | ||
224 | struct smu_simple_cmd | ||
225 | { | ||
226 | struct smu_cmd cmd; | ||
227 | u8 buffer[16]; | ||
228 | }; | ||
229 | |||
230 | /* | ||
231 | * Queues a simple command. All fields will be initialized by that | ||
232 | * function | ||
233 | */ | ||
234 | extern int smu_queue_simple(struct smu_simple_cmd *scmd, u8 command, | ||
235 | unsigned int data_len, | ||
236 | void (*done)(struct smu_cmd *cmd, void *misc), | ||
237 | void *misc, | ||
238 | ...); | ||
239 | |||
240 | /* | ||
241 | * Completion helper. Pass it to smu_queue_simple or as 'done' | ||
242 | * member to smu_queue_cmd, it will call complete() on the struct | ||
243 | * completion passed in the "misc" argument | ||
244 | */ | ||
245 | extern void smu_done_complete(struct smu_cmd *cmd, void *misc); | ||
246 | |||
247 | /* | ||
248 | * Synchronous helpers. Will spin-wait for completion of a command | ||
249 | */ | ||
250 | extern void smu_spinwait_cmd(struct smu_cmd *cmd); | ||
251 | |||
252 | static inline void smu_spinwait_simple(struct smu_simple_cmd *scmd) | ||
253 | { | ||
254 | smu_spinwait_cmd(&scmd->cmd); | ||
255 | } | ||
256 | |||
257 | /* | ||
258 | * Poll routine to call if blocked with irqs off | ||
259 | */ | ||
260 | extern void smu_poll(void); | ||
261 | |||
262 | |||
263 | /* | ||
264 | * Init routine, presence check.... | ||
265 | */ | ||
266 | extern int smu_init(void); | ||
267 | extern int smu_present(void); | ||
268 | struct of_device; | ||
269 | extern struct of_device *smu_get_ofdev(void); | ||
270 | |||
271 | |||
272 | /* | ||
273 | * Common command wrappers | ||
274 | */ | ||
275 | extern void smu_shutdown(void); | ||
276 | extern void smu_restart(void); | ||
277 | struct rtc_time; | ||
278 | extern int smu_get_rtc_time(struct rtc_time *time, int spinwait); | ||
279 | extern int smu_set_rtc_time(struct rtc_time *time, int spinwait); | ||
280 | |||
281 | /* | ||
282 | * SMU command buffer absolute address, exported by pmac_setup, | ||
283 | * this is allocated very early during boot. | ||
284 | */ | ||
285 | extern unsigned long smu_cmdbuf_abs; | ||
286 | |||
287 | |||
288 | /* | ||
289 | * Kenrel asynchronous i2c interface | ||
290 | */ | ||
291 | |||
292 | /* SMU i2c header, exactly matches i2c header on wire */ | ||
293 | struct smu_i2c_param | ||
294 | { | ||
295 | u8 bus; /* SMU bus ID (from device tree) */ | ||
296 | u8 type; /* i2c transfer type */ | ||
297 | u8 devaddr; /* device address (includes direction) */ | ||
298 | u8 sublen; /* subaddress length */ | ||
299 | u8 subaddr[3]; /* subaddress */ | ||
300 | u8 caddr; /* combined address, filled by SMU driver */ | ||
301 | u8 datalen; /* length of transfer */ | ||
302 | u8 data[7]; /* data */ | ||
303 | }; | ||
304 | |||
305 | #define SMU_I2C_READ_MAX 0x0d | ||
306 | #define SMU_I2C_WRITE_MAX 0x05 | ||
307 | |||
308 | struct smu_i2c_cmd | ||
309 | { | ||
310 | /* public */ | ||
311 | struct smu_i2c_param info; | ||
312 | void (*done)(struct smu_i2c_cmd *cmd, void *misc); | ||
313 | void *misc; | ||
314 | int status; /* 1 = pending, 0 = ok, <0 = fail */ | ||
315 | |||
316 | /* private */ | ||
317 | struct smu_cmd scmd; | ||
318 | int read; | ||
319 | int stage; | ||
320 | int retries; | ||
321 | u8 pdata[0x10]; | ||
322 | struct list_head link; | ||
323 | }; | ||
324 | |||
325 | /* | ||
326 | * Call this to queue an i2c command to the SMU. You must fill info, | ||
327 | * including info.data for a write, done and misc. | ||
328 | * For now, no polling interface is provided so you have to use completion | ||
329 | * callback. | ||
330 | */ | ||
331 | extern int smu_queue_i2c(struct smu_i2c_cmd *cmd); | ||
332 | |||
333 | |||
334 | #endif /* __KERNEL__ */ | ||
335 | |||
336 | /* | ||
337 | * - Userland interface - | ||
338 | */ | ||
339 | |||
340 | /* | ||
341 | * A given instance of the device can be configured for 2 different | ||
342 | * things at the moment: | ||
343 | * | ||
344 | * - sending SMU commands (default at open() time) | ||
345 | * - receiving SMU events (not yet implemented) | ||
346 | * | ||
347 | * Commands are written with write() of a command block. They can be | ||
348 | * "driver" commands (for example to switch to event reception mode) | ||
349 | * or real SMU commands. They are made of a header followed by command | ||
350 | * data if any. | ||
351 | * | ||
352 | * For SMU commands (not for driver commands), you can then read() back | ||
353 | * a reply. The reader will be blocked or not depending on how the device | ||
354 | * file is opened. poll() isn't implemented yet. The reply will consist | ||
355 | * of a header as well, followed by the reply data if any. You should | ||
356 | * always provide a buffer large enough for the maximum reply data, I | ||
357 | * recommand one page. | ||
358 | * | ||
359 | * It is illegal to send SMU commands through a file descriptor configured | ||
360 | * for events reception | ||
361 | * | ||
362 | */ | ||
363 | struct smu_user_cmd_hdr | ||
364 | { | ||
365 | __u32 cmdtype; | ||
366 | #define SMU_CMDTYPE_SMU 0 /* SMU command */ | ||
367 | #define SMU_CMDTYPE_WANTS_EVENTS 1 /* switch fd to events mode */ | ||
368 | |||
369 | __u8 cmd; /* SMU command byte */ | ||
370 | __u32 data_len; /* Lenght of data following */ | ||
371 | }; | ||
372 | |||
373 | struct smu_user_reply_hdr | ||
374 | { | ||
375 | __u32 status; /* Command status */ | ||
376 | __u32 reply_len; /* Lenght of data follwing */ | ||
377 | }; | ||
378 | |||
379 | #endif /* _SMU_H */ | ||
diff --git a/include/asm-powerpc/sparsemem.h b/include/asm-powerpc/sparsemem.h new file mode 100644 index 000000000000..1c95ab99deb3 --- /dev/null +++ b/include/asm-powerpc/sparsemem.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _ASM_POWERPC_SPARSEMEM_H | ||
2 | #define _ASM_POWERPC_SPARSEMEM_H 1 | ||
3 | |||
4 | #ifdef CONFIG_SPARSEMEM | ||
5 | /* | ||
6 | * SECTION_SIZE_BITS 2^N: how big each section will be | ||
7 | * MAX_PHYSADDR_BITS 2^N: how much physical address space we have | ||
8 | * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space | ||
9 | */ | ||
10 | #define SECTION_SIZE_BITS 24 | ||
11 | #define MAX_PHYSADDR_BITS 38 | ||
12 | #define MAX_PHYSMEM_BITS 36 | ||
13 | |||
14 | #endif /* CONFIG_SPARSEMEM */ | ||
15 | |||
16 | #endif /* _ASM_POWERPC_SPARSEMEM_H */ | ||
diff --git a/include/asm-powerpc/spinlock_types.h b/include/asm-powerpc/spinlock_types.h new file mode 100644 index 000000000000..74236c9f05b1 --- /dev/null +++ b/include/asm-powerpc/spinlock_types.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _ASM_POWERPC_SPINLOCK_TYPES_H | ||
2 | #define _ASM_POWERPC_SPINLOCK_TYPES_H | ||
3 | |||
4 | #ifndef __LINUX_SPINLOCK_TYPES_H | ||
5 | # error "please don't include this file directly" | ||
6 | #endif | ||
7 | |||
8 | typedef struct { | ||
9 | volatile unsigned int slock; | ||
10 | } raw_spinlock_t; | ||
11 | |||
12 | #define __RAW_SPIN_LOCK_UNLOCKED { 0 } | ||
13 | |||
14 | typedef struct { | ||
15 | volatile signed int lock; | ||
16 | } raw_rwlock_t; | ||
17 | |||
18 | #define __RAW_RW_LOCK_UNLOCKED { 0 } | ||
19 | |||
20 | #endif | ||
diff --git a/include/asm-powerpc/sstep.h b/include/asm-powerpc/sstep.h new file mode 100644 index 000000000000..630a9889c07c --- /dev/null +++ b/include/asm-powerpc/sstep.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Paul Mackerras <paulus@au.ibm.com>, IBM | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | */ | ||
9 | |||
10 | struct pt_regs; | ||
11 | |||
12 | /* | ||
13 | * We don't allow single-stepping an mtmsrd that would clear | ||
14 | * MSR_RI, since that would make the exception unrecoverable. | ||
15 | * Since we need to single-step to proceed from a breakpoint, | ||
16 | * we don't allow putting a breakpoint on an mtmsrd instruction. | ||
17 | * Similarly we don't allow breakpoints on rfid instructions. | ||
18 | * These macros tell us if an instruction is a mtmsrd or rfid. | ||
19 | * Note that IS_MTMSRD returns true for both an mtmsr (32-bit) | ||
20 | * and an mtmsrd (64-bit). | ||
21 | */ | ||
22 | #define IS_MTMSRD(instr) (((instr) & 0xfc0007be) == 0x7c000124) | ||
23 | #define IS_RFID(instr) (((instr) & 0xfc0007fe) == 0x4c000024) | ||
24 | |||
25 | /* Emulate instructions that cause a transfer of control. */ | ||
26 | extern int emulate_step(struct pt_regs *regs, unsigned int instr); | ||
diff --git a/include/asm-powerpc/stat.h b/include/asm-powerpc/stat.h new file mode 100644 index 000000000000..e4edc510b530 --- /dev/null +++ b/include/asm-powerpc/stat.h | |||
@@ -0,0 +1,81 @@ | |||
1 | #ifndef _ASM_POWERPC_STAT_H | ||
2 | #define _ASM_POWERPC_STAT_H | ||
3 | /* | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | */ | ||
9 | #include <linux/types.h> | ||
10 | |||
11 | #define STAT_HAVE_NSEC 1 | ||
12 | |||
13 | #ifndef __powerpc64__ | ||
14 | struct __old_kernel_stat { | ||
15 | unsigned short st_dev; | ||
16 | unsigned short st_ino; | ||
17 | unsigned short st_mode; | ||
18 | unsigned short st_nlink; | ||
19 | unsigned short st_uid; | ||
20 | unsigned short st_gid; | ||
21 | unsigned short st_rdev; | ||
22 | unsigned long st_size; | ||
23 | unsigned long st_atime; | ||
24 | unsigned long st_mtime; | ||
25 | unsigned long st_ctime; | ||
26 | }; | ||
27 | #endif /* !__powerpc64__ */ | ||
28 | |||
29 | struct stat { | ||
30 | unsigned long st_dev; | ||
31 | ino_t st_ino; | ||
32 | #ifdef __powerpc64__ | ||
33 | nlink_t st_nlink; | ||
34 | mode_t st_mode; | ||
35 | #else | ||
36 | mode_t st_mode; | ||
37 | nlink_t st_nlink; | ||
38 | #endif | ||
39 | uid_t st_uid; | ||
40 | gid_t st_gid; | ||
41 | unsigned long st_rdev; | ||
42 | off_t st_size; | ||
43 | unsigned long st_blksize; | ||
44 | unsigned long st_blocks; | ||
45 | unsigned long st_atime; | ||
46 | unsigned long st_atime_nsec; | ||
47 | unsigned long st_mtime; | ||
48 | unsigned long st_mtime_nsec; | ||
49 | unsigned long st_ctime; | ||
50 | unsigned long st_ctime_nsec; | ||
51 | unsigned long __unused4; | ||
52 | unsigned long __unused5; | ||
53 | #ifdef __powerpc64__ | ||
54 | unsigned long __unused6; | ||
55 | #endif | ||
56 | }; | ||
57 | |||
58 | /* This matches struct stat64 in glibc2.1. Only used for 32 bit. */ | ||
59 | struct stat64 { | ||
60 | unsigned long long st_dev; /* Device. */ | ||
61 | unsigned long long st_ino; /* File serial number. */ | ||
62 | unsigned int st_mode; /* File mode. */ | ||
63 | unsigned int st_nlink; /* Link count. */ | ||
64 | unsigned int st_uid; /* User ID of the file's owner. */ | ||
65 | unsigned int st_gid; /* Group ID of the file's group. */ | ||
66 | unsigned long long st_rdev; /* Device number, if device. */ | ||
67 | unsigned short __pad2; | ||
68 | long long st_size; /* Size of file, in bytes. */ | ||
69 | int st_blksize; /* Optimal block size for I/O. */ | ||
70 | long long st_blocks; /* Number 512-byte blocks allocated. */ | ||
71 | int st_atime; /* Time of last access. */ | ||
72 | unsigned int st_atime_nsec; | ||
73 | int st_mtime; /* Time of last modification. */ | ||
74 | unsigned int st_mtime_nsec; | ||
75 | int st_ctime; /* Time of last status change. */ | ||
76 | unsigned int st_ctime_nsec; | ||
77 | unsigned int __unused4; | ||
78 | unsigned int __unused5; | ||
79 | }; | ||
80 | |||
81 | #endif /* _ASM_POWERPC_STAT_H */ | ||
diff --git a/include/asm-powerpc/statfs.h b/include/asm-powerpc/statfs.h new file mode 100644 index 000000000000..67024026c10d --- /dev/null +++ b/include/asm-powerpc/statfs.h | |||
@@ -0,0 +1,60 @@ | |||
1 | #ifndef _ASM_POWERPC_STATFS_H | ||
2 | #define _ASM_POWERPC_STATFS_H | ||
3 | |||
4 | /* For ppc32 we just use the generic definitions, not so simple on ppc64 */ | ||
5 | |||
6 | #ifndef __powerpc64__ | ||
7 | #include <asm-generic/statfs.h> | ||
8 | #else | ||
9 | |||
10 | #ifndef __KERNEL_STRICT_NAMES | ||
11 | #include <linux/types.h> | ||
12 | typedef __kernel_fsid_t fsid_t; | ||
13 | #endif | ||
14 | |||
15 | /* | ||
16 | * We're already 64-bit, so duplicate the definition | ||
17 | */ | ||
18 | struct statfs { | ||
19 | long f_type; | ||
20 | long f_bsize; | ||
21 | long f_blocks; | ||
22 | long f_bfree; | ||
23 | long f_bavail; | ||
24 | long f_files; | ||
25 | long f_ffree; | ||
26 | __kernel_fsid_t f_fsid; | ||
27 | long f_namelen; | ||
28 | long f_frsize; | ||
29 | long f_spare[5]; | ||
30 | }; | ||
31 | |||
32 | struct statfs64 { | ||
33 | long f_type; | ||
34 | long f_bsize; | ||
35 | long f_blocks; | ||
36 | long f_bfree; | ||
37 | long f_bavail; | ||
38 | long f_files; | ||
39 | long f_ffree; | ||
40 | __kernel_fsid_t f_fsid; | ||
41 | long f_namelen; | ||
42 | long f_frsize; | ||
43 | long f_spare[5]; | ||
44 | }; | ||
45 | |||
46 | struct compat_statfs64 { | ||
47 | __u32 f_type; | ||
48 | __u32 f_bsize; | ||
49 | __u64 f_blocks; | ||
50 | __u64 f_bfree; | ||
51 | __u64 f_bavail; | ||
52 | __u64 f_files; | ||
53 | __u64 f_ffree; | ||
54 | __kernel_fsid_t f_fsid; | ||
55 | __u32 f_namelen; | ||
56 | __u32 f_frsize; | ||
57 | __u32 f_spare[5]; | ||
58 | }; | ||
59 | #endif /* ! __powerpc64__ */ | ||
60 | #endif | ||
diff --git a/include/asm-powerpc/synch.h b/include/asm-powerpc/synch.h new file mode 100644 index 000000000000..4660c0394a77 --- /dev/null +++ b/include/asm-powerpc/synch.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef _ASM_POWERPC_SYNCH_H | ||
2 | #define _ASM_POWERPC_SYNCH_H | ||
3 | |||
4 | #include <linux/config.h> | ||
5 | |||
6 | #ifdef __powerpc64__ | ||
7 | #define __SUBARCH_HAS_LWSYNC | ||
8 | #endif | ||
9 | |||
10 | #ifdef __SUBARCH_HAS_LWSYNC | ||
11 | # define LWSYNC lwsync | ||
12 | #else | ||
13 | # define LWSYNC sync | ||
14 | #endif | ||
15 | |||
16 | |||
17 | /* | ||
18 | * Arguably the bitops and *xchg operations don't imply any memory barrier | ||
19 | * or SMP ordering, but in fact a lot of drivers expect them to imply | ||
20 | * both, since they do on x86 cpus. | ||
21 | */ | ||
22 | #ifdef CONFIG_SMP | ||
23 | #define EIEIO_ON_SMP "eieio\n" | ||
24 | #define ISYNC_ON_SMP "\n\tisync" | ||
25 | #define SYNC_ON_SMP __stringify(LWSYNC) "\n" | ||
26 | #else | ||
27 | #define EIEIO_ON_SMP | ||
28 | #define ISYNC_ON_SMP | ||
29 | #define SYNC_ON_SMP | ||
30 | #endif | ||
31 | |||
32 | static inline void eieio(void) | ||
33 | { | ||
34 | __asm__ __volatile__ ("eieio" : : : "memory"); | ||
35 | } | ||
36 | |||
37 | static inline void isync(void) | ||
38 | { | ||
39 | __asm__ __volatile__ ("isync" : : : "memory"); | ||
40 | } | ||
41 | |||
42 | #ifdef CONFIG_SMP | ||
43 | #define eieio_on_smp() eieio() | ||
44 | #define isync_on_smp() isync() | ||
45 | #else | ||
46 | #define eieio_on_smp() __asm__ __volatile__("": : :"memory") | ||
47 | #define isync_on_smp() __asm__ __volatile__("": : :"memory") | ||
48 | #endif | ||
49 | |||
50 | #endif /* _ASM_POWERPC_SYNCH_H */ | ||
51 | |||
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h new file mode 100644 index 000000000000..b5da0b851e02 --- /dev/null +++ b/include/asm-powerpc/system.h | |||
@@ -0,0 +1,411 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu> | ||
3 | */ | ||
4 | #ifndef _ASM_POWERPC_SYSTEM_H | ||
5 | #define _ASM_POWERPC_SYSTEM_H | ||
6 | |||
7 | #include <linux/config.h> | ||
8 | #include <linux/kernel.h> | ||
9 | |||
10 | #include <asm/hw_irq.h> | ||
11 | #include <asm/ppc_asm.h> | ||
12 | #include <asm/atomic.h> | ||
13 | |||
14 | /* | ||
15 | * Memory barrier. | ||
16 | * The sync instruction guarantees that all memory accesses initiated | ||
17 | * by this processor have been performed (with respect to all other | ||
18 | * mechanisms that access memory). The eieio instruction is a barrier | ||
19 | * providing an ordering (separately) for (a) cacheable stores and (b) | ||
20 | * loads and stores to non-cacheable memory (e.g. I/O devices). | ||
21 | * | ||
22 | * mb() prevents loads and stores being reordered across this point. | ||
23 | * rmb() prevents loads being reordered across this point. | ||
24 | * wmb() prevents stores being reordered across this point. | ||
25 | * read_barrier_depends() prevents data-dependent loads being reordered | ||
26 | * across this point (nop on PPC). | ||
27 | * | ||
28 | * We have to use the sync instructions for mb(), since lwsync doesn't | ||
29 | * order loads with respect to previous stores. Lwsync is fine for | ||
30 | * rmb(), though. Note that lwsync is interpreted as sync by | ||
31 | * 32-bit and older 64-bit CPUs. | ||
32 | * | ||
33 | * For wmb(), we use sync since wmb is used in drivers to order | ||
34 | * stores to system memory with respect to writes to the device. | ||
35 | * However, smp_wmb() can be a lighter-weight eieio barrier on | ||
36 | * SMP since it is only used to order updates to system memory. | ||
37 | */ | ||
38 | #define mb() __asm__ __volatile__ ("sync" : : : "memory") | ||
39 | #define rmb() __asm__ __volatile__ ("lwsync" : : : "memory") | ||
40 | #define wmb() __asm__ __volatile__ ("sync" : : : "memory") | ||
41 | #define read_barrier_depends() do { } while(0) | ||
42 | |||
43 | #define set_mb(var, value) do { var = value; mb(); } while (0) | ||
44 | #define set_wmb(var, value) do { var = value; wmb(); } while (0) | ||
45 | |||
46 | #ifdef CONFIG_SMP | ||
47 | #define smp_mb() mb() | ||
48 | #define smp_rmb() rmb() | ||
49 | #define smp_wmb() __asm__ __volatile__ ("eieio" : : : "memory") | ||
50 | #define smp_read_barrier_depends() read_barrier_depends() | ||
51 | #else | ||
52 | #define smp_mb() barrier() | ||
53 | #define smp_rmb() barrier() | ||
54 | #define smp_wmb() barrier() | ||
55 | #define smp_read_barrier_depends() do { } while(0) | ||
56 | #endif /* CONFIG_SMP */ | ||
57 | |||
58 | #ifdef __KERNEL__ | ||
59 | struct task_struct; | ||
60 | struct pt_regs; | ||
61 | |||
62 | #ifdef CONFIG_DEBUGGER | ||
63 | |||
64 | extern int (*__debugger)(struct pt_regs *regs); | ||
65 | extern int (*__debugger_ipi)(struct pt_regs *regs); | ||
66 | extern int (*__debugger_bpt)(struct pt_regs *regs); | ||
67 | extern int (*__debugger_sstep)(struct pt_regs *regs); | ||
68 | extern int (*__debugger_iabr_match)(struct pt_regs *regs); | ||
69 | extern int (*__debugger_dabr_match)(struct pt_regs *regs); | ||
70 | extern int (*__debugger_fault_handler)(struct pt_regs *regs); | ||
71 | |||
72 | #define DEBUGGER_BOILERPLATE(__NAME) \ | ||
73 | static inline int __NAME(struct pt_regs *regs) \ | ||
74 | { \ | ||
75 | if (unlikely(__ ## __NAME)) \ | ||
76 | return __ ## __NAME(regs); \ | ||
77 | return 0; \ | ||
78 | } | ||
79 | |||
80 | DEBUGGER_BOILERPLATE(debugger) | ||
81 | DEBUGGER_BOILERPLATE(debugger_ipi) | ||
82 | DEBUGGER_BOILERPLATE(debugger_bpt) | ||
83 | DEBUGGER_BOILERPLATE(debugger_sstep) | ||
84 | DEBUGGER_BOILERPLATE(debugger_iabr_match) | ||
85 | DEBUGGER_BOILERPLATE(debugger_dabr_match) | ||
86 | DEBUGGER_BOILERPLATE(debugger_fault_handler) | ||
87 | |||
88 | #ifdef CONFIG_XMON | ||
89 | extern void xmon_init(int enable); | ||
90 | #endif | ||
91 | |||
92 | #else | ||
93 | static inline int debugger(struct pt_regs *regs) { return 0; } | ||
94 | static inline int debugger_ipi(struct pt_regs *regs) { return 0; } | ||
95 | static inline int debugger_bpt(struct pt_regs *regs) { return 0; } | ||
96 | static inline int debugger_sstep(struct pt_regs *regs) { return 0; } | ||
97 | static inline int debugger_iabr_match(struct pt_regs *regs) { return 0; } | ||
98 | static inline int debugger_dabr_match(struct pt_regs *regs) { return 0; } | ||
99 | static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; } | ||
100 | #endif | ||
101 | |||
102 | extern int set_dabr(unsigned long dabr); | ||
103 | extern void print_backtrace(unsigned long *); | ||
104 | extern void show_regs(struct pt_regs * regs); | ||
105 | extern void flush_instruction_cache(void); | ||
106 | extern void hard_reset_now(void); | ||
107 | extern void poweroff_now(void); | ||
108 | |||
109 | #ifdef CONFIG_6xx | ||
110 | extern long _get_L2CR(void); | ||
111 | extern long _get_L3CR(void); | ||
112 | extern void _set_L2CR(unsigned long); | ||
113 | extern void _set_L3CR(unsigned long); | ||
114 | #else | ||
115 | #define _get_L2CR() 0L | ||
116 | #define _get_L3CR() 0L | ||
117 | #define _set_L2CR(val) do { } while(0) | ||
118 | #define _set_L3CR(val) do { } while(0) | ||
119 | #endif | ||
120 | |||
121 | extern void via_cuda_init(void); | ||
122 | extern void read_rtc_time(void); | ||
123 | extern void pmac_find_display(void); | ||
124 | extern void giveup_fpu(struct task_struct *); | ||
125 | extern void disable_kernel_fp(void); | ||
126 | extern void enable_kernel_fp(void); | ||
127 | extern void flush_fp_to_thread(struct task_struct *); | ||
128 | extern void enable_kernel_altivec(void); | ||
129 | extern void giveup_altivec(struct task_struct *); | ||
130 | extern void load_up_altivec(struct task_struct *); | ||
131 | extern int emulate_altivec(struct pt_regs *); | ||
132 | extern void giveup_spe(struct task_struct *); | ||
133 | extern void load_up_spe(struct task_struct *); | ||
134 | extern int fix_alignment(struct pt_regs *); | ||
135 | extern void cvt_fd(float *from, double *to, struct thread_struct *thread); | ||
136 | extern void cvt_df(double *from, float *to, struct thread_struct *thread); | ||
137 | |||
138 | #ifdef CONFIG_ALTIVEC | ||
139 | extern void flush_altivec_to_thread(struct task_struct *); | ||
140 | #else | ||
141 | static inline void flush_altivec_to_thread(struct task_struct *t) | ||
142 | { | ||
143 | } | ||
144 | #endif | ||
145 | |||
146 | #ifdef CONFIG_SPE | ||
147 | extern void flush_spe_to_thread(struct task_struct *); | ||
148 | #else | ||
149 | static inline void flush_spe_to_thread(struct task_struct *t) | ||
150 | { | ||
151 | } | ||
152 | #endif | ||
153 | |||
154 | extern int call_rtas(const char *, int, int, unsigned long *, ...); | ||
155 | extern void cacheable_memzero(void *p, unsigned int nb); | ||
156 | extern void *cacheable_memcpy(void *, const void *, unsigned int); | ||
157 | extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long); | ||
158 | extern void bad_page_fault(struct pt_regs *, unsigned long, int); | ||
159 | extern int die(const char *, struct pt_regs *, long); | ||
160 | extern void _exception(int, struct pt_regs *, int, unsigned long); | ||
161 | #ifdef CONFIG_BOOKE_WDT | ||
162 | extern u32 booke_wdt_enabled; | ||
163 | extern u32 booke_wdt_period; | ||
164 | #endif /* CONFIG_BOOKE_WDT */ | ||
165 | |||
166 | /* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */ | ||
167 | extern unsigned char e2a(unsigned char); | ||
168 | |||
169 | struct device_node; | ||
170 | extern void note_scsi_host(struct device_node *, void *); | ||
171 | |||
172 | extern struct task_struct *__switch_to(struct task_struct *, | ||
173 | struct task_struct *); | ||
174 | #define switch_to(prev, next, last) ((last) = __switch_to((prev), (next))) | ||
175 | |||
176 | struct thread_struct; | ||
177 | extern struct task_struct *_switch(struct thread_struct *prev, | ||
178 | struct thread_struct *next); | ||
179 | |||
180 | extern unsigned int rtas_data; | ||
181 | extern int mem_init_done; /* set on boot once kmalloc can be called */ | ||
182 | extern unsigned long memory_limit; | ||
183 | |||
184 | extern int powersave_nap; /* set if nap mode can be used in idle loop */ | ||
185 | |||
186 | /* | ||
187 | * Atomic exchange | ||
188 | * | ||
189 | * Changes the memory location '*ptr' to be val and returns | ||
190 | * the previous value stored there. | ||
191 | */ | ||
192 | static __inline__ unsigned long | ||
193 | __xchg_u32(volatile void *p, unsigned long val) | ||
194 | { | ||
195 | unsigned long prev; | ||
196 | |||
197 | __asm__ __volatile__( | ||
198 | EIEIO_ON_SMP | ||
199 | "1: lwarx %0,0,%2 \n" | ||
200 | PPC405_ERR77(0,%2) | ||
201 | " stwcx. %3,0,%2 \n\ | ||
202 | bne- 1b" | ||
203 | ISYNC_ON_SMP | ||
204 | : "=&r" (prev), "=m" (*(volatile unsigned int *)p) | ||
205 | : "r" (p), "r" (val), "m" (*(volatile unsigned int *)p) | ||
206 | : "cc", "memory"); | ||
207 | |||
208 | return prev; | ||
209 | } | ||
210 | |||
211 | #ifdef CONFIG_PPC64 | ||
212 | static __inline__ unsigned long | ||
213 | __xchg_u64(volatile void *p, unsigned long val) | ||
214 | { | ||
215 | unsigned long prev; | ||
216 | |||
217 | __asm__ __volatile__( | ||
218 | EIEIO_ON_SMP | ||
219 | "1: ldarx %0,0,%2 \n" | ||
220 | PPC405_ERR77(0,%2) | ||
221 | " stdcx. %3,0,%2 \n\ | ||
222 | bne- 1b" | ||
223 | ISYNC_ON_SMP | ||
224 | : "=&r" (prev), "=m" (*(volatile unsigned long *)p) | ||
225 | : "r" (p), "r" (val), "m" (*(volatile unsigned long *)p) | ||
226 | : "cc", "memory"); | ||
227 | |||
228 | return prev; | ||
229 | } | ||
230 | #endif | ||
231 | |||
232 | /* | ||
233 | * This function doesn't exist, so you'll get a linker error | ||
234 | * if something tries to do an invalid xchg(). | ||
235 | */ | ||
236 | extern void __xchg_called_with_bad_pointer(void); | ||
237 | |||
238 | static __inline__ unsigned long | ||
239 | __xchg(volatile void *ptr, unsigned long x, unsigned int size) | ||
240 | { | ||
241 | switch (size) { | ||
242 | case 4: | ||
243 | return __xchg_u32(ptr, x); | ||
244 | #ifdef CONFIG_PPC64 | ||
245 | case 8: | ||
246 | return __xchg_u64(ptr, x); | ||
247 | #endif | ||
248 | } | ||
249 | __xchg_called_with_bad_pointer(); | ||
250 | return x; | ||
251 | } | ||
252 | |||
253 | #define xchg(ptr,x) \ | ||
254 | ({ \ | ||
255 | __typeof__(*(ptr)) _x_ = (x); \ | ||
256 | (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \ | ||
257 | }) | ||
258 | |||
259 | #define tas(ptr) (xchg((ptr),1)) | ||
260 | |||
261 | /* | ||
262 | * Compare and exchange - if *p == old, set it to new, | ||
263 | * and return the old value of *p. | ||
264 | */ | ||
265 | #define __HAVE_ARCH_CMPXCHG 1 | ||
266 | |||
267 | static __inline__ unsigned long | ||
268 | __cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new) | ||
269 | { | ||
270 | unsigned int prev; | ||
271 | |||
272 | __asm__ __volatile__ ( | ||
273 | EIEIO_ON_SMP | ||
274 | "1: lwarx %0,0,%2 # __cmpxchg_u32\n\ | ||
275 | cmpw 0,%0,%3\n\ | ||
276 | bne- 2f\n" | ||
277 | PPC405_ERR77(0,%2) | ||
278 | " stwcx. %4,0,%2\n\ | ||
279 | bne- 1b" | ||
280 | ISYNC_ON_SMP | ||
281 | "\n\ | ||
282 | 2:" | ||
283 | : "=&r" (prev), "=m" (*p) | ||
284 | : "r" (p), "r" (old), "r" (new), "m" (*p) | ||
285 | : "cc", "memory"); | ||
286 | |||
287 | return prev; | ||
288 | } | ||
289 | |||
290 | #ifdef CONFIG_PPC64 | ||
291 | static __inline__ unsigned long | ||
292 | __cmpxchg_u64(volatile long *p, unsigned long old, unsigned long new) | ||
293 | { | ||
294 | unsigned long prev; | ||
295 | |||
296 | __asm__ __volatile__ ( | ||
297 | EIEIO_ON_SMP | ||
298 | "1: ldarx %0,0,%2 # __cmpxchg_u64\n\ | ||
299 | cmpd 0,%0,%3\n\ | ||
300 | bne- 2f\n\ | ||
301 | stdcx. %4,0,%2\n\ | ||
302 | bne- 1b" | ||
303 | ISYNC_ON_SMP | ||
304 | "\n\ | ||
305 | 2:" | ||
306 | : "=&r" (prev), "=m" (*p) | ||
307 | : "r" (p), "r" (old), "r" (new), "m" (*p) | ||
308 | : "cc", "memory"); | ||
309 | |||
310 | return prev; | ||
311 | } | ||
312 | #endif | ||
313 | |||
314 | /* This function doesn't exist, so you'll get a linker error | ||
315 | if something tries to do an invalid cmpxchg(). */ | ||
316 | extern void __cmpxchg_called_with_bad_pointer(void); | ||
317 | |||
318 | static __inline__ unsigned long | ||
319 | __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, | ||
320 | unsigned int size) | ||
321 | { | ||
322 | switch (size) { | ||
323 | case 4: | ||
324 | return __cmpxchg_u32(ptr, old, new); | ||
325 | #ifdef CONFIG_PPC64 | ||
326 | case 8: | ||
327 | return __cmpxchg_u64(ptr, old, new); | ||
328 | #endif | ||
329 | } | ||
330 | __cmpxchg_called_with_bad_pointer(); | ||
331 | return old; | ||
332 | } | ||
333 | |||
334 | #define cmpxchg(ptr,o,n) \ | ||
335 | ({ \ | ||
336 | __typeof__(*(ptr)) _o_ = (o); \ | ||
337 | __typeof__(*(ptr)) _n_ = (n); \ | ||
338 | (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \ | ||
339 | (unsigned long)_n_, sizeof(*(ptr))); \ | ||
340 | }) | ||
341 | |||
342 | #ifdef CONFIG_PPC64 | ||
343 | /* | ||
344 | * We handle most unaligned accesses in hardware. On the other hand | ||
345 | * unaligned DMA can be very expensive on some ppc64 IO chips (it does | ||
346 | * powers of 2 writes until it reaches sufficient alignment). | ||
347 | * | ||
348 | * Based on this we disable the IP header alignment in network drivers. | ||
349 | */ | ||
350 | #define NET_IP_ALIGN 0 | ||
351 | #endif | ||
352 | |||
353 | #define arch_align_stack(x) (x) | ||
354 | |||
355 | /* Used in very early kernel initialization. */ | ||
356 | extern unsigned long reloc_offset(void); | ||
357 | extern unsigned long add_reloc_offset(unsigned long); | ||
358 | extern void reloc_got2(unsigned long); | ||
359 | |||
360 | #define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x))) | ||
361 | |||
362 | static inline void create_instruction(unsigned long addr, unsigned int instr) | ||
363 | { | ||
364 | unsigned int *p; | ||
365 | p = (unsigned int *)addr; | ||
366 | *p = instr; | ||
367 | asm ("dcbst 0, %0; sync; icbi 0,%0; sync; isync" : : "r" (p)); | ||
368 | } | ||
369 | |||
370 | /* Flags for create_branch: | ||
371 | * "b" == create_branch(addr, target, 0); | ||
372 | * "ba" == create_branch(addr, target, BRANCH_ABSOLUTE); | ||
373 | * "bl" == create_branch(addr, target, BRANCH_SET_LINK); | ||
374 | * "bla" == create_branch(addr, target, BRANCH_ABSOLUTE | BRANCH_SET_LINK); | ||
375 | */ | ||
376 | #define BRANCH_SET_LINK 0x1 | ||
377 | #define BRANCH_ABSOLUTE 0x2 | ||
378 | |||
379 | static inline void create_branch(unsigned long addr, | ||
380 | unsigned long target, int flags) | ||
381 | { | ||
382 | unsigned int instruction; | ||
383 | |||
384 | if (! (flags & BRANCH_ABSOLUTE)) | ||
385 | target = target - addr; | ||
386 | |||
387 | /* Mask out the flags and target, so they don't step on each other. */ | ||
388 | instruction = 0x48000000 | (flags & 0x3) | (target & 0x03FFFFFC); | ||
389 | |||
390 | create_instruction(addr, instruction); | ||
391 | } | ||
392 | |||
393 | static inline void create_function_call(unsigned long addr, void * func) | ||
394 | { | ||
395 | unsigned long func_addr; | ||
396 | |||
397 | #ifdef CONFIG_PPC64 | ||
398 | /* | ||
399 | * On PPC64 the function pointer actually points to the function's | ||
400 | * descriptor. The first entry in the descriptor is the address | ||
401 | * of the function text. | ||
402 | */ | ||
403 | func_addr = *(unsigned long *)func; | ||
404 | #else | ||
405 | func_addr = (unsigned long)func; | ||
406 | #endif | ||
407 | create_branch(addr, func_addr, BRANCH_SET_LINK); | ||
408 | } | ||
409 | |||
410 | #endif /* __KERNEL__ */ | ||
411 | #endif /* _ASM_POWERPC_SYSTEM_H */ | ||
diff --git a/include/asm-powerpc/termios.h b/include/asm-powerpc/termios.h index c5b8e5358f83..7f80a019b6a0 100644 --- a/include/asm-powerpc/termios.h +++ b/include/asm-powerpc/termios.h | |||
@@ -94,142 +94,9 @@ struct termio { | |||
94 | #define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025" | 94 | #define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025" |
95 | #endif | 95 | #endif |
96 | 96 | ||
97 | #define FIOCLEX _IO('f', 1) | ||
98 | #define FIONCLEX _IO('f', 2) | ||
99 | #define FIOASYNC _IOW('f', 125, int) | ||
100 | #define FIONBIO _IOW('f', 126, int) | ||
101 | #define FIONREAD _IOR('f', 127, int) | ||
102 | #define TIOCINQ FIONREAD | ||
103 | |||
104 | #define TIOCGETP _IOR('t', 8, struct sgttyb) | ||
105 | #define TIOCSETP _IOW('t', 9, struct sgttyb) | ||
106 | #define TIOCSETN _IOW('t', 10, struct sgttyb) /* TIOCSETP wo flush */ | ||
107 | |||
108 | #define TIOCSETC _IOW('t', 17, struct tchars) | ||
109 | #define TIOCGETC _IOR('t', 18, struct tchars) | ||
110 | #define TCGETS _IOR('t', 19, struct termios) | ||
111 | #define TCSETS _IOW('t', 20, struct termios) | ||
112 | #define TCSETSW _IOW('t', 21, struct termios) | ||
113 | #define TCSETSF _IOW('t', 22, struct termios) | ||
114 | |||
115 | #define TCGETA _IOR('t', 23, struct termio) | ||
116 | #define TCSETA _IOW('t', 24, struct termio) | ||
117 | #define TCSETAW _IOW('t', 25, struct termio) | ||
118 | #define TCSETAF _IOW('t', 28, struct termio) | ||
119 | |||
120 | #define TCSBRK _IO('t', 29) | ||
121 | #define TCXONC _IO('t', 30) | ||
122 | #define TCFLSH _IO('t', 31) | ||
123 | |||
124 | #define TIOCSWINSZ _IOW('t', 103, struct winsize) | ||
125 | #define TIOCGWINSZ _IOR('t', 104, struct winsize) | ||
126 | #define TIOCSTART _IO('t', 110) /* start output, like ^Q */ | ||
127 | #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ | ||
128 | #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ | ||
129 | |||
130 | #define TIOCGLTC _IOR('t', 116, struct ltchars) | ||
131 | #define TIOCSLTC _IOW('t', 117, struct ltchars) | ||
132 | #define TIOCSPGRP _IOW('t', 118, int) | ||
133 | #define TIOCGPGRP _IOR('t', 119, int) | ||
134 | |||
135 | #define TIOCEXCL 0x540C | ||
136 | #define TIOCNXCL 0x540D | ||
137 | #define TIOCSCTTY 0x540E | ||
138 | |||
139 | #define TIOCSTI 0x5412 | ||
140 | #define TIOCMGET 0x5415 | ||
141 | #define TIOCMBIS 0x5416 | ||
142 | #define TIOCMBIC 0x5417 | ||
143 | #define TIOCMSET 0x5418 | ||
144 | #define TIOCGSOFTCAR 0x5419 | ||
145 | #define TIOCSSOFTCAR 0x541A | ||
146 | #define TIOCLINUX 0x541C | ||
147 | #define TIOCCONS 0x541D | ||
148 | #define TIOCGSERIAL 0x541E | ||
149 | #define TIOCSSERIAL 0x541F | ||
150 | #define TIOCPKT 0x5420 | ||
151 | |||
152 | #define TIOCNOTTY 0x5422 | ||
153 | #define TIOCSETD 0x5423 | ||
154 | #define TIOCGETD 0x5424 | ||
155 | #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ | ||
156 | |||
157 | #define TIOCSERCONFIG 0x5453 | ||
158 | #define TIOCSERGWILD 0x5454 | ||
159 | #define TIOCSERSWILD 0x5455 | ||
160 | #define TIOCGLCKTRMIOS 0x5456 | ||
161 | #define TIOCSLCKTRMIOS 0x5457 | ||
162 | #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ | ||
163 | #define TIOCSERGETLSR 0x5459 /* Get line status register */ | ||
164 | #define TIOCSERGETMULTI 0x545A /* Get multiport config */ | ||
165 | #define TIOCSERSETMULTI 0x545B /* Set multiport config */ | ||
166 | |||
167 | #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ | ||
168 | #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ | ||
169 | |||
170 | /* Used for packet mode */ | ||
171 | #define TIOCPKT_DATA 0 | ||
172 | #define TIOCPKT_FLUSHREAD 1 | ||
173 | #define TIOCPKT_FLUSHWRITE 2 | ||
174 | #define TIOCPKT_STOP 4 | ||
175 | #define TIOCPKT_START 8 | ||
176 | #define TIOCPKT_NOSTOP 16 | ||
177 | #define TIOCPKT_DOSTOP 32 | ||
178 | |||
179 | /* modem lines */ | ||
180 | #define TIOCM_LE 0x001 | ||
181 | #define TIOCM_DTR 0x002 | ||
182 | #define TIOCM_RTS 0x004 | ||
183 | #define TIOCM_ST 0x008 | ||
184 | #define TIOCM_SR 0x010 | ||
185 | #define TIOCM_CTS 0x020 | ||
186 | #define TIOCM_CAR 0x040 | ||
187 | #define TIOCM_RNG 0x080 | ||
188 | #define TIOCM_DSR 0x100 | ||
189 | #define TIOCM_CD TIOCM_CAR | ||
190 | #define TIOCM_RI TIOCM_RNG | ||
191 | #define TIOCM_OUT1 0x2000 | ||
192 | #define TIOCM_OUT2 0x4000 | ||
193 | #define TIOCM_LOOP 0x8000 | ||
194 | |||
195 | /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ | ||
196 | #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ | ||
197 | |||
198 | #ifdef __KERNEL__ | 97 | #ifdef __KERNEL__ |
199 | 98 | ||
200 | /* | 99 | #include <asm-generic/termios.h> |
201 | * Translate a "termio" structure into a "termios". Ugh. | ||
202 | */ | ||
203 | #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \ | ||
204 | unsigned short __tmp; \ | ||
205 | get_user(__tmp,&(termio)->x); \ | ||
206 | (termios)->x = (0xffff0000 & (termios)->x) | __tmp; \ | ||
207 | } | ||
208 | |||
209 | #define user_termio_to_kernel_termios(termios, termio) \ | ||
210 | ({ \ | ||
211 | SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ | ||
212 | SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ | ||
213 | SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ | ||
214 | SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ | ||
215 | copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ | ||
216 | }) | ||
217 | |||
218 | /* | ||
219 | * Translate a "termios" structure into a "termio". Ugh. | ||
220 | */ | ||
221 | #define kernel_termios_to_user_termio(termio, termios) \ | ||
222 | ({ \ | ||
223 | put_user((termios)->c_iflag, &(termio)->c_iflag); \ | ||
224 | put_user((termios)->c_oflag, &(termio)->c_oflag); \ | ||
225 | put_user((termios)->c_cflag, &(termio)->c_cflag); \ | ||
226 | put_user((termios)->c_lflag, &(termio)->c_lflag); \ | ||
227 | put_user((termios)->c_line, &(termio)->c_line); \ | ||
228 | copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ | ||
229 | }) | ||
230 | |||
231 | #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios)) | ||
232 | #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios)) | ||
233 | 100 | ||
234 | #endif /* __KERNEL__ */ | 101 | #endif /* __KERNEL__ */ |
235 | 102 | ||
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h new file mode 100644 index 000000000000..ab17db79f69d --- /dev/null +++ b/include/asm-powerpc/thread_info.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* thread_info.h: PowerPC low-level thread information | ||
2 | * adapted from the i386 version by Paul Mackerras | ||
3 | * | ||
4 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) | ||
5 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller | ||
6 | */ | ||
7 | |||
8 | #ifndef _ASM_POWERPC_THREAD_INFO_H | ||
9 | #define _ASM_POWERPC_THREAD_INFO_H | ||
10 | |||
11 | #ifdef __KERNEL__ | ||
12 | |||
13 | /* We have 8k stacks on ppc32 and 16k on ppc64 */ | ||
14 | |||
15 | #ifdef CONFIG_PPC64 | ||
16 | #define THREAD_SHIFT 14 | ||
17 | #else | ||
18 | #define THREAD_SHIFT 13 | ||
19 | #endif | ||
20 | |||
21 | #define THREAD_SIZE (1 << THREAD_SHIFT) | ||
22 | |||
23 | #ifndef __ASSEMBLY__ | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/cache.h> | ||
26 | #include <asm/processor.h> | ||
27 | #include <asm/page.h> | ||
28 | #include <linux/stringify.h> | ||
29 | |||
30 | /* | ||
31 | * low level task data. | ||
32 | */ | ||
33 | struct thread_info { | ||
34 | struct task_struct *task; /* main task structure */ | ||
35 | struct exec_domain *exec_domain; /* execution domain */ | ||
36 | int cpu; /* cpu we're on */ | ||
37 | int preempt_count; /* 0 => preemptable, | ||
38 | <0 => BUG */ | ||
39 | struct restart_block restart_block; | ||
40 | /* set by force_successful_syscall_return */ | ||
41 | unsigned char syscall_noerror; | ||
42 | /* low level flags - has atomic operations done on it */ | ||
43 | unsigned long flags ____cacheline_aligned_in_smp; | ||
44 | }; | ||
45 | |||
46 | /* | ||
47 | * macros/functions for gaining access to the thread information structure | ||
48 | * | ||
49 | * preempt_count needs to be 1 initially, until the scheduler is functional. | ||
50 | */ | ||
51 | #define INIT_THREAD_INFO(tsk) \ | ||
52 | { \ | ||
53 | .task = &tsk, \ | ||
54 | .exec_domain = &default_exec_domain, \ | ||
55 | .cpu = 0, \ | ||
56 | .preempt_count = 1, \ | ||
57 | .restart_block = { \ | ||
58 | .fn = do_no_restart_syscall, \ | ||
59 | }, \ | ||
60 | .flags = 0, \ | ||
61 | } | ||
62 | |||
63 | #define init_thread_info (init_thread_union.thread_info) | ||
64 | #define init_stack (init_thread_union.stack) | ||
65 | |||
66 | /* thread information allocation */ | ||
67 | |||
68 | #ifdef CONFIG_DEBUG_STACK_USAGE | ||
69 | #define THREAD_INFO_GFP GFP_KERNEL | __GFP_ZERO | ||
70 | #else | ||
71 | #define THREAD_INFO_GFP GFP_KERNEL | ||
72 | #endif | ||
73 | |||
74 | #if THREAD_SHIFT >= PAGE_SHIFT | ||
75 | |||
76 | #define THREAD_ORDER (THREAD_SHIFT - PAGE_SHIFT) | ||
77 | |||
78 | #define alloc_thread_info(tsk) \ | ||
79 | ((struct thread_info *)__get_free_pages(THREAD_INFO_GFP, THREAD_ORDER)) | ||
80 | #define free_thread_info(ti) free_pages((unsigned long)ti, THREAD_ORDER) | ||
81 | |||
82 | #else /* THREAD_SHIFT < PAGE_SHIFT */ | ||
83 | |||
84 | #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, THREAD_INFO_GFP) | ||
85 | #define free_thread_info(ti) kfree(ti) | ||
86 | |||
87 | #endif /* THREAD_SHIFT < PAGE_SHIFT */ | ||
88 | |||
89 | #define get_thread_info(ti) get_task_struct((ti)->task) | ||
90 | #define put_thread_info(ti) put_task_struct((ti)->task) | ||
91 | |||
92 | /* how to get the thread information struct from C */ | ||
93 | static inline struct thread_info *current_thread_info(void) | ||
94 | { | ||
95 | register unsigned long sp asm("r1"); | ||
96 | |||
97 | /* gcc4, at least, is smart enough to turn this into a single | ||
98 | * rlwinm for ppc32 and clrrdi for ppc64 */ | ||
99 | return (struct thread_info *)(sp & ~(THREAD_SIZE-1)); | ||
100 | } | ||
101 | |||
102 | #endif /* __ASSEMBLY__ */ | ||
103 | |||
104 | #define PREEMPT_ACTIVE 0x10000000 | ||
105 | |||
106 | /* | ||
107 | * thread information flag bit numbers | ||
108 | */ | ||
109 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ | ||
110 | #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ | ||
111 | #define TIF_SIGPENDING 2 /* signal pending */ | ||
112 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ | ||
113 | #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling | ||
114 | TIF_NEED_RESCHED */ | ||
115 | #define TIF_32BIT 5 /* 32 bit binary */ | ||
116 | /* #define SPARE 6 */ | ||
117 | #define TIF_ABI_PENDING 7 /* 32/64 bit switch needed */ | ||
118 | #define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */ | ||
119 | #define TIF_SINGLESTEP 9 /* singlestepping active */ | ||
120 | #define TIF_MEMDIE 10 | ||
121 | #define TIF_SECCOMP 11 /* secure computing */ | ||
122 | |||
123 | /* as above, but as bit values */ | ||
124 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | ||
125 | #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) | ||
126 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) | ||
127 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | ||
128 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) | ||
129 | #define _TIF_32BIT (1<<TIF_32BIT) | ||
130 | /* #define _SPARE (1<<SPARE) */ | ||
131 | #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) | ||
132 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) | ||
133 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) | ||
134 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) | ||
135 | #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP) | ||
136 | |||
137 | #define _TIF_USER_WORK_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \ | ||
138 | _TIF_NEED_RESCHED) | ||
139 | |||
140 | #endif /* __KERNEL__ */ | ||
141 | |||
142 | #endif /* _ASM_POWERPC_THREAD_INFO_H */ | ||
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h new file mode 100644 index 000000000000..d9b86a17271b --- /dev/null +++ b/include/asm-powerpc/time.h | |||
@@ -0,0 +1,226 @@ | |||
1 | /* | ||
2 | * Common time prototypes and such for all ppc machines. | ||
3 | * | ||
4 | * Written by Cort Dougan (cort@cs.nmt.edu) to merge | ||
5 | * Paul Mackerras' version and mine for PReP and Pmac. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #ifndef __POWERPC_TIME_H | ||
14 | #define __POWERPC_TIME_H | ||
15 | |||
16 | #ifdef __KERNEL__ | ||
17 | #include <linux/config.h> | ||
18 | #include <linux/types.h> | ||
19 | #include <linux/percpu.h> | ||
20 | |||
21 | #include <asm/processor.h> | ||
22 | #ifdef CONFIG_PPC64 | ||
23 | #include <asm/paca.h> | ||
24 | #include <asm/iseries/hv_call.h> | ||
25 | #endif | ||
26 | |||
27 | /* time.c */ | ||
28 | extern unsigned long tb_ticks_per_jiffy; | ||
29 | extern unsigned long tb_ticks_per_usec; | ||
30 | extern unsigned long tb_ticks_per_sec; | ||
31 | extern u64 tb_to_xs; | ||
32 | extern unsigned tb_to_us; | ||
33 | extern unsigned long tb_last_stamp; | ||
34 | extern u64 tb_last_jiffy; | ||
35 | |||
36 | DECLARE_PER_CPU(unsigned long, last_jiffy); | ||
37 | |||
38 | struct rtc_time; | ||
39 | extern void to_tm(int tim, struct rtc_time * tm); | ||
40 | extern time_t last_rtc_update; | ||
41 | |||
42 | extern void generic_calibrate_decr(void); | ||
43 | extern void wakeup_decrementer(void); | ||
44 | |||
45 | /* Some sane defaults: 125 MHz timebase, 1GHz processor */ | ||
46 | extern unsigned long ppc_proc_freq; | ||
47 | #define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8) | ||
48 | extern unsigned long ppc_tb_freq; | ||
49 | #define DEFAULT_TB_FREQ 125000000UL | ||
50 | |||
51 | /* | ||
52 | * By putting all of this stuff into a single struct we | ||
53 | * reduce the number of cache lines touched by do_gettimeofday. | ||
54 | * Both by collecting all of the data in one cache line and | ||
55 | * by touching only one TOC entry on ppc64. | ||
56 | */ | ||
57 | struct gettimeofday_vars { | ||
58 | u64 tb_to_xs; | ||
59 | u64 stamp_xsec; | ||
60 | u64 tb_orig_stamp; | ||
61 | }; | ||
62 | |||
63 | struct gettimeofday_struct { | ||
64 | unsigned long tb_ticks_per_sec; | ||
65 | struct gettimeofday_vars vars[2]; | ||
66 | struct gettimeofday_vars * volatile varp; | ||
67 | unsigned var_idx; | ||
68 | unsigned tb_to_us; | ||
69 | }; | ||
70 | |||
71 | struct div_result { | ||
72 | u64 result_high; | ||
73 | u64 result_low; | ||
74 | }; | ||
75 | |||
76 | /* Accessor functions for the timebase (RTC on 601) registers. */ | ||
77 | /* If one day CONFIG_POWER is added just define __USE_RTC as 1 */ | ||
78 | #ifdef CONFIG_6xx | ||
79 | #define __USE_RTC() (!cpu_has_feature(CPU_FTR_USE_TB)) | ||
80 | #else | ||
81 | #define __USE_RTC() 0 | ||
82 | #endif | ||
83 | |||
84 | /* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */ | ||
85 | static inline unsigned long get_tbl(void) | ||
86 | { | ||
87 | unsigned long tbl; | ||
88 | |||
89 | #if defined(CONFIG_403GCX) | ||
90 | asm volatile("mfspr %0, 0x3dd" : "=r" (tbl)); | ||
91 | #else | ||
92 | asm volatile("mftb %0" : "=r" (tbl)); | ||
93 | #endif | ||
94 | return tbl; | ||
95 | } | ||
96 | |||
97 | static inline unsigned int get_tbu(void) | ||
98 | { | ||
99 | unsigned int tbu; | ||
100 | |||
101 | #if defined(CONFIG_403GCX) | ||
102 | asm volatile("mfspr %0, 0x3dc" : "=r" (tbu)); | ||
103 | #else | ||
104 | asm volatile("mftbu %0" : "=r" (tbu)); | ||
105 | #endif | ||
106 | return tbu; | ||
107 | } | ||
108 | |||
109 | static inline unsigned int get_rtcl(void) | ||
110 | { | ||
111 | unsigned int rtcl; | ||
112 | |||
113 | asm volatile("mfrtcl %0" : "=r" (rtcl)); | ||
114 | return rtcl; | ||
115 | } | ||
116 | |||
117 | static inline u64 get_rtc(void) | ||
118 | { | ||
119 | unsigned int hi, lo, hi2; | ||
120 | |||
121 | do { | ||
122 | asm volatile("mfrtcu %0; mfrtcl %1; mfrtcu %2" | ||
123 | : "=r" (hi), "=r" (lo), "=r" (hi2)); | ||
124 | } while (hi2 != hi); | ||
125 | return (u64)hi * 1000000000 + lo; | ||
126 | } | ||
127 | |||
128 | #ifdef CONFIG_PPC64 | ||
129 | static inline u64 get_tb(void) | ||
130 | { | ||
131 | return mftb(); | ||
132 | } | ||
133 | #else | ||
134 | static inline u64 get_tb(void) | ||
135 | { | ||
136 | unsigned int tbhi, tblo, tbhi2; | ||
137 | |||
138 | do { | ||
139 | tbhi = get_tbu(); | ||
140 | tblo = get_tbl(); | ||
141 | tbhi2 = get_tbu(); | ||
142 | } while (tbhi != tbhi2); | ||
143 | |||
144 | return ((u64)tbhi << 32) | tblo; | ||
145 | } | ||
146 | #endif | ||
147 | |||
148 | static inline void set_tb(unsigned int upper, unsigned int lower) | ||
149 | { | ||
150 | mtspr(SPRN_TBWL, 0); | ||
151 | mtspr(SPRN_TBWU, upper); | ||
152 | mtspr(SPRN_TBWL, lower); | ||
153 | } | ||
154 | |||
155 | /* Accessor functions for the decrementer register. | ||
156 | * The 4xx doesn't even have a decrementer. I tried to use the | ||
157 | * generic timer interrupt code, which seems OK, with the 4xx PIT | ||
158 | * in auto-reload mode. The problem is PIT stops counting when it | ||
159 | * hits zero. If it would wrap, we could use it just like a decrementer. | ||
160 | */ | ||
161 | static inline unsigned int get_dec(void) | ||
162 | { | ||
163 | #if defined(CONFIG_40x) | ||
164 | return (mfspr(SPRN_PIT)); | ||
165 | #else | ||
166 | return (mfspr(SPRN_DEC)); | ||
167 | #endif | ||
168 | } | ||
169 | |||
170 | static inline void set_dec(int val) | ||
171 | { | ||
172 | #if defined(CONFIG_40x) | ||
173 | return; /* Have to let it auto-reload */ | ||
174 | #elif defined(CONFIG_8xx_CPU6) | ||
175 | set_dec_cpu6(val); | ||
176 | #else | ||
177 | #ifdef CONFIG_PPC_ISERIES | ||
178 | struct paca_struct *lpaca = get_paca(); | ||
179 | int cur_dec; | ||
180 | |||
181 | if (lpaca->lppaca.shared_proc) { | ||
182 | lpaca->lppaca.virtual_decr = val; | ||
183 | cur_dec = get_dec(); | ||
184 | if (cur_dec > val) | ||
185 | HvCall_setVirtualDecr(); | ||
186 | } else | ||
187 | #endif | ||
188 | mtspr(SPRN_DEC, val); | ||
189 | #endif /* not 40x or 8xx_CPU6 */ | ||
190 | } | ||
191 | |||
192 | static inline unsigned long tb_ticks_since(unsigned long tstamp) | ||
193 | { | ||
194 | if (__USE_RTC()) { | ||
195 | int delta = get_rtcl() - (unsigned int) tstamp; | ||
196 | return delta < 0 ? delta + 1000000000 : delta; | ||
197 | } | ||
198 | return get_tbl() - tstamp; | ||
199 | } | ||
200 | |||
201 | #define mulhwu(x,y) \ | ||
202 | ({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;}) | ||
203 | |||
204 | #ifdef CONFIG_PPC64 | ||
205 | #define mulhdu(x,y) \ | ||
206 | ({unsigned long z; asm ("mulhdu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;}) | ||
207 | #else | ||
208 | extern u64 mulhdu(u64, u64); | ||
209 | #endif | ||
210 | |||
211 | extern void smp_space_timers(unsigned int); | ||
212 | |||
213 | extern unsigned mulhwu_scale_factor(unsigned, unsigned); | ||
214 | extern void div128_by_32(u64 dividend_high, u64 dividend_low, | ||
215 | unsigned divisor, struct div_result *dr); | ||
216 | |||
217 | /* Used to store Processor Utilization register (purr) values */ | ||
218 | |||
219 | struct cpu_usage { | ||
220 | u64 current_tb; /* Holds the current purr register values */ | ||
221 | }; | ||
222 | |||
223 | DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array); | ||
224 | |||
225 | #endif /* __KERNEL__ */ | ||
226 | #endif /* __PPC64_TIME_H */ | ||
diff --git a/include/asm-powerpc/tlb.h b/include/asm-powerpc/tlb.h new file mode 100644 index 000000000000..56659f121779 --- /dev/null +++ b/include/asm-powerpc/tlb.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * TLB shootdown specifics for powerpc | ||
3 | * | ||
4 | * Copyright (C) 2002 Anton Blanchard, IBM Corp. | ||
5 | * Copyright (C) 2002 Paul Mackerras, IBM Corp. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | #ifndef _ASM_POWERPC_TLB_H | ||
13 | #define _ASM_POWERPC_TLB_H | ||
14 | |||
15 | #include <linux/config.h> | ||
16 | #ifndef __powerpc64__ | ||
17 | #include <asm/pgtable.h> | ||
18 | #endif | ||
19 | #include <asm/pgalloc.h> | ||
20 | #include <asm/tlbflush.h> | ||
21 | #ifndef __powerpc64__ | ||
22 | #include <asm/page.h> | ||
23 | #include <asm/mmu.h> | ||
24 | #endif | ||
25 | |||
26 | struct mmu_gather; | ||
27 | |||
28 | #define tlb_start_vma(tlb, vma) do { } while (0) | ||
29 | #define tlb_end_vma(tlb, vma) do { } while (0) | ||
30 | |||
31 | #if !defined(CONFIG_PPC_STD_MMU) | ||
32 | |||
33 | #define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) | ||
34 | |||
35 | #elif defined(__powerpc64__) | ||
36 | |||
37 | extern void pte_free_finish(void); | ||
38 | |||
39 | static inline void tlb_flush(struct mmu_gather *tlb) | ||
40 | { | ||
41 | flush_tlb_pending(); | ||
42 | pte_free_finish(); | ||
43 | } | ||
44 | |||
45 | #else | ||
46 | |||
47 | extern void tlb_flush(struct mmu_gather *tlb); | ||
48 | |||
49 | #endif | ||
50 | |||
51 | /* Get the generic bits... */ | ||
52 | #include <asm-generic/tlb.h> | ||
53 | |||
54 | #if !defined(CONFIG_PPC_STD_MMU) || defined(__powerpc64__) | ||
55 | |||
56 | #define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0) | ||
57 | |||
58 | #else | ||
59 | extern void flush_hash_entry(struct mm_struct *mm, pte_t *ptep, | ||
60 | unsigned long address); | ||
61 | |||
62 | static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, | ||
63 | unsigned long address) | ||
64 | { | ||
65 | if (pte_val(*ptep) & _PAGE_HASHPTE) | ||
66 | flush_hash_entry(tlb->mm, ptep, address); | ||
67 | } | ||
68 | |||
69 | #endif | ||
70 | #endif /* __ASM_POWERPC_TLB_H */ | ||
diff --git a/include/asm-powerpc/tlbflush.h b/include/asm-powerpc/tlbflush.h new file mode 100644 index 000000000000..ca3655672bbc --- /dev/null +++ b/include/asm-powerpc/tlbflush.h | |||
@@ -0,0 +1,146 @@ | |||
1 | #ifndef _ASM_POWERPC_TLBFLUSH_H | ||
2 | #define _ASM_POWERPC_TLBFLUSH_H | ||
3 | /* | ||
4 | * TLB flushing: | ||
5 | * | ||
6 | * - flush_tlb_mm(mm) flushes the specified mm context TLB's | ||
7 | * - flush_tlb_page(vma, vmaddr) flushes one page | ||
8 | * - flush_tlb_page_nohash(vma, vmaddr) flushes one page if SW loaded TLB | ||
9 | * - flush_tlb_range(vma, start, end) flushes a range of pages | ||
10 | * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages | ||
11 | * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version | ||
16 | * 2 of the License, or (at your option) any later version. | ||
17 | */ | ||
18 | #ifdef __KERNEL__ | ||
19 | |||
20 | #include <linux/config.h> | ||
21 | |||
22 | struct mm_struct; | ||
23 | |||
24 | #ifdef CONFIG_PPC64 | ||
25 | |||
26 | #include <linux/percpu.h> | ||
27 | #include <asm/page.h> | ||
28 | |||
29 | #define PPC64_TLB_BATCH_NR 192 | ||
30 | |||
31 | struct ppc64_tlb_batch { | ||
32 | unsigned long index; | ||
33 | struct mm_struct *mm; | ||
34 | pte_t pte[PPC64_TLB_BATCH_NR]; | ||
35 | unsigned long vaddr[PPC64_TLB_BATCH_NR]; | ||
36 | unsigned int large; | ||
37 | }; | ||
38 | DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); | ||
39 | |||
40 | extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch); | ||
41 | |||
42 | static inline void flush_tlb_pending(void) | ||
43 | { | ||
44 | struct ppc64_tlb_batch *batch = &get_cpu_var(ppc64_tlb_batch); | ||
45 | |||
46 | if (batch->index) | ||
47 | __flush_tlb_pending(batch); | ||
48 | put_cpu_var(ppc64_tlb_batch); | ||
49 | } | ||
50 | |||
51 | extern void flush_hash_page(unsigned long va, pte_t pte, int local); | ||
52 | void flush_hash_range(unsigned long number, int local); | ||
53 | |||
54 | #else /* CONFIG_PPC64 */ | ||
55 | |||
56 | #include <linux/mm.h> | ||
57 | |||
58 | extern void _tlbie(unsigned long address); | ||
59 | extern void _tlbia(void); | ||
60 | |||
61 | /* | ||
62 | * TODO: (CONFIG_FSL_BOOKE) determine if flush_tlb_range & | ||
63 | * flush_tlb_kernel_range are best implemented as tlbia vs | ||
64 | * specific tlbie's | ||
65 | */ | ||
66 | |||
67 | #if (defined(CONFIG_4xx) && !defined(CONFIG_44x)) || defined(CONFIG_8xx) | ||
68 | #define flush_tlb_pending() asm volatile ("tlbia; sync" : : : "memory") | ||
69 | #elif defined(CONFIG_4xx) || defined(CONFIG_FSL_BOOKE) | ||
70 | #define flush_tlb_pending() _tlbia() | ||
71 | #endif | ||
72 | |||
73 | /* | ||
74 | * This gets called at the end of handling a page fault, when | ||
75 | * the kernel has put a new PTE into the page table for the process. | ||
76 | * We use it to ensure coherency between the i-cache and d-cache | ||
77 | * for the page which has just been mapped in. | ||
78 | * On machines which use an MMU hash table, we use this to put a | ||
79 | * corresponding HPTE into the hash table ahead of time, instead of | ||
80 | * waiting for the inevitable extra hash-table miss exception. | ||
81 | */ | ||
82 | extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t); | ||
83 | |||
84 | #endif /* CONFIG_PPC64 */ | ||
85 | |||
86 | #if defined(CONFIG_PPC64) || defined(CONFIG_4xx) || \ | ||
87 | defined(CONFIG_FSL_BOOKE) || defined(CONFIG_8xx) | ||
88 | |||
89 | static inline void flush_tlb_mm(struct mm_struct *mm) | ||
90 | { | ||
91 | flush_tlb_pending(); | ||
92 | } | ||
93 | |||
94 | static inline void flush_tlb_page(struct vm_area_struct *vma, | ||
95 | unsigned long vmaddr) | ||
96 | { | ||
97 | #ifdef CONFIG_PPC64 | ||
98 | flush_tlb_pending(); | ||
99 | #else | ||
100 | _tlbie(vmaddr); | ||
101 | #endif | ||
102 | } | ||
103 | |||
104 | static inline void flush_tlb_page_nohash(struct vm_area_struct *vma, | ||
105 | unsigned long vmaddr) | ||
106 | { | ||
107 | #ifndef CONFIG_PPC64 | ||
108 | _tlbie(vmaddr); | ||
109 | #endif | ||
110 | } | ||
111 | |||
112 | static inline void flush_tlb_range(struct vm_area_struct *vma, | ||
113 | unsigned long start, unsigned long end) | ||
114 | { | ||
115 | flush_tlb_pending(); | ||
116 | } | ||
117 | |||
118 | static inline void flush_tlb_kernel_range(unsigned long start, | ||
119 | unsigned long end) | ||
120 | { | ||
121 | flush_tlb_pending(); | ||
122 | } | ||
123 | |||
124 | #else /* 6xx, 7xx, 7xxx cpus */ | ||
125 | |||
126 | extern void flush_tlb_mm(struct mm_struct *mm); | ||
127 | extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr); | ||
128 | extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr); | ||
129 | extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, | ||
130 | unsigned long end); | ||
131 | extern void flush_tlb_kernel_range(unsigned long start, unsigned long end); | ||
132 | |||
133 | #endif | ||
134 | |||
135 | /* | ||
136 | * This is called in munmap when we have freed up some page-table | ||
137 | * pages. We don't need to do anything here, there's nothing special | ||
138 | * about our page-table pages. -- paulus | ||
139 | */ | ||
140 | static inline void flush_tlb_pgtables(struct mm_struct *mm, | ||
141 | unsigned long start, unsigned long end) | ||
142 | { | ||
143 | } | ||
144 | |||
145 | #endif /*__KERNEL__ */ | ||
146 | #endif /* _ASM_POWERPC_TLBFLUSH_H */ | ||
diff --git a/include/asm-powerpc/types.h b/include/asm-powerpc/types.h new file mode 100644 index 000000000000..ec3c2ee8bf86 --- /dev/null +++ b/include/asm-powerpc/types.h | |||
@@ -0,0 +1,110 @@ | |||
1 | #ifndef _ASM_POWERPC_TYPES_H | ||
2 | #define _ASM_POWERPC_TYPES_H | ||
3 | |||
4 | #ifndef __ASSEMBLY__ | ||
5 | |||
6 | /* | ||
7 | * This file is never included by application software unless | ||
8 | * explicitly requested (e.g., via linux/types.h) in which case the | ||
9 | * application is Linux specific so (user-) name space pollution is | ||
10 | * not a major issue. However, for interoperability, libraries still | ||
11 | * need to be careful to avoid a name clashes. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version | ||
16 | * 2 of the License, or (at your option) any later version. | ||
17 | */ | ||
18 | |||
19 | #ifdef __powerpc64__ | ||
20 | typedef unsigned int umode_t; | ||
21 | #else | ||
22 | typedef unsigned short umode_t; | ||
23 | #endif | ||
24 | |||
25 | /* | ||
26 | * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the | ||
27 | * header files exported to user space | ||
28 | */ | ||
29 | |||
30 | typedef __signed__ char __s8; | ||
31 | typedef unsigned char __u8; | ||
32 | |||
33 | typedef __signed__ short __s16; | ||
34 | typedef unsigned short __u16; | ||
35 | |||
36 | typedef __signed__ int __s32; | ||
37 | typedef unsigned int __u32; | ||
38 | |||
39 | #ifdef __powerpc64__ | ||
40 | typedef __signed__ long __s64; | ||
41 | typedef unsigned long __u64; | ||
42 | #else | ||
43 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) | ||
44 | typedef __signed__ long long __s64; | ||
45 | typedef unsigned long long __u64; | ||
46 | #endif | ||
47 | #endif /* __powerpc64__ */ | ||
48 | |||
49 | typedef struct { | ||
50 | __u32 u[4]; | ||
51 | } __attribute((aligned(16))) __vector128; | ||
52 | |||
53 | #endif /* __ASSEMBLY__ */ | ||
54 | |||
55 | #ifdef __KERNEL__ | ||
56 | /* | ||
57 | * These aren't exported outside the kernel to avoid name space clashes | ||
58 | */ | ||
59 | #ifdef __powerpc64__ | ||
60 | #define BITS_PER_LONG 64 | ||
61 | #else | ||
62 | #define BITS_PER_LONG 32 | ||
63 | #endif | ||
64 | |||
65 | #ifndef __ASSEMBLY__ | ||
66 | |||
67 | #include <linux/config.h> | ||
68 | |||
69 | typedef signed char s8; | ||
70 | typedef unsigned char u8; | ||
71 | |||
72 | typedef signed short s16; | ||
73 | typedef unsigned short u16; | ||
74 | |||
75 | typedef signed int s32; | ||
76 | typedef unsigned int u32; | ||
77 | |||
78 | #ifdef __powerpc64__ | ||
79 | typedef signed long s64; | ||
80 | typedef unsigned long u64; | ||
81 | #else | ||
82 | typedef signed long long s64; | ||
83 | typedef unsigned long long u64; | ||
84 | #endif | ||
85 | |||
86 | typedef __vector128 vector128; | ||
87 | |||
88 | #ifdef __powerpc64__ | ||
89 | typedef u64 dma_addr_t; | ||
90 | #else | ||
91 | typedef u32 dma_addr_t; | ||
92 | #endif | ||
93 | typedef u64 dma64_addr_t; | ||
94 | |||
95 | typedef struct { | ||
96 | unsigned long entry; | ||
97 | unsigned long toc; | ||
98 | unsigned long env; | ||
99 | } func_descr_t; | ||
100 | |||
101 | #ifdef CONFIG_LBD | ||
102 | typedef u64 sector_t; | ||
103 | #define HAVE_SECTOR_T | ||
104 | #endif | ||
105 | |||
106 | #endif /* __ASSEMBLY__ */ | ||
107 | |||
108 | #endif /* __KERNEL__ */ | ||
109 | |||
110 | #endif /* _ASM_POWERPC_TYPES_H */ | ||
diff --git a/include/asm-powerpc/uaccess.h b/include/asm-powerpc/uaccess.h new file mode 100644 index 000000000000..33af730f0d19 --- /dev/null +++ b/include/asm-powerpc/uaccess.h | |||
@@ -0,0 +1,468 @@ | |||
1 | #ifndef _ARCH_POWERPC_UACCESS_H | ||
2 | #define _ARCH_POWERPC_UACCESS_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | #ifndef __ASSEMBLY__ | ||
6 | |||
7 | #include <linux/sched.h> | ||
8 | #include <linux/errno.h> | ||
9 | #include <asm/processor.h> | ||
10 | |||
11 | #define VERIFY_READ 0 | ||
12 | #define VERIFY_WRITE 1 | ||
13 | |||
14 | /* | ||
15 | * The fs value determines whether argument validity checking should be | ||
16 | * performed or not. If get_fs() == USER_DS, checking is performed, with | ||
17 | * get_fs() == KERNEL_DS, checking is bypassed. | ||
18 | * | ||
19 | * For historical reasons, these macros are grossly misnamed. | ||
20 | * | ||
21 | * The fs/ds values are now the highest legal address in the "segment". | ||
22 | * This simplifies the checking in the routines below. | ||
23 | */ | ||
24 | |||
25 | #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) | ||
26 | |||
27 | #define KERNEL_DS MAKE_MM_SEG(~0UL) | ||
28 | #ifdef __powerpc64__ | ||
29 | /* We use TASK_SIZE_USER64 as TASK_SIZE is not constant */ | ||
30 | #define USER_DS MAKE_MM_SEG(TASK_SIZE_USER64 - 1) | ||
31 | #else | ||
32 | #define USER_DS MAKE_MM_SEG(TASK_SIZE - 1) | ||
33 | #endif | ||
34 | |||
35 | #define get_ds() (KERNEL_DS) | ||
36 | #define get_fs() (current->thread.fs) | ||
37 | #define set_fs(val) (current->thread.fs = (val)) | ||
38 | |||
39 | #define segment_eq(a, b) ((a).seg == (b).seg) | ||
40 | |||
41 | #ifdef __powerpc64__ | ||
42 | /* | ||
43 | * This check is sufficient because there is a large enough | ||
44 | * gap between user addresses and the kernel addresses | ||
45 | */ | ||
46 | #define __access_ok(addr, size, segment) \ | ||
47 | (((addr) <= (segment).seg) && ((size) <= (segment).seg)) | ||
48 | |||
49 | #else | ||
50 | |||
51 | #define __access_ok(addr, size, segment) \ | ||
52 | (((addr) <= (segment).seg) && \ | ||
53 | (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr))))) | ||
54 | |||
55 | #endif | ||
56 | |||
57 | #define access_ok(type, addr, size) \ | ||
58 | (__chk_user_ptr(addr), \ | ||
59 | __access_ok((__force unsigned long)(addr), (size), get_fs())) | ||
60 | |||
61 | /* | ||
62 | * The exception table consists of pairs of addresses: the first is the | ||
63 | * address of an instruction that is allowed to fault, and the second is | ||
64 | * the address at which the program should continue. No registers are | ||
65 | * modified, so it is entirely up to the continuation code to figure out | ||
66 | * what to do. | ||
67 | * | ||
68 | * All the routines below use bits of fixup code that are out of line | ||
69 | * with the main instruction path. This means when everything is well, | ||
70 | * we don't even have to jump over them. Further, they do not intrude | ||
71 | * on our cache or tlb entries. | ||
72 | */ | ||
73 | |||
74 | struct exception_table_entry { | ||
75 | unsigned long insn; | ||
76 | unsigned long fixup; | ||
77 | }; | ||
78 | |||
79 | /* | ||
80 | * These are the main single-value transfer routines. They automatically | ||
81 | * use the right size if we just have the right pointer type. | ||
82 | * | ||
83 | * This gets kind of ugly. We want to return _two_ values in "get_user()" | ||
84 | * and yet we don't want to do any pointers, because that is too much | ||
85 | * of a performance impact. Thus we have a few rather ugly macros here, | ||
86 | * and hide all the ugliness from the user. | ||
87 | * | ||
88 | * The "__xxx" versions of the user access functions are versions that | ||
89 | * do not verify the address space, that must have been done previously | ||
90 | * with a separate "access_ok()" call (this is used when we do multiple | ||
91 | * accesses to the same area of user memory). | ||
92 | * | ||
93 | * As we use the same address space for kernel and user data on the | ||
94 | * PowerPC, we can just do these as direct assignments. (Of course, the | ||
95 | * exception handling means that it's no longer "just"...) | ||
96 | * | ||
97 | * The "user64" versions of the user access functions are versions that | ||
98 | * allow access of 64-bit data. The "get_user" functions do not | ||
99 | * properly handle 64-bit data because the value gets down cast to a long. | ||
100 | * The "put_user" functions already handle 64-bit data properly but we add | ||
101 | * "user64" versions for completeness | ||
102 | */ | ||
103 | #define get_user(x, ptr) \ | ||
104 | __get_user_check((x), (ptr), sizeof(*(ptr))) | ||
105 | #define put_user(x, ptr) \ | ||
106 | __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) | ||
107 | |||
108 | #define __get_user(x, ptr) \ | ||
109 | __get_user_nocheck((x), (ptr), sizeof(*(ptr))) | ||
110 | #define __put_user(x, ptr) \ | ||
111 | __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) | ||
112 | #ifndef __powerpc64__ | ||
113 | #define __get_user64(x, ptr) \ | ||
114 | __get_user64_nocheck((x), (ptr), sizeof(*(ptr))) | ||
115 | #define __put_user64(x, ptr) __put_user(x, ptr) | ||
116 | #endif | ||
117 | |||
118 | #define __get_user_unaligned __get_user | ||
119 | #define __put_user_unaligned __put_user | ||
120 | |||
121 | extern long __put_user_bad(void); | ||
122 | |||
123 | #ifdef __powerpc64__ | ||
124 | #define __EX_TABLE_ALIGN "3" | ||
125 | #define __EX_TABLE_TYPE "llong" | ||
126 | #else | ||
127 | #define __EX_TABLE_ALIGN "2" | ||
128 | #define __EX_TABLE_TYPE "long" | ||
129 | #endif | ||
130 | |||
131 | /* | ||
132 | * We don't tell gcc that we are accessing memory, but this is OK | ||
133 | * because we do not write to any memory gcc knows about, so there | ||
134 | * are no aliasing issues. | ||
135 | */ | ||
136 | #define __put_user_asm(x, addr, err, op) \ | ||
137 | __asm__ __volatile__( \ | ||
138 | "1: " op " %1,0(%2) # put_user\n" \ | ||
139 | "2:\n" \ | ||
140 | ".section .fixup,\"ax\"\n" \ | ||
141 | "3: li %0,%3\n" \ | ||
142 | " b 2b\n" \ | ||
143 | ".previous\n" \ | ||
144 | ".section __ex_table,\"a\"\n" \ | ||
145 | " .align " __EX_TABLE_ALIGN "\n" \ | ||
146 | " ."__EX_TABLE_TYPE" 1b,3b\n" \ | ||
147 | ".previous" \ | ||
148 | : "=r" (err) \ | ||
149 | : "r" (x), "b" (addr), "i" (-EFAULT), "0" (err)) | ||
150 | |||
151 | #ifdef __powerpc64__ | ||
152 | #define __put_user_asm2(x, ptr, retval) \ | ||
153 | __put_user_asm(x, ptr, retval, "std") | ||
154 | #else /* __powerpc64__ */ | ||
155 | #define __put_user_asm2(x, addr, err) \ | ||
156 | __asm__ __volatile__( \ | ||
157 | "1: stw %1,0(%2)\n" \ | ||
158 | "2: stw %1+1,4(%2)\n" \ | ||
159 | "3:\n" \ | ||
160 | ".section .fixup,\"ax\"\n" \ | ||
161 | "4: li %0,%3\n" \ | ||
162 | " b 3b\n" \ | ||
163 | ".previous\n" \ | ||
164 | ".section __ex_table,\"a\"\n" \ | ||
165 | " .align " __EX_TABLE_ALIGN "\n" \ | ||
166 | " ." __EX_TABLE_TYPE " 1b,4b\n" \ | ||
167 | " ." __EX_TABLE_TYPE " 2b,4b\n" \ | ||
168 | ".previous" \ | ||
169 | : "=r" (err) \ | ||
170 | : "r" (x), "b" (addr), "i" (-EFAULT), "0" (err)) | ||
171 | #endif /* __powerpc64__ */ | ||
172 | |||
173 | #define __put_user_size(x, ptr, size, retval) \ | ||
174 | do { \ | ||
175 | retval = 0; \ | ||
176 | switch (size) { \ | ||
177 | case 1: __put_user_asm(x, ptr, retval, "stb"); break; \ | ||
178 | case 2: __put_user_asm(x, ptr, retval, "sth"); break; \ | ||
179 | case 4: __put_user_asm(x, ptr, retval, "stw"); break; \ | ||
180 | case 8: __put_user_asm2(x, ptr, retval); break; \ | ||
181 | default: __put_user_bad(); \ | ||
182 | } \ | ||
183 | } while (0) | ||
184 | |||
185 | #define __put_user_nocheck(x, ptr, size) \ | ||
186 | ({ \ | ||
187 | long __pu_err; \ | ||
188 | might_sleep(); \ | ||
189 | __chk_user_ptr(ptr); \ | ||
190 | __put_user_size((x), (ptr), (size), __pu_err); \ | ||
191 | __pu_err; \ | ||
192 | }) | ||
193 | |||
194 | #define __put_user_check(x, ptr, size) \ | ||
195 | ({ \ | ||
196 | long __pu_err = -EFAULT; \ | ||
197 | __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ | ||
198 | might_sleep(); \ | ||
199 | if (access_ok(VERIFY_WRITE, __pu_addr, size)) \ | ||
200 | __put_user_size((x), __pu_addr, (size), __pu_err); \ | ||
201 | __pu_err; \ | ||
202 | }) | ||
203 | |||
204 | extern long __get_user_bad(void); | ||
205 | |||
206 | #define __get_user_asm(x, addr, err, op) \ | ||
207 | __asm__ __volatile__( \ | ||
208 | "1: "op" %1,0(%2) # get_user\n" \ | ||
209 | "2:\n" \ | ||
210 | ".section .fixup,\"ax\"\n" \ | ||
211 | "3: li %0,%3\n" \ | ||
212 | " li %1,0\n" \ | ||
213 | " b 2b\n" \ | ||
214 | ".previous\n" \ | ||
215 | ".section __ex_table,\"a\"\n" \ | ||
216 | " .align "__EX_TABLE_ALIGN "\n" \ | ||
217 | " ." __EX_TABLE_TYPE " 1b,3b\n" \ | ||
218 | ".previous" \ | ||
219 | : "=r" (err), "=r" (x) \ | ||
220 | : "b" (addr), "i" (-EFAULT), "0" (err)) | ||
221 | |||
222 | #ifdef __powerpc64__ | ||
223 | #define __get_user_asm2(x, addr, err) \ | ||
224 | __get_user_asm(x, addr, err, "ld") | ||
225 | #else /* __powerpc64__ */ | ||
226 | #define __get_user_asm2(x, addr, err) \ | ||
227 | __asm__ __volatile__( \ | ||
228 | "1: lwz %1,0(%2)\n" \ | ||
229 | "2: lwz %1+1,4(%2)\n" \ | ||
230 | "3:\n" \ | ||
231 | ".section .fixup,\"ax\"\n" \ | ||
232 | "4: li %0,%3\n" \ | ||
233 | " li %1,0\n" \ | ||
234 | " li %1+1,0\n" \ | ||
235 | " b 3b\n" \ | ||
236 | ".previous\n" \ | ||
237 | ".section __ex_table,\"a\"\n" \ | ||
238 | " .align " __EX_TABLE_ALIGN "\n" \ | ||
239 | " ." __EX_TABLE_TYPE " 1b,4b\n" \ | ||
240 | " ." __EX_TABLE_TYPE " 2b,4b\n" \ | ||
241 | ".previous" \ | ||
242 | : "=r" (err), "=&r" (x) \ | ||
243 | : "b" (addr), "i" (-EFAULT), "0" (err)) | ||
244 | #endif /* __powerpc64__ */ | ||
245 | |||
246 | #define __get_user_size(x, ptr, size, retval) \ | ||
247 | do { \ | ||
248 | retval = 0; \ | ||
249 | __chk_user_ptr(ptr); \ | ||
250 | if (size > sizeof(x)) \ | ||
251 | (x) = __get_user_bad(); \ | ||
252 | switch (size) { \ | ||
253 | case 1: __get_user_asm(x, ptr, retval, "lbz"); break; \ | ||
254 | case 2: __get_user_asm(x, ptr, retval, "lhz"); break; \ | ||
255 | case 4: __get_user_asm(x, ptr, retval, "lwz"); break; \ | ||
256 | case 8: __get_user_asm2(x, ptr, retval); break; \ | ||
257 | default: (x) = __get_user_bad(); \ | ||
258 | } \ | ||
259 | } while (0) | ||
260 | |||
261 | #define __get_user_nocheck(x, ptr, size) \ | ||
262 | ({ \ | ||
263 | long __gu_err; \ | ||
264 | unsigned long __gu_val; \ | ||
265 | __chk_user_ptr(ptr); \ | ||
266 | might_sleep(); \ | ||
267 | __get_user_size(__gu_val, (ptr), (size), __gu_err); \ | ||
268 | (x) = (__typeof__(*(ptr)))__gu_val; \ | ||
269 | __gu_err; \ | ||
270 | }) | ||
271 | |||
272 | #ifndef __powerpc64__ | ||
273 | #define __get_user64_nocheck(x, ptr, size) \ | ||
274 | ({ \ | ||
275 | long __gu_err; \ | ||
276 | long long __gu_val; \ | ||
277 | __chk_user_ptr(ptr); \ | ||
278 | might_sleep(); \ | ||
279 | __get_user_size(__gu_val, (ptr), (size), __gu_err); \ | ||
280 | (x) = (__typeof__(*(ptr)))__gu_val; \ | ||
281 | __gu_err; \ | ||
282 | }) | ||
283 | #endif /* __powerpc64__ */ | ||
284 | |||
285 | #define __get_user_check(x, ptr, size) \ | ||
286 | ({ \ | ||
287 | long __gu_err = -EFAULT; \ | ||
288 | unsigned long __gu_val = 0; \ | ||
289 | const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ | ||
290 | might_sleep(); \ | ||
291 | if (access_ok(VERIFY_READ, __gu_addr, (size))) \ | ||
292 | __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ | ||
293 | (x) = (__typeof__(*(ptr)))__gu_val; \ | ||
294 | __gu_err; \ | ||
295 | }) | ||
296 | |||
297 | /* more complex routines */ | ||
298 | |||
299 | extern unsigned long __copy_tofrom_user(void __user *to, | ||
300 | const void __user *from, unsigned long size); | ||
301 | |||
302 | #ifndef __powerpc64__ | ||
303 | |||
304 | extern inline unsigned long copy_from_user(void *to, | ||
305 | const void __user *from, unsigned long n) | ||
306 | { | ||
307 | unsigned long over; | ||
308 | |||
309 | if (access_ok(VERIFY_READ, from, n)) | ||
310 | return __copy_tofrom_user((__force void __user *)to, from, n); | ||
311 | if ((unsigned long)from < TASK_SIZE) { | ||
312 | over = (unsigned long)from + n - TASK_SIZE; | ||
313 | return __copy_tofrom_user((__force void __user *)to, from, | ||
314 | n - over) + over; | ||
315 | } | ||
316 | return n; | ||
317 | } | ||
318 | |||
319 | extern inline unsigned long copy_to_user(void __user *to, | ||
320 | const void *from, unsigned long n) | ||
321 | { | ||
322 | unsigned long over; | ||
323 | |||
324 | if (access_ok(VERIFY_WRITE, to, n)) | ||
325 | return __copy_tofrom_user(to, (__force void __user *)from, n); | ||
326 | if ((unsigned long)to < TASK_SIZE) { | ||
327 | over = (unsigned long)to + n - TASK_SIZE; | ||
328 | return __copy_tofrom_user(to, (__force void __user *)from, | ||
329 | n - over) + over; | ||
330 | } | ||
331 | return n; | ||
332 | } | ||
333 | |||
334 | #else /* __powerpc64__ */ | ||
335 | |||
336 | #define __copy_in_user(to, from, size) \ | ||
337 | __copy_tofrom_user((to), (from), (size)) | ||
338 | |||
339 | extern unsigned long copy_from_user(void *to, const void __user *from, | ||
340 | unsigned long n); | ||
341 | extern unsigned long copy_to_user(void __user *to, const void *from, | ||
342 | unsigned long n); | ||
343 | extern unsigned long copy_in_user(void __user *to, const void __user *from, | ||
344 | unsigned long n); | ||
345 | |||
346 | #endif /* __powerpc64__ */ | ||
347 | |||
348 | static inline unsigned long __copy_from_user_inatomic(void *to, | ||
349 | const void __user *from, unsigned long n) | ||
350 | { | ||
351 | if (__builtin_constant_p(n) && (n <= 8)) { | ||
352 | unsigned long ret; | ||
353 | |||
354 | switch (n) { | ||
355 | case 1: | ||
356 | __get_user_size(*(u8 *)to, from, 1, ret); | ||
357 | break; | ||
358 | case 2: | ||
359 | __get_user_size(*(u16 *)to, from, 2, ret); | ||
360 | break; | ||
361 | case 4: | ||
362 | __get_user_size(*(u32 *)to, from, 4, ret); | ||
363 | break; | ||
364 | case 8: | ||
365 | __get_user_size(*(u64 *)to, from, 8, ret); | ||
366 | break; | ||
367 | } | ||
368 | if (ret == 0) | ||
369 | return 0; | ||
370 | } | ||
371 | return __copy_tofrom_user((__force void __user *)to, from, n); | ||
372 | } | ||
373 | |||
374 | static inline unsigned long __copy_to_user_inatomic(void __user *to, | ||
375 | const void *from, unsigned long n) | ||
376 | { | ||
377 | if (__builtin_constant_p(n) && (n <= 8)) { | ||
378 | unsigned long ret; | ||
379 | |||
380 | switch (n) { | ||
381 | case 1: | ||
382 | __put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret); | ||
383 | break; | ||
384 | case 2: | ||
385 | __put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret); | ||
386 | break; | ||
387 | case 4: | ||
388 | __put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret); | ||
389 | break; | ||
390 | case 8: | ||
391 | __put_user_size(*(u64 *)from, (u64 __user *)to, 8, ret); | ||
392 | break; | ||
393 | } | ||
394 | if (ret == 0) | ||
395 | return 0; | ||
396 | } | ||
397 | return __copy_tofrom_user(to, (__force const void __user *)from, n); | ||
398 | } | ||
399 | |||
400 | static inline unsigned long __copy_from_user(void *to, | ||
401 | const void __user *from, unsigned long size) | ||
402 | { | ||
403 | might_sleep(); | ||
404 | return __copy_from_user_inatomic(to, from, size); | ||
405 | } | ||
406 | |||
407 | static inline unsigned long __copy_to_user(void __user *to, | ||
408 | const void *from, unsigned long size) | ||
409 | { | ||
410 | might_sleep(); | ||
411 | return __copy_to_user_inatomic(to, from, size); | ||
412 | } | ||
413 | |||
414 | extern unsigned long __clear_user(void __user *addr, unsigned long size); | ||
415 | |||
416 | static inline unsigned long clear_user(void __user *addr, unsigned long size) | ||
417 | { | ||
418 | might_sleep(); | ||
419 | if (likely(access_ok(VERIFY_WRITE, addr, size))) | ||
420 | return __clear_user(addr, size); | ||
421 | if ((unsigned long)addr < TASK_SIZE) { | ||
422 | unsigned long over = (unsigned long)addr + size - TASK_SIZE; | ||
423 | return __clear_user(addr, size - over) + over; | ||
424 | } | ||
425 | return size; | ||
426 | } | ||
427 | |||
428 | extern int __strncpy_from_user(char *dst, const char __user *src, long count); | ||
429 | |||
430 | static inline long strncpy_from_user(char *dst, const char __user *src, | ||
431 | long count) | ||
432 | { | ||
433 | might_sleep(); | ||
434 | if (likely(access_ok(VERIFY_READ, src, 1))) | ||
435 | return __strncpy_from_user(dst, src, count); | ||
436 | return -EFAULT; | ||
437 | } | ||
438 | |||
439 | /* | ||
440 | * Return the size of a string (including the ending 0) | ||
441 | * | ||
442 | * Return 0 for error | ||
443 | */ | ||
444 | extern int __strnlen_user(const char __user *str, long len, unsigned long top); | ||
445 | |||
446 | /* | ||
447 | * Returns the length of the string at str (including the null byte), | ||
448 | * or 0 if we hit a page we can't access, | ||
449 | * or something > len if we didn't find a null byte. | ||
450 | * | ||
451 | * The `top' parameter to __strnlen_user is to make sure that | ||
452 | * we can never overflow from the user area into kernel space. | ||
453 | */ | ||
454 | static inline int strnlen_user(const char __user *str, long len) | ||
455 | { | ||
456 | unsigned long top = current->thread.fs.seg; | ||
457 | |||
458 | if ((unsigned long)str > top) | ||
459 | return 0; | ||
460 | return __strnlen_user(str, len, top); | ||
461 | } | ||
462 | |||
463 | #define strlen_user(str) strnlen_user((str), 0x7ffffffe) | ||
464 | |||
465 | #endif /* __ASSEMBLY__ */ | ||
466 | #endif /* __KERNEL__ */ | ||
467 | |||
468 | #endif /* _ARCH_POWERPC_UACCESS_H */ | ||
diff --git a/include/asm-powerpc/ucontext.h b/include/asm-powerpc/ucontext.h new file mode 100644 index 000000000000..d9a4ddf0cc86 --- /dev/null +++ b/include/asm-powerpc/ucontext.h | |||
@@ -0,0 +1,40 @@ | |||
1 | #ifndef _ASM_POWERPC_UCONTEXT_H | ||
2 | #define _ASM_POWERPC_UCONTEXT_H | ||
3 | |||
4 | #ifdef __powerpc64__ | ||
5 | #include <asm/sigcontext.h> | ||
6 | #else | ||
7 | #include <asm/elf.h> | ||
8 | #endif | ||
9 | #include <asm/signal.h> | ||
10 | |||
11 | #ifndef __powerpc64__ | ||
12 | struct mcontext { | ||
13 | elf_gregset_t mc_gregs; | ||
14 | elf_fpregset_t mc_fregs; | ||
15 | unsigned long mc_pad[2]; | ||
16 | elf_vrregset_t mc_vregs __attribute__((__aligned__(16))); | ||
17 | }; | ||
18 | #endif | ||
19 | |||
20 | struct ucontext { | ||
21 | unsigned long uc_flags; | ||
22 | struct ucontext __user *uc_link; | ||
23 | stack_t uc_stack; | ||
24 | #ifndef __powerpc64__ | ||
25 | int uc_pad[7]; | ||
26 | struct mcontext __user *uc_regs;/* points to uc_mcontext field */ | ||
27 | #endif | ||
28 | sigset_t uc_sigmask; | ||
29 | /* glibc has 1024-bit signal masks, ours are 64-bit */ | ||
30 | #ifdef __powerpc64__ | ||
31 | sigset_t __unused[15]; /* Allow for uc_sigmask growth */ | ||
32 | struct sigcontext uc_mcontext; /* last for extensibility */ | ||
33 | #else | ||
34 | int uc_maskext[30]; | ||
35 | int uc_pad2[3]; | ||
36 | struct mcontext uc_mcontext; | ||
37 | #endif | ||
38 | }; | ||
39 | |||
40 | #endif /* _ASM_POWERPC_UCONTEXT_H */ | ||
diff --git a/include/asm-powerpc/uninorth.h b/include/asm-powerpc/uninorth.h new file mode 100644 index 000000000000..f737732c3861 --- /dev/null +++ b/include/asm-powerpc/uninorth.h | |||
@@ -0,0 +1,229 @@ | |||
1 | /* | ||
2 | * uninorth.h: definitions for using the "UniNorth" host bridge chip | ||
3 | * from Apple. This chip is used on "Core99" machines | ||
4 | * This also includes U2 used on more recent MacRISC2/3 | ||
5 | * machines and U3 (G5) | ||
6 | * | ||
7 | */ | ||
8 | #ifdef __KERNEL__ | ||
9 | #ifndef __ASM_UNINORTH_H__ | ||
10 | #define __ASM_UNINORTH_H__ | ||
11 | |||
12 | /* | ||
13 | * Uni-N and U3 config space reg. definitions | ||
14 | * | ||
15 | * (Little endian) | ||
16 | */ | ||
17 | |||
18 | /* Address ranges selection. This one should work with Bandit too */ | ||
19 | /* Not U3 */ | ||
20 | #define UNI_N_ADDR_SELECT 0x48 | ||
21 | #define UNI_N_ADDR_COARSE_MASK 0xffff0000 /* 256Mb regions at *0000000 */ | ||
22 | #define UNI_N_ADDR_FINE_MASK 0x0000ffff /* 16Mb regions at f*000000 */ | ||
23 | |||
24 | /* AGP registers */ | ||
25 | /* Not U3 */ | ||
26 | #define UNI_N_CFG_GART_BASE 0x8c | ||
27 | #define UNI_N_CFG_AGP_BASE 0x90 | ||
28 | #define UNI_N_CFG_GART_CTRL 0x94 | ||
29 | #define UNI_N_CFG_INTERNAL_STATUS 0x98 | ||
30 | #define UNI_N_CFG_GART_DUMMY_PAGE 0xa4 | ||
31 | |||
32 | /* UNI_N_CFG_GART_CTRL bits definitions */ | ||
33 | #define UNI_N_CFG_GART_INVAL 0x00000001 | ||
34 | #define UNI_N_CFG_GART_ENABLE 0x00000100 | ||
35 | #define UNI_N_CFG_GART_2xRESET 0x00010000 | ||
36 | #define UNI_N_CFG_GART_DISSBADET 0x00020000 | ||
37 | /* The following seems to only be used only on U3 <j.glisse@gmail.com> */ | ||
38 | #define U3_N_CFG_GART_SYNCMODE 0x00040000 | ||
39 | #define U3_N_CFG_GART_PERFRD 0x00080000 | ||
40 | #define U3_N_CFG_GART_B2BGNT 0x00200000 | ||
41 | #define U3_N_CFG_GART_FASTDDR 0x00400000 | ||
42 | |||
43 | /* My understanding of UniNorth AGP as of UniNorth rev 1.0x, | ||
44 | * revision 1.5 (x4 AGP) may need further changes. | ||
45 | * | ||
46 | * AGP_BASE register contains the base address of the AGP aperture on | ||
47 | * the AGP bus. It doesn't seem to be visible to the CPU as of UniNorth 1.x, | ||
48 | * even if decoding of this address range is enabled in the address select | ||
49 | * register. Apparently, the only supported bases are 256Mb multiples | ||
50 | * (high 4 bits of that register). | ||
51 | * | ||
52 | * GART_BASE register appear to contain the physical address of the GART | ||
53 | * in system memory in the high address bits (page aligned), and the | ||
54 | * GART size in the low order bits (number of GART pages) | ||
55 | * | ||
56 | * The GART format itself is one 32bits word per physical memory page. | ||
57 | * This word contains, in little-endian format (!!!), the physical address | ||
58 | * of the page in the high bits, and what appears to be an "enable" bit | ||
59 | * in the LSB bit (0) that must be set to 1 when the entry is valid. | ||
60 | * | ||
61 | * Obviously, the GART is not cache coherent and so any change to it | ||
62 | * must be flushed to memory (or maybe just make the GART space non | ||
63 | * cachable). AGP memory itself doens't seem to be cache coherent neither. | ||
64 | * | ||
65 | * In order to invalidate the GART (which is probably necessary to inval | ||
66 | * the bridge internal TLBs), the following sequence has to be written, | ||
67 | * in order, to the GART_CTRL register: | ||
68 | * | ||
69 | * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL | ||
70 | * UNI_N_CFG_GART_ENABLE | ||
71 | * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_2xRESET | ||
72 | * UNI_N_CFG_GART_ENABLE | ||
73 | * | ||
74 | * As far as AGP "features" are concerned, it looks like fast write may | ||
75 | * not be supported but this has to be confirmed. | ||
76 | * | ||
77 | * Turning on AGP seem to require a double invalidate operation, one before | ||
78 | * setting the AGP command register, on after. | ||
79 | * | ||
80 | * Turning off AGP seems to require the following sequence: first wait | ||
81 | * for the AGP to be idle by reading the internal status register, then | ||
82 | * write in that order to the GART_CTRL register: | ||
83 | * | ||
84 | * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL | ||
85 | * 0 | ||
86 | * UNI_N_CFG_GART_2xRESET | ||
87 | * 0 | ||
88 | */ | ||
89 | |||
90 | /* | ||
91 | * Uni-N memory mapped reg. definitions | ||
92 | * | ||
93 | * Those registers are Big-Endian !! | ||
94 | * | ||
95 | * Their meaning come from either Darwin and/or from experiments I made with | ||
96 | * the bootrom, I'm not sure about their exact meaning yet | ||
97 | * | ||
98 | */ | ||
99 | |||
100 | /* Version of the UniNorth chip */ | ||
101 | #define UNI_N_VERSION 0x0000 /* Known versions: 3,7 and 8 */ | ||
102 | |||
103 | #define UNI_N_VERSION_107 0x0003 /* 1.0.7 */ | ||
104 | #define UNI_N_VERSION_10A 0x0007 /* 1.0.10 */ | ||
105 | #define UNI_N_VERSION_150 0x0011 /* 1.5 */ | ||
106 | #define UNI_N_VERSION_200 0x0024 /* 2.0 */ | ||
107 | #define UNI_N_VERSION_PANGEA 0x00C0 /* Integrated U1 + K */ | ||
108 | #define UNI_N_VERSION_INTREPID 0x00D2 /* Integrated U2 + K */ | ||
109 | #define UNI_N_VERSION_300 0x0030 /* 3.0 (U3 on G5) */ | ||
110 | |||
111 | /* This register is used to enable/disable various clocks */ | ||
112 | #define UNI_N_CLOCK_CNTL 0x0020 | ||
113 | #define UNI_N_CLOCK_CNTL_PCI 0x00000001 /* PCI2 clock control */ | ||
114 | #define UNI_N_CLOCK_CNTL_GMAC 0x00000002 /* GMAC clock control */ | ||
115 | #define UNI_N_CLOCK_CNTL_FW 0x00000004 /* FireWire clock control */ | ||
116 | #define UNI_N_CLOCK_CNTL_ATA100 0x00000010 /* ATA-100 clock control (U2) */ | ||
117 | |||
118 | /* Power Management control */ | ||
119 | #define UNI_N_POWER_MGT 0x0030 | ||
120 | #define UNI_N_POWER_MGT_NORMAL 0x00 | ||
121 | #define UNI_N_POWER_MGT_IDLE2 0x01 | ||
122 | #define UNI_N_POWER_MGT_SLEEP 0x02 | ||
123 | |||
124 | /* This register is configured by Darwin depending on the UniN | ||
125 | * revision | ||
126 | */ | ||
127 | #define UNI_N_ARB_CTRL 0x0040 | ||
128 | #define UNI_N_ARB_CTRL_QACK_DELAY_SHIFT 15 | ||
129 | #define UNI_N_ARB_CTRL_QACK_DELAY_MASK 0x0e1f8000 | ||
130 | #define UNI_N_ARB_CTRL_QACK_DELAY 0x30 | ||
131 | #define UNI_N_ARB_CTRL_QACK_DELAY105 0x00 | ||
132 | |||
133 | /* This one _might_ return the CPU number of the CPU reading it; | ||
134 | * the bootROM decides whether to boot or to sleep/spinloop depending | ||
135 | * on this register beeing 0 or not | ||
136 | */ | ||
137 | #define UNI_N_CPU_NUMBER 0x0050 | ||
138 | |||
139 | /* This register appear to be read by the bootROM to decide what | ||
140 | * to do on a non-recoverable reset (powerup or wakeup) | ||
141 | */ | ||
142 | #define UNI_N_HWINIT_STATE 0x0070 | ||
143 | #define UNI_N_HWINIT_STATE_SLEEPING 0x01 | ||
144 | #define UNI_N_HWINIT_STATE_RUNNING 0x02 | ||
145 | /* This last bit appear to be used by the bootROM to know the second | ||
146 | * CPU has started and will enter it's sleep loop with IP=0 | ||
147 | */ | ||
148 | #define UNI_N_HWINIT_STATE_CPU1_FLAG 0x10000000 | ||
149 | |||
150 | /* This register controls AACK delay, which is set when 2004 iBook/PowerBook | ||
151 | * is in low speed mode. | ||
152 | */ | ||
153 | #define UNI_N_AACK_DELAY 0x0100 | ||
154 | #define UNI_N_AACK_DELAY_ENABLE 0x00000001 | ||
155 | |||
156 | /* Clock status for Intrepid */ | ||
157 | #define UNI_N_CLOCK_STOP_STATUS0 0x0150 | ||
158 | #define UNI_N_CLOCK_STOPPED_EXTAGP 0x00200000 | ||
159 | #define UNI_N_CLOCK_STOPPED_AGPDEL 0x00100000 | ||
160 | #define UNI_N_CLOCK_STOPPED_I2S0_45_49 0x00080000 | ||
161 | #define UNI_N_CLOCK_STOPPED_I2S0_18 0x00040000 | ||
162 | #define UNI_N_CLOCK_STOPPED_I2S1_45_49 0x00020000 | ||
163 | #define UNI_N_CLOCK_STOPPED_I2S1_18 0x00010000 | ||
164 | #define UNI_N_CLOCK_STOPPED_TIMER 0x00008000 | ||
165 | #define UNI_N_CLOCK_STOPPED_SCC_RTCLK18 0x00004000 | ||
166 | #define UNI_N_CLOCK_STOPPED_SCC_RTCLK32 0x00002000 | ||
167 | #define UNI_N_CLOCK_STOPPED_SCC_VIA32 0x00001000 | ||
168 | #define UNI_N_CLOCK_STOPPED_SCC_SLOT0 0x00000800 | ||
169 | #define UNI_N_CLOCK_STOPPED_SCC_SLOT1 0x00000400 | ||
170 | #define UNI_N_CLOCK_STOPPED_SCC_SLOT2 0x00000200 | ||
171 | #define UNI_N_CLOCK_STOPPED_PCI_FBCLKO 0x00000100 | ||
172 | #define UNI_N_CLOCK_STOPPED_VEO0 0x00000080 | ||
173 | #define UNI_N_CLOCK_STOPPED_VEO1 0x00000040 | ||
174 | #define UNI_N_CLOCK_STOPPED_USB0 0x00000020 | ||
175 | #define UNI_N_CLOCK_STOPPED_USB1 0x00000010 | ||
176 | #define UNI_N_CLOCK_STOPPED_USB2 0x00000008 | ||
177 | #define UNI_N_CLOCK_STOPPED_32 0x00000004 | ||
178 | #define UNI_N_CLOCK_STOPPED_45 0x00000002 | ||
179 | #define UNI_N_CLOCK_STOPPED_49 0x00000001 | ||
180 | |||
181 | #define UNI_N_CLOCK_STOP_STATUS1 0x0160 | ||
182 | #define UNI_N_CLOCK_STOPPED_PLL4REF 0x00080000 | ||
183 | #define UNI_N_CLOCK_STOPPED_CPUDEL 0x00040000 | ||
184 | #define UNI_N_CLOCK_STOPPED_CPU 0x00020000 | ||
185 | #define UNI_N_CLOCK_STOPPED_BUF_REFCKO 0x00010000 | ||
186 | #define UNI_N_CLOCK_STOPPED_PCI2 0x00008000 | ||
187 | #define UNI_N_CLOCK_STOPPED_FW 0x00004000 | ||
188 | #define UNI_N_CLOCK_STOPPED_GB 0x00002000 | ||
189 | #define UNI_N_CLOCK_STOPPED_ATA66 0x00001000 | ||
190 | #define UNI_N_CLOCK_STOPPED_ATA100 0x00000800 | ||
191 | #define UNI_N_CLOCK_STOPPED_MAX 0x00000400 | ||
192 | #define UNI_N_CLOCK_STOPPED_PCI1 0x00000200 | ||
193 | #define UNI_N_CLOCK_STOPPED_KLPCI 0x00000100 | ||
194 | #define UNI_N_CLOCK_STOPPED_USB0PCI 0x00000080 | ||
195 | #define UNI_N_CLOCK_STOPPED_USB1PCI 0x00000040 | ||
196 | #define UNI_N_CLOCK_STOPPED_USB2PCI 0x00000020 | ||
197 | #define UNI_N_CLOCK_STOPPED_7PCI1 0x00000008 | ||
198 | #define UNI_N_CLOCK_STOPPED_AGP 0x00000004 | ||
199 | #define UNI_N_CLOCK_STOPPED_PCI0 0x00000002 | ||
200 | #define UNI_N_CLOCK_STOPPED_18 0x00000001 | ||
201 | |||
202 | /* Intrepid registe to OF do-platform-clockspreading */ | ||
203 | #define UNI_N_CLOCK_SPREADING 0x190 | ||
204 | |||
205 | /* Uninorth 1.5 rev. has additional perf. monitor registers at 0xf00-0xf50 */ | ||
206 | |||
207 | |||
208 | /* | ||
209 | * U3 specific registers | ||
210 | */ | ||
211 | |||
212 | |||
213 | /* U3 Toggle */ | ||
214 | #define U3_TOGGLE_REG 0x00e0 | ||
215 | #define U3_PMC_START_STOP 0x0001 | ||
216 | #define U3_MPIC_RESET 0x0002 | ||
217 | #define U3_MPIC_OUTPUT_ENABLE 0x0004 | ||
218 | |||
219 | /* U3 API PHY Config 1 */ | ||
220 | #define U3_API_PHY_CONFIG_1 0x23030 | ||
221 | |||
222 | /* U3 HyperTransport registers */ | ||
223 | #define U3_HT_CONFIG_BASE 0x70000 | ||
224 | #define U3_HT_LINK_COMMAND 0x100 | ||
225 | #define U3_HT_LINK_CONFIG 0x110 | ||
226 | #define U3_HT_LINK_FREQ 0x120 | ||
227 | |||
228 | #endif /* __ASM_UNINORTH_H__ */ | ||
229 | #endif /* __KERNEL__ */ | ||
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h new file mode 100644 index 000000000000..0991dfceef1d --- /dev/null +++ b/include/asm-powerpc/unistd.h | |||
@@ -0,0 +1,509 @@ | |||
1 | #ifndef _ASM_PPC_UNISTD_H_ | ||
2 | #define _ASM_PPC_UNISTD_H_ | ||
3 | |||
4 | /* | ||
5 | * This file contains the system call numbers. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #define __NR_restart_syscall 0 | ||
14 | #define __NR_exit 1 | ||
15 | #define __NR_fork 2 | ||
16 | #define __NR_read 3 | ||
17 | #define __NR_write 4 | ||
18 | #define __NR_open 5 | ||
19 | #define __NR_close 6 | ||
20 | #define __NR_waitpid 7 | ||
21 | #define __NR_creat 8 | ||
22 | #define __NR_link 9 | ||
23 | #define __NR_unlink 10 | ||
24 | #define __NR_execve 11 | ||
25 | #define __NR_chdir 12 | ||
26 | #define __NR_time 13 | ||
27 | #define __NR_mknod 14 | ||
28 | #define __NR_chmod 15 | ||
29 | #define __NR_lchown 16 | ||
30 | #define __NR_break 17 | ||
31 | #define __NR_oldstat 18 | ||
32 | #define __NR_lseek 19 | ||
33 | #define __NR_getpid 20 | ||
34 | #define __NR_mount 21 | ||
35 | #define __NR_umount 22 | ||
36 | #define __NR_setuid 23 | ||
37 | #define __NR_getuid 24 | ||
38 | #define __NR_stime 25 | ||
39 | #define __NR_ptrace 26 | ||
40 | #define __NR_alarm 27 | ||
41 | #define __NR_oldfstat 28 | ||
42 | #define __NR_pause 29 | ||
43 | #define __NR_utime 30 | ||
44 | #define __NR_stty 31 | ||
45 | #define __NR_gtty 32 | ||
46 | #define __NR_access 33 | ||
47 | #define __NR_nice 34 | ||
48 | #define __NR_ftime 35 | ||
49 | #define __NR_sync 36 | ||
50 | #define __NR_kill 37 | ||
51 | #define __NR_rename 38 | ||
52 | #define __NR_mkdir 39 | ||
53 | #define __NR_rmdir 40 | ||
54 | #define __NR_dup 41 | ||
55 | #define __NR_pipe 42 | ||
56 | #define __NR_times 43 | ||
57 | #define __NR_prof 44 | ||
58 | #define __NR_brk 45 | ||
59 | #define __NR_setgid 46 | ||
60 | #define __NR_getgid 47 | ||
61 | #define __NR_signal 48 | ||
62 | #define __NR_geteuid 49 | ||
63 | #define __NR_getegid 50 | ||
64 | #define __NR_acct 51 | ||
65 | #define __NR_umount2 52 | ||
66 | #define __NR_lock 53 | ||
67 | #define __NR_ioctl 54 | ||
68 | #define __NR_fcntl 55 | ||
69 | #define __NR_mpx 56 | ||
70 | #define __NR_setpgid 57 | ||
71 | #define __NR_ulimit 58 | ||
72 | #define __NR_oldolduname 59 | ||
73 | #define __NR_umask 60 | ||
74 | #define __NR_chroot 61 | ||
75 | #define __NR_ustat 62 | ||
76 | #define __NR_dup2 63 | ||
77 | #define __NR_getppid 64 | ||
78 | #define __NR_getpgrp 65 | ||
79 | #define __NR_setsid 66 | ||
80 | #define __NR_sigaction 67 | ||
81 | #define __NR_sgetmask 68 | ||
82 | #define __NR_ssetmask 69 | ||
83 | #define __NR_setreuid 70 | ||
84 | #define __NR_setregid 71 | ||
85 | #define __NR_sigsuspend 72 | ||
86 | #define __NR_sigpending 73 | ||
87 | #define __NR_sethostname 74 | ||
88 | #define __NR_setrlimit 75 | ||
89 | #define __NR_getrlimit 76 | ||
90 | #define __NR_getrusage 77 | ||
91 | #define __NR_gettimeofday 78 | ||
92 | #define __NR_settimeofday 79 | ||
93 | #define __NR_getgroups 80 | ||
94 | #define __NR_setgroups 81 | ||
95 | #define __NR_select 82 | ||
96 | #define __NR_symlink 83 | ||
97 | #define __NR_oldlstat 84 | ||
98 | #define __NR_readlink 85 | ||
99 | #define __NR_uselib 86 | ||
100 | #define __NR_swapon 87 | ||
101 | #define __NR_reboot 88 | ||
102 | #define __NR_readdir 89 | ||
103 | #define __NR_mmap 90 | ||
104 | #define __NR_munmap 91 | ||
105 | #define __NR_truncate 92 | ||
106 | #define __NR_ftruncate 93 | ||
107 | #define __NR_fchmod 94 | ||
108 | #define __NR_fchown 95 | ||
109 | #define __NR_getpriority 96 | ||
110 | #define __NR_setpriority 97 | ||
111 | #define __NR_profil 98 | ||
112 | #define __NR_statfs 99 | ||
113 | #define __NR_fstatfs 100 | ||
114 | #define __NR_ioperm 101 | ||
115 | #define __NR_socketcall 102 | ||
116 | #define __NR_syslog 103 | ||
117 | #define __NR_setitimer 104 | ||
118 | #define __NR_getitimer 105 | ||
119 | #define __NR_stat 106 | ||
120 | #define __NR_lstat 107 | ||
121 | #define __NR_fstat 108 | ||
122 | #define __NR_olduname 109 | ||
123 | #define __NR_iopl 110 | ||
124 | #define __NR_vhangup 111 | ||
125 | #define __NR_idle 112 | ||
126 | #define __NR_vm86 113 | ||
127 | #define __NR_wait4 114 | ||
128 | #define __NR_swapoff 115 | ||
129 | #define __NR_sysinfo 116 | ||
130 | #define __NR_ipc 117 | ||
131 | #define __NR_fsync 118 | ||
132 | #define __NR_sigreturn 119 | ||
133 | #define __NR_clone 120 | ||
134 | #define __NR_setdomainname 121 | ||
135 | #define __NR_uname 122 | ||
136 | #define __NR_modify_ldt 123 | ||
137 | #define __NR_adjtimex 124 | ||
138 | #define __NR_mprotect 125 | ||
139 | #define __NR_sigprocmask 126 | ||
140 | #define __NR_create_module 127 | ||
141 | #define __NR_init_module 128 | ||
142 | #define __NR_delete_module 129 | ||
143 | #define __NR_get_kernel_syms 130 | ||
144 | #define __NR_quotactl 131 | ||
145 | #define __NR_getpgid 132 | ||
146 | #define __NR_fchdir 133 | ||
147 | #define __NR_bdflush 134 | ||
148 | #define __NR_sysfs 135 | ||
149 | #define __NR_personality 136 | ||
150 | #define __NR_afs_syscall 137 /* Syscall for Andrew File System */ | ||
151 | #define __NR_setfsuid 138 | ||
152 | #define __NR_setfsgid 139 | ||
153 | #define __NR__llseek 140 | ||
154 | #define __NR_getdents 141 | ||
155 | #define __NR__newselect 142 | ||
156 | #define __NR_flock 143 | ||
157 | #define __NR_msync 144 | ||
158 | #define __NR_readv 145 | ||
159 | #define __NR_writev 146 | ||
160 | #define __NR_getsid 147 | ||
161 | #define __NR_fdatasync 148 | ||
162 | #define __NR__sysctl 149 | ||
163 | #define __NR_mlock 150 | ||
164 | #define __NR_munlock 151 | ||
165 | #define __NR_mlockall 152 | ||
166 | #define __NR_munlockall 153 | ||
167 | #define __NR_sched_setparam 154 | ||
168 | #define __NR_sched_getparam 155 | ||
169 | #define __NR_sched_setscheduler 156 | ||
170 | #define __NR_sched_getscheduler 157 | ||
171 | #define __NR_sched_yield 158 | ||
172 | #define __NR_sched_get_priority_max 159 | ||
173 | #define __NR_sched_get_priority_min 160 | ||
174 | #define __NR_sched_rr_get_interval 161 | ||
175 | #define __NR_nanosleep 162 | ||
176 | #define __NR_mremap 163 | ||
177 | #define __NR_setresuid 164 | ||
178 | #define __NR_getresuid 165 | ||
179 | #define __NR_query_module 166 | ||
180 | #define __NR_poll 167 | ||
181 | #define __NR_nfsservctl 168 | ||
182 | #define __NR_setresgid 169 | ||
183 | #define __NR_getresgid 170 | ||
184 | #define __NR_prctl 171 | ||
185 | #define __NR_rt_sigreturn 172 | ||
186 | #define __NR_rt_sigaction 173 | ||
187 | #define __NR_rt_sigprocmask 174 | ||
188 | #define __NR_rt_sigpending 175 | ||
189 | #define __NR_rt_sigtimedwait 176 | ||
190 | #define __NR_rt_sigqueueinfo 177 | ||
191 | #define __NR_rt_sigsuspend 178 | ||
192 | #define __NR_pread64 179 | ||
193 | #define __NR_pwrite64 180 | ||
194 | #define __NR_chown 181 | ||
195 | #define __NR_getcwd 182 | ||
196 | #define __NR_capget 183 | ||
197 | #define __NR_capset 184 | ||
198 | #define __NR_sigaltstack 185 | ||
199 | #define __NR_sendfile 186 | ||
200 | #define __NR_getpmsg 187 /* some people actually want streams */ | ||
201 | #define __NR_putpmsg 188 /* some people actually want streams */ | ||
202 | #define __NR_vfork 189 | ||
203 | #define __NR_ugetrlimit 190 /* SuS compliant getrlimit */ | ||
204 | #define __NR_readahead 191 | ||
205 | #ifndef __powerpc64__ /* these are 32-bit only */ | ||
206 | #define __NR_mmap2 192 | ||
207 | #define __NR_truncate64 193 | ||
208 | #define __NR_ftruncate64 194 | ||
209 | #define __NR_stat64 195 | ||
210 | #define __NR_lstat64 196 | ||
211 | #define __NR_fstat64 197 | ||
212 | #endif | ||
213 | #define __NR_pciconfig_read 198 | ||
214 | #define __NR_pciconfig_write 199 | ||
215 | #define __NR_pciconfig_iobase 200 | ||
216 | #define __NR_multiplexer 201 | ||
217 | #define __NR_getdents64 202 | ||
218 | #define __NR_pivot_root 203 | ||
219 | #ifndef __powerpc64__ | ||
220 | #define __NR_fcntl64 204 | ||
221 | #endif | ||
222 | #define __NR_madvise 205 | ||
223 | #define __NR_mincore 206 | ||
224 | #define __NR_gettid 207 | ||
225 | #define __NR_tkill 208 | ||
226 | #define __NR_setxattr 209 | ||
227 | #define __NR_lsetxattr 210 | ||
228 | #define __NR_fsetxattr 211 | ||
229 | #define __NR_getxattr 212 | ||
230 | #define __NR_lgetxattr 213 | ||
231 | #define __NR_fgetxattr 214 | ||
232 | #define __NR_listxattr 215 | ||
233 | #define __NR_llistxattr 216 | ||
234 | #define __NR_flistxattr 217 | ||
235 | #define __NR_removexattr 218 | ||
236 | #define __NR_lremovexattr 219 | ||
237 | #define __NR_fremovexattr 220 | ||
238 | #define __NR_futex 221 | ||
239 | #define __NR_sched_setaffinity 222 | ||
240 | #define __NR_sched_getaffinity 223 | ||
241 | /* 224 currently unused */ | ||
242 | #define __NR_tuxcall 225 | ||
243 | #ifndef __powerpc64__ | ||
244 | #define __NR_sendfile64 226 | ||
245 | #endif | ||
246 | #define __NR_io_setup 227 | ||
247 | #define __NR_io_destroy 228 | ||
248 | #define __NR_io_getevents 229 | ||
249 | #define __NR_io_submit 230 | ||
250 | #define __NR_io_cancel 231 | ||
251 | #define __NR_set_tid_address 232 | ||
252 | #define __NR_fadvise64 233 | ||
253 | #define __NR_exit_group 234 | ||
254 | #define __NR_lookup_dcookie 235 | ||
255 | #define __NR_epoll_create 236 | ||
256 | #define __NR_epoll_ctl 237 | ||
257 | #define __NR_epoll_wait 238 | ||
258 | #define __NR_remap_file_pages 239 | ||
259 | #define __NR_timer_create 240 | ||
260 | #define __NR_timer_settime 241 | ||
261 | #define __NR_timer_gettime 242 | ||
262 | #define __NR_timer_getoverrun 243 | ||
263 | #define __NR_timer_delete 244 | ||
264 | #define __NR_clock_settime 245 | ||
265 | #define __NR_clock_gettime 246 | ||
266 | #define __NR_clock_getres 247 | ||
267 | #define __NR_clock_nanosleep 248 | ||
268 | #define __NR_swapcontext 249 | ||
269 | #define __NR_tgkill 250 | ||
270 | #define __NR_utimes 251 | ||
271 | #define __NR_statfs64 252 | ||
272 | #define __NR_fstatfs64 253 | ||
273 | #ifndef __powerpc64__ | ||
274 | #define __NR_fadvise64_64 254 | ||
275 | #endif | ||
276 | #define __NR_rtas 255 | ||
277 | #define __NR_sys_debug_setcontext 256 | ||
278 | /* Number 257 is reserved for vserver */ | ||
279 | /* 258 currently unused */ | ||
280 | #define __NR_mbind 259 | ||
281 | #define __NR_get_mempolicy 260 | ||
282 | #define __NR_set_mempolicy 261 | ||
283 | #define __NR_mq_open 262 | ||
284 | #define __NR_mq_unlink 263 | ||
285 | #define __NR_mq_timedsend 264 | ||
286 | #define __NR_mq_timedreceive 265 | ||
287 | #define __NR_mq_notify 266 | ||
288 | #define __NR_mq_getsetattr 267 | ||
289 | #define __NR_kexec_load 268 | ||
290 | #define __NR_add_key 269 | ||
291 | #define __NR_request_key 270 | ||
292 | #define __NR_keyctl 271 | ||
293 | #define __NR_waitid 272 | ||
294 | #define __NR_ioprio_set 273 | ||
295 | #define __NR_ioprio_get 274 | ||
296 | #define __NR_inotify_init 275 | ||
297 | #define __NR_inotify_add_watch 276 | ||
298 | #define __NR_inotify_rm_watch 277 | ||
299 | |||
300 | #define __NR_syscalls 278 | ||
301 | |||
302 | #ifdef __KERNEL__ | ||
303 | #define __NR__exit __NR_exit | ||
304 | #define NR_syscalls __NR_syscalls | ||
305 | #endif | ||
306 | |||
307 | #ifndef __ASSEMBLY__ | ||
308 | |||
309 | /* On powerpc a system call basically clobbers the same registers like a | ||
310 | * function call, with the exception of LR (which is needed for the | ||
311 | * "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal | ||
312 | * an error return status). | ||
313 | */ | ||
314 | |||
315 | #define __syscall_nr(nr, type, name, args...) \ | ||
316 | unsigned long __sc_ret, __sc_err; \ | ||
317 | { \ | ||
318 | register unsigned long __sc_0 __asm__ ("r0"); \ | ||
319 | register unsigned long __sc_3 __asm__ ("r3"); \ | ||
320 | register unsigned long __sc_4 __asm__ ("r4"); \ | ||
321 | register unsigned long __sc_5 __asm__ ("r5"); \ | ||
322 | register unsigned long __sc_6 __asm__ ("r6"); \ | ||
323 | register unsigned long __sc_7 __asm__ ("r7"); \ | ||
324 | register unsigned long __sc_8 __asm__ ("r8"); \ | ||
325 | \ | ||
326 | __sc_loadargs_##nr(name, args); \ | ||
327 | __asm__ __volatile__ \ | ||
328 | ("sc \n\t" \ | ||
329 | "mfcr %0 " \ | ||
330 | : "=&r" (__sc_0), \ | ||
331 | "=&r" (__sc_3), "=&r" (__sc_4), \ | ||
332 | "=&r" (__sc_5), "=&r" (__sc_6), \ | ||
333 | "=&r" (__sc_7), "=&r" (__sc_8) \ | ||
334 | : __sc_asm_input_##nr \ | ||
335 | : "cr0", "ctr", "memory", \ | ||
336 | "r9", "r10","r11", "r12"); \ | ||
337 | __sc_ret = __sc_3; \ | ||
338 | __sc_err = __sc_0; \ | ||
339 | } \ | ||
340 | if (__sc_err & 0x10000000) \ | ||
341 | { \ | ||
342 | errno = __sc_ret; \ | ||
343 | __sc_ret = -1; \ | ||
344 | } \ | ||
345 | return (type) __sc_ret | ||
346 | |||
347 | #define __sc_loadargs_0(name, dummy...) \ | ||
348 | __sc_0 = __NR_##name | ||
349 | #define __sc_loadargs_1(name, arg1) \ | ||
350 | __sc_loadargs_0(name); \ | ||
351 | __sc_3 = (unsigned long) (arg1) | ||
352 | #define __sc_loadargs_2(name, arg1, arg2) \ | ||
353 | __sc_loadargs_1(name, arg1); \ | ||
354 | __sc_4 = (unsigned long) (arg2) | ||
355 | #define __sc_loadargs_3(name, arg1, arg2, arg3) \ | ||
356 | __sc_loadargs_2(name, arg1, arg2); \ | ||
357 | __sc_5 = (unsigned long) (arg3) | ||
358 | #define __sc_loadargs_4(name, arg1, arg2, arg3, arg4) \ | ||
359 | __sc_loadargs_3(name, arg1, arg2, arg3); \ | ||
360 | __sc_6 = (unsigned long) (arg4) | ||
361 | #define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5) \ | ||
362 | __sc_loadargs_4(name, arg1, arg2, arg3, arg4); \ | ||
363 | __sc_7 = (unsigned long) (arg5) | ||
364 | #define __sc_loadargs_6(name, arg1, arg2, arg3, arg4, arg5, arg6) \ | ||
365 | __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5); \ | ||
366 | __sc_8 = (unsigned long) (arg6) | ||
367 | |||
368 | #define __sc_asm_input_0 "0" (__sc_0) | ||
369 | #define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3) | ||
370 | #define __sc_asm_input_2 __sc_asm_input_1, "2" (__sc_4) | ||
371 | #define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5) | ||
372 | #define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6) | ||
373 | #define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7) | ||
374 | #define __sc_asm_input_6 __sc_asm_input_5, "6" (__sc_8) | ||
375 | |||
376 | #define _syscall0(type,name) \ | ||
377 | type name(void) \ | ||
378 | { \ | ||
379 | __syscall_nr(0, type, name); \ | ||
380 | } | ||
381 | |||
382 | #define _syscall1(type,name,type1,arg1) \ | ||
383 | type name(type1 arg1) \ | ||
384 | { \ | ||
385 | __syscall_nr(1, type, name, arg1); \ | ||
386 | } | ||
387 | |||
388 | #define _syscall2(type,name,type1,arg1,type2,arg2) \ | ||
389 | type name(type1 arg1, type2 arg2) \ | ||
390 | { \ | ||
391 | __syscall_nr(2, type, name, arg1, arg2); \ | ||
392 | } | ||
393 | |||
394 | #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ | ||
395 | type name(type1 arg1, type2 arg2, type3 arg3) \ | ||
396 | { \ | ||
397 | __syscall_nr(3, type, name, arg1, arg2, arg3); \ | ||
398 | } | ||
399 | |||
400 | #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ | ||
401 | type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ | ||
402 | { \ | ||
403 | __syscall_nr(4, type, name, arg1, arg2, arg3, arg4); \ | ||
404 | } | ||
405 | |||
406 | #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ | ||
407 | type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ | ||
408 | { \ | ||
409 | __syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5); \ | ||
410 | } | ||
411 | #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \ | ||
412 | type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \ | ||
413 | { \ | ||
414 | __syscall_nr(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6); \ | ||
415 | } | ||
416 | |||
417 | #ifdef __KERNEL__ | ||
418 | |||
419 | #include <linux/config.h> | ||
420 | #include <linux/types.h> | ||
421 | #include <linux/compiler.h> | ||
422 | #include <linux/linkage.h> | ||
423 | |||
424 | #define __ARCH_WANT_IPC_PARSE_VERSION | ||
425 | #define __ARCH_WANT_OLD_READDIR | ||
426 | #define __ARCH_WANT_STAT64 | ||
427 | #define __ARCH_WANT_SYS_ALARM | ||
428 | #define __ARCH_WANT_SYS_GETHOSTNAME | ||
429 | #define __ARCH_WANT_SYS_PAUSE | ||
430 | #define __ARCH_WANT_SYS_SGETMASK | ||
431 | #define __ARCH_WANT_SYS_SIGNAL | ||
432 | #define __ARCH_WANT_SYS_TIME | ||
433 | #define __ARCH_WANT_SYS_UTIME | ||
434 | #define __ARCH_WANT_SYS_WAITPID | ||
435 | #define __ARCH_WANT_SYS_SOCKETCALL | ||
436 | #define __ARCH_WANT_SYS_FADVISE64 | ||
437 | #define __ARCH_WANT_SYS_GETPGRP | ||
438 | #define __ARCH_WANT_SYS_LLSEEK | ||
439 | #define __ARCH_WANT_SYS_NICE | ||
440 | #define __ARCH_WANT_SYS_OLD_GETRLIMIT | ||
441 | #define __ARCH_WANT_SYS_OLDUMOUNT | ||
442 | #define __ARCH_WANT_SYS_SIGPENDING | ||
443 | #define __ARCH_WANT_SYS_SIGPROCMASK | ||
444 | #define __ARCH_WANT_SYS_RT_SIGACTION | ||
445 | #ifdef CONFIG_PPC32 | ||
446 | #define __ARCH_WANT_OLD_STAT | ||
447 | #endif | ||
448 | #ifdef CONFIG_PPC64 | ||
449 | #define __ARCH_WANT_COMPAT_SYS_TIME | ||
450 | #endif | ||
451 | |||
452 | /* | ||
453 | * System call prototypes. | ||
454 | */ | ||
455 | #ifdef __KERNEL_SYSCALLS__ | ||
456 | extern pid_t setsid(void); | ||
457 | extern int write(int fd, const char *buf, off_t count); | ||
458 | extern int read(int fd, char *buf, off_t count); | ||
459 | extern off_t lseek(int fd, off_t offset, int count); | ||
460 | extern int dup(int fd); | ||
461 | extern int execve(const char *file, char **argv, char **envp); | ||
462 | extern int open(const char *file, int flag, int mode); | ||
463 | extern int close(int fd); | ||
464 | extern pid_t waitpid(pid_t pid, int *wait_stat, int options); | ||
465 | #endif /* __KERNEL_SYSCALLS__ */ | ||
466 | |||
467 | /* | ||
468 | * Functions that implement syscalls. | ||
469 | */ | ||
470 | unsigned long sys_mmap(unsigned long addr, size_t len, unsigned long prot, | ||
471 | unsigned long flags, unsigned long fd, off_t offset); | ||
472 | unsigned long sys_mmap2(unsigned long addr, size_t len, | ||
473 | unsigned long prot, unsigned long flags, | ||
474 | unsigned long fd, unsigned long pgoff); | ||
475 | struct pt_regs; | ||
476 | int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2, | ||
477 | unsigned long a3, unsigned long a4, unsigned long a5, | ||
478 | struct pt_regs *regs); | ||
479 | int sys_clone(unsigned long clone_flags, unsigned long usp, | ||
480 | int __user *parent_tidp, void __user *child_threadptr, | ||
481 | int __user *child_tidp, int p6, struct pt_regs *regs); | ||
482 | int sys_fork(unsigned long p1, unsigned long p2, unsigned long p3, | ||
483 | unsigned long p4, unsigned long p5, unsigned long p6, | ||
484 | struct pt_regs *regs); | ||
485 | int sys_vfork(unsigned long p1, unsigned long p2, unsigned long p3, | ||
486 | unsigned long p4, unsigned long p5, unsigned long p6, | ||
487 | struct pt_regs *regs); | ||
488 | int sys_pipe(int __user *fildes); | ||
489 | struct sigaction; | ||
490 | long sys_rt_sigaction(int sig, const struct sigaction __user *act, | ||
491 | struct sigaction __user *oact, size_t sigsetsize); | ||
492 | |||
493 | /* | ||
494 | * "Conditional" syscalls | ||
495 | * | ||
496 | * What we want is __attribute__((weak,alias("sys_ni_syscall"))), | ||
497 | * but it doesn't work on all toolchains, so we just do it by hand | ||
498 | */ | ||
499 | #ifdef CONFIG_PPC32 | ||
500 | #define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall") | ||
501 | #else | ||
502 | #define cond_syscall(x) asm(".weak\t." #x "\n\t.set\t." #x ",.sys_ni_syscall") | ||
503 | #endif | ||
504 | |||
505 | #endif /* __KERNEL__ */ | ||
506 | |||
507 | #endif /* __ASSEMBLY__ */ | ||
508 | |||
509 | #endif /* _ASM_PPC_UNISTD_H_ */ | ||
diff --git a/include/asm-powerpc/vga.h b/include/asm-powerpc/vga.h new file mode 100644 index 000000000000..f8d350aabf1a --- /dev/null +++ b/include/asm-powerpc/vga.h | |||
@@ -0,0 +1,54 @@ | |||
1 | #ifndef _ASM_POWERPC_VGA_H_ | ||
2 | #define _ASM_POWERPC_VGA_H_ | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | /* | ||
7 | * Access to VGA videoram | ||
8 | * | ||
9 | * (c) 1998 Martin Mares <mj@ucw.cz> | ||
10 | */ | ||
11 | |||
12 | |||
13 | #include <asm/io.h> | ||
14 | |||
15 | #include <linux/config.h> | ||
16 | |||
17 | #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE) | ||
18 | |||
19 | #define VT_BUF_HAVE_RW | ||
20 | /* | ||
21 | * These are only needed for supporting VGA or MDA text mode, which use little | ||
22 | * endian byte ordering. | ||
23 | * In other cases, we can optimize by using native byte ordering and | ||
24 | * <linux/vt_buffer.h> has already done the right job for us. | ||
25 | */ | ||
26 | |||
27 | static inline void scr_writew(u16 val, volatile u16 *addr) | ||
28 | { | ||
29 | st_le16(addr, val); | ||
30 | } | ||
31 | |||
32 | static inline u16 scr_readw(volatile const u16 *addr) | ||
33 | { | ||
34 | return ld_le16(addr); | ||
35 | } | ||
36 | |||
37 | #define VT_BUF_HAVE_MEMCPYW | ||
38 | #define scr_memcpyw memcpy | ||
39 | |||
40 | #endif /* !CONFIG_VGA_CONSOLE && !CONFIG_MDA_CONSOLE */ | ||
41 | |||
42 | extern unsigned long vgacon_remap_base; | ||
43 | |||
44 | #ifdef __powerpc64__ | ||
45 | #define VGA_MAP_MEM(x) ((unsigned long) ioremap((x), 0)) | ||
46 | #else | ||
47 | #define VGA_MAP_MEM(x) (x + vgacon_remap_base) | ||
48 | #endif | ||
49 | |||
50 | #define vga_readb(x) (*(x)) | ||
51 | #define vga_writeb(x,y) (*(y) = (x)) | ||
52 | |||
53 | #endif /* __KERNEL__ */ | ||
54 | #endif /* _ASM_POWERPC_VGA_H_ */ | ||
diff --git a/include/asm-powerpc/vio.h b/include/asm-powerpc/vio.h new file mode 100644 index 000000000000..e0ccf108277c --- /dev/null +++ b/include/asm-powerpc/vio.h | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * IBM PowerPC Virtual I/O Infrastructure Support. | ||
3 | * | ||
4 | * Copyright (c) 2003 IBM Corp. | ||
5 | * Dave Engebretsen engebret@us.ibm.com | ||
6 | * Santiago Leon santil@us.ibm.com | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | |||
14 | #ifndef _ASM_POWERPC_VIO_H | ||
15 | #define _ASM_POWERPC_VIO_H | ||
16 | |||
17 | #include <linux/config.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/device.h> | ||
21 | #include <linux/dma-mapping.h> | ||
22 | #include <linux/mod_devicetable.h> | ||
23 | |||
24 | #include <asm/hvcall.h> | ||
25 | #include <asm/scatterlist.h> | ||
26 | |||
27 | /* | ||
28 | * Architecture-specific constants for drivers to | ||
29 | * extract attributes of the device using vio_get_attribute() | ||
30 | */ | ||
31 | #define VETH_MAC_ADDR "local-mac-address" | ||
32 | #define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters" | ||
33 | |||
34 | /* End architecture-specific constants */ | ||
35 | |||
36 | #define h_vio_signal(ua, mode) \ | ||
37 | plpar_hcall_norets(H_VIO_SIGNAL, ua, mode) | ||
38 | |||
39 | #define VIO_IRQ_DISABLE 0UL | ||
40 | #define VIO_IRQ_ENABLE 1UL | ||
41 | |||
42 | struct iommu_table; | ||
43 | |||
44 | /* | ||
45 | * The vio_dev structure is used to describe virtual I/O devices. | ||
46 | */ | ||
47 | struct vio_dev { | ||
48 | struct iommu_table *iommu_table; /* vio_map_* uses this */ | ||
49 | char *name; | ||
50 | char *type; | ||
51 | uint32_t unit_address; | ||
52 | unsigned int irq; | ||
53 | struct device dev; | ||
54 | }; | ||
55 | |||
56 | struct vio_driver { | ||
57 | struct list_head node; | ||
58 | const struct vio_device_id *id_table; | ||
59 | int (*probe)(struct vio_dev *dev, const struct vio_device_id *id); | ||
60 | int (*remove)(struct vio_dev *dev); | ||
61 | void (*shutdown)(struct vio_dev *dev); | ||
62 | unsigned long driver_data; | ||
63 | struct device_driver driver; | ||
64 | }; | ||
65 | |||
66 | struct vio_bus_ops { | ||
67 | int (*match)(const struct vio_device_id *id, const struct vio_dev *dev); | ||
68 | void (*unregister_device)(struct vio_dev *); | ||
69 | void (*release_device)(struct device *); | ||
70 | }; | ||
71 | |||
72 | extern struct dma_mapping_ops vio_dma_ops; | ||
73 | extern struct bus_type vio_bus_type; | ||
74 | extern struct vio_dev vio_bus_device; | ||
75 | |||
76 | extern int vio_register_driver(struct vio_driver *drv); | ||
77 | extern void vio_unregister_driver(struct vio_driver *drv); | ||
78 | |||
79 | extern struct vio_dev * __devinit vio_register_device(struct vio_dev *viodev); | ||
80 | extern void __devinit vio_unregister_device(struct vio_dev *dev); | ||
81 | |||
82 | extern int vio_bus_init(struct vio_bus_ops *); | ||
83 | |||
84 | #ifdef CONFIG_PPC_PSERIES | ||
85 | struct device_node; | ||
86 | |||
87 | extern struct vio_dev * __devinit vio_register_device_node( | ||
88 | struct device_node *node_vdev); | ||
89 | extern struct vio_dev *vio_find_node(struct device_node *vnode); | ||
90 | extern const void *vio_get_attribute(struct vio_dev *vdev, void *which, | ||
91 | int *length); | ||
92 | extern int vio_enable_interrupts(struct vio_dev *dev); | ||
93 | extern int vio_disable_interrupts(struct vio_dev *dev); | ||
94 | #endif | ||
95 | |||
96 | static inline struct vio_driver *to_vio_driver(struct device_driver *drv) | ||
97 | { | ||
98 | return container_of(drv, struct vio_driver, driver); | ||
99 | } | ||
100 | |||
101 | static inline struct vio_dev *to_vio_dev(struct device *dev) | ||
102 | { | ||
103 | return container_of(dev, struct vio_dev, dev); | ||
104 | } | ||
105 | |||
106 | #endif /* _ASM_POWERPC_VIO_H */ | ||
diff --git a/include/asm-powerpc/xmon.h b/include/asm-powerpc/xmon.h new file mode 100644 index 000000000000..43f7129984c7 --- /dev/null +++ b/include/asm-powerpc/xmon.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef __PPC_XMON_H | ||
2 | #define __PPC_XMON_H | ||
3 | #ifdef __KERNEL__ | ||
4 | |||
5 | struct pt_regs; | ||
6 | |||
7 | extern int xmon(struct pt_regs *excp); | ||
8 | extern void xmon_printf(const char *fmt, ...); | ||
9 | extern void xmon_init(int); | ||
10 | |||
11 | #endif | ||
12 | #endif | ||