Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/def_task eced03f21 -> a591f975a


apps; main() is now the entry point to default 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/a591f975
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a591f975
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a591f975

Branch: refs/heads/def_task
Commit: a591f975a103c82d5a3ce777a26b4c1b90e0049e
Parents: eced03f
Author: Marko Kiiskila <[email protected]>
Authored: Mon Jan 23 14:37:35 2017 -0800
Committer: Marko Kiiskila <[email protected]>
Committed: Mon Jan 23 14:37:35 2017 -0800

----------------------------------------------------------------------
 apps/blecent/src/main.c        | 43 ++++-------------------------------
 apps/blecent/syscfg.yml        |  4 ++++
 apps/blehci/src/main.c         |  9 +++-----
 apps/blehci/syscfg.yml         | 24 ++++++++++++++++++++
 apps/bleprph_oic/src/main.c    | 45 ++++++-------------------------------
 apps/bleprph_oic/syscfg.yml    |  5 +++++
 apps/bletest/src/main.c        | 37 ++++--------------------------
 apps/bletest/syscfg.yml        |  4 ++++
 apps/bletiny/src/main.c        | 44 +++++-------------------------------
 apps/bletiny/syscfg.yml        |  4 ++++
 apps/bleuart/src/main.c        | 36 ++++-------------------------
 apps/bleuart/syscfg.yml        |  4 ++++
 apps/ocf_sample/src/main.c     | 45 ++++++++-----------------------------
 apps/ocf_sample/syscfg.yml     |  3 +++
 apps/slinky_oic/src/main.c     | 44 +++++-------------------------------
 apps/slinky_oic/syscfg.yml     |  4 ++++
 apps/spitest/src/main.c        | 40 +++++----------------------------
 apps/spitest/syscfg.yml        |  4 ++++
 apps/splitty/src/main.c        | 40 ++++-----------------------------
 apps/splitty/syscfg.yml        |  4 ++++
 apps/testbench/src/testbench.c | 37 +++---------------------------
 apps/testbench/syscfg.yml      |  4 ++++
 apps/timtest/src/main.c        | 39 ++++----------------------------
 23 files changed, 123 insertions(+), 400 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/blecent/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blecent/src/main.c b/apps/blecent/src/main.c
index 8f6a524..f6de476 100755
--- a/apps/blecent/src/main.c
+++ b/apps/blecent/src/main.c
@@ -42,14 +42,6 @@
 /** Log data. */
 struct log blecent_log;
 
-/** blecent task settings. */
-#define BLECENT_TASK_PRIO           1
-#define BLECENT_STACK_SIZE          (OS_STACK_ALIGN(336))
-
-struct os_eventq blecent_evq;
-struct os_task blecent_task;
-bssnz_t os_stack_t blecent_stack[BLECENT_STACK_SIZE];
-
 static int blecent_gap_event(struct ble_gap_event *event, void *arg);
 
 /**
@@ -447,22 +439,9 @@ blecent_on_sync(void)
 }
 
 /**
- * Event loop for the main blecent task.
- */
-static void
-blecent_task_handler(void *unused)
-{
-    while (1) {
-        os_eventq_run(&blecent_evq);
-    }
-}
-
-/**
  * main
  *
- * The main function for the project. This function initializes the os, calls
- * init_tasks to initialize tasks (and possibly other objects), then starts the
- * OS. We should not return from os start.
+ * All application logic and NimBLE host work is performed in default task.
  *
  * @return int NOTE: this function should never return!
  */
@@ -478,16 +457,6 @@ main(void)
     log_register("blecent", &blecent_log, &log_console_handler, NULL,
                  LOG_SYSLEVEL);
 
-    /* Initialize the eventq for the application task. */
-    os_eventq_init(&blecent_evq);
-
-    /* Create the blecent task.  All application logic and NimBLE host
-     * operations are performed in this task.
-     */
-    os_task_init(&blecent_task, "blecent", blecent_task_handler,
-                 NULL, BLECENT_TASK_PRIO, OS_WAIT_FOREVER,
-                 blecent_stack, BLECENT_STACK_SIZE);
-
     /* Configure the host. */
     log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL,
                  LOG_SYSLEVEL);
@@ -502,14 +471,10 @@ main(void)
     rc = ble_svc_gap_device_name_set("nimble-blecent");
     assert(rc == 0);
 
-    /* Set the default eventq for packages that lack a dedicated task. */
-    os_eventq_dflt_set(&blecent_evq);
-
-    /* Start the OS */
-    os_start();
-
     /* os start should never return. If it does, this should be an error */
