1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

1060 Commits

Author SHA1 Message Date
b84c3e47bf
Merge pull request #17267 from maribu/core/alignof
core/kernel_defines.h: drop ALIGN_OF()
2022-01-05 14:10:00 +01:00
chrysn
49ff487ea2 core: Warn about using irq_enable 2021-12-21 18:03:55 +01:00
Vitor Batista
921fdd0975 core/include/debug.h: minor debug fix 2021-12-08 17:09:17 +01:00
Benjamin Valentin
41a5b7ef7a core: change return type of irq_is_in(), irq_is_enabled() to bool
This only cleans up the API, no change in behavior or users of the API
is expected.
2021-12-08 15:53:15 +01:00
Marian Buschsieweke
b9c07f9622
core/sched: silence -Wcast-align 2021-12-03 10:12:34 +01:00
Benjamin Valentin
b5ea78ad47 core/msg: make msg_avail() return 0 on no queue
For the caller there should be no difference if there is no message
in the queue and if there can't be a message in the queue.

The current API works as one would expect if there is a message queue,
but once called from a thread that does not have a message queue
configured, code that does

    while (msg_avail())

will end up in an infinite loop.

Remove this foot-gun from the API by making the return value of
msg_avail() independend of the availability of a message queue.
2021-11-29 12:04:16 +01:00
Marian Buschsieweke
9535447e6f
core/kernel_defines.h: drop ALIGN_OF()
Since we moved to C11 now for all platforms, using `alignof()` provided
by `<stdalign.h>` has become the better option.
2021-11-25 09:20:22 +01:00
Jan Romann
3c86b74dc6
core: uncrustify 2021-11-18 15:44:00 +01:00
Marian Buschsieweke
d7a0ea1eec
core/bitarthm: suppress false positives
Co-authored-by: chrysn <chrysn@fsfe.org>
2021-11-18 09:45:22 +01:00
Marian Buschsieweke
58e197098d
core: add WITHOUT_PEDANTIC() and DECLARE_CONSTANT()
`WITHOUT_PEDANTIC(expr)` disables `-Wpedantic` for `expr`, but switches
back to the previous diagnostic settings afterwards. This helps defining
macros that are not strictly ISO compliant without having to drop the
`-Wpedantic` flag entirely.

`DECLARE_CONSTANT(identifier, const_expr)` declares an anonymous `enum`
constant named `identifier` and assigns it the value `const_expr`. Here,
`const_expr` has to be a compile time constant, but is not needed to be
an integer constant expression. It basically is a tool to magically
convert a non-integer constant expression into a integer constant
expression.
2021-11-10 15:22:47 +01:00
Benjamin Valentin
e2639cb53a core/include/kernel_defines.h: Fix index_of()
Calculate the size of the element based on the array given, not based
on the element pointer.

The element might as well be given as a `void *` via a callback.
In that case, if the user forgets to cast the `void *` to the array
element type, the calculation returns false values.

