Commit Graph

7632 Commits

Author SHA1 Message Date
Jukka Rissanen b9253b5c19 net: capture: Fix the return value of net_capture_is_enabled()
The net_capture_is_enabled() function returns boolean value
so fix the function prototype.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-28 10:41:35 -05:00
Jukka Rissanen 3033b8e4d5 net: capture: Fix the function documentation
The net_capture_pkt() does not return anything so remove the
return description from the function documentation.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-28 10:41:35 -05:00
Daniel Leung dfa4b7e375 kernel: mmu: z_backing_store* to k_mem_paging_backing_store*
These functions are those that need be implemented by backing
store outside kernel. Promote them from z_* so these can be
included in documentation.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-28 11:33:22 -04:00
Daniel Leung 31c362d966 kernel: mmu: rename z_eviction* to k_mem_paging_eviction*
These functions and data structures are those that need
to be implemented by eviction algorithm and application
outside kernel. Promote them from z_* so these can be
included in documentation.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-28 11:33:22 -04:00
Daniel Leung 231a1e75ab kernel: mmu: add doxygen group for demand paging APIs
This adds the doxygen group for demand paging APIs in
sys/mem_manage.h header file.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-28 11:33:22 -04:00
Torbjörn Leksell 22071d613c Tracing: TRACING_NONE Compilation Fix
Fixed several compilation errors that resulted from selecting
TRACING without specifying a tracing system (Tracerecorder,
CTF, Systemview). In this case (TRACING_NONE), some default trace hooks
(in tracing.h) were incorrectly named resulting in compilation errors.
The legacy sys_trace_isr_enter, sys_trace_isr_exit, and sys_trace_idle
also caused problems since these were only given as defines, resulting
in undefined reference errors since they are required by the assembly
files calling these. To solve this issue I've added a stub file
"tracing_none.c" (only compiled if TRACING_NONE) and declared the
functions in tracing.h if no tracing system is selected.

Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
2021-05-27 14:39:40 -05:00
Stephanos Ioannidis 9881ce0a11 linker: cpp: Disable sorting of C++ exception handling info sections
The `CONFIG_LINKER_SORT_BY_ALIGNMENT` config, which is enabled by
default, causes the sections containing C++ exception handling
information to be re-ordered for certain targets (in particular, the
64-bit arch targets). This effectively breaks the required "crtbegin.o
-> others -> crtend.o" order and causes the address of the
__EH_FRAME_BEGIN__ symbol to be invalid; thereby, causing C++
exception unwinding to fail.

This commit adds SORT_NONE property to these sections in order to
ensure that the linking order specified in the linker command line is
maintained.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-05-27 14:36:13 -05:00
Torsten Rasmussen 7d37fe21d1 cmake: c++ exceptions linking support
Fixes part of: #32448

This commit updates the CMake CMAKE_CXX_LINK_EXECUTABLE to include
crtbegin.o and crtend.o at the right locations when linking with gcc.

It also updates linker scripts to ensure proper location of the
exception header frame sections.

This ensure proper handling of exceptions for those architectures
- x86
- xtensa
- riscv32

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-05-27 07:43:28 -05:00
Casper Bonde 3af1f4bac5 Bluetooth: ISO: Make it possible to setup unidirectional CIS
The current iso commands in the shell only supports setting up
a bidirectional stream or unidirectional for central role.
Adding rx/tx/rxtx option to iso listen command to allow for
peripheral side configuration of an iso connection.

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
2021-05-27 13:16:40 +02:00
Casper Bonde 04dfcba792 Bluetooth: ISO: Add sequence number to ISO data packets
The sequence number is needed in the appliaction layer to detect lost
packets in the ISO stream in cases where the timestamp is not included.
(Sequence number is mandatory to include where timestamp is optional).
The API for the public metadata have been moved to a public header file.

As the size of the ISO meta data exceeds the default 4 octets net_buf
user_data the public ISO metadata have been moved into a seperate array.
The internal metadata is still stored in net_buf user_data.