-    assert(0);
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
 
     return 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/blecent/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/blecent/syscfg.yml b/apps/blecent/syscfg.yml
index b233e5d..a335ed7 100644
--- a/apps/blecent/syscfg.yml
+++ b/apps/blecent/syscfg.yml
@@ -21,3 +21,7 @@
 syscfg.vals:
     # DEBUG logging is a bit noisy; use INFO.
     LOG_LEVEL: 1
+
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 1
+    OS_MAIN_STACK_SIZE: 336

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/blehci/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blehci/src/main.c b/apps/blehci/src/main.c
index a4a156f..04f4e88 100755
--- a/apps/blehci/src/main.c
+++ b/apps/blehci/src/main.c
@@ -26,11 +26,8 @@ main(void)
     /* Initialize OS */
     sysinit();
 
-    /* Start the OS */
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
-
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
     return 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/blehci/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/blehci/syscfg.yml b/apps/blehci/syscfg.yml
new file mode 100644
index 0000000..51bc588
--- /dev/null
+++ b/apps/blehci/syscfg.yml
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Package: apps/blehci
+
+syscfg.vals:
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 254
+    OS_MAIN_STACK_SIZE: 64

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/bleprph_oic/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph_oic/src/main.c b/apps/bleprph_oic/src/main.c
index b5fa010..04ca451 100755
--- a/apps/bleprph_oic/src/main.c
+++ b/apps/bleprph_oic/src/main.c
@@ -46,14 +46,6 @@
 /** Log data. */
 struct log bleprph_log;
 
-/** bleprph task settings. */
-#define BLEPRPH_TASK_PRIO           1
-#define BLEPRPH_STACK_SIZE          (OS_STACK_ALIGN(336))
-
-static struct os_eventq bleprph_evq;
-static struct os_task bleprph_task;
-static os_stack_t bleprph_stack[BLEPRPH_STACK_SIZE];
-
 static int bleprph_gap_event(struct ble_gap_event *event, void *arg);
 
 /**
@@ -333,20 +325,6 @@ static const oc_handler_t omgr_oc_handler = {
     .init = omgr_app_init,
 };
 
-/*
- * Event loop for the main bleprph task.
- */
-static void
-bleprph_task_handler(void *unused)
-{
-    oc_main_init((oc_handler_t *)&omgr_oc_handler);
-    mgmt_evq_set(&bleprph_evq);
-
-    while (1) {
-        os_eventq_run(&bleprph_evq);
-    }
-}
-
 /**
  * main
  *
@@ -378,18 +356,10 @@ main(void)
     /* Initialize the OIC  */
     log_register("oic", &oc_log, &log_console_handler, NULL, LOG_SYSLEVEL);
 
-    os_eventq_init(&bleprph_evq);
-    os_eventq_dflt_set(&bleprph_evq);
-
-    /*
-     * Create the bleprph task.  All omgr and NimBLE host operations are
-     * performed in this task.
-     */
-    os_task_init(&bleprph_task, "bleprph", bleprph_task_handler,
-                 NULL, BLEPRPH_TASK_PRIO, OS_WAIT_FOREVER,
-                 bleprph_stack, BLEPRPH_STACK_SIZE);
+    ble_hs_evq_set(os_eventq_dflt_get());
 
-    ble_hs_evq_set(&bleprph_evq);
+    oc_main_init((oc_handler_t *)&omgr_oc_handler);
+    mgmt_evq_set(os_eventq_dflt_get());
 
     oc_ble_coap_gatt_srv_init();
     ble_hs_cfg.reset_cb = bleprph_on_reset;
@@ -403,11 +373,10 @@ main(void)
     /* Our light resource */
     hal_gpio_init_out(LED_BLINK_PIN, 1);
 
-    /* Start the OS */
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
+    /* Never exit */
 
     return 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/bleprph_oic/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/bleprph_oic/syscfg.yml b/apps/bleprph_oic/syscfg.yml
index 220978c..18db24b 100644
--- a/apps/bleprph_oic/syscfg.yml
+++ b/apps/bleprph_oic/syscfg.yml
@@ -58,3 +58,8 @@ syscfg.vals:
     STATS_CLI: 1
     LOG_CLI: 1
     STATS_NAMES: 1
+
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 1
+    OS_MAIN_STACK_SIZE: 336
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c
index 11ecb4e..3010a3f 100755
--- a/apps/bletest/src/main.c
+++ b/apps/bletest/src/main.c
@@ -52,7 +52,6 @@
 #include "../src/ble_hs_priv.h"
 #include "bletest_priv.h"
 