Disarm this foot gun by basing the element size off the given array.
2021-11-06 00:35:39 +01:00
Benjamin Valentin
01a49d3d19 core/include/kernel_defines.h: add index_of() macro 2021-11-05 16:42:38 +01:00
Martine Lenders
e27fd3018e
core/thread.h: fix new uncrustify error 2021-11-05 09:27:00 +01:00
Martine Lenders
f08989a3c8
core: make SCHED_TEST_STACK boolean and default to 1 with DEVELHELP 2021-11-05 09:27:00 +01:00
Hauke Petersen
3d7d797a57
core/sched: add sched_change_priority() function
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
2021-11-02 20:44:32 +01:00
Marian Buschsieweke
ff7e7c26cf
core/log: Add anchor to doc to allow stable references 2021-10-10 21:35:31 +02:00
Martine Lenders
ea8e632eda
Merge pull request #16765 from benpicco/RIOT_VERSION_CODE
build system: add machine-readable RIOT_VERSION_CODE macro
2021-09-22 12:47:35 +02:00
Benjamin Valentin
7ef2594327 core/include/kernel_defines.h: add RIOT_VERSION_NUM macro 2021-09-21 17:43:29 +02:00
4fd1ae89a7
Merge pull request #16463 from kfessel/p-sched-int
core/sched: add runq_callback hook and runq inspection functions
2021-09-15 15:43:50 +03:00
2b2c5fe746 core/thread: provide getters for thread_t fields as used by ps() 2021-09-15 10:16:45 +02:00
chrysn
137399c8cb core/msg doc: Clarify; elaborating on interaction with queue 2021-09-01 14:56:41 +02:00
Hauke Petersen
b526394d82 core/irq.h: add irq_is_enabled() function 2021-08-25 08:01:05 +02:00
Jan Romann
4384795cb9
treewide: Remove excessive newlines 2021-08-13 19:50:38 +02:00
Karl Fessel
671a7edca1 core/sched: uncrustify sched_cb declaration
this is a change out of this PR scope to reduce
the number of uncrustify complains for future edits
2021-08-09 14:22:07 +02:00
Karl Fessel
3508012942 core/sched: name inspection functions the same as the used clist fns 2021-08-09 14:18:18 +02:00
Francisco
d7b3328601
Merge pull request #16098 from kfessel/p-remove-lifo
core/lifo: Remove lifo [after 2021.04]
2021-06-15 13:55:30 +02:00
JulianHolzwarth
8309889e39 core/msg.c: fixed msg_queue_print() 2021-06-02 01:28:22 +02:00
Karl Fessel
9f00528a58 core/sched: add runq_callback hook and runq inspection functions 2021-05-10 15:01:58 +02:00
95a2456457
Merge pull request #16330 from kfessel/p-add-clist-special
core/clist: add special cardinality tests and matching unittest
2021-04-15 12:14:58 +02:00
Karl Fessel
5735d99971 core/clist: add special cardinality tests and matching unittest
adds clist_exactly_one() and clist_more_than_one()
and a unittest that tests them
2021-04-14 21:00:10 +02:00
Karl Fessel
1dde0f42d4 core/sched: keep scheduler clist internal to sched
adds sched_runq_advance(prio)
used it in core/thread and
test malloc_thread_safety
2021-04-14 09:53:04 +02:00
020945a773 core/clist: add clist_is_empty() 2021-04-09 10:54:29 +02:00
Joakim Nohlgård
87727febd7 core/msg: Fix mismatched printf bool format
_Bool will be extended to int when calling the variadic printf function.
2021-03-24 12:01:23 +01:00
Joakim Nohlgård
783c407787 core/msg: Fix mismatched printf signed/unsigned format
enum signedness depends on the platform settings, use explicit casts for robustness
2021-03-24 12:01:18 +01:00
Joakim Nohlgård
a83516b2f6 core/msg: Fix mismatched printf signed/unsigned format
cib_avail returns unsigned int
2021-03-24 12:01:07 +01:00
e8e8405c4a core/thread: move thread configuration into seperate header 2021-03-02 11:56:11 +01:00
Karl Fessel
1c1f051ab7 core/lifo: Remove lifo 2021-02-27 11:59:36 +01:00
Karl Fessel
55a0ca402b core/lifo: deprecate file for remove after 2021.04 2021-02-27 10:17:33 +01:00
Karl Fessel
9ab0681634 core/lifo: remove lifo.c, keep api with lifo.h
use LOG_DEBUG instead of DEBUG
2021-02-26 17:45:31 +01:00
2861d1f353 core/xfa: typeof() -> __typeof__() 2021-02-23 13:37:19 +01:00
df4dc36d91 core/xfa: add "experimental" note 2021-02-18 10:46:08 +01:00
d310044a88 core/xfa: fix doxygen issues 2021-02-18 10:46:08 +01:00
249ed5f2e1 core/include/xfa.h: uncrustify 2021-02-18 10:46:08 +01:00
2bc7bb4740 core/xfa: make externc happy 2021-02-18 10:46:08 +01:00
e827f0bdf1 core/xfa: add comments explaining the pragmas 2021-02-18 10:46:08 +01:00
50dc68bd21 core/xfa: make const XFA's volatile
This prevents gcc from figuring out that an XFA that has been
initialized in the same file is technically empty when the compilation
unit is seen by itself. This happened with gcc 10.1.0 on msp430-elf.
2021-02-18 10:46:08 +01:00
b54afa1449 xfa: remove duplicate "const" from _XFA_CONST 2021-02-18 10:46:08 +01:00
ac549abbb9 xfa: remove common -Txfa.ld include 2021-02-18 10:46:08 +01:00
bdd59ae7f2 core: disable -Warray-bounds for XFA users 2021-02-18 10:46:08 +01:00
66092f5506 core: Introduce cross file arrays (XFA)
Co-Authored-By: Joakim Nohlgård <joakim.nohlgard@eistec.se>
2021-02-16 14:21:32 +01:00
chrysn
6145949f88 core/mutex: Add assert guard against usage without threads 2021-02-15 06:01:01 +01:00
Martine Lenders
9b40bb63c2
core: apply uncrustify patches 2021-02-02 22:21:14 +01:00
9d5f87bf67
core/thread: Allow for inline thread_yield_higher
Similar to irq.h, this allows for inline the often trivial
thread_yield_higher function
2021-01-19 11:03:20 +01:00
f0ce992d4a
core/thread: uncrustify header file 2021-01-19 10:28:58 +01:00
323fa3b5ac
core/mutex: fix typo in documentation 2020-12-29 11:48:48 +01:00
Marian Buschsieweke
8bbe56c302
core/mutex: compatibility with non-C languages
Due to limited compatibility with C, we cannot use the inline mutex_trylock
implementation for C++. Instead, we provide a mutex_trylock_ffi() intended for
foreign function interfaces. This should also benefit rust users.
2020-12-09 11:53:48 +01:00
Marian Buschsieweke
472d6d0abc
core/mutex: fix documentation 2020-12-08 23:04:16 +01:00
229291ef01
Merge pull request #15442 from maribu/mutex_abort
core/mutex: Add mutex_cancel
2020-12-08 17:12:52 +01:00
Marian Buschsieweke
df66dd0272
core/mutex: uncrustify 2020-12-08 14:50:50 +01:00
Marian Buschsieweke
e348407888
core/mutex: Add mutex_cancel() & mutex_lock_cancelable()
Add a version of `mutex_lock()` that can be canceled with the obvious name
`mutex_lock_cancelable()`. This function returns `0` on success, and
`-ECANCELED` when the calling thread was unblocked via a call to
`mutex_cancel()` (and hence without obtaining the mutex).

