diff --git a/conts/baremetal/test/SConstruct b/conts/baremetal/test/SConstruct index 6e0d141..f2d8f75 100644 --- a/conts/baremetal/test/SConstruct +++ b/conts/baremetal/test/SConstruct @@ -61,6 +61,7 @@ env = Environment(CC = config.user_toolchain + 'gcc', src = Glob('*.[cS]') src += Glob('src/*.[cS]') +src += Glob('src/arch/*.[cS]') objs = env.Object(src) prog = env.Program('main.elf', objs) diff --git a/conts/baremetal/test/src/arch-arm/new_thread.S b/conts/baremetal/test/src/arch-arm/new_thread.S index 2dbaaf2..88dcfc7 100644 --- a/conts/baremetal/test/src/arch-arm/new_thread.S +++ b/conts/baremetal/test/src/arch-arm/new_thread.S @@ -1,11 +1,11 @@ #include -BEGIN_PROC(setup_new_thread) +BEGIN_PROC(local_setup_new_thread) ldr r0, [sp, #-4]! @ Load first argument. mov lr, pc @ Save return address ldr pc, [sp, #-4]! @ Load function pointer from stack new_thread_exit: b new_thread_exit @ We infinitely loop for now. -END_PROC(setup_new_thread) +END_PROC(local_setup_new_thread) diff --git a/conts/baremetal/test/src/captest.c b/conts/baremetal/test/src/captest.c index 816aedb..da70565 100644 --- a/conts/baremetal/test/src/captest.c +++ b/conts/baremetal/test/src/captest.c @@ -15,8 +15,8 @@ int simple_pager_thread(void *arg) l4_getid(&ids); - //printf("Thread spawned from pager, " - // "trying to create new thread.\n"); + printf("Thread spawned from pager, \ + trying to create new thread.\n"); err = l4_thread_control(THREAD_CREATE | TC_SHARE_SPACE | TC_AS_PAGER, &ids); @@ -24,8 +24,8 @@ int simple_pager_thread(void *arg) if (res == 0) if (err == -ENOCAP || err == -ENOMEM) { - //printf("Creation failed with %d " - // "as expected.\n", err); + printf("Creation failed with %d " + "as expected.\n", err); testres = 0; } else { printf("Creation was supposed to fail " @@ -56,7 +56,6 @@ int simple_pager_thread(void *arg) int wait_check_test(struct task_ids *ids) { -#if 0 int result; /* Wait for thread to finish */ @@ -68,7 +67,7 @@ int wait_check_test(struct task_ids *ids) printf("Top-level test has failed\n"); } /* Else it is a success */ -#endif + return 0; } @@ -77,7 +76,7 @@ int capability_test(void) int err; struct task_ids ids; int TEST_MUST_FAIL = 0; - int TEST_MUST_SUCCEED = 1; + //int TEST_MUST_SUCCEED = 1; /* Read pager capabilities */ caps_read_all(); @@ -93,17 +92,17 @@ int capability_test(void) goto out_err; } + printf("waititng for result\n"); /* Wait for test to finish and check result */ if (wait_check_test(&ids) < 0) goto out_err; - #if 0 + /* Destroy test thread */ if ((err = l4_thread_control(THREAD_DESTROY, &ids)) < 0) { printf("Destruction of top-level simple_pager failed.\n"); BUG(); } -#endif /* * Share operations with the same thread @@ -132,7 +131,6 @@ int capability_test(void) if (wait_check_test(&ids) < 0) goto out_err; -#if 0 /* Destroy test thread */ if ((err = l4_thread_control(THREAD_DESTROY, &ids)) < 0) { printf("Destruction of top-level simple_pager failed.\n"); diff --git a/conts/baremetal/test/src/thread.c b/conts/baremetal/test/src/thread.c index 6235dfb..3936d43 100644 --- a/conts/baremetal/test/src/thread.c +++ b/conts/baremetal/test/src/thread.c @@ -12,7 +12,7 @@ char *__stack_ptr = &stack[1][0]; char utcb[THREADS_TOTAL][UTCB_SIZE] ALIGN(8); char *__utcb_ptr = &utcb[1][0]; -extern void setup_new_thread(void); +extern void local_setup_new_thread(void); int thread_create(int (*func)(void *), void *args, unsigned int flags, struct task_ids *new_ids) @@ -44,16 +44,16 @@ int thread_create(int (*func)(void *), void *args, unsigned int flags, return -ENOMEM; /* First word of new stack is arg */ - ((unsigned long *)__stack_ptr)[-1] = (unsigned long)args; + *(((unsigned int *)__stack_ptr) -1) = (unsigned int)args; /* Second word of new stack is function address */ - ((unsigned long *)__stack_ptr)[-2] = (unsigned long)func; + *(((unsigned int *)__stack_ptr) -2) = (unsigned int)func; /* Setup new thread pc, sp, utcb */ memset(&exregs, 0, sizeof(exregs)); exregs_set_stack(&exregs, (unsigned long)__stack_ptr); exregs_set_utcb(&exregs, (unsigned long)__utcb_ptr); - exregs_set_pc(&exregs, (unsigned long)setup_new_thread); + exregs_set_pc(&exregs, (unsigned long)local_setup_new_thread); if ((err = l4_exchange_registers(&exregs, ids.tid)) < 0) return err;