Author: jcatena
Date: Sun Feb 7 06:17:13 2010
New Revision: 45481
URL:
http://svn.reactos.org/svn/reactos?rev=45481&view=rev
Log:
[ntos] msvc wip
Modified:
branches/jcatena-branch/ntoskrnl/ex/init.c
branches/jcatena-branch/ntoskrnl/include/internal/ke.h
branches/jcatena-branch/ntoskrnl/include/internal/ob.h
branches/jcatena-branch/ntoskrnl/include/internal/trap_x.h
branches/jcatena-branch/ntoskrnl/include/ntoskrnl_bld.h
branches/jcatena-branch/ntoskrnl/ke/dpc.c
branches/jcatena-branch/ntoskrnl/ke/i386/irqobj.c
branches/jcatena-branch/ntoskrnl/ke/i386/traphdlr.c
branches/jcatena-branch/ntoskrnl/ke/thrdobj.c
branches/jcatena-branch/ntoskrnl/ke/thrdschd.c
branches/jcatena-branch/ntoskrnl/mm/mminit.c
branches/jcatena-branch/ntoskrnl/ps/process.c
branches/jcatena-branch/ntoskrnl/ps/thread.c
branches/jcatena-branch/ntoskrnl/trap/i386/TrapStub.h
branches/jcatena-branch/ntoskrnl/trap/trap.c
branches/jcatena-branch/ntoskrnl/trap/trap.h
branches/jcatena-branch/ntoskrnl/trap/trap.vcproj
Modified: branches/jcatena-branch/ntoskrnl/ex/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/ex/init…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/ex/init.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/ex/init.c [iso-8859-1] Sun Feb 7 06:17:13 2010
@@ -1226,6 +1226,10 @@
DPRINTT("DbgkInitialize\n");
DbgkInitialize();
+ DPRINTT("DbgkInitialize r\n");
+ _asm int 3
+
+
/* Calculate the tick count multiplier */
ExpTickCountMultiplier = ExComputeTickCountMultiplier(KeMaximumIncrement);
SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
@@ -1265,6 +1269,19 @@
PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
DPRINTT("\n");
+
+ // _enable();
+ // DPRINTT("_enable\n");
+ // _ASM int 3
+ __test(0x110, 0);
+
+
+ // DPRINTT("DbgWait\n");
+ // DbgWait(5000 * 10000);
+ // DPRINTT("DbgWait r\n");
+ // _ASM int 3
+
+
/* Allocate the initialization buffer */
InitBuffer = ExAllocatePoolWithTag(NonPagedPool,
sizeof(INIT_BUFFER),
@@ -1282,7 +1299,11 @@
KeSetPriorityThread(KeGetCurrentThread(), HIGH_PRIORITY);
/* Do Phase 1 HAL Initialization */
- if (!HalInitSystem(1, LoaderBlock)) KeBugCheck(HAL1_INITIALIZATION_FAILED);
+ DPRINTT("HalInitSystem\n");
+ if (!HalInitSystem(1, LoaderBlock))
+ KeBugCheck(HAL1_INITIALIZATION_FAILED);
+ DPRINTT("HalInitSystem r\n");
+
/* Get the command line and upcase it */
CommandLine = _strupr(LoaderBlock->LoadOptions);
Modified: branches/jcatena-branch/ntoskrnl/include/internal/ke.h
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/include…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/include/internal/ke.h [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/include/internal/ke.h [iso-8859-1] Sun Feb 7
06:17:13 2010
@@ -98,9 +98,13 @@
extern UCHAR KeProcessNodeSeed;
extern ETHREAD KiInitialThread;
extern EPROCESS KiInitialProcess;
+
+#if 0 // moved to interrupt.h
extern PULONG KiInterruptTemplateObject;
extern PULONG KiInterruptTemplateDispatch;
extern PULONG KiInterruptTemplate2ndDispatch;
+#endif
+
extern ULONG KiUnexpectedEntrySize;
extern ULONG_PTR KiDoubleFaultStack;
extern EX_PUSH_LOCK KernelAddressSpaceLock;
Modified: branches/jcatena-branch/ntoskrnl/include/internal/ob.h
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/include…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/include/internal/ob.h [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/include/internal/ob.h [iso-8859-1] Sun Feb 7
06:17:13 2010
@@ -9,7 +9,7 @@
//
// Define this if you want debugging support
//
-#define _OB_DEBUG_ 0x00
+#define _OB_DEBUG_ 0xFF
//
// These define the Debug Masks Supported
Modified: branches/jcatena-branch/ntoskrnl/include/internal/trap_x.h
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/include…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/include/internal/trap_x.h [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/include/internal/trap_x.h [iso-8859-1] Sun Feb 7
06:17:13 2010
@@ -305,7 +305,7 @@
mov eax, KTRAP_FRAME.Eax[esp]
mov ecx, KTRAP_FRAME.Ecx[esp]
mov edx, KTRAP_FRAME.Edx[esp]
- jmp edx
+ iretd
#else
mov ebx, [esp+KTRAP_FRAME_EBX]
mov esi, [esp+KTRAP_FRAME_ESI]
@@ -624,15 +624,14 @@
#endif
}
-//
// Returns whether or not this is a V86 trap by checking the EFLAGS field.
-//
-// FIXME: GCC 4.5 Can Improve this with "goto labels"
-//
BOOLEAN
FORCEINLINE
KiIsV8086TrapSafe(IN PKTRAP_FRAME TrapFrame)
{
+#if defined(_MSC_VER)
+ return TrapFrame->EFlags & EFLAGS_V86_MASK ? TRUE : FALSE;
+#elif defined(__GNUC__)
BOOLEAN Result;
/*
@@ -642,12 +641,9 @@
* Instead, we use the SS segment which is guaranteed to be correct. Because
* operate in 32-bit flat mode, this works just fine.
*/
-#if defined(_MSC_VER)
- _ASM_BEGIN
- test ss:[TrapFrame+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
- setnz Result
- _ASM_END
-#elif defined(__GNUC__)
+//
+// FIXME: GCC 4.5 Can Improve this with "goto labels"
+//
asm volatile
(
"testl $%c[f], %%ss:%1\n"
@@ -656,13 +652,13 @@
: "m"(TrapFrame->EFlags),
[f] "i"(EFLAGS_V86_MASK)
);
-#elif
-#error unsupported compiler
-#endif
-
/* If V86 flag was set */
return Result;
-}
+#elif
+#error unsupported compiler
+#endif
+}
+
//
// Returns whether or not this is a user-mode trap by checking the SegCs field.
@@ -673,8 +669,9 @@
FORCEINLINE
KiIsUserTrapSafe(IN PKTRAP_FRAME TrapFrame)
{
- BOOLEAN Result;
-
+#if defined(_MSC_VER)
+ return TrapFrame->SegCs != KGDT_R0_CODE ? TRUE : FALSE;
+#elif defined(__GNUC__)
/*
* The check MUST be done this way, as we guarantee that no DS/ES/FS segment
* is used (since it might be garbage).
@@ -682,13 +679,9 @@
* Instead, we use the SS segment which is guaranteed to be correct. Because
* operate in 32-bit flat mode, this works just fine.
*/
-#if defined(_MSC_VER)
- _ASM_BEGIN
- cmp ss:[TrapFrame+KTRAP_FRAME_CS], KGDT_R0_CODE
- setnz Result
- _ASM_END
-#elif defined(__GNUC__)
- asm volatile
+ BOOLEAN Result;
+
+ asm volatile
(
"cmp $%c[f], %%ss:%1\n"
"setnz %0\n"
@@ -696,12 +689,12 @@
: "m"(TrapFrame->SegCs),
[f] "i"(KGDT_R0_CODE)
);
-#elif
-#error unsupported compiler
-#endif
-
/* If V86 flag was set */
return Result;
+#elif
+#error unsupported compiler
+#endif
+
}
VOID
@@ -940,6 +933,7 @@
}
}
+#if 0
//
// Interrupt Trap Entry
//
@@ -947,15 +941,16 @@
FORCEINLINE
KiEnterInterruptTrap(IN PKTRAP_FRAME TrapFrame)
{
- ULONG Ds, Es;
+
+ // ULONG Ds, Es;
/* Check for V86 mode, otherwise check for ring 3 code */
if (__builtin_expect(KiIsV8086TrapSafe(TrapFrame), 0))
{
/* Set correct segments */
- Ke386SetDs(KGDT_R3_DATA | RPL_MASK);
- Ke386SetEs(KGDT_R3_DATA | RPL_MASK);
- Ke386SetFs(KGDT_R0_PCR);
+ // Ke386SetDs(KGDT_R3_DATA | RPL_MASK);
+ // Ke386SetEs(KGDT_R3_DATA | RPL_MASK);
+ // Ke386SetFs(KGDT_R0_PCR);
/* Restore V8086 segments into Protected Mode segments */
TrapFrame->SegFs = TrapFrame->V86Fs;
@@ -965,20 +960,12 @@
}
else if (__builtin_expect(KiIsUserTrapSafe(TrapFrame), 1)) /* Ring 3 is more common
*/
{
- /* Save DS/ES and load correct values */
- Es = Ke386GetEs();
- Ds = Ke386GetDs();
- TrapFrame->SegDs = Ds;
- TrapFrame->SegEs = Es;
- Ke386SetDs(KGDT_R3_DATA | RPL_MASK);
- Ke386SetEs(KGDT_R3_DATA | RPL_MASK);
-
- /* Save FS/GS */
- TrapFrame->SegFs = Ke386GetFs();
+ /* Save GS */
+ // TrapFrame->SegFs = Ke386GetFs();
TrapFrame->SegGs = Ke386GetGs();
/* Set correct FS */
- Ke386SetFs(KGDT_R0_PCR);
+ // Ke386SetFs(KGDT_R0_PCR);
}
/* Save exception list and terminate it */
@@ -997,8 +984,10 @@
}
/* Set debug header */
- KiFillTrapFrameDebug(TrapFrame);
-}
+ // KiFillTrapFrameDebug(TrapFrame);
+}
+#endif
+
#if 0
//
@@ -1178,7 +1167,7 @@
_ASM_BEGIN
mov KTRAP_FRAME.Eax[esp], eax
mov KTRAP_FRAME.Ecx[esp], ecx
- mov KTRAP_FRAME.Edx[esp], eax
+ mov KTRAP_FRAME.Edx[esp], edx
_ASM_END
#elif defined(__GNUC)
__asm__ __volatile__
Modified: branches/jcatena-branch/ntoskrnl/include/ntoskrnl_bld.h
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/include…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/include/ntoskrnl_bld.h [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/include/ntoskrnl_bld.h [iso-8859-1] Sun Feb 7
06:17:13 2010
@@ -140,4 +140,4 @@
#define HALDISPATCH (&HalDispatchTable)
#define ExRaiseStatus RtlRaiseStatus
-void __test(void);
+void __test(int fn, void *arg);
Modified: branches/jcatena-branch/ntoskrnl/ke/dpc.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/ke/dpc.…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/ke/dpc.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/ke/dpc.c [iso-8859-1] Sun Feb 7 06:17:13 2010
@@ -454,6 +454,8 @@
PKPRCB Prcb = KeGetCurrentPrcb();
PKTHREAD NextThread, Thread = Prcb->CurrentThread;
+ DPRINTT("\n");
+
/* Check if a DPC Event was requested to be signaled */
if (InterlockedExchange(&Prcb->DpcSetEventRequest, 0))
{
Modified: branches/jcatena-branch/ntoskrnl/ke/i386/irqobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/ke/i386…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/ke/i386/irqobj.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/ke/i386/irqobj.c [iso-8859-1] Sun Feb 7 06:17:13
2010
@@ -43,23 +43,20 @@
Entry = HalVectorToIDTEntry(Vector);
/* Setup the handlers */
- Dispatch->NoDispatch = (PVOID)KiInterruptNoDispatch;
+ Dispatch->NoDispatch = (PVOID)KiInterruptNoDispatch;
Dispatch->InterruptDispatch = (PVOID)KiInterruptDispatch;
- Dispatch->FloatingDispatch = (PVOID)KiInterruptNoDispatch; // Floating
Interrupts are not supported
+ Dispatch->FloatingDispatch = (PVOID)KiInterruptNoDispatch; // Floating Interrupts
are not supported
Dispatch->ChainedDispatch = (PVOID)KiChainedDispatch;
- // Dispatch->FlatDispatch = NULL;
- Dispatch->FlatDispatch = (PVOID)KiInterruptNoDispatch;
+ Dispatch->FlatDispatch = (PVOID)NULL;
/* Get the current handler */
Current = KeQueryInterruptHandler(Vector);
/* Set the interrupt */
- Dispatch->Interrupt = CONTAINING_RECORD(Current,
- KINTERRUPT,
- DispatchCode);
+ Dispatch->Interrupt = KiInterruptGetObject(Current);
/* Check what this interrupt is connected to */
- if ((PKINTERRUPT_ROUTINE)Current == Dispatch->NoDispatch)
+ if (Current == (PVOID)Dispatch->NoDispatch)
{
/* Not connected */
Dispatch->Type = NoConnect;
@@ -95,7 +92,9 @@
DISPATCH_INFO Dispatch;
PKINTERRUPT_ROUTINE Handler;
- /* Get vector data */
+ DPRINTT("\n");
+
+ /* Get vector data */
KiGetVectorDispatch(Interrupt->Vector, &Dispatch);
/* Check if we're only disconnecting */
@@ -121,9 +120,13 @@
ASSERT(Dispatch.FlatDispatch == NULL);
Handler = (PVOID)&Interrupt->DispatchCode;
}
-
+
/* Register the interrupt */
- KeRegisterInterruptHandler(Interrupt->Vector, Handler);
+ _ASM int 3
+ Interrupt->DispatchAddress = Handler;
+ KeRegisterInterruptHandler(Interrupt->Vector,
(PVOID)&Interrupt->DispatchCode);
+
+ // KeRegisterInterruptHandler(Interrupt->Vector, Handler);
}
VOID
@@ -145,27 +148,22 @@
KiEoiHelper(TrapFrame);
}
-#if 0
VOID
KiUnexpectedInterrupt(VOID)
{
/* Crash the machine */
KeBugCheck(TRAP_CAUSE_UNKNOWN);
}
-#endif
-
-typedef void (FASTCALL PKI_INTERRUPT_DISPATCH)(IN PKTRAP_FRAME TrapFrame, IN PKINTERRUPT
Interrupt);
-
+
VOID
FASTCALL
-// KiUnexpectedInterruptTailHandler(IN PKTRAP_FRAME TrapFrame, IN PKINTERRUPT Interrupt
)
-KiInterruptNoDispatch(IN PKTRAP_FRAME TrapFrame, IN PKINTERRUPT Interrupt)
+KiUnexpectedInterruptTailHandler(IN PKTRAP_FRAME TrapFrame, PKINTERRUPT Interrupt)
{
KIRQL OldIrql;
- DPRINTT("\n");
-
- /* Enter trap */
+ DPRINTT("\n");
+
+ /* Enter trap */
KiEnterInterruptTrap(TrapFrame);
/* Increase interrupt count */
@@ -187,12 +185,52 @@
}
}
-VOID FASTCALL KiInterruptDispatch(IN PKTRAP_FRAME TrapFrame, IN PKINTERRUPT Interrupt)
+typedef
+VOID
+(FASTCALL PKI_INTERRUPT_DISPATCH)(
+ IN PKTRAP_FRAME TrapFrame,
+ IN PKINTERRUPT Interrupt
+);
+
+VOID
+FASTCALL
+KiInterruptNoDispatch(IN PKTRAP_FRAME TrapFrame, PKINTERRUPT Interrupt)
+{
+ KIRQL OldIrql;
+
+ DPRINTT("\n");
+
+ /* Enter trap */
+ KiEnterInterruptTrap(TrapFrame);
+
+ /* Increase interrupt count */
+ KeGetCurrentPrcb()->InterruptCount++;
+
+ /* Start the interrupt */
+ if (HalBeginSystemInterrupt(HIGH_LEVEL, Interrupt->Vector, &OldIrql))
+ {
+ /* Warn user */
+ DPRINT1("\n\x7\x7!!! Unexpected Interrupt %02lx !!!\n");
+
+ /* Now call the epilogue code */
+ KiExitInterrupt(TrapFrame, OldIrql, FALSE);
+ }
+ else
+ {
+ /* Now call the epilogue code */
+ KiExitInterrupt(TrapFrame, OldIrql, TRUE);
+ }
+}
+
+VOID
+FASTCALL
+KiInterruptDispatch(IN PKTRAP_FRAME TrapFrame,
+ IN PKINTERRUPT Interrupt)
{
KIRQL OldIrql;
- DPRINTT("\n");
- /* Increase interrupt count */
+ DPRINTT("\n");
+ /* Increase interrupt count */
KeGetCurrentPrcb()->InterruptCount++;
/* Begin the interrupt, making sure it's not spurious */
@@ -228,8 +266,9 @@
BOOLEAN Handled;
PLIST_ENTRY NextEntry, ListHead;
- DPRINTT("\n");
- /* Increase interrupt count */
+ DPRINTT("\n");
+
+ /* Increase interrupt count */
KeGetCurrentPrcb()->InterruptCount++;
/* Begin the interrupt, making sure it's not spurious */
@@ -296,25 +335,21 @@
}
}
-
-#if 0
VOID
FASTCALL
KiInterruptTemplateHandler(IN PKTRAP_FRAME TrapFrame,
IN PKINTERRUPT Interrupt)
{
- /* Enter interrupt frame */
+ DPRINTT("\n");
+ /* Enter interrupt frame */
KiEnterInterruptTrap(TrapFrame);
/* Call the correct dispatcher */
((PKI_INTERRUPT_DISPATCH*)Interrupt->DispatchAddress)(TrapFrame, Interrupt);
}
-#endif
-
-#if 0
-KiTrap(KiInterruptTemplate, KI_PUSH_FAKE_ERROR_CODE | KI_HARDWARE_INT);
-KiTrap(KiUnexpectedInterruptTail, KI_PUSH_FAKE_ERROR_CODE);
-#endif
+
+// KiTrap(KiInterruptTemplate, KI_PUSH_FAKE_ERROR_CODE | KI_HARDWARE_INT);
+// KiTrap(KiUnexpectedInterruptTail, KI_PUSH_FAKE_ERROR_CODE);
/* PUBLIC FUNCTIONS **********************************************************/
@@ -335,10 +370,7 @@
IN CHAR ProcessorNumber,
IN BOOLEAN FloatingSave)
{
- // ULONG i;
- iptru PatchAddr;
- PULONG DispatchCode = &Interrupt->DispatchCode[0];
- PULONG Patch = DispatchCode;
+ PULONG DispatchCode = &Interrupt->DispatchCode[0];
/* Set the Interrupt Header */
Interrupt->Type = InterruptObject;
@@ -368,29 +400,12 @@
Interrupt->FloatingSave = FloatingSave;
Interrupt->TickCount = MAXULONG;
Interrupt->DispatchCount = MAXULONG;
- Interrupt->DispatchAddress = (PKINTERRUPT_ROUTINE)KiInterruptNoDispatch;
-
-#if 0 // !!!
- /* Loop the template in memory */
- for (i = 0; i < KINTERRUPT_DISPATCH_CODES; i++)
- {
- /* Copy the dispatch code */
- *DispatchCode++ = ((PULONG)KiInterruptTemplate)[i];
- }
-#endif
-
-#if 0
- /* Jump to the last 4 bytes */
- Patch = (PULONG)((ULONG_PTR)Patch +
- ((ULONG_PTR)&KiInterruptTemplateObject -
- (ULONG_PTR)KiInterruptTemplate) - 4);
-
- /* Apply the patch */
- *Patch = PtrToUlong(Interrupt);
-#endif
-
- PatchAddr = (iptru)KiInterrupt0 + Interrupt->Vector * ((iptru)KiInterrupt1 -
(iptru)KiInterrupt0);
- *((iptru *)(PatchAddr+1)) = (iptru)Interrupt;
+
+ /* copy the handler template code to the actual handler instance */
+ memcpy(DispatchCode, KiInterruptTemplate, KiInterruptTemplateSize);
+
+ // patch handler to associate PKINTERRUPT to it
+ KiInterruptSetObject(DispatchCode, Interrupt);
/* Disconnect it at first */
Interrupt->Connected = FALSE;
@@ -409,7 +424,9 @@
ULONG Vector;
DISPATCH_INFO Dispatch;
- /* Get data from interrupt */
+ DPRINTT("\n");
+
+ /* Get data from interrupt */
Number = Interrupt->Number;
Vector = Interrupt->Vector;
Irql = Interrupt->Irql;
@@ -507,7 +524,8 @@
PKINTERRUPT NextInterrupt;
BOOLEAN State;
- /* Set the affinity */
+ DPRINTT("\n");
+ /* Set the affinity */
KeSetSystemAffinityThread(1 << Interrupt->Number);
/* Lock the dispatcher */
@@ -588,6 +606,8 @@
NTSTATUS Status;
KIRQL OldIrql;
+ DPRINTT("\n");
+
/* Raise IRQL */
OldIrql = KfRaiseIrql(Interrupt->SynchronizeIrql);
Modified: branches/jcatena-branch/ntoskrnl/ke/i386/traphdlr.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/ke/i386…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Sun Feb 7 06:17:13
2010
@@ -1159,7 +1159,6 @@
return; // !!!
KiEoiHelper(TrapFrame);
}
- DPRINTT("KiEoiHelper r\n");
/* Check for S-LIST fault */
if (TrapFrame->Eip == (ULONG_PTR)ExpInterlockedPopEntrySListFault)
Modified: branches/jcatena-branch/ntoskrnl/ke/thrdobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/ke/thrd…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/ke/thrdobj.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/ke/thrdobj.c [iso-8859-1] Sun Feb 7 06:17:13 2010
@@ -1317,7 +1317,7 @@
/* Return Old Priority */
DPRINTT("ret=%x\n", OldPriority);
-
+ return OldPriority;
}
/*
Modified: branches/jcatena-branch/ntoskrnl/ke/thrdschd.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/ke/thrd…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/ke/thrdschd.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/ke/thrdschd.c [iso-8859-1] Sun Feb 7 06:17:13 2010
@@ -345,7 +345,9 @@
PKTHREAD NextThread;
ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);
- /* Acquire the PRCB lock */
+ DPRINTT("\n");
+
+ /* Acquire the PRCB lock */
KiAcquirePrcbLock(Prcb);
/* Get the next thread */
@@ -711,7 +713,9 @@
PKPRCB Prcb = KeGetCurrentPrcb();
PKTHREAD Thread = KeGetCurrentThread(), NextThread;
- /* Fail if there's no ready summary */
+ DPRINTT("\n");
+
+ /* Fail if there's no ready summary */
if (!Prcb->ReadySummary) return Status;
/* Raise IRQL to synch */
Modified: branches/jcatena-branch/ntoskrnl/mm/mminit.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/mm/mmin…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/mm/mminit.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/mm/mminit.c [iso-8859-1] Sun Feb 7 06:17:13 2010
@@ -361,6 +361,7 @@
if (Phase == 0)
{
+ DPRINTT("phase 0\n");
/* Initialize the kernel address space */
KeInitializeGuardedMutex(&PsGetCurrentProcess()->AddressCreationLock);
MmKernelAddressSpace = MmGetCurrentAddressSpace();
@@ -412,9 +413,6 @@
/* Initialize the Loader Lock */
KeInitializeMutant(&MmSystemLoadLock, FALSE);
-
- DPRINT1("__test\n");
- __test();
/* Reload boot drivers */
MiReloadBootLoadedDrivers(LoaderBlock);
@@ -432,7 +430,8 @@
}
else if (Phase == 1)
{
- MmInitializeRmapList();
+ DPRINTT("phase 1\n");
+ MmInitializeRmapList();
MmInitializePageOp();
MmInitSectionImplementation();
MmInitPagingFile();
@@ -479,7 +478,7 @@
{
}
-
+ DPRINTT("r\n");
return TRUE;
}
Modified: branches/jcatena-branch/ntoskrnl/ps/process.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/ps/proc…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/ps/process.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/ps/process.c [iso-8859-1] Sun Feb 7 06:17:13 2010
@@ -371,7 +371,6 @@
DPRINTT("PSTRACE\n");
PSTRACE(PS_PROCESS_DEBUG,
"ProcessHandle: %p Parent: %p\n", ProcessHandle, ParentProcess);
- DPRINTT("PSTRACE r\n");
/* Validate flags */
if (Flags & ~PS_ALL_FLAGS) return STATUS_INVALID_PARAMETER;
@@ -380,12 +379,14 @@
if (ParentProcess)
{
/* Reference it */
- Status = ObReferenceObjectByHandle(ParentProcess,
+ DPRINTT("ObReferenceObjectByHandle\n");
+ Status = ObReferenceObjectByHandle(ParentProcess,
PROCESS_CREATE_PROCESS,
PsProcessType,
PreviousMode,
(PVOID*)&Parent,
NULL);
+ DPRINTT("ObReferenceObjectByHandle r=%x\n", Status);
if (!NT_SUCCESS(Status)) return Status;
/* If this process should be in a job but the parent isn't */
Modified: branches/jcatena-branch/ntoskrnl/ps/thread.c
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/ps/thre…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/ps/thread.c [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/ps/thread.c [iso-8859-1] Sun Feb 7 06:17:13 2010
@@ -143,7 +143,10 @@
PSTRACE(PS_THREAD_DEBUG,
"StartRoutine: %p StartContext: %p\n", StartRoutine,
StartContext);
- /* Unlock the dispatcher Database */
+ // CpuDumpCpu(7);
+ // _ASM int 3
+
+ /* Unlock the dispatcher Database */
KeLowerIrql(PASSIVE_LEVEL);
Thread = PsGetCurrentThread();
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] Sun Feb 7 06:17:13
2010
@@ -14,10 +14,10 @@
#define TRAP_STUB_FS KGDT_R0_PCR
#endif
-#define TRAP_STUB_NAMEH tokenpaste(TRAP_STUB_NAME, Handler)
+// #define TRAP_STUB_NAMEH tokenpaste(TRAP_STUB_NAME, Handler)
#if (TRAP_STUB_FLAGS & TRAPF_INTERRUPT)
-VOID _FASTCALL tokenpaste(TRAP_STUB_NAME, Handler)(KTRAP_FRAME *TrapFrame);
+VOID _FASTCALL tokenpaste(TRAP_STUB_NAME, Handler)(KTRAP_FRAME *TrapFrame, PKINTERRUPT
Interrupt);
#else
VOID _FASTCALL tokenpaste(TRAP_STUB_NAME, Handler)(KTRAP_FRAME *TrapFrame);
#endif
@@ -33,7 +33,8 @@
mov esp, KTSS.Esp0[esp]
sub esp, dword ptr offset KTRAP_FRAME.V86Es
#elif (TRAP_STUB_FLAGS & TRAPF_INTERRUPT)
- // the primary stub (trap_m.h) pushes the vector number
+ // the primary stub (trap_m.h) pushes a pointer to KINTERRUPT
+ int 3
sub esp, offset KTRAP_FRAME.ErrCode
#elif (TRAP_STUB_FLAGS & TRAPF_ERRORCODE)
sub esp, offset KTRAP_FRAME.ErrCode
@@ -61,24 +62,26 @@
#if !(TRAP_STUB_FLAGS & TRAPF_NOSAVESEG)
mov KTRAP_FRAME.SegDs[esp], ds
mov KTRAP_FRAME.SegEs[esp], es
-#if !(TRAP_STUB_FLAGS & TRAPF_NOSAVEFS)
- mov KTRAP_FRAME.SegFs[esp], fs
-#endif
#if !(TRAP_STUB_FLAGS & TRAPF_NOLOADDS)
-#ifndef TRAP_STUB_DS
-#define TRAP_STUB_DS (KGDT_R3_DATA | RPL_MASK)
-#endif
mov ax, TRAP_STUB_DS
mov ds, ax
mov es, ax
#endif
+#if !(TRAP_STUB_FLAGS & TRAPF_NOSAVEFS)
+ mov KTRAP_FRAME.SegFs[esp], fs
+#if (TRAP_STUB_FLAGS & TRAPF_LOADFS)
+ mov ax, TRAP_STUB_FS
+ mov fs, ax
#endif
+#endif // #if !(TRAP_STUB_FLAGS & TRAPF_NOSAVEFS)
+#endif // #if !(TRAP_STUB_FLAGS & TRAPF_NOSAVESEG)
// call handler
#if (TRAP_STUB_FLAGS & TRAPF_INTERRUPT)
mov edx, KTRAP_FRAME.ErrCode[esp]
mov ecx, esp
- call KINTERRUPT.DispatchAddress[edx]
+ call tokenpaste(TRAP_STUB_NAME, Handler)
+ // call KINTERRUPT.DispatchAddress[edx]
#else
mov ecx, esp
call tokenpaste(TRAP_STUB_NAME, Handler)
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] Sun Feb 7 06:17:13 2010
@@ -140,8 +140,19 @@
void *kk = KiTrap00;
+VOID _FASTCALL KiInterruptHandler(KTRAP_FRAME *TrapFrame, PKINTERRUPT Interrupt)
+{
+ DPRINTT("\n");
+ _ASM int 3
+ KiInterruptTemplateHandler(TrapFrame, Interrupt);
+ // KiTrapReturn(TrapFrame);
+}
+
VOID _CDECL KiTrapInit(VOID)
{
- KiInterruptInitialData.DispatchAddress = (PKINTERRUPT_ROUTINE)KiInterruptNoDispatch;
+ PKINTERRUPT Interrupt = &KiInterruptInitialData;
+
+ Interrupt->DispatchAddress = (PKINTERRUPT_ROUTINE)KiInterruptNoDispatch;
+ Interrupt->Vector = 0x30;
}
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] Sun Feb 7 06:17:13 2010
@@ -2,7 +2,8 @@
#define DBGTRAP DPRINT1
// #define DBGTRAPENTRY DPRINT1("\n"); DbgDumpCpu(7|DBG_DUMPCPU_TSS);
DPRINT1("TrapFrame=%p:\n", TrapFrame); DbgDumpMem(TrapFrame, 0x80)
-#define DBGTRAPENTRY DbgDumpCpu(7); DPRINT1("TrapFrame=%p:\n", TrapFrame);
DbgDumpMem(TrapFrame, sizeof(KTRAP_FRAME));
+// #define DBGTRAPENTRY DbgDumpCpu(7); DPRINT1("TrapFrame=%p:\n", TrapFrame);
DbgDumpMem(TrapFrame, sizeof(KTRAP_FRAME));
+#define DBGTRAPENTRY
// TRAP_STUB_FLAGS TrapStub x-macro flags
// trap type
@@ -14,10 +15,24 @@
#define TRAPF_NOSAVEFS 0x200
#define TRAPF_SAVENOVOL 0x400
#define TRAPF_NOLOADDS 0x800
+#define TRAPF_LOADFS 0x1000
#include <trap_asm.h>
+// interrupt handler template
+VOID _CDECL KiInterruptTemplate(VOID);
+extern PULONG KiInterruptTemplateEnd;
+extern PULONG KiInterruptTemplateObject;
+extern PULONG KiInterruptTemplateDispatch;
+extern PULONG KiInterruptTemplate2ndDispatch;
+#define KiInterruptTemplateSize ((iptru)&KiInterruptTemplateEnd -
(iptru)KiInterruptTemplate)
+#define KiInterruptTemplateObjectOffset ((iptru)&KiInterruptTemplateObject -
(iptru)KiInterruptTemplate - sizeof(iptru))
+
extern KINTERRUPT KiInterruptInitialData;
+
+VOID _FASTCALL KiInterruptTemplateHandler(PKTRAP_FRAME TrapFrame, PKINTERRUPT
Interrupt);
+VOID _CDECL KiUnexpectedInterruptTail(VOID);
+VOID _FASTCALL KiUnexpectedInterruptTailHandler(PKTRAP_FRAME TrapFrame, PKINTERRUPT
Interrupt);
VOID _CDECL KiTrapInit(VOID);
VOID _CDECL KiInterrupt0(VOID);
@@ -32,3 +47,18 @@
VOID KiExitTrapDebugChecks(IN PKTRAP_FRAME TrapFrame, IN KTRAP_EXIT_SKIP_BITS SkipBits);
VOID KiEnterTrap(IN PKTRAP_FRAME TrapFrame);
VOID KiExitTrap(IN PKTRAP_FRAME TrapFrame, IN UCHAR Skip);
+VOID FASTCALL KiEnterInterruptTrap(IN PKTRAP_FRAME TrapFrame);
+
+
+// get the PKINTERRUPT assigned to the int handler
+// it is an immediate patched in the handler code
+// see KeInterruptTemplate code
+PKINTERRUPT _INLINE KiInterruptGetObject(PVOID Handler)
+{
+ return *((PKINTERRUPT *)(((iptru)Handler)+KiInterruptTemplateObjectOffset));
+}
+
+VOID _INLINE KiInterruptSetObject(PVOID Handler, PKINTERRUPT Interrupt)
+{
+ *((PKINTERRUPT *)(((iptru)Handler)+KiInterruptTemplateObjectOffset)) = Interrupt;
+}
Modified: branches/jcatena-branch/ntoskrnl/trap/trap.vcproj
URL:
http://svn.reactos.org/svn/reactos/branches/jcatena-branch/ntoskrnl/trap/tr…
==============================================================================
--- branches/jcatena-branch/ntoskrnl/trap/trap.vcproj [iso-8859-1] (original)
+++ branches/jcatena-branch/ntoskrnl/trap/trap.vcproj [iso-8859-1] Sun Feb 7 06:17:13
2010
@@ -185,6 +185,10 @@
</File>
<File
+ RelativePath=".\i386\trap_m.s"
+ >
+ </File>
+ <File
RelativePath=".\i386\TrapStub.h"
</File>