diff --git a/hermit/Makefile b/hermit/Makefile index a2eb565e5..c2aa11492 100644 --- a/hermit/Makefile +++ b/hermit/Makefile @@ -120,6 +120,7 @@ include/hermit/config.inc: include/hermit/config.h @awk '/^#define KERNEL_STACK_SIZE/{ print "%define KERNEL_STACK_SIZE", $$3 }' include/hermit/config.h >> include/hermit/config.inc @awk '/^#define VIDEO_MEM_ADDR/{ print "%define VIDEO_MEM_ADDR", $$3 }' include/hermit/config.h >> include/hermit/config.inc @awk '/^#define DYNAMIC_TICKS/{ print "%define DYNAMIC_TICKS", $$3 }' include/hermit/config.h >> include/hermit/config.inc + @awk '/^#define SAVE_FPU/{ print "%define SAVE_FPU", $$3 }' include/hermit/config.h >> include/hermit/config.inc %.o : %.asm include/hermit/config.inc @echo [ASM] $@ diff --git a/hermit/arch/x86/kernel/entry.asm b/hermit/arch/x86/kernel/entry.asm index 40c8ec917..f94eeadd9 100644 --- a/hermit/arch/x86/kernel/entry.asm +++ b/hermit/arch/x86/kernel/entry.asm @@ -574,10 +574,12 @@ common_switch: call get_current_stack ; get new rsp mov rsp, rax +%ifdef SAVE_FPU ; set task switched flag mov rax, cr0 or rax, 8 mov cr0, rax +%endif ; call cleanup code call finish_task_switch diff --git a/hermit/arch/x86/kernel/tasks.c b/hermit/arch/x86/kernel/tasks.c index b10bbdabe..84976e8dd 100644 --- a/hermit/arch/x86/kernel/tasks.c +++ b/hermit/arch/x86/kernel/tasks.c @@ -97,6 +97,14 @@ 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 diff --git a/hermit/include/hermit/config.h b/hermit/include/hermit/config.h index e2bd8cb0f..904cede19 100644 --- a/hermit/include/hermit/config.h +++ b/hermit/include/hermit/config.h @@ -41,11 +41,12 @@ extern "C" { #define VIDEO_MEM_ADDR 0xB8000 /* the video memory address */ #define CACHE_LINE 64 #define KERNEL_STACK_SIZE (8*1024) -#define DEFAULT_STACK_SIZE (128*1024) +#define DEFAULT_STACK_SIZE (64*1024*1024) #define KMSG_SIZE (4*1024) #define INT_SYSCALL 0x80 #define MAILBOX_SIZE 32 //#define WITH_PCI_IDS +#define SAVE_FPU #define BYTE_ORDER LITTLE_ENDIAN