Commit graph

6855 commits

Author SHA1 Message Date
Jakub Rzeszutko 52c999210f shell: internal api update in shell.h
Add Z_ prefix for internal macros.
Remove obsolete defines.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-01-14 12:07:25 +01:00
Jakub Rzeszutko 14022083b2 shell: internal api update: uart backend
Add prefix Z_ to internal macros.
Remove obsolete and not used macros.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-01-14 12:07:25 +01:00
Jakub Rzeszutko 37e8d825bf shell: internal api update: log backend
Add prefix z_ to internal functions and macros handling log backend.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-01-14 12:07:25 +01:00
Jakub Rzeszutko 91b01ce703 shell: internal api update: history module
Add prefix z_ to internal functions handling history feature.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-01-14 12:07:25 +01:00
Jakub Rzeszutko 460995c810 shell: internal api update: fprintf
Add z_ prefix to internal fprintf functions and macros.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-01-14 12:07:25 +01:00
Anas Nashif fc1b5de4c3 kernel: move thread definitions to thread.h
Move thread definitions to its own header to avoid redeclaration and
redefinition of types which is not allowed in some standards.

Fixes #29937

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-13 18:18:42 -05:00
Daniel Leung 7a5f9e81de x86: define dynamic thread object alignment
x86 and x86_64 require certain alignment in the k_thread struct
since the buffer to save/restore FPU/SSE registers requires
strict alignment.

Fixes #29589
Fixes #29629

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-01-13 09:43:55 -08:00
Daniel Leung fe477ea6d3 kernel: userspace: aligned memory allocation for dynamic objects
This allows allocating dynamic kernel objects with memory alignment
requirements. The first candidate is for thread objects where,
on some architectures, it must be aligned for saving/restoring
registers.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-01-13 09:43:55 -08:00
Sylvio Alves 57c7dfbbc3 drivers: entropy: esp32: update register call
Update entropy driver to use proper registers

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-01-13 09:10:46 -05:00
Julien Massot 41f5c948a5 arch: arm: cortex_r: Add CMSIS support for Cortex-R7
This commit adds the CMSIS-Core(R) support to the Zephyr RTOS Cortex-R7.


Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-01-13 15:04:43 +01:00
Eden Desta fa6ac271ec Update can_common: Check bitrate is greater than 0
Ensure bitrate is greater than 0 so the program does not fault when RESET nmt command is sent
2021-01-12 15:11:18 -06:00
Henrik Brix Andersen 7aeb3df5c6 drivers: pwm: fix compilation with CONFIG_PWM_CAPTURE=n
Fix compilation with pwm.h with CONFIG_PWM_CAPTURE=n.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-01-12 15:55:43 -05:00
Henrik Brix Andersen 77b8440fd1 drivers: pwm: add API for capturing pwm pulse width and period
Extend the PWM API with optional API functions for capturing PWM pulse
width and period cycles.

Fixes #26026.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-01-12 19:43:06 +01:00
Kumar Gala 86e98f0894 device: deprecate DEVICE_AND_API_INIT
Make DEVICE_AND_API_INIT deprecated in favor of DEVICE_DT_INST_DEFINE
or DEVICE_DEFINE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-01-12 08:31:12 -06:00
Carlo Caione e710d36f77 aarch64: mmu: Enable CONFIG_MMU
Enable CONFIG_MMU for AArch64 and add the new arch_mem_map() required
function.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-01-12 06:51:09 -05:00
Carlo Caione 6a3401d6be aarch64: mmu: Fix variable types
Before hooking up the MMU driver code to the Zephyr MMU core code it's
better to match the expected variable types of the two parts.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-01-12 06:51:09 -05:00
Carlo Caione 0a0061d901 aarch64: mmu: Do not assume a single set of pagetables is used
The MMU code is currently assuming that Zephyr only uses one single set
of page tables shared by kernel and user threads. This could possibly be
not longer true in the future when multiple set of page tables can be
present and swapped at run-time.

With this patch a new arm_mmu_ptables struct is introduced that is used
to host a buffer pointing to the memory region containing the page
tables and the helper variables used to manage the page tables. This new
struct is then used by the ARM64 MMU code instead of assuming that the
kernel page tables are the only ones present.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-01-12 06:51:09 -05:00
chao an 1027b0e4f0 Bluetooth: host: add support for unregister scanner callback
This is a pairing function with bt_le_scan_cb_register()
to used for remove the scanner callback from callback list.

