Author: ros-arm-bringup
Date: Thu Jul 31 02:06:19 2008
New Revision: 34974
URL:
http://svn.reactos.org/svn/reactos?rev=34974&view=rev
Log:
implement kiuserinitializeapc, and begin writing test code for kiswapprocess.
Modified:
trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s
trunk/reactos/ntoskrnl/ke/arm/trapc.c
trunk/reactos/ntoskrnl/ke/arm/usercall.c
Modified: trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/stubs_asm.…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s [iso-8859-1] Thu Jul 31 02:06:19 2008
@@ -32,8 +32,6 @@
//
// User Mode Support
//
-GENERATE_ARM_STUB KiInitializeUserApc
-GENERATE_ARM_STUB KiSwapProcess
GENERATE_ARM_STUB KeSwitchKernelStack
GENERATE_ARM_STUB RtlCreateUserThread
GENERATE_ARM_STUB RtlInitializeContext
Modified: trunk/reactos/ntoskrnl/ke/arm/trapc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/trapc.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] Thu Jul 31 02:06:19 2008
@@ -85,6 +85,32 @@
KeArmWaitForInterrupt();
}
}
+}
+
+VOID
+NTAPI
+KiSwapProcess(IN PKPROCESS NewProcess,
+ IN PKPROCESS OldProcess)
+{
+ ARM_TTB_REGISTER TtbRegister;
+ DPRINT1("Swapping from: %p (%16s) to %p (%16s)\n",
+ OldProcess, ((PEPROCESS)OldProcess)->ImageFileName,
+ NewProcess, ((PEPROCESS)NewProcess)->ImageFileName);
+
+ //
+ // Update the page directory base
+ //
+ TtbRegister.AsUlong = (ULONG)NewProcess->DirectoryTableBase.LowPart;
+ ASSERT(TtbRegister.Reserved == 0);
+ KeArmTranslationTableRegisterSet(TtbRegister);
+
+ //
+ // FIXME: Flush the TLB
+ //
+
+
+ DPRINT1("Survived!\n");
+ while (TRUE);
}
BOOLEAN
Modified: trunk/reactos/ntoskrnl/ke/arm/usercall.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/usercall.c…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/usercall.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/usercall.c [iso-8859-1] Thu Jul 31 02:06:19 2008
@@ -261,3 +261,47 @@
//
Thread->TrapFrame = (PKTRAP_FRAME)TrapFrame->PreviousTrapFrame;
}
+
+VOID
+NTAPI
+KiInitializeUserApc(IN PKEXCEPTION_FRAME ExceptionFrame,
+ IN PKTRAP_FRAME TrapFrame,
+ IN PKNORMAL_ROUTINE NormalRoutine,
+ IN PVOID NormalContext,
+ IN PVOID SystemArgument1,
+ IN PVOID SystemArgument2)
+{
+ CONTEXT Context;
+ ULONG_PTR Stack;
+ ULONG ContextLength;
+ DPRINT1("User APC: %p %p %p\n", NormalContext, SystemArgument1,
SystemArgument2);
+
+ //
+ // Build the user mode context
+ //
+ Context.ContextFlags = CONTEXT_FULL;
+ KeTrapFrameToContext(TrapFrame, ExceptionFrame, &Context);
+
+ //
+ // Setup the context on the user stack
+ //
+ ContextLength = sizeof(CONTEXT);
+ Stack = (ULONG_PTR)(Context.Sp & ~7) - ContextLength;
+
+ //
+ // Make sure the stack is valid, and copy the context
+ //
+ ProbeForWrite((PVOID)Stack, ContextLength, sizeof(QUAD));
+ RtlMoveMemory((PVOID)Stack, &Context, sizeof(CONTEXT));
+
+ //
+ // Setup the trap frame when we return to user mode
+ //
+ TrapFrame->R0 = (ULONG)NormalContext;
+ TrapFrame->R1 = (ULONG)SystemArgument1;
+ TrapFrame->R2 = (ULONG)SystemArgument2;
+ TrapFrame->R3 = (ULONG)NormalRoutine;
+ TrapFrame->R8 = Stack;
+ TrapFrame->UserSp = Stack;
+ TrapFrame->UserLr = (ULONG)KeUserApcDispatcher;
+}