Add /arm tree for Memory Manager and stub MmUpdatePageDir in C.
authorReactOS Portable Systems Group <ros-arm-bringup@svn.reactos.org>
Wed, 13 Feb 2008 05:16:14 +0000 (05:16 +0000)
committerReactOS Portable Systems Group <ros-arm-bringup@svn.reactos.org>
Wed, 13 Feb 2008 05:16:14 +0000 (05:16 +0000)
Add exp.c for ARM. Stub out KeContextToTrapFrame in C.
Add thrdini.c for ARM and implement KeArmInitThreadWithContext -- may require changes if the exception frame structure isn't preserving all we need. Stub out KiThreadStartup in C.

svn path=/trunk/; revision=32341

reactos/ntoskrnl/ke/arm/exp.c [new file with mode: 0644]
reactos/ntoskrnl/ke/arm/stubs_asm.s
reactos/ntoskrnl/ke/arm/thrdini.c [new file with mode: 0644]
reactos/ntoskrnl/mm/arm/stubs.c [new file with mode: 0644]
reactos/ntoskrnl/ntoskrnl.rbuild

diff --git a/reactos/ntoskrnl/ke/arm/exp.c b/reactos/ntoskrnl/ke/arm/exp.c
new file mode 100644 (file)
index 0000000..82e0028
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * PROJECT:         ReactOS Kernel
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            ntoskrnl/ke/arm/exp.c
+ * PURPOSE:         Implements exception helper routines for ARM machines
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+KeContextToTrapFrame(IN PCONTEXT Context,
+                     IN OUT PKEXCEPTION_FRAME ExceptionFrame,
+                     IN OUT PKTRAP_FRAME TrapFrame,
+                     IN ULONG ContextFlags,
+                     IN KPROCESSOR_MODE PreviousMode)
+{
+    UNIMPLEMENTED;
+    return;
+}
index e3e11ca..732d403 100644 (file)
@@ -1,7 +1,8 @@
 #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 
@@ -37,63 +38,26 @@ GENERATE_ARM_STUB InterlockedExchangeAdd
 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 
@@ -105,26 +69,87 @@ GENERATE_ARM_STUB _aulldiv
 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
@@ -143,13 +168,8 @@ GENERATE_ARM_STUB MmCreateVirtualMappingUnsafe
 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
@@ -157,12 +177,20 @@ GENERATE_ARM_STUB MmDeletePageTable
 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
diff --git a/reactos/ntoskrnl/ke/arm/thrdini.c b/reactos/ntoskrnl/ke/arm/thrdini.c
new file mode 100644 (file)
index 0000000..7ca1ebb
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * 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;
+}
diff --git a/reactos/ntoskrnl/mm/arm/stubs.c b/reactos/ntoskrnl/mm/arm/stubs.c
new file mode 100644 (file)
index 0000000..5e31c35
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * PROJECT:         ReactOS Kernel
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            ntoskrnl/mm/arm/stubs.c
+ * PURPOSE:         ARM Memory Manager
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <ntoskrnl.h>
+#define NDEBUG
+#include <debug.h>
+/* GLOBALS ********************************************************************/
+
+//
+// METAFIXME: We need to stop using 1MB Section Entry TTEs!
+//
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+MmUpdatePageDir(IN PEPROCESS Process,
+                IN PVOID Address,
+                IN ULONG Size)
+{
+    //
+    // Nothing to do
+    //
+    UNIMPLEMENTED;
+    return;
+}
index 3bc074a..e8d0dc1 100644 (file)
                                <file first="true">boot.s</file>
                                <file>arm_kprintf.c</file>
                                <file>cpu.c</file>
+                               <file>exp.c</file>
                                <file>kiinit.c</file>
                                <file>stubs_asm.s</file>
                                <file>stubs.c</file>
+                               <file>thrdini.c</file>
                        </directory>
                </if>
                <if property="ARCH" value="powerpc">
                                <file>page.c</file>
                        </directory>
                </if>
+               <if property="ARCH" value="arm">
+                       <directory name="arm">
+                               <file>stubs.c</file>
+                       </directory>
+               </if>
                <if property="ARCH" value="powerpc">
                        <directory name="powerpc">
                                <file>pfault.c</file>