Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

gdtsup.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1991 Microsoft Corporation 00004 00005 Module Name: 00006 00007 gdtsup.c 00008 00009 Abstract: 00010 00011 This module implements interfaces that support manipulation of i386 Gdts. 00012 These entry points only exist on i386 machines. 00013 00014 Author: 00015 00016 Dave Hastings (daveh) 28 May 1991 00017 00018 Environment: 00019 00020 Kernel mode only. 00021 00022 Revision History: 00023 Fred Yang (intel) 20 Aug 1996 - based on ../i386/gdtsup.c but stripped 00024 out the code we don't need. IA64 will never set an entry in the GDT 00025 at runtime, for example... 00026 00027 --*/ 00028 00029 #include "ki.h" 00030 00031 VOID 00032 KeIA32GetGdtEntryThread( 00033 IN PKTHREAD Thread, 00034 IN ULONG Offset, 00035 OUT PKGDTENTRY Descriptor 00036 ) 00037 /*++ 00038 00039 Routine Description: 00040 00041 This routine returns the contents of an entry in the Gdt. If the 00042 entry is thread specific, the entry for the specified thread is 00043 created and returned (KGDT_LDT, and KGDT_R3_TEB). If the selector 00044 is processor dependent, the entry for the current processor is 00045 returned (KGDT_R0_PCR). 00046 00047 Arguments: 00048 00049 Thread -- Supplies a pointer to the thread to return the entry for. 00050 00051 Offset -- Supplies the offset in the Gdt. This value must be 0 00052 mod 8. 00053 00054 Descriptor -- Returns the contents of the Gdt descriptor 00055 00056 Return Value: 00057 00058 None. 00059 00060 --*/ 00061 00062 { 00063 #if 0 00064 PKGDTENTRY Gdt; 00065 PKPROCESS Process; 00066 00067 // 00068 // If the entry is out of range, don't return anything 00069 // 00070 00071 if (Offset >= GDT_TABLE_SIZE) { 00072 return ; 00073 } 00074 00075 if (Offset == KGDT_LDT) { 00076 00077 // 00078 // Materialize Ldt selector 00079 // 00080 00081 Process = Thread->ApcState.Process; 00082 00083 // 00084 // Assume same process 00085 // 00086 ASSERT (&(PsGetCurrentProcess()->Pcb) == Process); 00087 00088 *Descriptor = Process->LdtDescriptor; 00089 00090 } else { 00091 00092 // 00093 // Copy Selector from Gdt 00094 // 00095 // N.B. We will change the base later, if it is KGDT_R3_TEB 00096 // 00097 00098 PTEB Teb = (PTEB)(Thread->Teb); 00099 00100 *Descriptor = *((PKGDTENTRY)((PCHAR)(Teb->Gdt) + Offset)); 00101 00102 // 00103 // if it is the TEB selector, fix the base 00104 // 00105 00106 if (Offset == KGDT_R3_TEB) { 00107 Descriptor->BaseLow = (USHORT)((ULONG_PTR)(Thread->Teb) & 0xFFFF); 00108 Descriptor->HighWord.Bytes.BaseMid = 00109 (UCHAR) ( ( (ULONG_PTR)(Thread->Teb) & ((ULONG_PTR)0xFF0000L)) >> 16); 00110 Descriptor->HighWord.Bytes.BaseHi = 00111 (CHAR) ( ( (ULONG_PTR)(Thread->Teb) & ((ULONG_PTR)0xFF000000L)) >> 24); 00112 } 00113 } 00114 00115 return ; 00116 #endif 00117 }

Generated on Sat May 15 19:40:05 2004 for test by doxygen 1.3.7