-#define BLETEST_HOST_PROC_TASK_PRIO     4
 #define BLETEST_TASK_PRIO               5
 
 /* For LED toggling */
@@ -183,7 +182,6 @@ bletest_multi_adv_instances[BLETEST_CFG_ADV_TEST_INSTANCES] 
= {
 uint32_t g_next_os_time;
 int g_bletest_state;
 struct os_eventq g_bletest_evq;
-struct os_eventq g_bletest_host_proc_evq;
 struct os_callout g_bletest_timer;
 struct os_task bletest_task;
 bssnz_t os_stack_t bletest_stack[BLETEST_STACK_SIZE];
@@ -203,10 +201,6 @@ uint16_t g_bletest_ltk_reply_handle;
 uint32_t g_bletest_hw_id[4];
 struct hci_create_conn g_cc;
 
-/* Host processing task */
-struct os_task bletest_host_proc_task;
-bssnz_t os_stack_t bletest_host_proc_stack[BLETEST_STACK_SIZE];
-
 /* --- For LE encryption testing --- */
 /* Key: 0x4C68384139F574D836BCF34E9DFB01BF */
 const uint8_t g_ble_ll_encrypt_test_key[16] =
@@ -1251,19 +1245,6 @@ bletest_task_handler(void *arg)
 }
 
 /**
- * BLE test host processing task handler
- *
- * @param arg
- */
-void
-bletest_host_proc_task_handler(void *arg)
-{
-    while (1) {
-        os_eventq_run(&g_bletest_host_proc_evq);
-    }
-}
-
-/**
  * main
  *
  * The main function for the project. This function initializes the os, calls
@@ -1318,18 +1299,6 @@ main(void)
     g_led_pin = LED_BLINK_PIN;
     hal_gpio_init_out(g_led_pin, 1);
 
-    /* Initialize eventq for bletest host processing task */
-    os_eventq_init(&g_bletest_host_proc_evq);
-
-    rc = os_task_init(&bletest_host_proc_task, "bletest_host_proc",
-                      bletest_host_proc_task_handler, NULL,
-                      BLETEST_HOST_PROC_TASK_PRIO, OS_WAIT_FOREVER,
-                      bletest_host_proc_stack, BLETEST_STACK_SIZE);
-    assert(rc == 0);
-
-    /* Set the default eventq for packages that lack a dedicated task. */
-    os_eventq_dflt_set(&g_bletest_host_proc_evq);
-
     /* Initialize eventq for bletest task */
     os_eventq_init(&g_bletest_evq);
 
@@ -1338,8 +1307,10 @@ main(void)
                       BLETEST_STACK_SIZE);
     assert(rc == 0);
 
-    /* Start the OS */
-    os_start();
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
+    /* Never returns */
 
     /* os start should never return. If it does, this should be an error */
     assert(0);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/bletest/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/bletest/syscfg.yml b/apps/bletest/syscfg.yml
index 6767a83..7a6cbd5 100644
--- a/apps/bletest/syscfg.yml
+++ b/apps/bletest/syscfg.yml
@@ -21,3 +21,7 @@
 syscfg.vals:
     MSYS_1_BLOCK_COUNT: 16
     BLE_SM_LEGACY: 0
+
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 4
+    OS_MAIN_STACK_SIZE: 256

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index f8dbfbc..37e5728 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -61,10 +61,6 @@
 #include "../src/ble_hs_atomic_priv.h"
 #include "../src/ble_hs_hci_priv.h"
 
-/* BLETINY variables */
-#define BLETINY_STACK_SIZE             (OS_STACK_ALIGN(512))
-#define BLETINY_TASK_PRIO              1
-
 #if MYNEWT_VAL(BLE_ROLE_CENTRAL)
 #define BLETINY_MAX_SVCS               32
 #define BLETINY_MAX_CHRS               64
@@ -75,10 +71,6 @@
 #define BLETINY_MAX_DSCS               1
 #endif
 
-struct os_eventq bletiny_evq;
-struct os_task bletiny_task;
-bssnz_t os_stack_t bletiny_stack[BLETINY_STACK_SIZE];
-
 struct log bletiny_log;
 
 bssnz_t struct bletiny_conn bletiny_conns[MYNEWT_VAL(BLE_MAX_CONNECTIONS)];
