/SPARTAN/trunk/test/fp/fp0/test.c |
---|
0,0 → 1,70 |
#include <arch/interrupt.h> |
#include <print.h> |
#include <debug.h> |
#include <panic.h> |
#include <arch/i8259.h> |
#include <func.h> |
#include <cpu.h> |
#include <arch/asm.h> |
#include <mm/tlb.h> |
#include <test.h> |
#include <arch.h> |
#include <arch/smp/atomic.h> |
#include <proc/thread.h> |
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags); |
static void thread(void *data) |
{ |
while(1) |
{ |
double e,d,le,f; |
le=-1; |
e=0; |
f=1; |
for(d=1;e!=le;d*=f,f+=1) {le=e;e=e+1/d;} |
if((int)(100000000*e)==271828182) printf("THREAD:%s e OK\n",(char*)data); |
else panic("THREAD:%s e Failed\n",(char*)data); |
// printf("100000000*e:%d\n"); |
} |
//printf("TEST:%s\n",(char*)data); |
} |
void test(void) |
{ |
thread_t *t; |
t=thread_create(thread, (void*)"0", TASK,0); |
thread_ready(t); |
t=thread_create(thread, (void*)"1", TASK,0); |
thread_ready(t); |
t=thread_create(thread, (void*)"2", TASK,0); |
thread_ready(t); |
t=thread_create(thread, (void*)"3", TASK,0); |
thread_ready(t); |
while(1); |
} |
/SPARTAN/trunk/src/Makefile.config |
---|
17,7 → 17,7 |
#USERSPACE=__USERSPACE__ |
# Uncomment if you want to run in the test mode |
#TEST=__TEST__ |
TEST=__TEST__ |
TEST_FILE=test.c |
25,7 → 25,8 |
#TEST_DIR=synch/rwlock1/ |
#TEST_DIR=synch/rwlock2/ |
#TEST_DIR=synch/rwlock3/ |
TEST_DIR=synch/rwlock4/ |
#TEST_DIR=synch/rwlock4/ |
#TEST_DIR=synch/rwlock5/ |
#TEST_DIR=synch/semaphore1/ |
#TEST_DIR=synch/semaphore2/ |
TEST_DIR=fp/fp0 |
/SPARTAN/trunk/arch/ia32/boot/Makefile |
---|
5,6 → 5,7 |
build: boot.bin |
dd if=boot.bin of=../../../src/image.bin bs=512 conv=sync |
-cat ../../../src/kernel.bin >>../../../src/image.bin |
dd if=/dev/zero of=../../../src/image.bin bs=1 seek=$(KERNEL_SIZE) count=`expr 1474560 - $(KERNEL_SIZE)` |
boot.bin: boot.o |
ld -T boot.ld -entry _start_0x7c00 --oformat binary boot.o -o $@ |
/SPARTAN/trunk/arch/ia32/include/interrupt.h |
---|
77,6 → 77,7 |
extern void null_interrupt(__u8 n, __u32 stack[]); |
extern void gp_fault(__u8 n, __u32 stack[]); |
extern void nm_fault(__u8 n, __u32 stack[]); |
extern void ss_fault(__u8 n, __u32 stack[]); |
extern void page_fault(__u8 n, __u32 stack[]); |
extern void syscall(__u8 n, __u32 stack[]); |
extern void tlb_shootdown_ipi(__u8 n, __u32 stack[]); |
/SPARTAN/trunk/arch/ia32/src/fpu_context.c |
---|
51,26 → 51,28 |
void fpu_lazy_context_save(fpu_context_t *fctx) |
{ |
printf(""); |
asm( |
"mov %0,%%eax;" |
"fxsave (%%eax);" |
"ret;" |
:"=m"(fctx) |
: |
:"%eax" |
:"eax" |
); |
printf(""); |
} |
void fpu_lazy_context_restore(fpu_context_t *fctx) |
{ |
printf(""); |
asm( |
"mov %0,%%eax;" |
"fxrstor (%%eax);" |
"ret;" |
:"=m"(fctx) |
: |
:"%eax" |
:"eax" |
); |
printf(""); |
} |
void fpu_init(void) |
/SPARTAN/trunk/arch/ia32/src/pm.c |
---|
121,6 → 121,7 |
} |
trap_register(13, gp_fault); |
trap_register( 7, nm_fault); |
trap_register(12, ss_fault); |
} |
/SPARTAN/trunk/arch/ia32/src/interrupt.c |
---|
85,22 → 85,38 |
panic("general protection fault\n"); |
} |
void ss_fault(__u8 n, __u32 stack[]) |
{ |
printf("stack[0]=%X, %%eip=%X, %%cs=%X, flags=%X\n", stack[0], stack[1], stack[2], stack[3]); |
printf("%%eax=%L, %%ebx=%L, %%ecx=%L, %%edx=%L,\n%%edi=%L, %%esi=%L, %%ebp=%L, %%esp=%L\n", stack[-2], stack[-5], stack[-3], stack[-4], stack[-9], stack[-8], stack[-1], stack); |
printf("stack: %X, %X, %X, %X\n", stack[4], stack[5], stack[6], stack[7]); |
panic("Stack fault\n"); |
} |
void nm_fault(__u8 n, __u32 stack[]) |
{ |
// printf("-1\n"); |
reset_TS_flag(); |
if ((CPU->fpu_owner)!=NULL) |
{ |
fpu_lazy_context_save(&((CPU->fpu_owner)->saved_fpu_context)); |
// printf("owner %X\n",(int)(&((CPU->fpu_owner)->saved_fpu_context))); |
fpu_lazy_context_save(&((CPU->fpu_owner)->saved_fpu_context)); |
// printf("owner 2\n"); |
(CPU->fpu_owner)->fpu_context_engaged=0; /* Enables migration */ |
// printf("owner 3\n"); |
} |
// printf("0\n"); |
if(THREAD->fpu_context_exists) fpu_lazy_context_restore(&(THREAD->saved_fpu_context)); |
else {fpu_init();THREAD->fpu_context_exists=1;} |
// printf("1\n"); |
CPU->fpu_owner=THREAD; |
reset_TS_flag(); |
// printf("2\n"); |
// printf("3\n"); |
// panic("#NM fault\n"); |
} |