mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-13 18:51:01 +01:00
kern: invoke supervisor mode thread functions from C++ context with valid stack frame
This commit is contained in:
parent
23ba31da1f
commit
9cfd535568
@ -21,6 +21,15 @@ namespace ams::kern::arch::arm64 {
|
||||
void UserModeThreadStarter();
|
||||
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() {
|
||||
MESOSPHERE_ASSERT(!KInterruptManager::AreInterruptsEnabled());
|
||||
/* Send KDebug event for this thread's creation. */
|
||||
|
@ -76,6 +76,9 @@ _ZN3ams4kern4arch5arm6427SupervisorModeThreadStarterEv:
|
||||
/* v */
|
||||
/* | u64 argument | u64 entrypoint | KThread::StackParameters (size 0x30) | */
|
||||
|
||||
/* Clear the link register. */
|
||||
mov x30, #0
|
||||
|
||||
/* Load the argument and entrypoint. */
|
||||
ldp x0, x1, [sp], #0x10
|
||||
|
||||
@ -84,4 +87,6 @@ _ZN3ams4kern4arch5arm6427SupervisorModeThreadStarterEv:
|
||||
|
||||
/* Mask I bit in DAIF */
|
||||
msr daifclr, #2
|
||||
br x1
|
||||
|
||||
/* Invoke the function (by calling ams::kern::arch::arm64::InvokeSupervisorModeThread(argument, entrypoint)). */
|
||||
b _ZN3ams4kern4arch5arm6426InvokeSupervisorModeThreadEmm
|
||||
|
Loading…
Reference in New Issue
Block a user