@@ -1567,19 +1559,6 @@ bletiny_on_reset(int reason)
 }
 
 /**
- * BLE test task
- *
- * @param arg
- */
-static void
-bletiny_task_handler(void *arg)
-{
-    while (1) {
-        os_eventq_run(&bletiny_evq);
-    }
-}
-
-/**
  * main
  *
  * The main function for the project. This function initializes the os, calls
@@ -1628,16 +1607,6 @@ main(void)
     log_register("bletiny", &bletiny_log, &log_console_handler, NULL,
                  LOG_SYSLEVEL);
 
-    /* Initialize eventq for the application task. */
-    os_eventq_init(&bletiny_evq);
-
-    /* Create the bletiny task.  All application logic and NimBLE host
-     * operations are performed in this task.
-     */
-    os_task_init(&bletiny_task, "bletiny", bletiny_task_handler,
-                 NULL, BLETINY_TASK_PRIO, OS_WAIT_FOREVER,
-                 bletiny_stack, BLETINY_STACK_SIZE);
-
     /* Initialize the NimBLE host configuration. */
     log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL,
                  LOG_SYSLEVEL);
@@ -1657,15 +1626,12 @@ main(void)
     /* Create a callout (timer).  This callout is used by the "tx" bletiny
      * command to repeatedly send packets of sequential data bytes.
      */
-    os_callout_init(&bletiny_tx_timer, &bletiny_evq, bletiny_tx_timer_cb,
-                    NULL);
-
-    /* Set the default eventq for packages that lack a dedicated task. */
-    os_eventq_dflt_set(&bletiny_evq);
-
-    /* Start the OS */
-    os_start();
+    os_callout_init(&bletiny_tx_timer, os_eventq_dflt_get(),
+                    bletiny_tx_timer_cb, NULL);
 
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
     /* os start should never return. If it does, this should be an error */
     assert(0);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/bletiny/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/bletiny/syscfg.yml b/apps/bletiny/syscfg.yml
index 81a62f0..eadbe01 100644
--- a/apps/bletiny/syscfg.yml
+++ b/apps/bletiny/syscfg.yml
@@ -31,3 +31,7 @@ syscfg.vals:
 
     # Disable eddystone beacons.
     BLE_EDDYSTONE: 0
+
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 1
+    OS_MAIN_STACK_SIZE: 512

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/bleuart/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleuart/src/main.c b/apps/bleuart/src/main.c
index 241fff2..094c2fa 100755
--- a/apps/bleuart/src/main.c
+++ b/apps/bleuart/src/main.c
@@ -52,14 +52,6 @@
 #include "nmgrble/newtmgr_ble.h"
 #include "bleuart/bleuart.h"
 
-/** bleuart task settings. */
-#define bleuart_TASK_PRIO           1
-#define bleuart_STACK_SIZE          (OS_STACK_ALIGN(336))
-
-struct os_eventq bleuart_evq;
-struct os_task bleuart_task;
-bssnz_t os_stack_t bleuart_stack[bleuart_STACK_SIZE];
-
 static int bleuart_gap_event(struct ble_gap_event *event, void *arg);
 
 /**
@@ -179,15 +171,6 @@ bleuart_on_sync(void)
 }
 
 /**
- * Event loop for the main bleuart task.
- */
-static void
-bleuart_task_handler(void *unused)
-{
-    os_eventq_run(&bleuart_evq);
-}
-
-/**
  * main
  *
  * The main function for the project. This function initializes the os, calls
@@ -204,10 +187,6 @@ main(void)
     /* Initialize OS */
     sysinit();
 
-    os_task_init(&bleuart_task, "bleuart", bleuart_task_handler,
-                 NULL, bleuart_TASK_PRIO, OS_WAIT_FOREVER,
-                 bleuart_stack, bleuart_STACK_SIZE);
-
     /* Initialize the BLE host. */
     log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL,
                  LOG_SYSLEVEL);
@@ -216,21 +195,14 @@ main(void)
     rc = bleuart_gatt_svr_init();
     assert(rc == 0);
 
-    /* Initialize eventq */
-    os_eventq_init(&bleuart_evq);
-
     /* Set the default device name. */
     rc = ble_svc_gap_device_name_set("Mynewt_BLEuart");
     assert(rc == 0);
 
-    /* Set the default eventq for packages that lack a dedicated task. */
-    os_eventq_dflt_set(&bleuart_evq);
-
-    /* Start the OS */
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
+    /* Never exit */
 
     return 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/bleuart/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/bleuart/syscfg.yml b/apps/bleuart/syscfg.yml
