Commit graph

471 commits

Author SHA1 Message Date
Allan Stephens 1342adbd63 unified: Add missing arguments to K_TIMER_DEFINE()
It is now possible to specify the expiry and stop functions
of a statically-defined timer, just as can be done for a
dynamically-defined timer.

[Part of fix to ZEP-1186]

Change-Id: Ibb9096f3fdafdc6c904184587f86ecd52accdd66
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-11-04 00:47:23 +00:00
Allan Stephens e7d2cc216d unified: Add object tracing support for kernel objects
Defines an object tracing list for each kernel object type
that supports object tracing, and ensures that both statically
and dynamically defined objects are added to the appropriate list.

Ensure that each static kernel object is grouped together with
the other static objects of the same type. Revise the initialization
function for each kernel type (or create it, if needed) so that
each static object is added to the object tracing list for its
associated type.

Note 1: Threads are handled a bit differently than other kernel
object types. A statically-defined thread is added to the thread
list when the thread is started, not when the kernel initializes.
Also, a thread is removed from the thread list when the thread
terminates or aborts, unlike other types of kernel objects which
are never removed from an object tracing list. (Such support would
require the creation of APIs to "uninitialize" the kernel object.)

Note 2: The list head variables for all kernel object types
are now explicitly defined. However, the list head variable for
the ring buffer type continues to be implicitly defined for the
time being, since it isn't considered to be an core kernel object
type.

Change-Id: Ie24d41023e05b3598dc6b344e6871a9692bba02d
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-11-02 21:56:27 +00:00
Peter Mitsis 058fa4e493 unified: API changes to event handling
Allows event objects to pend signals in a cumulative way using
the semaphore in a non-binary way.

Jira: ZEP-928
Change-Id: I3ce8a075ef89309118596ec5781c15d4f3289d34
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-11-01 16:27:41 -04:00
Peter Mitsis 348eb4c4fb unified: Update kernel.h doxygen comments
Jira: ZEP-981
Change-Id: I3797f5e8824b4a01153f3c1fe0e070d3b107f596
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-31 23:56:04 +00:00
Benjamin Walsh 31a3f6a70e unified: rename 'events' to 'alerts'
Event is such an overloaded and generic term (event logger, *kernel*
event logger, "protocol" events in other subsystems, etc.), that it is
confusing for the name an object. Events are kinda like signals, but not
exactly, so we chose not to name them 'signals' to prevent further
confusion. "Alerts" felt like a good fit, since they are used to "alert"
an application that something of significance should be addressed and
because an "alert handler" can be proactively registered with an alert.

Change-Id: Ibfeb5eaf0e6e62702ac3fec281d17f8a63145fa1
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-10-28 18:44:18 +00:00
Benjamin Walsh 7ef0f624a7 unified: rename 'memory maps' to 'memory slabs'
This better aligns with the actual functionality of the object.

Change-Id: I70abf54f994e92abd7367251089ea4f735d273fe
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-10-28 18:44:18 +00:00
Allan Stephens 88095027f4 unified: Ensure K_THREAD_DEFINE() generates a thread id
Previously the macro provided no way for an application to
easily reference a statically-defined thread.

Change-Id: I552e5f4ab4e6e8a793bb3a6a2b0c2636b900023a
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-27 08:36:14 -05:00
Allan Stephens 6cfe1322f8 unified: Streamline thread initialization macros
The _THREAD_INITIALIZER() macro is now used in all cases where
a static thread is defined. It accepts the arguments used by
k_thread_spawn(), as well as the legacy abort function and task
group arguments.

The two remaining legacy macros required to support static threads
now appear in legacy.h.

Change-Id: I7ba24c285beee63d63c8da0e0fa120f35c0d9526
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-27 08:14:51 -05:00
Allan Stephens 7c5bffa669 unified: Add options field to static thread initialization structure
Adds the field, in preparation for making use of it in the future.

