Commit graph

6135 commits

Author SHA1 Message Date
Andy Ross e39bf29321 kernel/timeout: Doc cleanup
Add a doc string for k_timeout_t.  Rephrase a few other items for
clarity.  Fix some syntax goofs.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Andy Ross 914205ca85 kernel/timeout: Add k_uptime_ticks() API
Add a call to get the system tick count as an official API (and
redefine the existing millisecond API in terms of it).  Sophisticated
applications need to be able to count ticks directly, and the newer
timeout API supports that.  Uptime should too, for symmetry.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Andy Ross 5a5d3daf6f kernel/timeout: Add timeout remaining/expires APIs
Add tick-based (i.e. precision resistant) inspection APIs for kernel
timeouts visible via k_timer, k_delayed work and thread timeouts
(i.e. pended/sleeping threads).  These are each available in
"remaining" and "expires" variants returning time values relative to
current time and system start.  All have system calls where applicable
(i.e. everywhere but k_delayed_work, which is not a userspace API)

The pre-existing millisecond "remaining_get()" predicates for timer
and delayed work remain, but are expressed in terms of the newer
calls.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Andy Ross e1bc595947 kernel.h: Add timeout APIs for higher precision units
Add timeout generator macros to the public API for micro/nanosecond
values and cycles.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Andy Ross 4c7b77a716 kernel/timeout: Add absolute timeout APIs
Add support for "absolute" timeouts, which are expressed relative to
system uptime instead of deltas from current time.  These allow for
more race-resistant code to be written by allowing application code to
do a single timeout computation, once, and then reuse the timeout
value even if the thread wakes up and needs to suspend again later.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Andy Ross cfeb07eded kernel/timeout: Enable 64 bit timeout precision
Add a CONFIG_TIMEOUT_64BIT kconfig that, when selected, makes the
k_ticks_t used in timeout computations pervasively 64 bit.  This will
allow much longer timeouts and much faster (i.e. more precise) tick
rates.  It also enables the use of absolute (not delta) timeouts in an
upcoming commit.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Andy Ross 7832738ae9 kernel/timeout: Make timeout arguments an opaque type
Add a k_timeout_t type, and use it everywhere that kernel API
functions were accepting a millisecond timeout argument.  Instead of
forcing milliseconds everywhere (which are often not integrally
representable as system ticks), do the conversion to ticks at the
point where the timeout is created.  This avoids an extra unit
conversion in some application code, and allows us to express the
timeout in units other than milliseconds to achieve greater precision.

The existing K_MSEC() et. al. macros now return initializers for a
k_timeout_t.

The K_NO_WAIT and K_FOREVER constants have now become k_timeout_t
values, which means they cannot be operated on as integers.
Applications which have their own APIs that need to inspect these
vs. user-provided timeouts can now use a K_TIMEOUT_EQ() predicate to
test for equality.

Timer drivers, which receive an integer tick count in ther
z_clock_set_timeout() functions, now use the integer-valued
K_TICKS_FOREVER constant instead of K_FOREVER.

For the initial release, to preserve source compatibility, a
CONFIG_LEGACY_TIMEOUT_API kconfig is provided.  When true, the
k_timeout_t will remain a compatible 32 bit value that will work with
any legacy Zephyr application.

Some subsystems present timeout (or timeout-like) values to their own
users as APIs that would re-use the kernel's own constants and
conventions.  These will require some minor design work to adapt to
the new scheme (in most cases just using k_timeout_t directly in their
own API), and they have not been changed in this patch, instead
selecting CONFIG_LEGACY_TIMEOUT_API via kconfig.  These subsystems
include: CAN Bus, the Microbit display driver, I2S, LoRa modem
drivers, the UART Async API, Video hardware drivers, the console
subsystem, and the network buffer abstraction.

k_sleep() now takes a k_timeout_t argument, with a k_msleep() variant
provided that works identically to the original API.

Most of the changes here are just type/configuration management and
documentation, but there are logic changes in mempool, where a loop
that used a timeout numerically has been reworked using a new
z_timeout_end_calc() predicate.  Also in queue.c, a (when POLL was
enabled) a similar loop was needlessly used to try to retry the
k_poll() call after a spurious failure.  But k_poll() does not fail
spuriously, so the loop was removed.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Andy Ross 32bb2395c2 timeout: Fix up API usage
Kernel timeouts have always been a 32 bit integer despite the
existence of generation macros, and existing code has been
inconsistent about using them.  Upcoming commits are going to make the
timeout arguments opaque, so fix things up to be rigorously correct.
Changes include:

+ Adding a K_TIMEOUT_EQ() macro for code that needs to compare timeout
  values for equality (e.g. with K_FOREVER or K_NO_WAIT).

+ Adding a k_msleep() synonym for k_sleep() which can continue to take
  integral arguments as k_sleep() moves away to timeout arguments.

+ Pervasively using the K_MSEC(), K_SECONDS(), et. al. macros to
  generate timeout arguments.

+ Removing the usage of K_NO_WAIT as the final argument to
  K_THREAD_DEFINE().  This is just a count of milliseconds and we need
  to use a zero.

This patch include no logic changes and should not affect generated
code at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Carlo Caione 99a8155914 arm: AArch64: Add support for nested exception handlers
In the current implementation both SPSR and ELR registers are saved with
the callee-saved registers and restored by the context-switch routine.
To support nested IRQs we have to save those on the stack when entering
and exiting from an ISR.

Since the values are now carried on the stack we can now add those to
the ESF and the initial stack and take care to restore them for new
threads using the new thread wrapper routine.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-03-31 19:24:48 +02:00
Stephanos Ioannidis ed82a60767 interrupt_controller: gic: Add GICD_SGIR field definitions
This commit adds the GICD_SGIR register (used for generating software
generated interrupts) field definitions.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-31 19:24:48 +02:00
Joakim Andersson 29749af88a Bluetooth: host: Fix high-duty cycle directed extended advertising
Fix high-duty cycle directed advertising when extended advertising
feature has been enabled. The duration parameter when starting extended
high duty cycle directed advertising has to be set to a non-zero value
less than or equal to 1.28 seconds.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-31 12:48:19 +03:00
Oleg Zhurakivskyy b1e1f64d14 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-31 07:18:06 +02:00
Oleg Zhurakivskyy c408fa88a3 toolchain: common: Merge build assert macros
In order to de-duplicate 2 macros with the same use,
merge BUILD_ASSERT(), BUILD_ASSERT_MSG() into one macro.

Make BUILD_ASSERT_MSG() deprecated.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-31 07:18:06 +02:00
Joakim Andersson ed11ca1744 Bluetooth: host: Add error code to directed advertiser
Add error code to API for starting directed advertiser. Also rename the
API in order to follow the established naming pattern.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson e1fafc8b9f Bluetooth: HCI: Add additional HCI defines for extended advertising
Add additional HCI defines for extended advertising. Renamed a few
parameters that are not yet in use.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson 69a82170c4 Bluetooth: host: Add scan API for extended scanner
Add scanner API for extended scanner. This includes the options to scan
on the LE Coded PHY for long range, configuring scan timeout with scan
timeout callback and additional information received from the extended
advertising report.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson f2d7b77e96 Bluetooth: host: Deprecate BT_LE_ADV defines in hci.h in favour of gap.h
Deprecate BT_LE_ADV defines in hci.h that are expected to be used by the
application in the scan received callback to identify the advertising
PDU type. These defines are mixing HCI input parameters and advertising
PDU types. Internally it is acceptable to mix these, but at the API we
should to mix in them.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson be57dfbe2a Bluetooth: host: Rename and deprecate scan filter for more scan options
Rename filter_dup parameters used for scanning filter options to the
more generic name options, and make scan filter options follow same
naming patters as advertising and initiator scan options.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson b8f48410e5 Bluetooth: host: Add API for advertising sets
Add API for creating and starting advertising sets. This allows to start
and advertising set for a specific timeout or number of events.
The advertising set can be configured to advertise extended data on
secondary advertising channels or advertise on LE Coded PHY to give the
advertiser longer range.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson 405ce842ab Bluetooth: host: Add new argument and return code to bt_create_conn_le
Deprecate bt_create_conn_le and rename it to in order to add return
code, new arguments and to follow the established naming convention.

Add API for the application to control the scan parameters of the
initiator role. This allows the application more scheduling control
of the initiator in multi-role scenarios. Also provides options to
configure the initiator for LE Coded PHY for long range support.
We deprecate the old way of creating connection to make the name more
consistent with the rest of the API.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Joakim Andersson 7d5a10038d Bluetooth: host: Add GAP definitions
Add GAP definitions for advertising PDU types and properties LE PHY
types and values that signifies either invalid or disabled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-30 00:38:23 +03:00
Martí Bolívar 574ee1cd80 devicetree.h: fix typo in docstring
The name of the chosen node existence check DT_HAS_CHOSEN is wrong.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-29 09:10:04 -05:00
Martí Bolívar 413e16d7bf devicetree.h: sort sub-includes and API docs for them
Trivial cleanup: sort the devicetree/foo.h includes and the relevant
sections for them in the documentation.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-29 09:10:04 -05:00
Jaron Kelleher c6fd99d048 api: irq: Add Multi-level IRQ utility functions
This adds utility functions to irq.h in accordance with zephyr's
multi-level irq numbering schema. Functions that are added will
get the zephyr IRQs level and provide function to return the
interrupt number at a particular level.

Fixes issue #20338

Signed-off-by: Jaron Kelleher <jkelleher@fb.com>
2020-03-28 07:12:30 -04:00
Tomasz Bursztyka 4322c66e4b net: Expose a way to know if the network interface is suspended or not
And use it in the shell to display such information then.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-03-27 14:48:30 +02:00
Tomasz Bursztyka 80917ec16f net: Add preliminaly support for suspending/resuming a net interface
Such state needs to be set _from_ the PM API functions and not the other
way round. So if a network device driver does not support such API, it
will not be able to set the core net_if on PM state, obviously.

Currently, these functions only set/unset NET_IF_SUSPENDED flag.

More logic will be added later, to decide whether the net_if can be
actually set to suspend mode or not and also to take care of all timers
related to the interface.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-03-27 14:48:30 +02:00
Jukka Rissanen dee07c9e0a net: if: Add function to check any pending TX packets
This function can be used for example by network power management
to check if the network interface can be suspended or not.
If there are network packets in transmit queue, then the network
interface cannot be suspended yet.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-03-27 14:48:30 +02:00
Tomasz Bursztyka 4ae72db135 net: Enable PM settings on network devices
By changing the various *NET_DEVICE* macros. It is up to the device
drivers to either set a proper PM function or, if not supported or PM
disabled, to use device_pm_control_nop relevantly.

All existing macro calls are updated. Since no PM support was added so
far, device_pm_control_nop is used as the default everywhere.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-03-27 14:48:30 +02:00
Tomasz Bursztyka ebe20f99c7 device: Provide a dummy macro for device_pm_control_nop on disabled PM
This will prove to be useful on enabling PM setting for the network
devices.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-03-27 14:48:30 +02:00
Kumar Gala 1c3ed6dab6 devicetree: Rename spi cs gpio macros
Rename the DT_*_CS_* macro's to DT_*_CS_GPIOS_* to be more clear.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 12:24:23 -05:00
Ioannis Papamanoglou 7cb7dd277a devicetree.h: Add macro DT_INST_FOREACH
With this macro device drivers can call macros and functions
on every device instance compatible to that driver.
This makes it possible to make drivers agnostic to the
potential counts of instances.
Sidenote: Introduces helper macro DT_CALL_WITH_ARG.

Signed-off-by: Ioannis Papamanoglou <iopapamanoglou@gmail.com>
2020-03-26 11:15:38 -05:00
Robert Lubos ca5489d99f net: ieee802154: Add config to enable PAN coordinator mode
Add config to the radio API to enable/disable PAN coordinator mode.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-03-26 17:42:40 +02:00
Robert Lubos 5f67e4d9df net: ieee802154: Add config to enable promiscous mode
Add config to the radio API to enable/disable promiscuous mode.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-03-26 17:42:40 +02:00
Kumar Gala 8ea8925ebe drivers: esp32: Convert esp32 drivers to new DT_INST macros
Convert older DT_INST_ macro use in esp32 drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 08:49:11 -05:00
Johan Carlsson 552508506f usb: filter out synchronization type for isochronous endpoints
Fix so that different isochronous synchronization modes can be used.
It filters out the synchronization mode before sending the endpoint
type to drivers.

Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
2020-03-26 14:09:55 +01:00
Krzysztof Chruscinski 81c3d7b925 logging: Fix LOG_LEVEL_SET macro
LOG_LEVEL_SET was ignoring level argument and was setting default
log level always.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-03-26 08:04:02 -04:00
Stephanos Ioannidis 33928f18ae arch: arm: aarch32: Add header shims for cortex_a_r renaming
Out-of-tree code can still be using the old file locations. Introduce
header shims to include the headers from the new correct location and
print a warning message.