Signed-off-by: chao an <anchao@xiaomi.com>
2021-01-12 12:31:00 +02:00
chao.an bc7e86b9ec Bluetooth: host: Unified namespace of hci event
BT_HCI_EV_LE_REMOTE_FEAT_COMPLETE ->
BT_HCI_EVT_LE_REMOTE_FEAT_COMPLETE

Signed-off-by: chao an <anchao@xiaomi.com>
2021-01-12 12:30:11 +02:00
Flavio Ceolin 12af01a121 dts: Add _OR variant macro for DT_PROP_LEN
Like DT_PROP_LEN_OR(), but with a fallback to
default_value.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-10 12:43:08 -05:00
Erik Robstad 1feb49fd22 drivers: Dev. spec. PWM functionality for SX1509B
Add device specific functions for initiating
and controlling PWM output pins.

Signed-off-by: Erik Robstad <erik.robstad@nordicsemi.no>
2021-01-08 15:52:42 +01:00
Vinayak Kariappa Chettimada 6bc79ce33a Bluetooth: Define assigned number values of BIGInfo and Broadcast Code
Add defines for assigned number values of BIGInfo and
Broadcast Code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-08 16:38:19 +02:00
Flavio Ceolin 2b49266861 power: Add notifier API
Get rid of weak functions adding a new API to register an object to
receive notifications when the system changes power state.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-07 12:40:19 -05:00
Peter Bigot d12a99588b lib: cbprintf: remove cbprintf_arglen
This function was designed to support the logging infrastructure's
need to copy values from va_list structures.  It did not meet that
need, since some values need to be changed based on additional data
that is only available when the complete format specification is
examined.  Remove the function as unnecessary.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-07 14:02:06 +01:00
Peter Bigot acd43cbaac net: timeout: refactor to fix multiple problems
The net_timeout structure is documented to exist because of behavior
that is no longer true, i.e. that `k_delayed_work_submit()` supports
only delays up to INT32_MAX milliseconds.  Nonetheless, use of 32-bit
timestamps within the work handlers mean the restriction is still
present.

This infrastructure is currently used for two timers with long
durations:
* address for IPv6 addresses
* prefix for IPv6 prefixes

The handling of rollover was subtly different between these: address
wraps reset the start time while prefix wraps did not.

The calculation of remaining time in ipv6_nbr was incorrect when the
original requested time in seconds was a multiple of
NET_TIMEOUT_MAX_VALUE: the remainder value would be zero while the
wrap counter was positive, causing the calculation to indicate no time
remained.

The maximum value was set to allow a 100 ms latency between elapse of
the deadline and assessment of a given timer, but detection of
rollover assumed that the captured time in the work handler was
precisely the expected deadline, which is unlikely to be true.  Use of
the shared system work queue also risks observed latency exceeding 100
ms.  These calculations could produce delays to next event that
exceeded the maximum delay, which introduced special cases.

Refactor so all operations that use this structure are encapsulated
into API that is documented and has a full-coverage unit test.  Switch
to the standard mechanism of detecting completed deadlines by
calculating the signed difference between the deadline and the current
time, which eliminates some special cases.

Uniformly rely on the scanning the set of timers to determine the next
deadline, rather than assuming that the most recent update is always
next.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-07 11:14:38 +02:00
Jordan Yates 9f95d8d029 net: buf: convert #define to static inline
Swap the `net_buf_*` -> `net_buf_simple_*` conversion `#define`s to
`static inline` functions. This is to provide better type checking on
the use of these functions.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-01-07 10:40:48 +02:00
Enjia Mai 56f84b60ed tests: fix some issues when enabling coverage for qemu_x86_64
Fix some issues in linker.ld when enabling coverage report feature
for qemu_x86_64 platform:
1. Fix the gcov record data should not be in BSS section.
2. Fix some test case crash due to lack of memory page align before
gcov rodata.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-01-05 10:32:38 -08:00
Jordan Yates 7be105b86a net: buf: net_buf_remove_* API
Adds a new family of `struct net_buf` operations that remove data from
the end of the buffer.