Also re-orders the existing fields of the _static_thread_data
structure so they appear in the same order as the arguments
to k_thread_spawn(). This makes it easier to ensure all of the
arguments and fields are handled in a consistent manner.

Change-Id: I401687ecfdacd52c05ab95af7f12d8dc658ed419
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-27 08:14:51 -05:00
Andrew Boie 431607c20a nios2: port to unified kernel
With this patch we introduce unified kernel support for NIOS II.
Not all test cases have been ported, but the following command
currently succeeds with 43/43 passing test cases:

 $ sanitycheck --arch=nios2 -xKERNEL_TYPE=unified \
         --tag=unified_capable

Issue: ZEP-934
Change-Id: Id8effa0369a6a22c4d0a789fa2a8e108af0e0786
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-10-26 17:10:13 +00:00
Allan Stephens e262615280 unified: Remove k_thread_abort_handler() support
The new kernel doesn't support the thread abort handler concept,
so only the legacy API for this capability is needed.

Change-Id: Ie809092e73b784504c3d298911d216bed8dd8993
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-26 17:03:12 +00:00
Allan Stephens 480a131ad9 unified: Support heap memory pool
Fleshes out the prototype heap memory pool support
to make it fully operational. Noteworthy changes are
listed below:

Tweaks arguments to k_malloc() and k_free() to be more like
malloc() and free(). Similarly, modifies k_free() to take
no action when passed a NULL pointer.

Now stores the complete block descriptor at the start
of any block allocated from the heap memory pool. This
increases memory overhead by 4 bytes per block, but
streamlines the allocation and freeing algorithms. It also
ensures that the routines will work if the block descriptor
internals are changed in the future.

Now allows the heap memory pool to be defined using the
HEAP_MEM_POOL_SIZE configuration option. This will be the
official configuration approach in the unified kernel.

Also allows the heap memory pool to be defined using the
(undocumented) HEAP_SIZE entry in the MDEF. This is provided
for legacy reasons only.

Co-locates memory pool initialization code to keep the line
that causes memory pool initialization to be done during booting
right next to the routine that does the initialization.

Change-Id: Ifea9d88142fb434d4bea38bb1fcc4856a3853d8d
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-25 00:10:34 +00:00
Allan Stephens 904cf97263 unified: Eliminate thread config structure used by work queues
Reworks k_work_q_start() so that it accepts its 3 configuration
settings directly, rather than forcing the caller to pass in a
configuration data structure.

Change-Id: Ic0bd1b94f1a1c8e0f8a84b3bd3677d59d0708734
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-25 00:10:34 +00:00
Allan Stephens 06aefdb654 unified: Align thread creation APIs
Aligns the APIs for defining a thread at compile time and for
spawning a thread at run time.

Change-Id: Ic5df450cbe4d0eb562fb4a608f1ac5a8a7cb4b96
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-25 00:10:33 +00:00
Allan Stephens 35ffaff43d unified: Don't bother initializing memory map buffer
The "__noinit" was accidentally lost during initial prototyping
of the unified kernel. This just restores it ...

Change-Id: Id13e0e9a323c1bcd49c28a5d8da73943b0177890
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-25 00:10:33 +00:00
Peter Mitsis 602e6a8ae7 unfied: Tweak stack API parameters
- Reorders parameters where necessary

Change-Id: I0aa659515b71c8f2d6ed7fae47489ddcb10eb69f
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-24 22:58:27 +00:00
Peter Mitsis ddbe77a1dd unified: Remove unused K_STACK_SIZE() macro
Change-Id: I3ded26e249fec3e9024984f4a788bf312c3c2d88
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-24 22:58:26 +00:00
Dmitriy Korovkin 3c90651fd8 unified/arc: add memory pools support for ARC architecture
ARC does not align data structures by 4 bytes by default.
Add necessary linker sections.