These shims should be removed after two releases.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-26 11:20:36 +01:00
Stephanos Ioannidis a033683783 arch: arm: aarch32: Rename cortex_r to cortex_a_r
This commit renames the `cortex_r` directory under the AArch32 to
`cortex_a_r`, in preparation for the AArch32 Cortex-A support.

The rationale for this renaming is that the Cortex-A and Cortex-R share
the same base design and the difference between them, other than the
MPU vs. MMU, is minimal.

Since most of the architecture port code and configurations will be
shared between the Cortex-A and Cortex-R architectures, it is
advantageous to have them together in the same directory.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-26 11:20:36 +01:00
Kumar Gala ec4584348e devicetree: Add DT_INST version of some DT_*_HAS_* macros
Add DT_INST implementations of DT_PROP_HAS_IDX, DT_PHA_HAS_CELL_AT_IDX,
and DT_INST_PHA_HAS_CELL.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 05:18:32 -05:00
Kumar Gala d3871c909d devicetree: fix whitespace in devicetree.h
Fix some minor whitespace issues in include/devicetree.h

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 05:18:32 -05:00
Martí Bolívar 9d15e98643 devicetree: fix DT_NUM_INST() when the answer is 0
Use UTIL_AND() so it works even when there are no instances.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-26 03:22:33 -05:00
Daniel Leung 4e1637b54e kernel: add sys init level for SMP
This adds a sys init level which allows device and sys_init
to be done after SMP initialization, z_smp_init(), when all
cores are up and running.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-03-25 19:07:28 -04:00
Krzysztof Chruscinski f0548f100e shell: Replace __attribute__((unused)) with __unused
Replaced gcc specific with generic.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-03-25 09:34:21 -04:00
Krzysztof Chruscinski 2885da209b logging: Replace __attribute__((unused)) with __unused
Replaced gcc specific with generic.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-03-25 09:34:21 -04:00
Martí Bolívar 1edc84f526 sys/util.h: add UTIL_OR and UTIL_AND
These are short-circuiting utility helpers that can save typing
in situations where avoiding evaluation of the not-taken branch
skips invalid expressions.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-25 13:21:28 +01:00
Martí Bolívar 49f97f64dd devicetree: add DT_HAS_DRV_INST(instance_number)
Convenience macro for checking the existence of a node by instance
number.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-24 14:04:27 -05:00
Martí Bolívar c3ec5db6d2 devicetree.h: add accessor API for nodes and properties
This is joint work with Kumar Gala (see signed-off-by).

Add helper macros which abstract the "true names" of each of the four
types of node identifier we intend to support (e.g. DT_ALIAS(),
DT_INST()).

These can be passed to a new DT_PROP() macro which can be used to read
the value of a devicetree property given a node identifier from one of
these four other macros, and the as-a-c-token name of the property.
Add other accessor macros and tests as well.

Add some convenience APIs for writing device drivers based on instance
numbers as well. Drivers can "#define DT_DRV_COMPAT driver_compatible"
at the top of the file, then utilize these DT_INST_* macros to access
various property defines.

For example, the uart_sifive driver can do:

  #define DT_DRV_COMPAT sifive_uart0

Then use DT_INST macros like:

  .port         = DT_INST_REG_ADDR(0),
  .sys_clk_freq = DT_INST_PROP(0, clock_frequency),

For convenience working with specific hardware, also add:

  <devicetree/gpio.h>
  <devicetree/adc.h>
  <devicetree/spi.h>

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-24 10:11:20 -05:00
Martí Bolívar dc85edd2e9 scripts: dts: write new gen_defines.py
This is joint work with Kumar Gala (see signed-off-by).

This supports a new devicetree macro syntax coming. It's not really
worth mixing up the old and the new generation scripts into one file,
because:

- we aim to remove support for the old macros at some point, so it
  will be cleaner to start fresh with a new script based on the old one
  that only generates the new syntax

- it will avoid regressions to leave the existing code alone while
  we're moving users to the new names

Keep the existing script by moving it to gen_legacy_defines.py and
changing a few comments and strings around. It's responsible for
generating:

- devicetree.conf: only needed by deprecated kconfigfunctions
- devicetree_legacy_unfixed.h: "old" devicetree_unfixed.h macros

Put a new gen_defines.py in its place. It generates:

- zephyr.dts
- devicetree_unfixed.h in the new syntax

Include devicetree_legacy_unfixed.h from devicetree.h so no DT users
are affected by this change.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-24 10:11:20 -05:00
Peter Bigot 42f9d14a3f kernel: deprecate k_uptime_delta_32
The documentation motivates this function by saying it is more
efficient than the core 64-bit version.  This was untrue when
originally added, and is untrue now.  Mark the function deprecated and
replace its sole in-tree use with the trivial equivalent.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-03-23 10:26:05 -04:00
Joakim Andersson e4538c6807 Bluetooth: HCI: Re-organize vendor read static address handling
Add header definition for bt_read_static_addr function. Declaring it
without a header definition will not give any compilation error when
function definition changes.
Refactor nRF SoC specific code into nRF specific source files and
provide weak definitions when these are not implemented. This will make
it easier to add handlers per vendor.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-22 11:58:17 +02:00
Ioannis Glaropoulos 91f6d98745 kernel: cpu idle: add info about IRQ unlocking in k_cpu_idle
We add a note in k_cpu_idle() documentation, stressing that for
certain architectures. the function unmasks interrupts
unconditionally before returning. In the
documentation of the architecture-specific API (arch_cpu_idle)
we describe the expected behavior with regards to the wake-up
event.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-03-20 11:53:14 +01:00
Carles Cufi cd38fb1610 Revert "toolchain: common: Merge build assert macros"
This reverts commit 974aa3add4.

Pull Request #23437 was merged by mistake with an invalid manifest.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-19 18:45:13 +01:00
Carles Cufi 4b37a8f3a4 Revert "global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()"
This reverts commit 8739517107.

Pull Request #23437 was merged by mistake with an invalid manifest.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-19 18:45:13 +01:00
Oleg Zhurakivskyy 8739517107 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-19 15:47:53 +01:00
Oleg Zhurakivskyy 974aa3add4 toolchain: common: Merge build assert macros
In order to de-duplicate 2 macros with the same use,
merge BUILD_ASSERT(), BUILD_ASSERT_MSG() into one macro.

Make BUILD_ASSERT_MSG() deprecated.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-19 15:47:53 +01:00
Stephanos Ioannidis 495407aabc interrupt_controller: gic: Fix GICD_ICFGR field definition names
This commit fixes the field definition names for `GICD_ICFGR`, which
were incorrectly prefixed with `GICC_`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-19 14:15:40 +01:00
Stephanos Ioannidis efd6e4c3a5 arch: arm: cortex_r: Add CMSIS support
This commit adds the CMSIS-Core(R) support to the Zephyr RTOS Cortex-R
architecture port.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-18 15:47:21 -05:00
Carles Cufi 4ffeb79ecd doc: reference: Add disk access API
Add the disk access API to the doc reference.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-18 11:47:24 +01:00
Carles Cufi 68bfb5c3f2 doc: reference: Add clock control API
Add the clock control API to the documentation reference.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-18 11:47:24 +01:00
Carles Cufi 22854d39c0 doc: reference: Add the LED and LED Strip APIs
Add the LED (regular and strip) APIs to the doc.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-18 11:47:24 +01:00
Carles Cufi 46f108519d doc: reference: Add hwinfo API
Add the hwinfo API to the reference documentation.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-18 11:47:24 +01:00
Carles Cufi 5690b1e69d doc: reference: Add pages for audio
Add reference pages for the following APIs:

- Audio Codec
- DMIC

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-18 11:47:24 +01:00
Carles Cufi ab03b538d4 doc: reference: Add GNA API entry
Add an entry for the GNA API.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-18 11:47:24 +01:00
Martí Bolívar 7b2376b72e util.h: add MACRO_MAP_CAT() and MACRO_MAP_CAT_N()
This is like MACRO_MAP(), but it pastes the results together into a
single token. The result is kind of a fold of the ## operator.

