1 #ifndef _INTRIN_INTERNAL_
2 #define _INTRIN_INTERNAL_
6 KeSetCurrentIrql(KIRQL Irql
)
13 KiGetGdtEntry(PVOID pGdt
, USHORT Selector
)
15 return (PKGDTENTRY64
)((ULONG64
)pGdt
+ (Selector
& ~RPL_MASK
));
20 KiGetGdtDescriptorBase(PKGDTENTRY Entry
)
22 return (PVOID
)((ULONG64
)Entry
->BaseLow
|
23 (ULONG64
)Entry
->Bytes
.BaseMiddle
<< 16 |
24 (ULONG64
)Entry
->Bytes
.BaseHigh
<< 24 |
25 (ULONG64
)Entry
->BaseUpper
<< 32);
30 KiSetGdtDescriptorBase(PKGDTENTRY Entry
, ULONG64 Base
)
32 Entry
->BaseLow
= Base
& 0xffff;
33 Entry
->Bits
.BaseMiddle
= (Base
>> 16) & 0xff;
34 Entry
->Bits
.BaseHigh
= (Base
>> 24) & 0xff;
35 Entry
->BaseUpper
= Base
>> 32;
40 KiSetGdtDescriptorLimit(PKGDTENTRY Entry
, ULONG Limit
)
42 Entry
->LimitLow
= Limit
& 0xffff;
43 Entry
->Bits
.LimitHigh
= Limit
>> 16;
48 KiInitGdtEntry(PKGDTENTRY64 Entry
, ULONG64 Base
, ULONG Size
, UCHAR Type
, UCHAR Dpl
)
50 KiSetGdtDescriptorBase(Entry
, Base
);
51 KiSetGdtDescriptorLimit(Entry
, Size
- 1);
52 Entry
->Bits
.Type
= Type
;
53 Entry
->Bits
.Dpl
= Dpl
;
54 Entry
->Bits
.Present
= 1;
55 Entry
->Bits
.System
= 0;
56 Entry
->Bits
.LongMode
= 0;
57 Entry
->Bits
.DefaultBig
= 0;
58 Entry
->Bits
.Granularity
= 0;
59 Entry
->MustBeZero
= 0;
64 static __inline__
__attribute__((always_inline
)) void __lgdt(void *Source
)
66 __asm__
__volatile__("lgdt %0" : : "m"(*(short*)Source
));
69 static __inline__
__attribute__((always_inline
)) void __sgdt(void *Destination
)
71 __asm__
__volatile__("sgdt %0" : : "m"(*(short*)Destination
) : "memory");
74 static __inline__
__attribute__((always_inline
)) void __lldt(unsigned short Value
)
76 __asm__
__volatile__("lldt %0" : : "rm"(Value
));
79 static __inline__
__attribute__((always_inline
)) void __sldt(void *Destination
)
81 __asm__
__volatile__("sldt %0" : : "m"(*(short*)Destination
) : "memory");
84 static __inline__
__attribute__((always_inline
)) void __ldmxcsr(unsigned long *Source
)
86 __asm__
__volatile__("ldmxcsr %0" : : "m"(*Source
));
89 static __inline__
__attribute__((always_inline
)) void __stmxcsr(unsigned long *Destination
)
91 __asm__
__volatile__("stmxcsr %0" : : "m"(*Destination
) : "memory");
94 static __inline__
__attribute__((always_inline
)) void __ltr(unsigned short Source
)
96 __asm__
__volatile__("ltr %0" : : "rm"(Source
));
99 static __inline__
__attribute__((always_inline
)) void __str(unsigned short *Destination
)
101 __asm__
__volatile__("str %0" : : "m"(*Destination
) : "memory");
105 #elif defined(_MSC_VER)
107 void __lgdt(void *Source
);
109 void __sgdt(void *Destination
);
111 void __lldt(unsigned short Value
);
113 void __sldt(void *Destination
);
115 void __ltr(unsigned short Source
);
117 void __str(unsigned short *Destination
);
121 #error Unknown compiler for inline assembler