--- trunk/reactos/ntoskrnl/ke/i386/syscall.S 2006-01-17 03:28:33 UTC (rev 20932)
+++ trunk/reactos/ntoskrnl/ke/i386/syscall.S 2006-01-17 05:05:35 UTC (rev 20933)
@@ -7,8 +7,6 @@
#include <asm.h>
#include <internal/i386/asmmacro.S>
-#define APC_INDEX_MISMATCH 1
-#define IRQL_GT_ZERO_AT_SYSTEM_SERVICE 0x4A
.globl _KiServiceExit
.globl _KiServiceExit2
@@ -18,7 +16,7 @@
.intel_syntax noprefix
/*
- * There are 3 main types of Trap Entries:
+ * There are 3 main types of Trap Entries: <= Move this to asmmacro.S
*
* - System Calls
* - TODO
@@ -31,7 +29,7 @@
*/
/*
- * There are 3 main types of Trap Exits:
+ * There are 3 main types of Trap Exits: <= Correct some things and move to asmmacro.S
*
* - KiServiceExit
* - Clear interrupt flag
@@ -66,17 +64,10 @@
* All these are exemplified by the 3 trap exits shown above
*/
-/*
- * There is also common Debug Code present in the common exit code, which
- * in turn calls common code to save the debug registers
- */
-
/*
* FIXMEs:
- * - Dig in trap code and see why we need to push/pop the segments,
- * which -shouldn't- be needed on syscalls; one of the things
- * missing for this to work is lazy loading in the GPF handler,
- * but there are other things to consider.
+ * - Figure out why ES/DS gets messed up in VMWare, when doing KiServiceExit only,
+ * and only when called from user-mode, and returning to user-mode.
* - Use macros and merge with trap.s nicely
*/
@@ -159,15 +150,13 @@
/* Push previous mode */
push UserMode
-.att_syntax
- /* Save other registers */
- sub $0xC, %esp // + 0x70
- pushl $KGDT_R3_DATA + RPL_MASK // + 0x40
- pushl $KGDT_R3_DATA + RPL_MASK // + 0x44
- pushl $0 // + 0x48
- sub $0x30, %esp // + 0x70
-.intel_syntax noprefix
+ /* Skip the other registers */
+ sub esp, 0x48
+ /* Hack: it seems that on VMWare someone damages ES/DS on exit. Investigate! */
+ mov dword ptr [esp+KTRAP_FRAME_DS], KGDT_R3_DATA + RPL_MASK
+ mov dword ptr [esp+KTRAP_FRAME_ES], KGDT_R3_DATA + RPL_MASK
+
/* Make space for us on the stack */
sub ebp, 0x29C
@@ -216,16 +205,14 @@
/* Save the old previous mode */
push ss:[esi+KTHREAD_PREVIOUS_MODE]
-
-.att_syntax
- /* Save other registers */
- sub $0xC, %esp // + 0x70
- pushl %ds // + 0x40
- pushl %es // + 0x44
- pushl %gs // + 0x48
- sub $0x30, %esp // + 0x70
-.intel_syntax noprefix
+ /* Skip the other registers */
+ sub esp, 0x48
+
+ /* Hack: it seems that on VMWare someone damages ES/DS on exit. Investigate! */
+ mov [esp+KTRAP_FRAME_DS], ds
+ mov [esp+KTRAP_FRAME_ES], es
+
/* Set the new previous mode based on the saved CS selector */
mov ebx, [esp+0x6C]
and ebx, 1
@@ -424,6 +411,10 @@
/* Check for, and deliver, User-Mode APCs if needed */
CHECK_FOR_APC_DELIVER 1
+ /* Hack for VMWare: Sometimes ES/DS seem to be invalid when returning to user-mode. Investigate! */
+ mov es, [ebp+KTRAP_FRAME_ES]
+ mov ds, [ebp+KTRAP_FRAME_DS]
+
// ========================= COMMON TRAP EXIT CODE ===================//
#ifdef DBG
/* Assert the flags */
@@ -515,14 +506,6 @@
jz CommonStackClean
// ==================== END IF FULL RESTORE NEEDED ====================//
-//badbadbad
- add esp, 0x30
- pop gs
- pop es
- pop ds
- add esp, 0x14
-//badbadbad
-
/* Restore FS */
RestoreFs:
lea esp, [ebp+KTRAP_FRAME_FS]
--- trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S 2006-01-17 03:28:33 UTC (rev 20932)
+++ trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S 2006-01-17 05:05:35 UTC (rev 20933)
@@ -9,17 +9,9 @@
/* INCLUDES ******************************************************************/
#include <asm.h>
-//#include <bugcodes.h>
-#define APC_INDEX_MISMATCH 1
-#define IRQL_GT_ZERO_AT_SYSTEM_SERVICE 0x4A
-#define STATUS_NO_CALLBACK_ACTIVE 0xC0000258
+#include <internal/i386/asmmacro.S>
.intel_syntax noprefix
-// This file is a work in progress. Most of the code is currently disabled.
-
-/* GLOBALS ****************************************************************/
-.extern PVOID _KeUserCallbackDispatcher
-
/* FUNCTIONS ****************************************************************/
.globl _KiGetUserModeStackAddress@0
@@ -186,8 +178,7 @@
lea esi, [edx+KTRAP_FRAME_FS]
rep movsd
- /* TODO: Ugly hack because of some missing logic in syscall.s */
- mov dword ptr [esp+KTRAP_FRAME_GS], 0
+ /* VMWARE Hack because ES/DS sometimes gets smashed when returning to User-Mode. Investigate! */
mov dword ptr [esp+KTRAP_FRAME_DS], KGDT_R3_DATA + RPL_MASK
mov dword ptr [esp+KTRAP_FRAME_ES], KGDT_R3_DATA + RPL_MASK
@@ -209,12 +200,7 @@
sti
/* Write the debug data */
- mov edi, [ebp+KTRAP_FRAME_EBP]
- mov edx, [ebp+KTRAP_FRAME_EIP]
- mov [ebp+KTRAP_FRAME_DEBUGPOINTER], edx
- mov dword ptr [ebp+KTRAP_FRAME_DEBUGARGMARK], 0xBADB0D00
- mov [ebp+KTRAP_FRAME_DEBUGEBP], ebx
- mov [ebp+KTRAP_FRAME_DEBUGEIP], edi
+ SET_TF_DEBUG_HEADER
/* Exit to user-mode */
jmp _KiServiceExit