Commit graph

15409 commits

Author SHA1 Message Date
Daniel Leung
de9f396854 arc: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
25f87aac87 x86: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
a4de092faa drivers: ec_host_cmd_periph: remove @return doc for void funcs
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
3c622e1a2f drivers: pcie: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
36e3c47f73 bluetooth: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
3feec54acf lib: os: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
c955a44f13 usb: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
cd9533687a drivers: cache: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
bff37a3a6c drivers: serial: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
44ee482b0a drivers: console: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
975e257f2c drivers: interrupt_controller: remove @return doc for void funcs
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
63b4300577 sys: include: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung
d3b030be9b kernel: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Mark Holden
7b2b283677 debug: coredump: allow for coredump backends to be defined outside of tree
Move coredump_backend_api struct to public header so that custom backends
for coredump can be defined out of tree. Create simple backend in test
directory for verification.

Signed-off-by: Mark Holden <mholden@fb.com>
2022-01-11 18:17:24 -05:00
Daniel Leung
d8f97caac2 lib: os: mem_blocks: add memory blocks allocator groups
This adds similar ability of sys_multi_heap to the memory blocks
allocator, where a choice function can be used to select
which allocator (of a group) is used for memory block allocation.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-11 16:10:53 -05:00
Daniel Leung
8308f3f4d5 lib: os: introduce memory blocks allocator
This introduces yet another memory blocks allocator where:

() All memory blocks have a single fixed size.

() Multiple blocks can be allocated or freed at the same time.

() A group of blocks allocated together may not be contiguous.
   This is useful for operations such as scatter-gather DMA
   transfers.

() Bookkeeping of allocated blocks is done outside of
   the associated buffer (unlike memory slab). This allows
   the buffer to reside in memory regions where these can be
   powered down to conserve energy.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-11 16:10:53 -05:00
Daniel Leung
0f7c31e0a4 math: introduce macro for integer log2
This introduces macro for calculating integer log2.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-11 16:10:53 -05:00
Henrik Brix Andersen
e919db3222 drivers: can: add user_data to state change callback
Add optional user data argument to can_set_state_change_callback() to
comply with Zephyr API design guidelines.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-11 11:54:04 +01:00
Andy Ross
97ada8bc04 arch/xtensa: Promote adsp RPO/cache utilities to an arch API
This is trick (mapping RAM twice so you can use alternate Region
Protection Option addresses to control cacheability) is something any
Xtensa hardware designer might productively choose to do.  And as it
works really well, we should encourage that by making this a generic
architecture feature for Zephyr.

Now everything works by setting two kconfig values at the soc level
defining the cached and uncached regions.  As long as these are
correct, you can then use the new arch_xtensa_un/cached_ptr() APIs to
convert between them and a ARCH_XTENSA_SET_RPO_TLB() macro that
provides much smaller initialization code (in C!) than the HAL
assembly macros.  The conversion routines have been generalized to
support conversion between any two regions.

Note that full KERNEL_COHERENCE still requires support from the
platform linker script, that can't be made generic given the way
Zephyr does linkage.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-11 11:53:53 +01:00
Gerard Marull-Paretas
a84a16f8ff arch: arm: aarch32: cortex_m: nvic: make header self-contained
The header contains macros that make use of the Devicetree API, however,
<devicetree.h> is not included. This was "mitigated" by most <soc.h>
including <devicetree.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-11 11:52:27 +01:00
Emil Gydesen
baf48fbe2e zephyr: Add UTF-8 truncating strlcpy variant
Add a function to copy a UTF-8 encoded string that
ensure correct truncation of the string if the source
is larger than the destination, as well as ensuring that
the resulting destination string is NULL-terminated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-11 11:50:15 +01:00
Emil Gydesen
5cb72d2193 zephyr: Add function to properly truncate UTF-8 strings
Add a function that can properly truncate UTF-8 strings
without leaving unterminated started characters,
as UTF-8 characters can be 1-4 bytes long.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-11 11:50:15 +01:00
Jaremy J. Creechley
3ac2ca2aa5 net: socket: extend posix compatability SO_<opts>
Adding these definitions help ease of porting POSIX applications.

