kernel/os; os_init() - add function name to be used as the entry point to main task.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fd7bb7c6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fd7bb7c6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fd7bb7c6 Branch: refs/heads/develop Commit: fd7bb7c6f7116aacd29bd8c627f11d82aa18a46e Parents: b32668d Author: Marko Kiiskila <[email protected]> Authored: Wed Jan 25 14:28:12 2017 -0800 Committer: Marko Kiiskila <[email protected]> Committed: Wed Jan 25 14:32:31 2017 -0800 ---------------------------------------------------------------------- hw/mcu/native/src/hal_system.c | 3 ++- kernel/os/include/os/os.h | 2 +- kernel/os/src/os.c | 18 ++++++++++-------- kernel/os/test/src/mempool_test.c | 2 +- kernel/os/test/src/mutex_test.c | 2 +- kernel/os/test/src/os_test.c | 2 +- kernel/os/test/src/sem_test.c | 2 +- .../src/testcases/event_test_poll_single_sr.c | 2 +- kernel/os/test/src/testcases/event_test_poll_sr.c | 2 +- .../src/testcases/event_test_poll_timeout_sr.c | 2 +- kernel/os/test/src/testcases/event_test_src.c | 2 +- kernel/os/test/src/testcases/os_callout_test.c | 2 +- .../os/test/src/testcases/os_callout_test_speak.c | 2 +- .../os/test/src/testcases/os_callout_test_stop.c | 2 +- libc/baselibc/src/start.c | 5 ++--- .../mn_socket/test/src/testcases/socket_tests.c | 2 +- test/testutil/src/testutil.c | 2 +- 17 files changed, 28 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/hw/mcu/native/src/hal_system.c ---------------------------------------------------------------------- diff --git a/hw/mcu/native/src/hal_system.c b/hw/mcu/native/src/hal_system.c index 59927c9..a27932c 100644 --- a/hw/mcu/native/src/hal_system.c +++ b/hw/mcu/native/src/hal_system.c @@ -64,6 +64,7 @@ mcu_sim_parse_args(int argc, char **argv) { int ch; char *progname; + extern int main(int argc, char **arg); #if MYNEWT_VAL(OS_SCHEDULING) if (g_os_started) { @@ -88,7 +89,7 @@ mcu_sim_parse_args(int argc, char **argv) } } #if MYNEWT_VAL(OS_SCHEDULING) - os_init(); + os_init(main); os_start(); #endif } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/include/os/os.h ---------------------------------------------------------------------- diff --git a/kernel/os/include/os/os.h b/kernel/os/include/os/os.h index 17f42a8..c8734d4 100644 --- a/kernel/os/include/os/os.h +++ b/kernel/os/include/os/os.h @@ -86,7 +86,7 @@ typedef enum os_error os_error_t; #define OS_MAIN_TASK_PRIO MYNEWT_VAL(OS_MAIN_TASK_PRIO) #define OS_MAIN_STACK_SIZE MYNEWT_VAL(OS_MAIN_STACK_SIZE) -void os_init(void); +void os_init(int (*fn)(int argc, char **argv)); void os_start(void); /* XXX: Not sure if this should go here; I want to differentiate API that http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/src/os.c ---------------------------------------------------------------------- diff --git a/kernel/os/src/os.c b/kernel/os/src/os.c index 374f5f1..edbadbc 100644 --- a/kernel/os/src/os.c +++ b/kernel/os/src/os.c @@ -130,12 +130,13 @@ os_started(void) static void os_main(void *arg) { - extern int main(int argc, char **argv); + int (*fn)(int argc, char **argv) = arg; os_eventq_init(os_eventq_dflt_get()); #if !MYNEWT_VAL(SELFTEST) - main(0, NULL); + fn(0, NULL); #else + (void)fn; while (1) { os_eventq_run(os_eventq_dflt_get()); } @@ -157,11 +158,6 @@ os_init_idle_task(void) rc = os_sanity_init(); assert(rc == 0); - rc = os_task_init(&os_main_task, "main", os_main, NULL, - OS_MAIN_TASK_PRIO, OS_WAIT_FOREVER, os_main_stack, - OS_STACK_ALIGN(OS_MAIN_STACK_SIZE)); - assert(rc == 0); - assert(MYNEWT_VAL(WATCHDOG_INTERVAL) - 200 > MYNEWT_VAL(SANITY_INTERVAL)); rc = hal_watchdog_init(MYNEWT_VAL(WATCHDOG_INTERVAL)); @@ -173,7 +169,7 @@ os_init_idle_task(void) * support to initialize the operating system. */ void -os_init(void) +os_init(int (*main_fn)(int argc, char **arg)) { os_error_t err; @@ -186,6 +182,12 @@ os_init(void) err = os_arch_os_init(); assert(err == OS_OK); + if (main_fn) { + err = os_task_init(&os_main_task, "main", os_main, main_fn, + OS_MAIN_TASK_PRIO, OS_WAIT_FOREVER, os_main_stack, + OS_STACK_ALIGN(OS_MAIN_STACK_SIZE)); + assert(err == 0); + } /* Call bsp related OS initializations */ hal_bsp_init(); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/mempool_test.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/mempool_test.c b/kernel/os/test/src/mempool_test.c index 5be2aca..10f4a0a 100644 --- a/kernel/os/test/src/mempool_test.c +++ b/kernel/os/test/src/mempool_test.c @@ -60,7 +60,7 @@ mempool_test_get_pool_size(int num_blocks, int block_size) void os_mempool_ts_pretest(void* arg) { - os_init(); + os_init(NULL); sysinit(); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/mutex_test.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/mutex_test.c b/kernel/os/test/src/mutex_test.c index ae05a27..0974b3b 100644 --- a/kernel/os/test/src/mutex_test.c +++ b/kernel/os/test/src/mutex_test.c @@ -335,7 +335,7 @@ os_mutex_tc_pretest(void* arg) /* * Only call if running in "native" simulated environment */ - os_init(); + os_init(NULL); sysinit(); #endif return; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/os_test.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/os_test.c b/kernel/os/test/src/os_test.c index 33b0868..eb868fa 100644 --- a/kernel/os/test/src/os_test.c +++ b/kernel/os/test/src/os_test.c @@ -73,7 +73,7 @@ os_test_restart(void) void os_selftest_pretest_cb(void* arg) { - os_init(); + os_init(NULL); sysinit(); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/sem_test.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/sem_test.c b/kernel/os/test/src/sem_test.c index 42e7bfe..397fa18 100644 --- a/kernel/os/test/src/sem_test.c +++ b/kernel/os/test/src/sem_test.c @@ -279,7 +279,7 @@ void os_sem_tc_pretest(void* arg) { #if MYNEWT_VAL(SELFTEST) - os_init(); + os_init(NULL); sysinit(); #endif return; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/testcases/event_test_poll_single_sr.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/testcases/event_test_poll_single_sr.c b/kernel/os/test/src/testcases/event_test_poll_single_sr.c index 72e1a5f..416528b 100644 --- a/kernel/os/test/src/testcases/event_test_poll_single_sr.c +++ b/kernel/os/test/src/testcases/event_test_poll_single_sr.c @@ -26,7 +26,7 @@ TEST_CASE(event_test_poll_single_sr) #if MYNEWT_VAL(SELFTEST) /* Initializing the OS */ - os_init(); + os_init(NULL); sysinit(); #endif /* Initialize the task */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/testcases/event_test_poll_sr.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/testcases/event_test_poll_sr.c b/kernel/os/test/src/testcases/event_test_poll_sr.c index e981839..e3dfbf6 100644 --- a/kernel/os/test/src/testcases/event_test_poll_sr.c +++ b/kernel/os/test/src/testcases/event_test_poll_sr.c @@ -25,7 +25,7 @@ TEST_CASE(event_test_poll_sr) #if MYNEWT_VAL(SELFTEST) /* Initializing the OS */ - os_init(); + os_init(NULL); sysinit(); #endif /* Initialize the task */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/testcases/event_test_poll_timeout_sr.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/testcases/event_test_poll_timeout_sr.c b/kernel/os/test/src/testcases/event_test_poll_timeout_sr.c index d7bccee..be92879 100644 --- a/kernel/os/test/src/testcases/event_test_poll_timeout_sr.c +++ b/kernel/os/test/src/testcases/event_test_poll_timeout_sr.c @@ -25,7 +25,7 @@ TEST_CASE(event_test_poll_timeout_sr) #if MYNEWT_VAL(SELFTEST) /* Initializing the OS */ - os_init(); + os_init(NULL); sysinit(); #endif /* Initialize the task */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/testcases/event_test_src.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/testcases/event_test_src.c b/kernel/os/test/src/testcases/event_test_src.c index f1adbea..76231c5 100644 --- a/kernel/os/test/src/testcases/event_test_src.c +++ b/kernel/os/test/src/testcases/event_test_src.c @@ -24,7 +24,7 @@ TEST_CASE(event_test_sr) #if MYNEWT_VAL(SELFTEST) /* Initializing the OS */ - os_init(); + os_init(NULL); sysinit(); #endif /* Initialize the task */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/testcases/os_callout_test.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/testcases/os_callout_test.c b/kernel/os/test/src/testcases/os_callout_test.c index a03570a..5354a1d 100644 --- a/kernel/os/test/src/testcases/os_callout_test.c +++ b/kernel/os/test/src/testcases/os_callout_test.c @@ -24,7 +24,7 @@ TEST_CASE(callout_test) #if MYNEWT_VAL(SELFTEST) /* Initializing the OS */ - os_init(); + os_init(NULL); sysinit(); #endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/testcases/os_callout_test_speak.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/testcases/os_callout_test_speak.c b/kernel/os/test/src/testcases/os_callout_test_speak.c index de8664f..bdd647b 100644 --- a/kernel/os/test/src/testcases/os_callout_test_speak.c +++ b/kernel/os/test/src/testcases/os_callout_test_speak.c @@ -24,7 +24,7 @@ TEST_CASE(callout_test_speak) #if MYNEWT_VAL(SELFTEST) /* Initializing the OS */ - os_init(); + os_init(NULL); sysinit(); #endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/kernel/os/test/src/testcases/os_callout_test_stop.c ---------------------------------------------------------------------- diff --git a/kernel/os/test/src/testcases/os_callout_test_stop.c b/kernel/os/test/src/testcases/os_callout_test_stop.c index 6b1a8e7..98ba7e4 100644 --- a/kernel/os/test/src/testcases/os_callout_test_stop.c +++ b/kernel/os/test/src/testcases/os_callout_test_stop.c @@ -25,7 +25,7 @@ TEST_CASE(callout_test_stop) #if MYNEWT_VAL(SELFTEST) /* Initializing the OS */ - os_init(); + os_init(NULL); sysinit(); #endif http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/libc/baselibc/src/start.c ---------------------------------------------------------------------- diff --git a/libc/baselibc/src/start.c b/libc/baselibc/src/start.c index febf5b2..7f6caac 100644 --- a/libc/baselibc/src/start.c +++ b/libc/baselibc/src/start.c @@ -19,10 +19,9 @@ #include <stdlib.h> #include <sysinit/sysinit.h> +#include <os/os.h> extern int main(int argc, char **argv); -extern void os_init(void); -extern void os_start(void); /* * Rudimentary startup function. @@ -35,7 +34,7 @@ void _start(void) rc = main(0, NULL); exit(rc); #else - os_init(); + os_init(main); os_start(); #endif } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/net/ip/mn_socket/test/src/testcases/socket_tests.c ---------------------------------------------------------------------- diff --git a/net/ip/mn_socket/test/src/testcases/socket_tests.c b/net/ip/mn_socket/test/src/testcases/socket_tests.c index 8bfc2b8..a1668aa 100644 --- a/net/ip/mn_socket/test/src/testcases/socket_tests.c +++ b/net/ip/mn_socket/test/src/testcases/socket_tests.c @@ -20,7 +20,7 @@ TEST_CASE(socket_tests) { - os_init(); + os_init(NULL); sysinit(); os_sem_init(&test_sem, 0); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd7bb7c6/test/testutil/src/testutil.c ---------------------------------------------------------------------- diff --git a/test/testutil/src/testutil.c b/test/testutil/src/testutil.c index 9a1c0fe..6064cb0 100644 --- a/test/testutil/src/testutil.c +++ b/test/testutil/src/testutil.c @@ -41,7 +41,7 @@ int tu_init(void) { #if MYNEWT_VAL(SELFTEST) - os_init(); + os_init(NULL); sysinit(); #endif
