diff --git a/hermit/arch/x86/include/asm/processor.h b/hermit/arch/x86/include/asm/processor.h index c5697a71e..37fbb1357 100644 --- a/hermit/arch/x86/include/asm/processor.h +++ b/hermit/arch/x86/include/asm/processor.h @@ -722,8 +722,17 @@ static inline void register_task(void) */ inline static int system_calibration(void) { + size_t cr0; + apic_init(); register_task(); + + // set task switched flag for the first FPU access + // => initialize the FPU + cr0 = read_cr0(); + cr0 |= CR0_TS; + write_cr0(cr0); + irq_enable(); detect_cpu_frequency(); apic_calibration(); diff --git a/hermit/arch/x86/kernel/apic.c b/hermit/arch/x86/kernel/apic.c index 287673acf..16ec81e21 100644 --- a/hermit/arch/x86/kernel/apic.c +++ b/hermit/arch/x86/kernel/apic.c @@ -669,6 +669,12 @@ int smp_start(void) //kprintf("CR0 of core %u: 0x%x\n", atomic_int32_read(¤t_boot_id), read_cr0()); online[atomic_int32_read(¤t_boot_id)] = 1; + // set task switched flag for the first FPU access + // => initialize the FPU + size_t cr0 = read_cr0(); + cr0 |= CR0_TS; + write_cr0(cr0); + set_idle_task(); irq_enable(); diff --git a/hermit/arch/x86/kernel/tasks.c b/hermit/arch/x86/kernel/tasks.c index 84976e8dd..b10bbdabe 100644 --- a/hermit/arch/x86/kernel/tasks.c +++ b/hermit/arch/x86/kernel/tasks.c @@ -97,14 +97,6 @@ static int thread_entry(void* arg, size_t ep) if (init_tls()) return -ENOMEM; -#ifndef SAVE_FPU - // set task switched flag for the first FPU access - // => initialize the FPU - size_t cr0 = read_cr0(); - cr0 |= CR0_TS; - write_cr0(cr0); -#endif - //vma_dump(); // set first argument