So you are saying that there will still be well-defined places where things get initialized and that there will be defined ranges for these stages? For example:
0 - 99 Before os_init() is called. 100-199 in os_init() after os_init() code executes 200-299: in os_start() somewhere Realize that the above are just examples and not meant to be actual ranges or actual places where we initalize. > On Jan 23, 2017, at 9:03 PM, Sterling Hughes > <[email protected]> wrote: > > Also, one other thing to look at with the new sysinit changes. I think we > probably need to revise the ordering on device initialization. > > Right now device init has the following: > > /* > * Initialization order, defines when a device should be initialized > * by the Mynewt kernel. > * > */ > #define OS_DEV_INIT_PRIMARY (1) > #define OS_DEV_INIT_SECONDARY (2) > #define OS_DEV_INIT_KERNEL (3) > > #define OS_DEV_INIT_F_CRITICAL (1 << 0) > > > #define OS_DEV_INIT_PRIO_DEFAULT (0xff) > > And these stages are called: > > In os_init(): PRIMARY, SECONDARY > In os_start(): KERNEL > > I think it makes sense to more clearly map these stages to the new sparsely > designed sysinit stages, and add device init hooks throughout the system > startup. > > Given the new sparse IDs, I’m thinking that we could do it per-ID range, i.e. > os_dev_initializeall(100), os_dev_initializeall(200), etc. Within that > range, devices could be initialized by priority. > > Thoughts? > > Sterling > > On 23 Jan 2017, at 19:12, Jacob Rosenthal wrote: > >> Looks like this breaks splitty as app, bleprph as loader >> Error: Syscfg ambiguities detected: >> Setting: OS_MAIN_TASK_PRIO, Packages: [apps/bleprph, apps/splitty] >> Setting history (newest -> oldest): >> OS_MAIN_TASK_PRIO: [apps/splitty:10, apps/bleprph:1, kernel/os:0xfe] >> >> Setting OS_MAIN_TASK_PRIO in splitty to 1 made this go away..but Dont know >> if theres other complications related to that though.Then it gets stuck >> after confirming image and resetting while entering the app image at >> gcc_startup_nrf51.s Default_Handler >> >> On Mon, Jan 23, 2017 at 4:48 PM, marko kiiskila <[email protected]> wrote: >> >>> I pushed this change to develop. >>> >>> You’ll need to update the newt tool as part of this change; as sysinit >>> calls should not include call to os_init() anymore. >>> >>> After this change you can specify multiple calls to be made to your package >>> from sysinit(). >>> Tell newt to do this by having this kind of block in your pkg.yml. >>> >>> pkg.init: >>> ble_hs_init: 200 >>> ble_hs_init2: 500 >>> >>> I.e. in pkg.init block specify function name followed by call order. >>> >>> And app main() should minimally look like: >>> >>> int >>> main(int argc, char **argv) >>> { >>> #ifdef ARCH_sim >>> mcu_sim_parse_args(argc, argv); >>> #endif >>> >>> sysinit(); >>> >>> while (1) { >>> os_eventq_run(os_eventq_dflt_get()); >>> } >>> assert(0); >>> >>> return rc; >>> } >>> >>> So there’s a call to mcu_sim_parse_args() (in case app can execute in >>> simulator), >>> call to sysinit(), which calls all the package init routines, followed by >>> this main task >>> calling os_eventq_run() for default task. >>> >>> I might also want to lock the scheduler for the duration of call to >>> sysinit(); >>> but we don’t have that facility yet. This might be a good time to add it? >>> >>>> On Jan 21, 2017, at 9:00 AM, will sanfilippo <[email protected]> wrote: >>>> >>>> +1 sounds good to me. I dont think the amount of changes to the app are >>> all that many and folks should be able to deal with them pretty easily. >>>> >>>> >>>>> On Jan 20, 2017, at 1:35 PM, Sterling Hughes < >>> [email protected]> wrote: >>>>> >>>>> Hey, >>>>> >>>>> Changed the subject to call this out to more people. :-) >>>>> >>>>> Response above, because I generally think this is on the right track. >>> In my view, we should bite the bullet prior to 1.0, and move to this >>> approach. I think it greatly simplifies startup, and the concept of the >>> default event queue now ties into their being a default task. >>>>> >>>>> That said, I’m open to concerns from others — it is a fairly major >>> change to system startup, and it would be last minute. With Fabio’s last >>> changes to the hal_flash* APIs, I think we’re mostly good for 1.0 >>> otherwise, and should roll beta2 soon after this. >>>>> >>>>> Sterling >>>>> >>>>> On 20 Jan 2017, at 13:26, marko kiiskila wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> this is continuation of effort Chris started to improve sysinit. >>>>>> >>>>>> What I’ve started on this branch is an attempt to (hopefully) make >>> things >>>>>> better. >>>>>> >>>>>> I added a concept of “main task”, which would be created by the system >>>>>> automatically, and it’s job would be to handle events from the os >>> default >>>>>> event queue. >>>>>> Currently, you have to create this queue, and assign processing of it >>>>>> to a task inside your app. >>>>>> >>>>>> Another thing I’m doing here is move the call to main() to happen >>>>>> within this task’s context. At the moment this happens before OS >>>>>> has been initialized, or started. >>>>>> So now you can count on OS being up when doing package initialization. >>>>>> At the moment quite a few packages queue a 'start event’ to take place >>>>>> right after OS has started. This would not be needed anymore, as >>>>>> you can do everything during the init routine itself. >>>>>> >>>>>> Also, the default event queue gets assigned, and initialized before >>> any of >>>>>> the packages have had their respective init routines called. >>> Previously, >>>>>> this often happened after sysinit() had been called, and packages did >>>>>> not know where to queue that start event. >>>>>> >>>>>> I checked this in to a branch, and wanted to hear yay/nay before >>> proceeding >>>>>> with this further. As this is a bit of an architectural change. >>>>>> Also, I want to hear if this should make it’s way in before 1.0. >>>>>> >>>>>> More specifically, take a look at how applications would have to >>> change their >>>>>> main(); instead of calling os_start() in the end, they would start >>> processing >>>>>> events from default queue. And they’d have specify the priority, and >>> stack >>>>>> size of the main task. >>>>>> >>>>>> Another change I was going to make would involve changes in the way >>>>>> packages register routines to be called from sysinit(). >>>>>> Currently, there’s only one init() per-package. >>>>>> I was going to make it possible for a package to register multiple >>> routines >>>>>> for this. That way you can break the initialization to multiple parts >>> in cases >>>>>> where packages have interdependencies between each other. >>>>>> Also, the app should be able to interject pieces of code that gets >>> executed >>>>>> in the middle of sysinit(). >>>>>> To make this easier, I was going to make the current initialization >>> level >>>>>> numbering a bit wider. So the existing level “1” would become “100”, >>>>>> and “2” -> “200”. >>>>>> >>>>>> So, feedback about this approach, and then whether this is 1.0 or 1.1 >>>>>> kind of thing. >>>>>> >>>>>> Thanks, >>>>>> M >>>>>> >>>>>>> Begin forwarded message: >>>>>>> >>>>>>> From: [email protected] >>>>>>> Subject: incubator-mynewt-core git commit: os; spin up OS before >>> calling. main() gets called in context of main task. >>>>>>> Date: January 20, 2017 at 12:18:03 PM PST >>>>>>> To: [email protected] >>>>>>> Reply-To: [email protected] >>>>>>> >>>>>>> Repository: incubator-mynewt-core >>>>>>> Updated Branches: >>>>>>> refs/heads/def_task [created] 0c9fe5e2b >>>>>>> >>>>>>> >>>>>>> os; spin up OS before calling. main() gets called in context of >>>>>>> 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/0c9fe5e2 >>>>>>> Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/tree/0c9fe5e2 >>>>>>> Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/diff/0c9fe5e2 >>>>>>> >>>>>>> Branch: refs/heads/def_task >>>>>>> Commit: 0c9fe5e2b3c6d3f6ca34e570e34eac6e55a40c66 >>>>>>> Parents: 449ef81 >>>>>>> Author: Marko Kiiskila <[email protected]> >>>>>>> Authored: Fri Jan 20 12:16:20 2017 -0800 >>>>>>> Committer: Marko Kiiskila <[email protected]> >>>>>>> Committed: Fri Jan 20 12:16:20 2017 -0800 >>>>>>> >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> apps/bleprph/src/main.c | 47 +- >>>>>>> apps/bleprph/syscfg.yml | 4 + >>>>>>> apps/oled_test/pkg.yml | 47 ++ >>>>>>> apps/oled_test/src/main.c | 467 >>> +++++++++++++++++++ >>>>>>> apps/slinky/src/main.c | 44 +- >>>>>>> apps/slinky/syscfg.yml | 3 + >>>>>>> hw/mcu/native/src/hal_system.c | 16 +- >>>>>>> kernel/os/include/os/os.h | 2 + >>>>>>> kernel/os/include/os/os_eventq.h | 1 - >>>>>>> kernel/os/src/os.c | 24 + >>>>>>> kernel/os/src/os_eventq.c | 23 +- >>>>>>> kernel/os/syscfg.yml | 6 + >>>>>>> kernel/os/test/src/eventq_test.c | 1 - >>>>>>> kernel/os/test/src/mempool_test.c | 1 + >>>>>>> kernel/os/test/src/mutex_test.c | 3 +- >>>>>>> kernel/os/test/src/os_test.c | 5 +- >>>>>>> kernel/os/test/src/sem_test.c | 73 +-- >>>>>>> .../test/src/testcases/event_test_poll_0timo.c | 2 +- >>>>>>> .../src/testcases/event_test_poll_single_sr.c | 3 +- >>>>>>> .../os/test/src/testcases/event_test_poll_sr.c | 1 + >>>>>>> .../src/testcases/event_test_poll_timeout_sr.c | 5 +- >>>>>>> kernel/os/test/src/testcases/event_test_src.c | 3 +- >>>>>>> kernel/os/test/src/testcases/os_callout_test.c | 7 +- >>>>>>> .../test/src/testcases/os_callout_test_speak.c | 7 +- >>>>>>> .../test/src/testcases/os_callout_test_stop.c | 9 +- >>>>>>> libc/baselibc/src/start.c | 9 + >>>>>>> .../mn_socket/test/src/testcases/socket_tests.c | 1 + >>>>>>> test/testutil/src/testutil.c | 1 + >>>>>>> 28 files changed, 660 insertions(+), 155 deletions(-) >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/apps/bleprph/src/main.c >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c >>>>>>> index 65911a5..e75264d 100755 >>>>>>> --- a/apps/bleprph/src/main.c >>>>>>> +++ b/apps/bleprph/src/main.c >>>>>>> @@ -42,14 +42,6 @@ >>>>>>> /** Log data. */ >>>>>>> struct log bleprph_log; >>>>>>> >>>>>>> -/** bleprph task settings. */ >>>>>>> -#define BLEPRPH_TASK_PRIO 1 >>>>>>> -#define BLEPRPH_STACK_SIZE (OS_STACK_ALIGN(428)) >>>>>>> - >>>>>>> -struct os_eventq bleprph_evq; >>>>>>> -struct os_task bleprph_task; >>>>>>> -bssnz_t os_stack_t *bleprph_stack; >>>>>>> - >>>>>>> static int bleprph_gap_event(struct ble_gap_event *event, void *arg); >>>>>>> >>>>>>> /** >>>>>>> @@ -248,17 +240,6 @@ bleprph_on_sync(void) >>>>>>> } >>>>>>> >>>>>>> /** >>>>>>> - * Event loop for the main bleprph task. >>>>>>> - */ >>>>>>> -static void >>>>>>> -bleprph_task_handler(void *unused) >>>>>>> -{ >>>>>>> - while (1) { >>>>>>> - os_eventq_run(&bleprph_evq); >>>>>>> - } >>>>>>> -} >>>>>>> - >>>>>>> -/** >>>>>>> * main >>>>>>> * >>>>>>> * The main function for the project. This function initializes the >>> os, calls >>>>>>> @@ -282,19 +263,6 @@ main(void) >>>>>>> log_register("bleprph", &bleprph_log, &log_console_handler, NULL, >>>>>>> LOG_SYSLEVEL); >>>>>>> >>>>>>> - /* Initialize eventq */ >>>>>>> - os_eventq_init(&bleprph_evq); >>>>>>> - >>>>>>> - bleprph_stack = malloc(sizeof bleprph_stack * >>> BLEPRPH_STACK_SIZE); >>>>>>> - assert(bleprph_stack != NULL); >>>>>>> - >>>>>>> - /* Create the bleprph task. All application logic 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); >>>>>>> - >>>>>>> /* Initialize the NimBLE host configuration. */ >>>>>>> log_register("ble_hs", &ble_hs_log, &log_console_handler, NULL, >>>>>>> LOG_SYSLEVEL); >>>>>>> @@ -309,9 +277,6 @@ main(void) >>>>>>> rc = ble_svc_gap_device_name_set("nimble-bleprph"); >>>>>>> assert(rc == 0); >>>>>>> >>>>>>> - /* Set the default eventq for packages that lack a dedicated >>> task. */ >>>>>>> - os_eventq_dflt_set(&bleprph_evq); >>>>>>> - >>>>>>> conf_load(); >>>>>>> >>>>>>> /* If this app is acting as the loader in a split image setup, jump >>> into >>>>>>> @@ -327,11 +292,11 @@ main(void) >>>>>>> } >>>>>>> #endif >>>>>>> >>>>>>> - /* Start the OS */ >>>>>>> - os_start(); >>>>>>> - >>>>>>> - /* os start should never return. If it does, this should be an >>> error */ >>>>>>> - assert(0); >>>>>>> - >>>>>>> + /* >>>>>>> + * As the last thing, process events from default event queue. >>>>>>> + */ >>>>>>> + while (1) { >>>>>>> + os_eventq_run(os_eventq_dflt_get()); >>>>>>> + } >>>>>>> return 0; >>>>>>> } >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/apps/bleprph/syscfg.yml >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/apps/bleprph/syscfg.yml b/apps/bleprph/syscfg.yml >>>>>>> index 6db8c1e..f40e959 100644 >>>>>>> --- a/apps/bleprph/syscfg.yml >>>>>>> +++ b/apps/bleprph/syscfg.yml >>>>>>> @@ -42,3 +42,7 @@ syscfg.vals: >>>>>>> >>>>>>> # Enable Config. >>>>>>> CONFIG_NEWTMGR: 1 >>>>>>> + >>>>>>> + # OS main/default task >>>>>>> + OS_MAIN_TASK_PRIO: 1 >>>>>>> + OS_MAIN_STACK_SIZE: 428 >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/apps/oled_test/pkg.yml >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/apps/oled_test/pkg.yml b/apps/oled_test/pkg.yml >>>>>>> new file mode 100644 >>>>>>> index 0000000..89c9cd0 >>>>>>> --- /dev/null >>>>>>> +++ b/apps/oled_test/pkg.yml >>>>>>> @@ -0,0 +1,47 @@ >>>>>>> +# >>>>>>> +# 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. >>>>>>> +# >>>>>>> + >>>>>>> +pkg.name: apps/oled_test >>>>>>> +pkg.type: app >>>>>>> +pkg.description: Example application which exercises OLED_display. >>>>>>> +pkg.author: "Apache Mynewt <[email protected]>" >>>>>>> +pkg.homepage: "http://mynewt.apache.org/" >>>>>>> +pkg.keywords: >>>>>>> + >>>>>>> +pkg.deps: >>>>>>> + - drivers/mpu_3050 >>>>>>> + - fs/nffs >>>>>>> + - libs/console/full >>>>>>> + - libs/flash_test >>>>>>> + - libs/imgmgr >>>>>>> + - libs/newtmgr >>>>>>> + - libs/os >>>>>>> + - libs/shell >>>>>>> + - libs/util >>>>>>> + - sys/config >>>>>>> + - sys/id >>>>>>> + >>>>>>> +pkg.cflags: >>>>>>> + - "-DSTATS_NAME_ENABLE=1" >>>>>>> + >>>>>>> +pkg.cflags.NFFS: >>>>>>> + - "-DNFFS_PRESENT" >>>>>>> + >>>>>>> +pkg.cflags.FCB: >>>>>>> + - "-DFCB_PRESENT" >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/apps/oled_test/src/main.c >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/apps/oled_test/src/main.c b/apps/oled_test/src/main.c >>>>>>> new file mode 100755 >>>>>>> index 0000000..f8494b9 >>>>>>> --- /dev/null >>>>>>> +++ b/apps/oled_test/src/main.c >>>>>>> @@ -0,0 +1,467 @@ >>>>>>> +/** >>>>>>> + * 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. >>>>>>> + */ >>>>>>> +#include <os/os.h> >>>>>>> +#include <bsp/bsp.h> >>>>>>> +#include <hal/hal_gpio.h> >>>>>>> +#include <hal/hal_flash.h> >>>>>>> +#include <console/console.h> >>>>>>> +#include <shell/shell.h> >>>>>>> +#include <config/config.h> >>>>>>> +#include <hal/flash_map.h> >>>>>>> +#include <hal/hal_system.h> >>>>>>> +#ifdef NFFS_PRESENT >>>>>>> +#include <fs/fs.h> >>>>>>> +#include <nffs/nffs.h> >>>>>>> +#include <config/config_file.h> >>>>>>> +#elif FCB_PRESENT >>>>>>> +#include <fcb/fcb.h> >>>>>>> +#include <config/config_fcb.h> >>>>>>> +#else >>>>>>> +#error "Need NFFS or FCB for config storage" >>>>>>> +#endif >>>>>>> +#include <newtmgr/newtmgr.h> >>>>>>> +#include <bootutil/image.h> >>>>>>> +#include <bootutil/bootutil_misc.h> >>>>>>> +#include <imgmgr/imgmgr.h> >>>>>>> +#include <assert.h> >>>>>>> +#include <string.h> >>>>>>> +#include <json/json.h> >>>>>>> +#include <flash_test/flash_test.h> >>>>>>> +#include <reboot/log_reboot.h> >>>>>>> +#include <os/os_time.h> >>>>>>> +#include <id/id.h> >>>>>>> + >>>>>>> +#include <mpu_3050/mpu_3050.h> >>>>>>> + >>>>>>> +#ifdef ARCH_sim >>>>>>> +#include <mcu/mcu_sim.h> >>>>>>> +#endif >>>>>>> + >>>>>>> +/* Init all tasks */ >>>>>>> +volatile int tasks_initialized; >>>>>>> +int init_tasks(void); >>>>>>> + >>>>>>> +/* Task 1 */ >>>>>>> +#define TASK1_PRIO (8) >>>>>>> +#define TASK1_STACK_SIZE OS_STACK_ALIGN(192) >>>>>>> +struct os_task task1; >>>>>>> +os_stack_t stack1[TASK1_STACK_SIZE]; >>>>>>> +static volatile int g_task1_loops; >>>>>>> + >>>>>>> +/* Task 2 */ >>>>>>> +#define TASK2_PRIO (9) >>>>>>> +#define TASK2_STACK_SIZE OS_STACK_ALIGN(128) >>>>>>> +struct os_task task2; >>>>>>> +os_stack_t stack2[TASK2_STACK_SIZE]; >>>>>>> + >>>>>>> +#define SHELL_TASK_PRIO (3) >>>>>>> +#define SHELL_MAX_INPUT_LEN (256) >>>>>>> +#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(384)) >>>>>>> +os_stack_t shell_stack[SHELL_TASK_STACK_SIZE]; >>>>>>> + >>>>>>> +#define NEWTMGR_TASK_PRIO (4) >>>>>>> +#define NEWTMGR_TASK_STACK_SIZE (OS_STACK_ALIGN(896)) >>>>>>> +os_stack_t newtmgr_stack[NEWTMGR_TASK_STACK_SIZE]; >>>>>>> + >>>>>>> +static volatile int g_task2_loops; >>>>>>> + >>>>>>> +/* Global test semaphore */ >>>>>>> +struct os_sem g_test_sem; >>>>>>> + >>>>>>> +/* For LED toggling */ >>>>>>> +int g_led_pin; >>>>>>> + >>>>>>> +#ifdef NFFS_PRESENT >>>>>>> +/* configuration file */ >>>>>>> +#define MY_CONFIG_DIR "/cfg" >>>>>>> +#define MY_CONFIG_FILE "/cfg/run" >>>>>>> +#define MY_CONFIG_MAX_LINES 32 >>>>>>> + >>>>>>> +static struct conf_file my_conf = { >>>>>>> + .cf_name = MY_CONFIG_FILE, >>>>>>> + .cf_maxlines = MY_CONFIG_MAX_LINES >>>>>>> +}; >>>>>>> +#elif FCB_PRESENT >>>>>>> +struct flash_area conf_fcb_area[NFFS_AREA_MAX + 1]; >>>>>>> + >>>>>>> +static struct conf_fcb my_conf = { >>>>>>> + .cf_fcb.f_magic = 0xc09f6e5e, >>>>>>> + .cf_fcb.f_sectors = conf_fcb_area >>>>>>> +}; >>>>>>> +#endif >>>>>>> + >>>>>>> +#define DEFAULT_MBUF_MPOOL_BUF_LEN (256) >>>>>>> +#define DEFAULT_MBUF_MPOOL_NBUFS (10) >>>>>>> + >>>>>>> +uint8_t default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN * >>>>>>> + DEFAULT_MBUF_MPOOL_NBUFS]; >>>>>>> + >>>>>>> +struct os_mbuf_pool default_mbuf_pool; >>>>>>> +struct os_mempool default_mbuf_mpool; >>>>>>> + >>>>>>> +static char *test_conf_get(int argc, char **argv, char *val, int >>> max_len); >>>>>>> +static int test_conf_set(int argc, char **argv, char *val); >>>>>>> +static int test_conf_commit(void); >>>>>>> +static int test_conf_export(void (*export_func)(char *name, char >>> *val), >>>>>>> + enum conf_export_tgt tgt); >>>>>>> + >>>>>>> +static struct conf_handler test_conf_handler = { >>>>>>> + .ch_name = "test", >>>>>>> + .ch_get = test_conf_get, >>>>>>> + .ch_set = test_conf_set, >>>>>>> + .ch_commit = test_conf_commit, >>>>>>> + .ch_export = test_conf_export >>>>>>> +}; >>>>>>> + >>>>>>> +static uint8_t test8; >>>>>>> +static uint8_t test8_shadow; >>>>>>> +static char test_str[32]; >>>>>>> + >>>>>>> +static char * >>>>>>> +test_conf_get(int argc, char **argv, char *buf, int max_len) >>>>>>> +{ >>>>>>> + if (argc == 1) { >>>>>>> + if (!strcmp(argv[0], "8")) { >>>>>>> + return conf_str_from_value(CONF_INT8, &test8, buf, >>> max_len); >>>>>>> + } else if (!strcmp(argv[0], "str")) { >>>>>>> + return test_str; >>>>>>> + } >>>>>>> + } >>>>>>> + return NULL; >>>>>>> +} >>>>>>> + >>>>>>> +static int >>>>>>> +test_conf_set(int argc, char **argv, char *val) >>>>>>> +{ >>>>>>> + if (argc == 1) { >>>>>>> + if (!strcmp(argv[0], "8")) { >>>>>>> + return CONF_VALUE_SET(val, CONF_INT8, test8_shadow); >>>>>>> + } else if (!strcmp(argv[0], "str")) { >>>>>>> + return CONF_VALUE_SET(val, CONF_STRING, test_str); >>>>>>> + } >>>>>>> + } >>>>>>> + return OS_ENOENT; >>>>>>> +} >>>>>>> + >>>>>>> +static int >>>>>>> +test_conf_commit(void) >>>>>>> +{ >>>>>>> + test8 = test8_shadow; >>>>>>> + >>>>>>> + return 0; >>>>>>> +} >>>>>>> + >>>>>>> +static int >>>>>>> +test_conf_export(void (*func)(char *name, char *val), enum >>> conf_export_tgt tgt) >>>>>>> +{ >>>>>>> + char buf[4]; >>>>>>> + >>>>>>> + conf_str_from_value(CONF_INT8, &test8, buf, sizeof(buf)); >>>>>>> + func("test/8", buf); >>>>>>> + func("test/str", test_str); >>>>>>> + return 0; >>>>>>> +} >>>>>>> + >>>>>>> +void >>>>>>> +task1_handler(void *arg) >>>>>>> +{ >>>>>>> + struct os_task *t; >>>>>>> + >>>>>>> + /* Set the led pin for the E407 devboard */ >>>>>>> + g_led_pin = LED_BLINK_PIN; >>>>>>> + hal_gpio_init_out(g_led_pin, 1); >>>>>>> + >>>>>>> + while (1) { >>>>>>> + t = os_sched_get_current_task(); >>>>>>> + assert(t->t_func == task1_handler); >>>>>>> + >>>>>>> + ++g_task1_loops; >>>>>>> + >>>>>>> + /* Wait one second */ >>>>>>> + os_time_delay(1000); >>>>>>> + >>>>>>> + /* Toggle the LED */ >>>>>>> + hal_gpio_toggle(g_led_pin); >>>>>>> + >>>>>>> + /* Release semaphore to task 2 */ >>>>>>> + os_sem_release(&g_test_sem); >>>>>>> + } >>>>>>> +} >>>>>>> + >>>>>>> +#if 0 >>>>>>> +#define SSD1306_DEV ARDUINO_ZERO_I2C >>>>>>> + >>>>>>> +static int >>>>>>> +ssd1306_cli(int argc, char **argv) >>>>>>> +{ >>>>>>> + int rc; >>>>>>> + >>>>>>> + if (argc < 1) { >>>>>>> + console_printf("too few args\n"); >>>>>>> + return 0; >>>>>>> + } >>>>>>> + if (!strcmp(argv[1], "init")) { >>>>>>> + rc = ssd1306_init(SSD1306_DEV); >>>>>>> + console_printf("ssd1306_init() = %d\n", rc); >>>>>>> + if (rc) { >>>>>>> + return 0; >>>>>>> + } >>>>>>> + rc = ssd1306_enable(); >>>>>>> + console_printf("ssd1306_enable() = %d\n", rc); >>>>>>> + } else if (!strcmp(argv[1], "cls")) { >>>>>>> + rc = ssd1306_fill(0); >>>>>>> + console_printf("ssd1306_fill(0) = %d\n", rc); >>>>>>> + } else if (!strcmp(argv[1], "fill")) { >>>>>>> + rc = ssd1306_fill(255); >>>>>>> + console_printf("ssd1306_fill(255) = %d\n", rc); >>>>>>> + } >>>>>>> + return 0; >>>>>>> +} >>>>>>> + >>>>>>> +struct shell_cmd ssd1306_cli_cmd = { >>>>>>> + .sc_cmd = "oled", >>>>>>> + .sc_cmd_func = ssd1306_cli >>>>>>> +}; >>>>>>> +#endif >>>>>>> + >>>>>>> +#include <hal/hal_i2c.h> >>>>>>> +#define GYRO_DEV 5 >>>>>>> + >>>>>>> +static int >>>>>>> +mpu3050_cli(int argc, char **argv) >>>>>>> +{ >>>>>>> + int rc; >>>>>>> + static struct mpu3050 gyro; >>>>>>> + uint16_t x, y, z; >>>>>>> + uint8_t reg, val; >>>>>>> + >>>>>>> + if (argc < 2) { >>>>>>> + console_printf("too few args\n"); >>>>>>> + return 0; >>>>>>> + } >>>>>>> + if (!strcmp(argv[1], "init")) { >>>>>>> + rc = mpu3050_init(&gyro, GYRO_DEV, MPU3050_I2C_ADDR); >>>>>>> + console_printf("mpu3050_init() = %d\n", rc); >>>>>>> + if (rc) { >>>>>>> + return 0; >>>>>>> + } >>>>>>> + } else if (!strcmp(argv[1], "raw")) { >>>>>>> + rc = mpu3050_read_xyz(&gyro, &x, &y, &z); >>>>>>> + console_printf("mpu3050_read_raw() = %d\n", rc); >>>>>>> + if (rc == 0) { >>>>>>> + console_printf("x=%d y=%d x=%d\n", x, y, z); >>>>>>> + } >>>>>>> + } else if (!strcmp(argv[1], "reg")) { >>>>>>> + if (argc < 3) { >>>>>>> + return 0; >>>>>>> + } >>>>>>> + >>>>>>> + reg = strtoul(argv[2], 0, 0); >>>>>>> + rc = mpu3050_read_reg(&gyro, reg, &val); >>>>>>> + console_printf("mpu3050_read_reg(%d) = %d\n", reg, rc); >>>>>>> + if (rc == 0) { >>>>>>> + console_printf("val=%x\n", val); >>>>>>> + } >>>>>>> + } else if (!strcmp(argv[1], "probe")) { >>>>>>> + uint32_t now, then; >>>>>>> + if (argc < 3) { >>>>>>> + console_printf("more args needed\n"); >>>>>>> + return 0; >>>>>>> + } >>>>>>> + >>>>>>> + val = strtoul(argv[2], 0, 0); >>>>>>> + then = os_time_get(); >>>>>>> + rc = hal_i2c_master_probe(0, 0x40, val); >>>>>>> + now = os_time_get(); >>>>>>> + console_printf("probe=%d %ld->%ld\n", rc, then, now); >>>>>>> + } else { >>>>>>> + console_printf("unknown cmd %s\n", argv[1]); >>>>>>> + } >>>>>>> + return 0; >>>>>>> +} >>>>>>> + >>>>>>> +struct shell_cmd mpu3050_cli_cmd = { >>>>>>> + .sc_cmd = "gyro", >>>>>>> + .sc_cmd_func = mpu3050_cli >>>>>>> +}; >>>>>>> + >>>>>>> +/** >>>>>>> + * init_tasks >>>>>>> + * >>>>>>> + * Called by main.c after os_init(). This function performs >>> initializations >>>>>>> + * that are required before tasks are running. >>>>>>> + * >>>>>>> + * @return int 0 success; error otherwise. >>>>>>> + */ >>>>>>> +int >>>>>>> +init_tasks(void) >>>>>>> +{ >>>>>>> + /* Initialize global test semaphore */ >>>>>>> + os_sem_init(&g_test_sem, 0); >>>>>>> + >>>>>>> + os_task_init(&task1, "task1", task1_handler, NULL, >>>>>>> + TASK1_PRIO, OS_WAIT_FOREVER, stack1, TASK1_STACK_SIZE); >>>>>>> + >>>>>>> + tasks_initialized = 1; >>>>>>> + return 0; >>>>>>> +} >>>>>>> + >>>>>>> +#ifdef NFFS_PRESENT >>>>>>> +static void >>>>>>> +setup_for_nffs(void) >>>>>>> +{ >>>>>>> + /* NFFS_AREA_MAX is defined in the BSP-specified bsp.h header >>> file. */ >>>>>>> + struct nffs_area_desc descs[NFFS_AREA_MAX + 1]; >>>>>>> + int cnt; >>>>>>> + int rc; >>>>>>> + >>>>>>> + /* Initialize nffs's internal state. */ >>>>>>> + rc = nffs_init(); >>>>>>> + assert(rc == 0); >>>>>>> + >>>>>>> + /* Convert the set of flash blocks we intend to use for nffs >>> into an array >>>>>>> + * of nffs area descriptors. >>>>>>> + */ >>>>>>> + cnt = NFFS_AREA_MAX; >>>>>>> + rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs); >>>>>>> + assert(rc == 0); >>>>>>> + >>>>>>> + /* Attempt to restore an existing nffs file system from flash. */ >>>>>>> + if (nffs_detect(descs) == FS_ECORRUPT) { >>>>>>> + /* No valid nffs instance detected; format a new one. */ >>>>>>> + rc = nffs_format(descs); >>>>>>> + assert(rc == 0); >>>>>>> + } >>>>>>> + >>>>>>> + fs_mkdir(MY_CONFIG_DIR); >>>>>>> + rc = conf_file_src(&my_conf); >>>>>>> + assert(rc == 0); >>>>>>> + rc = conf_file_dst(&my_conf); >>>>>>> + assert(rc == 0); >>>>>>> +} >>>>>>> + >>>>>>> +#elif FCB_PRESENT >>>>>>> + >>>>>>> +static void >>>>>>> +setup_for_fcb(void) >>>>>>> +{ >>>>>>> + int cnt; >>>>>>> + int rc; >>>>>>> + >>>>>>> + rc = flash_area_to_sectors(FLASH_AREA_NFFS, &cnt, NULL); >>>>>>> + assert(rc == 0); >>>>>>> + assert(cnt <= sizeof(conf_fcb_area) / sizeof(conf_fcb_area[0])); >>>>>>> + flash_area_to_sectors(FLASH_AREA_NFFS, &cnt, conf_fcb_area); >>>>>>> + >>>>>>> + my_conf.cf_fcb.f_sector_cnt = cnt; >>>>>>> + >>>>>>> + rc = conf_fcb_src(&my_conf); >>>>>>> + if (rc) { >>>>>>> + for (cnt = 0; cnt < my_conf.cf_fcb.f_sector_cnt; cnt++) { >>>>>>> + flash_area_erase(&conf_fcb_area[cnt], 0, >>>>>>> + conf_fcb_area[cnt].fa_size); >>>>>>> + } >>>>>>> + rc = conf_fcb_src(&my_conf); >>>>>>> + } >>>>>>> + assert(rc == 0); >>>>>>> + rc = conf_fcb_dst(&my_conf); >>>>>>> + assert(rc == 0); >>>>>>> +} >>>>>>> + >>>>>>> +#endif >>>>>>> + >>>>>>> +/** >>>>>>> + * 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. >>>>>>> + * >>>>>>> + * @return int NOTE: this function should never return! >>>>>>> + */ >>>>>>> +int >>>>>>> +main(int argc, char **argv) >>>>>>> +{ >>>>>>> + int rc; >>>>>>> + struct image_version ver; >>>>>>> + >>>>>>> +#ifdef ARCH_sim >>>>>>> + mcu_sim_parse_args(argc, argv); >>>>>>> +#endif >>>>>>> + >>>>>>> + conf_init(); >>>>>>> + rc = conf_register(&test_conf_handler); >>>>>>> + assert(rc == 0); >>>>>>> + >>>>>>> + os_init(); >>>>>>> + >>>>>>> + rc = os_mempool_init(&default_mbuf_mpool, >>> DEFAULT_MBUF_MPOOL_NBUFS, >>>>>>> + DEFAULT_MBUF_MPOOL_BUF_LEN, default_mbuf_mpool_data, >>>>>>> + "default_mbuf_data"); >>>>>>> + assert(rc == 0); >>>>>>> + >>>>>>> + rc = os_mbuf_pool_init(&default_mbuf_pool, &default_mbuf_mpool, >>>>>>> + DEFAULT_MBUF_MPOOL_BUF_LEN, DEFAULT_MBUF_MPOOL_NBUFS); >>>>>>> + assert(rc == 0); >>>>>>> + >>>>>>> + rc = os_msys_register(&default_mbuf_pool); >>>>>>> + assert(rc == 0); >>>>>>> + >>>>>>> + rc = hal_flash_init(); >>>>>>> + assert(rc == 0); >>>>>>> + >>>>>>> +#ifdef NFFS_PRESENT >>>>>>> + setup_for_nffs(); >>>>>>> +#elif FCB_PRESENT >>>>>>> + setup_for_fcb(); >>>>>>> +#endif >>>>>>> + >>>>>>> + id_init(); >>>>>>> + >>>>>>> + shell_task_init(SHELL_TASK_PRIO, shell_stack, >>> SHELL_TASK_STACK_SIZE, >>>>>>> + SHELL_MAX_INPUT_LEN); >>>>>>> + >>>>>>> + nmgr_task_init(NEWTMGR_TASK_PRIO, newtmgr_stack, >>> NEWTMGR_TASK_STACK_SIZE); >>>>>>> + imgmgr_module_init(); >>>>>>> + >>>>>>> + if (imgr_my_version(&ver) == 0) { >>>>>>> + console_printf("\nSlinky %u.%u.%u.%u\n", >>>>>>> + ver.iv_major, ver.iv_minor, ver.iv_revision, >>>>>>> + (unsigned int)ver.iv_build_num); >>>>>>> + } else { >>>>>>> + console_printf("\nSlinky\n"); >>>>>>> + } >>>>>>> + >>>>>>> +#if 0 >>>>>>> + shell_cmd_register(&ssd1306_cli_cmd); >>>>>>> +#endif >>>>>>> + shell_cmd_register(&mpu3050_cli_cmd); >>>>>>> + >>>>>>> + conf_load(); >>>>>>> + >>>>>>> + rc = init_tasks(); >>>>>>> + >>>>>>> + os_start(); >>>>>>> + >>>>>>> + /* os start should never return. If it does, this should be an >>> error */ >>>>>>> + assert(0); >>>>>>> + >>>>>>> + return rc; >>>>>>> +} >>>>>>> + >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/apps/slinky/src/main.c >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c >>>>>>> index 9007fdd..956ce38 100755 >>>>>>> --- a/apps/slinky/src/main.c >>>>>>> +++ b/apps/slinky/src/main.c >>>>>>> @@ -61,11 +61,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 log my_log; >>>>>>> >>>>>>> static volatile int g_task2_loops; >>>>>>> @@ -106,8 +101,6 @@ static char test_str[32]; >>>>>>> static uint32_t cbmem_buf[MAX_CBMEM_BUF]; >>>>>>> static struct cbmem cbmem; >>>>>>> >>>>>>> -static struct os_eventq slinky_evq; >>>>>>> - >>>>>>> static char * >>>>>>> test_conf_get(int argc, char **argv, char *buf, int max_len) >>>>>>> { >>>>>>> @@ -212,18 +205,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(&slinky_evq); >>>>>>> - } >>>>>>> -} >>>>>>> - >>>>>>> -/** >>>>>>> * init_tasks >>>>>>> * >>>>>>> * Called by main.c after sysinit(). This function performs >>> initializations >>>>>>> @@ -250,19 +231,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(&slinky_evq); >>>>>>> - os_eventq_dflt_set(&slinky_evq); >>>>>>> } >>>>>>> >>>>>>> /** >>>>>>> @@ -318,10 +286,10 @@ main(int argc, char **argv) >>>>>>> } >>>>>>> #endif >>>>>>> >>>>>>> - os_start(); >>>>>>> - >>>>>>> - /* os start should never return. If it does, this should be an >>> error */ >>>>>>> - assert(0); >>>>>>> - >>>>>>> - return rc; >>>>>>> + /* >>>>>>> + * As the last thing, process events from default event queue. >>>>>>> + */ >>>>>>> + while (1) { >>>>>>> + os_eventq_run(os_eventq_dflt_get()); >>>>>>> + } >>>>>>> } >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/apps/slinky/syscfg.yml >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/apps/slinky/syscfg.yml b/apps/slinky/syscfg.yml >>>>>>> index 7438a81..1beee37 100644 >>>>>>> --- a/apps/slinky/syscfg.yml >>>>>>> +++ b/apps/slinky/syscfg.yml >>>>>>> @@ -40,3 +40,6 @@ syscfg.vals: >>>>>>> STATS_NEWTMGR: 1 >>>>>>> LOG_NEWTMGR: 1 >>>>>>> CONFIG_NEWTMGR: 1 >>>>>>> + >>>>>>> + OS_MAIN_TASK_PRIO: 10 >>>>>>> + OS_MAIN_STACKS_SIZE: 512 >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 5931c81..59927c9 100644 >>>>>>> --- a/hw/mcu/native/src/hal_system.c >>>>>>> +++ b/hw/mcu/native/src/hal_system.c >>>>>>> @@ -26,6 +26,10 @@ >>>>>>> #include "hal/hal_system.h" >>>>>>> #include "mcu/mcu_sim.h" >>>>>>> >>>>>>> +#if MYNEWT_VAL(OS_SCHEDULING) >>>>>>> +#include <os/os.h> >>>>>>> +#endif >>>>>>> + >>>>>>> void >>>>>>> hal_system_reset(void) >>>>>>> { >>>>>>> @@ -59,8 +63,14 @@ void >>>>>>> mcu_sim_parse_args(int argc, char **argv) >>>>>>> { >>>>>>> int ch; >>>>>>> - char *progname = argv[0]; >>>>>>> + char *progname; >>>>>>> >>>>>>> +#if MYNEWT_VAL(OS_SCHEDULING) >>>>>>> + if (g_os_started) { >>>>>>> + return; >>>>>>> + } >>>>>>> +#endif >>>>>>> + progname = argv[0]; >>>>>>> while ((ch = getopt(argc, argv, "hf:u:")) != -1) { >>>>>>> switch (ch) { >>>>>>> case 'f': >>>>>>> @@ -77,4 +87,8 @@ mcu_sim_parse_args(int argc, char **argv) >>>>>>> break; >>>>>>> } >>>>>>> } >>>>>>> +#if MYNEWT_VAL(OS_SCHEDULING) >>>>>>> + os_init(); >>>>>>> + os_start(); >>>>>>> +#endif >>>>>>> } >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/kernel/os/include/os/os.h >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/kernel/os/include/os/os.h b/kernel/os/include/os/os.h >>>>>>> index 0939dac..17f42a8 100644 >>>>>>> --- a/kernel/os/include/os/os.h >>>>>>> +++ b/kernel/os/include/os/os.h >>>>>>> @@ -83,6 +83,8 @@ enum os_error { >>>>>>> typedef enum os_error os_error_t; >>>>>>> >>>>>>> #define OS_IDLE_PRIO (0xff) >>>>>>> +#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_start(void); >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/kernel/os/include/os/os_eventq.h >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/kernel/os/include/os/os_eventq.h >>> b/kernel/os/include/os/os_eventq.h >>>>>>> index cfe0d34..092e724 100644 >>>>>>> --- a/kernel/os/include/os/os_eventq.h >>>>>>> +++ b/kernel/os/include/os/os_eventq.h >>>>>>> @@ -53,7 +53,6 @@ struct os_event *os_eventq_get(struct os_eventq *); >>>>>>> void os_eventq_run(struct os_eventq *evq); >>>>>>> struct os_event *os_eventq_poll(struct os_eventq **, int, os_time_t); >>>>>>> void os_eventq_remove(struct os_eventq *, struct os_event *); >>>>>>> -void os_eventq_dflt_set(struct os_eventq *evq); >>>>>>> struct os_eventq *os_eventq_dflt_get(void); >>>>>>> void os_eventq_designate(struct os_eventq **dst, struct os_eventq >>> *val, >>>>>>> struct os_event *start_ev); >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/kernel/os/src/os.c >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/kernel/os/src/os.c b/kernel/os/src/os.c >>>>>>> index 6dfe128..374f5f1 100644 >>>>>>> --- a/kernel/os/src/os.c >>>>>>> +++ b/kernel/os/src/os.c >>>>>>> @@ -42,6 +42,10 @@ struct os_task g_idle_task; >>>>>>> os_stack_t g_idle_task_stack[OS_STACK_ALIGN(OS_IDLE_STACK_SIZE)]; >>>>>>> >>>>>>> uint32_t g_os_idle_ctr; >>>>>>> + >>>>>>> +static struct os_task os_main_task; >>>>>>> +static os_stack_t os_main_stack[OS_STACK_ALIGN(OS_MAIN_STACK_SIZE)]; >>>>>>> + >>>>>>> /* Default zero. Set by the architecture specific code when os is >>> started. >>>>>>> */ >>>>>>> int g_os_started; >>>>>>> @@ -123,6 +127,21 @@ os_started(void) >>>>>>> return (g_os_started); >>>>>>> } >>>>>>> >>>>>>> +static void >>>>>>> +os_main(void *arg) >>>>>>> +{ >>>>>>> + extern int main(int argc, char **argv); >>>>>>> + >>>>>>> + os_eventq_init(os_eventq_dflt_get()); >>>>>>> +#if !MYNEWT_VAL(SELFTEST) >>>>>>> + main(0, NULL); >>>>>>> +#else >>>>>>> + while (1) { >>>>>>> + os_eventq_run(os_eventq_dflt_get()); >>>>>>> + } >>>>>>> +#endif >>>>>>> + assert(0); >>>>>>> +} >>>>>>> >>>>>>> void >>>>>>> os_init_idle_task(void) >>>>>>> @@ -138,6 +157,11 @@ 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)); >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/kernel/os/src/os_eventq.c >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/kernel/os/src/os_eventq.c b/kernel/os/src/os_eventq.c >>>>>>> index d443dfd..d5be9ae 100644 >>>>>>> --- a/kernel/os/src/os_eventq.c >>>>>>> +++ b/kernel/os/src/os_eventq.c >>>>>>> @@ -29,7 +29,7 @@ >>>>>>> * @{ >>>>>>> */ >>>>>>> >>>>>>> -static struct os_eventq *os_eventq_main; >>>>>>> +static struct os_eventq os_eventq_main; >>>>>>> >>>>>>> /** >>>>>>> * Initialize the event queue >>>>>>> @@ -279,29 +279,14 @@ os_eventq_remove(struct os_eventq *evq, struct >>> os_event *ev) >>>>>>> } >>>>>>> >>>>>>> /** >>>>>>> - * Assigns the default event queue. Packages which require an event >>> queue, and >>>>>>> - * which haven't been explicitly told which one to use, will use >>> this one >>>>>>> - * automatically. >>>>>>> + * Retrieves the default event queue processed by OS main task. >>>>>>> * >>>>>>> - * @param evq The event queue to designate as the >>> default. >>>>>>> - */ >>>>>>> -void >>>>>>> -os_eventq_dflt_set(struct os_eventq *evq) >>>>>>> -{ >>>>>>> - os_eventq_main = evq; >>>>>>> -} >>>>>>> - >>>>>>> -/** >>>>>>> - * Retrieves the default event queue, if any. The default event >>> queue is >>>>>>> - * designated via a call to os_eventq_dflt_set(). >>>>>>> - * >>>>>>> - * @return The default event queue, no NULL if >>> there isn't >>>>>>> - * any. >>>>>>> + * @return The default event queue. >>>>>>> */ >>>>>>> struct os_eventq * >>>>>>> os_eventq_dflt_get(void) >>>>>>> { >>>>>>> - return os_eventq_main; >>>>>>> + return &os_eventq_main; >>>>>>> } >>>>>>> >>>>>>> void >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/kernel/os/syscfg.yml >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/kernel/os/syscfg.yml b/kernel/os/syscfg.yml >>>>>>> index e175bce..e329059 100644 >>>>>>> --- a/kernel/os/syscfg.yml >>>>>>> +++ b/kernel/os/syscfg.yml >>>>>>> @@ -19,6 +19,12 @@ >>>>>>> # Package: kernel/os >>>>>>> >>>>>>> syscfg.defs: >>>>>>> + OS_MAIN_TASK_PRIO: >>>>>>> + description: 'Priority of initialization and main task' >>>>>>> + value: 0xfe >>>>>>> + OS_MAIN_STACK_SIZE: >>>>>>> + description: 'Stack size of initialization and main task' >>>>>>> + value: 1024 >>>>>>> OS_CLI: >>>>>>> description: 'TBD' >>>>>>> value: 0 >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/kernel/os/test/src/eventq_test.c >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/kernel/os/test/src/eventq_test.c >>> b/kernel/os/test/src/eventq_test.c >>>>>>> index 01e8f3f..a48546d 100644 >>>>>>> --- a/kernel/os/test/src/eventq_test.c >>>>>>> +++ b/kernel/os/test/src/eventq_test.c >>>>>>> @@ -197,7 +197,6 @@ eventq_task_poll_timeout_send(void *arg) >>>>>>> >>>>>>> /* This task sleeps until the receive task completes the test. */ >>>>>>> os_time_delay(1000000); >>>>>>> - >>>>>>> } >>>>>>> >>>>>>> /* Receiving multiple event queues with a time failure */ >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 7d86c2c..5be2aca 100644 >>>>>>> --- a/kernel/os/test/src/mempool_test.c >>>>>>> +++ b/kernel/os/test/src/mempool_test.c >>>>>>> @@ -60,6 +60,7 @@ mempool_test_get_pool_size(int num_blocks, int >>> block_size) >>>>>>> void >>>>>>> os_mempool_ts_pretest(void* arg) >>>>>>> { >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> } >>>>>>> >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 6f8ee69..ae05a27 100644 >>>>>>> --- a/kernel/os/test/src/mutex_test.c >>>>>>> +++ b/kernel/os/test/src/mutex_test.c >>>>>>> @@ -296,7 +296,7 @@ mutex_task3_handler(void *arg) >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> +void >>>>>>> mutex_task4_handler(void *arg) >>>>>>> { >>>>>>> os_error_t err; >>>>>>> @@ -335,6 +335,7 @@ os_mutex_tc_pretest(void* arg) >>>>>>> /* >>>>>>> * Only call if running in "native" simulated environment >>>>>>> */ >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> return; >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 2e5bf9d..33b0868 100644 >>>>>>> --- a/kernel/os/test/src/os_test.c >>>>>>> +++ b/kernel/os/test/src/os_test.c >>>>>>> @@ -73,6 +73,7 @@ os_test_restart(void) >>>>>>> void >>>>>>> os_selftest_pretest_cb(void* arg) >>>>>>> { >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> } >>>>>>> >>>>>>> @@ -92,10 +93,10 @@ os_test_all(void) >>>>>>> >>>>>>> tu_suite_set_init_cb(os_mempool_test_init, NULL); >>>>>>> os_mempool_test_suite(); >>>>>>> - >>>>>>> +#if 1 >>>>>>> tu_suite_set_init_cb(os_mutex_test_init, NULL); >>>>>>> os_mutex_test_suite(); >>>>>>> - >>>>>>> +#endif >>>>>>> tu_suite_set_init_cb(os_sem_test_init, NULL); >>>>>>> os_sem_test_suite(); >>>>>>> >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 98348b4..42e7bfe 100644 >>>>>>> --- a/kernel/os/test/src/sem_test.c >>>>>>> +++ b/kernel/os/test/src/sem_test.c >>>>>>> @@ -6,7 +6,7 @@ >>>>>>> * 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, >>>>>>> @@ -44,23 +44,23 @@ os_stack_t *stack4; >>>>>>> struct os_sem g_sem1; >>>>>>> #endif /* MYNEWT_VAL(SELFTEST) */ >>>>>>> >>>>>>> -/* >>>>>>> +/* >>>>>>> * TEST NUMBERS: >>>>>>> * 10: In this test we have the highest priority task getting the >>> semaphore >>>>>>> * then sleeping. Two lower priority tasks then wake up and attempt >>> to get >>>>>>> * the semaphore. They are blocked until the higher priority task >>> releases >>>>>>> * the semaphore, at which point the lower priority tasks should wake >>> up in >>>>>>> * order, get the semaphore, then release it and go back to sleep. >>>>>>> - * >>>>>>> + * >>>>>>> */ >>>>>>> char sem_test_buf[128]; >>>>>>> >>>>>>> /** >>>>>>> * sem test disp sem >>>>>>> - * >>>>>>> - * Display semaphore contents >>>>>>> - * >>>>>>> - * @param sem >>>>>>> + * >>>>>>> + * Display semaphore contents >>>>>>> + * >>>>>>> + * @param sem >>>>>>> */ >>>>>>> const char * >>>>>>> sem_test_sem_to_s(const struct os_sem *sem) >>>>>>> @@ -71,7 +71,7 @@ sem_test_sem_to_s(const struct os_sem *sem) >>>>>>> return sem_test_buf; >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> +void >>>>>>> sem_test_sleep_task_handler(void *arg) >>>>>>> { >>>>>>> struct os_task *t; >>>>>>> @@ -104,13 +104,13 @@ sem_test_pend_release_loop(int delay, int >>> timeout, int itvl) >>>>>>> } >>>>>>> >>>>>>> /** >>>>>>> - * sem test basic >>>>>>> - * >>>>>>> + * sem test basic >>>>>>> + * >>>>>>> * Basic semaphore tests >>>>>>> - * >>>>>>> - * @return int >>>>>>> + * >>>>>>> + * @return int >>>>>>> */ >>>>>>> -void >>>>>>> +void >>>>>>> sem_test_basic_handler(void *arg) >>>>>>> { >>>>>>> struct os_task *t; >>>>>>> @@ -178,7 +178,7 @@ sem_test_basic_handler(void *arg) >>>>>>> #endif >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> +void >>>>>>> sem_test_1_task1_handler(void *arg) >>>>>>> { >>>>>>> os_error_t err; >>>>>>> @@ -208,69 +208,69 @@ sem_test_1_task1_handler(void *arg) >>>>>>> #endif >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_1_task2_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_1_task2_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(0, OS_TICKS_PER_SEC / 10, >>>>>>> OS_TICKS_PER_SEC / 10); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_1_task3_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_1_task3_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(0, OS_TIMEOUT_NEVER, OS_TICKS_PER_SEC * >>> 2); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_2_task2_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_2_task2_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(0, 2000, 2000); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_2_task3_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_2_task3_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(0, OS_TIMEOUT_NEVER, 2000); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_2_task4_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_2_task4_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(0, 2000, 2000); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_3_task2_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_3_task2_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(100, 2000, 2000); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_3_task3_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_3_task3_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(150, 2000, 2000); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_3_task4_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_3_task4_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(0, 2000, 2000); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_4_task2_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_4_task2_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(60, 2000, 2000); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_4_task3_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_4_task3_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(60, 2000, 2000); >>>>>>> } >>>>>>> >>>>>>> -void >>>>>>> -sem_test_4_task4_handler(void *arg) >>>>>>> +void >>>>>>> +sem_test_4_task4_handler(void *arg) >>>>>>> { >>>>>>> sem_test_pend_release_loop(0, 2000, 2000); >>>>>>> } >>>>>>> @@ -279,6 +279,7 @@ void >>>>>>> os_sem_tc_pretest(void* arg) >>>>>>> { >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> return; >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/kernel/os/test/src/testcases/event_test_poll_0timo.c >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/kernel/os/test/src/testcases/event_test_poll_0timo.c >>> b/kernel/os/test/src/testcases/event_test_poll_0timo.c >>>>>>> index 5e86395..b53418e 100644 >>>>>>> --- a/kernel/os/test/src/testcases/event_test_poll_0timo.c >>>>>>> +++ b/kernel/os/test/src/testcases/event_test_poll_0timo.c >>>>>>> @@ -6,7 +6,7 @@ >>>>>>> * 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, >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 122980e..72e1a5f 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,10 +26,11 @@ TEST_CASE(event_test_poll_single_sr) >>>>>>> >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> /* Initializing the OS */ >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> /* Initialize the task */ >>>>>>> - os_task_init(&eventq_task_poll_single_s, >>> "eventq_task_poll_single_s", >>>>>>> + os_task_init(&eventq_task_poll_single_s, >>> "eventq_task_poll_single_s", >>>>>>> eventq_task_poll_single_send, NULL, SEND_TASK_POLL_SINGLE_PRIO, >>>>>>> OS_WAIT_FOREVER, eventq_task_stack_poll_single_s, >>> POLL_STACK_SIZE); >>>>>>> >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 1d003d5..e981839 100644 >>>>>>> --- a/kernel/os/test/src/testcases/event_test_poll_sr.c >>>>>>> +++ b/kernel/os/test/src/testcases/event_test_poll_sr.c >>>>>>> @@ -25,6 +25,7 @@ TEST_CASE(event_test_poll_sr) >>>>>>> >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> /* Initializing the OS */ >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> /* Initialize the task */ >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 3972fa4..d7bccee 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 >>>>>>> @@ -6,7 +6,7 @@ >>>>>>> * 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, >>>>>>> @@ -25,10 +25,11 @@ TEST_CASE(event_test_poll_timeout_sr) >>>>>>> >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> /* Initializing the OS */ >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> /* Initialize the task */ >>>>>>> - os_task_init(&eventq_task_poll_timeout_s, >>> "eventq_task_poll_timeout_s", >>>>>>> + os_task_init(&eventq_task_poll_timeout_s, >>> "eventq_task_poll_timeout_s", >>>>>>> eventq_task_poll_timeout_send, NULL, >>> SEND_TASK_POLL_TIMEOUT_PRIO, >>>>>>> OS_WAIT_FOREVER, eventq_task_stack_poll_timeout_s, >>> POLL_STACK_SIZE); >>>>>>> >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 9d3e35b..f1adbea 100644 >>>>>>> --- a/kernel/os/test/src/testcases/event_test_src.c >>>>>>> +++ b/kernel/os/test/src/testcases/event_test_src.c >>>>>>> @@ -6,7 +6,7 @@ >>>>>>> * 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, >>>>>>> @@ -24,6 +24,7 @@ TEST_CASE(event_test_sr) >>>>>>> >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> /* Initializing the OS */ >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> /* Initialize the task */ >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 fdc2926..a03570a 100644 >>>>>>> --- a/kernel/os/test/src/testcases/os_callout_test.c >>>>>>> +++ b/kernel/os/test/src/testcases/os_callout_test.c >>>>>>> @@ -6,7 +6,7 @@ >>>>>>> * 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, >>>>>>> @@ -24,9 +24,10 @@ TEST_CASE(callout_test) >>>>>>> >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> /* Initializing the OS */ >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> - >>>>>>> + >>>>>>> /* Initialize the sending task */ >>>>>>> os_task_init(&callout_task_struct_send, "callout_task_send", >>>>>>> callout_task_send, NULL, SEND_CALLOUT_TASK_PRIO, >>> OS_WAIT_FOREVER, >>>>>>> @@ -38,7 +39,7 @@ TEST_CASE(callout_test) >>>>>>> callout_task_stack_receive, CALLOUT_STACK_SIZE); >>>>>>> >>>>>>> os_eventq_init(&callout_evq); >>>>>>> - >>>>>>> + >>>>>>> /* Initialize the callout function */ >>>>>>> os_callout_init(&callout_test_c, &callout_evq, my_callout, NULL); >>>>>>> >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 2d08085..de8664f 100644 >>>>>>> --- a/kernel/os/test/src/testcases/os_callout_test_speak.c >>>>>>> +++ b/kernel/os/test/src/testcases/os_callout_test_speak.c >>>>>>> @@ -24,9 +24,10 @@ TEST_CASE(callout_test_speak) >>>>>>> >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> /* Initializing the OS */ >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> - >>>>>>> + >>>>>>> /* Initialize the sending task */ >>>>>>> os_task_init(&callout_task_struct_speak, "callout_task_speak", >>>>>>> callout_task_stop_speak, NULL, SPEAK_CALLOUT_TASK_PRIO, >>>>>>> @@ -38,10 +39,10 @@ TEST_CASE(callout_test_speak) >>>>>>> OS_WAIT_FOREVER, callout_task_stack_listen, CALLOUT_STACK_SIZE); >>>>>>> >>>>>>> os_eventq_init(&callout_evq); >>>>>>> - >>>>>>> + >>>>>>> /* Initialize the callout function */ >>>>>>> os_callout_init(&callout_speak, &callout_evq, >>>>>>> - my_callout_speak_func, NULL); >>>>>>> + my_callout_speak_func, NULL); >>>>>>> >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> /* Does not return until OS_restart is called */ >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 15733c1..6b1a8e7 100644 >>>>>>> --- a/kernel/os/test/src/testcases/os_callout_test_stop.c >>>>>>> +++ b/kernel/os/test/src/testcases/os_callout_test_stop.c >>>>>>> @@ -6,7 +6,7 @@ >>>>>>> * 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, >>>>>>> @@ -25,6 +25,7 @@ TEST_CASE(callout_test_stop) >>>>>>> >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> /* Initializing the OS */ >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> >>>>>>> @@ -39,12 +40,12 @@ TEST_CASE(callout_test_stop) >>>>>>> RECEIVE_STOP_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER, >>>>>>> callout_task_stack_stop_receive, CALLOUT_STACK_SIZE); >>>>>>> >>>>>>> - for(k = 0; k< MULTI_SIZE; k++){ >>>>>>> + for(k = 0; k < MULTI_SIZE; k++){ >>>>>>> os_eventq_init(&callout_stop_evq[k]); >>>>>>> } >>>>>>> - >>>>>>> + >>>>>>> /* Initialize the callout function */ >>>>>>> - for(k = 0; k<MULTI_SIZE; k++){ >>>>>>> + for (k = 0; k < MULTI_SIZE; k++){ >>>>>>> os_callout_init(&callout_stop_test[k], &callout_stop_evq[k], >>>>>>> my_callout_stop_func, NULL); >>>>>>> } >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/libc/baselibc/src/start.c >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/libc/baselibc/src/start.c b/libc/baselibc/src/start.c >>>>>>> index 9848c76..febf5b2 100644 >>>>>>> --- a/libc/baselibc/src/start.c >>>>>>> +++ b/libc/baselibc/src/start.c >>>>>>> @@ -18,17 +18,26 @@ >>>>>>> */ >>>>>>> #include <stdlib.h> >>>>>>> >>>>>>> +#include <sysinit/sysinit.h> >>>>>>> + >>>>>>> extern int main(int argc, char **argv); >>>>>>> +extern void os_init(void); >>>>>>> +extern void os_start(void); >>>>>>> >>>>>>> /* >>>>>>> * Rudimentary startup function. >>>>>>> */ >>>>>>> void _start(void) >>>>>>> { >>>>>>> +#if !MYNEWT_VAL(OS_SCHEDULING) >>>>>>> int rc; >>>>>>> >>>>>>> rc = main(0, NULL); >>>>>>> exit(rc); >>>>>>> +#else >>>>>>> + os_init(); >>>>>>> + os_start(); >>>>>>> +#endif >>>>>>> } >>>>>>> >>>>>>> void >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/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 3a81cc8..8bfc2b8 100644 >>>>>>> --- a/net/ip/mn_socket/test/src/testcases/socket_tests.c >>>>>>> +++ b/net/ip/mn_socket/test/src/testcases/socket_tests.c >>>>>>> @@ -20,6 +20,7 @@ >>>>>>> >>>>>>> TEST_CASE(socket_tests) >>>>>>> { >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> >>>>>>> os_sem_init(&test_sem, 0); >>>>>>> >>>>>>> http://git-wip-us.apache.org/repos/asf/incubator-mynewt- >>> core/blob/0c9fe5e2/test/testutil/src/testutil.c >>>>>>> ------------------------------------------------------------ >>> ---------- >>>>>>> diff --git a/test/testutil/src/testutil.c >>> b/test/testutil/src/testutil.c >>>>>>> index 6abb62b..9a1c0fe 100644 >>>>>>> --- a/test/testutil/src/testutil.c >>>>>>> +++ b/test/testutil/src/testutil.c >>>>>>> @@ -41,6 +41,7 @@ int >>>>>>> tu_init(void) >>>>>>> { >>>>>>> #if MYNEWT_VAL(SELFTEST) >>>>>>> + os_init(); >>>>>>> sysinit(); >>>>>>> #endif >>>>>>> >>>>>>> >>>>>>> >>>> >>> >>>
