Sync with trunk r58113.
[reactos.git] / ntoskrnl / ke / i386 / context.c
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: ntoskrnl/ke/i386/context.c
5 * PURPOSE: Context Switching Related Code
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14
15 /* GLOBALS ********************************************************************/
16
17 /* FUNCTIONS ******************************************************************/
18
19 VOID
20 NTAPI
21 KiSwapProcess(IN PKPROCESS NewProcess,
22 IN PKPROCESS OldProcess)
23 {
24 PKIPCR Pcr = (PKIPCR)KeGetPcr();
25 #ifdef CONFIG_SMP
26 LONG SetMember;
27
28 /* Update active processor mask */
29 SetMember = (LONG)Pcr->SetMember;
30 InterlockedXor((PLONG)&NewProcess->ActiveProcessors, SetMember);
31 InterlockedXor((PLONG)&OldProcess->ActiveProcessors, SetMember);
32 #endif
33
34 /* Check for new LDT */
35 if (NewProcess->LdtDescriptor.LimitLow != OldProcess->LdtDescriptor.LimitLow)
36 {
37 /* Not handled yet */
38 UNIMPLEMENTED;
39 ASSERT(FALSE); // while (TRUE);
40 return;
41 }
42
43 /* Update CR3 */
44 __writecr3(NewProcess->DirectoryTableBase[0]);
45
46 /* Clear GS */
47 Ke386SetGs(0);
48
49 /* Update IOPM offset */
50 Pcr->TSS->IoMapBase = NewProcess->IopmOffset;
51 }
52