I wasn't able to figure out a way to implement this using any of the
existing macros, so there's some more copy/pasting of handler macros
for different numbers of arguments.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-18 03:12:08 -06:00
Joakim Andersson 6339cd0c96 Bluetooth: host: Minor header file doxygen fixes
Minor header file doxygen fixes:
 - Use /** @brief consistently
 - Indent all comments to the same level
 - Use @note instead of NOTE:
 - Align @note text
 - Align @return text
 - Add /** to documentation comments

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-17 21:13:35 +02:00
Andrew Boie 28be793cb6 kernel: delete separate logic for priv stacks
This never needed to be put in a separate gperf table.
Privilege mode stacks can be generated by the main
gen_kobject_list.py logic, which we do here.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-17 20:11:27 +02:00
Andrew Boie 2dc2ecfb60 kernel: rename struct _k_object
Private type, internal to the kernel, not directly associated
with any k_object_* APIs. Is the return value of z_object_find().
Rename to struct z_object.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-17 20:11:27 +02:00
Andrew Boie 2f3a89fa8d kernel: rename _k_object_assignment
Private structure, rename to z_object_assignment

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-17 20:11:27 +02:00
Andrew Boie 4bad34e749 kernel: rename _k_thread_stack_element
Private data type, prefix with z_.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-17 20:11:27 +02:00
Andrew Boie f2734ab022 kernel: use a union for kobject data values
Rather than stuffing various values in a uintptr_t based on
type using casts, use a union for this instead.

No functional difference, but the semantics of the data member
are now much clearer to the casual observer since it is now
formally defined by this union.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-17 20:11:27 +02:00
Jukka Rissanen 78234833a7 net: pkt: Add flag for telling if this is 1st TCP packet
TCP code needs to know whether the pkt is sent the first time
or is it a resent one. This information is used when deciding
if the pkt ref count needs to be increased or not. The packet
does not need to increase ref count when sent first time, as
the ref count is already 1 when the pkt is created. But for the
2nd time the packet is sent, we will need to increase the ref
count in order to avoid buffer leak.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-03-17 13:13:58 +02:00
Dominik Ermel 08c8dc7e27 subsys/mgmt: Enabling mynewt-core version of tinycbor
This PR provides changes that are required after replacing Tinycbor
with copy of source code from mynewt-core.
The Tinycbor has been replaced with mynewt-core version to reduce
maintenance effort; by replacing it the Zephy specific changes have been
reduced to small patch over mynewt codebase.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-03-17 11:58:18 +01:00
Andrew Boie 7cb8f5c61e include: debug: remove old stack functions
These were unsafe.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-14 13:10:19 -04:00
Andrew Boie 760644041c net: purge NET_STACK and other stack APIs
The current design of the network-specific stack dumping APIs
is fundamentally unsafe. You cannot properly dump stack data
without information which is only available in the thread object.

In addition, this infrastructure is unnecessary. There is already
a core shell command which dumps stack information for all
active threads.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-14 13:10:19 -04:00
Anas Nashif 428261945b doc: doxygen: add missing groups and categorise
Add various missing groups and categorise modules correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-14 13:01:03 -04:00
Anas Nashif b12869a3f9 docs: crypto: crypto API documentation
Fix crypto API doxygen syntax and integrate into documentation as RST.

Fixes #21820

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-03-14 13:01:03 -04:00
Stephanos Ioannidis cd90d49a86 arch: arm: Optimise Cortex-R exception return function.
z_arm_exc_exit (z_arm_int_exit) requires the current execution mode to
be specified as a parameter (through r0). This is not necessary because
this value can be directly read from CPSR.

This commit modifies the exception return function to retrieve the
current execution mode from CPSR and removes all provisions for passing
the execution mode parameter.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-14 11:49:22 +01:00
Timo Teräs e740818093 driver: uart: ns16550: convert custom init options to DTS flow control
The sole purpose of init options has been to enable hardware flow
control on NS16750 when asked. Use the proper DTS tags for this.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2020-03-14 02:22:05 +02:00
Marcin Niestroj dc5ac89ab9 posix: add zephyr_linker_sources() support
Add snippets sections in linker script, so we add support for
zephyr_linker_sources() in native_posix arch.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-03-13 19:24:21 +01:00
Jose Alberto Meza 7325f460eb API: peci: Add Platform Environment Control Interface API
Add Platform Environment Control Interface API
This API defines following calls:

- peci_configure
- peci_enable
- peci_disable
- peci_transaction

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2020-03-13 18:53:04 +02:00
Joakim Andersson 628b3bc416 Bluetooth: host: Allow get local OOB data while advertiser is enabled
Allow to get local OOB data while advertiser, scanner or whitelist
initiator is active. If direct initiator is active or the advertiser
is using the random address as a random static identity address then
the function will return error.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-13 17:16:51 +02:00
Joakim Andersson ba2a327c5b Bluetooth: host: Update documentation regarding LE SC and OOB pairing
Update documentation regarding LE SC and OOB to include full name
befor starting to use abbreviations. Rephrase some sentences to be more
clear and add references to Kconfig options.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-13 17:16:51 +02:00
Francisco Munoz f400589c32 include: drivers: sensor: Add sensor channel for TACH
Introduce an appropiate channel for reading back RPMs in tachometers

Signed-off-by: Francisco Munoz <francisco.munoz.ruiz@intel.com>
2020-03-13 08:49:21 -05:00
Kumar Gala 28a88fc638 sys/util.h: allow UTIL_LISTIFY to pass args to repeat macro
Change UTIL_LISTIFY to support passing arguments to the F macro.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-13 07:33:57 -06:00
Andrew Boie 322816eada kernel: add k_thread_join()
Callers will go to sleep until the thread exits, either normally
or crashing out.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-13 08:42:43 -04:00
Stephanos Ioannidis e816ac7124 isr_tables: Support hardware interrupt vector table-only configuration.
The existing isr_tables implementation does not allow enabling only
hardware interrupt vector table without software isr table.

This commit ensures that CONFIG_GEN_IRQ_VECTOR_TABLE can be used
without setting CONFIG_GEN_SW_ISR_TABLE.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-13 12:02:03 +01:00
Stephanos Ioannidis 91ceee782f arch: arm: aarch64: Refactor interrupt interface
The current AArch64 interrupt system relies on the multi-level
interrupt mechanism and the `irq_nextlevel` public interface to invoke
the Generic Interrupt Controller (GIC) driver functions.

Since the GIC driver has been refactored to provide a direct interface,
in order to resolve various implementation issues described in the GIC
driver refactoring commit, the architecture interrupt control functions
are updated to directly invoke the GIC driver functions.

This commit also adds support for the ARMv8 cores (e.g. Cortex-A53)
that allow interfacing to a custom external interrupt controller
(i.e. non-GIC) by mapping the architecture interrupt control functions
to the SoC layer interrupt control functions when
`ARM_CUSTOM_INTERRUPT_CONTROLLER` configuration is enabled.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-13 09:59:59 +01:00
Stephanos Ioannidis 2c5ca5505c arch: arm: aarch32: Refactor interrupt interface
The current AArch32 (Cortex-R and to-be-added Cortex-A) interrupt
system relies on the multi-level interrupt mechanism and the
`irq_nextlevel` public interface to invoke the Generic Interrupt
Controller (GIC) driver functions.

Since the GIC driver has been refactored to provide a direct interface,
in order to resolve various implementation issues described in the GIC
driver refactoring commit, the architecture interrupt control functions
are updated to directly invoke the GIC driver functions.

This commit also adds support for the Cortex-R cores (Cortex-R4 and R5)
that allow interfacing to a custom external interrupt controller
(i.e. non-GIC) by introducing the `ARM_CUSTOM_INTERRUPT_CONTROLLER`
configuration that maps the architecture interrupt control functions to
the SoC layer interrupt control functions.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-13 09:59:59 +01:00
Stephanos Ioannidis 5ab698bd56 arch: arm: aarch32: Fix header description
This commit fixes incorrect header descriptions for the ARM AArch32
public headers.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-13 09:59:59 +01:00
Stephanos Ioannidis 50519ce7ba interrupt_controller: gic: Refactor GIC driver interface
The current Generic Interrupt Controller (GIC) driver makes use of the
multi-level interrupt mechanism and `irq_nextlevel` public interface.

This is a less-than-ideal implementation for the following reasons:

1. The GIC is often used as the main interrupt controller for the
  Cortex-A and Cortex-R family SoCs and, in this case, it is not a 2nd
  level interrupt controller; in fact, it is the root interrupt
  controller and therefore should be treated as such.

2. The only reason for using `irq_nextlevel` here is to interface the
  architecture implementation to the interrupt controller functions.
  Since there is no nesting or multiple instances of an interrupt
  controller involved, there is really no point in adding such an
  abstraction.

3. 2nd level topology adds many unnecessary abstractions and results
  in strange coding artefacts as well as performance penalty due to
  additional branching.

This commit refactors the GIC driver interface as follows:

1. Remove the current GIC driver interface based on the multi-level
  interrupt mechanism and the `irq_nextlevel` public interface.

2. Define the GIC driver interface in
  `include/drivers/interrupt_controller/gic.h` and allow the arch
  implementation to directly invoke this interface.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-13 09:59:59 +01:00
Marcin Niestroj accef325a2 net: mqtt: add MQTT_UTF8_LITERAL() helper macro
This macro allows to easily initialize utf8 strings (struct mqtt_utf8)
from C literals, as it automatically calculates string length.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-03-13 10:06:18 +02:00
Ioannis Glaropoulos d9a6e1d0c0 arch: arm: aarch32: rename z_arm_int_lib_init() function
We rename the z_arm_int_lib_init() function to
z_arm_interrupt_init(), aligning to how other
ARCHes name their IRQ initialization function.
There is nothing about 'library' in this
functionality, so we remove the 'lib' in-fix.

The commit does not introduce any behavior changes.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-03-12 20:11:44 +02:00
Flavio Ceolin b0b320b7dd drivers: i2c: Remove invalid syscalls
i2c_slave_register/unregister must not be syscalls since it provides
callbacks that will run in supervisor mode. Nonetheless, verification
functions were missing which means that these functions never worked
from usermode.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-12 19:52:01 +02:00
Iván Morales cc0d2447f1 Bluetooth: smp: Adding Legacy OOB pairing support
Added support for Legacy pairing using OOB Temporary Key

Signed-off-by: Iván Morales <ivan98ams@gmail.com>
2020-03-12 12:30:15 +02:00
PK Chan 9f9e00a62d net: mqtt: Added event for MQTT ping response.
There are scenarios where there is a NAT firewall in between MQTT
client and server. In such case, the NAT TCP timeout may be shorter
than MQTT keepalive timeout and TCP timeout. The the MQTT ping
request message is dropped by the NAT firewall, so that it cannot be
received by the server, resulting in void MQTT ping response message.
There is no TCP FIN or RST at all. The application looks hang-up
until TCP timeout happens on the client side, which may take too
long.

Therefore, the event MQTT_EVT_PINGRESP is added to inform the
application that the route between client and server is still valid.

Signed-off-by: PK Chan <pak.kee.chan@nordicsemi.no>
2020-03-12 11:07:14 +02:00
Corey Wharton 86bfc489f4 scripts: Replace hard-coded subsystem list with __subsystem annotations.
This change removes the hardcoded subsystem list in gen_kobject_list.py
favor of marking the relevant driver API structs with the _subsystem
sentinel.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-03-11 17:13:39 +02:00
Corey Wharton ccd15df510 scripts: Dynamically add driver subsystems to subsystems list
This change extends the parse_syscalls.py script to scan for a
__subsystem sentinal added to driver api declarations. It thens
generates a list that is passed into gen_kobject_list.py to extend
the subsystems list. This allows subsystems to be declared in the
code instead of a separate python list and provides a mechanism for
defining out-of-tree subsystems.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-03-11 17:13:39 +02:00
Carlo Caione b4335a04ac arm: aarch64: Reintroduce _ASM_FILE_PROLOGUE
This is currently missing from the AArch64 assembly files.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-03-11 09:34:24 +01:00
Stephanos Ioannidis 0bd86f3604 arch: arm: aarch32: Allow selecting compiler instruction set
This commit introduces the `COMPILER_ISA_THUMB2` symbol to allow
choosing either the ARM or Thumb instruction set for C code
compilation.

In addition, this commit introduces the `ASSEMBLER_ISA_THUMB2` helper
symbol to specify the default target instruction set for the assembler.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-10 17:51:32 +01:00
Daniel Bujak 92a31f1a40 drivers: sensor: Add support for free-fall triggering to sensor api
Add an entry in the sensor_trigger_type enum for triggering an
event on free-fall

Signed-off-by: Daniel Bujak <danb@swiftlabs.com>
2020-03-10 18:31:38 +02:00
Andrew Boie 9f0acd44a4 kernel: add APIs for atomic os on pointers
The existing APIs are insufficient on 64-bit systems as atomic_t
is 32-bits wide.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-10 10:18:16 -04:00
Andrew Boie 60e0019751 kernel: fix return type for atomic_cas()
In some cases this was a bool, in some cases an integer value
of 1 or 0. Standardize on bool.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-10 10:18:16 -04:00
Andrew Boie 831f6d5051 shell: use correct data type for atomic variables
The variable needs to be an atomic_t, and in one case it was
being incremented outside of an atomic_inc/atomic_add.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-10 10:18:16 -04:00
Nicholas Lowell 17b19eb810 pthread: add setname/getname glibc extensions
Adding the ability to set and get pthread names by defining
some non-standard extension functions that were first
introduced by Glibc.

Similar to zephyr thread naming, these allow for thread
tracking and debugging even when using the more portable
posix API.

Though Glibc was the originator, the current POSIX functions
have return codes based on Oracle's adopted spec, so these
functions follow suit.  The Oracle and Glibc function
prototypes match.

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2020-03-10 15:15:34 +02:00
Håkon Øye Amundsen 64d8e65f33 DFU: add init function with area id as parameter
This allows flash_img.c to be used outside of mcuboot scope.
Add new call to not break existing code.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-03-10 15:07:27 +02:00
Paul Sokolovsky 347f6784fb include: posix: time: Make possible to include with CONFIG_ARCH_POSIX
While CONFIG_ARCH_POSIX in general isn't compatible with Zephyr POSIX
subsys (because CONFIG_ARCH_POSIX itself is implemented on top of
POSIX, so there're obvious conflicts), apply workaround to allow to
at least use clock_gettime() and clock_settime() functions.

This change is grounded in upcoming support for date manipulation
commands for Zephyr shell, which are implemented using functions
above. There's no guarantee that CONFIG_ARCH_POSIX and Zephyr POSIX
subsys will coexist for any other usecase. (But the change is
relatively clean and is definitely in the right direction of
prototyping ways of such a coexistance.)

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
(cherry picked from commit 4a05644bce81f4792c018964d29c1158f1982d1e)
2020-03-10 15:04:12 +02:00
Joakim Andersson 681dfdc12b Bluetooth: HCI_VS: Check for supported command
According to the Zephyr VS HCI specification:
Only Read_Version_Information and Read_Supported_Commands commands are
mandatory.

Check for supported Read Supported Features command before issuing this
command to the controller.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-10 15:02:48 +02:00
Marek Porwisz 5c57f382de net: ieee802154: Extend radio api to support energy scan feature
Add the Energy Scan capability to the possible capabilities list.
Create new energy scan callback function type to make its usage
more readable.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2020-03-10 14:59:10 +02:00
Robert Lubos d2e7a7d0c7 net: lwm2m: Notify when it's safe to turn RX off
According to LWM2M specification, when Queue Mode is used, the LWM2M
client should keep the reciever on for specified time after sending A
CoAP message. This commit adds a new LWM2M event,
`LWM2M_RD_CLIENT_EVENT_QUEUE_MODE_RX_OFF`, to facilitate the process by
notifying the application when it's safe to turn the receiver off.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-03-10 14:57:29 +02:00
Göran Weinholt 091f630014 net: ppp: ipcp: negotiate DNS servers and optionally use them
We now negotiate DNS servers in the IPCP configuration. This has been
observed to speed up the connection setup. The received DNS servers
are used by the DNS resolver library, but we leave it optional since
the static server list might be preferable.

Increase MAX_IPCP_OPTIONS to 4 so that we can nack all RFC 1877
options.

Signed-off-by: Göran Weinholt <goran.weinholt@endian.se>
2020-03-10 14:09:10 +02:00
Jukka Rissanen 9d4fbb2912 crc: Add crc8 implementation and tests
Add crc8 implementation and unit tests for it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-03-10 12:53:53 +02:00
Wayne Ren 85f591e866 arch: arc: enable MPU_REQUIRES_NON_OVERLAPPING_REGIONS for arc mpu ver 3
arc mpu ver3 does not allow mpu region overlap, so need to enable
MPU_REQUIRES_NON_OVERLAPPING_REGIONS.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2020-03-10 11:58:03 +02:00
Flavio Ceolin 4b2fc256cf sys: usermode: Document 0 size buffer memory check
Documenting that 0 size buffer has undefined behavior.
See: https://github.com/zephyrproject-rtos/zephyr/pull/23239

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-07 13:12:51 +02:00
Alexey Eremin 6f3f3c230c Bluetooth: Make macro definition compatible with 7-2018-q2-update g++
In C++ designated initializers require that designators used in the
expression must appear in the same order as the data members.

In addition, 7-2018-q2-update version of g++ doesn't support
implicit member initialization, so all members must be
initialized.

Signed-off-by: Alexey Eremin <a.eremin.msu@gmail.com>
2020-03-06 11:27:46 +02:00
Alexander Wachter 75724bf299 doc: hwinfo: Clarify return values.
Change the doxygen doc from "negative on error" to -ENOSUP and
negative value on driver specific errors.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-02-27 21:14:54 +01:00
Gerard Marull-Paretas 6d003af827 lib/timeutil: add missing header required for s64_t
sys/timeutil.h could not be used without including first
<zephyr/types.h> because s64_t type definition was missing.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-02-27 11:35:43 +02:00
Joakim Andersson 1db7a11c3f Bluetooth: host: Document bt_conn_unref responsibility of caller
Document the need for the caller to call  bt_conn_unref on the
connection object returned from API functions.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-25 14:12:04 +02:00
Abhishek Shah f587c5f019 arch: arm64: mmu: Add zephyr execution regions
Add zephyr execution regions(text, rodata, data, noinit, bss, etc.)
with proper attributes to translation tables.
Linker script has been modified a little to align these sections to
minimum translation granule(4 kB).

With this in place, code cannot be overwritten accidently as it is
marked read only. Similarly, execution is prohibited from data/RW
section as it is marked execute-never.

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-02-20 17:24:59 +02:00
Abhishek Shah 10a05a162f arch: arm64: Add MMU support
Add MMU support for ARMv8A. We support 4kB translation granule.
Regions to be mapped with specific attributes are required to be
at least 4kB aligned and can be provided through platform file(soc.c).

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-02-20 17:24:59 +02:00
Abhishek Shah 6429dd81bf arch: arm: aarch64: linker.ld: move vector table to text segment
Following changes are done:
- The vector table should be placed in text segment.
- Removed Vector relay table related entries as it is
  only applicable to aarch32.
- irq_vector_table contains ISR pointers - should be placed
  in rodata segment.
- put openocd_dbg in rodata and skip adding <linker_relocate.ld>
  as CONFIG_CODE_DATA_RELOCATION is not defined for aarch64
  currently (add later if needed).

Fixes: #22673
Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-02-20 17:24:59 +02:00
Abhishek Shah 1d59d3afed arch: arm: aarch64: linker: Discard plt and got sections
plt and got sections are used for dynamic linking which
is not supported in Zephyr.

Reference: #11953
commit 3ba7097e73 ("linker: add orphan sections to linker script")

Signed-off-by: Abhishek Shah <abhishek.shah@broadcom.com>
2020-02-20 17:24:59 +02:00
Andrew Boie 9062a5ee91 revert: "program local APIC LDR register for..."
This reverts commit 87b65c5ac2.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-19 14:40:19 -08:00
Ioannis Glaropoulos 4223b71b77 arch: aarch32: define macro for PendSV IRQ priority level
We introduce a macro to define the IRQ priority level for
PendsV, and use it in arch/arm/include/aarch32/exc.h
to set the PendSV IRQ level. The commit does not change
the behavior of PendSV interrupt.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos f9d9b7642e arch: aarch32: document exception priority scheme for 32-bit ARM
This commit adds some documentation for the exception
priority scheme for 32-bit ARM architecture variants.
In addition we document that SVCall priority level for
ARMv6-M is implicitly set to highest (by leaving it as
default).

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Ioannis Glaropoulos 14237335e0 arch: arm: update file header info for arm/aarch32/exc.h
Public arm/aarch32/exc.h header file is used by both
Cortex-M and Cortex-R; we update the header information
accordingly.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-02-19 12:19:43 -08:00
Zide Chen 87b65c5ac2 interrupt_controller: program local APIC LDR register for xAPIC
If IO APIC is in logical destination mode, local APICs compare their
logical APIC ID defined in LDR (Logical Destination Register) with
the destination code sent with the interrupt to determine whether or not
to accept the incoming interrupt.

This patch programs LDR in xAPIC mode to support IO APIC logical mode.

The local APIC ID from local APIC ID register can't be used as the
'logical APIC ID' because LAPIC ID may not be consecutive numbers hence
it makes it impossible for LDR to encode 8 IDs within 8 bits.

This patch chooses 0 for BSP, and for APs, cpu_number which is the index
to x86_cpuboot[], which ultimately assigned in z_smp_init[].

Signed-off-by: Zide Chen <zide.chen@intel.com>
2020-02-19 10:25:10 -08:00
Joakim Andersson ee3f634cf7 Bluetooth: GATT: Document settings_load and service register requirement
Document that all services that should be included in the initial
database hash should be registered before calling settings load. All
services added after settings_load will trigger a new hash calculation
and a new value stored. This would result in the database hash always
being rewritten.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-18 13:55:33 +02:00
Andrzej Puzdrowski ead335cb40 settings: Include entire API into doxygen
The Runtime API and the name processing API were omitted in
the documentation as were not included in any doxygen group.

This patch includes them in dedicated settings API doxygen
sub-groups.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-02-17 15:34:33 -06:00
Luiz Augusto von Dentz 038d727c18 kernel: work: Return error if timeout cannot be aborted
This is aligned with the documentation which states that an error shall
be returned if the work has been completed:

  '-EINVAL Work item is being processed or has completed its work.'

Though in order to be able to resubmit from the handler itself it needs
to be able to distinct when the work is already completed so instead of
-EINVAL it return -EALREADY when the work is considered to be completed.

Fixes #22803

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-02-17 22:37:26 +02:00
Stephanos Ioannidis 0e3bc28633 arch: arm: cortex_r: linker.ld: Fix ROM section names
This commit fixes the improper naming of the ROM sections.

1. Rename the first ROM section, which was previously named using the
  `_TEXT_SECTION_NAME` definition, to `rom_start`, as this section does
  not actually represent the text section.

2. Rename the second ROM section, which was previously named
  `_TEXT_SECTION_NAME_2` which supposedly refers to the definition of
  the same name that does not exist, to `_TEXT_SECTION_NAME`. Note that
  this is indeed the section that contains the text section from the
  source image.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-14 17:50:47 +01:00
Stephanos Ioannidis f053f1b25d arch: arm: cortex_r: linker.ld: Clean-up
This commit cleans up the linker.ld file for the Cortex-R arch.

* Convert all TAB characters to SPACE.
* Fix insane placement of curly brackets.
* Fix overall text alignments.
* Remove the special handlings for the Cortex-M devices that were
  copied from `include/arm/aarch32/cortex_m/scripts/linker.ld`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-14 17:50:47 +01:00
Peter Bigot fe266f9d2c gpio: restore missing legacy devicetree direction flag
GPIO_DIR_OUT is deprecated but allowed in devicetree bindings because
some in-tree bindings provided it in the past.  GPIO_DIR_IN was the
former explicit way of representing the default direction.  Put it
back so symmetry is maintained.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-13 22:50:45 +02:00
Andrew Boie f1b1332c94 x86: fix large Kconfig values on 64-bit
Use the special x86 operand modifier 'p' to print the raw value.
This fixes an issue on x86-64 where errors were generated
if a constant larger than INT_MAX was used.

Values larger than UINT_MAX are still unsupported (on any arch).

Fixes: #22542

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-13 09:03:03 +02:00
Stephanos Ioannidis f2e2b66215 arch: arm: aarch64: Fix _vector_end symbol placement
This commit relocates the `_vector_end` symbol that was previously
placed after the OpenOCD sections to before these sections, as the
OpenOCD debug sections are not part of the "vector table."

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-12 15:51:58 +01:00
Stephanos Ioannidis c4cb84140f arch: arm: aarch64: linker.ld: Fix ROM section names
This commit fixes the improper naming of the ROM sections.

1. Rename the first ROM section, which was previously named using the
  `_TEXT_SECTION_NAME` definition, to `rom_start`, as this section does
  not actually represent the text section.

2. Rename the second ROM section, which was previously named
  `_TEXT_SECTION_NAME_2` which supposedly refers to the definition of
  the same name that does not exist, to `_TEXT_SECTION_NAME`. Note that
  this is indeed the section that contains the text section from the
  source image.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-12 15:51:58 +01:00
Stephanos Ioannidis e619e36b1b arch: arm: aarch64: linker.ld: Clean-up
This commit cleans-up the linker.ld file for the AArch64 arch.

* Convert all TAB characters to SPACE.
* Fix insane placement of curly brackets.
* Fix overall text alignments.
* Remove the special handlings for the Cortex-M devices that were
  copied from `include/arm/aarch32/cortex_m/scripts/linker.ld`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-12 15:51:58 +01:00
Robert Lubos 4f9b9a4500 shell: telnet: Replace timer with a delayed work
A `k_timer` callback is called from the ISR context on certain devices
(nRF), which resulted in an assert in the kernel, as `telnet_send`, and
thus `net_context_send` used a mutex.

Fix the issue by replacing a timer used by the `shell_telnet` module
with a delayed work, which will execute it's callback in a system
workqueue context.

Fixes #22697

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-02-12 10:22:49 +02:00
Joakim Andersson 08a39851dc Bluetooth: host: Rename scan recv callback info struct
Rename the scan recv callback info struct so that it reflects that it
is part of the scan recv callback. This will make it consistent with
future plans for advertising callbacks.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-11 23:57:27 +02:00
Joakim Andersson 4702df0cec Bluetooth: HCI: Fix size of evt_type parameter
Fix the size of the evt_type, this lead to error over serialized HCI
where the event could not be interpreted correctly from the HCI
controller.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-11 23:56:47 +02:00
Krzysztof Chruscinski 547d623c37 debug: stack: Add missing log_strdup
Log call was missing log_strdup wrap around thread name which
is a string in RAM.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-02-11 12:55:02 -08:00
Glenn Engel ebcb6a5e71 logging: Fixes c++ compile error using LOG_BACKEND_DEFINE
Ordered struct init properties to match declaration order.  Compiled
and ran on qemu emulator.

Fixes #22482

Signed-off-by: Glenn Engel <glenne@engel.org>
2020-02-11 20:11:12 +02:00
Stephanos Ioannidis bea3ee0ed0 arch: arm: Fix incorrect Cortex-R interrupt state control logic.
This commit fixes incorrect Cortex-R interrupt lock, unlock and state
check function implementations.

The issues can be summarised as follows:

1. The current implementation of 'z_arch_irq_lock' returns the value
  of CPSR as the IRQ key and, since CPSR contains many other state
  bits, this caused 'z_arch_irq_unlocked' to return false even when
  IRQ is unlocked. This problem is fixed by isolating only the I-bit
  of CPSR and returning this value as the IRQ key, such that it
  returns a non-zero value when interrupt is disabled.

2. The current implementation of 'z_arch_irq_unlock' directly updates
  the value of CPSR control field with the IRQ key and this can cause
  other state bits in CPSR to be corrupted. This problem is fixed by
  conditionally enabling interrupt using CPSIE instruction when the
  value of IRQ key is a zero.

3. The current implementation of 'z_arch_is_in_isr' checks the value
  of CPSR MODE field and returns true if its value is IRQ or FIQ.
  While this does not normally cause an issue, the function can return
  false when IRQ offloading is used because the offload function
  executes in SVC mode. This problem is fixed by adding check for SVC
  mode.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-11 08:03:37 -08:00
Nicholas Lowell e4e9b9d8d7 posix: fix unistd.h extern C brace mismatch
If unistd.h is included while CONFIG_POSIX_API is not
defined, there is a mismatch of extern C braces that will
cause compile errors

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2020-02-11 17:50:21 +02:00
Stephanos Ioannidis 71362ddf5d arch: arm: aarch64: linker.ld: Remove redundant text section offset
This commit removes the redundant text section offset specification in
the AArch64 linker script.

The text section offset is already specified by the
`text_section_offset.ld`, which is included by
`arch/common/CMakeLists.txt`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-02-10 20:04:21 +01:00
Andrew Boie 768a30c14f x86: organize 64-bit ESF
The callee-saved registers have been separated out and will not
be saved/restored if exception debugging is shut off.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-08 08:51:43 -05:00
Andy Ross 7353c7f95d kernel/userspace: Move syscall_frame field to thread struct
The syscall exception frame was stored on the CPU struct during
syscall execution, but that's not right.  System calls might "feel
like" exceptions, but they're actually perfectly normal kernel mode
code and can be preempted and migrated between CPUs at any time.

Put the field on the thread struct.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-02-08 08:51:04 -05:00
Andy Ross eefd3daa81 kernel/smp: arch/x86_64: Address race with CPU migration
Use of the _current_cpu pointer cannot be done safely in a preemptible
context.  If a thread is preempted and migrates to another CPU, the
old CPU record will be wrong.

Add a validation assert to the expression that catches incorrect
usages, and fix up the spots where it was wrong (most important being
a few uses of _current outside of locks, and the arch_is_in_isr()
implementation).

Note that the resulting _current expression now requires locking and
is going to be somewhat slower.  Longer term it's going to be better
to augment the arch API to allow SMP architectures to implement a
faster "get current thread pointer" action than this default.

Note also that this change means that "_current" is no longer
expressible as an lvalue (long ago, it was just a static variable), so
the places where it gets assigned now assign to _current_cpu->current
instead.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-02-08 08:51:04 -05:00
Markus Fuchs e1948ae3a1 include: crypto: Add Galois/Counter Mode (GCM) support
Add support for AES Galois/Counter Mode of Operation to the Crypto API.

Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
2020-02-08 13:40:33 +02:00
Nicholas Lowell b096fcc476 pthread: wrap header with extern C
Other posix headers were already wrapped, this one seems
to have been missed so it can be compiled with C++

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2020-02-08 10:21:01 +02:00
Andrew Boie efc5fe07a2 kernel: overhaul unused stack measurement
The existing stack_analyze APIs had some problems:

1. Not properly namespaced
2. Accepted the stack object as a parameter, yet the stack object
   does not contain the necessary information to get the associated
   buffer region, the thread object is needed for this
3. Caused a crash on certain platforms that do not allow inspection
   of unused stack space for the currently running thread
4. No user mode access
5. Separately passed in thread name

We deprecate these functions and add a new API
k_thread_stack_space_get() which addresses all of these issues.

A helper API log_stack_usage() also added which resembles
STACK_ANALYZE() in functionality.

Fixes: #17852

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-08 10:02:35 +02:00
Zide Chen c698669f4e arch/x86_64: make sysapic.h available for x86_64 as well
sysapic.h is needed for x86_64 if CONFIG_LOAPIC is defined.

Signed-off-by: Zide Chen <zide.chen@intel.com>
2020-02-07 14:14:53 -08:00
Anas Nashif 73008b427c tracing: move headers under include/tracing
Move tracing.h to include/tracing/ to align with subsystem reorg.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-07 15:58:05 -05:00
Johan Hedberg 578dbe1c0a Bluetooth: Mesh: Support reliable sending when publishing
Until now the choice of reliable sending (segmented messages with
acks) was implicitly dependent on the size of the payload. Add a new
member to the bt_mesh_model_pub to force using segment acks even when
the payload would fit a single unsegmented message.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-02-07 20:42:15 +02:00
Andrew Boie d1f50122f9 kernel: move timing externs to public header
These arch_timing_ defines get used in certain timer
drivers and need to be in the public include space,
and not the private kernel headers.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-06 23:07:37 -05:00
Alexander Wachter 55baaf0365 can: isotp: Add ISO-TP library
This commit adds a ISO-TP (ISO15765-2) library.
The library makes use of net buffers and spawns a workqueue thread.
The CAN device that is passed to bind and send can be used concurrently
beside this library.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2020-02-06 10:16:29 +02:00
Wentong Wu 4f4b8ef4ea tracing: add TRACING_TEST Kconfig option
Add Kconfig option TRACING_TEST which can be used to
customize tracing packet format (currently supporting
string format and data format) for testing purpose.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-02-05 23:54:26 -05:00
Wentong Wu 8ccc04de6a tracing: add infrastructure for collection of tracing data
First, this commit adds user interface in tracing_format.h which
can trace both string format and data format packet.

Second, it adds method both for asynchronous and synchronous way.
For asynchronous method, tracing packet will be buffered in tracing
buffer first, tracing thread will output the stream data with the
help of tracing backend when tracing thread get scheduled.

Third, it adds UART and USB tracing backend for asynchronous
tracing method, and adds POSIX tracing backend for synchronous
tracing way.

Also it can receive command from host to dynamically enable and
disable tracing to have host capture tracing data conveniently.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-02-05 23:54:26 -05:00
Peter Bigot 1977ac3ce2 lib: os: onoff: documentation clarifications
Note that the client structure must be reinitialized before each use,
and make more clear that its internal fields are not part of the
public API.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 13:48:31 -05:00
Tobias Svehagen 46a95f12ad Bluetooth: Mesh: Add database for managing nodes and keys
Refactor the handling of network nodes and their keys into a separate
Mesh Configuration Database (CDB). This, not only creates a separation
of the local node and the other nodes, but also makes it possible to
implement functions to manage the whole, or at least parts of the mesh
network.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2020-02-05 18:47:41 +02:00
Krzysztof Chruscinski ce766305b7 drivers: clock_control: Add subsys argument to the callback
Added subsys argument to the callback, updated one driver which
used it and test cases.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-02-05 17:07:01 +01:00
Johan Hedberg 8183a7fd29 arch: xtensa: Add support for Intel Apollolake
Add the necessary architecture changes for Intel Apollolake.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-02-05 10:43:25 -05:00
Peter Bigot 7c95d503b0 gpio: clean up internal API function prototypes
Use gpio_pin_t uniformly when passing pin indexes to the driver.  Use
gpio_flags_t uniformly when passing flags to the driver.  Change name
of pin configuration function in API function table to be consistent
with other API functions.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 37239dbcbf gpio: rename typedef for devicetree flags
gpio_dt_flags_t is shorter and consistent with DT_ prefix.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot f017209821 gpio: use reduced-size role typedef for public API pin indexes
There is a typedef used to store pin indexes in configuration
structures.  For consistency it should also be used to identify pin
indexes in function prototypes.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot c7d526be04 gpio: remove port access op support
The only remaining port operations have dedicated API function table
entries.  Remove the defines for access op (mode), and remove support
for access op from all implementations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 1f9beb193f gpio: remove legacy read/write API functions
The last external reference to these was removed when the pin
write/read functions were deprecated.  Remove the syscall support, API
function table entries, and implementation from all drivers.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 1947481cce gpio: deprecate gpio pin callback enable and disable API
These have been replaced by the appropriate call to
gpio_pin_interrupt_configure().  While the disable function could be
implemented using the new functionality, the enable function cannot
because the interrupt mode is not available.  Consequently we cannot
replace these with equivalent functionality using the legacy API.

Clean up the internal implementation by removing the inaccessible
port-based enable/disable feature, leaving the pin-based capability in
place.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 09af4ba1ab gpio: mark deprecated flag macros
Mark the outdated flag macros as deprecated so they can be fixed.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 2befa6a251 gpio: deprecate legacy gpio pin read/write functions
These have been replaced by get/set functions in both raw and
active-sensitive variants.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Tomasz Bursztyka 62b2cae2ae drivers/ieee802154: Adapt cc1200 driver to new GPIO API
Update to use new API for GPIO pin configuration and operation.  Fix
invalid arithmetic on void pointer.  Convert to support devicetree.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Tomasz Bursztyka 3587fe2fe3 drivers/ieee802154: Adapt cc2520 driver to new GPIO API
Update to use new API for GPIO pin configuration and operation.  Fix
invalid arithmetic on void pointer.  Mark all CC2520 GPIOs as required
in binding.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Tomasz Bursztyka a40e9d3762 drivers/wifi: Switch WINC1500 to new GPIO API
Use new API to configure and interact with GPIOs.  Move GPIO
initialization from sample into driver.  The existing physical/line
level control has been kept rather than converting to logical level
signals.

Also improve error messages.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 558a585805 gpio: do not deprecate internal direction mask
Existing drivers still use this; move it above the deprecated macro
region.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot d85a9e30d1 gpio: remove unused internal API
Remove macros and a state structure that are not used anywhere and
incompletely describe a GPIO pin specifier.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot d3281f5b6f gpio: clean up API documentation
Use more standard Doxygen styling.  Add clarification to
recommendations and expectations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Henrik Brix Andersen 82ecb89dae drivers: gpio: lmp90xxx: update to use new GPIO API
Update the TI LMP90xxx GPIO driver to the new GPIO API.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-02-05 12:00:36 +01:00
Peter Bigot d68807a391 drivers: gpio_mmio32: add support for pin validation
Add the common config structure as a prefix of the driver-specific
config structure and use the mask parameter to initialize it.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 9022d33fec drivers: gpio: add support for device-specific pin validation
Extend the driver data structure with a field that identifies the pins
supported by the device.  Document the fields and who is responsible
for maintaining them.

Update all configuration functions for specific pins to return an
error if the pin is not supported.

Update all set/get functions for specific pins to assert if the pin is
not supported.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 9d41d53927 drivers: gpio: fix const qualifier on driver data pointers
Several declarations provided a const pointer to mutable data.  Change
all declarations that are not used to change the invert field to be
pointers to const data.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 2016cc64aa drivers: gpio: provide typedefs for flags and devicetree properties
The public API for GPIO flags should use unsigned values, and for
MISRA compliance the size should not be platform-dependent.  Add a
typedef for generic flags.

Also add typedefs for pin indexes and devicetree flags so these can
be safely recorded from devicetree property values without risking
loss of information if more flags are added in the future.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 52aa8edbd0 gpio: support logic-level output at initialization
Extend the physical level GPIO_OUTPUT_{HIGH,LOW} configuration with
GPIO_OUTPUT_{ACTIVE,INACTIVE} for logic level initialization.

This enables use of device-tree configuration flags in calls to
gpio_pin_configure() to set the logic level without having to
determine the corresponding physical level.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 2b150bff4f gpio: avoid disabling interrupts when supporting legacy code
gpio_pin_interrupt_configure() is invoked from within
gpio_pin_configure() to support legacy code that combines pin and
interrupt configuration.  Expressing a disabled interrupt by a zero
value for interrupt flags causes this invocation to disable interrupts
when the intent is to change only a pin configuration, such as pull
direction.

Support a distinction between explicitly disabling interrupts and
leaving the interrupt configuration unchanged.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 33cf10b5b8 gpio: unify assert checks for pin and interrupt configuration
gpio_pin_interrupt_configure() verified that the pin was within range,
while gpio_pin_configure() did not.  Make them consistent since they
take the same set of flags.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Kumar Gala 8f4da10356 drivers: mmio32: update to use new GPIO API
As the mmio32 is more of a library than a proper driver, just implement
the new port functions and have pin_interrupt_configure marked pretty
much as not supported.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 12:00:36 +01:00
Peter Bigot 30d0818179 drivers/gpio: use more clear expression for GPIO direction mask
Define the mask in terms of the individual non-zero fields to isolate
from future changes to the bit position.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 0db954a8a8 tests: gpio_basic_api: fix misplacement of debounce flag
The debounce flag is to be provided to the pin configuration, not the
pin interrupt configuration.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski 4fcb88cb51 gpio: add new asserts verifying flag configurations
The asserts verify that:
- Output needs to be enabled for 'Open Drain', 'Open Source' mode to be
  supported.
- GPIO_LINE_OPEN_DRAIN flag can be enabled only if GPIO_SINGLE_ENDED is
  enabled.
- Only one of GPIO_INT_LOW_0, GPIO_INT_HIGH_1 can be enabled for a level
  interrupt.
- GPIO_INT_DEBOUNCE is not passed to gpio_pin_interrupt_configure
  function.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Erwan Gouriou 78d7b2106a drivers/interrup_controller: stm32: stm32_exti_enable could be void
stm32_exti_enable was returning errors on line > 32 or line pointing
to non implemented line. Both conditions are hard-coded, hence there
is no use to detect them dynamically in the code.
Check them with assert. As a consequence, function could now be void.

Additionally, enable exti irq line only if both checks are passed.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Erwan Gouriou 29e9780ad1 drivers/interrupt_controller: stm32: Clean set api from unused arg
Argument 'port' in stm32_exti_set_callback function is not
used, remove it.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Erwan Gouriou e88cdffcd6 drivers/gpio: stm32: exti: Clear triggers when not requested
Since it is now possible to disable/re-enable interrupts and
also to reconfigure an already configured interrupt, it is
now required to clear non requested triggers.
While it is not strictly requested, triggers are also cleared
when interrupt is disabled (assuming trigger should be configured
when interrupt is enabled).

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>

fixup exti
2020-02-05 12:00:36 +01:00
Peter Bigot fca26890b0 drivers/gpio: document that unsupported DEBOUNCE should be ignored
A large number of sensor drivers specify GPIO_INT_DEBOUNCE to request
a debounced signal; in practice the debounce may be performed by
external components on the board.  Historically this flag was ignored
on the many GPIO peripherals that do not support hardware debouncing.

Document that this flag is an exception to the normal rule that
unsupported features should be rejected by gpio_pin_configure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 9e8947fe3e drivers: gpio: add named flag set for disconnected GPIO
A disconnected GPIO is one that is neither an input nor an output.
This is represented by a zero-valued all-default configuration.  Call
this configuration GPIO_DISCONNECTED so the intent is clear.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 060daac089 gpio: add error return when blocking might occur
External GPIO drivers may not be supported from interrupt context
because they involve blocking bus transactions.  Describe the return
value for this situation, and add the I/O error to operations where it
was missing.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 53178c36bd gpio: put back deprecation comments
The comments identifying replacement API were inadvertently removed
along with the flag that triggers deprecation warnings.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Kumar Gala cb9c3efaad drivers: gpio_mmio32: Add gpio_driver_data to driver data
Add gpio_driver_data as the first element in the driver data as the gpio
core expects this.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 12:00:36 +01:00
Kumar Gala b535881f0c gpio: Handle logical conversion in gpio api layer
Move handling of logical flag support into gpio_pin_configure and
gpio_pin_interrupt_configure.  This way drivers don't need to know
anything about logical levels.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Kumar Gala 84b27a1525 gpio: Reorder code in drivers/gpio.h
Move z_impl_gpio_pin_interrupt_configure before gpio_pin_configure so we
can utilize z_impl_gpio_pin_interrupt_configure in gpio_pin_configure in
the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 12:00:36 +01:00
Peter Bigot 48b674b570 gpio: use named types to distinguish pin sets from pin values
Both pin sets and values encoding pin values are ultimately represented
by 32-bit unsigned integers. Provide typedefs that make the role of a
parameter explicit.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski 33193a57eb gpio: add gpio_pin_interrupt_configure function
This commit moves interrupt configuration for a single pin from
gpio_pin_configure to gpio_pin_interrupt_configure function.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski d6191b5781 gpio: add new functions to set/get pin/port values
This commit adds following functions which work with pin logical levels
(take into account GPIO_ACTIVE_LOW flag):
- gpio_port_get, gpio_port_set_masked, gpio_port_set_bits,
  gpio_port_clear_bits, gpio_port_set_clr_bits
- gpio_pin_get, gpio_pin_set
Functions which work with pin physical levels:
- gpio_port_get_raw, gpio_port_set_masked_raw, gpio_port_set_bits_raw,
  gpio_port_clear_bits_raw, gpio_port_set_clr_bits_raw
- gpio_pin_get_raw, gpio_pin_set_raw
As well as functions:
- gpio_port_toggle_bits, gpio_pin_toggle_bits

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski af972c2c47 api: gpio: Align GPIO dt-bindings flags with Linux DTS
This commit makes following changes to GPIO dt-bindings flags:
- Added GPIO_ACTIVE_LOW, GPIO_ACTIVE_HIGH to indicate pin active state.
- Added GPIO_OPEN_DRAIN, GPIO_OPEN_SOURCE to configure single ended pin
  driving mode.
- Added GPIO_PULL_UP, GPIO_PULL_DOWN flags.
- GPIO_INPUT, GPIO_OUTPUT to configure pin as input or output.
- Added GPIO_OUTPUT_LOW, GPIO_OUTPUT_HIGH flags to initialize output
  in low or high state.
- reworked GPIO_INT_* flags to configure pin interrupts.
- following flags were deprecated: GPIO_DIR_*, GPIO_DS_DISCONNECT_*,
  GPIO_PUD_*, GPIO_INT_ACTIVE_*, GPIO_INT_DOUBLE_EDGE, GPIO_POL_*.

To be aligned with Linux DTS standard any GPIO flags that should not be
used in DTS files are moved from include/dt-bindings/gpio/gpio.h file to
include/drivers/gpio.h with an exception of several old flags which
removal would cause DTS compilation errors. Those remaining old flags
will be removed from include/dt-bindings/gpio/gpio.h at a later stage.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Vinayak Kariappa Chettimada ca0e8595d9 Bluetooth: host: Added new LE Feature Support bit masks
Added new LE Feature Support bit mask as documented in
Bluetooth Spec. v5.2 Vol 6, Part B, Section 4.6 Feature
Support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-05 12:29:39 +02:00
Vinayak Kariappa Chettimada 3e8b4918f3 Bluetooth: Add HCI Error codes defined in BT 5.2 Spec.
Add missing and new HCI Error code values as defined in
Bluetooth Core Specification v5.2.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-02-05 09:11:57 +02:00
Peter A. Bigot 4420c5ed40 adc: provide API to help with conversions
Gain values are specified with enumeration values that can't be used
to reverse the effects of scaling the input signal.  Provide a
function that reverses the effect of the gain by scaling a measured
value.

Also provide a function that converts a raw measurement captured with
a reference voltage and specific gain and resolution to the
corresponding voltage in millivolts.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-02-03 16:26:51 +01:00
Joakim Andersson 499b4e0ce0 Bluetooth: host: Document privacy-disabled directed advertising reports
Document why a privacy-disabled scanner will not notify about directed
advertising reports. This is the default behaviour of the
privacy-disabled scanner. In order to receive the reports the option
BT_SCAN_WITH_IDENTITY must be enabled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-02-03 12:44:39 +02:00
Marcin Niestroj 21409494d1 power: device: deduplicate suspending code
Function to put devices in lower power mode were all implemented in the
same way. Deduplicate code there by implementing single function to
handle all cases.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-02-02 09:05:15 -05:00
Maureen Helm 5a330f9b36 drivers: kscan: Extend callback arguments to 32-bits
Extends the keyboard scan callback row and column arguments from 8-bits
to 32-bits to support a touch panel driver implementation.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-02-01 08:50:16 -05:00
Ulf Magnusson 46f98d86c7 include: gcc.h: Add a __WARN() macro with a custom warning on expansion
Works like __DEPRECATED_MACRO with a custom message. Can do this for
example:

    #define FOO __WARN("Please use BAR instead") ...

Implement __DEPRECATED_MACRO with __WARN().

Useful for https://github.com/zephyrproject-rtos/zephyr/pull/21506.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-01 08:48:17 -05:00
Krzysztof Chruscinski 279e5b45b8 shell: Fix SHELL_COND_CMD_ARG_REGISTER macro with NULL handler
Macro was failing when handler was NULL and else case was
hit because of attempt to concatenate with handler which was
set to NULL (which is ((void *)0)).

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-02-01 08:10:06 -05:00
Carlo Caione 3aef85458d arch: arm64: Dump registers content on fatal error
Extend the ESF structure and dump the most important registers in the
error exception handler.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Carlo Caione 87d8a035dd arch: arm64: Support aarch64-gcc compiler
To be able to successfully compile the kernel for the ARM64 architecture
we have to tweak the compiler-related files to be able to use the
AArch64 GCC compiler.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Carlo Caione 1be0c05311 arch: arm64: Introduce ARM64 (AArch64) architecture
Introduce the basic ARM64 architecture support.

A new CONFIG_ARM64 symbol is introduced for the new architecture and new
cmake / Kconfig files are added to switch between ARM and ARM64.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Carlo Caione 6f36300219 drivers: timer: Add per-core ARM architected timer
ARM cores may have a per-core architected timer, which provides per-cpu
timers, attached to a GIC to deliver its per-processor interrupts via
PPIs. This is the most common case supported by QEMU in the virt
platform.

This patch introduces support for this timer abstracting the way the
timer registers are actually accessed. This is needed because different
architectures (for example ARMv7-R vs ARMv8-A) use different registers
and even the same architecture (ARMv8-A) can actually use different
timers (ELx physical timers vs ELx virtual timers).

So we introduce the common driver here but the actual SoC / architecture
/ board must provide the three helpers (arm_arch_timer_set_compare(),
arm_arch_timer_toggle(), arm_arch_timer_count()) using an header file
imported through the arch/cpu.h header file.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Nicholas Lowell 797174350d debug: tracing: Remove unneeded prototypes
The initial prototypes for sys_trace_* are not needed
because they are either declared in the specified tracing header
or as empty #defines further in the header.

These actually cause linkage conflicts if CTF tracing is attempted
with C++ projects.

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2020-02-01 08:06:28 -05:00
Peter Bigot bfa3eb17b2 toolchain: gcc: respect existing deprecated macro define
The __deprecated symbol can be pre-defined to avoid warnings of use of
deprecated API in tests of that API.  Enable that same feature for
macros that are deprecated.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-31 12:32:50 -08:00
Martin Rieva 2685a94c02 Bluetooth: Host: Add generic pairing query callback
Similar to pairing_confirm this callback is called each
time a peer requests pairing, but for all types of
pairings, except SSP. The pairing req/rsp information is
passed as a parameter so the application can decide
wheter to accept or reject the pairing.

Fixes: #21036

Signed-off-by: Martin Rieva <mrrv@demant.com>
2020-01-31 20:39:25 +02:00
Robert Lubos 7fcd32b005 net: sockets: Fix gethostname socket.h/unistd.h clash
This commit fixes an issue observed with SimpleLink sockets with
multiple definitions of `gethostname` function. So far, the definition
within `socket.h` was not visible when offloading was enabled.

As this is no longer the case, and SimpleLink partially uses POSIX
subsystem, builds for this platform resulted in compilation error.

The issue was fixed by moving `gethostname` declaration in unistd.h
inside the `#ifdef CONFIG_POSIX_API` block.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-31 11:36:02 -05:00
Robert Lubos bea1093e62 net: sockets: Remove socket offloading interface
Instead of using a custom offloading interface, users can use
`NET_SOCKET_REGISTER` macro to register custom socket API provider. This
solution removes a limitation, that only one offloaded interface can be
registered and that it cannot be used together with native IP stack.

The only exception remainig are DNS releated operations -
`getaddrinfo`/`freeaddrinfo`, which, when offloaded, have to be
registered specifically.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-31 11:36:02 -05:00
Robert Lubos 561973060e net: sockets: Extend ioctl poll protocol with offloading feature
Allow to use offloaded `poll` implementation via the existing ioctl poll
control mechanism.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-31 11:36:02 -05:00
Andrzej Puzdrowski 063ee74d4f doc/subsys/settings: improve settings API doc
Corrected improper return value description of
settings_runtime_get().

Added return value description to each of settings handler
description.

Include run-time API into doxygen build.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-01-31 07:45:52 -05:00
Kim Bøndergaard dea0511659 net: mqtt: struct mqtt_sec_config: Declare hostname with const
The hostname member of struct mqtt_sec_config is used as optval
argument to ztls_sesockopt_ctx().
optval is declared as const void* so no need to limit hostname
to not allow const variables

Signed-off-by: Kim Bøndergaard <kibo@prevas.dk>
2020-01-30 14:19:55 -05:00
Trond Einar Snekvik 4ea59711d2 Bluetooth: Move Mesh CCM into a separate module
Moves the Mesh AES-CCM module out into a separate module, to make it
accessible from other subsystems. Adds the new CCM API in
include/bluetooth/crypto.h along with the bt_encrypt functions.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-01-30 12:41:45 +02:00
Mieszko Mierunski dc3c906d12 drivers: uart: Switch timeout values to s32_t in UART async API
Use signed values for timeout in UART asynchronous API, to be consistent
with timeout type in timer and workqueue values.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2020-01-29 19:37:31 +01:00
Ulf Magnusson 1b394ad153 soc: ti_simplelink: kconfig: Refactor CCFG flash block handling
Instead of having TI_CCFG_PRESENT as a symbol that's only defined in
soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.defconfig.series and y when
SOC_SERIES_CC13X2_CC26X2 is enabled, turn it into a helper symbol that's
selected by SOC_SERIES_CC13X2_CC26X2.

This avoids having a symbol that's only defined in a Kconfig.defconfig
file, which is confusing. It also makes things a bit more generic, in
case other boards with CCFGs are added.

Also rename it to HAS_TI_CCFG to be consistent with other helper
symbols, and add a help text.

Flagged by scripts/kconfig/lint.py.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-29 09:41:46 -06:00
Peter A. Bigot 1964bf08bb lib: os: onoff: add API for on-off service request and release management
There are various situations where it's necessary to support turning
devices on or off at runtime, includin power rails, clocks, other
peripherals, and binary device power management.  The complexity of
properly managing multiple consumers of a device in a multithreaded
system suggests that a shared implementation is desirable.  This
commit provides an API that supports managing on-off resources.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-29 14:08:46 +01:00
Kwon Tae-young 346e5c3a45 include: drivers: lora: Added support for RSSI and SNR in the recv API
Change the API to support RSSI, SNR of data received through lora_recv.

Signed-off-by: Kwon Tae-young <tykwon@m2i.co.kr>
2020-01-28 17:28:26 -05:00
Erik Johnson fe83035474 logging: Added explicit casts of buffer in hexdump delegates
Since the various delegates have different data types for their
parameters, this makes the call into this macro a little simpler
(alleviating the need for each call to know how it'll be handed off
down the chain).

Signed-off-by: Erik Johnson <erik.johnson@nimbelink.com>
2020-01-28 17:20:15 -05:00
Erik Johnson ee855a1bf6 logging: Added explicit cast to u16_t of LOG_CURRENT_MODULE_ID()
Matches other code that uses this macro (just above).

Signed-off-by: Erik Johnson <erik.johnson@nimbelink.com>
2020-01-28 17:20:15 -05:00
Francois Ramu b7a3e7dc31 dts: bindings: dma add support for controller
This patch introduces the periph to/from memory dma transfer
define new values for dma cells on client side

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-01-28 12:58:44 -06:00
Henrik Brix Andersen c894a6db4d drivers: counter: add counter_get_value(), deprecate counter_read()
Introduce a new counter API function for reading the current counter
value (counter_get_value()) and deprecate the former counter_read() in
favor of this.

Update all drivers and calling code to match the new counter API.

The previous counter driver API function for reading the current value
of the counter (counter_read()) did not support indicating whether the
read suceeded. This is fine for counters internal to the SoC where the
read always succeeds but insufficient for external counters (e.g. I2C
or SPI slaves).

Fixes #21846.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2020-01-28 12:52:46 -05:00
Peter Bigot 0a81465554 treewide: use full path to can.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Wentong Wu 7cb74655da power: add system power management direct force mode.
Add system power management direct force trigger mode. In this
mode application thread can directly put system in sleep or deep
sleep mode instead of waiting for idle thread to do it, so that
it can reduce latency to enter low power mode.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-01-24 21:37:40 -05:00
Wentong Wu a9bd208b5b Power: change sys_pm_force_power_state only works for one shot
Change sys_pm_force_power_state only works for the current ongoing
suspend operation, before the end of syspend state forced_pm_state
will be cleared.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-01-24 21:37:40 -05:00
Wentong Wu 5f328f3501 Style: remove extern on the function declarations in the header
Remove extern on the function declarations in the header file to
keep consistent with others.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-01-24 21:37:40 -05:00
Michael Scott 407ceeee6d net: if: Make sure iface->if_dev is not null when accessing L2
commit 971ae59913 ("net: pkt: Make sure iface is not null when
accessing L2") fixed net_if_l2 where iface was NULL, however if
iface->if_dev is NULL, the check breaks and returns an offset of
NULL (0x82 or so).  This is incorrect.

Let's add a check for iface->if_dev as well.

Signed-off-by: Michael Scott <mike@foundries.io>
2020-01-24 23:30:10 +02:00
Jukka Rissanen f9c18dd962 net: dns: Support multiple simultaneous mDNS requests
As mDNS requests set DNS id to 0, we cannot use it to match
the DNS response packet. In order to allow this functionality,
create a hash from query name and type, and use that together
with DNS id to match request and response.

Fixes #21914

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-01-24 16:22:18 +02:00
Øyvind Rønningstad 05f0d85b6a extensions.cmake: Replace TEXT_START with ROM_START
In zephyr_linker_sources().
This is done since the point of the location is to place things at given
offsets. This can only be done consistenly if the linker code is placed
into the _first_ section.

All uses of TEXT_START are replaced with ROM_START.

ROM_START is only supported in some arches, as some arches have several
custom sections before text. These don't currently have ROM_START or
TEXT_START available, but that could be added with a bit of refactoring
in their linker script.

No SORT_KEYs are changed.

This also fixes an error introduced when TEXT_START was added, where
TEXT_SECTION_OFFSET was applied to riscv's common linker.ld instead of
to openisa_rv32m1's specific linker.ld.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2020-01-23 03:22:59 -08:00
Ioannis Glaropoulos e94551e2b7 arch: arm: cortex-m: properly name ROM sections in the linker
This commit does the following:
- renames the 'text' ROM section to 'rom_start', to reflect
  that this section is the first section of the image.
- renames the 'TEXT_SECTION_NAME_2' section to 'text', since
  that section (whose start is pointed by _image_text_start)
  holds the entire image text section.

The commit removes the confusion by having multiple ROM sections
named as 'text' in ARM Cortex-M builds.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2020-01-23 03:22:59 -08:00
Ioannis Glaropoulos 29d88c6c73 arch: arm: cortex-m: linker.ld: do not indent preprocessor directives
We should not use indentation for pre-processor directives.
This commit fixes the indentation in the ARM Cortex-M linker
script.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-01-23 03:22:59 -08:00
Krzysztof Chruscinski a8b5a2e65e kernel: device: Add const qualifier to device_config
Device config structure is placed in rom section but there was
no const prefix used. Lack of prefix suggested that structure
is in ram (ram_report is also fooled). Added const prefix to
explicitly inform that it goes to rom.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-01-22 06:32:36 -06:00
Andy Ross e06ba702d5 kernel/sched: Address thread abort termination delay issue on SMP
It's possible for a thread to abort itself simultaneously with an
external abort from another thread.  In fact in our test suite this is
a common thing, as ztest will abort its own spawend threads at the end
of a test, as they tend to be exiting on their own.

When that happens, the thread marks itself DEAD and does all its
scheduler bookeeping, but it is STILL RUNNING on its own stack until
it makes its way to its final swap.  The external context would see
that "dead" metadata and return from k_thread_abort(), allowing the
next test to reuse and spawn the same thread struct while the old
context was still running.  Obviously that's bad.

Unfortunately, this is impossible to address completely without
modifying every SMP architecture to add a API-visible hook to every
swap that signals completion.  In practice the best we can do is add a
delay.  But note the optimization: almost always, the scheduler IPI
catches the running thread and kills it from interrupt context
(i.e. on a different stack).  When that happens, we know that the
interrupted thread will never be resumed (because it's dead) and can
elide the delay.  We only pay the cost when we actually detect a race.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-01-21 14:47:52 -08:00
Henrik Brix Andersen 0f60477667 drivers: counter: add missing syscalls
Add missing syscalls and fix already present syscalls for the counter
API.

Fixes #14650.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2020-01-21 11:36:55 -05:00
Andrzej Puzdrowski 68f51f66c6 doc: cleanup after NFFS removal
Patch introduce references to LittleFS instead of NFFS where it
was suitable. In other places NFFS mentions were removed

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-01-21 15:32:47 +01:00
Andrzej Puzdrowski c0aa294690 fs: remove NFFS subsystem
NFFS is removed as it has serious bugs (by design) which haven't
been resolved since extended range of time.
One of most serious issues bunch were described here:
https://github.com/apache/mynewt-nffs/issues/10

Since lack of support NFFS upsterem it doesn't make sense to keep
it in zephyr.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-01-21 15:32:47 +01:00
Anas Nashif 756d8b03e2 kernel: queue: runtime error handling
Runtime error handling for k_queue_append_list and k_queue_merge_slist.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-20 17:19:54 -05:00
Anas Nashif 1ed67d1d51 kernel: stack: error handling
Add runtime error checking for both k_stack_push and k_stack_cleanup.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-20 17:19:54 -05:00
Anas Nashif 11b9365542 kernel: msgq: error handling
Add runtime error handling for k_msgq_cleanup. We return 0 on success
now and -EAGAIN when cleanup is not possible.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-20 17:19:54 -05:00
Anas Nashif dfc2bbcd3c kernel: mem_slab: error handling
Add runtime error checking for k_mem_slab_init and replace asserts with
returning error codes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-20 17:19:54 -05:00
Anas Nashif 361a84d07f kernel: pipe: runtime error checking
Add runtime error checking to k_pipe_cleanup and k_pipe_get and remove
asserts.
Adapted test which was expecting a fault to handle errors instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-20 17:19:54 -05:00
Anas Nashif 928af3ce09 kernel: semaphore: k_sem_init error checking
Check for errors at runtime and stop depending on ASSERTs.
This changes the API for
- k_sem_init

k_sem_init now returns -EINVAL on invalid data.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-20 17:19:54 -05:00
Anas Nashif 86bb2d06d7 kernel: mutex: add error checking
k_mutex_unlock will now perform error checking and return on failures.

If the current thread does not own the mutex, we will now return -EPERM.
In the unlikely situation where we own a lock and the lock count is
zero, we assert. This is considered an undefined bahviour and should not
happen.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-20 17:19:54 -05:00
Anas Nashif 22b95a2047 base: add error checking macros
Define there options for runtime error handling:
- assert on all errors (ASSERT_ON_ERRORS)
- no runtime checks (no asserts, no runtime error handling)
  (NO_RUNTIME_CHECKS)
- full runtime error handling (the default) (RUNTIME_ERROR_CHECKS)

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-20 17:19:54 -05:00
Henrik Brix Andersen 308f204952 canbus: canopen: add LED indicator support
Add support for CANopen LED indicators according to the CAN in
Automation (CiA) 303-3 specification.

This fixes #15278.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-20 17:17:23 +01:00
Henrik Brix Andersen 2dcbd8bbc1 canbus: canopen: add object dictionary storage
Add support for storing the CANopen object dictionary to non-volatile
storage.

This fixes #15278.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-20 17:17:23 +01:00
Jan Van Winkel 9814e743fd driver: display: Added BGR565 pixel format
Added BGR565 pixel format ti display format enumeration.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2020-01-20 09:21:04 -06:00
Jan Van Winkel ecaa7102d2 driver: display: Clarified byte order of pixel formats
Clarified that the byte order of multi byte pixel formats is in big
endian order.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2020-01-20 09:21:04 -06:00
Robert Lubos 665d195f3a net: sockets: tls: Add missing symbols for a few options
`TLS_PEER_VERIFY` and `TLS_DTLS_ROLE` options accept specific values,
yet no symbols were defined for them. In result, magic numbers were used
in several places, making the code less readable.

Fix this issue, by adding the missing symbols to the `socket.h` header,
and using them in places where related socket options are set.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-20 09:58:23 +02:00
Robert Lubos 20b1c695ab net: mqtt: Add keep alive timeout helper
Add function that returns remaining time until next keep alive message
shall be sent. Such function could be used for instance as a source
for `poll` timeout.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-18 12:25:33 +02:00
Andrew Boie e34f1cee06 x86: implement kernel page table isolation
Implement a set of per-cpu trampoline stacks which all
interrupts and exceptions will initially land on, and also
as an intermediate stack for privilege changes as we need
some stack space to swap page tables.

Set up the special trampoline page which contains all the
trampoline stacks, TSS, and GDT. This page needs to be
present in the user page tables or interrupts don't work.

CPU exceptions, with KPTI turned on, are treated as interrupts
and not traps so that we have IRQs locked on exception entry.

Add some additional macros for defining IDT entries.

Add special handling of locore text/rodata sections when
creating user mode page tables on x86-64.

Restore qemu_x86_64 to use KPTI, and remove restrictions on
enabling user mode on x86-64.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-17 16:17:39 -05:00
Andrew Boie a51b125aba drivers: serial: add async API system calls
These were unintentionally omitted. We don't expose callback
registration or callback response APIs for security reasons.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-17 16:15:02 -05:00
Ulf Magnusson 2b12de56ac dts: Add include/generated_dts_board.h for backwards compatibility
Includes include/devicetree.h and generates a warning.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 17:57:59 +01:00
Ulf Magnusson 4e85006ba4 dts: Rename generated_dts_board*.{h,conf} to devicetree*.{h,conf}
generated_dts_board.h is pretty redundant and confusing as a name. Call
it devicetree.h instead.

dts.h would be another option, but DTS stands for "devicetree source"
and is the source code format, so it's a bit confusing too.

The replacement was done by grepping for 'generated_dts_board' and
'GENERATED_DTS_BOARD'.

Two build diagram and input-output SVG files were updated as well, along
with misc. documentation.

hal_ti, mcuboot, and ci-tools updates are included too, in the west.yml
update.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-17 17:57:59 +01:00
Siddharth Chandrasekaran 0ff77b10e1 crypto: api: New capability flag CAP_NO_IV_PREFIX
Zephyr crypto API currently does not allow IV to be treated as separate
entity. This is mostly due to fact that underlying libraries expect the
IV to be prefixed to the cipher/plain text for performance reasons. But
there are cases where the IV is derived from other sources and not
directly transmitted to the other end. In such cases, it must be treated
as a first class citizen.

This patch adds a new capability flag `CAP_NO_IV_PREFIX` to the crypto
API that allows operations without prefixing the IV to the cipher/plain
text. When `CAP_NO_IV_PREFIX` is active (and supported), the IV passed
to cipher_*_op() must not be modified.

As a side effect, the length of the cipher/plain texts are equal;
allowing for in-place encryption/decryption.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-01-16 18:34:20 +01:00
Trond Einar Snekvik 19718fd6da Bluetooth: Mesh: Skip publish if update fails
Allow models to skip a periodic publish interval by returning an error
from the publish update callback.

Previously, an error return from publish update would cancel periodic
publishing. This can't be recovered from, and as such, no valid model
implementation could return an error from this callback, and there was
no way to skip a periodic publish.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-01-16 14:13:37 +02:00
Brooks Prumo 92f61b8075 include: dfu: Add extern "C" in mcuboot.h
I ran into a build failure trying to use Zephyr's MCUmgr.  It was a
missing symbol at link time, and since I am using C++, I looked to see
if it was a name mangling issue.  The mcuboot.h header file was missing
`extern "C"` guards, which was the root cause of the issue.

This commit adds C++ support to mcuboot.h by adding in `extern "C"`
guards.  I validated this change by building and running my DFU
application with MCUmgr successfully.

Signed-off-by: Brooks Prumo <brooks@prumo.org>
2020-01-15 12:18:59 -06:00
Peter A. Bigot ac5acb9530 drivers: sensor: ccs811: provide API to fetch configuration and versions
The application may want to know the configured mode without inspecting
Kconfig macros; this is important for proper management of BASELINE
which is mode-dependent.

It also may need to know the version of the hardware and firmware, as
the behavior of application firmware 2.0 is significantly better than
version 1.1.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Peter A. Bigot 2dd990ad55 drivers: sensor: ccs811: enable drive mode 4
This mode is documented as producing a raw result every 250 ms that the
application must convert to eCO2 and eTVOC readings.  In practice
application firmware 2.0 appears to convert the readings as with all
other rates.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Peter A. Bigot cb84836745 drivers: sensor: ccs811: provide access to sensor results
Expose the entire content of the ALG_RESULT_DATA block to the
application, primarily so the status and error flags can be seen.  With
those available the application has the ability to detect that a stale
result has been provided so sensor_fetch_sample() can return -EAGAIN in
this case instead of -EIO, and it doesn't need to block which is
annoying.

This should also make the sensor usable on older Nordic Thingy:52
devices with outdated CCS811 application firmware that doesn't properly
implement the DATA_READY bit.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Peter A. Bigot c90a738d8c drivers: sensor: ccs811: support update of environmental conditions
Accurate estimate of gas presence requires temperature and humidity
data.  Add API to update these values.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Peter A. Bigot af0c69fb9f drivers: sensor: ccs811: add interface for BASELINE management
Proper use of the CCS811 requires maintenance of the BASELINE
register value measured in clean air at various points in the sensor
life cycle.  The sensor driver abstraction has no facility to support
this, so add an application header with functions to fetch and update
the register value.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Joakim Andersson c353fdfa0f Bluetooth: host: Document connection object behaviour
Add documentation for why connection objects are still in use during the
disconnected callback and document error code when starting connectable
advertiser with no free connection object available.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-14 14:27:31 +01:00
Andrew Boie a594ca7c8f kernel: cleanup and formally define CPU start fn
The "key" parameter is legacy, remove it.

Add a typedef for the expected function pointer type.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie 3d80208025 x86: implement user mode on 64-bit
- In early boot, enable the syscall instruction and set up
  necessary MSRs
- Add a hook to update page tables on context switch
- Properly initialize thread based on whether it will
  start in user or supervisor mode
- Add landing function for system calls to execute the
  desired handler
- Implement arch_user_string_nlen()
- Implement logic for dropping a thread down to user mode
- Reserve per-CPU storage space for user and privilege
  elevation stack pointers, necessary for handling syscalls
  when no free registers are available
- Proper handling of gs register considerations when
  transitioning privilege levels

Kernel page table isolation (KPTI) is not yet implemented.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie 07c278382a x86: remove retpoline code
This code:

1) Doesn't work
2) Hasn't ever been enabled by default
3) We mitigate Spectre V2 via Extended IBRS anyway

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie 077b587447 x86: implement hw-based oops for both variants
We use a fixed value of 32 as the way interrupts/exceptions
are setup in x86_64's locore.S do not lend themselves to
Kconfig configuration of the vector to use.

HW-based kernel oops is now permanently on, there's no reason
to make it optional that I can see.

Default vectors for IPI and irq offload adjusted to not
collide.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie d24b704e89 x86: fix 64-bit issues in thread_stack.h
We should not be casting stuff related to memory sizes
to u32_t.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie c71e66e2a5 x86: add system call functions for 64-bit
Nothing too fancy here, we try as much as possible to
use the same register layout as the C calling convention.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie f5468d1192 x86: add linker directives for 64-bit user mode
Includes linker script fragments for the kernel object
tables and automatic memory partitions. The data section
is moved to the end per the requirements of
include/linker/kobject.h.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie 7ea958e0dd x86: optimize locations of psp and thread ptables
z_x86_thread_page_tables_get() now works for both user
and supervisor threads, returning the kernel page tables
in the latter case. This API has been up-leveled to
a common header.

The per-thread privilege elevation stack initial stack
pointer, and the per-thread page table locations are no
longer computed from other values, and instead are stored
in thread->arch.

A problem where the wrong page tables were dumped out
on certain kinds of page faults has been fixed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie e45c6eeebc x86: expose APIs for dumping MMU entry flags
Add two new non-static APIs for dumping out the
page table entries for a specified memory address,
and move to the main MMU code. Has debugging uses
when trying to figure out why memory domains are not
set up correctly.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie ded0185eb8 x86: add GDT descriptors for user mode
These are arranged in the particular order required
by the syscall/sysret instructions.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie 692fda47fc x86: use MSRs for %gs
We don't need to set up GDT data descriptors for setting
%gs. Instead, we use the x86 MSRs to set GS_BASE and
KERNEL_GS_BASE.

We don't currently allow user mode to set %gs on its own,
but later on if we do, we have everything set up to issue
'swapgs' instructions on syscall or IRQ.

Unused entries in the GDT have been removed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie 592ecf07c7 x86: add MSR defintions needed for syscalls
Define MSR register addresses for various MSRs related to
SYSCALL/SYSRET. We also add MSRs for FS/GS base addresses
(for GS, both kernel and user mode) to support SWAPGS.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Andrew Boie 10d033ebf0 x86: enable recoverable exceptions on 64-bit
These were previously assumed to always be fatal.
We can't have the faulting thread's XMM registers
clobbered, so put the SIMD/FPU state onto the stack
as well. This is fairly large (512 bytes) and the
execption stack is already uncomfortably small, so
increase to 2K.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 16:35:10 -05:00
Joakim Andersson 87812c9633 Bluetooth: host: Add BT_BUF_SIZE to include HCI reserve for buf size
Add helper define BT_BUF_SIZE which considers the BT_BUF_RESERVE when
declaring Bluetooth HCI buffers.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 17:59:00 +01:00
Andrew Boie c1fdf98ba5 kernel: show what spinlock was used incorrectly
Also helps identify corruption cases where the spinlock pointer
used wasn't actually a spinlock.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-13 10:17:16 -05:00
Paul Sokolovsky 57d538cef8 include: crypto: Cleanup docstrings
Fix typos, use punctuation and capitalization more consistently. In
a few cases, rewrite sentences for clarity.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-01-13 08:33:21 -06:00
Trond Einar Snekvik 5b14ab4481 Bluetooth: Add dynamic le scan listener interface
Adds a way to register listeners for incoming scanner packets, in
addition to the callback passed in bt_le_scan_enable.

This allows application modules to add multiple scan packet listeners
without owning the scanner life cycle API, enabling use cases like
beacon scanning alongside Bluetooth Mesh.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-01-13 14:27:01 +01:00
Joakim Andersson e04e4c27e8 kernel: panic: Option ASSERT_NO_FILE_INFO controls panic or oops print
Use option ASSERT_NO_FILE_INFO to control panic or oops location print.
The cause of the exception can be backtraced using the stackframe
instead, which would give the user a way to reduce the footprint of the
panic implementation.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson 27bbfb66b4 assert: Completely remove file info and condition expression
Completely remove the file info and condition expression from the
the print statement if they are not enabled. This saves a little code
space which adds up when there are many assert calls.

In bluetooth shell test this saves around 4.5k bytes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson 8aecf14928 assert: Disable line number printing together with file printing
Disable printing the line number in assertions when file name has been
disabled. Knowing the line number is not very useful when the name of
the file is unknown.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson 4af5815bf4 assert: Add option to disable assertion messages
Add option to disable the assertion message, this makes all __ASSERT
behave as __ASSERT_NO_MSG instead.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson 7a433325f5 assert: Add verbose option to assertion messages
Add verbose option which would control if the assertion mechanism prints
any information at all. With this disabled they application will have to
use the stack-frame to locate the assertion location.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson 000d9b15ff assert: Move __ASSERT_LOC so it can be used when asserts are disabled
Move __ASSERT_LOC macro so that it can be used by other modules even
when CONFIG_ASSERT are disabled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Joakim Andersson 94d331b2eb assert: Add option to disable condition from assertion message
Add Kconfig option to disable the conditional expression in the assert
that failed. This would save code space, and file and line provides
better information than the conditional expression in case where
the same expression would be asserted upon.

For example __ASSERT_NO_MSG(buf) wouldn't make much sense in
configuration where CONFIG_ASSERT_NO_FILE_INFO was enabled.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00
Trond Einar Snekvik 723e14a432 Bluetooth: Mesh: Model start callback
Replaces the Mesh model settings_commit callback with a start callback,
indicating that the mesh model behavior is ready to start. Everything
that was previously done in the settings_commit callback may be moved to
this callback, which gets called just after mesh settings are committed,
instead of in the middle of the process.

This resolves an issue where models had no context in which to start
their behavior, as the previous settings_commit call fired before the
mesh was declared valid, making access APIs inaccessible.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-01-11 18:20:00 +01:00
Kim Sekkelund 9ea6e72bae Bluetooth: host: cfg_write callback to return error code
Current implementation of application's cfg_write callback only has the
possibility of returning boolean status, which in case of failure only
allows for one error code; BT_ATT_ERR_WRITE_NOT_PERMITTED.
This change makes the application able to add own security check on
characteristic subscription in the cfg_write callback and report a more
relevant error code (e.g. BT_ATT_ERR_AUTHORIZATION).

Signed-off-by: Kim Sekkelund <ksek@oticon.com>
2020-01-10 17:41:15 +01:00
Stephanos Ioannidis bc8524eb82 arch: arm: Rewrite Cortex-R reset vector function.
This commit addresses the following issues:

1. Add a new Kconfig configuration for specifying Dual-redundant Core
   Lock-step (DCLS) processor topology.

2. Register initialisation is only required when Dual-redundant Core
   Lock-step (DCLS) is implemented in hardware. This initialisation is
   required on DCLS only because the architectural registers are in an
   indeterminate state after reset and therefore the initial register
   state of the two parallel executing cores are not guaranteed to be
   identical, which can lead to DCCM detecting it as a hardware fault.
   A conditional compilation check for this hardware configuration
   using the newly added CONFIG_CPU_HAS_DCLS flag has been added.

3. The existing CPU register initialisation code did not take into
   account the banked registers for every execution mode. The new
   implementation ensures that all architectural registers of every
   mode are initialised.

4. Add VFP register initialisation for when floating-point support is
   enabled and the core is configured in DCLS topology. This
   initialisation sequence is required for the same reason given in
   the first issue.

5. Add provision for platform-specific initialisation on Cortex-R
   using PLATFORM_SPECIFIC_INIT config and z_platform_init function.

6. Remove seemingly pointless and inadequately defined STACK_MARGIN.
   Not only does it violate the 8-byte stack alignment rule, it does
   not provide any form of real stack protection.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-01-10 10:34:17 +01:00
Carles Cufi beedf19ca4 shell: Remove deprecated macros
Remove deprecated macros and add a note to the release notes to this
effect.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-01-09 14:38:49 -05:00
Luiz Augusto von Dentz 3be9980bd6 Bluetooth: GATT: Remove _peer member from bt_gatt_subscribe_params
This further reduce the overhead on each subscription at expense of
having a dedicated array to store subscriptions, the code now maintain
a separate list for each peer which should also scale better with large
number of subscriptions to different peers.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-01-09 19:20:21 +01:00