diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2006-12-06 20:14:02 -0500 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2006-12-06 20:14:02 -0500 |
commit | 9ca36101a8d74704d78f10910f89d62de96f9dc8 (patch) | |
tree | 358086c902c021f9316968062dc1b1165cf5f897 /include/asm-i386/pda.h | |
parent | eb5b7b9d86f46b45ba1f986302fdf7df84fb8297 (diff) |
[PATCH] i386: Basic definitions for i386-pda
This patch has the basic definitions of struct i386_pda, and the segment
selector in the GDT.
asm-i386/pda.h is more or less a direct copy of asm-x86_64/pda.h. The most
interesting difference is the use of _proxy_pda, which is used to give gcc a
model for the actual memory operations on the real pda structure. No actual
reference is ever made to _proxy_pda, so it is never defined.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Jan Beulich <jbeulich@novell.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Diffstat (limited to 'include/asm-i386/pda.h')
-rw-r--r-- | include/asm-i386/pda.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/include/asm-i386/pda.h b/include/asm-i386/pda.h new file mode 100644 index 000000000000..4c39ccb1305c --- /dev/null +++ b/include/asm-i386/pda.h | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | Per-processor Data Areas | ||
3 | Jeremy Fitzhardinge <jeremy@goop.org> 2006 | ||
4 | Based on asm-x86_64/pda.h by Andi Kleen. | ||
5 | */ | ||
6 | #ifndef _I386_PDA_H | ||
7 | #define _I386_PDA_H | ||
8 | |||
9 | #include <linux/stddef.h> | ||
10 | |||
11 | struct i386_pda | ||
12 | { | ||
13 | struct i386_pda *_pda; /* pointer to self */ | ||
14 | }; | ||
15 | |||
16 | extern struct i386_pda *_cpu_pda[]; | ||
17 | |||
18 | #define cpu_pda(i) (_cpu_pda[i]) | ||
19 | |||
20 | #define pda_offset(field) offsetof(struct i386_pda, field) | ||
21 | |||
22 | extern void __bad_pda_field(void); | ||
23 | |||
24 | /* This variable is never instantiated. It is only used as a stand-in | ||
25 | for the real per-cpu PDA memory, so that gcc can understand what | ||
26 | memory operations the inline asms() below are performing. This | ||
27 | eliminates the need to make the asms volatile or have memory | ||
28 | clobbers, so gcc can readily analyse them. */ | ||
29 | extern struct i386_pda _proxy_pda; | ||
30 | |||
31 | #define pda_to_op(op,field,val) \ | ||
32 | do { \ | ||
33 | typedef typeof(_proxy_pda.field) T__; \ | ||
34 | if (0) { T__ tmp__; tmp__ = (val); } \ | ||
35 | switch (sizeof(_proxy_pda.field)) { \ | ||
36 | case 1: \ | ||
37 | asm(op "b %1,%%gs:%c2" \ | ||
38 | : "+m" (_proxy_pda.field) \ | ||
39 | :"ri" ((T__)val), \ | ||
40 | "i"(pda_offset(field))); \ | ||
41 | break; \ | ||
42 | case 2: \ | ||
43 | asm(op "w %1,%%gs:%c2" \ | ||
44 | : "+m" (_proxy_pda.field) \ | ||
45 | :"ri" ((T__)val), \ | ||
46 | "i"(pda_offset(field))); \ | ||
47 | break; \ | ||
48 | case 4: \ | ||
49 | asm(op "l %1,%%gs:%c2" \ | ||
50 | : "+m" (_proxy_pda.field) \ | ||
51 | :"ri" ((T__)val), \ | ||
52 | "i"(pda_offset(field))); \ | ||
53 | break; \ | ||
54 | default: __bad_pda_field(); \ | ||
55 | } \ | ||
56 | } while (0) | ||
57 | |||
58 | #define pda_from_op(op,field) \ | ||
59 | ({ \ | ||
60 | typeof(_proxy_pda.field) ret__; \ | ||
61 | switch (sizeof(_proxy_pda.field)) { \ | ||
62 | case 1: \ | ||
63 | asm(op "b %%gs:%c1,%0" \ | ||
64 | : "=r" (ret__) \ | ||
65 | : "i" (pda_offset(field)), \ | ||
66 | "m" (_proxy_pda.field)); \ | ||
67 | break; \ | ||
68 | case 2: \ | ||
69 | asm(op "w %%gs:%c1,%0" \ | ||
70 | : "=r" (ret__) \ | ||
71 | : "i" (pda_offset(field)), \ | ||
72 | "m" (_proxy_pda.field)); \ | ||
73 | break; \ | ||
74 | case 4: \ | ||
75 | asm(op "l %%gs:%c1,%0" \ | ||
76 | : "=r" (ret__) \ | ||
77 | : "i" (pda_offset(field)), \ | ||
78 | "m" (_proxy_pda.field)); \ | ||
79 | break; \ | ||
80 | default: __bad_pda_field(); \ | ||
81 | } \ | ||
82 | ret__; }) | ||
83 | |||
84 | /* Return a pointer to a pda field */ | ||
85 | #define pda_addr(field) \ | ||
86 | ((typeof(_proxy_pda.field) *)((unsigned char *)read_pda(_pda) + \ | ||
87 | pda_offset(field))) | ||
88 | |||
89 | #define read_pda(field) pda_from_op("mov",field) | ||
90 | #define write_pda(field,val) pda_to_op("mov",field,val) | ||
91 | #define add_pda(field,val) pda_to_op("add",field,val) | ||
92 | #define sub_pda(field,val) pda_to_op("sub",field,val) | ||
93 | #define or_pda(field,val) pda_to_op("or",field,val) | ||
94 | |||
95 | #endif /* _I386_PDA_H */ | ||