DPRINT->DPRINT1 in key places (when something fails we shouldn't keep silence).
[reactos.git] / msvc6 / ntoskrnl / ke_i386_stkswitch.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2000 David Welch <welch@cwcom.net>
4 *
5 * Moved to MSVC-compatible inline assembler by Mike Nordell, 2003-12-26
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21 /*
22 * FILE: ntoskrnl/ke/i386/vm86_sup.S
23 * PURPOSE: V86 mode support
24 * PROGRAMMER: David Welch (welch@cwcom.net)
25 * UPDATE HISTORY:
26 * Created 09/10/00
27 */
28
29 /* INCLUDES ******************************************************************/
30
31 #pragma hdrstop
32
33 #include <ddk/ntddk.h>
34 #include <ddk/status.h>
35 #include <internal/i386/segment.h>
36 #include <internal/i386/fpu.h>
37 #include <internal/ps.h>
38 #include <ddk/defines.h>
39 #include <internal/v86m.h>
40 #include <ntos/tss.h>
41 //#include <ntos/service.h>
42 #include <internal/trap.h>
43 #include <internal/ps.h>
44
45 #include <roscfg.h>
46 #include <internal/ntoskrnl.h>
47 #include <internal/i386/segment.h>
48
49
50 void KeReturnFromSystemCall();
51
52 /*
53 * FUNCTION: KeStackSwitchAndRet
54 * PURPOSE: Switch to a new stack and return from the first frame on
55 * the new stack which was assumed to a stdcall function with
56 * 8 bytes of arguments and which saved edi, esi and ebx.
57 */
58 __declspec(naked)
59 VOID STDCALL
60 KeStackSwitchAndRet(PVOID NewStack)
61 {
62 __asm
63 {
64 push ebp
65 mov ebp, esp
66
67 cli
68
69 mov esp, NewStack
70
71 sti
72
73 pop edi
74 pop esi
75 pop ebx
76
77 pop ebp
78 ret 8
79 }
80 }
81
82 __declspec(naked)
83 VOID STDCALL
84 KePushAndStackSwitchAndSysRet(ULONG Push, PVOID NewStack)
85 {
86 __asm
87 {
88 push ebp
89 mov ebp, esp
90
91 push ebx
92 push esi
93 push edi
94
95 cli
96
97 push 8[ebp]
98
99 mov ebx, fs:KPCR_CURRENT_THREAD
100 mov KTHREAD_CALLBACK_STACK[ebx], esp
101 mov esp, 12[ebp]
102
103 sti
104
105 push 0
106 call KeLowerIrql
107
108 jmp KeReturnFromSystemCall
109 }
110 }