They currently do nothing in the core network stack and will
return an error if used. However, they help port some POSIX
without changing these. In particular, this enables using the
Nim programming language's standard library with Zephyr.

- The values copy Linux amd64, similar to the other SO_OPTIONS
- Add SO_SNDBUF to fix simplelink wifi
- Use compat options in simplelink wifi

Signed-off-by: Jaremy J. Creechley <jaremy.creechley@panthalassa.com>
2022-01-11 11:48:16 +01:00
Yuval Peress
ab1caef8c3 ztest: Update ztest with more powerful testing APIs
1. Test suites in prior ztest serve no purpose other than logical
ordering of tests into a named-group. Move the construct of setup and
teardown into the test suite and away from individual tests.
Additionally, add the constructs of before/after to the test suites.
This model more closely resembels other testing frameworks such as gTest
and Junit.
2. Test can be added to a suite by using ZTEST() or ZTEST_F() where _F
stands for fixture. In the case where _F is used, the argument `this`
will be provided with the type `struct suite_name##_fixture*`. Again,
this models other modern testing frameworks and allows the test to
directly access the already set up data related to the test suite.
3. Add the concept of test rules (from Junit). Rules are similar to the
before/after functions of the test suites but are global and run on all
suites. An example of a test rule can be to check that nothing was
logged to ERROR. The rule can cause the test to fail if anything was
logged to ERROR during an integration test. Another example would be a
rule that verifies that tests ran within some defined timeout.

Signed-off-by: Yuval Peress <peress@google.com>
2022-01-11 11:47:30 +01:00
Jim Shu
b13dd54fb4 arch: riscv: pmp: simplify pmp region number computation
Simplify multiple ifdef case in computing region number. Also move these
macros to core_pmp.c because they are only used in one file.

Signed-off-by: Jim Shu <cwshu@andestech.com>
2022-01-11 11:47:03 +01:00
Jim Shu
3f16fdefbf riscv: linker: fix duplicate symbol when CONFIG_USERSPACE=y
_image_ram_start symbol is duplicate in CONFIG_USERSPACE. This symbol
should be at the start of app_smem in userspace, so remove another
symbol in CONFIG_USERSPACE.

Signed-off-by: Jim Shu <cwshu@andestech.com>
2022-01-11 11:47:03 +01:00
Piotr Pryga
96048bdf65 include: Bluetooth: Add LE Supported Features type to GAP
BT 5.3 Core Spec provides possibility to transmit LE Supported
Features in advertising data. The value is prepared as in
case of other advertising data by an application.
There was missing LE Supported Features advertising data type in
macros defined in gap.h.

Besides that, the commit provides set of macros that help
to encode 64-bit LE Supported Features data into advertising
data.
There is a set of macros because all 0x0 bytes after last
non-zero byte should be ommited.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-11 11:45:27 +01:00
Gerard Marull-Paretas
696caa0524 pm: policy: return a reference to the next state
Return a constant reference to the next state instead of a copy of
struct pm_state_info. When the next state should be active, just return
NULL. Struct copying should be in general avoided, specially in code
paths executed frequently as is this one.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-11 10:46:20 +01:00
Gerard Marull-Paretas
8385d1bce5 pm: state: add pm_state_cpu_get_all
Add a new API to obtain the list of power states available for a given
CPU.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-11 10:46:20 +01:00
Gerard Marull-Paretas
da94d0d0f8 sys: time_units: add missing include
The header can't be fully used in standalone mode: toolchain.h has to be
included first, otherwise the ALWAYS_INLINE attribute is not defined.
Headers that can be directly included and are not self-contained should
be considered a bad practice.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-11 10:46:20 +01:00
Peter Mitsis
d1353a4584 kernel: pipes: add pipe flush routines
Adds two routines to flush pipe objects:
   k_pipe_flush()
     - This routine flushes the entire pipe. That includes both
     the pipe's buffer and all pended writers. It is equivalent
     to reading everything into a giant temporary buffer which
     is then discarded.
   k_pipe_buffer_flush()
     - This routine flushes only the pipe's buffer (if it exists).
     It is equivalent to reading a maximum of "buffer size" bytes
     into a temporary buffer which is then discarded.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-01-10 12:17:14 -05:00
