* Add more documented flags from ks386.inc to asm.h
* Isolate and clean-up the VMWare hack; the shared trap exit macro can
now be implemented.
Modified: trunk/reactos/include/ndk/asm.h
Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S
Modified: trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S
_____
Modified: trunk/reactos/include/ndk/asm.h
--- trunk/reactos/include/ndk/asm.h 2006-01-17 03:28:33 UTC (rev
20932)
+++ trunk/reactos/include/ndk/asm.h 2006-01-17 05:05:35 UTC (rev
20933)
@@ -354,10 +354,13 @@
#define CBSTACK_RESULT_LENGTH 0x24
//
-// NTSTATUS Codes
+// NTSTATUS and Bugcheck Codes
//
#ifdef __ASM__
#define STATUS_INVALID_SYSTEM_SERVICE 0xC000001C
+#define STATUS_NO_CALLBACK_ACTIVE 0xC0000258
+#define APC_INDEX_MISMATCH 1
+#define IRQL_GT_ZERO_AT_SYSTEM_SERVICE 0x4A
#endif
//
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S
--- 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]
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/usercall_asm.S
--- 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
* Add more PSDK defintions to asm.h
* Use these new definitions instead of constants in syscall.S
* Document the macros using doxygen-compatible format, and convert
SET_TF_DEBUG_HEADER to as macro instead of CPP macro.
* Use SET_TF_DEBUG_HEADER in system call handlers instead of duplicating
the code.
Modified: trunk/reactos/include/ndk/asm.h
Modified: trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S
_____
Modified: trunk/reactos/include/ndk/asm.h
--- trunk/reactos/include/ndk/asm.h 2006-01-17 01:22:21 UTC (rev
20929)
+++ trunk/reactos/include/ndk/asm.h 2006-01-17 03:00:21 UTC (rev
20930)
@@ -361,6 +361,20 @@
#endif
//
+// System Call Table definitions
+//
+#define NUMBER_SERVICE_TABLES 0x0002
+#define SERVICE_NUMBER_MASK 0x0FFF
+#define SERVICE_TABLE_SHIFT 0x0008
+#define SERVICE_TABLE_MASK 0x0010
+#define SERVICE_TABLE_TEST 0x0010
+#define SERVICE_DESCRIPTOR_BASE 0x0000
+#define SERVICE_DESCRIPTOR_COUNT 0x0004
+#define SERVICE_DESCRIPTOR_LIMIT 0x0008
+#define SERVICE_DESCRIPTOR_NUMBER 0x000C
+#define SERVICE_DESCRIPTOR_LENGTH 0x0010
+
+//
// Generic Definitions
//
#define MAXIMUM_IDTVECTOR 0xFF
_____
Modified: trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
--- trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
2006-01-17 01:22:21 UTC (rev 20929)
+++ trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
2006-01-17 03:00:21 UTC (rev 20930)
@@ -46,30 +46,40 @@
#endif
//
-// SET_TF_DEBUG_HEADER
+// @name SET_TF_DEBUG_HEADER
+//
// This macro sets up the debug header in the trap frame.
-// Assumptions:
-// ebp = PKTRAP_FRAME
-// edi/ebx = Have been saved and can be used
//
-#define SET_TF_DEBUG_HEADER \
- /* Get the Debug Trap Frame EBP/EIP */ \
- mov ebx, [ebp+KTRAP_FRAME_EBP]; \
- mov edi, [ebp+KTRAP_FRAME_EIP]; \
-\
- /* Write the debug data */ \
- 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;
+// @param None.
+//
+// @remark ebp = PKTRAP_FRAME.
+// edi/ebx = Have been saved and can be used.
+//
+.macro SET_TF_DEBUG_HEADER
+ /* Get the Debug Trap Frame EBP/EIP */
+ mov ebx, [ebp+KTRAP_FRAME_EBP]
+ mov edi, [ebp+KTRAP_FRAME_EIP]
+ /* Write the debug data */
+ 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
+.endm
+
//
-// These macros help with USer-Mode APC delivery after exiting a trap.
-//
-// CHECK_FOR_APC_DELIVER
+// @name CHECK_FOR_APC_DELIVER
+//
// This macro checks if the trapframe indicates a return to user-mode,
// and, if so, checks if user-mode APCs should be delivered.
//
+// @param PreserveEax
+// Determines if EAX should be preserved. Implies that the
segment
+// registers will also be saved.
+//
+// @remark ebp = PKTRAP_FRAME.
+// ebx = Saved and will be used.
+//
.macro CHECK_FOR_APC_DELIVER PreserveEax
/* Check for V86 mode */
test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
@@ -129,26 +139,28 @@
2:
.endm
-
//
-// These macros control common execution paths for Traps and System
Call Code
-//
-// TRAP_PROLOG
+// @name TRAP_PROLOG
+//
// This macro creates a standard trap entry prologue.
// It should be used for entry into any kernel trap (KiTrapXx), but not
for
// system calls, which require special handling.
//
-// Use as follows:
-// _KiTrap00:
-// /* Push fake error code */
-// push 0
+// @param Label
+// Identifying name of the caller function; will be used to
append
+// to the name V86 and DR helper functions, which must already
exist.
//
-// /* Enter common prologue */
-// TRAP_PROLOG(0)
+// @remark Use as follows:
+// _KiTrap00:
+// /* Push fake error code */
+// push 0
//
-// /* Handle trap */
-// <Your Trap Code Here>
+// /* Enter common prologue */
+// TRAP_PROLOG(0)
//
+// /* Handle trap */
+// <Your Trap Code Here>
+//
#define TRAP_PROLOG(Label) \
/* Just to be safe, clear out the HIWORD, since it's reserved */ \
mov word ptr [esp+2], 0; \
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S
--- trunk/reactos/ntoskrnl/ke/i386/syscall.S 2006-01-17 01:22:21 UTC
(rev 20929)
+++ trunk/reactos/ntoskrnl/ke/i386/syscall.S 2006-01-17 03:00:21 UTC
(rev 20930)
@@ -238,24 +238,20 @@
mov ebx, [esi+KTHREAD_TRAP_FRAME]
mov [ebp+KTRAP_FRAME_EDX], ebx
-// ==================== COMMON DR SAVE CHECK.AND DEBUG FRAME SETUP
============//
/* Flush DR7 */
and dword ptr [ebp+KTRAP_FRAME_DR7], 0
/* Check if the thread was being debugged */
test byte ptr [esi+KTHREAD_DEBUG_ACTIVE], 0xFF
- cld
//jnz Dr_kss_a
- /* Save a pointer to the trap frame in the TCB */
SharedCode:
mov [esi+KTHREAD_TRAP_FRAME], ebp
- /* Get the Debug Trap Frame EBP/EIP */
- mov ebx, [ebp+KTRAP_FRAME_EBP]
- mov edi, [ebp+KTRAP_FRAME_EIP]
+ /* Set the trap frame debug header */
+ SET_TF_DEBUG_HEADER
-#ifdef DBG
+#ifdef DBG // FIXME: Is this for GDB? Can it be moved in the stub?
/*
* We want to know the address from where the syscall stub was
called.
* If PrevMode is KernelMode, that address is stored in our own
(kernel)
@@ -269,15 +265,9 @@
jz PrevWasKernelMode
mov edi, [edi+4]
PrevWasKernelMode:
+ mov [ebp+KTRAP_FRAME_DEBUGEIP], edi
#endif
- /* Write the debug data */
- 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
-
-// ============= END OF COMMON DR SAVE CHECK.AND DEBUG FRAME SETUP
============//
/* Enable interrupts */
sti
@@ -288,8 +278,8 @@
* The offset is related to the Table Index as such: Offset =
TableIndex x 10
*/
mov edi, eax
- shr edi, 8
- and edi, 0x10
+ shr edi, SERVICE_TABLE_SHIFT
+ and edi, SERVICE_TABLE_MASK
mov ecx, edi
/* Now add the thread's base system table to the offset */
@@ -297,8 +287,8 @@
/* Get the true syscall ID and check it */
mov ebx, eax
- and eax, 0xFFF
- cmp eax, [edi+8]
+ and eax, SERVICE_NUMBER_MASK
+ cmp eax, [edi+SERVICE_DESCRIPTOR_LIMIT]
/* Invalid ID, try to load Win32K Table */
jnb KiBBTUnexpectedRange
@@ -307,7 +297,7 @@
// <== We don't have a KeGdiFlushUserBatch callback yet (needs to
be
// sent through the PsInitializeWin32Callouts structure)
/* Check if this was Win32K */
- cmp ecx, 0x10
+ cmp ecx, SERVICE_TABLE_TEST
jnz NotWin32K
/* Get the TEB */
@@ -332,7 +322,7 @@
#ifdef DBG
/* Increase per-syscall count */
- mov ecx, [edi+4]
+ mov ecx, [edi+SERVICE_DESCRIPTOR_COUNT]
jecxz NoCountTable
inc dword ptr [ecx+eax*4]
#endif
@@ -342,12 +332,12 @@
mov esi, edx
/* Allocate room for argument list from kernel stack */
- mov ebx, [edi+12]
+ mov ebx, [edi+SERVICE_DESCRIPTOR_NUMBER]
xor ecx, ecx
mov cl, [eax+ebx]
/* Get pointer to function */
- mov edi, [edi]
+ mov edi, [edi+SERVICE_DESCRIPTOR_BASE]
mov ebx, [edi+eax*4]
/* Allocate space on our stack */
make arrow available in 24x24
Modified: trunk/reactos/subsys/system/explorer/res/arrow.ico
_____
Modified: trunk/reactos/subsys/system/explorer/res/arrow.ico
(Binary files differ)