Add bt_cap_unicast_group_get_info to get information about
a CAP unicast group. For now this just contain the pointer
to the BAP unicast group, which then can be used with
bt_bap_unicast_group_get_info to get information specific
to BAP. The bt_cap_unicast_group_info struct can later be
expanded with any additional information CAP may add.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add bt_bap_unicast_group_get_info to get information
about a unicast group. In this first iteration the info
struct only contains the sink and source presentation
delay, but the info struct can easily be expanded on
later to contain more.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
To simplify the work on client drivers, provide a STM32_DMA_GET_INSTANCE()
macro which abstracts:
- STM32_DMA_STREAM_OFFSET
- __LL_DMA_GET_STREAM_INSTANCE() vs __LL_DMA_GET_CHANNEL_INSTANCE()
Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
USB host, device, Type-C, and BC1.2 are now all grouped under a
top-level USB entry in the "Device drivers" doxygen group.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
rtc_ds3231.h only contains register definitions and bitmasks used
internally by the driver - make this header file private.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
There is a "native" RTC driver for DS3231 now (maxim,ds3231-rtc, one of
the multiple functions implemented as MFD) so do all we can to
discourage the use of the legacy, counter-API based, driver.
Flag the compatible as deprecated.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The `pio` value is stored in the internal `pio_rpi_pico_config` structure
that is not exposed. However, it is the first element of the structure.
Here, I convert the pointer to `pio_rpi_pico_config` into a pointer to PIO
to access this value.
Signed-off-by: Terry Geng <terry@terriex.com>
add a wrapper function to read the number of bytes currently buffered
and pending for the next flash write operation.
Signed-off-by: Syver Haraldsen <syver.haraldsen@nordicsemi.no>
These types are useful for IoT deployments and should be available
thru the resolver interface to get the data. The SRV is especially
useful to find services on the local network when not using a dns-sd
deployment and just something like Avanhi or Bonjour.
Signed-off-by: Charles Hardin <ckhardin@gmail.com>
There was an issue where terminating the BIG while in the
ISO connected callbacks could lead to continueing the loops
would cause access to cleared memory.
The simple solution to this is to simply prevent
bt_iso_big_terminate from terminating the BIGs while we are
processing the BIG HCI events.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rework doxygen group naming and fold "internal" Flash API into the main
Flash API group.
Also a minor fix of a missing javadoc-style comment.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Add checks on the fs pointer passed through the api before using to
avoid causing an exception
Signed-off-by: Theis Mejnertsen <theismejnertsen@gmail.com>
zms_active_sector_free_space is documented to return -EACCES on fs not
mounted error but currently returns an usigned type size_t. This fixes
that by changing the return value into a ssize_t
Signed-off-by: Theis Mejnertsen <theismejnertsen@gmail.com>
These macros depend on time.h (which is not included in clock.h)
and are not really kernel related, but translation from the kernel
tick representation into time_spec values.
Let's place them in timeutils with their related macros/functions.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
* Fixes in code and test so it works with any expected time_t size.
* Fix test_timespec_normalize so it also tests the output of
timespec_normalize(), fixing some incorrect expected values
accordingly.
* Test: Do not force a C library in the integration platform
and do not filter by libC as it is not necessary anymore.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Since it's possible that rounding up might not always be the right thing
to do in every situation, in order to allow the application to make more
informed decisions, we created a modified timespec_to_timeout() that also
returns the remainder (or difference) between the requested time to
convert and resulting k_timeout_t. The difference is expressed as a
timespec object.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Originally, the timespec_to_timeout() and timespec_from_timeout() tests
assumed that tv_sec and tv_nsec values divided evenly with the number of
ticks per second (CONFIG_SYS_CLOCK_TICKS_PER_SEC). However, those
assumptions broke down when testing with 32768 ticks/s .
Upon further investigation, there were additional corner cases
discovered that were not handled in an ideal or safe way.
Part of this fix involved identifying several "domains" and special
values that have semantic meaning that must be handled particularly
carefully.
Additional hidden-API constants were made to simplify the solution.
K_TICK_MIN (1)
K_TICK_MAX (UINT32_MAX-1 in 32-bit, INT64_MAX in 64-bit)
K_TIMESPEC_NO_WAIT (like K_NO_WAIT)
K_TIMESPEC_FOREVER (like K_FOREVER)
1. Converting a negative k_timeout_t
These only exist in 64-bit representation and actually encode absolute
timepoints via ticks. Since the stated purpose of the conversion
functions is to convert between durations, we must reject absolute
time points in timespec_from_timeout().
2. Converting a negative timespec
We assume that this duration means a timeout has already expired, and
round these up to K_NO_WAIT in timespec_to_timeout().
3. Due to the larger numeric space in the timespec representation,
the reverse mapping of timespec to k_timeout_t is "fuzzy". However,
K_NO_WAIT (K_TIMESPEC_NO_WAIT) and K_FOREVER (K_TIMESPEC_FOREVER) must
remain semantically equivalent. The previous implementation also held this
to be true, but the test cases are a bit clearer about it now.
4. Also, due to the larger numeric space in timespec representation,
there was a special requirement to round up to the nearest tick
boundary for any timespec in the strictly exclusive range
(K_TIMESPEC_NO_WAIT, K_TIMESPEC_MAX). We must round up, since
a) rounding down to K_NO_WAIT is most certainly not representative
of a non-zero finite duration delay
b) the kernel operates on tick boundaries
5. Above the K_TIMESPEC_MAX boundary, which is the highest possible
timespec that can be represented by a tick, and specifically in the
64-bit timeout representation, there is a domain that cannot be
rounded up to K_TIMESPEC_FOREVER and should always be rounded down to
K_TIMESPEC_MAX.
This is to ensure that finite durations remain finite (even if
they are beyond the heat death of the universe).
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Define additional constants and macros for converting between timespec
objects and k_timeout_t.
There are four semantically important durations identified with new
constants identified via '.
1. K_NO_WAIT / K_TIMESPEC_NO_WAIT'
* duration of zero
2. K_TICK_MIN' / K_TIMESPEC_MIN'
* minimum number of ticks strictly greater than K_NO_WAIT
3. K_TICK_MAX' / K_TIMESPEC_MAX'
* maximum number of ticks strictly and semantically less than K_FOREVER
4. K_FOREVER / K_TIMESPEC_FOREVER'
* the familiar non-expiring number of ticks (i.e. infinity)
With these definitions, there are 3 meaningful regions for conversion
between timespec and k_timeout_t representation:
1. < K_TIMESPEC_NO_WAIT (i.e. a negative timespec)
* should be rounded up to K_TIMESPEC_NO_WAIT
* < K_NO_WAIT in ticks is an absolute time point in 64-bit
representation should no be permitted in the affected conversion
routines, as they are explicitly for converting time durations rather
than absolute time points.
2. K_TIMESPEC_NO_WAIT < x < K_TIMESPEC_MAX
* should be rounded-up to the next tick boundary
* must be represented as the minimal non-zero duration in ticks
3. K_TIMESPEC_MAX <= x < K_TIMESPEC_FOREVER
* must be represented as the maximum expiring duration in ticks
* should be rounded-down to K_TIMESPEC_MAX
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Implement the function bt_cap_initiator_broadcast_foreach_stream that
allows users to iterate on all BAP streams in a BAP broadcast source.
This can be used to easily get references to other broadcast streams in
the same group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
While these are not expected to be used by applications in normal
scenarios, they are still public and document them can be helpful in
non-normal scenarios.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
- No more need for special IRQ shadow stacks - just reuse the one
created for z_interrupt_stacks;
- Add the linker sections for the pairs of stack/shadow stack;
- Support shadow stack arrays.
Last item was a bit challenging: shadow stacks need to be initialised
before use, and this is done statically for normal shadow stacks. To
initialise the shadow stacks in the array, one needs how many entries it
has. While a simple approach would use `LISTIFY` to them do the
initialization on all entries, that is not possible as many stack arrays
are created using expressions instead of literals, such as
`CONFIG_MP_MAX_NUM_CPUS - 1`, which won't work with `LISTIFY`.
Instead, this patch uses a script, `gen_static_shstk_array.py` that
gathers all needed information and patches the ELF to initialize the
stack arrays. Note that this needs to be done before any other operation
on the ELF file that creates new representations, such as the .bin
output.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
This patch modifies thread stack macros (such as K_KERNEL_STACK_DECLARE
or K_KERNEL_STACK_ARRAY_DECLARE) to also create a HW shadow stack (when
CONFIG_HW_SHADOW_STACK=y), as well as define a pairing between the
thread stack (or thread stack array) and the shadow stack (or shadow
stack array).
This pairing, which currently is simply an array of pairs (stack,
shadow_stack) is searched during thread setup to find the corresponding
shadow stack and attach it to the thread. If linear search on this array
proves to be a performance issue, the actual structure can be revisited.
To define the size of the shadow stack for a given stack, the stack size
is used. A new Kconfig, CONFIG_HW_SHADOW_STACK_PERCENTAGE_SIZE is used
to define how big the shadow stack is compared to the stack. Note that
this size is in *addition* to the stack size. To avoid some shadow
stacks becoming too small, CONFIG_HW_SHADOW_STACK_MIN_SIZE is used to
define a minimum size. Note that after this size is defined, platform
restrictions on the size of the shadow stack are still applied.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
So that kernel created threads can use shadow stacks. Note that
CONFIG_X86_CET_SHADOW_STACK is abandoned in favour of
CONFIG_HW_SHADOW_STACK.
This means change some types, functions and macro throughout shadow
stack code.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
In order to allow kernel created threads (such as main and idle threads)
to make use of hardware shadow stack implementation, add an interface
for them.
This patch basically provides an infra that architectures need to
implement to provide hardware shadow stack.
Also, main and idle threads are updated to make use of this interface
(if hardware shadow stacks are enabled).
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Most notable difference on base support is the need to keep the shadow
stack tokens, which are 8 bytes, 8 bytes aligned. Some helper macros are
used for that.
Also, an `ssp` entry is added to the task state segment (TSS).
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Main peculiarity is that if an exception results in current thread being
aborted, we need to clear the busy bit on the shadow stack on the swap
to the new thread, otherwise future exceptions will fail when trying to
use a busy shadow stack.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Nested interrupts are supported, on the normal stack, by creating a
stack whose size is a multiple of CONFIG_ISR_DEPTH, and updating the
pointer used by Interrupt Stack Table (IST) to point to a new base,
inside the "oversized" stack.
The same approach is used for the shadow stack: shadow stack size is
multiplied by CONFIG_ISR_DEPTH, and the pointer to the stack on the
shadow stack pointer table is update to point to the next base.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
For IRQs, shadow stack support a mechanism similar to the Interrupt
Stack Table (IST) for x86_64: a table, indexed by the IST index, pointing
to a 64 byte table in memory containing the address of seven shadow stacks
to be used by the interrupt service routines.
This patch adds support to this mechanism. It is worth noting that, as
Zephyr may exit from an interrupt by going to a different thread than
the one that was interrupted, some housekeeping is done to ensure that
the necessary shadow stack tokens are on the right shadow stack before
return from the interrupt.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Shadow Stack is one of the capabilities provided by Intel Control-flow
Enforcement Technology (CET), aimed at defending against Return Oriented
Programming.
This patch enables it for x86_64 (32-bit support coming in future
patches):
- Add relevant Kconfigs;
- Shadow stacks should live in specially defined memory pages, so
gen_mmu.py was updated to allow that;
- A new macro, Z_X86_SHADOW_STACK_DEFINE, added to define the area
for a shadow stack;
- A new function, z_x86_thread_attach_shadow_stack(), added to
attach a shadow stack to a never started thread;
- locore.S changed to enable/disable shadow stack when a thread
using it comes in/out of execution.
As not all threads are currently shadow stack capable, threads that do
not use it will still run with shadow stack disabled. Ideally, at some
point in the future, all threads would use the shadow stack, so no need
to disable it at all.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Indirect Branch Tracking (IBT) is one of the capabilities provided by
Intel Control-flow Enforcement Technology (CET), aimed at defending
against Jump/Call Oriented Programming.
This patch enables it for x86 (32-bit, 64-bit support coming in future
patches):
- Add relevant Kconfigs (everything is behind X86_CET);
- Code to enable it;
- Enable compiler flags to enable it;
- Add `endbr32` instructions to asm code, where needed.
Points in the code where an indirect branch is expected to land need
special instructions that tell the CPU they are valid indirect branch
targets. Those are added by the compiler, so toolchain support is
necessary. Note that any code added to the final ELF also need those
markers, such as libc or libgcc.
Finally, tests added to ensure IBT behaves sanely.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Commit f9168ae464 made all non-cached memory
loadable by default.
However as nocache memory is typically used for reserving larger buffers to
be shared between peripherals, this comes at fairly large cost towards ROM
usage.
This commit creates two distinct sections for both loadable and
non-loadable nocache memory sections.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The gpio_int_trig enum did not enumerate all possible combinations
of flags after the addition of the GPIO_INT_WAKEUP flag.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
The GPIO_INT_WAKEUP flag is available in the binding header,
but was not propagated from dt_flags in the interrupt_configure_dt
function. Allow GPIOs to be declared as wakeup sources in dts
by propagating the flag.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Since 45a3d31, the GPIO_INT_WAKEUP flag has been available in
the binding header. Update the mask to include it.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Complete the Doxygen documentation for this sensor driver,
put in sensor_interface_ext group.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Complete the Doxygen documentation for this sensor driver,
put in sensor_interface_ext group.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
While reasonably straightforward, ensure the signature of the
comparator_callback_t is properly documented.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>