This also fixed the user_data overflow on 32 bit systems, caused by
writing the ts into user_data on index 4 to 7, which is outside the 4
allocated bytes.

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
2021-05-27 13:16:40 +02:00
Anas Nashif 5b8d418058 nios2: revert back to builtin sys_io functions
Some time ago we did a cleanup of sys_io function and left nios2 broken,
especially on the MAX10 board. Revert back to the original
implementation for this architecture.

Fixes #35694

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-26 18:09:47 -05:00
Marek Pieta 94cc9a9bdb arch: arm: Fix build warning
Change fixes a build warning related to attribute ignored in
declaration of struct. The __packed attribute is removed.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2021-05-26 11:17:45 -05:00
Flavio Ceolin d67a5786bc pm: device_runtime: Change API behavior s/_sync/_async
Most APIs have the default synchronous and an asynchronous version
with the sufix _async because that is the most common use.

All devices in tree right now are using the synchronous version, so
just change it to be consistent with the rest of the system.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin d325642892 pm: device_runtime: Get rid of atomic for state
Since we are using mutex to protect critical sections and mutexes are
reentrant, it is possible to get rid of atomic for the state because
we can lock the mutex in device_pm_callback.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin b1564c35d2 pm: device_runtime: Document isr and pre-kernel functions
Add notes for APIs that are allowed to be called from ISRs and
pre-kernel.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin 97281b3862 pm: device_runtime: get rid of the spinlock
Protect critical sections using the mutex.
The mutex is required to use the conditional variable and since we
need to atomically check the pm state and the workqueue before wait
the condition, it is necessary to protect them using the same mutex.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin ce989e33e6 pm: device_runtime: Fix atomic usage
Protect critical sessions using the spinlock available. The atomic
usage was not properly protecting the critical section and was
possible to have a race condition between the usage check and state
set.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin 378a19d2a8 pm: device_runtime: Add helper to wait on async ops
Add a function that properly uses a mutex to check a condition before
wait on the conditional variable.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Martí Bolívar a2b61d5ed0 devicetree.h: fix DT_ENUM_TOKEN docstring
Remove extraneous parentheses.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-26 08:30:31 -05:00
Dominik Ermel 3b49ed46df shell: Parametrize dummy shell buffer size
The commit adds Kconfig option to configure dummy shell buffer size.
Size of this buffer determines how mutch of command output will be
stored in buffer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-05-26 00:05:56 -04:00
Joakim Andersson 8a32c2d967 Bluetooth: host: Fix disconnect priority event handling
Fix issue is host handling of connected and disconnected event.
Since the host wants the disconnected event to be processed as a
priority event as well as in reguler event context while the connected
event is always in reguler event context we can end up in a situation
where the disconnected priority event is processed before the connected
event.

Since the disconnected priority event is there to release unack'ed TX
pending on the connection in case the RX thread is blocked waiting
for TX resources, we need to keep this behavior. Otherwise this would
be a potential deadlock of the RX thread waiting for resources that can
only be released by the RX thread.
When this situation happens we know that there cannot be any pending TX
on this connection so we can safely skip releasing of unack'ed TX.

The second thing the disconnected priority event does is marking the TX
path on the connection as disconnected. We need to do the same in this
situation, so we make sure that the TX path is already marked
disconnected when providing the connected callback to the application.

This fixes a regression from 4be66bd33d.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-25 20:30:48 +03:00
Joakim Andersson c429ffb0ed Bluetooth: host: Add check for already enabled in advertising set start
Add check for the advertising already being enabled when attempting to
start the advertising set.
Document that the advertising set cannot be started from the connection
connected callback, and instead has to be started from the advertising
set connected callback.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-25 19:26:23 +02:00
Anas Nashif edcf2accf7 tracing: rearrange tool header inclusion
tracerecorder maintains its macros definitions outside of zephyr and can
deal with undefined macros or hooks that are implemented in Zephyr but
not yet implemented in TR. Move inclusion to the bottom after all macros
have been initialized.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-25 07:36:38 -05:00
Carlo Caione 6fed3fdb61 cache: Do not warn on unused parameters
Silence the compiler complaining about unused parameters.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-05-25 07:05:22 -05:00
Andy Ross 851d14afc8 kernel/sched: Remove "cooperative scheduling only" special cases
The scheduler has historically had an API where an application can
inform the kernel that it will never create a thread that can be
preempted, and the kernel and architecture layer would use that as an
optimization hint to eliminate some code paths.