Change-Id: I3bf7aa38b9bc8cba56f824469040c027968fa564
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-10-22 01:27:01 +00:00
Peter Mitsis 5f39924e58 unified: memory pool APIs to use size_t
Change-Id: Id1dd37ad3bb35052fd53a6a26711c9e0c2070a25
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-21 15:33:58 +00:00
Peter Mitsis fb02d576c0 unified: Memory map APIs to use size_t
Change-Id: I035019c0cb7193400d02f493546fd3964baf073a
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-21 15:33:45 +00:00
Peter Mitsis 4a5d62fe15 unified: Update mem_map doxygen style function headers
Change-Id: Ic683a3ea6f723cf3d615ad28ebf603ed50af9155
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-21 15:33:44 +00:00
Allan Stephens 6c98c4d378 unified: Ensure delays do not time out prematurely
Ensures that all APIs which accept a timeout value wait for at least
the specified amount of time, and do not time out prematurely.

* The kernel now waits for the next system clock tick to occur before
  the timeout interval is considered to have started. (That is, the only
  way to ensure a delay of N tick intervals is to wait for N+1 ticks
  to occur.)

* Gets rid of ticks -> milliseconds -> ticks conversion in task_sleep()
  and fiber_sleep() legacy APIs, since this introduces rounding that
  -- coupled with the previous change -- can alter the number of ticks
  being requested during the sleep operation.

* Corrects work queue API that was incorrectly shown to use a delay
  measured in ticks, rather than milliseconds.

Change-Id: I8b04467237b24fb0364c8f344d872457418c18da
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-21 15:33:29 +00:00
Peter Mitsis 026b4ed4e2 unified: msgqs to use size_t
Change-Id: I9bedf22a052990395a1f83417c533b197b31987a
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-20 15:20:40 -04:00
Benjamin Walsh b9c1a067bf unified: doxygen comments for semaphores.
Change-Id: If1a9fa887b07736a70cb26227e147120e5a86f6f
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2016-10-19 18:36:03 +00:00
Allan Stephens 45bfa37f97 unified: Revise timer code to conform to new API specification
Provides users with a more compact and intuitive API for kernel
timers.

Provides legacy support for microkernel timers and nanokernel
timers by building on the new kernel timer infrastructure.
Each timer type requires only a small amount of additional
wrapper code, as well as the addition of a single pointer
field to the underlying timer structure, all of which will be
easily removed when support for the legacy APIs is discontinued.

Change-Id: I282dfaf1ed08681703baabf21e4dbc3516ee7463
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-19 18:14:58 +00:00
Peter Mitsis d7a3750b3c unified: Update msgq doxygen styled function headers
Change-Id: I4648ebcda9e6c3abea05b420584e2bcb112f3ed4
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-19 14:54:45 +00:00
Peter Mitsis 1da807e7a8 unified: Tweak msgq API parameters
- Reorders parameters where necessary
 - Adds alignment parameter to K_MSGQ_DEFINE() for buffer alignment
 - Renames parameters where necessary so they are more intuitive

Change-Id: I0b53105c04109127897bf4790e6908082f82da4e
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-19 14:54:44 +00:00
Peter Mitsis 67be24909d unified: Add k_msgq_num_free_get() API
Complements existing k_msgq_num_used_get().

Change-Id: If04a540878ae998ccdc14867a022c428947604a6
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-19 14:54:44 +00:00
Peter Mitsis f925f0f853 unified: Remove unused K_MSGQ_SIZE() macro
Change-Id: Ifabe0615672576834d41b36dfcc121d3de1ac30b
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-19 14:54:43 +00:00
Peter Mitsis 578f9111ed unified: Tweak mem_map API parameters
- Reorders parameters where necessary
 - Adds buffer alignment parameter to K_MEM_MAP_DEFINE()

Change-Id: Ifa1a09c62492cd6db8bdd83f31a5ca5ba072b484
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-18 15:31:51 +00:00
Peter Mitsis c001aa8ef6 unified: Add k_mem_map_num_free_get()
Complements existing k_mem_map_num_used_get().