index 15ddb95..a92d331 100644
--- a/apps/bleuart/syscfg.yml
+++ b/apps/bleuart/syscfg.yml
@@ -22,3 +22,7 @@ syscfg.vals:
     # Disable unused roles; bleuart is a peripheral-only app.
     BLE_ROLE_OBSERVER: 0
     BLE_ROLE_CENTRAL: 0
+
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 1
+    OS_MAIN_STACK_SIZE: 336

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/ocf_sample/src/main.c
----------------------------------------------------------------------
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
index 55d1b81..eb25cf1 100644
--- a/apps/ocf_sample/src/main.c
+++ b/apps/ocf_sample/src/main.c
@@ -35,13 +35,6 @@
 #include "ocf_sample.h"
 #endif
 
-/** Task for handling OCF-specific events. */
-#define OCF_MAIN_TASK_PRIO          (8)
-#define OCF_MAIN_TASK_STACK_SIZE    (OS_STACK_ALIGN(512))
-static os_stack_t ocf_stack[OCF_MAIN_TASK_STACK_SIZE];
-struct os_task ocf_main_task;
-struct os_eventq ocf_main_evq;
-
 #if (MYNEWT_VAL(OC_CLIENT) == 1)
 static void issue_requests(void);
 #endif
@@ -240,42 +233,20 @@ oc_handler_t ocf_handler = {
  };
 
 static void
-ocf_main_task_handler(void *arg)
+ocf_init_tasks(void)
 {
 #if (MYNEWT_VAL(OC_CLIENT) == 1)
-    os_callout_init(&callout, &ocf_main_evq, stop_observe, NULL);
+    os_callout_init(&callout, os_eventq_dflt_get(), stop_observe, NULL);
 #endif
-    while (1) {
-        os_eventq_run(&ocf_main_evq);
-    }
-    oc_main_shutdown();
-}
-
-static void
-ocf_init_tasks(void)
-{
-    int rc;
-
-    rc = os_task_init(&ocf_main_task, "ocf", ocf_main_task_handler, NULL,
-            OCF_MAIN_TASK_PRIO, OS_WAIT_FOREVER, ocf_stack,
-            OCF_MAIN_TASK_STACK_SIZE);
-    assert(rc == 0);
-
-    /* Initialize eventq */
-    os_eventq_init(&ocf_main_evq);
-
-    /* Set the default eventq for packages that lack a dedicated task. */
-    os_eventq_dflt_set(&ocf_main_evq);
-
     oc_main_init(&ocf_handler);
 }
 
 int
 main(int argc, char **argv)
 {
-    int rc;
-
-    (void)rc;
+#ifdef ARCH_sim
+    mcu_sim_parse_args(argc, argv);
+#endif
 
     /* Initialize OS */
     sysinit();
@@ -286,8 +257,10 @@ main(int argc, char **argv)
 
     ocf_init_tasks();
 
-    /* Start the OS */
-    os_start();
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
+    /* Never returns */
 
     /* os start should never return. If it does, this should be an error */
     assert(0);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/ocf_sample/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/ocf_sample/syscfg.yml b/apps/ocf_sample/syscfg.yml
index 0943080..f9e6360 100644
--- a/apps/ocf_sample/syscfg.yml
+++ b/apps/ocf_sample/syscfg.yml
@@ -20,3 +20,6 @@
 syscfg.vals:
     SHELL_TASK: 1
 
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 8
+    OS_MAIN_STACK_SIZE: 512

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/slinky_oic/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky_oic/src/main.c b/apps/slinky_oic/src/main.c
index 5eb0d8d..9c65537 100755
--- a/apps/slinky_oic/src/main.c
+++ b/apps/slinky_oic/src/main.c
@@ -56,13 +56,6 @@ static volatile int g_task1_loops;
 #define TASK2_STACK_SIZE    OS_STACK_ALIGN(64)
 static struct os_task task2;
 
-/* Task 3 */
-#define TASK3_PRIO (10)
-#define TASK3_STACK_SIZE    OS_STACK_ALIGN(512)
-static struct os_task task3;
-
-static struct os_eventq slinky_oic_evq;
-
 static struct log my_log;
 
 static volatile int g_task2_loops;
@@ -224,20 +217,6 @@ static const oc_handler_t omgr_oc_handler = {
 };
 
 /**
- * This task serves as a container for the shell and newtmgr packages.  These
- * packages enqueue timer events when they need this task to do work.
- */
-static void
-task3_handler(void *arg)
-{
-    oc_main_init((oc_handler_t *)&omgr_oc_handler);
-
-    while (1) {
-        os_eventq_run(&slinky_oic_evq);
-    }
-}
-
-/**
  * init_tasks
  *
  * Called by main.c after sysinit(). This function performs initializations
@@ -264,19 +243,8 @@ init_tasks(void)
     os_task_init(&task2, "task2", task2_handler, NULL,
             TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE);
 
-    pstack = malloc(sizeof(os_stack_t)*TASK3_STACK_SIZE);
-    assert(pstack);
-
-    os_task_init(&task3, "task3", task3_handler, NULL,
-            TASK3_PRIO, OS_WAIT_FOREVER, pstack, TASK3_STACK_SIZE);
-
-    /* Initialize eventq and designate it as the default.  Packages that need
-     * to schedule work items will piggyback on this eventq.  Example packages
-     * which do this are sys/shell and mgmt/newtmgr.
-     */
-    os_eventq_init(&slinky_oic_evq);
-    os_eventq_dflt_set(&slinky_oic_evq);
-    mgmt_evq_set(&slinky_oic_evq);
+    oc_main_init((oc_handler_t *)&omgr_oc_handler);
+    mgmt_evq_set(os_eventq_dflt_get());
 }
 
 /**
@@ -330,10 +298,10 @@ main(int argc, char **argv)
 
     init_tasks();
 
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
+    /* Never returns */
 
     return rc;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/slinky_oic/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/slinky_oic/syscfg.yml b/apps/slinky_oic/syscfg.yml
