mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 04:11:18 +00:00
kern: invoke supervisor mode thread functions from C++ context with valid stack frame
This commit is contained in:
parent
23ba31da1f
commit
9cfd535568
2 changed files with 15 additions and 1 deletions
|
@ -21,6 +21,15 @@ namespace ams::kern::arch::arm64 {
|
||||||
void UserModeThreadStarter();
|
void UserModeThreadStarter();
|
||||||
void SupervisorModeThreadStarter();
|
void SupervisorModeThreadStarter();
|
||||||
|
|
||||||
|
void InvokeSupervisorModeThread(uintptr_t argument, uintptr_t entrypoint) {
|
||||||
|
/* Invoke the function. */
|
||||||
|
using SupervisorModeFunctionType = void (*)(uintptr_t);
|
||||||
|
reinterpret_cast<SupervisorModeFunctionType>(entrypoint)(argument);
|
||||||
|
|
||||||
|
/* Wait forever. */
|
||||||
|
AMS_INFINITE_LOOP();
|
||||||
|
}
|
||||||
|
|
||||||
void OnThreadStart() {
|
void OnThreadStart() {
|
||||||
MESOSPHERE_ASSERT(!KInterruptManager::AreInterruptsEnabled());
|
MESOSPHERE_ASSERT(!KInterruptManager::AreInterruptsEnabled());
|
||||||
/* Send KDebug event for this thread's creation. */
|
/* Send KDebug event for this thread's creation. */
|
||||||
|
|
|
@ -76,6 +76,9 @@ _ZN3ams4kern4arch5arm6427SupervisorModeThreadStarterEv:
|
||||||
/* v */
|
/* v */
|
||||||
/* | u64 argument | u64 entrypoint | KThread::StackParameters (size 0x30) | */
|
/* | u64 argument | u64 entrypoint | KThread::StackParameters (size 0x30) | */
|
||||||
|
|
||||||
|
/* Clear the link register. */
|
||||||
|
mov x30, #0
|
||||||
|
|
||||||
/* Load the argument and entrypoint. */
|
/* Load the argument and entrypoint. */
|
||||||
ldp x0, x1, [sp], #0x10
|
ldp x0, x1, [sp], #0x10
|
||||||
|
|
||||||
|
@ -84,4 +87,6 @@ _ZN3ams4kern4arch5arm6427SupervisorModeThreadStarterEv:
|
||||||
|
|
||||||
/* Mask I bit in DAIF */
|
/* Mask I bit in DAIF */
|
||||||
msr daifclr, #2
|
msr daifclr, #2
|
||||||
br x1
|
|
||||||
|
/* Invoke the function (by calling ams::kern::arch::arm64::InvokeSupervisorModeThread(argument, entrypoint)). */
|
||||||
|
b _ZN3ams4kern4arch5arm6426InvokeSupervisorModeThreadEmm
|
||||||
|
|
Loading…
Reference in a new issue