Peter Mitsis
0ebd6c7f26 kernel/sched: enable/disable runtime stats
Adds support to enable/disable both thread and cpu runtime
stats.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-01-10 10:38:06 -05:00
Peter Mitsis
f498118daa debug: thread analyzer to display runtime stats
Updates the thread analyzer to display the thread runtime
stats.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-01-10 10:38:06 -05:00
Peter Mitsis
4eb1dd02cc kernel: extend CPU runtime stats
Extends the CPU usage runtime stats to track current, total, peak
and average usage (as bounded by the scheduling of the idle thread).
This permits a developer to obtain more system information if desired
to tune the system.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-01-10 10:38:06 -05:00
Peter Mitsis
572f1db56a kernel: extend thread runtime stats
When the new Kconfig option CONFIG_SCHED_THREAD_USAGE_ANALYSIS
is enabled, additional timing stats are collected during context
switches. This extra information allows a developer to obtain the
the current, longest, average and total lengths of the time that
a thread has been scheduled to execute.

A developer can in turn use this information to tune their app and/or
alter their scheduling policies.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-01-10 10:38:06 -05:00
Daniel Leung
ae415272c1 sys: heap_listener: extend to cover more events
This extends the heap_listener to cover more events,
specifically, allocation, free and realloc.

Note that typedef are used so the callback can be
documented.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-10 10:28:04 -05:00
Daniel Leung
39d17a180a sys: heap_listener: resize_cb to also take heap ID
Add a parameter to the resize callback to also take the heap ID.
This allows a single callback to be used for multiple heaps if
so desired.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-10 10:28:04 -05:00
Henrik Brix Andersen
abaf7cc70d drivers: clock_control: lpc: syscon: add MCAN clock support
Add support for the LPC MCAN clock to the LPC SYSCON clock controller
driver.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-01-10 12:00:20 +01:00
Henrik Brix Andersen
8af4bb722d drivers: can: rename API functions for better consistency
Rename a few CAN API functions for clarity and consistency with other
Zephyr RTOS APIs.

CAN_DEFINE_MSGQ() becomes CAN_MSGQ_DEFINE() to match K_MSGQ_DEFINE().

can_attach_isr() becomes can_add_rx_filter() since a filter callback
function is not an interrupt service routine (although it is called in
isr context). The word "attach" is replaced with "add" since filters are
added, not attached. This matches the terminology used is other Zephyr
APIs better.

can_detach() becomes can_remove_rx_filter() to pair with
can_add_rx_filter().

can_attach_msgq() becomes can_add_rx_filter_msgq() and documentation is
updated to mention its relationship with can_add_rx_filter().

can_register_state_change_isr() becomes can_set_state_change_callback()
since a state change callback function is not an interrupt service
routine (although it is called in isr context). The word "register" is
replaced with "set" since only one state change callback can be in
place.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-10 10:44:37 +01:00
Tomasz Bursztyka
479215100d spi: Grab relevant properties from DTS into the operation bitfield
duplex and frame_format where recently added and obviously need to be
grabbed from DTS relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2022-01-08 06:28:57 -05:00
Martin Jäger
b710fa0a3c include: drivers: uart: Fix wording and return value docs
Further improvement of Doxygen comments based on PR review comments.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-01-07 14:01:12 -05:00
Martin Jäger
3a197cad02 include: drivers: uart: Restructure to improve docs
- Introduce Doxygen groups for the different APIs (polling, interrupt-
  driven, asynchronous).
- Hide internal driver API as it confuses the average user.
- Move Async API to the bottom so that the file is ordered from generic
  to more specific/sophisticated functions.

No code was changed.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-01-07 14:01:12 -05:00
Aleksander Wasaznik
e97413057a Bluetooth: Host: Fix type mismatch in bt_gatt_cancel
`bt_gatt_cancel` takes a `bt_gatt_.._params` pointer. The `params`
pointer is mistakenly passed on to `bt_att_req_cancel`, which expects a
`bt_att_req`.

