mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +00:00
kern: invoke supervisor mode thread functions from C++ context with valid stack frame
This commit is contained in:
parent
d0c557e30f
commit
4baf0e8cce
2 changed files with 15 additions and 1 deletions
|
@ -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 a new issue