diff --git a/arch/context.asm b/arch/context.asm index 3b4f542..0e65f1c 100644 --- a/arch/context.asm +++ b/arch/context.asm @@ -31,4 +31,5 @@ context_launch: ; with values from the non-volatile registers saved within the thread context (r15, r14, ...) align 16 fake_systemv_abi: - +mov rdi, r15 +ret diff --git a/arch/context.cc b/arch/context.cc index bf55d4e..636fbbc 100644 --- a/arch/context.cc +++ b/arch/context.cc @@ -8,8 +8,9 @@ void panic(){ void prepareContext(void* tos, Context& context, void (*kickoff)(void*), void* param1) { - ((uint64_t*)tos)[-1] = (uint64_t)panic; - ((uint64_t*)tos)[0] = (uint64_t)kickoff; + ((uint64_t*)tos)[-2] = (uint64_t)panic; + ((uint64_t*)tos)[-1] = (uint64_t)kickoff; + ((uint64_t*)tos)[0] = (uint64_t)fake_systemv_abi; context.rsp = tos; context.rbx = 0; context.rbp = 0; diff --git a/main.cc b/main.cc index d282d45..fa66e05 100644 --- a/main.cc +++ b/main.cc @@ -17,6 +17,7 @@ #include "interrupt/guard.h" #include "arch/context.h" +#include "thread/thread.h" ///TextStream kout = TextStream(0, 80, 0, 10, true); Ticketlock koutlock; @@ -108,9 +109,10 @@ extern "C" int main() { DBG << "Main CPU " << static_cast(LAPIC::getID()) << endl << flush; Context test1; + Thread test1_thread; uint8_t test1_stack[256]; - prepareContext(test1_stack, test1, (void(*)(void*)) &(Application::kickoff)); + prepareContext(&test1_stack[255], test1, (void(*)(void*)) &(Application::kickoff), ); context_launch(&test1); //Application{}.action();