os; add syscfg option which tells whether OS will be started or not.
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/f2b25f04 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f2b25f04 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f2b25f04 Branch: refs/heads/develop Commit: f2b25f0473e62e66c4bf87086eb027611a443780 Parents: b83b0f3 Author: Marko Kiiskila <[email protected]> Authored: Wed Dec 28 13:29:06 2016 -0800 Committer: Marko Kiiskila <[email protected]> Committed: Wed Dec 28 13:29:06 2016 -0800 ---------------------------------------------------------------------- kernel/os/src/os.c | 4 ++++ kernel/os/src/os_heap.c | 8 +++++++- kernel/os/src/os_time.c | 9 +++++++++ kernel/os/syscfg.yml | 3 +++ 4 files changed, 23 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f2b25f04/kernel/os/src/os.c ---------------------------------------------------------------------- diff --git a/kernel/os/src/os.c b/kernel/os/src/os.c index c313a26..6dfe128 100644 --- a/kernel/os/src/os.c +++ b/kernel/os/src/os.c @@ -179,6 +179,7 @@ os_init(void) void os_start(void) { +#if MYNEWT_VAL(OS_SCHEDULING) os_error_t err; err = os_dev_initialize_all(OS_DEV_INIT_KERNEL); @@ -189,6 +190,9 @@ os_start(void) err = os_arch_os_start(); assert(err == OS_OK); +#else + assert(0); +#endif } void http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f2b25f04/kernel/os/src/os_heap.c ---------------------------------------------------------------------- diff --git a/kernel/os/src/os_heap.c b/kernel/os/src/os_heap.c index 8592be0..0d94325 100644 --- a/kernel/os/src/os_heap.c +++ b/kernel/os/src/os_heap.c @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - +#include "syscfg/syscfg.h" #include <assert.h> #include "os/os_mutex.h" @@ -29,28 +29,34 @@ * @{ */ +#if MYNEWT_VAL(OS_SCHEDULING) static struct os_mutex os_malloc_mutex; +#endif static void os_malloc_lock(void) { +#if MYNEWT_VAL(OS_SCHEDULING) int rc; if (g_os_started) { rc = os_mutex_pend(&os_malloc_mutex, 0xffffffff); assert(rc == 0); } +#endif } static void os_malloc_unlock(void) { +#if MYNEWT_VAL(OS_SCHEDULING) int rc; if (g_os_started) { rc = os_mutex_release(&os_malloc_mutex); assert(rc == 0); } +#endif } /** http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f2b25f04/kernel/os/src/os_time.c ---------------------------------------------------------------------- diff --git a/kernel/os/src/os_time.c b/kernel/os/src/os_time.c index 52ca7e5..3f6816d 100644 --- a/kernel/os/src/os_time.c +++ b/kernel/os/src/os_time.c @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +#include "syscfg/syscfg.h" #include <assert.h> @@ -67,6 +68,7 @@ os_time_get(void) return (g_os_time); } +#if MYNEWT_VAL(OS_SCHEDULING) static void os_time_tick(int ticks) { @@ -113,6 +115,13 @@ os_time_advance(int ticks) } } } +#else +void +os_time_advance(int ticks) +{ + g_os_time += ticks; +} +#endif /** * Puts the current task to sleep for the specified number of os ticks. There http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f2b25f04/kernel/os/syscfg.yml ---------------------------------------------------------------------- diff --git a/kernel/os/syscfg.yml b/kernel/os/syscfg.yml index e2efda7..e175bce 100644 --- a/kernel/os/syscfg.yml +++ b/kernel/os/syscfg.yml @@ -27,6 +27,9 @@ syscfg.defs: OS_COREDUMP: description: 'TBD' value: 0 + OS_SCHEDULING: + description: 'Whether OS will be started or not' + value: 1 OS_CPUTIME_FREQ: description: 'Frequency of os cputime' value: 1000000
