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

gdtsup.c File Reference

#include "ki.h"

Go to the source code of this file.

Functions

VOID Ke386GetGdtEntryThread (IN PKTHREAD Thread, IN ULONG Offset, IN PKGDTENTRY Descriptor)
NTSTATUS KeI386SetGdtSelector (ULONG Selector, PKGDTENTRY GdtValue)


Function Documentation

VOID Ke386GetGdtEntryThread IN PKTHREAD  Thread,
IN ULONG  Offset,
IN PKGDTENTRY  Descriptor
 

Definition at line 33 of file i386/gdtsup.c.

References CHAR, KiPcr, L, Offset, and USHORT.

Referenced by PspQueryDescriptorThread().

00040 : 00041 00042 This routine returns the contents of an entry in the Gdt. If the 00043 entry is thread specific, the entry for the specified thread is 00044 created and returned (KGDT_LDT, and KGDT_R3_TEB). If the selector 00045 is processor dependent, the entry for the current processor is 00046 returned (KGDT_R0_PCR). 00047 00048 Arguments: 00049 00050 Thread -- Supplies a pointer to the thread to return the entry for. 00051 00052 Offset -- Supplies the offset in the Gdt. This value must be 0 00053 mod 8. 00054 00055 Descriptor -- Returns the contents of the Gdt descriptor 00056 00057 Return Value: 00058 00059 None. 00060 00061 --*/ 00062 00063 { 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 >= KGDT_NUMBER * sizeof(KGDTENTRY)) { 00072 return ; 00073 } 00074 00075 if (Offset == KGDT_LDT) { 00076 00077 // 00078 // Materialize Ldt selector 00079 // 00080 00081 Process = Thread->ApcState.Process; 00082 RtlMoveMemory( Descriptor, 00083 &(Process->LdtDescriptor), 00084 sizeof(KGDTENTRY) 00085 ); 00086 00087 } else { 00088 00089 // 00090 // Copy Selector from Ldt 00091 // 00092 // N.B. We will change the base later, if it is KGDT_R3_TEB 00093 // 00094 00095 00096 Gdt = KiPcr()->GDT; 00097 00098 RtlMoveMemory(Descriptor, (PCHAR)Gdt + Offset, sizeof(KGDTENTRY)); 00099 00100 // 00101 // if it is the TEB selector, fix the base 00102 // 00103 00104 if (Offset == KGDT_R3_TEB) { 00105 Descriptor->BaseLow = (USHORT)((ULONG)(Thread->Teb) & 0xFFFF); 00106 Descriptor->HighWord.Bytes.BaseMid = 00107 (UCHAR) ( ( (ULONG)(Thread->Teb) & 0xFF0000L) >> 16); 00108 Descriptor->HighWord.Bytes.BaseHi = 00109 (CHAR) ( ( (ULONG)(Thread->Teb) & 0xFF000000L) >> 24); 00110 } 00111 } 00112 00113 return ; 00114 }

NTSTATUS KeI386SetGdtSelector ULONG  Selector,
PKGDTENTRY  GdtValue
 

Definition at line 117 of file i386/gdtsup.c.

References ClearMember, KeActiveProcessors, KeFindFirstSetRightMember, KiProcessorBlock, and PAGED_CODE.

00123 : 00124 00125 Sets a GDTs returned via KeI386AllocateGdtSelectors to the supplied 00126 GdtValue. 00127 00128 Arguments: 00129 00130 Selector - Which GDT to set 00131 GdtValue - GDT value to set into GDT 00132 00133 Return Value: 00134 00135 status code 00136 00137 --*/ 00138 { 00139 KAFFINITY TargetSet; 00140 PKPRCB Prcb; 00141 PKPCR Pcr; 00142 PKGDTENTRY GdtEntry; 00143 ULONG GdtIndex, BitNumber; 00144 00145 PAGED_CODE (); 00146 00147 // 00148 // Verify GDT entry passed, and it's above the kernel GDT values 00149 // 00150 00151 GdtIndex = Selector >> 3; 00152 if ((Selector & 0x7) != 0 || GdtIndex < KGDT_NUMBER) { 00153 return STATUS_UNSUCCESSFUL; 00154 } 00155 00156 // 00157 // Set gdt entry in each processors GDT 00158 // 00159 00160 TargetSet = KeActiveProcessors; 00161 while (TargetSet != 0) { 00162 BitNumber = KeFindFirstSetRightMember(TargetSet); 00163 ClearMember(BitNumber, TargetSet); 00164 00165 Prcb = KiProcessorBlock[BitNumber]; 00166 Pcr = CONTAINING_RECORD (Prcb, KPCR, PrcbData); 00167 GdtEntry = Pcr->GDT + GdtIndex; 00168 00169 // set it 00170 *GdtEntry = *GdtValue; 00171 } 00172 00173 return STATUS_SUCCESS; 00174 } }


Generated on Sat May 15 19:43:48 2004 for test by doxygen 1.3.7