This is intended to simplify the implementation of `xtimer_mutex_lock_timeout()`
and to implement `ztimer_mutex_lock_timeout()`.
2020-12-08 14:50:49 +01:00
benpicco
aabd5eaca5
Merge pull request #15506 from kaspar030/refactor_thread_info
core: refactor thread info
2020-11-26 13:01:09 +01:00
ceea0ba949 core/thread: add thread_is_active() 2020-11-25 20:49:00 +01:00
1d5e2e9cd9 all: remove traces of kernel_types.h
Automatically removed using:

    $ git grep -l kernel_types | xargs sed -i '/^#include .kernel_types/d'
2020-11-25 17:52:34 +01:00
017e9e9d4d core/thread: add thread_get_status() 2020-11-25 14:39:22 +01:00
5321bcde89 core: thread: move thread_state_to_string() from ps.c 2020-11-25 14:35:00 +01:00
65f997026f core: drop kernel_types.h 2020-11-25 13:18:53 +01:00
1711b4b649 core/include/kernel_types.h: re-add c++ compat parts 2020-11-23 17:13:35 +01:00
0b801c4de0 all: adapt to moved sched defines 2020-11-23 16:56:34 +01:00
7fa8b69912 core: include inttypes.h in sched.h
sched.h now defines PRIkernel_pid to PRIi16, which in turn is defined in
inttypes.h.
2020-11-23 16:56:34 +01:00
1ca0c23173 core/msg: adapt to changed thread define location 2020-11-23 16:56:34 +01:00
369e9b30e2 core: move scheduler defines to sched.h 2020-11-23 16:56:34 +01:00
91111555a6 core/mbox: add mbox_size() and mbox_avail() 2020-11-20 10:38:17 +01:00
Marian Buschsieweke
a06a7978d3
core/mutex: clean up mutex_lock()
- Split out handling of the blocking code path of mutex_lock() into a static
  `_block()` function. This improves readability a bit and will ease review of
  a follow up PR.
- Return `void` instead of `int`.
2020-11-18 11:58:49 +01:00
Marian Buschsieweke
90103f2a6a
core/mutex: consistent debug output 2020-11-18 09:13:00 +01:00
c4ef8b71e1
Merge pull request #15327 from maribu/mutex_cleanup_splitout
core/mutex: Cleanup
2020-11-13 18:37:27 +01:00
Benjamin Valentin
eea2df99a3 core/msg_bus: enhace documentation 2020-11-09 21:13:08 +01:00
Marian Buschsieweke
d760e931ae
core/mutex: Cleanup
- Use static inline function for `mutex_try_lock()`
    - The implementation is trivial enough with the inline-able IRQ API to just
      always be inline-ed
- Rename `_mutex_lock()` to `mutex_lock()` and drop the blocking parameter
    - This was possible to the stand-alone `mutex_try_lock()` implementation
    - This yields a measurable performance bump
2020-11-06 23:27:13 +01:00
benpicco
f7d9e2f1ab
Merge pull request #15398 from maribu/mutex-doc
core/mutex: improve documentation
2020-11-06 19:15:10 +01:00
Marian Buschsieweke
876d500846
core/mutex: improve documentation 2020-11-06 18:23:26 +01:00
Leandro Lanzieri
1e41c6453a
core/sched_cb: add module to Kconfig 2020-11-06 15:57:56 +01:00
Martine Lenders
dd81a070f0
Merge pull request #15365 from miri64/core/enh/debug-IS_ACTIVE
core: debug: remove parenthesis around ENABLE_DEBUG define
2020-11-03 17:49:14 +01:00
benpicco
ee7a52db2f
Merge pull request #14023 from benpicco/core/msg_bus-bus_flag
core/msg_bus: allow to differ between messages form bus and from thread
2020-11-03 13:51:19 +01:00
Martine Lenders
2df29a6806
core: debug: remove parenthesis around ENABLE_DEBUG define 2020-11-03 13:01:08 +01:00
Benjamin Valentin
d6a6c218a3 core/msg_bus: allow to differ between messages form bus and from thread
Currently it is not possible to check if a message was sent over a bus
or if it was send the usual way using `msg_send()`.

This adds a flag to the `sender_pid` if the message was sent over a bus.
`MAXTHREADS` is currently set to 32, so there is still plenty of room in
the PID space. (`kernel_pid_t` is `int16_t`)