Change-Id: Ie69c0a8e30007e365820448bde48303718369904
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-18 15:31:50 +00:00
Peter Mitsis c19dd50093 unified: Remove unused K_MEM_MAP_SIZE() macro
Change-Id: I25673bbeeb5ba188f6e6f52e237494cfeb85a8c6
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-18 15:31:50 +00:00
Peter Mitsis 937042c22a unified: Update mem_pool doxygen style function headers
Change-Id: I3b751522bbabaec5c5146cc28b85d188344a693f
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-18 15:30:40 +00:00
Peter Mitsis 2a2b075826 unified: Tweak K_MEMORY_POOL_DEFINE() macro
- Renames to K_MEM_POOL_DEFINE() for consistency
- Adds alignment parameter to align the pool buffer.

Jira: ZEP-926
Change-Id: I6cf0a1ce45c3a0fc5f0675047d8928659df1e75e
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-18 15:30:40 +00:00
Peter Mitsis c61495b9bd unified: Remove unused K_MEM_POOL_SIZE() macro
Change-Id: I1fe11628baf6d8db1dcf5a57399b29f37496dd1b
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-18 15:30:39 +00:00
Peter Mitsis b2fd5be4dc unified: Rework K_THREAD_DEFINE()
K_THREAD_DEFINE() can no longer specify a thread group. However, it now
accepts a 'delay' parameter just as k_thread_spawn() does.

To create a statically defined thread that may belong to one or more thread
groups the new internal _MDEF_THREAD_DEFINE() macro is used. It is only used
for legacy purposes.

Threads can not both have a delayed start AND belong to a thread group.

Jira: ZEP-916
Change-Id: Ia6e59ddcb4fc68f1f60f9c6b0f4f227f161ad1bb
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-17 17:52:33 +00:00
Peter Mitsis d93078cb5b unified: Mailboxes to use size_t
Change-Id: I67c1b11d2b6c09e96eb72c3e16f67f5b5acbed3a
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-15 07:41:24 +00:00
Peter Mitsis 1209270bf8 unified: Relocate mailbox doxygen style function headers
Change-Id: I06e9ce40da650df67f05db8779a5f6199e6091d5
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-15 07:41:23 +00:00
Peter Mitsis 40680f6eb9 unified: Tweak mailbox API parameters
Tweak mailbox API parameters so that not only are their descriptions
correct, but their names match across header file and C file.

Change-Id: Ieeb3a40fb7c535a5eac2e06533d01d13aaf69181
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-15 07:41:23 +00:00
Peter Mitsis 2fef023c3d unified: Conditionally declare k_pipe_block_put()
The routine k_pipe_block_put() is only available if the system has
been configured for asynchronous pipe sends.

Change-Id: I642fecc961ca4ef4ac8839a01ffd4125c30794b8
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-15 07:09:59 +00:00
Peter Mitsis e5d9c58301 unified: Tweak pipe API parameters
- Reorders parameters where necessary
 - Adds alignment parameter to K_PIPE_DEFINE()
 - Renames parameters where necessary so they are sync'd
   between header and source files

Change-Id: I4f2367abc28aff646cc90beb9f08bb266e143b0c
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-15 07:09:58 +00:00
Peter Mitsis 59f59088ea unified: Remove unused K_PIPE_SIZE() macro
Change-Id: If7d3a0c9153365222c85072e62a537317b998bdb
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-15 07:09:57 +00:00
Allan Stephens 1d07bd1bff unified: Eliminate support for dynamic timers
Gets rid of official support for dynamic timer allocation
in the unified kernel, since users can easily define and
initialize timers at any time. Legacy support for dynamic
timers is maintained for backwards compatibility reasons
for the time being ...