This change makes bt_gatt_cancel locate the `req` and pass that to
`bt_att_req_cancel`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
2022-01-07 12:48:52 -05:00
Marc Herbert
61fe69dded sys: device_mmio.h replace <toolchain/common.h> with <toolchain.h>
In include/sys/device_mmio.h, replacing <toolchain/common.h>
fixes the following warning:

$ west build -b qemu_x86  tests/arch/x86/static_idt/

In file included from zephyr/include/toolchain.h:50,
             from zephyr/include/linker/section_tags.h:12,
             from zephyr/include/linker/sections.h:132,
             from zephyr/include/sys/device_mmio.h:19,
             from zephyr/include/drivers/interrupt_controller/loapic.h:14,
             from zephyr/include/drivers/interrupt_controller/sysapic.h:10,
             from zephyr/include/arch/x86/arch.h:231,
             from zephyr/include/arch/cpu.h:15,
             from zephyr/tests/arch/x86/static_idt/src/test_stubs.S:17:
zephyr/include/toolchain/gcc.h:61: error: BUILD_ASSERT redefined [-Werror]
   61 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
      |
In file included from zephyr/include/sys/device_mmio.h:18,
             from zephyr/include/drivers/interrupt_controller/loapic.h:14,
             from zephyr/include/drivers/interrupt_controller/sysapic.h:10,
             from zephyr/include/arch/x86/arch.h:231,
             from zephyr/include/arch/cpu.h:15,
             from zephyr/tests/arch/x86/static_idt/src/test_stubs.S:17:
zephyr/include/toolchain/common.h:165: note: this is the location of the
  previous definition
  165 | #define BUILD_ASSERT(EXPR, MSG...) \

<toolchain.h> provides a compiler-specific BUILD_ASSERT.
<toolchain/common.h> provides a generic, fallback BUILD_ASSERT and
should probably never be included directly.

Thanks to Gerard Marull-Paretas for recommending this fix.

Related to commit af20208cd9 ("devices: mark device MMIO declarations
to boot/pinned sections") that added #include <linker/sections.h>

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-01-07 12:47:31 -05:00
Krzysztof Chruscinski
bd8cc594d9 lib: os: mpsc_pbuf: Add const to mpsc_pbuf_free argument
Added const qualifier to argument in a function.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-07 18:47:19 +01:00
Peter Mitsis
48f516469a kernel: Fix typo in macro name
Fixes a typo in the macro ARCH_DYMANIC_OBJ_K_THREAD_ALIGNMENT
so that DYMANIC becomes DYNAMIC.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-01-07 11:20:46 -05:00
Torsten Rasmussen
77a7615eb2 linker: update posix linker template, linker.ld
The function `zephyr_linker_sources()` states:
> When placing into NOINIT, RWDATA, RODATA, ROM_START, the contents of
> the files will be placed inside an output section, so assume the
> section definition is already present.

However, in the posix linker.ld template the NOINIT, RWDATA, RODATA, and
ROM_START was not placed inside a pre-defined output section, which
means that linker scripts created for native_posix when
`zephyr_linker_sources()` is used are invalid

This result in the following failure:
> /usr/bin/ld:zephyr/linker_zephyr_prebuilt.cmd:81: syntax error
> collect2: error: ld returned 1 exit status

This PR fixes this issue be predefining output sections according to
the documented behavior.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-01-07 17:00:28 +01:00
Tomasz Bursztyka
4090962386 drivers/interrupt_controller: Add source id to VT-D interrupt remap
Change the API and apply that change where relevant.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2022-01-07 10:47:27 -05:00
Tomasz Bursztyka
345e122dd2 arch/x86: Add a function to retrieve ID from ACPI's DMAR
This will be necessary to get IOAPIC and HPET source ids for VT-D.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2022-01-07 10:47:27 -05:00
Tomasz Bursztyka
149cef11ce drivers/interrupt_controller: VT-D may manipulate the cache
Depending on a VT-D capability, it might be necessary to flush objects
from the cache.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2022-01-07 10:47:27 -05:00