ReactOS  0.4.14-dev-317-g96040ec
intrin_i.h
Go to the documentation of this file.
1 #ifndef _INTRIN_INTERNAL_
2 #define _INTRIN_INTERNAL_
3 
4 VOID
7 {
9 }
10 
13 KiGetGdtEntry(PVOID pGdt, USHORT Selector)
14 {
15  return (PKGDTENTRY64)((ULONG64)pGdt + (Selector & ~RPL_MASK));
16 }
17 
18 PVOID
21 {
22  return (PVOID)((ULONG64)Entry->BaseLow |
23  (ULONG64)Entry->Bytes.BaseMiddle << 16 |
24  (ULONG64)Entry->Bytes.BaseHigh << 24 |
25  (ULONG64)Entry->BaseUpper << 32);
26 }
27 
28 VOID
31 {
32  Entry->BaseLow = Base & 0xffff;
33  Entry->Bits.BaseMiddle = (Base >> 16) & 0xff;
34  Entry->Bits.BaseHigh = (Base >> 24) & 0xff;
35  Entry->BaseUpper = Base >> 32;
36 }
37 
38 VOID
41 {
42  Entry->LimitLow = Limit & 0xffff;
43  Entry->Bits.LimitHigh = Limit >> 16;
44 }
45 
46 VOID
49 {
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;
60 }
61 
62 #if defined(__GNUC__)
63 
64 static __inline__ __attribute__((always_inline)) void __lgdt(void *Source)
65 {
66  __asm__ __volatile__("lgdt %0" : : "m"(*(short*)Source));
67 }
68 
69 static __inline__ __attribute__((always_inline)) void __sgdt(void *Destination)
70 {
71  __asm__ __volatile__("sgdt %0" : : "m"(*(short*)Destination) : "memory");
72 }
73 
74 static __inline__ __attribute__((always_inline)) void __lldt(unsigned short Value)
75 {
76  __asm__ __volatile__("lldt %0" : : "rm"(Value));
77 }
78 
79 static __inline__ __attribute__((always_inline)) void __sldt(void *Destination)
80 {
81  __asm__ __volatile__("sldt %0" : : "m"(*(short*)Destination) : "memory");
82 }
83 
84 static __inline__ __attribute__((always_inline)) void __ldmxcsr(unsigned long *Source)
85 {
86  __asm__ __volatile__("ldmxcsr %0" : : "m"(*Source));
87 }
88 
89 static __inline__ __attribute__((always_inline)) void __stmxcsr(unsigned long *Destination)
90 {
91  __asm__ __volatile__("stmxcsr %0" : : "m"(*Destination) : "memory");
92 }
93 
94 static __inline__ __attribute__((always_inline)) void __ltr(unsigned short Source)
95 {
96  __asm__ __volatile__("ltr %0" : : "rm"(Source));
97 }
98 
99 static __inline__ __attribute__((always_inline)) void __str(unsigned short *Destination)
100 {
101  __asm__ __volatile__("str %0" : : "m"(*Destination) : "memory");
102 }
103 
104 
105 #elif defined(_MSC_VER)
106 
107 void __lgdt(void *Source);
108 
109 void __sgdt(void *Destination);
110 
111 void __lldt(unsigned short Value);
112 
113 void __sldt(void *Destination);
114 
115 void __ltr(unsigned short Source);
116 
117 void __str(unsigned short *Destination);
118 
119 
120 #else
121 #error Unknown compiler for inline assembler
122 #endif
123 
124 #endif
125 
126 /* EOF */
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
Type
Definition: Type.h:6
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2343
VOID FORCEINLINE KiInitGdtEntry(PKGDTENTRY64 Entry, ULONG64 Base, ULONG Size, UCHAR Type, UCHAR Dpl)
Definition: intrin_i.h:48
VOID FORCEINLINE KeSetCurrentIrql(KIRQL Irql)
Definition: intrin_i.h:6
_Out_ PKIRQL Irql
Definition: csq.h:179
__INTRIN_INLINE void __writecr8(unsigned int Data)
Definition: intrin_x86.h:1686
VOID FORCEINLINE KiSetGdtDescriptorLimit(PKGDTENTRY Entry, ULONG Limit)
Definition: intrin_i.h:40
#define __attribute__(x)
Definition: wpp_private.h:207
UCHAR KIRQL
Definition: env_spec_w32.h:591
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
#define RPL_MASK
Definition: ketypes.h:69
#define FORCEINLINE
Definition: ntbasedef.h:221
PVOID FORCEINLINE KiGetGdtDescriptorBase(PKGDTENTRY Entry)
Definition: intrin_i.h:20
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2891
PKGDTENTRY64 FORCEINLINE KiGetGdtEntry(PVOID pGdt, USHORT Selector)
Definition: intrin_i.h:13
VOID FORCEINLINE KiSetGdtDescriptorBase(PKGDTENTRY Entry, ULONG64 Base)
Definition: intrin_i.h:30
unsigned __int64 ULONG64
Definition: imports.h:198
unsigned char UCHAR
Definition: xmlstorage.h:181
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:328
base of all file and directory entries
Definition: entries.h:82