The semantics of `net_buf_remove_mem` have been chosen to match those of
`net_buf_pull_mem`, i.e. the return value is a pointer to the memory
that was removed.

The opposite of this function, `net_buf_remove`, would need to return
the old end of the data buffer to be useful. However this value is
always an invalid target for reading or writing data to (It points to
the middle of unused data).The existance of the function would be
misleading, therefore it is not implemented.

Fixes #31069.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-01-05 14:31:13 +02:00
Jordan Yates a5cd0c0c51 net: buf: net_buf_push_mem function
Add function that copies in new data to the start of a `struct net_buf`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-01-05 14:31:13 +02:00
Piotr Pryga 1c493b4a77 Bluetooth: host: direction: Add public API to set CTE TX params for adv.
Add publicly accessible function to set Constant Tone Extension
parameters for CTE transmission with periodic advertising.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-05 09:38:53 +01:00
Piotr Pryga 098f767298 Bluetooth: host: Add set connectionless CTE TX params wrapper function
Add implementation of a wrapper for HCI_LE_Set_-
Connectionless_CTE_Transmit_Parameters send command.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-05 09:38:53 +01:00
Piotr Pryga 9bfc095d4a Bluetooth: host: Add DF to initalization sequence
Add Direction Finding to host initialization sequence.
It allows to get information about Direction finding
optional CTE settings supported by controller.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-05 09:38:53 +01:00
Flavio Ceolin 8fe3866e19 power: rename _pm_power_state_ -> pm_power_state
Leftover from old renaming commits. This function is not private and
should not start with underscore.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-04 09:02:23 -05:00
Jordan Yates d0a56690a4 net: buf: document fragment limitations
Document limitations on the FIFO queuing functions when fragments are
used. Namely that the `get` functions are not thread-safe when fragments
are present.

This is due to multiple independent calls to `k_fifo_get/sys_slist_get`.
A second thread can interrupt the retrieval before all fragments have
been removed. The second thread can then read from the FIFO, obtaining
the trailing fragments as a 'new' `net_buf`. The first thread will then
either assert or pull in the next `net_buf` on the queue as part of the
first `net_buf`.

Fixes #28355

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-01-04 14:14:04 +02:00
Peter Bigot 8c1bef535b device: support generating defines from devicetree nodes with no label
The existing code only worked for nodes that had a label property,
which is every device except ESP32 pinmux.  However, a label property
should not be necessary for defining a device from devicetree.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:19:27 +01:00
Christopher Friedt 135ffaff74 kernel/k_malloc: add k_aligned_alloc
This change adds z_heap_aligned_alloc() and k_aligned_alloc()
and changes z_heap_malloc() and k_malloc() to be small wrappers around
the aligned variants.

Fixes #29519

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-12-27 18:17:07 +01:00
Peter Bigot 4080b7727f fs: provide access to DT-defined mount structures
Use a devicetree fstab entry node identifier to provide a unique
identifier for a fs_mount_t structure that is defined with everything
necessary to mount the file system associated with a partition.

The fs_mount_t structure will be defined in the implementation for
each file system type.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Peter Bigot 2f3e18c2ff devicetree: flash-partitions: decode fstab entry mount flags
Add a helper to convert from zephyr,fstab-base mount options to the
corresponding fs subsystem mount flags.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Peter Bigot e571c88565 devicetree: flash-partitions: expose helper macros
Make generally available the macro that provides the flash device in
which a particular partition can be found.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Peter Bigot ba24cd2f0f fs: add a mount flag for automounting file systems
File systems can be described in a devicetree node which pre-defines a
mount structure.  A feature in that structure is that it can be
automatically mounted when the filesystem implementation registers
itself.  Add a flag that can be used to trigger this behavior.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-27 18:16:20 +01:00
Christopher Friedt 724ee49173 gpio: add driver for emulated GPIO
The emulated GPIO controller will aid in automated
integration testing.

Fixes #26477

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-12-27 18:15:33 +01:00
Mulin Chao fa7843d12c driver: espi: add notification and opcodes for ec host command support.
This CL add a new notification event, ESPI_PERIPHERAL_EC_HOST_CMD, and
two response opcodes, ECUSTOM_HOST_CMD_GET_PARAM_MEMORY and
ECUSTOM_HOST_CMD_SEND_RESULT, to connect with host command sub-system
between host and ec.

