diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index 2a36ab76..fe1e602b 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -512,6 +512,7 @@ hack1: no_task_switch1: pop ebx + xor eax, eax sti ret diff --git a/arch/x86/kernel/isrs.c b/arch/x86/kernel/isrs.c index f1c4497f..1d8398bf 100644 --- a/arch/x86/kernel/isrs.c +++ b/arch/x86/kernel/isrs.c @@ -229,7 +229,8 @@ static void fault_handler(struct state *s) { if (s->int_no < 32) { kputs(exception_messages[s->int_no]); - kprintf(" Exception (%d) at 0x%x:0x%x, error code 0x%x\n", s->int_no, s->cs, s->eip, s->error); + kprintf(" Exception (%d) at 0x%x:0x%x, error code 0x%x, eflags 0x%x\n", + s->int_no, s->cs, s->eip, s->error, s->eflags); /* Now, we signalize that we have handled the interrupt */ if (apic_is_enabled()) diff --git a/include/metalsvm/stddef.h b/include/metalsvm/stddef.h index fef0fc07..a34ccf10 100644 --- a/include/metalsvm/stddef.h +++ b/include/metalsvm/stddef.h @@ -38,14 +38,14 @@ typedef unsigned int tid_t; #define DEFINE_PER_CORE(type, name, def_value) type name = def_value; #define CORE_ID 0 #else -#define per_core(name) __get_percore_##name() +#define per_core(name) (*__get_percore_##name()) #define DECLARE_PER_CORE(type, name) \ typedef struct { type var __attribute__ ((aligned (CACHE_LINE))); } aligned_##name;\ extern aligned_##name name[MAX_CORES];\ - inline static type __get_percore_##name(void) {\ - type ret; \ + inline static type* __get_percore_##name(void) {\ + type* ret; \ uint32_t flags = irq_nested_disable(); \ - ret = name[smp_id()].var; \ + ret = &(name[smp_id()].var); \ irq_nested_enable(flags);\ return ret; \ } diff --git a/kernel/tasks.c b/kernel/tasks.c index 96f47ad8..ec7ddf0d 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -68,7 +68,7 @@ int multitasking_init(void) { memset(task_table[0].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS); task_table[0].pgd = get_boot_pgd(); task_table[0].flags = TASK_DEFAULT_FLAGS; - current_task[0].var = task_table+0; + per_core(current_task) = task_table+0; return 0; } @@ -763,7 +763,7 @@ void scheduler(void) if (curr_task->status == TASK_RUNNING) curr_task->status = TASK_READY; task_table[new_id].status = TASK_RUNNING; - current_task[CORE_ID].var = task_table+new_id; + per_core(current_task) = task_table+new_id; goto get_task_out; } @@ -776,7 +776,7 @@ void scheduler(void) * we switch to the idle task, if the current task terminates * and no other is ready */ - current_task[CORE_ID].var = task_table+CORE_ID; + per_core(current_task) = task_table+CORE_ID; get_task_out: //kprintf("schedule %d on core %d\n", per_core(current_task)->id, smp_id());