Those optimizations have dwindled to almost nothing at this point, and
they're now objectively a smaller impact than the special casing that
was required to handle the idle thread (which, obviously, must always
be preemptible).

Fix this by eliminating the idea of "cooperative only" and ensuring
that there will always be at least one preemptible priority with value
>=0.  CONFIG_NUM_PREEMPT_PRIORITIES now specifies the number of
user-accessible priorities other than the idle thread.

The only remaining workaround is that some older architectures (and
also SPARC) use the CONFIG_PREEMPT_ENABLED=n state as a hint to skip
thread switching on interrupt exit.  So detect exactly those platforms
and implement a minimal workaround in the idle loop (basically "just
call swap()") instead, with a big explanation.

Note that this also fixes a bug in one of the philosophers samples,
where it would ask for 6 cooperative priorities but then use values -7
through -2.  It was assuming the kernel would magically create a
cooperative priority for its idle thread, which wasn't correct even
before.

Fixes #34584

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-24 23:38:16 -04:00
Maksim Masalski 5a9e9e8fd1 logging: remove dead code enum
Remove dead code enum tracing_log_id
Not used anywhere in the code. Also it caused MISRA rule 8.12
violation.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2021-05-21 18:09:23 -04:00
Gerard Marull-Paretas a4025ebaff net: dns_resolve: fix doxygen parameter names
Parameter names were not correct.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-21 12:17:04 -04:00
Gerard Marull-Paretas 1b8e2bad63 sys: p4wq: add missing docstring to K_P4WQ_ARRAY_DEFINE
flg parameter was not documented.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-21 12:17:04 -04:00
Gerard Marull-Paretas e0b4c9753c linker: devicetree_regions: escape special characters
Escape characters <> (generate warnings for the HTML build).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-21 12:17:04 -04:00
Gerard Marull-Paretas bb38c558c5 bluetooth: l2cap: fix doxygen references
References to BT_L2CAP_BUF_SIZE were not working.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-21 12:17:04 -04:00
Gerard Marull-Paretas da2816bab8 sys: arch_interface: fix doxygen groups
1. functions can only belong to one group, use arch-timing (already
   defined)
2. group was not properly terminated

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-21 12:17:04 -04:00
Gerard Marull-Paretas 2f12d53f9a device: fix unbalanced doxygen group
An extra @} was present, remove it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-21 12:17:04 -04:00
Andy Ross d37370301c k_heap: Clamp to a minimum heap size
The K_HEAP_DEFINE macro would allow users to specify heaps that are
too small, leading to potential corruption events (though at least
there were __ASSERTs that would catch this at runtime if enabled).

It would be nice to put the logic to compute this value into the heap
code, but that isn't available in kernel.h (and we don't want to pull
it in as this header is already WAY to thick).  So instead we just
hand-compute and document the choice.  We can address bitrot problems
with a test.

(Tweaks to heap size asserts and correct size bounds from Nicolas Pitre)

