diff options
author | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2015-06-17 16:11:18 -0700 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2015-06-20 18:15:33 +0200 |
commit | bef400b96cbce8a4947f6b147b4030a9422c2b7f (patch) | |
tree | 8ed70ee8cbee09b068e54aacf8f5f78b915895c6 /src/include | |
parent | 7c35af2bc3152cfc678561465f60884d56380632 (diff) |
x86: Make reading / writing of CRx registers 64bit proof
Change-Id: I782007fe9754ec3ae0b5dc31e7865f7e46cfbc74
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Signed-off-by: Scott Duplichan <scott@notabs.org>
Reviewed-on: http://review.coreboot.org/10576
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Marc Jones <marc.jones@se-eng.com>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/cpu/x86/cr.h | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/include/cpu/x86/cr.h b/src/include/cpu/x86/cr.h index 4d2be3a77a..8f77aec1d3 100644 --- a/src/include/cpu/x86/cr.h +++ b/src/include/cpu/x86/cr.h @@ -32,46 +32,55 @@ #define COMPILER_BARRIER "memory" #endif -static alwaysinline uint32_t read_cr0(void) +#ifdef __x86_64__ +#define CRx_TYPE uint64_t +#define CRx_IN "q" +#define CRx_RET "=q" +#else +#define CRx_TYPE uint32_t +#define CRx_IN "r" +#define CRx_RET "=r" +#endif +static alwaysinline CRx_TYPE read_cr0(void) { - uint32_t value; + CRx_TYPE value; __asm__ __volatile__ ( "mov %%cr0, %0" - : "=r" (value) + : CRx_RET (value) : : COMPILER_BARRIER ); return value; } -static alwaysinline void write_cr0(uint32_t data) +static alwaysinline void write_cr0(CRx_TYPE data) { __asm__ __volatile__ ( "mov %0, %%cr0" : - : "r" (data) + : CRx_IN (data) : COMPILER_BARRIER ); } -static alwaysinline uint32_t read_cr4(void) +static alwaysinline CRx_TYPE read_cr4(void) { - uint32_t value; + CRx_TYPE value; __asm__ __volatile__ ( "mov %%cr4, %0" - : "=r" (value) + : CRx_RET (value) : : COMPILER_BARRIER ); return value; } -static alwaysinline void write_cr4(uint32_t data) +static alwaysinline void write_cr4(CRx_TYPE data) { __asm__ __volatile__ ( "mov %0, %%cr4" : - : "r" (data) + : CRx_IN (data) : COMPILER_BARRIER ); } |