It also introduced three configurations to increase the flexibility of
ec host command settings:
1. ESPI_PERIPHERAL_HOST_CMD_DATA_PORT_NUM:
   Host I/O peripheral port number for ec host command data. The default
   value is 0x0200.
2. ESPI_PERIPHERAL_HOST_CMD_PARAM_PORT_NUM:
   Host I/O peripheral port number for ec host command parameters. The
   default value is 0x0800.

3. ESPI_NPCX_PERIPHERAL_HOST_CMD_PARAM_SIZE:
   Host I/O peripheral port size for ec host command in npcx series. The
   valid value in npcx ec series for this option is
   8/16/32/64/128/256/512/1024/2048/4096 bytes. The default value is 256
   bytes.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2020-12-20 13:05:50 -05:00
Mulin Chao 988a7a4826 driver: espi: add acpi and customized op codes for lpc r/w request func.
This CL introduces two kinds of op codes for espi_api_lpc_read_request
and espi_api_lpc_write_request Zephyr espi api functions.

One is for supporting ACPI and shared memory region to access ACPI data.
The other is customized for certain platforms such as Chromebook and so
on.

This CL also introduced the following configurations to add the
flexibility of these settings.

1. ESPI_PERIPHERAL_ACPI_SHM_REGION_PORT_NUM:
   Host I/O peripheral port number for shared memory region. The default
   value is default 0x0900

2. ESPI_NPCX_PERIPHERAL_ACPI_SHD_MEM_SIZE:
   Host I/O peripheral port size for shared memory in npcx series.
   Please notice the valid value in npcx ec series for this option is
   8/16/32/64/128/256/512/1024/2048/4096 bytes. The default value is 256
   bytes.

This CL also turn off hardware-wire feature which generates VW events
that connected to hardware signals such as SMI and SCI. We will set
VW output events directly via espi_api_send_vwire() api function.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2020-12-20 13:05:50 -05:00
Andrzej Głąbek f234c5f876 drivers: adc: Introduce the adc_sequence_options::user_data field
Introduce the field that can be used to associate a given sampling
sequence with any other data needed in the sampling-done callback
function.
Adjust one ADC API test case that uses a sequence callback so that
it checks if this introduced field is propagated as expected.

Also clarify in the description of the `sequence` parameter of the
callback function that this parameter is not supposed to be supplied
to the CONTAINER_OF() macro, to avoid any further confusion in that
regard.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-12-20 13:34:59 +01:00
Rihards Skuja 3b89f4a474 Bluetooth: fix C++ compile error
C++ disallows implicit cast to enum values.

Signed-off-by: Rihards Skuja <rihardssk@mikrotik.com>
2020-12-19 22:05:33 -05:00
Kumar Gala 9705df3084 drivers: gpio: Convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert driver(s) to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 19:59:05 -05:00
Fabio Utzig e64f4f950e doc: add kernel stack macros to stack apis
Fix broken references to K_THREAD_STACK_* and K_KERNEL_STACK_* macros
by adding those to the existing stack_apis group.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-12-18 12:18:50 +01:00
Fabio Utzig 8713da70a3 doc: fix @param usage in callbacks
The proper usage of @param in callbacks is currently unsupported by
Doxygen so not warnings are generated. The issues fixed with this commit
where found while adding support to Doxygen for validating @param in
callbacks like it currently does for functions.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-12-18 12:18:28 +01:00
Kumar Gala 7bd5607c33 net: ethernet: Introduce devicetree aware DEVICE define macros
Provide versions of ETH_NET_DEVICE_INIT that are both devicetree
node and instance aware. We use the _DEFINE suffix for the DT
versions to match the naming convention in device.h

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-17 11:02:11 -06:00
Kumar Gala ecba5aaa95 net: Introduce devicetree aware DEVICE define macros
Provide versions of NET_DEVICE_INIT, NET_DEVICE_INIT_INSTANCE, and
NET_DEVICE_OFFLOAD_INIT that are both devicetree node and instance
aware.  We use the _DEFINE suffix for the DT versions to match the
naming convention in device.h

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-17 11:02:11 -06:00