#include <internal/arm/asmmacro.S>
-GENERATE_ARM_STUB KiSwapContext
-GENERATE_ARM_STUB DbgBreakPointWithStatus
+//
+// Interlocked APIs
+//
GENERATE_ARM_STUB ExInterlockedAddLargeInteger
GENERATE_ARM_STUB ExInterlockedAddLargeStatistic
GENERATE_ARM_STUB ExInterlockedAddUlong
GENERATE_ARM_STUB InterlockedIncrement
GENERATE_ARM_STUB InterlockedPopEntrySList
GENERATE_ARM_STUB InterlockedPushEntrySList
-GENERATE_ARM_STUB Ke386CallBios
-GENERATE_ARM_STUB KeConnectInterrupt
-GENERATE_ARM_STUB KeDcacheFlushCount
-GENERATE_ARM_STUB KeDisconnectInterrupt
-GENERATE_ARM_STUB KeFlushEntireTb
-GENERATE_ARM_STUB KeGetRecommendedSharedDataAlignment
-GENERATE_ARM_STUB KeI386AllocateGdtSelectors
-GENERATE_ARM_STUB KeI386FlatToGdtSelector
-GENERATE_ARM_STUB KeI386ReleaseGdtSelectors
-GENERATE_ARM_STUB KeIcacheFlushCount
-GENERATE_ARM_STUB KeInitializeInterrupt
-GENERATE_ARM_STUB KeNumberProcessors
-GENERATE_ARM_STUB KeQueryActiveProcessors
-GENERATE_ARM_STUB KeRaiseUserException
-GENERATE_ARM_STUB KeRestoreFloatingPointState
-GENERATE_ARM_STUB KeSaveFloatingPointState
-GENERATE_ARM_STUB KeSaveStateForHibernate
-GENERATE_ARM_STUB KeSetDmaIoCoherency
-GENERATE_ARM_STUB KeSynchronizeExecution
-GENERATE_ARM_STUB KeUpdateRunTime
-GENERATE_ARM_STUB KeUpdateSystemTime
-GENERATE_ARM_STUB KeUserModeCallback
-GENERATE_ARM_STUB Kei386EoiHelper
-GENERATE_ARM_STUB KiCoprocessorError
-GENERATE_ARM_STUB KiDispatchInterrupt
-GENERATE_ARM_STUB KiApcInterrupt
-GENERATE_ARM_STUB KiPassiveRelease
-GENERATE_ARM_STUB KiInterruptTemplate
-GENERATE_ARM_STUB KiUnexpectedInterrupt
-GENERATE_ARM_STUB MmGetPhysicalAddress
-GENERATE_ARM_STUB NtVdmControl
+
+//
+// Port I/O and Register Access
+//
GENERATE_ARM_STUB READ_REGISTER_BUFFER_UCHAR
GENERATE_ARM_STUB READ_REGISTER_BUFFER_ULONG
GENERATE_ARM_STUB READ_REGISTER_BUFFER_USHORT
GENERATE_ARM_STUB READ_REGISTER_UCHAR
GENERATE_ARM_STUB READ_REGISTER_ULONG
GENERATE_ARM_STUB READ_REGISTER_USHORT
-GENERATE_ARM_STUB RtlCaptureContext
-GENERATE_ARM_STUB RtlCompareMemory
-GENERATE_ARM_STUB RtlCompareMemoryUlong
-GENERATE_ARM_STUB RtlFillMemory
-GENERATE_ARM_STUB RtlFillMemoryUlong
-GENERATE_ARM_STUB RtlGetCallersAddress
-GENERATE_ARM_STUB RtlMoveMemory
-GENERATE_ARM_STUB RtlPrefetchMemoryNonTemporal
-GENERATE_ARM_STUB RtlUlongByteSwap
-GENERATE_ARM_STUB RtlUlonglongByteSwap
-GENERATE_ARM_STUB RtlUnwind
-GENERATE_ARM_STUB RtlUshortByteSwap
-GENERATE_ARM_STUB RtlZeroMemory
GENERATE_ARM_STUB WRITE_REGISTER_BUFFER_UCHAR
GENERATE_ARM_STUB WRITE_REGISTER_BUFFER_ULONG
GENERATE_ARM_STUB WRITE_REGISTER_BUFFER_USHORT
GENERATE_ARM_STUB WRITE_REGISTER_UCHAR
GENERATE_ARM_STUB WRITE_REGISTER_ULONG
GENERATE_ARM_STUB WRITE_REGISTER_USHORT
-GENERATE_ARM_STUB _abnormal_termination
+
+//
+// CRT APIs implemented in ASM
+//
GENERATE_ARM_STUB _alldiv
GENERATE_ARM_STUB _alldvrm
GENERATE_ARM_STUB _allmul
GENERATE_ARM_STUB _aulldvrm
GENERATE_ARM_STUB _aullrem
GENERATE_ARM_STUB _aullshr
+
+//
+// RTL CRT-like APIs implemented in ASM
+//
+GENERATE_ARM_STUB RtlCompareMemory
+GENERATE_ARM_STUB RtlCompareMemoryUlong
+GENERATE_ARM_STUB RtlFillMemory
+GENERATE_ARM_STUB RtlFillMemoryUlong
+GENERATE_ARM_STUB RtlMoveMemory
+GENERATE_ARM_STUB RtlPrefetchMemoryNonTemporal
+GENERATE_ARM_STUB RtlUlongByteSwap
+GENERATE_ARM_STUB RtlUlonglongByteSwap
+GENERATE_ARM_STUB RtlUshortByteSwap
+GENERATE_ARM_STUB RtlZeroMemory
+
+//
+// Exceptions
+//
+GENERATE_ARM_STUB _abnormal_termination
GENERATE_ARM_STUB _except_handler2
GENERATE_ARM_STUB _except_handler3
GENERATE_ARM_STUB _global_unwind2
GENERATE_ARM_STUB _local_unwind2
-GENERATE_ARM_STUB KiSaveProcessorControlState
-GENERATE_ARM_STUB KiInitializeUserApc
-GENERATE_ARM_STUB KeDisableInterrupts
-GENERATE_ARM_STUB KeContextToTrapFrame
-GENERATE_ARM_STUB KiDispatchException
+
+//
+// Exported Ke Arch-Specific APIs
+//
+GENERATE_ARM_STUB KiSwapContext
+GENERATE_ARM_STUB DbgBreakPointWithStatus
+GENERATE_ARM_STUB Ke386CallBios
+GENERATE_ARM_STUB KeConnectInterrupt
+GENERATE_ARM_STUB KeDcacheFlushCount
+GENERATE_ARM_STUB KeDisconnectInterrupt
+GENERATE_ARM_STUB KeFlushEntireTb
+GENERATE_ARM_STUB KeGetRecommendedSharedDataAlignment
+GENERATE_ARM_STUB KeI386AllocateGdtSelectors
+GENERATE_ARM_STUB KeI386FlatToGdtSelector
+GENERATE_ARM_STUB KeI386ReleaseGdtSelectors
+GENERATE_ARM_STUB KeIcacheFlushCount
+GENERATE_ARM_STUB KeInitializeInterrupt
+GENERATE_ARM_STUB KeNumberProcessors
+GENERATE_ARM_STUB KeQueryActiveProcessors
+GENERATE_ARM_STUB KeRaiseUserException
+GENERATE_ARM_STUB KeRestoreFloatingPointState
+GENERATE_ARM_STUB KeSaveFloatingPointState
+GENERATE_ARM_STUB KeSaveStateForHibernate
+GENERATE_ARM_STUB KeSetDmaIoCoherency
+GENERATE_ARM_STUB KeSynchronizeExecution
+GENERATE_ARM_STUB KeUpdateRunTime
+GENERATE_ARM_STUB KeUpdateSystemTime
+GENERATE_ARM_STUB KeUserModeCallback
+GENERATE_ARM_STUB Kei386EoiHelper
+GENERATE_ARM_STUB KiCoprocessorError
+GENERATE_ARM_STUB KiDispatchInterrupt
GENERATE_ARM_STUB NtSetLdtEntries
GENERATE_ARM_STUB NtRaiseException
GENERATE_ARM_STUB NtCallbackReturn
GENERATE_ARM_STUB NtContinue
+GENERATE_ARM_STUB NtVdmControl
+GENERATE_ARM_STUB RtlCreateUserThread
+GENERATE_ARM_STUB RtlInitializeContext
+
+//
+// Internal Ke Arch-Specific Helpers
+//
+GENERATE_ARM_STUB KiSaveProcessorControlState
+GENERATE_ARM_STUB KiInitializeUserApc
+GENERATE_ARM_STUB KeDisableInterrupts
+GENERATE_ARM_STUB KiDispatchException
GENERATE_ARM_STUB KiSwapProcess
-GENERATE_ARM_STUB MmUpdatePageDir
-GENERATE_ARM_STUB KeArmInitThreadWithContext
-GENERATE_ARM_STUB MmGetPfnForProcess
-GENERATE_ARM_STUB MmCreateVirtualMapping
-GENERATE_ARM_STUB CmpInitializeMachineDependentConfiguration
GENERATE_ARM_STUB KeI386VdmInitialize
+GENERATE_ARM_STUB KeSwitchKernelStack
+GENERATE_ARM_STUB KiInitMachineDependent
+GENERATE_ARM_STUB KiComputeTimerTableIndex
+GENERATE_ARM_STUB CmpInitializeMachineDependentConfiguration
+
+
+//
+// Memory Manager Arch-Specific
+//
+GENERATE_ARM_STUB MmGetPhysicalAddress
GENERATE_ARM_STUB MmSetDirtyPage
GENERATE_ARM_STUB MmSetCleanPage
GENERATE_ARM_STUB MmIsDirtyPage
GENERATE_ARM_STUB MmInitializeHandBuiltProcess
GENERATE_ARM_STUB MmCreateProcessAddressSpace
GENERATE_ARM_STUB Mmi386ReleaseMmInfo
-GENERATE_ARM_STUB RtlCreateUserThread
-GENERATE_ARM_STUB RtlInitializeContext
-GENERATE_ARM_STUB RtlpGetExceptionAddress
-GENERATE_ARM_STUB RtlDispatchException
-GENERATE_ARM_STUB DebugService2
-GENERATE_ARM_STUB KdpGdbStubInit
-GENERATE_ARM_STUB KeSwitchKernelStack
+GENERATE_ARM_STUB MmGetPfnForProcess
+GENERATE_ARM_STUB MmCreateVirtualMapping
GENERATE_ARM_STUB MiInitPageDirectoryMap
GENERATE_ARM_STUB MmGetPageDirectory
GENERATE_ARM_STUB MmInitGlobalKernelPageDirectory
GENERATE_ARM_STUB MmGetPageProtect
GENERATE_ARM_STUB MmCreateVirtualMappingForKernel
GENERATE_ARM_STUB MiGetUserPageDirectoryCount
+
+//
+// Traps, Debugging and Execeptions
+//
+GENERATE_ARM_STUB KiApcInterrupt
+GENERATE_ARM_STUB KiPassiveRelease
+GENERATE_ARM_STUB KiInterruptTemplate
+GENERATE_ARM_STUB KiUnexpectedInterrupt
+GENERATE_ARM_STUB RtlCaptureContext
+GENERATE_ARM_STUB RtlGetCallersAddress
+GENERATE_ARM_STUB RtlUnwind
+GENERATE_ARM_STUB RtlpGetExceptionAddress
+GENERATE_ARM_STUB RtlDispatchException
+GENERATE_ARM_STUB DebugService2
GENERATE_ARM_STUB RtlpGetStackLimits
-GENERATE_ARM_STUB KiInitMachineDependent
-GENERATE_ARM_STUB KiComputeTimerTableIndex
-GENERATE_ARM_STUB _SEHCurrentRegistration
-GENERATE_ARM_STUB _SEHUnregisterFrame
-GENERATE_ARM_STUB _SEHRegisterFrame
-GENERATE_ARM_STUB _SEHCleanHandlerEnvironment
-GENERATE_ARM_STUB _SEHGlobalUnwind
+GENERATE_ARM_STUB KdpGdbStubInit
--- /dev/null
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/ke/arm/thrdini.c
+ * PURPOSE: Implements thread context setup and startup for ARM machines
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+typedef struct _KUINIT_FRAME
+{
+ KEXCEPTION_FRAME CtxSwitchFrame;
+ KEXCEPTION_FRAME ExceptionFrame;
+ KTRAP_FRAME TrapFrame;
+} KUINIT_FRAME, *PKUINIT_FRAME;
+
+typedef struct _KKINIT_FRAME
+{
+ KEXCEPTION_FRAME CtxSwitchFrame;
+} KKINIT_FRAME, *PKKINIT_FRAME;
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+KiThreadStartup(IN PKSYSTEM_ROUTINE SystemRoutine,
+ IN PKSTART_ROUTINE StartRoutine,
+ IN PVOID StartContext,
+ IN BOOLEAN UserThread,
+ IN KTRAP_FRAME TrapFrame)
+{
+ UNIMPLEMENTED;
+ return;
+}
+
+VOID
+NTAPI
+KeArmInitThreadWithContext(IN PKTHREAD Thread,
+ IN PKSYSTEM_ROUTINE SystemRoutine,
+ IN PKSTART_ROUTINE StartRoutine,
+ IN PVOID StartContext,
+ IN PCONTEXT ContextPointer)
+{
+ PKTRAP_FRAME TrapFrame;
+ PKEXCEPTION_FRAME ExceptionFrame = NULL, CtxSwitchFrame;
+
+ //
+ // Check if this is a user thread
+ //
+ if (ContextPointer)
+ {
+ //
+ // Setup the initial frame
+ //
+ PKUINIT_FRAME InitFrame;
+ InitFrame = (PKUINIT_FRAME)((ULONG_PTR)Thread->InitialStack -
+ sizeof(KUINIT_FRAME));
+
+ //
+ // Setup the Trap Frame and Exception frame
+ //
+ TrapFrame = &InitFrame->TrapFrame;
+ ExceptionFrame = &InitFrame->ExceptionFrame;
+
+ ///
+ // Zero out the trap frame and exception frame
+ //
+ RtlZeroMemory(TrapFrame, sizeof(KTRAP_FRAME));
+ RtlZeroMemory(ExceptionFrame, sizeof(KEXCEPTION_FRAME));
+
+ //
+ // Set up a trap frame from the context
+ //
+ KeContextToTrapFrame(ContextPointer,
+ ExceptionFrame,
+ TrapFrame,
+ ContextPointer->ContextFlags | CONTEXT_CONTROL,
+ UserMode);
+
+ //
+ // Set the previous mode as user
+ //
+ TrapFrame->PreviousMode = UserMode;
+ Thread->PreviousMode = UserMode;
+
+ //
+ // Clear the return address
+ //
+ ExceptionFrame->Lr = 0;
+
+ //
+ // Context switch frame to setup below
+ //
+ CtxSwitchFrame = &InitFrame->CtxSwitchFrame;
+ }
+ else
+ {
+ //
+ // Set up the Initial Frame for the system thread
+ //
+ PKKINIT_FRAME InitFrame;
+ InitFrame = (PKKINIT_FRAME)((ULONG_PTR)Thread->InitialStack -
+ sizeof(KKINIT_FRAME));
+
+ //
+ // Set the previous mode as kernel
+ //
+ Thread->PreviousMode = KernelMode;
+
+ //
+ // Context switch frame to setup below
+ //
+ CtxSwitchFrame = &InitFrame->CtxSwitchFrame;
+ }
+
+ //
+ // Now setup the context switch frame
+ //
+ CtxSwitchFrame->SwapReturn = (ULONG)KiThreadStartup;
+ CtxSwitchFrame->R11 = (ULONG)(ExceptionFrame ? ExceptionFrame : CtxSwitchFrame);
+
+ //
+ // Set the parameters
+ //
+ CtxSwitchFrame->R4 = (ULONG)ContextPointer;
+ CtxSwitchFrame->R5 = (ULONG)StartContext;
+ CtxSwitchFrame->R6 = (ULONG)StartRoutine;
+ CtxSwitchFrame->R7 = (ULONG)SystemRoutine;
+
+ //
+ // Save back the new value of the kernel stack
+ //
+ Thread->KernelStack = (PVOID)CtxSwitchFrame;
+}