implement kiuserinitializeapc, and begin writing test code for kiswapprocess.

svn path=/trunk/; revision=34974
This commit is contained in:
ReactOS Portable Systems Group 2008-07-31 07:06:19 +00:00
parent ef7ceb62bb
commit 6abcb17d2a
3 changed files with 70 additions and 2 deletions

View file

@ -32,8 +32,6 @@ GENERATE_ARM_STUB KeSynchronizeExecution
//
// User Mode Support
//
GENERATE_ARM_STUB KiInitializeUserApc
GENERATE_ARM_STUB KiSwapProcess
GENERATE_ARM_STUB KeSwitchKernelStack
GENERATE_ARM_STUB RtlCreateUserThread
GENERATE_ARM_STUB RtlInitializeContext

View file

@ -87,6 +87,32 @@ KiIdleLoop(VOID)
}
}
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
KiSwapContextInternal(IN PKTHREAD OldThread,
IN PKTHREAD NewThread)

View file

@ -261,3 +261,47 @@ KiSystemService(IN PKTHREAD Thread,
//
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;
}