The message type for bus message type is already accessed through a getter
function, so it's just consistent to do the same for sender_pid.
2020-11-03 10:52:43 +01:00
Bas Stottelaar
cc2e6b08d1 core/*: ENABLE_DEBUG not needed for inttypes.h 2020-11-02 21:49:39 +01:00
Bas Stottelaar
2d3d047fd6 core/*: replace #if ENABLE_DEBUG with IS_ACTIVE 2020-11-02 21:34:12 +01:00
Bas Stottelaar
e675b6379e core/*: realign ENABLE_DEBUG 2020-10-23 00:45:56 +02:00
Bas Stottelaar
ff53307599 core/*: reorder ENABLE_DEBUG after last include 2020-10-23 00:41:18 +02:00
benpicco
c979fda1f3
Merge pull request #14367 from basilfx/feature/cortex_m33
cpu/cortex: add initial support for Cortex-M33
2020-10-08 22:55:06 +02:00
Bas Stottelaar
0f8cecb50b cpu/cortexm_common: add support for Cortex-M33 2020-10-06 17:11:26 +02:00
c59349482a
core/msg_bus: fix typo 'busses' -> 'buses'
Also fix typo 'seach' -> 'search'
2020-10-02 07:52:18 +02:00
benpicco
ab15d67e80
Merge pull request #15059 from maribu/core-thread-cast-align
core/thread.c: Silence -Wcast-align flase positives
2020-09-26 16:31:58 +02:00
Marian Buschsieweke
e028f6bbe6
core/thread: thread_measure_stack_free() const arg
Add `const` to stack pointer passed to thread_measure_stack_free()
2020-09-25 14:30:33 +02:00
Marian Buschsieweke
59321065db
core/thread.c: Silence -Wcast-align flase positives
Verified that each warning generated by -Wcast-align is indeed a false positive
and used an (intermediate) cast to `uintptr_t` to silence the warnings.
2020-09-22 15:15:28 +02:00
Marian Buschsieweke
85e506e893
core/include/kernel_defines.h: Fix container_of()
container_of() is safe to use in regard to alignment requirements, when used
correctly. Using `uintptr_t` instead of `char *` for applying the offset results
in -Wcast-align not complaining.
2020-09-22 15:13:03 +02:00
Francisco
64f6b7ffa4
Merge pull request #14702 from maribu/sched_active_thread
treewide: Fix direct access to scheduler internals
2020-09-21 09:09:59 +02:00
Jim O'Brien
bd149e7db9 thread: Add THREAD_NAMES make flag
Separate thread names from DEVELHELP so thread names can be
enabled in non-development/debug builds when required/desired.
THREAD_NAMES will be enabled by default then DEVELHELP is set to 1.
2020-09-10 10:08:27 +02:00
Marian Buschsieweke
2d8bdf9b83
core/sched: Drop declaration of sched_active_{pid,thread}
This should increase odds that developers use thread_get_active() and
thread_getpid() instead.
2020-09-07 12:59:55 +02:00
77735e7e10
Merge pull request #14709 from bergzand/pr/sched/return_thread 2020-09-03 10:18:47 +02:00
495644adc0
sched: return the new thread on sched_run 2020-09-02 13:32:14 +02:00
f68f19a73f
Merge pull request #14722 from bergzand/pr/sched/runqueue_clz
sched: Reverse runqueue order when CLZ is available
2020-09-01 22:57:30 +02:00
Cenk Gündoğan
538155c344
Merge pull request #14904 from leandrolanzieri/pr/kconfig/change_prefix_convention
treewide: modify Kconfig symbol prefixes
2020-09-01 15:57:06 +02:00
c83b78a567
Merge pull request #14762 from maribu/move_byteorder
core/byteorder: Moved to sys
2020-09-01 15:02:11 +02:00
Vincent Dupont
96b018d8dd core/panic: callback app during panic 2020-08-31 16:45:13 +02:00
Leandro Lanzieri
2e79e00ca7
treewide: change Kconfig prefix for module symbols
This changes the prefix used for the symbols that reprensent modules
(not the ones generated from USEMODULE).

MOD_ => MODULE_
2020-08-31 09:57:28 +02:00
dd45eaa472
sched: simplify MODULE_CORE_IDLE_THREAD conditional 2020-08-25 14:00:01 +02:00
764b3102e4
sched: Early exit when scheduling same thread after sleep 2020-08-25 13:59:58 +02:00
benpicco
f3e1032f6e
Merge pull request #14827 from keith-packard/pr/libc/picolibc
Pr/libc/picolibc
2020-08-24 18:06:56 +02:00
Keith Packard
531050ada2 picolibc: Enable TLS support [v4]
Allocate and initialize a thread-local block for each thread at the
top of the stack.

Set the tls base when switching to a new thread.

Add tdata/tbss linker instructions to cortex_m and risc-v scripts.

Signed-off-by: Keith Packard <keithp@keithp.com>

---

v2:
	Squash fixes

v3:
	Replace tabs with spaces

v4:
	Add tbss to fe310 linker script
2020-08-24 08:26:16 -07:00
Marian Buschsieweke
8745d820ba
core/thread_flags: Fix code indention
Apply coding convention on the indent in the single switch statement within
core.
2020-08-23 21:18:10 +02:00
e6fd3630eb
sched: Remove extra mpu_enable during context switch 2020-08-19 20:13:28 +02:00
Marian Buschsieweke
164d2ac8f2
core/byteoder: Moved to sys
The byteorder utilities are never used in `core`, but extensively in `sys`.
They seem to be better located in `sys`.
2020-08-14 16:28:59 +02:00
Marian Buschsieweke
81d40d3f66
core/byteorder: Add byteoder_htobebufll & inverse
- Add `byteorder_bebuftohll()` to read an 64 bit value from a big endian buffer
- Add `byteorder_htobebufll()` to write an 64 bit value into a big endian buffer
2020-08-14 13:36:40 +02:00
Leandro Lanzieri
f5e57fbca4
core: Add modules to Kconfig 2020-08-12 12:22:35 +02:00
ab1d0b6f98
sched: Reverse runqueue order when CLZ is available
This commit reverses the runqueue_cache bit order when the architecture
has a CLZ (count leading zeros) instruction. When the architecture
supports CLZ, it is faster to determine the most significant set bit of
a word than to determine the least significant bit set. Unfortunately
when the instruction is not available, it is more efficient to determine
the least significant bit set.

Reversing the bit order shaves off another 4 cycles on the same54-xpro.
From 147 to 143 ticks when testing with tests/bench_sched_nop.
Architectures where no CLZ instruction is available are not affected.
2020-08-06 20:39:14 +02:00
Marian Buschsieweke
13575b2131
core/thread_flags: Avoid using inline w/o static
Apparently clang doesn't like static variables / functions being accessed called
from inline function (-Wstatic-in-inline). This commit results in the same
binary being generated while making clang happy.
2020-08-06 17:54:32 +02:00
Marian Buschsieweke
57264c5059
core: Access internal vars via helper funcs
Replace accesses to `sched_active_thread`, `sched_active_pid`, and
`sched_threads` with `thread_get_active()`, `thread_get_active_pid()`, and
`thread_get_unchecked()` where sensible.
2020-08-06 16:47:33 +02:00
Marian Buschsieweke
4a31578982
core/thread: Add/change helper access functions
- Add `thread_get_active()` to access the TCB
- Add `thread_get_unchecked()` as fast alternative to `thread_get()`
- Drop `volatile` qualifier in `thread_get()`
    - Right now every caller of this function does this. It is better to
      contain this undefined behavior to at least one place in code
2020-08-06 14:35:43 +02:00
e81d0050d1
Merge pull request #14717 from kaspar030/optim_msg_active_thread
core/msg: sched_threads[sched_active_pid] -> sched_active_thread
2020-08-06 14:18:17 +02:00
5dbcfa3391
Merge pull request #14698 from benpicco/core/bitarithm-msb_clz
core/bitarithm: use __builtin_clz() for bitarithm_msb()
2020-08-06 13:00:34 +02:00
1bb3d56bd5 core/msg: sched_threads[sched_active_pid] -> sched_active_thread
Same result, but only a single volatile read.
2020-08-06 12:46:26 +02:00
c9883cebfd core/atomic_c11: fix I2 typedef for 16bit platforms 2020-08-05 14:32:57 +02:00
Marian Buschsieweke
315cdcdb5f
core/thread: Make thread_get inlineable 2020-08-05 10:51:16 +02:00
Benjamin Valentin
14144030fa core/bitarithm: use __builtin_clz() for bitarithm_msb()
The `clz` instruction pretty much implements getting the most significant bit
in hardware, so use it instead of the software implementation.

This reults in both a reduction in code size as in a speedup:

master:

  text    data     bss     dec     hex filename
 14816     136    2424   17376    43e0 tests/bitarithm_timings/bin/same54-xpro/tests_bitarithm_timings.elf

 + bitarithm_msb: 3529411 iterations per second

this patch:

  text    data     bss     dec     hex filename
 14768     136    2424   17328    43b0 tests/bitarithm_timings/bin/same54-xpro/tests_bitarithm_timings.elf

 + bitarithm_msb: 9230761 iterations per second
2020-08-04 17:50:09 +02:00
benpicco
2d4d29367e
Merge pull request #14642 from maribu/fix-byteorder-big-endian
core/byteorder: Fix be byte buffer conversion on big endian systems
2020-07-29 01:25:03 +02:00
Marian Buschsieweke
e4387c84fd
core/byteorder: Fix from/to be buffers on be
Big endian buffers on big endian systems are already in big endian byte order,
so no byte shuffling is needed. However, byte buffers might be unaligned, so
copy operations that are safe with unaligned memory accesses need to be
used.
2020-07-28 22:34:25 +02:00
Martine Lenders
b1bf8ab981
Merge pull request #14565 from bergzand/pr/sched/fix_retrigger
sched: Prevent retriggering the scheduler interrupt during idle sleep
2020-07-28 22:11:25 +02:00
Leandro Lanzieri
72d6d9047f
Merge pull request #14429 from benpicco/core/boot_msg
core/init: make boot message configurable
2020-07-28 16:40:08 +02:00
Benjamin Valentin
25e67e019e core/init: make boot message configurable
It can be desirable to not have the boot message printed each time
(e.g. logs are transferred over a wireless link on battery) while
still retaining the ability to receive INFO level logs.

This adds the option to disable the boot-up message (and also to customize
it if that is desireable).
2020-07-28 11:04:55 +02:00
benpicco
6ef4276c35
Merge pull request #14621 from benpicco/core/byteorder-be
core/byteorder: add Big Endian implementations
2020-07-28 10:30:27 +02:00
d59233baf1
Merge pull request #14556 from benpicco/bitarithm_test_and_clear
core/bitarithm: add bitarithm_test_and_clear()
2020-07-28 10:11:47 +02:00
Benjamin Valentin
df18bfb459 core/byteorder: add Big Endian implementations 2020-07-27 18:36:07 +02:00
Benjamin Valentin
4d34cee72f core: add comments to symbols used by OpenOCD
OpenOCD makes assumptions about those symbol names / enum entries,
so add a note about it as a comment.
2020-07-27 16:14:42 +02:00
Benjamin Valentin
46b89eb723 core/msg_bus: fix shift on 8-bit platforms
The previous shift would wrap if the compiler defaults to 16 bit words.
Use explicit `unsigned long` integer constants to mitigate that.

before:

2020-07-22 15:25:17,063 # THREAD 1 start
2020-07-22 15:25:17,063 # THREAD 2 start
2020-07-22 15:25:17,065 # THREAD 3 start
2020-07-22 15:25:17,066 # THREADS CREATED
2020-07-22 15:25:17,068 # Posted event 22 to 0 threads
2020-07-22 15:25:17,071 # Posted event 23 to 0 threads
2020-07-22 15:25:17,076 # Posted event 24 to 0 threads
2020-07-22 15:25:17,076 # SUCCESS
2020-07-22 15:26:00,188 # Exiting Pyterm

after:

2020-07-22 15:26:10,374 # THREAD 1 start
2020-07-22 15:26:10,374 # THREAD 2 start
2020-07-22 15:26:10,377 # THREAD 3 start
2020-07-22 15:26:10,377 # THREADS CREATED
2020-07-22 15:26:10,380 # Posted event 22 to 0 threads
2020-07-22 15:26:10,383 # T1 recv: Hello Threads! (type=23)
2020-07-22 15:26:10,386 # T3 recv: Hello Threads! (type=23)
2020-07-22 15:26:10,388 # Posted event 23 to 2 threads
2020-07-22 15:26:10,391 # T2 recv: Hello Threads! (type=24)
2020-07-22 15:26:10,394 # Posted event 24 to 1 threads
2020-07-22 15:26:10,396 # SUCCESS
2020-07-22 15:27:31 +02:00
Benjamin Valentin
a8904edd7d core/bitarithm: add bitarithm_test_and_clear() 2020-07-21 16:03:59 +02:00
2d74651237
sched: Clear context_switch_request after potential idle sleep
An interrupt serviced during the idle sleep can re-request a context
switch while the scheduler is already going to switch contexts after the
idle sleep. Thi sched_context_switch_request should thus be cleared
after the idle sleep and not before where it could be modified during
the idle sleep and get out of sync.
2020-07-21 11:27:08 +02:00
e1b810b613
core/sched: tiny logic optimization in idle case
In the case that the no_thread_idle feature is active, the
runqueue_bitcache is checked twice in the case no thread is available to
schedule. This changes the inner while loop to a do-while loop to save
one check from the initial loop iteration, saving a cycle or so in the
idle case.
2020-07-20 23:26:47 +02:00
benpicco
e2e51ae7ef
Merge pull request #14368 from jia200x/pr/byteorder_bebuftohs
core/byteorder: add uint32 from/to buffer funcs
2020-07-13 12:31:43 +02:00
Jose Alamos
244d5191c8 core/byteorder: add uint32 from/to buffer funcs 2020-07-13 11:21:30 +02:00
Benjamin Valentin
b71fde68e9 core/panic: launch USB bootloader for easy recovery
If a board was flashed via USB bootloader, a crash means the user has to
perform a procedure to manually enter the bootloader again for recovery.

To allow for easier recovery, automatically lauch the bootloader on crash
if `DEVELHELP` is enabled.
2020-07-01 20:36:59 +02:00
d199865a12 core: sched: correctly unschedule when there's no idle thread 2020-06-25 16:02:29 +02:00
e3f6c0f340 core: make idle thread optional 2020-06-25 16:02:28 +02:00
c4b4e66422
sched_cb: Add function documentation 2020-06-23 15:40:57 +02:00
Martine Lenders
379d113af7
Merge pull request #14076 from miri64/cib/doc/fix-max-size
core/cib: fix documented maximum size restrictions
2020-06-19 17:18:20 +02:00
Martine S. Lenders
c2e1b8afea
core/cib: fix documented maximum size restrictions
MAXINT is not a defined value and since the types are unsigned also
misleading.
2020-06-19 15:08:58 +02:00
benpicco
7ea26cb118
Merge pull request #14295 from benpicco/core/include/macros/units_convenience
core/include: don't use 64 bit for MHZ & MiB macros
2020-06-17 15:01:44 +02:00
Benjamin Valentin
0862a3c512 core/include: Don't use 64 bit for MHZ & MiB macros
Those macros are all about convenience. However, always using 64 bit makes casts
nececcary that goes against the idea of having a convenience macro.

E.g. when printing a frequency in KHZ one might want to do

	printf("freq: %lu kHz\n", freq / KHZ(1));

leads to an error

> error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int'

Now we would have to cast - `%llu` is not available with newlib-nano and wholly
uneccecary.

Only use 64 bit artithmetic where necessary (GHZ, GiB), not for smaller units.
2020-06-17 12:50:50 +02:00
Leandro Lanzieri
4d65bc8e0a
cpu: Rename CPU_ARCH to CPU_CORE 2020-06-16 12:05:40 +02:00
Benjamin Valentin
8e83584f1c core/include: add macros for common units
I got tired of counting zeros in frequency defines, so add a few
helper macros to make defining frequency and sizes easier.
2020-06-03 16:00:19 +02:00
Benjamin Valentin
c29f133a63 core/msg_bus: clarify API of msg_bus_post()
Receiving threads must not modify the contents of the message as this
is racy by definition.

Also make `msg_bus_post()` accept `const void*` instead of `char *`.
2020-05-20 10:44:11 +02:00
Francisco Molina
cb5cbe7431
cpu/cortexm_common: add inlined header only def for irq_%
irq_% are not inlined by the compiler which leads to it branching
to a function that actually implement a single machine instruction.

Inlining these functions makes the call more efficient as well as
saving some bytes in ROM.
2020-05-12 16:37:34 +02:00
Benjamin Valentin
b3eb59c30e core/msg: add message bus 2020-04-28 13:35:05 +02:00
Benjamin Valentin
866c37c6b0 core/msg: split msg_send_int() into helper function
So it can be re-used for the message bus.
2020-04-28 11:30:56 +02:00
Francisco Molina
57938de035
core/doc: fix alignment 2020-04-21 15:10:56 +02:00
Francisco Molina
cbcb882454
core/include: add xtstr macro 2020-04-21 15:10:55 +02:00
46b6a95309
Merge pull request #13671 from jia200x/pr/move_thread_flags_error
core/thread_flags: remove #error from header file
2020-03-31 15:48:41 +02:00
8efe5960aa core: uncrustify 2020-03-30 17:02:08 +02:00
f99bc894de core: make some formatting uncrustify friendly (or ignore) 2020-03-30 17:00:32 +02:00
4a31068d15 core: disable uncrustify for atomic_*.c 2020-03-30 17:00:32 +02:00
JulianHolzwarth
dd6e51b1eb core/mutex.c _mutex_lock uses an int pointer
_mutex_lock uses a volatile int pointer for the parameter blocking instead of an int.
2020-03-26 17:26:07 +01:00
benpicco
a3dca87a78
Merge pull request #13300 from JulianHolzwarth/pr/thread_status_t/zombie_fixup
core/thread.c: thread_zombify small fix
2020-03-23 20:53:00 +01:00
Jose Alamos
027a47e3a8 core/thread_flags: remove #error from header file
This commit removes the #error from the thread_flags header.
This #error makes the usage of
if(IS_USED(MODULE_THAT_DEPENDS_ON_THREAD_FLAGS)) pattern harder,
because the error is triggered each time the header is included.
If a module uses any thread_flags function it will fail in link time
anyway.
2020-03-20 16:59:34 +01:00
Sören Tempel
59676a1f5e Make sure the mpu_noexec_ram regions has the lowest priority
From the ARMv7-M ARM section B3.5.3:

	Where there is an overlap between two regions, the register with
	the highest region number takes priority.

We want to make sure the mpu_noexec_ram region has the lowest
priority to allow the mpu_stack_guard region to overwrite the first N
bytes of it.

This change fixes using mpu_noexec_ram and mpu_stack_guard together.
2020-03-10 11:16:22 +01:00
1b8ec38e34 core/panic: add PANIC_EXPECT_FAIL 2020-02-24 10:48:43 +01:00
Leandro Lanzieri
ea8c85ae8b core/debug: Fix code style errors 2020-02-18 13:20:06 +01:00
Leandro Lanzieri
981b4eb8d0 core/debug: Fix documentation of ENABLE_DEBUG macro 2020-02-18 13:20:06 +01:00
JulianHolzwarth
ebe1bf1889 core/thread.c:thread_zombify always enables interrupts before yield 2020-02-05 18:00:13 +01:00
Karl Fessel
4445faaa3a core/shed: remove not needed bitarithm include add missing
bitarithm.h is not needed for the interface of shed but may cause conflicts
due to different definitions of SETBIT and CLRBIT

common implementations are: (value, offset) xor (value, mask) bitarithm
implements the later

frac.c and nrf52/usbdev.c use bitarithm.h but where missing the include

sam0/rtt.c defined a bit using mask from bitarithm,
changed that to the soulution used in sam0/rtc.c
2020-02-05 12:45:29 +01:00
c2534ad8f3 core: turn panic.c into a submodule 2020-01-31 13:55:26 +01:00
b6703f41dc core: turn kernel_init.c into core_init submodule 2020-01-31 13:52:13 +01:00
dec0870b4e core: cleanup kernel_init.c 2020-01-31 10:12:49 +01:00
mjc
7f44c02f45 core/ringbuffer: compensate 'ringbuffer_remove' underflow error
When rb->start = rb->size, `ringbuffer_get_one(ringbuffer_t *restrict rb)`
will read out of bounds.
2020-01-07 12:56:17 +01:00
JulianHolzwarth
2655c97fd5 core/thread.c: new function for zombie state 2019-12-11 16:48:31 +01:00
JulianHolzwarth
6b0156eac5 core/include/sched.h: new thread_status_t thread state 2019-12-11 15:44:59 +01:00
9dfcabf0d8 core: fix typos 2019-11-23 22:39:38 +01:00
Francois Berder
4a31f94cfc many typo fixes
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
2019-11-23 22:39:07 +01:00
Benjamin Valentin
a98a9e12e9 core: debug: introduce DEBUG_PUTS()
The DEBUG() function requires a minimal stack size for printf().
This is not always availiable.
To still allow static debug messages, introduce DEBUG_PUTS() that
gets resolved to puts() and does not carry such stack size requirements.
2019-11-20 19:09:47 +01:00
Leandro Lanzieri
0dd776a9e6 core/kernel_defines: Introduce 'IS_ACTIVE' macro.
IS_ACTIVE allows to evaluate macro definitions in non-preprocessor
expressions. It takes a macro that may be defined to 1 or not defined at
all and expands to 1 or 0 respectively.
2019-11-11 12:53:03 +01:00
fenghe
d6227cbc4d core/sched: remove duplicate include of irq.h 2019-10-31 01:28:32 +08:00
Marian Buschsieweke
e0cec17ec8
core/rmutex: Made C++ compatible 2019-10-24 23:08:36 +02:00
Gunar Schorcht
54e915eec5 core/assert: allow multiple static_asserts
Uses an own scope for the definition of the enum const to allow multiple `static_assert` statements within the same function in non-C11 environments.
2019-10-19 16:16:24 +02:00
JulianHolzwarth
fbf6a665e1 core/thread.c: change thread_getstatus return type
thread_status_t instead of int
2019-10-15 15:55:05 +02:00
Francisco Molina
1caf6610cb sys: add schedstatistics module 2019-09-13 11:37:44 +02:00
Martine Lenders
1887e9d3f4
Merge pull request #12203 from JulianHolzwarth/pr/core/thread/hotfix_prio_type
core/thread.c: thread_create fix priority type
2019-09-12 12:41:13 +02:00
JulianHolzwarth
1d16b3d5dc core/thread.c: thread_create fix priority type
Bugfix: changing type of priority to uint8_t to be consistent with struct _thread
2019-09-11 17:42:48 +02:00
Francisco Molina
fc58ebbd97 core/sched: separate sched_cb from schedstatistics 2019-09-10 17:08:21 +02:00
francisco
3d62fa05b8 core/schedstatistics: refactor
- add init_schedstatistics function to be called after
  auto_init, that way xtimer_is init is called before
  the first call to xtimer_now
- register schedstatics code as a callback to be executed
  on each sched_run()
2019-09-10 17:07:54 +02:00
Kees Bakker
2a0a36945c core: make use of ARRAY_SIZE macro 2019-08-06 19:43:54 +02:00
Benjamin Valentin
fcf31724a6 core: add ARRAY_SIZE macro 2019-08-06 19:31:10 +02:00
fdfd3133f7
core/sched_native: fix duplicate core_sched group definition
Introduce core_sched_native group and put this in group in parent
core_sched group
2019-08-05 16:57:37 +02:00
Marian Buschsieweke
7749e621b8
core: Fix undefined behaviour in C11 atomics
Casting pointers to volatile memory to pointers to regular memory is permitted,
but using those pointers to access the memory results in undefined behavior.
This commit changes the casts to no longer drop the volatile qualifier.

References: https://en.cppreference.com/w/c/language/volatile
2019-05-15 15:47:43 +02:00
be66fb0507 core/atomic_c11: fix declarations
gcc 9 started complaining about type mismatches:

1. all int sized return types are expected to be
   "unsigned int" instead of e.g., "uint32_t"

2. all arguments are expected to be passed as (volatile)
   void * pointers

This commit fixes 1. by doing ifdef'ed typedefs for I2 and I4, an fixes
2. by using void pointers, then casting within the template bodies.
2019-05-13 17:38:10 +02:00
e4fcac91a1 core/atomic_sync: guard by GCC >= 4.7
The documentation states that the implementation is missing for
gcc < 4.7, but then unconditionally compiles it, overriding the
builtins.
(gcc 9 starts complaining about mismatch of declarations.)
2019-05-13 13:18:21 +02:00
0d4f7b2715
Merge pull request #11510 from miri64/core/fix/thread_state-name-collision
core: rename thread_state_t to thread_status_t
2019-05-11 13:03:49 +02:00
Martine Lenders
db20a057ae core: rename thread_state_t to thread_status_t
This way it can't come to name collisions on `native` with Mac OSX'
threading library [1].

[1]: https://opensource.apple.com/source/xnu/xnu-792/osfmk/mach/thread_status.h.auto.html
2019-05-11 12:25:07 +02:00
87c72a8fe1 core/thread: unify thread_t variable naming
thread_t variables were named t, other_thread, cb. For consistency sake,
change all occurences to just "thread".
2019-05-11 11:39:32 +02:00
0ec9c57b2b add copyrights from IOTPUSH project 2019-05-02 12:09:37 +02:00
Hauke Petersen
c71fb4a435 core/clist: add clist_count() 2019-03-23 23:29:53 +01:00
Marian Buschsieweke
435f798a2b
core/sched: Fixed typo 2019-03-21 22:00:37 +01:00
Vincent Dupont
e8619b327b thread: allow overriding THREAD_PRIORITY_MAIN 2019-03-20 14:09:16 +01:00