Fixes #33009

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-20 17:52:21 -04:00
Krzysztof Chruscinski 281a9407c5 lib: os: cbprintf: Add ARG_UNUSED to unused arguments
Picky C++ compilation reported warnings that input arguments
are not used. Adding missing ARG_UNUSED().

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-20 08:23:31 -05:00
Krzysztof Chruscinski 81f0f4efd0 lib: os: cbprintf: Add missing initialization of structure fields
C++ compiliation may generate warning if all fields are not
explicitly initialized. Added explicit initialization to 0.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-20 08:23:31 -05:00
Krzysztof Chruscinski 8ffc8ff267 logging: Add missing initialization of structure fields
C++ compiliation may generate warning if some fields are not
explicitly initialized. Added explicit initialization to 0.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-20 08:23:31 -05:00
Watson Zeng 214d91c19d toolchain: arcmwdt: linker: fix placeholders for arcmwdt toolchain
syntax ". += length;" not work with arcmwdt toolchain, let's using
". = . + length;", which both work with gnu and arcmwdt toolchain.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-05-20 07:50:38 -05:00
Krzysztof Chruscinski 98ef609443 logging: Add empty Z_LOG_MSG2_SIMPLE_CREATE version
Add empty Z_LOG_MSG2_SIMPLE_CREATE when CONFIG_LOG_SPEED=n. It
allows to reduce compilation time by removing code at preprocessor
stage. Previously functionality was the same, compiler was removing
unused code but because logging is widely use that had a visible
impact on compile time.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-19 12:01:49 -05:00
Gerard Marull-Paretas 1ec0b181ab drivers: display: fix doxygen issues
The way some structures were documented was causing issues on the
Sphinx/Breathe side. Move to a more "standard" format.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-19 06:21:53 -04:00
Armando Visconti 4b4068c948 kernel/device: add arg checking in z_device_ready()
If this call receives an invalid device pointer as argument it
assumes that the `device` is not ready for usage.

This routine is currently called by two device specific APIs:

    - device_usable_check(const struct device *dev)
    - device_is_ready(const struct device *dev)

The device-specific APIs documentation claims that these two
routines must be called with a device pointer captured from
DEVICE_DT_GET(). So passing NULL is a violation of the rule.

Nevertheless, is quite common in drivers to assign NULL to
a device pointer if the corresponding DT property has not been
found (e.g. a not used gpio interrupt declaration for a given
device instance) and seems legit to interpret this condition
same as the device is not ready for usage.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-18 11:29:46 -05:00
Eduardo Montoya 68626227a3 net: openthread: fix CSL API
A couple of fixes on the OpenThread radio implementation.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-05-18 11:24:40 -05:00
Krzysztof Chruscinski d2f48ac35d shell: log_backend: Add mpsc_pbuf buffer alignment
Buffer used for storing log messages must be aligned as specified
by Z_LOG_MSG2_ALIGNMENT. Added missing alignment.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-18 11:22:13 -05:00
Anas Nashif eccda68418 power: trace power events
Trace PM transition sequence and events.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif 12dd237fce kernel: move thread_stack.h to include/kernel
Move this internal header file into kernel/ alongside other thread
related headers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 17:32:12 -04:00
Anas Nashif 9440a1c2b8 doc: kernel: thread stack is not the same as stack object
Fix mixup of stack objects and thread stacks.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 17:32:12 -04:00
Peter Bigot 47435904ef kernel: work: document error returns for schedule operations
When a non-zero delay is used the schedule functions can't fail, but
if K_NO_WAIT is passed error conditions may be forwarded from
k_submit_to_queue.

Also add a missed error return from k_submit_to_queue.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-05-17 15:36:03 -04:00
Anas Nashif 009dee157d doc: fix doxygen grouping
Fix various grouping issues in doxygen and name groups correctly in some
cases.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 11:51:44 -04:00
Krzysztof Chruscinski 8152992a13 logging: Simplify runtime filtering
Simplified handling of runtime filtering that lead to removal
of LOG_CHECK_CTX_LVL_FILTER macro. Fixing multiply coverity issues
like CID 236013.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-13 22:08:44 -04:00
Hake Huang 13964780ea dma: change an atmoic api for Coverity issue 233524
use atomic_clear_bit instead of atomic_test_and_set_bit
which will not return old value, and thus more coverity friendy

Fixing: #35154

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-05-13 07:15:18 -05:00
Krzysztof Chruscinski f8ac3a49ec lib: os: cbprintf: Avoid implicit casting to int *
Arg can be double * and it is casted to int *. Coverity reports
it (CID 235943). Fixed by adding intermediate void * variable.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-12 23:36:01 -05:00