diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/intr/riscv/rv64gc/jh7110/trap.c b/Ubiquitous/XiZi_AIoT/hardkernel/intr/riscv/rv64gc/jh7110/trap.c index 3a1a4c8db..32c66ca5c 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/intr/riscv/rv64gc/jh7110/trap.c +++ b/Ubiquitous/XiZi_AIoT/hardkernel/intr/riscv/rv64gc/jh7110/trap.c @@ -75,7 +75,7 @@ void kernel_intr_handler(struct trapframe* tf) panic("Intr at kernel mode should never happen by design.\n"); } -extern void context_switch(struct context**, struct context*); +extern void context_switch(struct context*, struct context*); void syscall_arch_handler(struct trapframe* tf) { uint64_t ec = tf->cause; @@ -97,7 +97,7 @@ void syscall_arch_handler(struct trapframe* tf) assert(cur_cpu()->task != NULL); ERROR("Error Task: %s\n", cur_cpu()->task->name); sys_exit(cur_cpu()->task); - context_switch(&cur_cpu()->task->thread_context.context, cur_cpu()->scheduler); + context_switch(&cur_cpu()->task->thread_context.context, &cur_cpu()->scheduler); panic("dabort end should never be reashed.\n"); } } diff --git a/Ubiquitous/XiZi_AIoT/softkernel/include/multicores.h b/Ubiquitous/XiZi_AIoT/softkernel/include/multicores.h index 2b0765cc8..fcc9625e8 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/include/multicores.h +++ b/Ubiquitous/XiZi_AIoT/softkernel/include/multicores.h @@ -37,7 +37,11 @@ struct CPU { int cpuid; struct Thread* task; +#ifndef __riscv struct context* scheduler; +#else + struct context scheduler; +#endif }; extern struct CPU global_cpus[NR_CPU]; diff --git a/Ubiquitous/XiZi_AIoT/softkernel/task/task.c b/Ubiquitous/XiZi_AIoT/softkernel/task/task.c index 527752d00..6567dc599 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/task/task.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/task/task.c @@ -292,7 +292,11 @@ static void task_state_set_running(struct Thread* task) uintptr_t riscv_kernel_satp = 0; #endif struct Thread* next_task_emergency = NULL; +#ifndef __riscv extern void context_switch(struct context**, struct context*); +#else +extern void context_switch(struct context*, struct context*); +#endif static void _scheduler(struct SchedulerRightGroup right_group) { struct MmuCommonDone* p_mmu_driver = AchieveResource(&right_group.mmu_driver_tag); diff --git a/Ubiquitous/XiZi_AIoT/softkernel/trap/abort_handler.c b/Ubiquitous/XiZi_AIoT/softkernel/trap/abort_handler.c index 9cbc00a8a..5ddcd649f 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/trap/abort_handler.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/trap/abort_handler.c @@ -48,7 +48,11 @@ Modification: #include "syscall.h" #include "task.h" +#ifndef __riscv extern void context_switch(struct context**, struct context*); +#else +extern void context_switch(struct context*, struct context*); +#endif __attribute__((optimize("O0"))) void dabort_handler(struct trapframe* r) { #ifndef __riscv @@ -74,7 +78,11 @@ __attribute__((optimize("O0"))) void dabort_handler(struct trapframe* r) xizi_enter_kernel(); sys_exit(cur_task); assert(cur_cpu()->task == NULL); +#ifndef __riscv context_switch(&cur_task->thread_context.context, cur_cpu()->scheduler); +#else + context_switch(cur_task->thread_context.context, &cur_cpu()->scheduler); +#endif panic("dabort end should never be reashed.\n"); } @@ -103,6 +111,10 @@ __attribute__((optimize("O0"))) void iabort_handler(struct trapframe* r) xizi_enter_kernel(); sys_exit(cur_task); assert(cur_cpu()->task == NULL); +#ifndef __riscv context_switch(&cur_task->thread_context.context, cur_cpu()->scheduler); +#else + context_switch(cur_task->thread_context.context, &cur_cpu()->scheduler); +#endif panic("iabort end should never be reashed.\n"); } diff --git a/Ubiquitous/XiZi_AIoT/softkernel/trap/default_irq_handler.c b/Ubiquitous/XiZi_AIoT/softkernel/trap/default_irq_handler.c index baa3ae2de..07fe4dcef 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/trap/default_irq_handler.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/trap/default_irq_handler.c @@ -53,7 +53,11 @@ void default_interrupt_routine(int irq) ERROR("Interrupt %d has been asserted\n", irq); } +#ifndef __riscv extern void context_switch(struct context**, struct context*); +#else +extern void context_switch(struct context*, struct context*); +#endif void intr_irq_dispatch(struct trapframe* tf) { xizi_enter_kernel(); @@ -86,7 +90,11 @@ void intr_irq_dispatch(struct trapframe* tf) if (cur_cpu()->task == NULL || current_task->state != RUNNING) { cur_cpu()->task = NULL; +#ifndef __riscv context_switch(¤t_task->thread_context.context, cur_cpu()->scheduler); +#else + context_switch(current_task->thread_context.context, &cur_cpu()->scheduler); +#endif } assert(current_task == cur_cpu()->task); diff --git a/Ubiquitous/XiZi_AIoT/softkernel/trap/software_irq_handler.c b/Ubiquitous/XiZi_AIoT/softkernel/trap/software_irq_handler.c index 4c1902a45..276f0e034 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/trap/software_irq_handler.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/trap/software_irq_handler.c @@ -45,7 +45,11 @@ bool swi_distributer_init(struct SwiDispatcherRightGroup* _right_group) return p_intr_driver != NULL; } +#ifndef __riscv extern void context_switch(struct context**, struct context*); +#else +extern void context_switch(struct context*, struct context*); +#endif void software_irq_dispatch(struct trapframe* tf) { xizi_enter_kernel(); @@ -68,7 +72,7 @@ void software_irq_dispatch(struct trapframe* tf) #ifndef __riscv context_switch(&cur_task->thread_context.context, cur_cpu()->scheduler); #else - context_switch(&cur_task->thread_context.context, &cpu->scheduler); + context_switch(cur_task->thread_context.context, &cpu->scheduler); #endif } if (syscall_num == SYSCALL_EXIT) {