Change-Id: I12b3e25914fe11e3886065bee4e96fb96f59b299
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-13 13:54:00 +00:00
Allan Stephens 018cd9a656 unified: Eliminate k_stack_init_with_buffer()
Folds this API into k_stack_init() to provide a single API
that requires the caller to pass in the stack buffer, just
as is done for other kernel objects initialization APIs
involving the use of a buffer.

Change-Id: Icad5fd6e5387d634738d1574f8dfbc5421cd642d
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-13 13:54:00 +00:00
Allan Stephens 399d0ad55a unified: Rationalize thread priority APIs
* Gets rid of k_current_priority_get(). Users can just call
  k_thread_priority_get(k_current_get()) instead.

* Declares k_thread_priority_get() in kernel.h, where it
  really belongs.

* Removes duplicate declaration of k_thread_priority_set().

Change-Id: I616ae6f2e06c95ecba3b92324186b3fa29162fd1
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-13 13:53:59 +00:00
Allan Stephens b03955033b unified: Eliminate unimplemented unified kernel APIs
Gets rid of unified kernel APIs that will never be implemented.
(i.e. They were proposed, but are no longer considered desirable.)

Change-Id: I63ff0d2cdef355d21595f2a778ef5d5b18796149
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-13 13:53:59 +00:00
Allan Stephens ea6cfd1d83 unified: Add legacy DEFINE_TASK support
Allows unified kernel to support legacy microkernel applications
that use private tasks.

Also renames the unified kernel macro for defining a thread
to be consistent with the naming used for defining other kernel
objects.

Change-Id: I667d87056138c45c291dd848344e4051bf9fd1ff
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-11 09:59:16 -05:00
Allan Stephens 86ea333b5a unified: Remove unimplemented kernel workload APIs
These can be re-introduced if a kernel workload measuring
capability is added to the unified kernel.

Change-Id: Id7ad9c1239667511ffcecf571126301c9b278929
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-10-11 09:54:44 -05:00
Benjamin Walsh 1a5450bb8e unified: merge NANO_TIMERS and NANO_TIMEOUTS with SYS_CLOCK_EXISTS
Timers are based off timeouts now, which can only be enabled when the
system clock is enabled. So the three are really just one setting now.

Keep the NANO_TIMERS and NANO_TIMEOUTS around for now until all
middleware that rely on them is updated. They are always enabled when
SYS_CLOCK_EXISTS is enabled.

Change-Id: Iaef1302ef9ad8fc5640542ab6d7304d67aafcfdc
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-10-10 21:27:41 +00:00
Benjamin Walsh b7ef0cba5f unified: remove last instances of struct tcs
Change-Id: I956bf0e96266e68ac1743f02a82ffafe77ebb0e8
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-10-10 21:27:38 +00:00
Benjamin Walsh 055262c159 unified: remaining timeout cleanup
Rename remaining functions to fit with kernel naming convention for
internal interfaces. Use struct k_thread instead of struct tcs.

Change-Id: I28cd7f6f4d7ddaeb825c8d2999242d8d2dd93f31
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-10-10 21:27:37 +00:00
Benjamin Walsh 57d55dcc7a unified: have __ticks_to_ms() return 0 when no system clock
Change-Id: I0834dfff2a631ef365be7ae3a55d5ad4ace3dbf5
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-10-10 21:27:32 +00:00
Benjamin Walsh 71d5228ca9 unified: un-comment k_thread_[suspend|resume|abort_handler_set]
They are now available.

Change-Id: Iae15636396fdf4d5da96f6735345857d83cd3d51
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-10-10 21:27:30 +00:00
Iván Briano 9c7b5eacea unified: Fix building of the unified kernel
Change-Id: I6824cdb9123a574a56af10efdebdc1c8b82427f8
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-10-04 18:11:05 -03:00
Peter Mitsis a04c0d70e1 unified: Rename k_thread_static_init structure
Renames the k_thread_static_init structure to better follow
Zephyr naming conventions.

