Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenintrin_i.h
Go to the documentation of this file.
00001 #pragma once 00002 00003 #if defined(__GNUC__) 00004 00005 #define Ke386SetGlobalDescriptorTable(X) \ 00006 __asm__("lgdt %0\n\t" \ 00007 : /* no outputs */ \ 00008 : "m" (*X)); 00009 00010 #define Ke386GetGlobalDescriptorTable(X) \ 00011 __asm__("sgdt %0\n\t" \ 00012 : "=m" (*X) \ 00013 : /* no input */ \ 00014 : "memory"); 00015 00016 FORCEINLINE 00017 VOID 00018 Ke386FxStore(IN PFX_SAVE_AREA SaveArea) 00019 { 00020 asm volatile ("fxrstor (%0)" : : "r"(SaveArea)); 00021 } 00022 00023 FORCEINLINE 00024 VOID 00025 Ke386FxSave(IN PFX_SAVE_AREA SaveArea) 00026 { 00027 asm volatile ("fxsave (%0)" : : "r"(SaveArea)); 00028 } 00029 00030 00031 FORCEINLINE 00032 VOID 00033 Ke386FnSave(IN PFLOATING_SAVE_AREA SaveArea) 00034 { 00035 asm volatile ("fnsave (%0); wait" : : "r"(SaveArea)); 00036 } 00037 00038 FORCEINLINE 00039 VOID 00040 Ke386SaveFpuState(IN PFX_SAVE_AREA SaveArea) 00041 { 00042 extern ULONG KeI386FxsrPresent; 00043 if (KeI386FxsrPresent) 00044 { 00045 __asm__ __volatile__ ("fxsave %0\n" : : "m"(*SaveArea)); 00046 } 00047 else 00048 { 00049 __asm__ __volatile__ ("fnsave %0\n wait\n" : : "m"(*SaveArea)); 00050 } 00051 } 00052 00053 FORCEINLINE 00054 VOID 00055 Ke386LoadFpuState(IN PFX_SAVE_AREA SaveArea) 00056 { 00057 extern ULONG KeI386FxsrPresent; 00058 if (KeI386FxsrPresent) 00059 { 00060 __asm__ __volatile__ ("fxrstor %0\n" : "=m"(SaveArea) : ); 00061 } 00062 else 00063 { 00064 __asm__ __volatile__ (".globl _FrRestore\n _FrRestore: \n frstor %0\n wait\n" : "=m"(SaveArea) : ); 00065 } 00066 } 00067 00068 FORCEINLINE 00069 USHORT 00070 Ke386GetLocalDescriptorTable() 00071 { 00072 USHORT Ldt; 00073 __asm__("sldt %0\n\t" 00074 : "=m" (Ldt) 00075 : /* no input */ 00076 : "memory"); 00077 return Ldt; 00078 } 00079 00080 #define Ke386SetLocalDescriptorTable(X) \ 00081 __asm__("lldt %w0\n\t" \ 00082 : /* no outputs */ \ 00083 : "q" (X)); 00084 00085 #define Ke386SetTr(X) __asm__ __volatile__("ltr %%ax" : :"a" (X)); 00086 00087 FORCEINLINE 00088 USHORT 00089 Ke386GetTr(VOID) 00090 { 00091 USHORT Tr; 00092 __asm__("str %0\n\t" 00093 : "=m" (Tr)); 00094 return Tr; 00095 } 00096 00097 #define _Ke386GetSeg(N) ({ \ 00098 unsigned int __d; \ 00099 __asm__("movl %%" #N ",%0\n\t" :"=r" (__d)); \ 00100 __d; \ 00101 }) 00102 00103 #define _Ke386SetSeg(N,X) __asm__ __volatile__("movl %0,%%" #N : :"r" (X)); 00104 00105 #define Ke386FnInit() __asm__("fninit\n\t"); 00106 #define Ke386ClearDirectionFlag() __asm__ __volatile__ ("cld") 00107 00108 00109 // 00110 // CR Macros 00111 // 00112 #define Ke386SetCr2(X) __asm__ __volatile__("movl %0,%%cr2" : :"r" (X)); 00113 00114 // 00115 // Segment Macros 00116 // 00117 #define Ke386GetSs() _Ke386GetSeg(ss) 00118 #define Ke386GetFs() _Ke386GetSeg(fs) 00119 #define Ke386GetDs() _Ke386GetSeg(ds) 00120 #define Ke386GetEs() _Ke386GetSeg(es) 00121 #define Ke386GetGs() _Ke386GetSeg(gs) 00122 #define Ke386SetFs(X) _Ke386SetSeg(fs, X) 00123 #define Ke386SetDs(X) _Ke386SetSeg(ds, X) 00124 #define Ke386SetEs(X) _Ke386SetSeg(es, X) 00125 #define Ke386SetSs(X) _Ke386SetSeg(ss, X) 00126 #define Ke386SetGs(X) _Ke386SetSeg(gs, X) 00127 00128 #elif defined(_MSC_VER) 00129 00130 FORCEINLINE 00131 VOID 00132 Ke386FnInit(VOID) 00133 { 00134 __asm fninit; 00135 } 00136 00137 FORCEINLINE 00138 VOID 00139 __sgdt(OUT PVOID Descriptor) 00140 { 00141 __asm 00142 { 00143 mov eax, Descriptor 00144 sgdt [eax] 00145 } 00146 } 00147 00148 FORCEINLINE 00149 VOID 00150 __fxsave(OUT PFX_SAVE_AREA SaveArea) 00151 { 00152 __asm mov eax, SaveArea 00153 __asm fxsave [eax] 00154 } 00155 00156 FORCEINLINE 00157 VOID 00158 __fxrstor(IN PFX_SAVE_AREA SaveArea) 00159 { 00160 __asm mov eax, SaveArea 00161 __asm fxrstor [eax] 00162 } 00163 00164 FORCEINLINE 00165 VOID 00166 __fnsave(OUT PFLOATING_SAVE_AREA SaveArea) 00167 { 00168 __asm mov eax, SaveArea 00169 __asm fnsave [eax] 00170 __asm wait; 00171 } 00172 00173 #define Ke386GetGlobalDescriptorTable __sgdt 00174 00175 FORCEINLINE 00176 VOID 00177 __lgdt(IN PVOID Descriptor) 00178 { 00179 __asm 00180 { 00181 mov eax, Descriptor 00182 lgdt [eax] 00183 } 00184 } 00185 #define Ke386SetGlobalDescriptorTable __lgdt 00186 00187 FORCEINLINE 00188 USHORT 00189 Ke386GetLocalDescriptorTable(VOID) 00190 { 00191 __asm sldt ax; 00192 } 00193 00194 FORCEINLINE 00195 VOID 00196 Ke386SetLocalDescriptorTable(IN USHORT Descriptor) 00197 { 00198 __asm lldt Descriptor; 00199 } 00200 00201 FORCEINLINE 00202 VOID 00203 Ke386SetTr(IN USHORT Tr) 00204 { 00205 __asm ltr Tr; 00206 } 00207 00208 FORCEINLINE 00209 USHORT 00210 Ke386GetTr(VOID) 00211 { 00212 __asm str ax; 00213 } 00214 00215 // 00216 // CR Macros 00217 // 00218 FORCEINLINE 00219 VOID 00220 Ke386SetCr2(IN ULONG Value) 00221 { 00222 __asm mov eax, Value; 00223 __asm mov cr2, eax; 00224 } 00225 00226 // 00227 // Segment Macros 00228 // 00229 FORCEINLINE 00230 USHORT 00231 Ke386GetSs(VOID) 00232 { 00233 __asm mov ax, ss; 00234 } 00235 00236 FORCEINLINE 00237 USHORT 00238 Ke386GetFs(VOID) 00239 { 00240 __asm mov ax, fs; 00241 } 00242 00243 FORCEINLINE 00244 USHORT 00245 Ke386GetDs(VOID) 00246 { 00247 __asm mov ax, ds; 00248 } 00249 00250 FORCEINLINE 00251 USHORT 00252 Ke386GetEs(VOID) 00253 { 00254 __asm mov ax, es; 00255 } 00256 00257 FORCEINLINE 00258 VOID 00259 Ke386SetSs(IN USHORT Value) 00260 { 00261 __asm mov ax, Value; 00262 __asm mov ss, ax; 00263 } 00264 00265 FORCEINLINE 00266 VOID 00267 Ke386SetFs(IN USHORT Value) 00268 { 00269 __asm mov ax, Value; 00270 __asm mov fs, ax; 00271 } 00272 00273 FORCEINLINE 00274 VOID 00275 Ke386SetDs(IN USHORT Value) 00276 { 00277 __asm mov ax, Value; 00278 __asm mov ds, ax; 00279 } 00280 00281 FORCEINLINE 00282 VOID 00283 Ke386SetEs(IN USHORT Value) 00284 { 00285 __asm mov ax, Value; 00286 __asm mov es, ax; 00287 } 00288 00289 FORCEINLINE 00290 VOID 00291 Ke386SetGs(IN USHORT Value) 00292 { 00293 __asm mov ax, Value; 00294 __asm mov gs, ax; 00295 } 00296 00297 extern ULONG KeI386FxsrPresent; 00298 00299 FORCEINLINE 00300 VOID 00301 Ke386SaveFpuState(IN PVOID SaveArea) 00302 { 00303 if (KeI386FxsrPresent) 00304 { 00305 __fxsave(SaveArea); 00306 } 00307 else 00308 { 00309 __fnsave(SaveArea); 00310 } 00311 } 00312 00313 #define Ke386FnSave __fnsave 00314 #define Ke386FxSave __fxsave 00315 // The name suggest, that the original author didn't understand what frstor means 00316 #define Ke386FxStore __fxrstor 00317 00318 00319 #else 00320 #error Unknown compiler for inline assembler 00321 #endif 00322 00323 /* EOF */ Generated on Sun May 27 2012 04:37:12 for ReactOS by
1.7.6.1
|