From 3ec5ec2e9422a5058c7c0ed38d008dbc9cc8ffdc Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 25 Aug 2008 00:10:15 +0000 Subject: [PATCH] Add X86_MSR constants, implement __lgdt, __sgdt, __lldt, __sldt, __ldmxcsr, __stmxcsr, __ltr, __str intrinsics. svn path=/branches/ros-amd64-bringup/; revision=35618 --- .../include/internal/amd64/intrin_i.h | 54 +++++++++++++------ reactos/ntoskrnl/include/internal/amd64/ke.h | 4 ++ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/amd64/intrin_i.h b/reactos/ntoskrnl/include/internal/amd64/intrin_i.h index 908d2eea9a7..2af9056f3f1 100644 --- a/reactos/ntoskrnl/include/internal/amd64/intrin_i.h +++ b/reactos/ntoskrnl/include/internal/amd64/intrin_i.h @@ -11,25 +11,45 @@ #if defined(__GNUC__) -#define Ke386SetInterruptDescriptorTable(X) \ - __asm__("lidt %0\n\t" \ - : /* no outputs */ \ - : "m" (X)); +static __inline__ __attribute__((always_inline)) void __lgdt(void *Source) +{ + __asm__ __volatile__("lgdt %0" : : "m"(*(short*)Source)); +} -#define Ke386GetInterruptDescriptorTable(X) \ - __asm__("sidt %0\n\t" \ - : /* no outputs */ \ - : "m" (X)); +static __inline__ __attribute__((always_inline)) void __sgdt(void *Destination) +{ + __asm__ __volatile__("sgdt %0" : : "m"(*(short*)Destination) : "memory"); +} -#define Ke386SetGlobalDescriptorTable(X) \ - __asm__("lgdt %0\n\t" \ - : /* no outputs */ \ - : "m" (X)); +static __inline__ __attribute__((always_inline)) void __lldt(void *Source) +{ + __asm__ __volatile__("lldt %0" : : "m"(*(short*)Source)); +} -#define Ke386GetGlobalDescriptorTable(X) \ - __asm__("sgdt %0\n\t" \ - : /* no outputs */ \ - : "m" (X)); +static __inline__ __attribute__((always_inline)) void __sldt(void *Destination) +{ + __asm__ __volatile__("sldt %0" : : "m"(*(short*)Destination) : "memory"); +} + +static __inline__ __attribute__((always_inline)) void __ldmxcsr(unsigned long *Source) +{ + __asm__ __volatile__("ldmxcsr %0" : : "m"(*Source)); +} + +static __inline__ __attribute__((always_inline)) void __stmxcsr(unsigned long *Destination) +{ + __asm__ __volatile__("stmxcsr %0" : : "m"(*Destination) : "memory"); +} + +static __inline__ __attribute__((always_inline)) void __ltr(unsigned short *Source) +{ + __asm__ __volatile__("ltr %0" : : "m"(*Source)); +} + +static __inline__ __attribute__((always_inline)) void __str(unsigned short *Destination) +{ + __asm__ __volatile__("str %0" : : "m"(*Destination) : "memory"); +} #define Ke386GetLocalDescriptorTable(X) \ __asm__("sldt %0\n\t" \ @@ -61,7 +81,7 @@ #define _Ke386GetDr(N) ({ \ unsigned int __d; \ - __asm__("movl %%dr" #N ",%0\n\t" :"=r" (__d)); \ + __asm__("movq %%dr" #N ",%0\n\t" :"=r" (__d)); \ __d; \ }) diff --git a/reactos/ntoskrnl/include/internal/amd64/ke.h b/reactos/ntoskrnl/include/internal/amd64/ke.h index fc830fa95d8..8ee91fb03d9 100644 --- a/reactos/ntoskrnl/include/internal/amd64/ke.h +++ b/reactos/ntoskrnl/include/internal/amd64/ke.h @@ -45,6 +45,10 @@ #define X86_MSR_GSBASE 0xC0000101 #define X86_MSR_KERNEL_GSBASE 0xC0000102 +#define X86_MSR_STAR 0xC0000081 +#define X86_MSR_LSTAR 0xC0000082 +#define X86_MSR_CSTAR 0xC0000083 +#define X86_MSR_SFMASK 0xC0000084 #ifndef __ASM__