Change-Id: I479add2aefa3421ebc0b879e0d04c0c7ffd7f107
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-04 19:57:58 +00:00
Luiz Augusto von Dentz 4ab9d32bd3 unified: Don't assert if work is pending on submit
This makes k_work_submit to allow resubmits when the work is pending so
the user code don't have to check the pending flag to avoid a possible
assert.

Change-Id: Ic39f3dc5936837ce84ad028cf3d426d0558c2925
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-04 17:30:42 +03:00
Luiz Augusto von Dentz ee1e99b3b7 unified: Add k_work_pending
This adds k_work_pending which can be use to check if a k_work is
pending execution.

Change-Id: Ifd56e8d65d555c7e9722c547fe83e13e886d63cd
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-04 17:30:42 +03:00
Peter Mitsis 0cb65c3c0d unified: Eliminate k_mem_pool_t typedef
Replaces it with a pointer as there is no need for an opaque memory
pool type.

Jira: ZEP-916
Change-Id: I5493eed25c9c34e1b850dc3b20699864edb22d28
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-03 20:17:02 +00:00
Peter Mitsis 0ca7cea8f3 unified: Relocate internal thread group APIs
Moves the following internal thread group APIs from the public
kernel.h header file to the more private thread.c source file as
they do not need to be public APIs.
	_k_task_list_start[];
	_k_task_list_end[];
	_FOREACH_STATIC_THREAD()
	is_in_any_group()

Change-Id: I0b731fb0c20a5574cb1b3c1397803af82918d69d
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-03 20:17:02 +00:00
Benjamin Walsh 72e5a39ba7 unified: fix misc issues with APIs in kernel.h
ZEP-1022

Change-Id: I88a043cb0127631fcbb48c91504fe4fcd6ae1ecc
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-10-01 01:36:38 +00:00
Benjamin Walsh 9091e5d253 unified: use correct init macro for k_fifo objects
Was using dlist macro instead of slist macro.

ZEP-1021.

Change-Id: I374ae88289669ca03e3c0c76d33fa0229977e403
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-10-01 01:36:38 +00:00
Dmitriy Korovkin 284042d746 unified: Invoke kernel object initialization with SYS_INIT macro
Kernel object initialization needs to follow the common initialization
scheme.

Change-Id: I6693678ed7c4975b3c588061013fa0c5d24968c3
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-09-28 19:13:35 +00:00
Benjamin Walsh ba5ddc189e unified: implement k_uptime_{get,delta}()
Simple conversion from ticks for now.

Change-Id: Ib81fc738d45641a6a3a88d2adec1f3eb861f3f97
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-23 21:39:40 +00:00
Benjamin Walsh a9604bd895 unified: move basic ticks-to-ms conversion to kernel.h
The basic conversion, i.e. not handling the TICKS_UNLIMITED case, is
useful internally since the kernel is still tick-based.

Change-Id: I00a01047ec48dad6834dd8ea5dc831eb8c0c2501
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-23 21:39:40 +00:00
Andy Ross 8d8b2acb26 k_timer: Don't allocate dynamic timers by default
Most apps run fine with static k_timer objects.  Don't pay the cost
for the timer pool if no one asks for it.

Also turn off the allocate/free API in the header if it can't possibly
work at runtime as it's an obviously-detectable error that would
otherwise be visible only at runtime.

Change-Id: I492e6e01c4213e3544f707247eea6e4bc601fefd
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2016-09-23 18:25:37 +00:00
Benjamin Walsh 70c68b92de unified: change signature of k_sem_reset()
Does not need to return anything, since it simply resets the count.

Change-Id: I1185ea1728a9809178afa53b3dba47f7650218e2
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-22 21:09:44 +00:00
Benjamin Walsh 0bee91dae1 unified: fix some leftover K_<obj>_DEFINE macros
The K_<obj>_DEFINE macros in the unified kernel create objects of name
'name', and not a pointer named 'name' to an object. Some macros
contained the code from early prototyping.

