Author: ros-arm-bringup
Date: Wed Jun 11 14:13:25 2008
New Revision: 33935
URL:
http://svn.reactos.org/svn/reactos?rev=33935&view=rev
Log:
- We now implement a skeleton framework for context switching
- The only things we do are swap the stack and then display the old/new thread/stack.
- More work to be done to actually save the non-volatiles, prepare the thread state, and
restore the volatiles for the new thread.
- Then we will return to the saved return address, and we should be in Phase 1 with
working thread switching/scheduling.
Added:
trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s (with props)
Modified:
trunk/reactos/ntoskrnl/include/internal/arm/ksarm.h
trunk/reactos/ntoskrnl/ke/arm/stubs.c
trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s
trunk/reactos/ntoskrnl/ke/arm/trapc.c
trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild
Modified: trunk/reactos/ntoskrnl/include/internal/arm/ksarm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/arm/ksarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/arm/ksarm.h [iso-8859-1] Wed Jun 11 14:13:25
2008
@@ -55,6 +55,11 @@
*/
.equ PcCurrentIrql, 0x14C
+/*
+ * KTHREAD Offsets
+ */
+.equ ThKernelStack, 0x20
+
#else
/*
Added: trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s (added)
+++ trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s [iso-8859-1] Wed Jun 11 14:13:25 2008
@@ -1,0 +1,50 @@
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/ke/arm/ctxswtch.s
+ * PURPOSE: Context Switch and Idle Thread on ARM
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+ .title "ARM Context Switching"
+ .include "ntoskrnl/include/internal/arm/kxarm.h"
+ .include "ntoskrnl/include/internal/arm/ksarm.h"
+
+ TEXTAREA
+ NESTED_ENTRY KiSwapContext
+ PROLOG_END KiSwapContext
+ //
+ // a1 = Old Thread
+ // a2 = New Thread
+ //
+
+ //
+ // Save volatile registers for the OLD thread
+ //
+
+ //
+ // Switch stacks
+ //
+ str sp, [a1, #ThKernelStack]
+ ldr sp, [a2, #ThKernelStack]
+
+ //
+ // Call the C context switch code
+ //
+ bl KiSwapContextInternal
+
+ //
+ // Restore volatile registers for the NEW thread
+ //
+
+ //
+ // Jump to saved restore address
+ //
+
+ //
+ // FIXME: TODO
+ //
+ b .
+
+ ENTRY_END KiSwapContext
+
Propchange: trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: trunk/reactos/ntoskrnl/ke/arm/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/stubs.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/stubs.c [iso-8859-1] Wed Jun 11 14:13:25 2008
@@ -2,6 +2,8 @@
#define NDEBUG
#include "debug.h"
+CCHAR KeNumberProcessors;
+ULONG KeDcacheFlushCount;
ULONG KeActiveProcessors;
ULONG KeProcessorArchitecture;
ULONG KeProcessorLevel;
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] Wed Jun 11 14:13:25 2008
@@ -12,17 +12,14 @@
//
// Exported Ke Arch-Specific APIs
//
-GENERATE_ARM_STUB KiSwapContext
GENERATE_ARM_STUB DbgBreakPointWithStatus
GENERATE_ARM_STUB KeConnectInterrupt
-GENERATE_ARM_STUB KeDcacheFlushCount
GENERATE_ARM_STUB KeDisconnectInterrupt
GENERATE_ARM_STUB KeFlushEntireTb
GENERATE_ARM_STUB KeGetRecommendedSharedDataAlignment
GENERATE_ARM_STUB KeIcacheFlushCount
GENERATE_ARM_STUB KeInitializeInterrupt
GENERATE_ARM_STUB KeInvalidateAllCaches
-GENERATE_ARM_STUB KeNumberProcessors
GENERATE_ARM_STUB KeQueryActiveProcessors
GENERATE_ARM_STUB KeRaiseUserException
GENERATE_ARM_STUB KeSaveStateForHibernate
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] Wed Jun 11 14:13:25 2008
@@ -24,7 +24,6 @@
IN PULONG Arguments,
IN ULONG ArgumentCount
);
-
/* FUNCTIONS ******************************************************************/
@@ -33,6 +32,18 @@
VOID FASTCALL
HalClearSoftwareInterrupt(IN KIRQL Request);
+
+VOID
+KiSwapContextInternal(IN PKTHREAD OldThread,
+ IN PKTHREAD NewThread)
+{
+ //
+ // FIXME: TODO
+ //
+ DPRINT1("Switching from: %p to %p\n", OldThread, NewThread);
+ DPRINT1("Stacks: %p %p\n", OldThread->KernelStack,
NewThread->KernelStack);
+ while (TRUE);
+}
VOID
KiDispatchInterrupt(VOID)
@@ -107,9 +118,12 @@
//
// Swap to the new thread
+ // On ARM we call KiSwapContext instead of KiSwapContextInternal,
+ // because we're calling this from C code and not assembly.
+ // This is similar to how it gets called for unwaiting, on x86
//
DPRINT1("Swapping context!\n");
- //KiSwapContextInternal();
+ KiSwapContext(OldThread, NewThread);
while (TRUE);
}
}
Modified: trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl-generic.…
==============================================================================
--- trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] Wed Jun 11 14:13:25 2008
@@ -63,6 +63,7 @@
<file first="true">boot.s</file>
<file>arm_kprintf.c</file>
<file>cpu.c</file>
+ <file>ctxswtch.s</file>
<file>exp.c</file>
<file>kiinit.c</file>
<file>stubs_asm.s</file>