Commit graph

17,121 commits

Author SHA1 Message Date
Anas Nashif
8fd777552e arch: add arch_proc_id() to get processor ID
Add a new interfaces for getting processor ID. On some of the
architectures, implement by means of arch_curr_cpu().

On xtensa, we get this via the PRID register.

Doxygen string by Andy Ross.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-21 10:48:28 +02:00
Audun Korneliussen
db78d04a96 Bluetooth: ISO: Add function for reading TX sync
This function retrieves TX sync information
(timestamp, offset, and sequence number)
from controller using HCI command HCI_LE_Read_ISO_TX_Sync.

Signed-off-by: Audun Korneliussen <audun.korneliussen@nordicsemi.no>
2022-06-21 10:46:56 +02:00
Juha Heiskanen
6d42ded565 net: lwm2m: LwM2M message allocation update
Allocated own message buffer for RD client interface.
This helps to cover if all messages are queued and need to do
registration or update.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 8dca91109d73a4a697e074c58ee9430d56c01a51)
2022-06-20 09:13:41 -04:00
Aleksandr Khromykh
507fa6fa2c Bluetooth: Mesh: RFU fixed group addresses can be used for subscription
Mesh 1.0.1 specification doesn't prohibit to use full range of
the fixed group addresses for subscription.
The immediate use case is upcoming IPT transport models
which will also work on Mesh 1.0 devices. The models
declare their own fixed group addresses.

Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
2022-06-20 10:27:36 +02:00
Stephanos Ioannidis
828a56e906 kernel: thread_stack: Add K_THREAD_STACK_DECLARE and its friends
This commit adds the following new thread stack declaration macros that
replace the now-deprecated thread stack "extern" macros:

  K_KERNEL_STACK_DECLARE
    * replaces K_KERNEL_STACK_EXTERN.
    * accepts a stack size parameter.

  K_KERNEL_STACK_ARRAY_DECLARE.
    * replaces K_KERNEL_STACK_ARRAY_EXTERN.

  K_KERNEL_PINNED_STACK_ARRAY_DECLARE.
    * replaces K_KERNEL_PINNED_STACK_ARRAY_EXTERN.

  K_THREAD_STACK_DECLARE
    * replaces K_THREAD_STACK_EXTERN.
    * accepts a stack size parameter.

  K_THREAD_STACK_ARRAY_DECLARE
    * replaces K_THREAD_STACK_ARRAY_EXTERN.

The term "declare" has been chosen in place of "extern" in order to
align with the existing terminology used throughout the kernel code.

Note that the K_{KERNEL,THREAD}_STACK_DECLARE macro accepts a new stack
size parameter so that the `sizeof` operator can be used with the
external stack symbols declared using it.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Stephanos Ioannidis
7931fffdb3 kernel: thread_stack: Remove redundant def command
This commit removes the `@def` command in the Doxygen documentation
because Doxygen is smart enough to figure out that a comment block is
for the following `#define`, and it is completely redundant.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Stephanos Ioannidis
2eec48beab kernel: thread_stack: Enforce consistent terminology
This commit updates the thread stack API documentation such the
terminology used by the documentation matches that of the actual macro
and function names.

For instance, the term "declare" in the context of "defining" a stack
has been changed to "define."

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Stephanos Ioannidis
96c926f47b kernel: thread_stack: Fix macro documentation group
This commit ensures that all thread stack API macros are included in
the `thread_stack_api` documentation group.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Krzysztof Chruscinski
c5f2cdef09 logging: Remove logging v1 from the logging
Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-16 10:51:15 -04:00
Carlo Caione
b6a3d598f3 device_mmio: Introduce DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME
Currently the device MMIO APIs is only able to map single DT-defined
regions and also the _NAMED variant is assuming that each DT-defined
device has only one single region to map.

This is a limitation and a problem when in the DT are defined devices
with multiple regions that need to be mapped.

This patch is trying to overcome this limitation by introducing the
DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME macro that leveraged the 'reg-names'
DT property to map multiple regions defined by a single device.

So for example in the DT we can have a device like:

  driver@c4000000 {
    reg = <0xc4000000 0x1000>, <0xc4001000 0x1000>;
    reg-names = "region0", "region1";
  };

