aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86_64
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2007-07-22 05:12:29 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-22 14:03:37 -0400
commitf51c94528a9bc73504928926ca4d791a2b7ddd7c (patch)
tree1562581d26098916a35a27ee58021f483c85b3da /include/asm-x86_64
parentabd4f7505bafdd6c5319fe3cb5caf9af6104e17a (diff)
x86_64: Use read and write crX in .c files
This patch uses the read and write functions provided at system.h for control registers instead of writting raw assembly over and over again in .c files. Functions to manipulate cr2 and cr8 were provided, as they were lacking. Also, removed some extra space after closing brackets Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-x86_64')
-rw-r--r--include/asm-x86_64/system.h34
1 files changed, 29 insertions, 5 deletions
diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h
index 6313d33a0686..02175aa1d16a 100644
--- a/include/asm-x86_64/system.h
+++ b/include/asm-x86_64/system.h
@@ -75,19 +75,31 @@ static inline unsigned long read_cr0(void)
75 unsigned long cr0; 75 unsigned long cr0;
76 asm volatile("movq %%cr0,%0" : "=r" (cr0)); 76 asm volatile("movq %%cr0,%0" : "=r" (cr0));
77 return cr0; 77 return cr0;
78} 78}
79 79
80static inline void write_cr0(unsigned long val) 80static inline void write_cr0(unsigned long val)
81{ 81{
82 asm volatile("movq %0,%%cr0" :: "r" (val)); 82 asm volatile("movq %0,%%cr0" :: "r" (val));
83} 83}
84
85static inline unsigned long read_cr2(void)
86{
87 unsigned long cr2;
88 asm("movq %%cr2,%0" : "=r" (cr2));
89 return cr2;
90}
91
92static inline void write_cr2(unsigned long val)
93{
94 asm volatile("movq %0,%%cr2" :: "r" (val));
95}
84 96
85static inline unsigned long read_cr3(void) 97static inline unsigned long read_cr3(void)
86{ 98{
87 unsigned long cr3; 99 unsigned long cr3;
88 asm("movq %%cr3,%0" : "=r" (cr3)); 100 asm("movq %%cr3,%0" : "=r" (cr3));
89 return cr3; 101 return cr3;
90} 102}
91 103
92static inline void write_cr3(unsigned long val) 104static inline void write_cr3(unsigned long val)
93{ 105{
@@ -99,12 +111,24 @@ static inline unsigned long read_cr4(void)
99 unsigned long cr4; 111 unsigned long cr4;
100 asm("movq %%cr4,%0" : "=r" (cr4)); 112 asm("movq %%cr4,%0" : "=r" (cr4));
101 return cr4; 113 return cr4;
102} 114}
103 115
104static inline void write_cr4(unsigned long val) 116static inline void write_cr4(unsigned long val)
105{ 117{
106 asm volatile("movq %0,%%cr4" :: "r" (val) : "memory"); 118 asm volatile("movq %0,%%cr4" :: "r" (val) : "memory");
107} 119}
120
121static inline unsigned long read_cr8(void)
122{
123 unsigned long cr8;
124 asm("movq %%cr8,%0" : "=r" (cr8));
125 return cr8;
126}
127
128static inline void write_cr8(unsigned long val)
129{
130 asm volatile("movq %0,%%cr8" :: "r" (val) : "memory");
131}
108 132
109#define stts() write_cr0(8 | read_cr0()) 133#define stts() write_cr0(8 | read_cr0())
110 134