index 6b82a40..6a31fce 100644
--- a/apps/slinky_oic/syscfg.yml
+++ b/apps/slinky_oic/syscfg.yml
@@ -41,3 +41,7 @@ syscfg.vals:
     OC_SERVER: 1
     OC_TRANSPORT_IP: 1
     OC_TRANSPORT_SERIAL: 1
+
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 10
+    OS_MAIN_STACK_SIZE: 512

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/spitest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/spitest/src/main.c b/apps/spitest/src/main.c
index 003baec..2e390f9 100755
--- a/apps/spitest/src/main.c
+++ b/apps/spitest/src/main.c
@@ -46,13 +46,6 @@ void *spi_cb_arg;
 #define TASK1_STACK_SIZE    OS_STACK_ALIGN(1024)
 struct os_task task1;
 
-/* Task 3 */
-#define TASK2_PRIO (2)
-#define TASK2_STACK_SIZE    OS_STACK_ALIGN(512)
-static struct os_task task2;
-
-static struct os_eventq spitest_evq;
-
 /* Global test semaphore */
 struct os_sem g_test_sem;
 
@@ -389,18 +382,6 @@ task1_handler(void *arg)
 #endif
 
 /**
- * This task serves as a container for the shell and newtmgr packages.  These
- * packages enqueue timer events when they need this task to do work.
- */
-static void
-task2_handler(void *arg)
-{
-    while (1) {
-        os_eventq_run(&spitest_evq);
-    }
-}
-
-/**
  * init_tasks
  *
  * Called by main.c after sysinit(). This function performs initializations
@@ -413,6 +394,8 @@ init_tasks(void)
 {
     os_stack_t *pstack;
 
+    (void)pstack;
+
     /* Initialize global test semaphore */
     os_sem_init(&g_test_sem, 0);
 
@@ -423,19 +406,6 @@ init_tasks(void)
     os_task_init(&task1, "task1", task1_handler, NULL,
             TASK1_PRIO, OS_WAIT_FOREVER, pstack, TASK1_STACK_SIZE);
 #endif
-
-    pstack = malloc(sizeof(os_stack_t)*TASK2_STACK_SIZE);
-    assert(pstack);
-
-    os_task_init(&task2, "task2", task2_handler, NULL,
-            TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE);
-
-    /* Initialize eventq and designate it as the default.  Packages that need
-     * to schedule work items will piggyback on this eventq.  Example packages
-     * which do this are sys/shell and mgmt/newtmgr.
-     */
-    os_eventq_init(&spitest_evq);
-    os_eventq_dflt_set(&spitest_evq);
 }
 
 /**
@@ -458,9 +428,11 @@ main(int argc, char **argv)
 
     sysinit();
     init_tasks();
-    os_start();
 
-    /* os start should never return. If it does, this should be an error */
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
+    /* Never returns */
     assert(0);
 
     return rc;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/spitest/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/spitest/syscfg.yml b/apps/spitest/syscfg.yml