Change-Id: I7262570fbe0b267012874eac0185b4e0cd7f523d
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-22 21:09:22 +00:00
Tomasz Bursztyka 276086da28 kernel: Fix for k_sem where counter is a unsigned int
So let the helper return the right type.

Change-Id: I850937a70fe042e42c06cb53ad736c8904221f1b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-09-22 17:01:48 +00:00
Dmitriy Korovkin 3c426888a1 unified: Implement memory pools
Due to the memory pool structure only static declaration of
memory pool is possible.

Change-Id: I4797ed88fd2ac3b7812ff26e552e1745611c4575
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-09-20 22:04:46 +00:00
Peter Mitsis 45403678aa unified: Add support for semaphore groups
Semaphore groups are enabled by default. Disabling them will both
decrease the footprint as well as improve the performance of the
k_sem_give() routine.

Change-Id: If6c1b0e2e1f71afd43e620f05f17068039d12b05
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-09-20 11:45:28 -04:00
Benjamin Walsh 456c6daa9f unified: initial unified kernel implementation
Summary of what this includes:

    initialization:

    Copy from nano_init.c, with the following changes:

    - the main thread is the continuation of the init thread, but an idle
      thread is created as well

    - _main() initializes threads in groups and starts the EXE group

    - the ready queues are initialized

    - the main thread is marked as non-essential once the system init is
      done

    - a weak main() symbol is provided if the application does not provide a
      main() function

    scheduler:

    Not an exhaustive list, but basically provide primitives for:

    - adding/removing a thread to/from a wait queue
    - adding/removing a thread to/from the ready queue
    - marking thread as ready
    - locking/unlocking the scheduler
      - instead of locking interrupts
    - getting/setting thread priority
      - checking what state (coop/preempt) a thread is currenlty running in
    - rescheduling threads
    - finding what thread is the next to run
    - yielding/sleeping/aborting sleep
    - finding the current thread

    threads:

    - Add operationns on threads, such as creating and starting them.

    standardized handling of kernel object return codes:

    - Kernel objects now cause _Swap() to return the following values:
         0      => operation successful
        -EAGAIN => operation timed out
        -Exxxxx => operation failed for another reason

    - The thread's swap_data field can be used to return any additional
    information required to complete the operation, such as the actual
    result of a successful operation.

    timeouts:

    - same as nano timeouts, renamed to simply 'timeouts'
    - the kernel is still tick-based, but objects take timeout values in
      ms for forward compatibility with a tickless kernel.

    semaphores:

      - Port of the nanokernel semaphores, which have the same basic behaviour
      as the microkernel ones. Semaphore groups are not yet implemented.

      - These semaphores are enhanced in that they accept an initial count and a
      count limit. This allows configuring them as binary semaphores, and also
      provisioning them without having to "give" the semaphore multiple times
      before using them.

    mutexes:

    - Straight port of the microkernel mutexes. An init function is added to
    allow defining them at runtime.

    pipes:

    - straight port

    timers:

    - amalgamation of nano and micro timers, with all functionalities
      intact.

    events:

    - re-implementation, using semaphores and workqueues.

    mailboxes:

    - straight port

    message queues:

    - straight port of  microkernel FIFOs

    memory maps:

    - straight port

    workqueues:

    - Basically, have all APIs follow the k_ naming rule, and use the _timeout
    subsystem from the unified kernel directory, and not the _nano_timeout
    one.

    stacks:

    - Port of the nanokernel stacks. They can now have multiple threads
    pending on them and threads can wait with a timeout.

    LIFOs:

    - Straight port of the nanokernel LIFOs.

    FIFOs:

    - Straight port of the nanokernel FIFOs.

Work by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
         Peter Mitsis <peter.mitsis@windriver.com>
         Allan Stephens <allan.stephens@windriver.com>
         Benjamin Walsh <benjamin.walsh@windriver.com>

Change-Id: Id3cadb3694484ab2ca467889cfb029be3cd3a7d6
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00