From f67bf6a63792161e1b510cad7fe1027e0b7f1237 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Sun, 14 Nov 2021 19:48:38 +0800 Subject: [PATCH] smp: thread_Start accepts NULL argument struct --- smp/kthread.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/smp/kthread.c b/smp/kthread.c index 80a3260..165c3d5 100644 --- a/smp/kthread.c +++ b/smp/kthread.c @@ -74,14 +74,16 @@ smp_thread_ID smp_thread_Start(void *entry, const smp_thread_Arguments *args, un t->state.cs = GDT_EXEC_SELECTOR; t->state.ss = GDT_DATA_SELECTOR; t->state.rip = (uint64_t)__smp_thread_EntryPoint; - t->state.rax = (uint64_t)entry; - t->state.rdi = args->a; - t->state.rsi = args->b; - t->state.rdx = args->c; - t->state.rcx = args->d; - t->state.r8 = args->e; - t->state.r9 = args->f; + + if (args) { + t->state.rdi = args->a; + t->state.rsi = args->b; + t->state.rdx = args->c; + t->state.rcx = args->d; + t->state.r8 = args->e; + t->state.r9 = args->f; + } tree_Node *spare = tree_FirstNode(__smp_StackPool); if (spare) {