index a790cfb..7207817 100644
--- a/apps/spitest/syscfg.yml
+++ b/apps/spitest/syscfg.yml
@@ -20,3 +20,7 @@
 
 syscfg.vals:
     SHELL_TASK: 0
+
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 2
+    OS_MAIN_STACK_SIZE: 512

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/splitty/src/main.c
----------------------------------------------------------------------
diff --git a/apps/splitty/src/main.c b/apps/splitty/src/main.c
index b63dbb5..f487381 100755
--- a/apps/splitty/src/main.c
+++ b/apps/splitty/src/main.c
@@ -54,11 +54,6 @@ static volatile int g_task1_loops;
 #define TASK2_STACK_SIZE    OS_STACK_ALIGN(32)
 static struct os_task task2;
 
-/* Task 3 */
-#define TASK3_PRIO (10)
-#define TASK3_STACK_SIZE    OS_STACK_ALIGN(428)
-static struct os_task task3;
-
 static struct log my_log;
 
 static volatile int g_task2_loops;
@@ -69,8 +64,6 @@ static struct os_sem g_test_sem;
 /* For LED toggling */
 static int g_led_pin;
 
-static struct os_eventq splitty_evq;
-
 STATS_SECT_START(gpio_stats)
 STATS_SECT_ENTRY(toggles)
 STATS_SECT_END
@@ -143,18 +136,6 @@ task2_handler(void *arg)
 }
 
 /**
- * This task serves as a container for the shell and newtmgr packages.  These
- * packages enqueue timer events when they need this task to do work.
- */
-static void
-task3_handler(void *arg)
-{
-    while (1) {
-        os_eventq_run(&splitty_evq);
-    }
-}
-
-/**
  * init_tasks
  *
  * Called by main.c after sysinit(). This function performs initializations
@@ -182,18 +163,6 @@ init_tasks(void)
     os_task_init(&task2, "task2", task2_handler, NULL,
             TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE);
 
-    pstack = malloc(sizeof(os_stack_t)*TASK3_STACK_SIZE);
-    assert(pstack);
-
-    os_task_init(&task3, "task3", task3_handler, NULL,
-            TASK3_PRIO, OS_WAIT_FOREVER, pstack, TASK3_STACK_SIZE);
-
-    /* Initialize eventq and designate it as the default.  Packages that need
-     * to schedule work items will piggyback on this eventq.  Example packages
-     * which do this are sys/shell and mgmt/newtmgr.
-     */
-    os_eventq_init(&splitty_evq);
-    os_eventq_dflt_set(&splitty_evq);
 }
 
 /**
@@ -231,10 +200,9 @@ main(int argc, char **argv)
 
     init_tasks();
 
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
-    assert(0);
-
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
+    /* Never exit */
     return rc;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/splitty/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/splitty/syscfg.yml b/apps/splitty/syscfg.yml
index 7ff1dfb..d7c1b35 100644
--- a/apps/splitty/syscfg.yml
+++ b/apps/splitty/syscfg.yml
@@ -27,3 +27,7 @@ syscfg.vals:
 
     # Log reboot messages to a flash circular buffer.
     REBOOT_LOG_FCB: 1
+
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 10
+    OS_MAIN_STACK_SIZE: 428

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/testbench/src/testbench.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench.c b/apps/testbench/src/testbench.c
index 47bddb4..a33a711 100644
--- a/apps/testbench/src/testbench.c
+++ b/apps/testbench/src/testbench.c
@@ -86,11 +86,6 @@ int init_tasks(void);
 #define TESTTASK_STACK_SIZE    OS_STACK_ALIGN(256)
 static struct os_task testtask;
 
-/* newtmgr Task */
-#define NMGRTASK_PRIO (2)
-#define NMGRTASK_STACK_SIZE    OS_STACK_ALIGN(768)
-static struct os_task nmgrtask;
-
 /* For LED toggling */
 int g_led_pin;
 
@@ -118,8 +113,6 @@ int forcefail; /* to optionally force a fail on a tests */
 
 char buildID[TESTBENCH_BUILDID_SZ];
 
-static struct os_eventq run_evq;
-
 struct runtest_evq_arg test_event_arg;
 char runtest_token[RUNTEST_REQ_SIZE];
 static int testbench_runtests(struct os_event *ev);
@@ -285,18 +278,6 @@ testtask_handler(void *arg)
 }
 
 /*
- * Event callbacks are automatically run and this is how
- * testbench_runtests (and the subsequent test suites) are intiated
- */
-static void
-nmgrtask_handler(void *arg)
-{
-    while (1) {
-        os_eventq_run(&run_evq);
-    }
-}
-
-/*
  * init_tasks include test workers 
  */
 int