and then we can use DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME doing:

  struct driver_config config = {
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region0, DT_DRV_INST(0)),
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region1, DT_DRV_INST(0)),
  };

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-16 11:26:10 +02:00
Georgij Cernysiov
8a237848b0 include: bindings: ospi flash add dual, quad modes
Adds dual and quad mode defines.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-06-16 10:29:15 +02:00
Nicolas Pitre
f00573555b Z_POW2_CEIL: simplify implementation
Avoid potentially calling __builtin_clz() twice with non-constant
values. Also add a test for it.

Clang produces false positive vla warnings so disable them. GCC will
spot real vla's already.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-06-16 10:28:15 +02:00
Krzysztof Chruscinski
747d6ffdb0 shell: Remove support for logging v1
Remove support for logging v1 from shell log backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Abramo Bagnara
ada9ca4c93 coding guidelines: comply with MISRA C:2012 Rule 7.2
MISRA C:2012 Rule 7.2 (A `u' or `U' suffix shall be applied to all
integer constants that are represented in an unsigned type)

Added missing `U' suffixes in constants that are involved in the
analyzed build, plus a few more not to introduce inconsistencies
with respect to nearby constants that are either unused in the
build (but implicitly unsigned) or are used and are immediately
converted to unsigned.

Signed-off-by: Abramo Bagnara <abramo.bagnara@bugseng.com>
2022-06-14 13:36:14 -04:00
Kumar Gala
f73a389e47 net: if: make driver name consistent for DT macros
Fixup how the drv_name field is set in NET_DEVICE_DT_OFFLOAD_DEFINE
and NET_DEVICE_DT_DEFINE_INSTANCE to be consistent with
NET_DEVICE_DT_DEFINE.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-14 09:31:39 +02:00
Luca Fancellu
58efbc6f4f drivers: xen: keep track of missed events on event channels
The current implementation for events channel is using an empty
callback for every unbind channel and the interrupt is clearing
every event and calling the callback.
However in a scenario where a domain fires a notification when
another has not yet bind the channel, the event will be missed.

To address this limitation, this commit is keeping track of
missed event channel notification when the empty callback is
used, a function to retrieve and clear the missed event is
introduced.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
2022-06-14 09:31:03 +02:00
Jedrzej Ciupis
644da741f4 net: pkt: add IEEE 802.15.4 TX power field
This commit extends the `struct net_pkt` structure with
`ieee802154_txpwr` field that contains signed value of the desired
transmission power of a IEEE 802.15.4 frame in dBm.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2022-06-14 09:30:43 +02:00
Gerard Marull-Paretas
a44664e95b device: remove deprecated (z_)device_usable_check
The API was deprecated in favor of (z_)device_is_ready.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-14 09:30:22 +02:00
Gerard Marull-Paretas
659f23c01f device: remove deprecated SYS_DEVICE_DEFINE
The macro was deprecated in favor of SYS_INIT.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-14 09:30:22 +02:00
Daniel Leung
33f8d0df4e kernel: workq: add k_work_user_queue_thread_get()
This adds a simple function to get the thread pointer to the user
mode thread of the user work queue. This is useful for granting
that user mode thread additional access to kernel objects.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-13 16:19:34 -04:00
Dominik Ermel
194340b1a2 storage/flash_map: Fix typos in flash_area_open documentation
Fixed typos.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-13 11:28:18 -05:00
Martí Bolívar
d130160813 devicetree.h: clean up token API docstrings
Clean up the docstrings for the APIs related to converting property
values to tokens. I think the current language has a few issues and
could be made clearer in some cases.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-06-13 09:44:32 -04:00
Kumar Gala
bd2b7e9502 net: if: Fix NET_DEVICE_DT_DEFINE_INSTANCE macro
Fix NET_DEVICE_DT_DEFINE_INSTANCE to pass through the init_fn
argument to Z_NET_DEVICE_INIT_INSTANCE.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-13 12:12:35 +02:00
Mariusz Skamra
fd3d5ac75c Bluetooth: audio: Minor documentation fix
Fix bt_audio_capability_set_available_contexts documentation.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-13 12:12:11 +02:00
Mariusz Skamra
e5cfb1ca4a Bluetooth: audio: Add getter for available audio context
Extend API with available audio contexts getter method.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-13 12:12:11 +02:00
Krzysztof Chruscinski
4c9633c2aa toolchain: common: Extending macro set for memory sections
Added macro for getting nth element from section.
Added macro for counting elements in the section.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-13 12:12:02 +02:00
Chay Guo
b47a8a428f drivers: clock_control: mcux_lpc_syscon_clock: Add flexcomm16 suppport
Added FlexCOMM16(HS SPI1) clock for MIMXRT5xx.

Signed-off-by: Chay Guo <changyi.guo@nxp.com>
2022-06-13 12:10:57 +02:00
Lars Knudsen
c27532eec4 Bluetooth: csis: add RSI advertising callback
Makes it possible for an application to
handle CSIS RSI advertising by registering a
callback, which will disable the internal
CSIS advertising.

Also fixes registering callbacks in CSIS.

Signed-off-by: Lars Knudsen <larsgk@gmail.com>
2022-06-10 09:47:40 +02:00
Georgij Cernysiov
a8fbdf72f7 lib: os: cbprintf: fix cbprintf_enums include path
Corrects `cbprintf_enums.h` include path to contain
<zephyr/...> prefix.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-06-09 18:28:47 +02:00
Andrei Emeltchenko
770f57e163 toolchain: Add __maybe_unused attribute
Add attribute __maybe_unused similar to Linux kernel.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-09 11:34:25 +02:00
David Palchak
b4a7f0f2ca linker: ensure global constructors only run once
Rename the symbols used to denote the locations of the global
constructor lists and modify the Zephyr start-up code accordingly.
On POSIX systems this ensures that the native libc init code won't
find any constructors to run before Zephyr loads.

Fixes #39347, #36858

Signed-off-by: David Palchak <palchak@google.com>
2022-06-09 11:33:36 +02:00
Chay Guo
08641f0616 driver: sensor: mcux_acmp: add discrete mode
The ACMP on i.MXRT11xx support discrete mode,
updated the driver to support discrete mode configuration.

Signed-off-by: Chay Guo <changyi.guo@nxp.com>
2022-06-09 11:30:49 +02:00
Seppo Takalo
e0296ca0b9 net: lwm2m: Allow initializing opaque and string data to zero length
By default, any string or opaque data that LwM2M engine initializes
sets data lenght to same value as given buffer length for that
resource.

However, on run time, engine keeps track how much data is written
to each resource, so when reading from any resource, should only
return data that has been written there. But uninitialized resources
return the content of the whole buffer.

Fixed the problem by introducing macros INIT_OBJ_RES_LEN(),
INIT_OBJ_RES_MULTI_DATA_LEN() and INIT_OBJ_RES_DATA_LEN() that
allows you to give the amount of data existing in buffer when
the resource is initialized. This sets the data_len and max_data_len
variables correctly.

Also introduced new functions lwm2m_engine_get_res_buf() and
lwm2m_engine_set_res_buf() that distinct between data size and
buffer size. Deprecated the previous functions
lwm2m_engine_get_res_data() and lwm2m_engine_set_res_data()

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-06-09 11:30:37 +02:00
Krzysztof Chruscinski
d660492914 logging: Add option for prolonged backend initialization
Extended logging backend API with log_backend_is_ready call which
returns 0 is backend is ready. Logging core will make sure that
all autostarted backends are ready before they are enabled.

This option allows to handle backends which are not yet ready
after init function is called (e.g. usb backend that is not plugged
in). If this is the only backend in the system, logging processing
will not start util first backend is ready.

Function for checking readiness is optional and when backend has
no such function it is assumed that backend is ready after
initialization function returns which makes this feature backward
compatible.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-09 09:40:01 +02:00
Mariusz Skamra
031717a916 Bluetooth: lc3: Improve BT_CODEC_LC3_CHAN_COUNT_SUPPORT macro
This improves the macro so that it can take variable number of
arguments, e.g. BT_CODEC_LC3_CHAN_COUNT_SUPPORT(1, 2, 8).

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:34 +02:00
Jordan Yates
319ffaed0a pm: device: helper to query power state
Adds a helper function to query whether a device is currently powered.
This can be used to determine if the chip can be initialised now, or if
it needs to be deferred.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-08 12:43:00 +02:00
Carlo Caione
673f41e708 riscv: Introduce support for RV32E
Introduce support for RV32E.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-08 18:50:22 +09:00
Carlo Caione
737dccec1a riscv: Move syscall parameter from a7 to t0
To prepare for RV32E support.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-08 18:50:22 +09:00
Andy Ross
8246d88bd3 include/arch_interface.h: Clarify platform-dependencies
Clarify a few restrictions that seem obvious but weren't specified:

+ On MP systems, counters are often asynchronous between cores, so you
  need to make sure all the values read are on the same CPU.

+ Many platforms have a 32 bit (or smaller, c.f. Cortex M SysTick)
  internal counter, but are being forced to return a 64 bit quantity
  that will behave badly on rollover (you can't just subtract two
  times anymore!).  Demand that the existing arch_timing_cycles_get()
  API (which didn't seem to have useful much to do) implement rollover
  correction on the subtraction.

This allows an Xtensa implementation based on direct CCOUNT reads on
intel_adsp to be correct per the API docs.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-06-07 19:04:42 +02:00
Krzysztof Chruscinski
0829610bbc lib: os: spsc_pbuf: Add option to use cache
Add flags option to init call and a flag to use cache.
Add Kconfig choice to pick how to approach cache. Cache can be
enforced in all spsc_pbuf instances, disable in all, or runtime selected
based on configuration flag. Option is added to allow memory footprint
savings.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Krzysztof Chruscinski
2f189e39a5 lib: os: Rename icmsg_buf to spsc_pbuf
Move icmsg_buf to lib/os and rename to spsc_pbuf (Single Producer
Single Consumer Packet Buffer). It is a generic module and initially
was created as internal module for ipc service.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Mariusz Skamra
4e15cbe456 Bluetooth: has: Handle active preset selection
This adds handling of active preset selection in HAS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:04 +02:00
Emil Gydesen
c513fd87e1 Bluetooth: ISO: Rename sn to seq_num
Rename the `sn` field(s) to `seq_num` to be more readable
and clear what the value covers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Emil Gydesen
65b5db6e3a Bluetooth: ISO: Rename ISO_INTERVAL_MIN/MAX
Rename the BT_ISO_INTERVAL_MIN/MAX to
BT_ISO_SDU_INTERVAL_MIN/MAX to avoid confusing this
the the ISO interval which is different from the SDU
interval.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Emil Gydesen
6786bbdb32 Bluetooth: ISO: Add sn and ts to bt_iso_chan_send
Add two new parameters to bt_iso_chan_send:
sn: The packet sequence number which shall be incremeted
per SDU interval.
ts: An optional timestamp value used to synchronize SDUs.

The sequence number in the API uses a 32-bit value even though
the sequence number for the HCI command is 16-bit. This is to
properly handle wrapping of sequence numbers, which is much
easier to do with additional bits allocated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Carlo Caione
86bb739b7b reserved_memory: Remove it and cleanup
The reserved memory mechanism (sections and regions definition) has been
entirely replaced, greatly extended and made it better by the work done
on the zephyr,memory-region compatible.

Since there is are no actual users, we can remove it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-07 09:41:57 -07:00
Gerard Marull-Paretas
d11c0a1ec7 drivers: adc: clarify differential sampling resolution
When using differential sampling, resolution needs to be one less, not
"may be".

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-08 01:17:31 +09:00
Gerard Marull-Paretas
73295a03e7 drivers: adc: add dt-spec helper functions
This patch adds the following dt-spec helpers:

- adc_channel_setup_dt()
- adc_raw_to_millivolts_dt()
- adc_sequence_init_dt()

The objective of these functions is to reduce application boilerplate
when Devicetree is used to configure the ADC.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-08 01:17:31 +09:00
Daniel Leung
125b33c185 logging: remove CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS
CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS was added as
a stop-gap measure to support Sys-T catalog messages. Since
the Sys-T backend has envolved to use tagged argument, this
kconfig and its effect are no longer needed. So remove it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Daniel Leung
fe0aa4c167 logging: support tagged argument in log message packaging
This adds support for packaging with tagged arguments for log
messages so that backends can make use of this information
when they process messages.

Note that currently tagged arguments must be used with
CONFIG_LOG2_ALWAYS_RUNTIME where log messages are created via
z_log_msg2_runtime_{v,}create(). For some reason, using C++ on
Cortex-M (mps2_an385) results in an additional empty string
argument being added to the list. This does not happen if only
doing C on mps2_an385, or on other architectures.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00