Author: jcatena
Date: Wed Feb 3 14:25:03 2010
New Revision: 45392
URL:
http://svn.reactos.org/svn/reactos?rev=45392&view=rev
Log:
[NTOS] msc trap stub
Modified:
branches/jcatena-branch/ntoskrnl/trap/i386/TrapStub.h
branches/jcatena-branch/ntoskrnl/trap/trap.c
branches/jcatena-branch/ntoskrnl/trap/trap.h
Modified: branches/jcatena-branch/ntoskrnl/trap/i386/TrapStub.h
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/trap/i3…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/trap/i386/TrapStub.h [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/trap/i386/TrapStub.h [iso-8859-1] Wed Feb 3 14:25:03
2010
@@ -6,17 +6,20 @@
#error
#endif
-#define TRAP_STUB_NAMEH0(x) x##Handler
-#define TRAP_STUB_NAMEH1(x) TRAP_STUB_NAMEH0(x)
-#define TRAP_STUB_NAMEH TRAP_STUB_NAMEH1(TRAP_STUB_NAME)
+#define TRAP_STUB_NAMEH tokenpaste(TRAP_STUB_NAME, Handler)
+#if (TRAP_STUB_FLAGS & TRAPF_INTERRUPT)
+#define TRAP_STUB_PARAM2 tokenpaste(TRAP_STUB_NAME, Interrupt)
+PKINTERRUPT TRAP_STUB_PARAM2;
+#else
VOID _FASTCALL TRAP_STUB_NAMEH(KTRAP_FRAME *TrapFrame);
+#endif
_NAKED VOID TRAP_STUB_NAME(VOID)
{
_ASM_BEGIN
// setup frame
-#if (TRAP_STUB_FLAGS & TRAPF_SYSENTER)
+#if (TRAP_STUB_FLAGS & TRAPF_FASTSYSCALL)
mov esp, ss:[KIP0PCRADDRESS + offset KPCR.TSS]
mov esp, KTSS.Esp0[esp]
// sub esp, dword ptr offset KTRAP_FRAME.V86Es
@@ -37,7 +40,7 @@
#if !(TRAP_STUB_FLAGS & TRAPF_NOSAVESEG)
mov KTRAP_FRAME.SegDs[esp], ds
mov KTRAP_FRAME.SegEs[esp], es
-#if !(TRAP_STUB_FLAGS & TRAPF_NOSAVEFS)
+#if (TRAP_STUB_FLAGS & TRAPF_SAVEFS)
mov KTRAP_FRAME.SegFs[esp], fs
#endif
#if !(TRAP_STUB_FLAGS & TRAPF_NOLOADDS)
@@ -57,23 +60,16 @@
mov KTRAP_FRAME.Edi[esp], edi
#endif
-#if (TRAP_STUB_FLAGS & TRAPF_VECTOR)
-:scadr:
- mov edx, 0
- call edx
-#endif
// call handler
mov ecx, esp
+#if (TRAP_STUB_FLAGS & TRAPF_INTERRUPT)
+ mov edx, TRAP_STUB_PARAM2
+ call PKINTERRUPT.DispatchAddress[edx]
+#else
call TRAP_STUB_NAMEH
+#endif
- _ASM_END
-
- // asmcall(TRAP_STUB_NAMEH);
- // call TRAP_STUB_NAMEH
- // call HandlerName
-
- _ASM_BEGIN
- // return
+ // restore regs
#if (TRAP_STUB_FLAGS & TRAPF_SAVENOVOL)
mov ebp, KTRAP_FRAME.Ebp[esp]
mov ebx, KTRAP_FRAME.Ebx[esp]
@@ -84,12 +80,21 @@
#if !(TRAP_STUB_FLAGS & TRAPF_NOSAVESEG)
mov ds, KTRAP_FRAME.SegDs[esp]
mov es, KTRAP_FRAME.SegEs[esp]
-#if !(TRAP_STUB_FLAGS & TRAPF_NOSAVEFS)
+#if (TRAP_STUB_FLAGS & TRAPF_SAVEFS)
mov fs, KTRAP_FRAME.SegFs[esp]
#endif
#endif
+ // restore volatle regs and return
mov eax, KTRAP_FRAME.Eax[esp]
+
+#if (TRAP_STUB_FLAGS & TRAPF_FASTSYSCALL)
+ mov ecx, KTRAP_FRAME.HardwareEsp[esp]
+ mov edx, KTRAP_FRAME.Eip[esp]
+ add esp, dword ptr offset KTRAP_FRAME.V86Es
+ sti
+ sysexit
+#endif
mov ecx, KTRAP_FRAME.Ecx[esp]
mov edx, KTRAP_FRAME.Edx[esp]
iretd
Modified: branches/jcatena-branch/ntoskrnl/trap/trap.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/trap/tr…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/trap/trap.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/trap/trap.c [iso-8859-1] Wed Feb 3 14:25:03 2010
@@ -129,7 +129,7 @@
//
#define TRAP_STUB_NAME KiFastCallEntry
-#define TRAP_STUB_FLAGS TRAPF_SYSENTER
+#define TRAP_STUB_FLAGS TRAPF_FASTSYSCALL
#include <TrapStub.h>
#define TRAP_STUB_NAME KiInterruptTemplate
@@ -140,6 +140,5 @@
VOID _FASTCALL init(void)
{
- void *t = scadr;
}
Modified: branches/jcatena-branch/ntoskrnl/trap/trap.h
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/trap/tr…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/trap/trap.h [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/trap/trap.h [iso-8859-1] Wed Feb 3 14:25:03 2010
@@ -1,14 +1,14 @@
_ONCE
-#define TRAPF_NOSAVESEG 1
-#define TRAPF_NOSAVEFS 2
-#define TRAPF_SAVENOVOL 4
-#define TRAPF_VECTOR 0x100
-#define TRAPF_ERRORCODE 0x200
-#define TRAPF_SYSENTER 0x400
-
-extern KPCR const *TrapPcr;
+// TRAP_STUB_FLAGS TrapStub x-macro flags
+// trap type
+#define TRAPF_ERRORCODE 1
+#define TRAPF_INTERRUPT 2
+#define TRAPF_FASTSYSCALL 4
+// options
+#define TRAPF_NOSAVESEG 0x100
+#define TRAPF_SAVEFS 0x200
+#define TRAPF_SAVENOVOL 0x400
+#define TRAPF_NOLOADDS 0x800
#include <trap_asm.h>
-
-