@@ -323,12 +304,6 @@ init_tasks(void)
     assert(stack4);
     stack4_size = TASK4_STACK_SIZE;
 
-    teststack = malloc(sizeof(os_stack_t) * NMGRTASK_STACK_SIZE);
-    assert(teststack);
-    os_task_init(&nmgrtask, "nmgrtask", nmgrtask_handler, NULL,
-                 NMGRTASK_PRIO, OS_WAIT_FOREVER, teststack,
-                 NMGRTASK_STACK_SIZE);
-
     teststack = malloc(sizeof(os_stack_t) * TESTTASK_STACK_SIZE);
     assert(teststack);
     os_task_init(&testtask, "testtask", testtask_handler, NULL,
@@ -379,12 +354,6 @@ main(int argc, char **argv)
     cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF);
     log_register("testlog", &testlog, &log_cbmem_handler, &cbmem, 
LOG_SYSLEVEL);
 
-    /*
-     * Initialize eventq and designate it as the default.
-     */
-    os_eventq_init(&run_evq);
-    os_eventq_dflt_set(&run_evq);
-
     log_reboot(hal_reset_cause());
 
     conf_load();
@@ -408,9 +377,9 @@ main(int argc, char **argv)
 
     testbench_test_init(); /* initialize globals include blink duty cycle */
 
-    os_start();
-
-    /* os start should never return. If it does, this should be an error */
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
     assert(0);
 
     return rc;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/testbench/syscfg.yml
----------------------------------------------------------------------
diff --git a/apps/testbench/syscfg.yml b/apps/testbench/syscfg.yml
index eadc7f3..dc3597a 100644
--- a/apps/testbench/syscfg.yml
+++ b/apps/testbench/syscfg.yml
@@ -31,3 +31,7 @@ syscfg.vals:
     RUNTEST_NEWTMGR: 1
 
 #    BSP_ARDUINO_ZERO_PRO: 1
+
+    # Default task settings
+    OS_MAIN_TASK_PRIO: 2
+    OS_MAIN_STACK_SIZE: 768

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a591f975/apps/timtest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/timtest/src/main.c b/apps/timtest/src/main.c
index a1264e8..1326612 100755
--- a/apps/timtest/src/main.c
+++ b/apps/timtest/src/main.c
@@ -40,13 +40,6 @@ struct os_task task1;
 #define TASK2_STACK_SIZE    OS_STACK_ALIGN(64)
 struct os_task task2;
 
-/* Task 3 */
-#define TASK3_PRIO (3)
-#define TASK3_STACK_SIZE    OS_STACK_ALIGN(512)
-static struct os_task task3;
-
-static struct os_eventq timtest_evq;
-
 #define TASK2_TIMER_NUM     (2)
 #define TASK2_TIMER_FREQ    (31250)
 
@@ -145,18 +138,6 @@ task2_handler(void *arg)
 }
 
 /**
- * This task serves as a container for the shell and newtmgr packages.  These
- * packages enqueue timer events when they need this task to do work.
- */
-static void
-task3_handler(void *arg)
-{
-    while (1) {
-        os_eventq_run(&timtest_evq);
-    }
-}
-
-/**
  * init_tasks
  *
  * Called by main.c after sysinit(). This function performs initializations
@@ -199,19 +180,6 @@ init_tasks(void)
 
     os_task_init(&task2, "task2", task2_handler, NULL,
             TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE);
-
-    pstack = malloc(sizeof(os_stack_t)*TASK3_STACK_SIZE);
-    assert(pstack);
-
-    os_task_init(&task3, "task3", task3_handler, NULL,
-            TASK3_PRIO, OS_WAIT_FOREVER, pstack, TASK3_STACK_SIZE);
-
-    /* Initialize eventq and designate it as the default.  Packages that need
-     * to schedule work items will piggyback on this eventq.  Example packages
-     * which do this are sys/shell and mgmt/newtmgr.
-     */
-    os_eventq_init(&timtest_evq);
-    os_eventq_dflt_set(&timtest_evq);
 }
 
 /**
@@ -230,10 +198,11 @@ main(int argc, char **argv)
 
     sysinit();
     init_tasks();
-    os_start();
-
-    assert(0);
 
+    while (1) {
+        os_eventq_run(os_eventq_dflt_get());
+    }
+    /* Never exit */
     return rc;
 }
 

Reply via email to