diff options
Diffstat (limited to 'samples/nanokernel')
-rw-r--r-- | samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c | 45 | ||||
-rw-r--r-- | samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h | 2 | ||||
-rw-r--r-- | samples/nanokernel/benchmark/sys_kernel/src/lifo.c | 186 | ||||
-rw-r--r-- | samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c | 179 | ||||
-rw-r--r-- | samples/nanokernel/benchmark/sys_kernel/src/sema.c | 95 | ||||
-rw-r--r-- | samples/nanokernel/benchmark/sys_kernel/src/stack.c | 161 | ||||
-rw-r--r-- | samples/nanokernel/benchmark/sys_kernel/src/syskernel.c | 132 | ||||
-rw-r--r-- | samples/nanokernel/benchmark/sys_kernel/src/syskernel.h | 4 | ||||
-rw-r--r-- | samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c | 28 | ||||
-rw-r--r-- | samples/nanokernel/test/test_context/src/context.c | 231 | ||||
-rw-r--r-- | samples/nanokernel/test/test_fifo/src/fifo.c | 324 | ||||
-rw-r--r-- | samples/nanokernel/test/test_lifo/src/lifo.c | 174 | ||||
-rw-r--r-- | samples/nanokernel/test/test_sema/src/sema.c | 137 | ||||
-rw-r--r-- | samples/nanokernel/test/test_stack/src/stack.c | 172 | ||||
-rw-r--r-- | samples/nanokernel/test/test_timer/src/timer.c | 174 |
15 files changed, 1037 insertions, 1007 deletions
diff --git a/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c b/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c index fbfa1279a..4bdc38bef 100644 --- a/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c +++ b/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c @@ -87,24 +87,24 @@ static char pStack[FIBER_STACK_SIZE]; /* pointer array ensures specified functions are linked into the image */ volatile pfunc func_array[] = { - /* nano timer functions */ + /* nano timer functions */ (pfunc)nano_timer_init, (pfunc)nano_fiber_timer_start, (pfunc)nano_fiber_timer_wait, - /* nano semaphore functions */ + /* nano semaphore functions */ (pfunc)nano_sem_init, (pfunc)nano_fiber_sem_take_wait, (pfunc)nano_fiber_sem_give, #ifdef TEST_max - /* nano LIFO functions */ + /* nano LIFO functions */ (pfunc)nano_lifo_init, (pfunc)nano_fiber_lifo_put, (pfunc)nano_fiber_lifo_get, - /* nano stack functions */ + /* nano stack functions */ (pfunc)nano_stack_init, (pfunc)nano_fiber_stack_push, (pfunc)nano_fiber_stack_pop, - /* nano FIFO functions */ + /* nano FIFO functions */ (pfunc)nano_fifo_init, (pfunc)nano_fiber_fifo_put, (pfunc)nano_fiber_fifo_get, @@ -119,9 +119,9 @@ volatile pfunc func_array[] = { */ void dummyIsr(void *unused) - { +{ ARG_UNUSED(unused); - } +} #ifdef TEST_reg /******************************************************************************* @@ -136,28 +136,27 @@ void dummyIsr(void *unused) */ static void isrDummyIntStub(void *unused) - { +{ ARG_UNUSED(unused); isr_dummy(); CODE_UNREACHABLE; - } +} #endif /* TEST_reg */ /******************************************************************************* * * fiberEntry - trivial fiber * + * @param message Message to be printed. + * @param arg1 Unused. + * * RETURNS: N/A */ -static void fiberEntry - ( - int message, /* message to be printed */ - int arg1 /* unused */ - ) - { +static void fiberEntry(int message, int arg1) +{ ARG_UNUSED(arg1); #ifdef TEST_max @@ -165,7 +164,7 @@ static void fiberEntry #else printk((char *)message); #endif /* TEST_max */ - } +} #endif /* !TEST_min */ @@ -180,19 +179,19 @@ static void fiberEntry */ void main(void) - { +{ #ifdef TEST_max - /* dynamically link in dummy ISR */ + /* dynamically link in dummy ISR */ irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr, - (void *) 0, isrDummyHandlerStub); + (void *) 0, isrDummyHandlerStub); #endif /* TEST_max */ #ifndef TEST_min - /* start a trivial fiber */ + /* start a trivial fiber */ task_fiber_start(pStack, FIBER_STACK_SIZE, fiberEntry, (int) MESSAGE, - (int) func_array, 10, 0); + (int) func_array, 10, 0); #endif /* !TEST_min */ while (1) { - i++; - } + i++; } +} diff --git a/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h b/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h index 427e32051..83570103f 100644 --- a/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h +++ b/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h @@ -42,7 +42,7 @@ static inline void isr_dummy(void) extern void _IntEnt(void); extern void _IntExit(void); - /* compiler-generated preamble pushes & modifies EBP */ + /* compiler-generated preamble pushes & modifies EBP */ __asm__ volatile ( "pop %%ebp;\n\t" "call _IntEnt;\n\t" diff --git a/samples/nanokernel/benchmark/sys_kernel/src/lifo.c b/samples/nanokernel/benchmark/sys_kernel/src/lifo.c index 09ca249e4..12af810eb 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/lifo.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/lifo.c @@ -47,26 +47,26 @@ static struct nano_fifo nanoFifo_sync; /* for synchronization */ */ void lifo_test_init(void) - { +{ nano_lifo_init(&nanoLifo1); nano_lifo_init(&nanoLifo2); - } +} /******************************************************************************* * * lifo_fiber1 - lifo test context * + * @param par1 Ignored parameter. + * @param par2 Number of test loops. + * * RETURNS: N/A * * \NOMANUAL */ -void lifo_fiber1( - int par1, /* ignored parameter */ - int par2 /* number of test loops */ - ) - { +void lifo_fiber1(int par1, int par2) +{ int i; int element_a[2]; int element_b[2]; @@ -75,84 +75,89 @@ void lifo_fiber1( ARG_UNUSED(par1); for (i = 0; i < par2 / 2; i++) { - pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1); - if (pelement[1] != 2 * i) - break; - element_a[1] = 2 * i; - nano_fiber_lifo_put(&nanoLifo2, element_a); - pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1); - if (pelement[1] != 2 * i + 1) - break; - element_b[1] = 2 * i + 1; - nano_fiber_lifo_put(&nanoLifo2, element_b); + pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1); + if (pelement[1] != 2 * i) { + break; + } + element_a[1] = 2 * i; + nano_fiber_lifo_put(&nanoLifo2, element_a); + pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1); + if (pelement[1] != 2 * i + 1) { + break; + } + element_b[1] = 2 * i + 1; + nano_fiber_lifo_put(&nanoLifo2, element_b); } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* * * lifo_fiber2 - lifo test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void lifo_fiber2( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void lifo_fiber2(int par1, int par2) +{ int i; int element[2]; int * pelement; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - element[1] = i; - nano_fiber_lifo_put(&nanoLifo1, element); - pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo2); - if (pelement[1] != i) - break; - (*pcounter)++; + element[1] = i; + nano_fiber_lifo_put(&nanoLifo1, element); + pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo2); + if (pelement[1] != i) { + break; + } + (*pcounter)++; } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* * * lifo_fiber3 - lifo test context * + * @param par1 Address of the counter. + * @param par2 Number of test loops. + * * RETURNS: N/A * * \NOMANUAL */ -void lifo_fiber3( - int par1, /* address of the counter */ - int par2 /* number of test loops */ - ) - { +void lifo_fiber3(int par1, int par2) +{ int i; int element[2]; int * pelement; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - element[1] = i; - nano_fiber_lifo_put(&nanoLifo1, element); - while (NULL == (pelement = (int *) nano_fiber_lifo_get(&nanoLifo2))) - fiber_yield(); - if (pelement[1] != i) - break; - (*pcounter)++; + element[1] = i; + nano_fiber_lifo_put(&nanoLifo1, element); + while (NULL == (pelement = (int *) nano_fiber_lifo_get(&nanoLifo2))) { + fiber_yield(); + } + if (pelement[1] != i) { + break; + } + (*pcounter)++; } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* * @@ -164,7 +169,7 @@ void lifo_fiber3( */ int lifo_test(void) - { +{ uint32_t t; int i = 0; int return_value = 0; @@ -173,12 +178,12 @@ int lifo_test(void) nano_fifo_init(&nanoFifo_sync); - /* test get wait & put fiber functions */ + /* test get wait & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "LIFO channel - 'nano_fiber_lifo_get_wait'"); + "LIFO channel - 'nano_fiber_lifo_get_wait'"); fprintf(output_file, sz_description, - "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," - " 'nano_fiber_lifo_put' functions;"); + "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," + " 'nano_fiber_lifo_put' functions;"); printf(sz_test_start_fmt, "'nano_fiber_lifo_get_wait'"); lifo_test_init(); @@ -186,26 +191,27 @@ int lifo_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, lifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, lifo_fiber2, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } - /* test get/yield & put fiber functions */ + /* test get/yield & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "LIFO channel - 'nano_fiber_lifo_get'"); + "LIFO channel - 'nano_fiber_lifo_get'"); fprintf(output_file, sz_description, - "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," - " 'nano_fiber_lifo_get',\n"); + "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," + " 'nano_fiber_lifo_get',\n"); fprintf(output_file, - "\t'nano_fiber_lifo_put', 'fiber_yield' functions;"); + "\t'nano_fiber_lifo_put', 'fiber_yield' functions;"); printf(sz_test_start_fmt, "'nano_fiber_lifo_get'"); lifo_test_init(); @@ -214,24 +220,25 @@ int lifo_test(void) i = 0; task_fiber_start(fiber_stack1, STACK_SIZE, lifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, lifo_fiber3, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } - /* test get wait & put fiber/task functions */ + /* test get wait & put fiber/task functions */ fprintf(output_file, sz_test_case_fmt, - "LIFO channel - 'nano_task_lifo_get_wait'"); + "LIFO channel - 'nano_task_lifo_get_wait'"); fprintf(output_file, sz_description, - "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," - " 'nano_fiber_lifo_put',\n"); + "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," + " 'nano_fiber_lifo_put',\n"); fprintf(output_file, "\t'nano_task_lifo_get_wait', 'nano_task_lifo_put' functions;"); printf(sz_test_start_fmt, "'nano_task_lifo_get_wait'"); @@ -240,30 +247,33 @@ int lifo_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, lifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) { - int element[2]; - int * pelement; - element[1] = 2 * i; - nano_task_lifo_put(&nanoLifo1, element); - element[1] = 2 * i + 1; - nano_task_lifo_put(&nanoLifo1, element); - - pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2); - if (pelement[1] != 2 * i + 1) - break; - pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2); - if (pelement[1] != 2 * i) - break; + int element[2]; + int * pelement; + element[1] = 2 * i; + nano_task_lifo_put(&nanoLifo1, element); + element[1] = 2 * i + 1; + nano_task_lifo_put(&nanoLifo1, element); + + pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2); + if (pelement[1] != 2 * i + 1) { + break; + } + pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2); + if (pelement[1] != 2 * i) { + break; + } } t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i * 2, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } return return_value; - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c b/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c index 86738ad48..5122fffb2 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c @@ -48,10 +48,10 @@ static struct nano_fifo nanoFifo_sync; /* for synchronization */ */ void fifo_test_init(void) - { +{ nano_fifo_init(&nanoFifo1); nano_fifo_init(&nanoFifo2); - } +} /******************************************************************************* @@ -60,29 +60,30 @@ void fifo_test_init(void) * * RETURNS: N/A * + * @param par1 Ignored parameter. + * @param par2 Number of test loops. + * * \NOMANUAL */ -void fifo_fiber1( - int par1, /* ignored parameter */ - int par2 /* number of test loops */ - ) - { +void fifo_fiber1(int par1, int par2) +{ int i; int element[2]; int * pelement; ARG_UNUSED(par1); for (i = 0; i < par2; i++) { - pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo1); - if (pelement[1] != i) - break; - element[1] = i; - nano_fiber_fifo_put(&nanoFifo2, element); + pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo1); + if (pelement[1] != i) { + break; + } + element[1] = i; + nano_fiber_fifo_put(&nanoFifo2, element); } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* @@ -91,30 +92,31 @@ void fifo_fiber1( * * RETURNS: N/A * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * \NOMANUAL */ -void fifo_fiber2( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void fifo_fiber2(int par1, int par2) +{ int i; int element[2]; int * pelement; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - element[1] = i; - nano_fiber_fifo_put(&nanoFifo1, element); - pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo2); - if (pelement[1] != i) - break; - (*pcounter)++; + element[1] = i; + nano_fiber_fifo_put(&nanoFifo1, element); + pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo2); + if (pelement[1] != i) { + break; + } + (*pcounter)++; } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* @@ -123,31 +125,33 @@ void fifo_fiber2( * * RETURNS: N/A * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * \NOMANUAL */ -void fifo_fiber3( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void fifo_fiber3(int par1, int par2) +{ int i; int element[2]; int * pelement; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - element[1] = i; - nano_fiber_fifo_put(&nanoFifo1, element); - while (NULL == (pelement = (int *) nano_fiber_fifo_get(&nanoFifo2))) - fiber_yield(); - if (pelement[1] != i) - break; - (*pcounter)++; + element[1] = i; + nano_fiber_fifo_put(&nanoFifo1, element); + while (NULL == (pelement = (int *) nano_fiber_fifo_get(&nanoFifo2))) { + fiber_yield(); + } + if (pelement[1] != i) { + break; + } + (*pcounter)++; } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* @@ -160,7 +164,7 @@ void fifo_fiber3( */ int fifo_test(void) - { +{ uint32_t t; int i = 0; int return_value = 0; @@ -169,12 +173,12 @@ int fifo_test(void) nano_fifo_init(&nanoFifo_sync); - /* test get wait & put fiber functions */ + /* test get wait & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "FIFO channel - 'nano_fiber_fifo_get_wait'"); + "FIFO channel - 'nano_fiber_fifo_get_wait'"); fprintf(output_file, sz_description, - "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," - " 'nano_fiber_fifo_put' functions;"); + "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," + " 'nano_fiber_fifo_put' functions;"); printf(sz_test_start_fmt, "'nano_fiber_fifo_get_wait'"); fifo_test_init(); @@ -182,26 +186,27 @@ int fifo_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, fifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, fifo_fiber2, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } - /* test get/yield & put fiber functions */ + /* test get/yield & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "FIFO channel - 'nano_fiber_fifo_get'"); + "FIFO channel - 'nano_fiber_fifo_get'"); fprintf(output_file, sz_description, - "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," - " 'nano_fiber_fifo_get',\n"); + "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," + " 'nano_fiber_fifo_get',\n"); fprintf(output_file, - "\t'nano_fiber_fifo_put', 'fiber_yield' functions;"); + "\t'nano_fiber_fifo_put', 'fiber_yield' functions;"); printf(sz_test_start_fmt, "'nano_fiber_fifo_get'"); fifo_test_init(); @@ -210,26 +215,27 @@ int fifo_test(void) i = 0; task_fiber_start(fiber_stack1, STACK_SIZE, fifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, fifo_fiber3, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } - /* test get wait & put fiber/task functions */ + /* test get wait & put fiber/task functions */ fprintf(output_file, sz_test_case_fmt, - "FIFO channel - 'nano_task_fifo_get_wait'"); + "FIFO channel - 'nano_task_fifo_get_wait'"); fprintf(output_file, sz_description, - "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," - " 'nano_fiber_fifo_put',\n"); + "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," + " 'nano_fiber_fifo_put',\n"); fprintf(output_file, - "\t'nano_task_fifo_get_wait', 'nano_task_fifo_put' functions;"); + "\t'nano_task_fifo_get_wait', 'nano_task_fifo_put' functions;"); printf(sz_test_start_fmt, "'nano_task_fifo_get_wait'"); fifo_test_init(); @@ -237,31 +243,34 @@ int fifo_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, fifo_fiber1, 0, - NUMBER_OF_LOOPS / 2, 3, 0); + NUMBER_OF_LOOPS / 2, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, fifo_fiber1, 0, - NUMBER_OF_LOOPS / 2, 3, 0); + NUMBER_OF_LOOPS / 2, 3, 0); for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) { - int element[2]; - int * pelement; - element[1] = i; - nano_task_fifo_put(&nanoFifo1, element); - element[1] = i; - nano_task_fifo_put(&nanoFifo1, element); - - pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2); - if (pelement[1] != i) - break; - pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2); - if (pelement[1] != i) - break; + int element[2]; + int * pelement; + element[1] = i; + nano_task_fifo_put(&nanoFifo1, element); + element[1] = i; + nano_task_fifo_put(&nanoFifo1, element); + + pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2); + if (pelement[1] != i) { + break; + } + pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2); + if (pelement[1] != i) { + break; + } } t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i * 2, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } return return_value; - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/sema.c b/samples/nanokernel/benchmark/sys_kernel/src/sema.c index 9d8093365..6047073e7 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/sema.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/sema.c @@ -45,85 +45,86 @@ struct nano_sem nanoSem2; */ void sema_test_init(void) - { +{ nano_sem_init(&nanoSem1); nano_sem_init(&nanoSem2); - } +} /******************************************************************************* * * sema_fiber1 - semaphore test context * + * @param par1 Ignored parameter. + * @param par2 Number of test loops. + * * RETURNS: N/A * * \NOMANUAL */ -void sema_fiber1( - int par1, /* ignored parameter */ - int par2 /* number of test loops */ - ) - { +void sema_fiber1(int par1, int par2) +{ int i; ARG_UNUSED(par1); for (i = 0; i < par2; i++) { - nano_fiber_sem_take_wait(&nanoSem1); - nano_fiber_sem_give(&nanoSem2); - } + nano_fiber_sem_take_wait(&nanoSem1); + nano_fiber_sem_give(&nanoSem2); } +} /******************************************************************************* * * sema_fiber2 - semaphore test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void sema_fiber2( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void sema_fiber2(int par1, int par2) +{ int i; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - nano_fiber_sem_give(&nanoSem1); - nano_fiber_sem_take_wait(&nanoSem2); - (*pcounter)++; - } + nano_fiber_sem_give(&nanoSem1); + nano_fiber_sem_take_wait(&nanoSem2); + (*pcounter)++; } +} /******************************************************************************* * * sema_fiber3 - semaphore test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void sema_fiber3( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void sema_fiber3(int par1, int par2) +{ int i; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - nano_fiber_sem_give(&nanoSem1); - while (!nano_fiber_sem_take(&nanoSem2)) - fiber_yield(); - (*pcounter)++; - } + nano_fiber_sem_give(&nanoSem1); + while (!nano_fiber_sem_take(&nanoSem2)) { + fiber_yield(); + } + (*pcounter)++; } +} /******************************************************************************* @@ -136,16 +137,16 @@ void sema_fiber3( */ int sema_test(void) - { +{ uint32_t t; int i = 0; int return_value = 0; fprintf(output_file, sz_test_case_fmt, - "Semaphore channel - 'nano_fiber_sem_take_wait'"); + "Semaphore channel - 'nano_fiber_sem_take_wait'"); fprintf(output_file, sz_description, - "testing 'nano_sem_init','nano_fiber_sem_take_wait'," - " 'nano_fiber_sem_give' functions;"); + "testing 'nano_sem_init','nano_fiber_sem_take_wait'," + " 'nano_fiber_sem_give' functions;"); printf(sz_test_start_fmt, "'nano_fiber_sem_take_wait'"); sema_test_init(); @@ -153,18 +154,18 @@ int sema_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, sema_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, sema_fiber2, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); fprintf(output_file, sz_test_case_fmt, - "Semaphore channel - 'nano_fiber_sem_take'"); + "Semaphore channel - 'nano_fiber_sem_take'"); fprintf(output_file, sz_description, - "testing 'nano_sem_init','nano_fiber_sem_take', 'fiber_yield',\n"); + "testing 'nano_sem_init','nano_fiber_sem_take', 'fiber_yield',\n"); fprintf(output_file, "\t'nano_fiber_sem_give' functions;"); printf(sz_test_start_fmt, "'nano_fiber_sem_take'"); @@ -174,21 +175,21 @@ int sema_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, sema_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, sema_fiber3, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); fprintf(output_file, sz_test_case_fmt, - "Semaphore channel - 'nano_task_sem_take_wait'"); + "Semaphore channel - 'nano_task_sem_take_wait'"); fprintf(output_file, sz_description, - "testing 'nano_sem_init','nano_fiber_sem_take_wait'," - " 'nano_fiber_sem_give',\n"); + "testing 'nano_sem_init','nano_fiber_sem_take_wait'," + " 'nano_fiber_sem_give',\n"); fprintf(output_file, - "\t'nano_task_sem_give', 'nano_task_sem_take_wait' functions;"); + "\t'nano_task_sem_give', 'nano_task_sem_take_wait' functions;"); printf(sz_test_start_fmt, "'nano_task_sem_take_wait'"); sema_test_init(); @@ -196,10 +197,10 @@ int sema_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, sema_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); for (i = 0; i < NUMBER_OF_LOOPS; i++) { - nano_task_sem_give(&nanoSem1); - nano_task_sem_take_wait(&nanoSem2); + nano_task_sem_give(&nanoSem1); + nano_task_sem_take_wait(&nanoSem2); } t = TIME_STAMP_DELTA_GET(t); @@ -207,4 +208,4 @@ int sema_test(void) return_value += check_result(i, t); return return_value; - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/stack.c b/samples/nanokernel/benchmark/sys_kernel/src/stack.c index 4fa89d5db..ea13e2440 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/stack.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/stack.c @@ -48,104 +48,109 @@ uint32_t stack2[2]; */ void stack_test_init(void) - { +{ nano_stack_init(&nanoChannel1, stack1); nano_stack_init(&nanoChannel2, stack2); - } +} /******************************************************************************* * * stack_fiber1 - stack test context * + * @param par1 Ignored parameter. + * @param par2 Number of test loops. + * * RETURNS: N/A * * \NOMANUAL */ -void stack_fiber1( - int par1, /* ignored parameter */ - int par2 /* number of test loops */ - ) - { +void stack_fiber1(int par1, int par2) +{ int i; uint32_t data; ARG_UNUSED(par1); for (i = 0; i < par2 / 2; i++) { - data = nano_fiber_stack_pop_wait(&nanoChannel1); - if (data != 2 * i) - break; - data = 2 * i; - nano_fiber_stack_push(&nanoChannel2, data); - data = nano_fiber_stack_pop_wait(&nanoChannel1); - if (data != 2 * i + 1) - break; - data = 2 * i + 1; - nano_fiber_stack_push(&nanoChannel2, data); - } + data = nano_fiber_stack_pop_wait(&nanoChannel1); + if (data != 2 * i) { + break; + } + data = 2 * i; + nano_fiber_stack_push(&nanoChannel2, data); + data = nano_fiber_stack_pop_wait(&nanoChannel1); + if (data != 2 * i + 1) { + break; + } + data = 2 * i + 1; + nano_fiber_stack_push(&nanoChannel2, data); } +} /******************************************************************************* * * stack_fiber2 - stack test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void stack_fiber2( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void stack_fiber2(int par1, int par2) +{ int i; uint32_t data; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - data = i; - nano_fiber_stack_push(&nanoChannel1, data); - data = nano_fiber_stack_pop_wait(&nanoChannel2); - if (data != i) - break; - (*pcounter)++; - } + data = i; + nano_fiber_stack_push(&nanoChannel1, data); + data = nano_fiber_stack_pop_wait(&nanoChannel2); + if (data != i) { + break; + } + (*pcounter)++; } +} /******************************************************************************* * * stack_fiber2 - stack test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void stack_fiber3( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void stack_fiber3(int par1, int par2) +{ int i; uint32_t data; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - data = i; - nano_fiber_stack_push(&nanoChannel1, data); - data = 0xffffffff; - while (!nano_fiber_stack_pop(&nanoChannel2, &data)) - fiber_yield(); - if (data != i) - break; - (*pcounter)++; - } + data = i; + nano_fiber_stack_push(&nanoChannel1, data); + data = 0xffffffff; + while (!nano_fiber_stack_pop(&nanoChannel2, &data)) { + fiber_yield(); + } + if (data != i) { + break; + } + (*pcounter)++; } +} /******************************************************************************* @@ -158,17 +163,17 @@ void stack_fiber3( */ int stack_test(void) - { +{ uint32_t t; int i = 0; int return_value = 0; - /* test get wait & put fiber functions */ + /* test get wait & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "Stack channel - 'nano_fiber_stack_pop_wait'"); + "Stack channel - 'nano_fiber_stack_pop_wait'"); fprintf(output_file, sz_description, - "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," - " 'nano_fiber_stack_push' functions;"); + "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," + " 'nano_fiber_stack_push' functions;"); printf(sz_test_start_fmt, "'nano_fiber_stack_pop_wait'"); stack_test_init(); @@ -176,22 +181,22 @@ int stack_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, stack_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, stack_fiber2, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* test get/yield & put fiber functions */ + /* test get/yield & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "Stack channel - 'nano_fiber_stack_pop'"); + "Stack channel - 'nano_fiber_stack_pop'"); fprintf(output_file, sz_description, - "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," - " 'nano_fiber_stack_pop',\n"); + "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," + " 'nano_fiber_stack_pop',\n"); fprintf(output_file, - "\t'nano_fiber_stack_push', 'fiber_yield' functions;"); + "\t'nano_fiber_stack_push', 'fiber_yield' functions;"); printf(sz_test_start_fmt, "'nano_fiber_stack_pop'"); stack_test_init(); @@ -200,22 +205,22 @@ int stack_test(void) i = 0; task_fiber_start(fiber_stack1, STACK_SIZE, stack_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, stack_fiber3, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* test get wait & put fiber/task functions */ + /* test get wait & put fiber/task functions */ fprintf(output_file, sz_test_case_fmt, - "Stack channel - 'nano_task_stack_pop_wait'"); + "Stack channel - 'nano_task_stack_pop_wait'"); fprintf(output_file, sz_description, - "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," - " 'nano_fiber_stack_push',\n"); + "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," + " 'nano_fiber_stack_push',\n"); fprintf(output_file, - "\t'nano_task_stack_pop_wait', 'nano_task_stack_push' functions;"); + "\t'nano_task_stack_pop_wait', 'nano_task_stack_push' functions;"); printf(sz_test_start_fmt, "'nano_task_stack_pop_wait'"); stack_test_init(); @@ -223,20 +228,22 @@ int stack_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, stack_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) { - uint32_t data; - data = 2 * i; - nano_task_stack_push(&nanoChannel1, data); - data = 2 * i + 1; - nano_task_stack_push(&nanoChannel1, data); - - data = nano_task_stack_pop_wait(&nanoChannel2); - if (data != 2 * i + 1) - break; - data = nano_task_stack_pop_wait(&nanoChannel2); - if (data != 2 * i) - break; + uint32_t data; + data = 2 * i; + nano_task_stack_push(&nanoChannel1, data); + data = 2 * i + 1; + nano_task_stack_push(&nanoChannel1, data); + + data = nano_task_stack_pop_wait(&nanoChannel2); + if (data != 2 * i + 1) { + break; + } + data = nano_task_stack_pop_wait(&nanoChannel2); + if (data != 2 * i) { + break; + } } t = TIME_STAMP_DELTA_GET(t); @@ -244,4 +251,4 @@ int stack_test(void) return_value += check_result(i * 2, t); return return_value; - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c index aff016126..ffd7beea8 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c @@ -87,13 +87,13 @@ uint32_t tm_off; * \NOMANUAL */ void begin_test(void) - { - /* - Invoke bench_test_start in order to be able to use - tCheck static variable. - */ +{ + /* + * Invoke bench_test_start in order to be able to use + * tCheck static variable. + */ bench_test_start(); - } +} /******************************************************************************* * @@ -101,41 +101,41 @@ void begin_test(void) * * RETURNS: 1 if success and 0 on failure * + * @param i Number of tests. + * @param t Time in ticks for the whole test. + * * \NOMANUAL */ -int check_result( - int i, /* number of tests */ - uint32_t t /* time in ticks for the whole test */ - ) - { - /* - bench_test_end checks tCheck static variable. - bench_test_start modifies it - */ +int check_result(int i, uint32_t t) +{ + /* + * bench_test_end checks tCheck static variable. + * bench_test_start modifies it + */ if (bench_test_end() != 0) { - fprintf(output_file, sz_case_result_fmt, sz_fail); - fprintf(output_file, sz_case_details_fmt, - "timer tick happened. Results are inaccurate"); - fprintf(output_file, sz_case_end_fmt); - return 0; + fprintf(output_file, sz_case_result_fmt, sz_fail); + fprintf(output_file, sz_case_details_fmt, + "timer tick happened. Results are inaccurate"); + fprintf(output_file, sz_case_end_fmt); + return 0; } if (i != NUMBER_OF_LOOPS) { - fprintf(output_file, sz_case_result_fmt, sz_fail); - fprintf(output_file, sz_case_details_fmt, "loop counter = "); - fprintf(output_file, "%i !!!", i); - fprintf(output_file, sz_case_end_fmt); - return 0; + fprintf(output_file, sz_case_result_fmt, sz_fail); + fprintf(output_file, sz_case_details_fmt, "loop counter = "); + fprintf(output_file, "%i !!!", i); + fprintf(output_file, sz_case_end_fmt); + return 0; } fprintf(output_file, sz_case_result_fmt, sz_success); fprintf(output_file, sz_case_details_fmt, - "Average time for 1 iteration: "); + "Average time for 1 iteration: "); fprintf(output_file, sz_case_timing_fmt, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, NUMBER_OF_LOOPS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, NUMBER_OF_LOOPS)); fprintf(output_file, sz_case_end_fmt); return 1; - } +} /******************************************************************************* @@ -159,20 +159,20 @@ int kbhit(void) * * RETURNS: N/A * + * @param continuously Run test till the user presses the key. + * * \NOMANUAL */ -void init_output( - int *continuously /* run test till the user presses the key */ - ) - { +void init_output(int *continuously) +{ ARG_UNUSED(continuously); - /* - * send all printf and fprintf to console - */ + /* + * send all printf and fprintf to console + */ output_file = stdout; - } +} /******************************************************************************* @@ -185,8 +185,8 @@ void init_output( */ void output_close(void) - { - } +{ +} /******************************************************************************* * @@ -202,7 +202,7 @@ void SysKernelBench(void) #else void main(void) #endif - { +{ int continuously = 0; int test_result; @@ -210,31 +210,33 @@ void main(void) bench_test_init(); do { - fprintf(output_file, sz_module_title_fmt, "Nanokernel API test"); - fprintf(output_file, sz_kernel_ver_fmt, kernel_version_get()); - fprintf(output_file, - "\n\nEach test below are repeated %d times and the average\n" - "time for one iteration is displayed.", NUMBER_OF_LOOPS); - - test_result = 0; - - test_result += sema_test(); - test_result += lifo_test(); - test_result += fifo_test(); - test_result += stack_test(); - - if (test_result) { - /* sema, lifo, fifo, stack account for twelve tests in total */ - if (test_result == 12) - fprintf(output_file, sz_module_result_fmt, sz_success); - else - fprintf(output_file, sz_module_result_fmt, sz_partial); - } - else - fprintf(output_file, sz_module_result_fmt, sz_fail); - - } - while (continuously && !kbhit()); + fprintf(output_file, sz_module_title_fmt, "Nanokernel API test"); + fprintf(output_file, sz_kernel_ver_fmt, kernel_version_get()); + fprintf(output_file, + "\n\nEach test below are repeated %d times and the average\n" + "time for one iteration is displayed.", NUMBER_OF_LOOPS); + + test_result = 0; + + test_result += sema_test(); + test_result += lifo_test(); + test_result += fifo_test(); + test_result += stack_test(); + + if (test_result) { + /* sema, lifo, fifo, stack account for twelve tests in total */ + if (test_result == 12) { + fprintf(output_file, sz_module_result_fmt, sz_success); + } + else { + fprintf(output_file, sz_module_result_fmt, sz_partial); + } + } + else { + fprintf(output_file, sz_module_result_fmt, sz_fail); + } + + } while (continuously && !kbhit()); output_close(); - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h index 77431f162..051e53860 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h +++ b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h @@ -74,12 +74,12 @@ int stack_test(void); void begin_test(void); static inline uint32_t BENCH_START(void) - { +{ uint32_t et; begin_test(); et = TIME_STAMP_DELTA_GET(0); return et; - } +} #endif /* SYSKERNEK_H */ diff --git a/samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c b/samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c index 5ba4ed6d5..7744fbf66 100644 --- a/samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c +++ b/samples/nanokernel/test/test_arm_m3_irq_vector_table/src/main.c @@ -59,11 +59,11 @@ struct nano_sem sem[3]; */ void isr0(void) - { +{ printk("%s ran!\n", __FUNCTION__); nano_isr_sem_give(&sem[0]); _IntExit(); - } +} /******************************************************************************* * @@ -73,11 +73,11 @@ void isr0(void) */ void isr1(void) - { +{ printk("%s ran!\n", __FUNCTION__); nano_isr_sem_give(&sem[1]); _IntExit(); - } +} /******************************************************************************* * @@ -87,11 +87,11 @@ void isr1(void) */ void isr2(void) - { +{ printk("%s ran!\n", __FUNCTION__); nano_isr_sem_give(&sem[2]); _IntExit(); - } +} /******************************************************************************* * @@ -101,13 +101,13 @@ void isr2(void) */ void main(void) - { +{ TC_START("Test Cortex-M3 IRQ installed directly in vector table"); for (int ii = 0; ii < 3; ii++) { - irq_enable(ii); - irq_priority_set(ii, _EXC_IRQ_DEFAULT_PRIO); - nano_sem_init(&sem[ii]); + irq_enable(ii); + irq_priority_set(ii, _EXC_IRQ_DEFAULT_PRIO); + nano_sem_init(&sem[ii]); } int rv; @@ -115,11 +115,13 @@ void main(void) nano_task_sem_take(&sem[1]) || nano_task_sem_take(&sem[2]) ? TC_FAIL : TC_PASS; - if (TC_FAIL == rv) + if (TC_FAIL == rv) { goto get_out; + } - for (int ii = 0; ii < 3; ii++) + for (int ii = 0; ii < 3; ii++) { _NvicSwInterruptTrigger(ii); + } rv = nano_task_sem_take(&sem[0]) && nano_task_sem_take(&sem[1]) && @@ -128,7 +130,7 @@ void main(void) get_out: TC_END_RESULT(rv); TC_END_REPORT(rv); - } +} typedef void (*vth)(void); /* Vector Table Handler */ vth __irq_vector_table _irq_vector_table[CONFIG_NUM_IRQS] = { diff --git a/samples/nanokernel/test/test_context/src/context.c b/samples/nanokernel/test/test_context/src/context.c index d472703b7..b6f8fee4c 100644 --- a/samples/nanokernel/test/test_context/src/context.c +++ b/samples/nanokernel/test/test_context/src/context.c @@ -96,9 +96,8 @@ typedef struct { union { void *data; /* pointer to data to use or return */ int value; /* value to be passed or returned */ - }; - } -ISR_INFO; + }; +} ISR_INFO; typedef int (* disable_interrupt_func)(int); typedef void (* enable_interrupt_func)(int); @@ -139,18 +138,18 @@ void isr_handler(void *data) ARG_UNUSED(data); switch (isrInfo.command) { - case CTX_SELF_CMD: - isrInfo.data = (void *) context_self_get(); - break; + case CTX_SELF_CMD: + isrInfo.data = (void *) context_self_get(); + break; - case CTX_TYPE_CMD: - isrInfo.value = context_type_get(); - break; + case CTX_TYPE_CMD: + isrInfo.value = context_type_get(); + break; - default: - isrInfo.error = UNKNOWN_COMMAND; - break; - } + default: + isrInfo.error = UNKNOWN_COMMAND; + break; + } } /* Cortex-M3 does not implement connecting non-IRQ exception handlers */ @@ -220,19 +219,19 @@ int nano_cpu_idleTest(void) int tick; /* current tick count */ int i; /* loop variable */ - /* Align to a "tick boundary". */ + /* Align to a "tick boundary". */ tick = nano_tick_get_32(); while (tick == nano_tick_get_32()) { - } + } tick = nano_tick_get_32(); for (i = 0; i < 5; i++) { /* Repeat the test five times */ nano_cpu_idle(); tick++; if (nano_tick_get_32() != tick) { - return TC_FAIL; - } + return TC_FAIL; } + } return TC_PASS; } @@ -334,22 +333,22 @@ int nanoCpuDisableInterruptsTest(disable_interrupt_func disableRtn, int tick2; int imask; - /* Align to a "tick boundary" */ + /* Align to a "tick boundary" */ tick = nano_tick_get_32(); while (nano_tick_get_32() == tick) { - } + } tick++; while (nano_tick_get_32() == tick) { count++; - } + } - /* - * Inflate <count> so that when we loop later, many ticks should have - * elapsed during the loop. This later loop will not exactly match the - * previous loop, but it should be close enough in structure that when - * combined with the inflated count, many ticks will have passed. - */ + /* + * Inflate <count> so that when we loop later, many ticks should have + * elapsed during the loop. This later loop will not exactly match the + * previous loop, but it should be close enough in structure that when + * combined with the inflated count, many ticks will have passed. + */ count <<= 4; @@ -357,25 +356,25 @@ int nanoCpuDisableInterruptsTest(disable_interrupt_func disableRtn, tick = nano_tick_get_32(); for (i = 0; i < count; i++) { nano_tick_get_32(); - } + } tick2 = nano_tick_get_32(); - /* - * Re-enable interrupts before returning (for both success and failure - * cases). - */ + /* + * Re-enable interrupts before returning (for both success and failure + * cases). + */ enableRtn(imask); if (tick2 != tick) { return TC_FAIL; - } + } - /* Now repeat with interrupts unlocked. */ + /* Now repeat with interrupts unlocked. */ for (i = 0; i < count; i++) { nano_tick_get_32(); - } + } return (tick == nano_tick_get_32()) ? TC_FAIL : TC_PASS; } @@ -401,12 +400,12 @@ int nanoCtxTaskTest(void) isrInfo.error = 0; _trigger_isrHandler(); if ((isrInfo.error != 0) || (isrInfo.data != (void *) ctxId)) { - /* - * Either the ISR detected an error, or the ISR context ID does not - * match the interrupted task's context ID. - */ + /* + * Either the ISR detected an error, or the ISR context ID does not + * match the interrupted task's context ID. + */ return TC_FAIL; - } + } TC_PRINT("Testing context_type_get() from an ISR\n"); isrInfo.command = CTX_TYPE_CMD; @@ -414,12 +413,12 @@ int nanoCtxTaskTest(void) _trigger_isrHandler(); if ((isrInfo.error != 0) || (isrInfo.value != NANO_CTX_ISR)) { return TC_FAIL; - } + } TC_PRINT("Testing context_type_get() from a task\n"); if (context_type_get() != NANO_CTX_TASK) { return TC_FAIL; - } + } return TC_PASS; } @@ -449,19 +448,19 @@ int nanoCtxFiberTest(nano_context_id_t taskCtxId) if (ctxId == taskCtxId) { fiberDetectedError = 1; return TC_FAIL; - } + } isrInfo.command = CTX_SELF_CMD; isrInfo.error = 0; _trigger_isrHandler(); if ((isrInfo.error != 0) || (isrInfo.data != (void *) ctxId)) { - /* - * Either the ISR detected an error, or the ISR context ID does not - * match the interrupted fiber's context ID. - */ + /* + * Either the ISR detected an error, or the ISR context ID does not + * match the interrupted fiber's context ID. + */ fiberDetectedError = 2; return TC_FAIL; - } + } isrInfo.command = CTX_TYPE_CMD; isrInfo.error = 0; @@ -469,12 +468,12 @@ int nanoCtxFiberTest(nano_context_id_t taskCtxId) if ((isrInfo.error != 0) || (isrInfo.value != NANO_CTX_ISR)) { fiberDetectedError = 3; return TC_FAIL; - } + } if (context_type_get() != NANO_CTX_FIBER) { fiberDetectedError = 4; return TC_FAIL; - } + } return TC_PASS; } @@ -499,20 +498,20 @@ static void fiberHelper(int arg1, int arg2) ARG_UNUSED(arg1); ARG_UNUSED(arg2); - /* - * This fiber starts off at a higher priority than fiberEntry(). Thus, it - * should execute immediately. - */ + /* + * This fiber starts off at a higher priority than fiberEntry(). Thus, it + * should execute immediately. + */ fiberEvidence++; - /* Test that helper will yield to a fiber of equal priority */ + /* Test that helper will yield to a fiber of equal priority */ ctxId = context_self_get(); ctxId->prio++; /* Lower priority to that of fiberEntry() */ fiber_yield(); /* Yield to fiber of equal priority */ fiberEvidence++; - /* <fiberEvidence> should now be 2 */ + /* <fiberEvidence> should now be 2 */ } @@ -538,27 +537,27 @@ int fiber_yieldTest(void) { nano_context_id_t ctxId; - /* - * Start a fiber of higher priority. Note that since the new fiber is - * being started from a fiber, it will not automatically switch to the - * fiber as it would if done from a task. - */ + /* + * Start a fiber of higher priority. Note that since the new fiber is + * being started from a fiber, it will not automatically switch to the + * fiber as it would if done from a task. + */ ctxId = context_self_get(); fiberEvidence = 0; fiber_fiber_start(fiberStack2, FIBER_STACKSIZE, fiberHelper, - 0, 0, FIBER_PRIORITY - 1, 0); + 0, 0, FIBER_PRIORITY - 1, 0); if (fiberEvidence != 0) { /* ERROR! Helper spawned at higher */ fiberDetectedError = 10; /* priority ran prematurely. */ return TC_FAIL; - } + } - /* - * Test that the fiber will yield to the higher priority helper. - * <fiberEvidence> is still 0. - */ + /* + * Test that the fiber will yield to the higher priority helper. + * <fiberEvidence> is still 0. + */ fiber_yield(); @@ -566,18 +565,18 @@ int fiber_yieldTest(void) /* ERROR! Did not yield to higher */ fiberDetectedError = 11; /* priority fiber. */ return TC_FAIL; - } + } if (fiberEvidence > 1) { /* ERROR! Helper did not yield to */ fiberDetectedError = 12; /* equal priority fiber. */ return TC_FAIL; - } + } - /* - * Raise the priority of fiberEntry(). Calling fiber_yield() should - * not result in switching to the helper. - */ + /* + * Raise the priority of fiberEntry(). Calling fiber_yield() should + * not result in switching to the helper. + */ ctxId->prio--; fiber_yield(); @@ -586,12 +585,12 @@ int fiber_yieldTest(void) /* ERROR! Context switched to a lower */ fiberDetectedError = 13; /* priority fiber! */ return TC_FAIL; - } + } - /* - * Block on <wakeFiber>. This will allow the helper fiber to complete. - * The main task will wake this fiber. - */ + /* + * Block on <wakeFiber>. This will allow the helper fiber to complete. + * The main task will wake this fiber. + */ nano_fiber_sem_take_wait(&wakeFiber); @@ -622,15 +621,15 @@ static void fiberEntry(int taskCtxId, int arg1) rv = nanoCtxFiberTest((nano_context_id_t) taskCtxId); if (rv != TC_PASS) { return; - } + } - /* Allow the task to print any messages before the next test runs */ + /* Allow the task to print any messages before the next test runs */ nano_fiber_sem_take_wait(&wakeFiber); rv = fiber_yieldTest(); if (rv != TC_PASS) { return; - } + } } /******************************************************************************* @@ -652,101 +651,101 @@ void main(void) rv = initNanoObjects(); if (rv != TC_PASS) { goto doneTests; - } + } TC_PRINT("Testing nano_cpu_idle()\n"); rv = nano_cpu_idleTest(); if (rv != TC_PASS) { goto doneTests; - } + } TC_PRINT("Testing interrupt locking and unlocking\n"); rv = nanoCpuDisableInterruptsTest(irq_lockWrapper, - irq_unlockWrapper, -1); + irq_unlockWrapper, -1); if (rv != TC_PASS) { goto doneTests; - } + } TC_PRINT("Testing inline interrupt locking and unlocking\n"); rv = nanoCpuDisableInterruptsTest(irq_lock_inlineWrapper, - irq_unlock_inlineWrapper, -1); + irq_unlock_inlineWrapper, -1); if (rv != TC_PASS) { goto doneTests; - } + } /* * The Cortex-M3/M4 use the SYSTICK exception for the system timer, which is * not considered an IRQ by the irq_enable/Disable APIs. */ #if !defined(CONFIG_CPU_CORTEXM3) - /* - * !!! TAKE NOTE !!! - * Disable interrupts coming from the timer. In the pcPentium case, this - * is IRQ0 (see board.h for definition of PIT_INT_LVL). Other BSPs may - * not be using the i8253 timer on IRQ0 and so a different IRQ value may - * be necessary when porting to another BSP. - */ + /* + * !!! TAKE NOTE !!! + * Disable interrupts coming from the timer. In the pcPentium case, this + * is IRQ0 (see board.h for definition of PIT_INT_LVL). Other BSPs may + * not be using the i8253 timer on IRQ0 and so a different IRQ value may + * be necessary when porting to another BSP. + */ TC_PRINT("Testing irq_disable() and irq_enable()\n"); rv = nanoCpuDisableInterruptsTest(irq_disableWrapper, - irq_enableWrapper, TICK_IRQ); + irq_enableWrapper, TICK_IRQ); if (rv != TC_PASS) { goto doneTests; - } + } #endif rv = nanoCtxTaskTest(); if (rv != TC_PASS) { goto doneTests; - } + } TC_PRINT("Spawning a fiber from a task\n"); fiberEvidence = 0; task_fiber_start(fiberStack1, FIBER_STACKSIZE, fiberEntry, - (int) context_self_get(), 0, FIBER_PRIORITY, 0); + (int) context_self_get(), 0, FIBER_PRIORITY, 0); if (fiberEvidence != 1) { - rv = TC_FAIL; + rv = TC_FAIL; TC_ERROR(" - fiber did not execute as expected!\n"); goto doneTests; - } + } - /* The fiber ran, now wake it so it can test context_self_get and context_type_get */ + /* The fiber ran, now wake it so it can test context_self_get and context_type_get */ TC_PRINT("Fiber to test context_self_get() and context_type_get\n"); nano_task_sem_give(&wakeFiber); if (fiberDetectedError != 0) { - rv = TC_FAIL; + rv = TC_FAIL; TC_ERROR(" - failure detected in fiber; fiberDetectedError = %d\n", - fiberDetectedError); + fiberDetectedError); goto doneTests; - } + } TC_PRINT("Fiber to test fiber_yield()\n"); nano_task_sem_give(&wakeFiber); if (fiberDetectedError != 0) { - rv = TC_FAIL; + rv = TC_FAIL; TC_ERROR(" - failure detected in fiber; fiberDetectedError = %d\n", - fiberDetectedError); + fiberDetectedError); goto doneTests; - } + } nano_task_sem_give(&wakeFiber); /* Cortex-M3 does not implement connecting non-IRQ exception handlers */ #if !defined(CONFIG_CPU_CORTEXM3) - /* - * Test divide by zero exception handler. - * - * WARNING: This code has been very carefully crafted so that it does - * what it is supposed to. Both "error" and "excHandlerExecuted" must be - * volatile to prevent the compiler from issuing a "divide by zero" - * warning (since otherwise in knows "excHandlerExecuted" is zero), - * and to ensure the compiler issues the two byte "idiv" instruction - * that the exception handler is designed to deal with. - */ + /* + * Test divide by zero exception handler. + * + * WARNING: This code has been very carefully crafted so that it does + * what it is supposed to. Both "error" and "excHandlerExecuted" must be + * volatile to prevent the compiler from issuing a "divide by zero" + * warning (since otherwise in knows "excHandlerExecuted" is zero), + * and to ensure the compiler issues the two byte "idiv" instruction + * that the exception handler is designed to deal with. + */ volatile int error; /* used to create a divide by zero error */ TC_PRINT("Verifying exception handler installed\n"); diff --git a/samples/nanokernel/test/test_fifo/src/fifo.c b/samples/nanokernel/test/test_fifo/src/fifo.c index a7da0cc5d..a53a7daa0 100644 --- a/samples/nanokernel/test/test_fifo/src/fifo.c +++ b/samples/nanokernel/test/test_fifo/src/fifo.c @@ -87,7 +87,7 @@ in ISR context. typedef struct { struct nano_fifo *channel; /* FIFO channel */ void *data; /* pointer to data to add */ - } ISR_FIFO_INFO; +} ISR_FIFO_INFO; /* globals */ @@ -199,58 +199,58 @@ void fiber1(void) void *pData; /* pointer to FIFO object get from the queue */ int count = 0; /* counter */ - /* Wait for fiber1 to be activated. */ + /* Wait for fiber1 to be activated. */ nano_fiber_sem_take_wait(&nanoSemObj1); - /* Wait for data to be added to <nanoFifoObj> by task */ + /* Wait for data to be added to <nanoFifoObj> by task */ pData = nano_fiber_fifo_get_wait(&nanoFifoObj); if (pData != pPutList1[0]) { TC_ERROR("fiber1 (1) - expected 0x%x, got 0x%x\n", - pPutList1[0], pData); + pPutList1[0], pData); retCode = TC_FAIL; return; - } + } - /* Wait for data to be added to <nanoFifoObj2> by fiber3 */ + /* Wait for data to be added to <nanoFifoObj2> by fiber3 */ pData = nano_fiber_fifo_get_wait(&nanoFifoObj2); if (pData != pPutList2[0]) { TC_ERROR("fiber1 (2) - expected 0x%x, got 0x%x\n", - pPutList2[0], pData); + pPutList2[0], pData); retCode = TC_FAIL; return; - } + } nano_fiber_sem_take_wait(&nanoSemObj1); /* Wait for fiber1 to be reactivated */ TC_PRINT("Test Fiber FIFO Get\n\n"); - /* Get all FIFOs */ + /* Get all FIFOs */ while ((pData = nano_fiber_fifo_get(&nanoFifoObj)) != NULL) { TC_PRINT("FIBER FIFO Get: count = %d, ptr is %p\n", count, pData); - if((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) { - TCERR1(count); - retCode = TC_FAIL; - return; - } - count++; + if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) { + TCERR1(count); + retCode = TC_FAIL; + return; } + count++; + } TC_END_RESULT(retCode); PRINT_LINE; - /* - * Entries in the FIFO queue have to be unique. - * Put data. - */ + /* + * Entries in the FIFO queue have to be unique. + * Put data. + */ TC_PRINT("Test Fiber FIFO Put\n"); TC_PRINT("\nFIBER FIFO Put Order: "); for (int i=0; i<NUM_FIFO_ELEMENT; i++) { nano_fiber_fifo_put(&nanoFifoObj, pPutList2[i]); TC_PRINT(" %p,", pPutList2[i]); - } + } TC_PRINT("\n"); PRINT_LINE; - /* Give semaphore to allow the main task to run */ + /* Give semaphore to allow the main task to run */ nano_fiber_sem_give(&nanoSemObjTask); } /* fiber1 */ @@ -274,12 +274,12 @@ void testFiberFifoGetW(void) TC_PRINT("Test Fiber FIFO Get Wait Interfaces\n\n"); pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2); TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData); - /* Verify results */ + /* Verify results */ if (pGetData != pMyFifoData1) { retCode = TC_FAIL; TCERR2; return; - } + } pPutData = pMyFifoData2; TC_PRINT("FIBER FIFO Put to queue1: %p\n", pPutData); @@ -287,12 +287,12 @@ void testFiberFifoGetW(void) pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2); TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData); - /* Verify results */ + /* Verify results */ if (pGetData != pMyFifoData3) { retCode = TC_FAIL; TCERR2; return; - } + } pPutData = pMyFifoData4; TC_PRINT("FIBER FIFO Put to queue1: %p\n", pPutData); @@ -317,42 +317,42 @@ void testFiberFifoGetW(void) void testIsrFifoFromFiber(void) { - void *pGetData; /* pointer to FIFO object get from the queue */ + void *pGetData; /* pointer to FIFO object get from the queue */ - TC_PRINT("Test ISR FIFO (invoked from Fiber)\n\n"); + TC_PRINT("Test ISR FIFO (invoked from Fiber)\n\n"); - /* This is data pushed by function testFiberFifoGetW */ - _trigger_nano_isr_fifo_get(); - pGetData = isrFifoInfo.data; + /* This is data pushed by function testFiberFifoGetW */ + _trigger_nano_isr_fifo_get(); + pGetData = isrFifoInfo.data; - TC_PRINT("ISR FIFO Get from queue1: %p\n", pGetData); - if (isrFifoInfo.data != pMyFifoData4) { - retCode = TC_FAIL; - TCERR2; - return; - } + TC_PRINT("ISR FIFO Get from queue1: %p\n", pGetData); + if (isrFifoInfo.data != pMyFifoData4) { + retCode = TC_FAIL; + TCERR2; + return; + } - /* Verify that the queue is empty */ - _trigger_nano_isr_fifo_get(); - pGetData = isrFifoInfo.data; + /* Verify that the queue is empty */ + _trigger_nano_isr_fifo_get(); + pGetData = isrFifoInfo.data; - if (pGetData != NULL) { - TC_PRINT("Get from queue1: %p\n", pGetData); - retCode = TC_FAIL; - TCERR3; - return; - } + if (pGetData != NULL) { + TC_PRINT("Get from queue1: %p\n", pGetData); + retCode = TC_FAIL; + TCERR3; + return; + } - /* Put more item into queue */ - TC_PRINT("\nISR FIFO (running in fiber context) Put Order: \n"); - for (int i=0; i<NUM_FIFO_ELEMENT; i++) { - isrFifoInfo.data = pPutList1[i]; - TC_PRINT(" %p,", pPutList1[i]); - _trigger_nano_isr_fifo_put(); - } - TC_PRINT("\n"); + /* Put more item into queue */ + TC_PRINT("\nISR FIFO (running in fiber context) Put Order: \n"); + for (int i=0; i<NUM_FIFO_ELEMENT; i++) { + isrFifoInfo.data = pPutList1[i]; + TC_PRINT(" %p,", pPutList1[i]); + _trigger_nano_isr_fifo_put(); + } + TC_PRINT("\n"); - TC_END_RESULT(retCode); + TC_END_RESULT(retCode); } /* testIsrFifoFromFiber */ @@ -371,54 +371,54 @@ void testIsrFifoFromFiber(void) void testIsrFifoFromTask(void) { - void *pGetData; /* pointer to FIFO object get from the queue */ - void *pPutData; /* pointer to FIFO object put to queue */ - int count = 0; /* counter */ - - TC_PRINT("Test ISR FIFO (invoked from Task)\n\n"); + void *pGetData; /* pointer to FIFO object get from the queue */ + void *pPutData; /* pointer to FIFO object put to queue */ + int count = 0; /* counter */ + + TC_PRINT("Test ISR FIFO (invoked from Task)\n\n"); + + /* This is data pushed by function testIsrFifoFromFiber + * Get all FIFOs + */ + _trigger_nano_isr_fifo_get(); + pGetData = isrFifoInfo.data; + + while (pGetData != NULL) { + TC_PRINT("Get from queue1: count = %d, ptr is %p\n", count, pGetData); + if ((count >= NUM_FIFO_ELEMENT) || (pGetData != pPutList1[count])) { + TCERR1(count); + retCode = TC_FAIL; + return; + } - /* This is data pushed by function testIsrFifoFromFiber - * Get all FIFOs - */ + /* Get the next element */ _trigger_nano_isr_fifo_get(); pGetData = isrFifoInfo.data; - - while (pGetData != NULL) { - TC_PRINT("Get from queue1: count = %d, ptr is %p\n", count, pGetData); - if ((count >= NUM_FIFO_ELEMENT) || (pGetData != pPutList1[count])) { - TCERR1(count); - retCode = TC_FAIL; - return; - } - - /* Get the next element */ - _trigger_nano_isr_fifo_get(); - pGetData = isrFifoInfo.data; - count++; - } /* while */ + count++; + } /* while */ - /* Put data into queue and get it again */ - pPutData = pPutList2[3]; + /* Put data into queue and get it again */ + pPutData = pPutList2[3]; - isrFifoInfo.data = pPutData; - _trigger_nano_isr_fifo_put(); - isrFifoInfo.data = NULL; /* force data to a new value */ - /* Get data from queue */ - _trigger_nano_isr_fifo_get(); - pGetData = isrFifoInfo.data; - /* Verify data */ - if (pGetData != pPutData) { - retCode = TC_FAIL; - TCERR2; - return; - } - else { + isrFifoInfo.data = pPutData; + _trigger_nano_isr_fifo_put(); + isrFifoInfo.data = NULL; /* force data to a new value */ + /* Get data from queue */ + _trigger_nano_isr_fifo_get(); + pGetData = isrFifoInfo.data; + /* Verify data */ + if (pGetData != pPutData) { + retCode = TC_FAIL; + TCERR2; + return; + } + else { TC_PRINT("\nTest ISR FIFO (invoked from Task) - put %p and get back %p\n", - pPutData, pGetData); - } + pPutData, pGetData); + } - TC_END_RESULT(retCode); + TC_END_RESULT(retCode); } /* testIsrFifoFromTask */ /******************************************************************************* @@ -432,40 +432,40 @@ void fiber2(void) { void *pData; /* pointer to FIFO object from the queue */ - /* Wait for fiber2 to be activated */ + /* Wait for fiber2 to be activated */ nano_fiber_sem_take_wait(&nanoSemObj2); - /* Wait for data to be added to <nanoFifoObj> */ + /* Wait for data to be added to <nanoFifoObj> */ pData = nano_fiber_fifo_get_wait(&nanoFifoObj); if (pData != pPutList1[1]) { TC_ERROR("fiber2 (1) - expected 0x%x, got 0x%x\n", - pPutList1[1], pData); + pPutList1[1], pData); retCode = TC_FAIL; return; - } + } - /* Wait for data to be added to <nanoFifoObj2> by fiber3 */ + /* Wait for data to be added to <nanoFifoObj2> by fiber3 */ pData = nano_fiber_fifo_get_wait(&nanoFifoObj2); if (pData != pPutList2[1]) { TC_ERROR("fiber2 (2) - expected 0x%x, got 0x%x\n", - pPutList2[1], pData); + pPutList2[1], pData); retCode = TC_FAIL; return; - } + } nano_fiber_sem_take_wait(&nanoSemObj2); /* Wait for fiber2 to be reactivated */ - /* Fiber #2 has been reactivated by main task */ + /* Fiber #2 has been reactivated by main task */ for (int i = 0; i < 4; i++) { pData = nano_fiber_fifo_get_wait(&nanoFifoObj); if (pData != pPutList1[i]) { - TC_ERROR("fiber2 (3) - iteration %d expected 0x%x, got 0x%x\n", - i, pPutList1[i], pData); - retCode = TC_FAIL; - return; - } + TC_ERROR("fiber2 (3) - iteration %d expected 0x%x, got 0x%x\n", + i, pPutList1[i], pData); + retCode = TC_FAIL; + return; } + } nano_fiber_sem_give(&nanoSemObjTask); /* Wake main task */ nano_fiber_sem_take_wait(&nanoSemObj2); /* Wait for fiber2 to be reactivated */ @@ -488,37 +488,37 @@ void fiber3(void) { void *pData; - /* Wait for fiber3 to be activated */ + /* Wait for fiber3 to be activated */ nano_fiber_sem_take_wait(&nanoSemObj3); - /* Put two items onto <nanoFifoObj2> to unblock fibers #1 and #2. */ + /* Put two items onto <nanoFifoObj2> to unblock fibers #1 and #2. */ nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[0]); /* Wake fiber1 */ nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[1]); /* Wake fiber2 */ - /* Wait for fiber3 to be re-activated */ + /* Wait for fiber3 to be re-activated */ nano_fiber_sem_take_wait(&nanoSemObj3); - /* Immediately get the data from <nanoFifoObj2>. */ + /* Immediately get the data from <nanoFifoObj2>. */ pData = nano_fiber_fifo_get_wait(&nanoFifoObj2); if (pData != pPutList2[0]) { retCode = TC_FAIL; TC_ERROR("fiber3 (1) - got 0x%x from <nanoFifoObj2>, expected 0x%x\n", - pData, pPutList2[0]); - } + pData, pPutList2[0]); + } - /* Put three items onto the FIFO for the task to get */ + /* Put three items onto the FIFO for the task to get */ nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[0]); nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[1]); nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[2]); - /* Sleep for 2 seconds */ + /* Sleep for 2 seconds */ nano_fiber_timer_start(&timer, SECONDS(2)); nano_fiber_timer_wait(&timer); - /* Put final item onto the FIFO for the task to get */ + /* Put final item onto the FIFO for the task to get */ nano_fiber_fifo_put(&nanoFifoObj2, pPutList2[3]); - /* Wait for fiber3 to be re-activated (not expected to occur) */ + /* Wait for fiber3 to be re-activated (not expected to occur) */ nano_fiber_sem_take_wait(&nanoSemObj3); } @@ -544,17 +544,17 @@ void testTaskFifoGetW(void) TC_PRINT("TASK FIFO Put to queue2: %p\n", pPutData); nano_task_fifo_put(&nanoFifoObj2, pPutData); - /* Activate fiber2 */ + /* Activate fiber2 */ nano_task_sem_give(&nanoSemObj2); pGetData = nano_task_fifo_get_wait(&nanoFifoObj); TC_PRINT("TASK FIFO Get from queue1: %p\n", pGetData); - /* Verify results */ + /* Verify results */ if (pGetData != pMyFifoData2) { retCode = TC_FAIL; TCERR2; return; - } + } pPutData = pMyFifoData3; TC_PRINT("TASK FIFO Put to queue2: %p\n", pPutData); @@ -608,41 +608,41 @@ void main(void) TC_START("Test Nanokernel FIFO"); - /* Initialize the FIFO queues and semaphore */ + /* Initialize the FIFO queues and semaphore */ initNanoObjects(); - /* Create and start the three (3) fibers. */ + /* Create and start the three (3) fibers. */ task_fiber_start(&fiberStack1[0], STACKSIZE, (nano_fiber_entry_t) fiber1, - 0, 0, 7, 0); + 0, 0, 7, 0); task_fiber_start(&fiberStack2[0], STACKSIZE, (nano_fiber_entry_t) fiber2, - 0, 0, 7, 0); + 0, 0, 7, 0); task_fiber_start(&fiberStack3[0], STACKSIZE, (nano_fiber_entry_t) fiber3, - 0, 0, 7, 0); + 0, 0, 7, 0); - /* - * The three fibers have each blocked on a different semaphore. Giving - * the semaphore nanoSemObjX will unblock fiberX (where X = {1, 2, 3}). - * - * Activate fibers #1 and #2. They will each block on nanoFifoObj. - */ + /* + * The three fibers have each blocked on a different semaphore. Giving + * the semaphore nanoSemObjX will unblock fiberX (where X = {1, 2, 3}). + * + * Activate fibers #1 and #2. They will each block on nanoFifoObj. + */ nano_task_sem_give(&nanoSemObj1); nano_task_sem_give(&nanoSemObj2); - /* Put two items into <nanoFifoObj> to unblock fibers #1 and #2. */ + /* Put two items into <nanoFifoObj> to unblock fibers #1 and #2. */ nano_task_fifo_put(&nanoFifoObj, pPutList1[0]); /* Wake fiber1 */ nano_task_fifo_put(&nanoFifoObj, pPutList1[1]); /* Wake fiber2 */ - /* Activate fiber #3 */ + /* Activate fiber #3 */ nano_task_sem_give(&nanoSemObj3); - /* - * All three fibers should be blocked on their semaphores. Put data into - * <nanoFifoObj2>. Fiber #3 will read it after it is reactivated. - */ + /* + * All three fibers should be blocked on their semaphores. Put data into + * <nanoFifoObj2>. Fiber #3 will read it after it is reactivated. + */ nano_task_fifo_put(&nanoFifoObj2, pPutList2[0]); nano_task_sem_give(&nanoSemObj3); /* Reactivate fiber #3 */ @@ -650,37 +650,37 @@ void main(void) for (int i = 0; i < 4; i++) { pData = nano_task_fifo_get_wait(&nanoFifoObj2); if (pData != pPutList2[i]) { - TC_ERROR("nano_task_fifo_get_wait() expected 0x%x, got 0x%x\n", - pPutList2[i], pData); - goto exit; - } + TC_ERROR("nano_task_fifo_get_wait() expected 0x%x, got 0x%x\n", + pPutList2[i], pData); + goto exit; } + } - /* Add items to <nanoFifoObj> for fiber #2 */ + /* Add items to <nanoFifoObj> for fiber #2 */ for (int i = 0; i < 4; i++) { nano_task_fifo_put(&nanoFifoObj, pPutList1[i]); - } + } nano_task_sem_give(&nanoSemObj2); /* Activate fiber #2 */ - /* Wait for fibers to finish */ + /* Wait for fibers to finish */ nano_task_sem_take_wait(&nanoSemObjTask); if (retCode == TC_FAIL) { goto exit; - } + } - /* - * Entries in the FIFO queue have to be unique. - * Put data to queue. - */ + /* + * Entries in the FIFO queue have to be unique. + * Put data to queue. + */ TC_PRINT("Test Task FIFO Put\n"); TC_PRINT("\nTASK FIFO Put Order: "); for (int i=0; i<NUM_FIFO_ELEMENT; i++) { nano_task_fifo_put(&nanoFifoObj, pPutList1[i]); TC_PRINT(" %p,", pPutList1[i]); - } + } TC_PRINT("\n"); PRINT_LINE; @@ -689,28 +689,28 @@ void main(void) if (retCode == TC_FAIL) { goto exit; - } + } - /* - * Wait for fiber1 to complete execution. (Using a semaphore gives - * the fiber the freedom to do blocking-type operations if it wants to.) - */ + /* + * Wait for fiber1 to complete execution. (Using a semaphore gives + * the fiber the freedom to do blocking-type operations if it wants to.) + */ nano_task_sem_take_wait(&nanoSemObjTask); TC_PRINT("Test Task FIFO Get\n"); - /* Get all FIFOs */ + /* Get all FIFOs */ while ((pData = nano_task_fifo_get(&nanoFifoObj)) != NULL) { TC_PRINT("TASK FIFO Get: count = %d, ptr is %p\n", count, pData); if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList2[count])) { - TCERR1(count); - retCode = TC_FAIL; - goto exit; - } - count++; + TCERR1(count); + retCode = TC_FAIL; + goto exit; } + count++; + } - /* Test FIFO Get Wait interfaces*/ + /* Test FIFO Get Wait interfaces*/ testTaskFifoGetW(); PRINT_LINE; diff --git a/samples/nanokernel/test/test_lifo/src/lifo.c b/samples/nanokernel/test/test_lifo/src/lifo.c index 1a4919538..92bc49458 100644 --- a/samples/nanokernel/test/test_lifo/src/lifo.c +++ b/samples/nanokernel/test/test_lifo/src/lifo.c @@ -73,12 +73,12 @@ These scenarios will be tested using a combinations of tasks, fibers and ISRs. typedef struct { struct nano_lifo *channel; /* LIFO channel */ void *data; /* pointer to data to add */ - } ISR_LIFO_INFO; +} ISR_LIFO_INFO; typedef struct { uint32_t link; /* 32-bit word for LIFO to use as a link */ uint32_t data; /* miscellaneous data put on LIFO (not important) */ - } LIFO_ITEM; +} LIFO_ITEM; /* locals */ @@ -160,10 +160,10 @@ int fiberLifoWaitTest(void) { void *data; /* ptr to data retrieved from LIFO */ - /* - * The LIFO is empty; wait for an item to be added to the LIFO - * from the task. - */ + /* + * The LIFO is empty; wait for an item to be added to the LIFO + * from the task. + */ TC_PRINT("Fiber waiting on an empty LIFO\n"); nano_fiber_sem_give(&taskWaitSem); @@ -171,35 +171,35 @@ int fiberLifoWaitTest(void) if (data != &lifoItem[0]) { fiberDetectedFailure = 1; return -1; - } + } nano_fiber_sem_take_wait(&fiberWaitSem); data = nano_fiber_lifo_get_wait(&lifoChannel); if (data != &lifoItem[2]) { fiberDetectedFailure = 1; return -1; - } + } - /* - * Give the task some time to check the results. Ideally, this would - * be waiting for a semaphore instead of a using a delay, but if the - * main task wakes the fiber before it blocks on the LIFO, the fiber - * will add the item to the LIFO too soon. Obviously, a semaphore could - * not be given if the task is blocked on the LIFO; hence the delay. - */ + /* + * Give the task some time to check the results. Ideally, this would + * be waiting for a semaphore instead of a using a delay, but if the + * main task wakes the fiber before it blocks on the LIFO, the fiber + * will add the item to the LIFO too soon. Obviously, a semaphore could + * not be given if the task is blocked on the LIFO; hence the delay. + */ nano_fiber_timer_start(&timer, SECONDS(2)); nano_fiber_timer_wait(&timer); - /* The task is waiting on an empty LIFO. Wake it up. */ + /* The task is waiting on an empty LIFO. Wake it up. */ nano_fiber_lifo_put(&lifoChannel, &lifoItem[3]); nano_fiber_lifo_put(&lifoChannel, &lifoItem[1]); - /* - * Wait for the task to check the results. If the results pass, then the - * the task will wake the fiber. If the results do not pass, then the - * fiber will wait forever. - */ + /* + * Wait for the task to check the results. If the results pass, then the + * the task will wake the fiber. If the results do not pass, then the + * fiber will wait forever. + */ nano_fiber_sem_take_wait(&fiberWaitSem); @@ -220,62 +220,62 @@ int fiberLifoNonWaitTest(void) { void *data; /* pointer to data retrieved from LIFO */ - /* The LIFO has two items in it; retrieve them both */ + /* The LIFO has two items in it; retrieve them both */ data = nano_fiber_lifo_get(&lifoChannel); if (data != (void *) &lifoItem[3]) { goto errorReturn; - } + } data = nano_fiber_lifo_get(&lifoChannel); if (data != (void *) &lifoItem[2]) { goto errorReturn; - } + } - /* LIFO should be empty--verify. */ + /* LIFO should be empty--verify. */ data = nano_fiber_lifo_get(&lifoChannel); if (data != NULL) { goto errorReturn; - } + } - /* - * The LIFO is now empty. Add two items to the LIFO and then wait - * for the semaphore so that the task can retrieve them. - */ + /* + * The LIFO is now empty. Add two items to the LIFO and then wait + * for the semaphore so that the task can retrieve them. + */ TC_PRINT("Task to get LIFO items without waiting\n"); nano_fiber_lifo_put(&lifoChannel, &lifoItem[0]); nano_fiber_lifo_put(&lifoChannel, &lifoItem[1]); nano_fiber_sem_give(&taskWaitSem); /* Wake the task (if blocked) */ - /* - * Wait for the task to get the items and then trigger an ISR to populate - * the LIFO. - */ + /* + * Wait for the task to get the items and then trigger an ISR to populate + * the LIFO. + */ nano_fiber_sem_take_wait(&fiberWaitSem); - /* - * The task retrieved the two items from the LIFO and then triggered - * two interrupts to add two other items to the LIFO. The fiber will - * now trigger two interrupts to read the two items. - */ + /* + * The task retrieved the two items from the LIFO and then triggered + * two interrupts to add two other items to the LIFO. The fiber will + * now trigger two interrupts to read the two items. + */ _trigger_nano_isr_lifo_get(); if (isrLifoInfo.data != &lifoItem[1]) { goto errorReturn; - } + } _trigger_nano_isr_lifo_get(); if (isrLifoInfo.data != &lifoItem[3]) { goto errorReturn; - } + } - /* The LIFO should now be empty--verify */ + /* The LIFO should now be empty--verify */ _trigger_nano_isr_lifo_get(); if (isrLifoInfo.data != NULL) { goto errorReturn; - } + } return 0; @@ -308,7 +308,7 @@ static void fiberEntry(int arg1, int arg2) if (rv == 0) { fiberLifoNonWaitTest(); - } + } } @@ -327,45 +327,45 @@ int taskLifoWaitTest(void) { void *data; /* ptr to data retrieved from LIFO */ - /* Wait on <taskWaitSem> in case fiber's print message blocked */ + /* Wait on <taskWaitSem> in case fiber's print message blocked */ nano_fiber_sem_take_wait(&taskWaitSem); - /* The fiber is waiting on the LIFO. Wake it. */ + /* The fiber is waiting on the LIFO. Wake it. */ nano_task_lifo_put(&lifoChannel, &lifoItem[0]); - /* - * The fiber ran, but is now blocked on the semaphore. Add an item to the - * LIFO before giving the semaphore that wakes the fiber so that we can - * cover the path of nano_fiber_lifo_get_wait() not waiting on the LIFO. - */ + /* + * The fiber ran, but is now blocked on the semaphore. Add an item to the + * LIFO before giving the semaphore that wakes the fiber so that we can + * cover the path of nano_fiber_lifo_get_wait() not waiting on the LIFO. + */ nano_task_lifo_put(&lifoChannel, &lifoItem[2]); nano_task_sem_give(&fiberWaitSem); - /* Check that the fiber got the correct item (lifoItem[0]) */ + /* Check that the fiber got the correct item (lifoItem[0]) */ if (fiberDetectedFailure) { TC_ERROR(" *** nano_task_lifo_put()/nano_fiber_lifo_get_wait() failure\n"); return TC_FAIL; - } + } - /* The LIFO is empty. This time the task will wait for the item. */ + /* The LIFO is empty. This time the task will wait for the item. */ TC_PRINT("Task waiting on an empty LIFO\n"); data = nano_task_lifo_get_wait(&lifoChannel); if (data != (void *) &lifoItem[1]) { TC_ERROR(" *** nano_task_lifo_get_wait()/nano_fiber_lifo_put() failure\n"); return TC_FAIL; - } + } data = nano_task_lifo_get_wait(&lifoChannel); if (data != (void *) &lifoItem[3]) { TC_ERROR(" *** nano_task_lifo_get_wait()/nano_fiber_lifo_put() failure\n"); return TC_FAIL; - } + } - /* Waiting on an empty LIFO passed for both fiber and task. */ + /* Waiting on an empty LIFO passed for both fiber and task. */ return TC_PASS; } @@ -384,51 +384,51 @@ int taskLifoNonWaitTest(void) { void *data; /* ptr to data retrieved from LIFO */ - /* - * The fiber is presently waiting for <fiberWaitSem>. Populate the LIFO - * before waking the fiber. - */ + /* + * The fiber is presently waiting for <fiberWaitSem>. Populate the LIFO + * before waking the fiber. + */ TC_PRINT("Fiber to get LIFO items without waiting\n"); nano_task_lifo_put(&lifoChannel, &lifoItem[2]); nano_task_lifo_put(&lifoChannel, &lifoItem[3]); nano_task_sem_give(&fiberWaitSem); /* Wake the fiber */ - /* Check that fiber received the items correctly */ + /* Check that fiber received the items correctly */ if (fiberDetectedFailure) { TC_ERROR(" *** nano_task_lifo_put()/nano_fiber_lifo_get() failure\n"); return TC_FAIL; - } + } - /* Wait for the fiber to be ready */ + /* Wait for the fiber to be ready */ nano_task_sem_take_wait(&taskWaitSem); data = nano_task_lifo_get(&lifoChannel); if (data != (void *) &lifoItem[1]) { TC_ERROR(" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n"); return TC_FAIL; - } + } data = nano_task_lifo_get(&lifoChannel); if (data != (void *) &lifoItem[0]) { TC_ERROR(" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n"); return TC_FAIL; - } + } data = nano_task_lifo_get(&lifoChannel); if (data != NULL) { TC_ERROR(" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n"); return TC_FAIL; - } + } - /* - * Software interrupts have been configured so that when invoked, - * the ISR will add an item to the LIFO. The fiber (when unblocked) - * trigger software interrupts to get the items from the LIFO from - * within an ISR. - * - * Populate the LIFO. - */ + /* + * Software interrupts have been configured so that when invoked, + * the ISR will add an item to the LIFO. The fiber (when unblocked) + * trigger software interrupts to get the items from the LIFO from + * within an ISR. + * + * Populate the LIFO. + */ TC_PRINT("ISR to get LIFO items without waiting\n"); isrLifoInfo.data = &lifoItem[3]; @@ -443,7 +443,7 @@ int taskLifoNonWaitTest(void) if (fiberDetectedFailure) { TC_ERROR(" *** nano_isr_lifo_put()/nano_isr_lifo_get() failure\n"); return TC_FAIL; - } + } return TC_PASS; } @@ -510,13 +510,13 @@ static void fiber_multi_waiters(int arg1, int arg2) if (item != &multi_waiters_items[arg1]) { TC_ERROR(" *** fiber %d did not receive correct item\n", arg1); TC_ERROR(" *** received %p instead of %p.\n", - item, &multi_waiters_items[arg1]); + item, &multi_waiters_items[arg1]); /* do NOT give the semaphore, signifying an error */ return; } TC_PRINT("multiple-waiter fiber %d got correct item, giving semaphore\n", - arg1); + arg1); nano_fiber_sem_give(&reply_multi_waiters); } @@ -534,7 +534,7 @@ static int do_test_multiple_waiters(void) /* pend all fibers one the same lifo */ for (ii = 0; ii < NUM_WAITERS; ii++) { task_fiber_start(fiber_multi_waiters_stacks[ii], FIBER_STACKSIZE, - fiber_multi_waiters, ii, 0, FIBER_PRIORITY, 0); + fiber_multi_waiters, ii, 0, FIBER_PRIORITY, 0); } /* wake up all the fibers: the task is preempted each time */ @@ -551,7 +551,7 @@ static int do_test_multiple_waiters(void) } TC_PRINT("Task took multi-waiter reply semaphore %d times, as expected.\n", - NUM_WAITERS); + NUM_WAITERS); if (nano_task_lifo_get(&multi_waiters)) { TC_ERROR(" *** multi_waiters should have been empty.\n"); @@ -607,23 +607,23 @@ void main(void) initNanoObjects(); - /* - * Start the fiber. The fiber will be given a higher priority than the - * main task. - */ + /* + * Start the fiber. The fiber will be given a higher priority than the + * main task. + */ task_fiber_start(fiberStack, FIBER_STACKSIZE, fiberEntry, - 0, 0, FIBER_PRIORITY, 0); + 0, 0, FIBER_PRIORITY, 0); rv = taskLifoWaitTest(); if (rv == TC_PASS) { rv = taskLifoNonWaitTest(); - } + } if (rv == TC_PASS) { rv = test_multiple_waiters(); - } + } TC_END_RESULT(rv); TC_END_REPORT(rv); diff --git a/samples/nanokernel/test/test_sema/src/sema.c b/samples/nanokernel/test/test_sema/src/sema.c index 42f2bd6a5..d597f0fc8 100644 --- a/samples/nanokernel/test/test_sema/src/sema.c +++ b/samples/nanokernel/test/test_sema/src/sema.c @@ -70,15 +70,15 @@ Scenario #3: typedef struct { struct nano_sem *sem; /* ptr to semaphore */ - int data; /* data */ - } ISR_SEM_INFO; + int data; /* data */ +} ISR_SEM_INFO; typedef enum { STS_INIT = -1, STS_TASK_WOKE_FIBER, STS_FIBER_WOKE_TASK, STS_ISR_WOKE_TASK - } SEM_TEST_STATE; +} SEM_TEST_STATE; /* locals */ @@ -153,26 +153,26 @@ int testSemFiberNoWait(void) TC_PRINT("Giving and taking a semaphore in a fiber (non-blocking)\n"); - /* - * Give the semaphore many times and then make sure that it can only be - * taken that many times. - */ + /* + * Give the semaphore many times and then make sure that it can only be + * taken that many times. + */ for (i = 0; i < 32; i++) { nano_fiber_sem_give(&testSem); - } + } for (i = 0; i < 32; i++) { if (nano_fiber_sem_take(&testSem) != 1) { - TC_ERROR(" *** Expected nano_fiber_sem_take() to succeed, not fail\n"); - goto errorReturn; - } + TC_ERROR(" *** Expected nano_fiber_sem_take() to succeed, not fail\n"); + goto errorReturn; } + } if (nano_fiber_sem_take(&testSem) != 0) { TC_ERROR(" *** Expected nano_fiber_sem_take() to fail, not succeed\n"); goto errorReturn; - } + } return TC_PASS; @@ -204,56 +204,57 @@ static void fiberEntry(int arg1, int arg2) rv = testSemFiberNoWait(); if (rv != TC_PASS) { return; - } + } - /* - * At this point <testSem> is not available. Wait for <testSem> to become - * available (the main task will give it). - */ + /* + * At this point <testSem> is not available. Wait for <testSem> to become + * available (the main task will give it). + */ nano_fiber_sem_take_wait(&testSem); semTestState = STS_TASK_WOKE_FIBER; - /* - * Delay for two seconds. This gives the main task time to print - * any messages (very important if I/O link is slow!), and wait - * on <testSem>. Once the delay is done, this fiber will give <testSem> - * thus waking the main task. - */ + /* + * Delay for two seconds. This gives the main task time to print + * any messages (very important if I/O link is slow!), and wait + * on <testSem>. Once the delay is done, this fiber will give <testSem> + * thus waking the main task. + */ nano_fiber_timer_start(&timer, SECONDS(2)); nano_fiber_timer_wait(&timer); - /* - * The main task is now waiting on <testSem>. Give the semaphore <testSem> - * to wake it. - */ + /* + * The main task is now waiting on <testSem>. Give the semaphore <testSem> + * to wake it. + */ nano_fiber_sem_give(&testSem); - /* - * Some small delay must be done so that the main task can process the - * semaphore signal. - */ + /* + * Some small delay must be done so that the main task can process the + * semaphore signal. + */ semTestState = STS_FIBER_WOKE_TASK; nano_fiber_timer_start(&timer, SECONDS(2)); nano_fiber_timer_wait(&timer); - /* - * The main task should be waiting on <testSem> again. This time, instead - * of giving the semaphore from the semaphore, give it from an ISR to wake - * the main task. - */ + /* + * The main task should be waiting on <testSem> again. This time, instead + * of giving the semaphore from the semaphore, give it from an ISR to wake + * the main task. + */ isrSemInfo.data = 0; isrSemInfo.sem = &testSem; _trigger_nano_isr_sem_give(); - if (isrSemInfo.data == 1) + if (isrSemInfo.data == 1) { semTestState = STS_ISR_WOKE_TASK; + } } /******************************************************************************* @@ -298,30 +299,30 @@ int testSemIsrNoWait(void) TC_PRINT("Giving and taking a semaphore in an ISR (non-blocking)\n"); - /* - * Give the semaphore many times and then make sure that it can only be - * taken that many times. - */ + /* + * Give the semaphore many times and then make sure that it can only be + * taken that many times. + */ isrSemInfo.sem = &testSem; for (i = 0; i < 32; i++) { _trigger_nano_isr_sem_give(); - } + } for (i = 0; i < 32; i++) { isrSemInfo.data = 0; _trigger_nano_isr_sem_take(); if (isrSemInfo.data != 1) { - TC_ERROR(" *** Expected nano_isr_sem_take() to succeed, not fail\n"); - goto errorReturn; - } + TC_ERROR(" *** Expected nano_isr_sem_take() to succeed, not fail\n"); + goto errorReturn; } + } _trigger_nano_isr_sem_take(); if (isrSemInfo.data != 0) { TC_ERROR(" *** Expected nano_isr_sem_take() to fail, not succeed!\n"); goto errorReturn; - } + } return TC_PASS; @@ -345,26 +346,26 @@ int testSemTaskNoWait(void) TC_PRINT("Giving and taking a semaphore in a task (non-blocking)\n"); - /* - * Give the semaphore many times and then make sure that it can only be - * taken that many times. - */ + /* + * Give the semaphore many times and then make sure that it can only be + * taken that many times. + */ for (i = 0; i < 32; i++) { nano_task_sem_give(&testSem); - } + } for (i = 0; i < 32; i++) { if (nano_task_sem_take(&testSem) != 1) { - TC_ERROR(" *** Expected nano_task_sem_take() to succeed, not fail\n"); - goto errorReturn; - } + TC_ERROR(" *** Expected nano_task_sem_take() to succeed, not fail\n"); + goto errorReturn; } + } if (nano_task_sem_take(&testSem) != 0) { TC_ERROR(" *** Expected nano_task_sem_take() to fail, not succeed!\n"); goto errorReturn; - } + } return TC_PASS; @@ -387,14 +388,14 @@ int testSemWait(void) if (fiberDetectedFailure != 0) { TC_ERROR(" *** Failure detected in the fiber."); return TC_FAIL; - } + } nano_task_sem_give(&testSem); /* Wake the fiber. */ if (semTestState != STS_TASK_WOKE_FIBER) { TC_ERROR(" *** Expected task to wake fiber. It did not.\n"); return TC_FAIL; - } + } TC_PRINT("Semaphore from the task woke the fiber\n"); @@ -403,7 +404,7 @@ int testSemWait(void) if (semTestState != STS_FIBER_WOKE_TASK) { TC_ERROR(" *** Expected fiber to wake task. It did not.\n"); return TC_FAIL; - } + } TC_PRINT("Semaphore from the fiber woke the task\n"); @@ -412,7 +413,7 @@ int testSemWait(void) if (semTestState != STS_ISR_WOKE_TASK) { TC_ERROR(" *** Expected ISR to wake task. It did not.\n"); return TC_FAIL; - } + } TC_PRINT("Semaphore from the ISR woke the task.\n"); return TC_PASS; @@ -541,32 +542,32 @@ void main(void) rv = testSemTaskNoWait(); if (rv != TC_PASS) { goto doneTests; - } + } rv = testSemIsrNoWait(); if (rv != TC_PASS) { goto doneTests; - } + } semTestState = STS_INIT; - /* - * Start the fiber. The fiber will be given a higher priority than the - * main task. - */ + /* + * Start the fiber. The fiber will be given a higher priority than the + * main task. + */ task_fiber_start(fiberStack, FIBER_STACKSIZE, fiberEntry, - 0, 0, FIBER_PRIORITY, 0); + 0, 0, FIBER_PRIORITY, 0); rv = testSemWait(); if (rv != TC_PASS) { goto doneTests; - } + } rv = test_multiple_waiters(); if (rv != TC_PASS) { goto doneTests; - } + } doneTests: TC_END_RESULT(rv); diff --git a/samples/nanokernel/test/test_stack/src/stack.c b/samples/nanokernel/test/test_stack/src/stack.c index 930668434..852b716f9 100644 --- a/samples/nanokernel/test/test_stack/src/stack.c +++ b/samples/nanokernel/test/test_stack/src/stack.c @@ -87,8 +87,8 @@ these are run in ISR context. typedef struct { struct nano_stack *channel; /* STACK channel */ - uint32_t data; /* data to add */ - } ISR_STACK_INFO; + uint32_t data; /* data to add */ +} ISR_STACK_INFO; /* globals */ @@ -100,9 +100,9 @@ char fiberStack3[STACKSIZE]; struct nano_timer timer; struct nano_stack nanoStackObj; struct nano_stack nanoStackObj2; -struct nano_sem nanoSemObj; /* Used for transferring control between - * main and fiber1 - */ +struct nano_sem nanoSemObj; /* Used for transferring control between + * main and fiber1 + */ uint32_t myData[NUM_STACK_ELEMENT]; uint32_t myIsrData[NUM_STACK_ELEMENT]; /* Data used for testing @@ -151,7 +151,7 @@ void initData(void) for (int i=0; i< NUM_STACK_ELEMENT; i++) { myData[i] = (STARTNUM + i) * MULTIPLIER; myIsrData[i] = myData[i] + MYNUMBER; - } + } } /* initData */ /******************************************************************************* @@ -192,9 +192,9 @@ void isr_stack_pop(void *parameter) ISR_STACK_INFO *pInfo = (ISR_STACK_INFO *) parameter; if (nano_isr_stack_pop(pInfo->channel, &(pInfo->data)) == 0) { - /* the stack is empty, set data to INVALID_DATA */ + /* the stack is empty, set data to INVALID_DATA */ pInfo->data = INVALID_DATA; - } + } } /* isr_stack_pop */ @@ -216,31 +216,31 @@ void fiber1(void) int count = 0; /* counter */ TC_PRINT("Test Fiber STACK Pop\n\n"); - /* Get all data */ + /* Get all data */ while (nano_fiber_stack_pop(&nanoStackObj, &data) != 0) { TC_PRINT("FIBER STACK Pop: count = %d, data is %d\n", count, data); if((count >= NUM_STACK_ELEMENT) || (data != myData[NUM_STACK_ELEMENT - 1 - count])) { - TCERR1(count); - retCode = TC_FAIL; - return; - } - count++; + TCERR1(count); + retCode = TC_FAIL; + return; } + count++; + } TC_END_RESULT(retCode); PRINT_LINE; - /* Put data */ + /* Put data */ TC_PRINT("Test Fiber STACK Push\n"); TC_PRINT("\nFIBER STACK Put Order: "); for (int i=NUM_STACK_ELEMENT; i>0; i--) { nano_fiber_stack_push(&nanoStackObj, myData[i-1]); TC_PRINT(" %d,", myData[i-1]); - } + } TC_PRINT("\n"); PRINT_LINE; - /* Give semaphore to allow the main task to run */ + /* Give semaphore to allow the main task to run */ nano_fiber_sem_give(&nanoSemObj); } /* fiber1 */ @@ -264,12 +264,12 @@ void testFiberStackPopW(void) TC_PRINT("Test Fiber STACK Pop Wait Interfaces\n\n"); data = nano_fiber_stack_pop_wait(&nanoStackObj2); TC_PRINT("FIBER STACK Pop from queue2: %d\n", data); - /* Verify results */ + /* Verify results */ if (data != myData[0]) { retCode = TC_FAIL; TCERR2; return; - } + } data = myData[1]; TC_PRINT("FIBER STACK Push to queue1: %d\n", data); @@ -277,12 +277,12 @@ void testFiberStackPopW(void) data = nano_fiber_stack_pop_wait(&nanoStackObj2); TC_PRINT("FIBER STACK Pop from queue2: %d\n", data); - /* Verify results */ + /* Verify results */ if (data != myData[2]) { retCode = TC_FAIL; TCERR2; return; - } + } data = myData[3]; TC_PRINT("FIBER STACK Push to queue1: %d\n", data); @@ -310,19 +310,19 @@ void testIsrStackFromFiber(void) TC_PRINT("Test ISR STACK (invoked from Fiber)\n\n"); - /* This is data pushed by function testFiberStackPopW */ + /* This is data pushed by function testFiberStackPopW */ _trigger_nano_isr_stack_pop(); result = isrStackInfo.data; if (result != INVALID_DATA) { TC_PRINT("ISR STACK (running in fiber context) Pop from queue1: %d\n", result); if (result != myData[3]) { - retCode = TC_FAIL; - TCERR2; - return; - } + retCode = TC_FAIL; + TCERR2; + return; } + } - /* Verify that the STACK is empty */ + /* Verify that the STACK is empty */ _trigger_nano_isr_stack_pop(); result = isrStackInfo.data; if (result != INVALID_DATA) { @@ -330,19 +330,19 @@ void testIsrStackFromFiber(void) retCode = TC_FAIL; TCERR3; return; - } + } - /* Put more data into STACK */ + /* Put more data into STACK */ TC_PRINT("ISR STACK (running in fiber context) Push to queue1: \n"); for (int i=0; i<NUM_STACK_ELEMENT; i++) { isrStackInfo.data = myIsrData[i]; TC_PRINT(" %d, ", myIsrData[i]); _trigger_nano_isr_stack_push(); - } + } TC_PRINT("\n"); - isrStackInfo.data = INVALID_DATA; /* Set variable to INVALID_DATA to ensure - * [data] changes - */ + + /* Set variable to INVALID_DATA to ensure [data] changes */ + isrStackInfo.data = INVALID_DATA; TC_END_RESULT(retCode); @@ -367,41 +367,41 @@ void testIsrStackFromTask(void) TC_PRINT("Test ISR STACK (invoked from Task)\n\n"); - /* Get all data */ + /* Get all data */ _trigger_nano_isr_stack_pop(); result = isrStackInfo.data; while (result != INVALID_DATA) { - TC_PRINT(" Pop from queue1: count = %d, data is %d\n", count, result); - if ((count >= NUM_STACK_ELEMENT) || (result != myIsrData[NUM_STACK_ELEMENT - count - 1])) { - TCERR1(count); - retCode = TC_FAIL; - return; - } /* if */ - - /* Get the next element */ - _trigger_nano_isr_stack_pop(); - result = isrStackInfo.data; - count++; + TC_PRINT(" Pop from queue1: count = %d, data is %d\n", count, result); + if ((count >= NUM_STACK_ELEMENT) || (result != myIsrData[NUM_STACK_ELEMENT - count - 1])) { + TCERR1(count); + retCode = TC_FAIL; + return; + } /* if */ + + /* Get the next element */ + _trigger_nano_isr_stack_pop(); + result = isrStackInfo.data; + count++; } /* while */ - /* Put data into stack and get it again */ + /* Put data into stack and get it again */ isrStackInfo.data = myIsrData[3]; _trigger_nano_isr_stack_push(); isrStackInfo.data = INVALID_DATA; /* force variable to a new value */ - /* Get data from stack */ + /* Get data from stack */ _trigger_nano_isr_stack_pop(); result = isrStackInfo.data; - /* Verify data */ + /* Verify data */ if (result != myIsrData[3]) { - TCERR2; - retCode = TC_FAIL; - return; + TCERR2; + retCode = TC_FAIL; + return; } else { - TC_PRINT("\nTest ISR STACK (invoked from Task) - push %d and pop back %d\n", - myIsrData[3], result); + TC_PRINT("\nTest ISR STACK (invoked from Task) - push %d and pop back %d\n", + myIsrData[3], result); } TC_END_RESULT(retCode); @@ -446,18 +446,18 @@ void testTaskStackPopW(void) TC_PRINT("TASK STACK Push to queue2: %d\n", data); nano_task_stack_push(&nanoStackObj2, data); - /* Start fiber */ + /* Start fiber */ task_fiber_start(&fiberStack2[0], STACKSIZE, - (nano_fiber_entry_t) fiber2, 0, 0, 7, 0); + (nano_fiber_entry_t) fiber2, 0, 0, 7, 0); data = nano_task_stack_pop_wait(&nanoStackObj); TC_PRINT("TASK STACK Pop from queue1: %d\n", data); - /* Verify results */ + /* Verify results */ if (data != myData[1]) { retCode = TC_FAIL; TCERR2; return; - } + } data = myData[2]; TC_PRINT("TASK STACK Push to queue2: %d\n", data); @@ -523,77 +523,77 @@ void main(void) TC_START("Test Nanokernel STACK"); - /* Initialize data */ + /* Initialize data */ initData(); - /* Initialize the queues and semaphore */ + /* Initialize the queues and semaphore */ initNanoObjects(); - /* Start fiber3 */ + /* Start fiber3 */ task_fiber_start(&fiberStack3[0], STACKSIZE, (nano_fiber_entry_t) fiber3, - 0, 0, 7, 0); - /* - * While fiber3 blocks (for one second), wait for an item to be pushed - * onto the stack so that it can be popped. This will put the nanokernel - * into an idle state. - */ + 0, 0, 7, 0); + /* + * While fiber3 blocks (for one second), wait for an item to be pushed + * onto the stack so that it can be popped. This will put the nanokernel + * into an idle state. + */ data = nano_task_stack_pop_wait(&nanoStackObj); if (data != myData[0]) { TC_ERROR("nano_task_stack_pop_wait() expected 0x%x, but got 0x%x\n", - myData[0], data); + myData[0], data); retCode = TC_FAIL; goto exit; } - /* Put data */ + /* Put data */ TC_PRINT("Test Task STACK Push\n"); TC_PRINT("\nTASK STACK Put Order: "); for (int i=0; i<NUM_STACK_ELEMENT; i++) { nano_task_stack_push(&nanoStackObj, myData[i]); TC_PRINT(" %d,", myData[i]); - } + } TC_PRINT("\n"); PRINT_LINE; - /* Start fiber */ + /* Start fiber */ task_fiber_start(&fiberStack1[0], STACKSIZE, - (nano_fiber_entry_t) fiber1, 0, 0, 7, 0); + (nano_fiber_entry_t) fiber1, 0, 0, 7, 0); if (retCode == TC_FAIL) { goto exit; - } + } - /* - * Wait for fiber1 to complete execution. (Using a semaphore gives - * the fiber the freedom to do blocking-type operations if it wants to.) - * - */ + /* + * Wait for fiber1 to complete execution. (Using a semaphore gives + * the fiber the freedom to do blocking-type operations if it wants to.) + * + */ nano_task_sem_take_wait(&nanoSemObj); TC_PRINT("Test Task STACK Pop\n"); - /* Get all data */ + /* Get all data */ while (nano_task_stack_pop(&nanoStackObj, &data) != 0) { TC_PRINT("TASK STACK Pop: count = %d, data is %d\n", count, data); if ((count >= NUM_STACK_ELEMENT) || (data != myData[count])) { - TCERR1(count); - retCode = TC_FAIL; - goto exit; - } - count++; + TCERR1(count); + retCode = TC_FAIL; + goto exit; } + count++; + } - /* Test Task Stack Pop Wait interfaces*/ + /* Test Task Stack Pop Wait interfaces*/ testTaskStackPopW(); if (retCode == TC_FAIL) { goto exit; - } + } PRINT_LINE; - /* Test ISR interfaces */ + /* Test ISR interfaces */ testIsrStackFromTask(); PRINT_LINE; diff --git a/samples/nanokernel/test/test_timer/src/timer.c b/samples/nanokernel/test/test_timer/src/timer.c index 8f50ae4b9..978e96c80 100644 --- a/samples/nanokernel/test/test_timer/src/timer.c +++ b/samples/nanokernel/test/test_timer/src/timer.c @@ -144,8 +144,8 @@ int basicTimerWait(timer_start_func startRtn, timer_getw_func waitRtn, tick = nano_tick_get_32(); while (nano_tick_get_32() == tick) { - /* Align to a tick boundary */ - } + /* Align to a tick boundary */ + } tick++; (void) nano_tick_delta(&reftime); @@ -155,36 +155,36 @@ int basicTimerWait(timer_start_func startRtn, timer_getw_func waitRtn, elapsed_32 = nano_tick_delta_32(&reftime); duration = nano_tick_get_32() - tick; - /* - * The difference between <duration> and <elapsed> is expected to be zero - * however, the test is allowing for tolerance of an extra tick in case of - * timing variations. - */ + /* + * The difference between <duration> and <elapsed> is expected to be zero + * however, the test is allowing for tolerance of an extra tick in case of + * timing variations. + */ if ((result != pTimerData) || (duration - elapsed_32 > 1) || ((duration - ticks) > 1)) { return TC_FAIL; - } + } - /* Check that the non-wait-timer-get routine works properly. */ + /* Check that the non-wait-timer-get routine works properly. */ tick = nano_tick_get_32(); while (nano_tick_get_32() == tick) { - /* Align to a tick boundary */ - } + /* Align to a tick boundary */ + } tick++; (void) nano_tick_delta(&reftime); startRtn(pTimer, ticks); /* Start the timer */ while ((result = getRtn(pTimer)) == NULL) { busywaited = 1; - } + } elapsed = nano_tick_delta(&reftime); duration = nano_tick_get_32() - tick; if ((busywaited != 1) || (result != pTimerData) || (duration - elapsed > 1) || ((duration - ticks) > 1)) { return TC_FAIL; - } + } return TC_PASS; } @@ -212,8 +212,8 @@ void startTimers(timer_start_func startRtn) tick = nano_tick_get_32(); while (nano_tick_get_32() == tick) { - /* Wait for the end of the tick */ - } + /* Wait for the end of the tick */ + } startRtn(&timer, TWO_SECONDS); startRtn(&longTimer, LONG_TIMEOUT); @@ -247,44 +247,44 @@ int busyWaitTimers(timer_get_func getRtn) while ((numExpired != 4) && (nano_tick_get_32() < ticks)) { result = getRtn(&timer); if (result != NULL) { - numExpired++; - if ((result != timerData) || (numExpired != 2)) { - TC_ERROR("Expected <timer> to expire 2nd, not 0x%x\n", - result); - return TC_FAIL; - } - } + numExpired++; + if ((result != timerData) || (numExpired != 2)) { + TC_ERROR("Expected <timer> to expire 2nd, not 0x%x\n", + result); + return TC_FAIL; + } + } result = getRtn(&shortTimer); if (result != NULL) { - numExpired++; - if ((result != shortTimerData) || (numExpired != 1)) { - TC_ERROR("Expected <shortTimer> to expire 1st, not 0x%x\n", - result); - return TC_FAIL; - } - } + numExpired++; + if ((result != shortTimerData) || (numExpired != 1)) { + TC_ERROR("Expected <shortTimer> to expire 1st, not 0x%x\n", + result); + return TC_FAIL; + } + } result = getRtn(&midTimer); if (result != NULL) { - numExpired++; - if ((result != midTimerData) || (numExpired != 3)) { - TC_ERROR("Expected <midTimer> to expire 3rd, not 0x%x\n", - result); - return TC_FAIL; - } - } + numExpired++; + if ((result != midTimerData) || (numExpired != 3)) { + TC_ERROR("Expected <midTimer> to expire 3rd, not 0x%x\n", + result); + return TC_FAIL; + } + } result = getRtn(&longTimer); if (result != NULL) { - numExpired++; - if ((result != longTimerData) || (numExpired != 4)) { - TC_ERROR("Expected <longTimer> to expire 4th, not 0x%x\n", - result); - return TC_FAIL; - } - } + numExpired++; + if ((result != longTimerData) || (numExpired != 4)) { + TC_ERROR("Expected <longTimer> to expire 4th, not 0x%x\n", + result); + return TC_FAIL; + } } + } return (nano_tick_get_32() < ticks) ? TC_PASS : TC_FAIL; } @@ -319,16 +319,16 @@ int stopTimers(timer_stop_func stopRtn, timer_get_func getRtn) startTick = nano_tick_get_32(); while (nano_tick_get_32() == startTick) { - } + } startTick++; endTick = startTick + SIX_SECONDS; while (nano_tick_get_32() < endTick) { if ((getRtn(&timer) != NULL) || (getRtn(&shortTimer) != NULL) || - (getRtn(&midTimer) != NULL) || (getRtn(&longTimer) != NULL)) { - return TC_FAIL; - } + (getRtn(&midTimer) != NULL) || (getRtn(&longTimer) != NULL)) { + return TC_FAIL; } + } return TC_PASS; } @@ -378,16 +378,16 @@ static void fiberEntry(int arg1, int arg2) TC_PRINT("Fiber testing basic timer functionality\n"); rv = basicTimerWait(nano_fiber_timer_start, nano_fiber_timer_wait, - nano_fiber_timer_test, &timer, timerData, TWO_SECONDS); + nano_fiber_timer_test, &timer, timerData, TWO_SECONDS); nano_fiber_sem_give(&wakeTask); if (rv != TC_PASS) { fiberDetectedError = 1; return; - } + } nano_fiber_sem_take_wait(&wakeFiber); /* Wait forever - let task run */ - /* Check that timers expire in the correct order */ + /* Check that timers expire in the correct order */ TC_PRINT("Fiber testing timers expire in the correct order\n"); startTimers(nano_fiber_timer_start); rv = busyWaitTimers(nano_fiber_timer_test); @@ -395,10 +395,10 @@ static void fiberEntry(int arg1, int arg2) if (rv != TC_PASS) { fiberDetectedError = 2; return; - } + } nano_fiber_sem_take_wait(&wakeFiber); /* Wait forever - let task run */ - /* Check that timers can be stopped */ + /* Check that timers can be stopped */ TC_PRINT("Task testing the stopping of timers\n"); startTimers(nano_fiber_timer_start); rv = stopTimers(nano_fiber_timer_stop, nano_fiber_timer_test); @@ -406,23 +406,23 @@ static void fiberEntry(int arg1, int arg2) if (rv != TC_PASS) { fiberDetectedError = 3; return; - } + } nano_fiber_sem_take_wait(&wakeFiber); /* Wait forever - let task run */ - /* Fiber to wait on a timer that will be stopped by another fiber */ + /* Fiber to wait on a timer that will be stopped by another fiber */ TC_PRINT("Fiber to stop a timer that has a waiting fiber\n"); fiber_fiber_start(fiber2Stack, FIBER2_STACKSIZE, fiber2Entry, - 0, 0, FIBER2_PRIORITY, 0); + 0, 0, FIBER2_PRIORITY, 0); nano_fiber_timer_start(&timer, TWO_SECONDS); /* Start timer */ result = nano_fiber_timer_wait(&timer); /* Wait on timer */ - /* Control switches to newly created fiber #2 before coming back. */ + /* Control switches to newly created fiber #2 before coming back. */ if (result != NULL) { fiberDetectedError = 4; nano_fiber_sem_give(&wakeTask); return; - } + } - /* Fiber to wait on timer that will be stopped by the task */ + /* Fiber to wait on timer that will be stopped by the task */ TC_PRINT("Task to stop a timer that has a waiting fiber\n"); nano_fiber_sem_give(&wakeTask); nano_fiber_timer_start(&timer, TWO_SECONDS); @@ -430,7 +430,7 @@ static void fiberEntry(int arg1, int arg2) if (result != NULL) { fiberDetectedError = 5; return; - } + } nano_fiber_sem_give(&wakeTask); } @@ -454,10 +454,10 @@ int nano_cycle_get_32Test(void) timeStamp2 = nano_cycle_get_32(); if (timeStamp2 < timeStamp1) { - TC_ERROR("Timestamp value not increasing with successive calls\n"); - return TC_FAIL; - } + TC_ERROR("Timestamp value not increasing with successive calls\n"); + return TC_FAIL; } + } return TC_PASS; } @@ -481,37 +481,37 @@ void main(void) TC_PRINT("Task testing basic timer functionality\n"); rv = basicTimerWait(nano_task_timer_start, nano_task_timer_wait, - nano_task_timer_test, &timer, timerData, TWO_SECONDS); + nano_task_timer_test, &timer, timerData, TWO_SECONDS); if (rv != TC_PASS) { TC_ERROR("Task-level of waiting for timers failed\n"); goto doneTests; - } + } - /* Check that timers expire in the correct order */ + /* Check that timers expire in the correct order */ TC_PRINT("Task testing timers expire in the correct order\n"); startTimers(nano_task_timer_start); rv = busyWaitTimers(nano_task_timer_test); if (rv != TC_PASS) { TC_ERROR("Task-level timer expiration order failed\n"); goto doneTests; - } + } - /* Check that timers can be stopped */ + /* Check that timers can be stopped */ TC_PRINT("Task testing the stopping of timers\n"); startTimers(nano_task_timer_start); rv = stopTimers(nano_task_timer_stop, nano_task_timer_test); if (rv != TC_PASS) { TC_ERROR("Task-level stopping of timers test failed\n"); goto doneTests; - } + } - /* - * Start the fiber. The fiber will be given a higher priority than the - * main task. - */ + /* + * Start the fiber. The fiber will be given a higher priority than the + * main task. + */ task_fiber_start(fiberStack, FIBER_STACKSIZE, fiberEntry, - 0, 0, FIBER_PRIORITY, 0); + 0, 0, FIBER_PRIORITY, 0); nano_task_sem_take_wait(&wakeTask); @@ -519,7 +519,7 @@ void main(void) TC_ERROR("Fiber-level of waiting for timers failed\n"); rv = TC_FAIL; goto doneTests; - } + } nano_task_sem_give(&wakeFiber); nano_task_sem_take_wait(&wakeTask); @@ -528,7 +528,7 @@ void main(void) TC_ERROR("Fiber-level timer expiration order failed\n"); rv = TC_FAIL; goto doneTests; - } + } nano_task_sem_give(&wakeFiber); nano_task_sem_take_wait(&wakeTask); @@ -537,7 +537,7 @@ void main(void) TC_ERROR("Fiber-level stopping of timers test failed\n"); rv = TC_FAIL; goto doneTests; - } + } nano_task_sem_give(&wakeFiber); nano_task_sem_take_wait(&wakeTask); @@ -545,27 +545,27 @@ void main(void) TC_ERROR("Fiber stopping a timer waited upon by a fiber failed\n"); rv = TC_FAIL; goto doneTests; - } + } nano_task_timer_stop(&timer); if (fiberDetectedError == 5) { TC_ERROR("Task stopping a timer waited upon by a fiber failed\n"); rv = TC_FAIL; goto doneTests; - } + } nano_task_sem_take_wait(&wakeTask); #if 0 - /* - * Due to recent changes in the i8253 file that correct an issue on real - * hardware, this test will fail when run under QEMU. On QEMU, the i8253 - * timer can at appear to run backwards. This can generate a false - * failure detection when this test is run under QEMU as part of the - * standard sanity/regression checks. This suggests that the test is not - * of high enough quality to be included during the standard sanity/ - * regression checks. - */ + /* + * Due to recent changes in the i8253 file that correct an issue on real + * hardware, this test will fail when run under QEMU. On QEMU, the i8253 + * timer can at appear to run backwards. This can generate a false + * failure detection when this test is run under QEMU as part of the + * standard sanity/regression checks. This suggests that the test is not + * of high enough quality to be included during the standard sanity/ + * regression checks. + */ TC_PRINT("Task testing of nano_cycle_get_32()\n"); rv = nano_cycle_get_32Test(); |