mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-01 19:26:16 +00:00
- 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. svn path=/trunk/; revision=33935
This commit is contained in:
@@ -55,6 +55,11 @@
|
||||
*/
|
||||
.equ PcCurrentIrql, 0x14C
|
||||
|
||||
/*
|
||||
* KTHREAD Offsets
|
||||
*/
|
||||
.equ ThKernelStack, 0x20
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,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
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define NDEBUG
|
||||
#include "debug.h"
|
||||
|
||||
CCHAR KeNumberProcessors;
|
||||
ULONG KeDcacheFlushCount;
|
||||
ULONG KeActiveProcessors;
|
||||
ULONG KeProcessorArchitecture;
|
||||
ULONG KeProcessorLevel;
|
||||
|
||||
@@ -12,17 +12,14 @@ GENERATE_ARM_STUB _local_unwind2
|
||||
//
|
||||
// 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
|
||||
|
||||
@@ -24,7 +24,6 @@ KiSystemCall(
|
||||
IN PULONG Arguments,
|
||||
IN ULONG ArgumentCount
|
||||
);
|
||||
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
@@ -34,6 +33,18 @@ HalGetInterruptSource(VOID);
|
||||
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 @@ KiDispatchInterrupt(VOID)
|
||||
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user