:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / ntoskrnl / ke / i386 / ldt.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 2000  ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /*
20  * PROJECT:         ReactOS kernel
21  * FILE:            ntoskrnl/ke/i386/ldt.c
22  * PURPOSE:         LDT managment
23  * PROGRAMMER:      David Welch (welch@cwcom.net)
24  * UPDATE HISTORY:
25  *                  Created 22/05/98
26  */
27
28 /* INCLUDES *****************************************************************/
29
30 #include <ddk/ntddk.h>
31 #include <internal/ke.h>
32 #include <internal/ps.h>
33 #include <internal/i386/segment.h>
34
35 #define NDEBUG
36 #include <internal/debug.h>
37
38 /* GLOBALS *******************************************************************/
39
40 /*
41  * Empty LDT shared by every process that doesn't have its own.
42  */
43 STATIC UCHAR KiNullLdt[8];
44
45 /* FUNCTIONS *****************************************************************/
46
47 NTSTATUS STDCALL
48 NtSetLdtEntries (HANDLE Thread,
49                  ULONG FirstEntry,
50                  PULONG Entries)
51 {
52   return(STATUS_NOT_IMPLEMENTED);
53 }
54
55 VOID
56 Ki386InitializeLdt(VOID)
57 {
58   PUSHORT Gdt = KeGetCurrentKPCR()->GDT;
59   unsigned int base, length;
60
61   /*
62    * Set up an a descriptor for the LDT
63    */
64   base = (unsigned int)&KiNullLdt;
65   length = sizeof(KiNullLdt) - 1;
66   
67   Gdt[(LDT_SELECTOR / 2) + 0] = (length & 0xFFFF);
68   Gdt[(LDT_SELECTOR / 2) + 1] = (base & 0xFFFF);
69   Gdt[(LDT_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200;
70   Gdt[(LDT_SELECTOR / 2) + 3] = ((length & 0xF0000) >> 16) |
71     ((base & 0xFF000000) >> 16);
72 }