2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/ke/i386/ctxswitch.S
5 * PURPOSE: Thread Context Switching
7 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
8 * Gregor Anich (FPU Code)
11 /* INCLUDES ******************************************************************/
16 EXTERN @KiSwapContextEntry@8:PROC
17 EXTERN @KiSwapContextExit@8:PROC
18 EXTERN @KiRetireDpcList@4:PROC
19 EXTERN @KiEnterV86Mode@4:PROC
20 EXTERN @KiExitV86Mode@4:PROC
22 /* FUNCTIONS ****************************************************************/
25 PUBLIC @KiSwapContextInternal@0
26 @KiSwapContextInternal@0:
27 /* Build switch frame */
30 jmp @KiSwapContextEntry@8
33 PUBLIC @KiSwapContext@8
35 /* Save 4 registers */
38 /* Save all the non-volatile ones */
44 /* Get the wait IRQL */
47 /* Do the swap with the registers correctly setup */
48 call @KiSwapContextInternal@0
50 /* Return the registers */
61 PUBLIC @KiSwitchThreads@8
63 /* Load the new kernel stack and switch OS to new thread */
65 call @KiSwapContextExit@8
67 /* Now we're on the new thread. Return to the caller to restore registers */
72 PUBLIC @KiRetireDpcListInDpcStack@8
73 @KiRetireDpcListInDpcStack@8:
74 /* Switch stacks and retire DPCs */
78 call @KiRetireDpcList@4
80 /* Return on original stack */
85 /* FIXFIX: Move to C code ****/
86 PUBLIC _Ki386SetupAndExitToV86Mode@4
87 _Ki386SetupAndExitToV86Mode@4:
89 /* Enter V8086 mode */
91 sub esp, (12 + KTRAP_FRAME_LENGTH + NPX_FRAME_LENGTH)
93 call @KiEnterV86Mode@4
97 PUBLIC @Ki386BiosCallReturnAddress@4
98 @Ki386BiosCallReturnAddress@4:
100 /* Exit V8086 mode */
101 call @KiExitV86Mode@4
103 add esp, (12 + KTRAP_FRAME_LENGTH + NPX_FRAME_LENGTH)