Commit graph

62 commits

Author SHA1 Message Date
Guennadi Liakhovetski b53a792ff0 llext: enable tristate Kconfig options
kconfiglib.py has a hard dependency on CONFIG_MODULES to support 'm'
values for tristate Kconfig options. It's a logical companion for
but can also be used with other configurations.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-01-11 10:26:04 -05:00
Fabio Baltieri 6ae03d98a0 drivers, subsys: sort the lists again, mark the blocks for checking
Sort the Kconfig and CMakeLists include blocks again, and mark the start
and end of the blocks so that the CI can keep them sorted.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-13 09:41:05 +01:00
Tom Burdick 41e0a4a371 llext: Linkable loadable extensions
Adds the linkable loadable extensions (llext) subsystem which provides
functionality for reading, parsing, and linking ELF encoded executable
code into a managed extension to the running elf base image.

A loader interface, and default buffer loader implementation,
make available to the llext subsystem the elf data. A simple management
API provide the ability to load and unload extensions as needed. A shell
interface for extension loading and unloading makes it easy to try.

Adds initial support for armv7 thumb built elfs with very specific
compiler flags.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Co-authored-by: Chen Peng1 <peng1.chen@intel.com>
Co-authored-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-09-29 20:50:38 -04:00
Yonatan Schachter 5508b17fb4 bindesc: Add initial support for binary descriptor definition
Binary descriptors are data objects stored at a known location
of a binary image. They can be read by an external tool or image,
and are used mostly for build information: version, build time,
host information, etc.
This commit adds initial support for defining such descriptors.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2023-09-28 07:39:09 -04:00
Carlo Caione e4a125b6a4 dt: Make zephyr,memory-attr a capabilities bitmask
This is the final step in making the `zephyr,memory-attr` property
actually useful.

The problem with the current implementation is that `zephyr,memory-attr`
is an enum type, this is making very difficult to use that to actually
describe the memory capabilities. The solution proposed in this PR is to
use the `zephyr,memory-attr` property as an OR-ed bitmask of memory
attributes.

With the change proposed in this PR it is possible in the DeviceTree to
mark the memory regions with a bitmask of attributes by using the
`zephyr,memory-attr` property. This property and the related memory
region can then be retrieved at run-time by leveraging a provided helper
library or the usual DT helpers.

The set of general attributes that can be specified in the property are
defined and explained in
`include/zephyr/dt-bindings/memory-attr/memory-attr.h` (the list can be
extended when needed).

For example, to mark a memory region in the DeviceTree as volatile,
non-cacheable, out-of-order:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_VOLATILE |
			       DT_MEM_NON_CACHEABLE |
			       DT_MEM_OOO )>;
   };

The `zephyr,memory-attr` property can also be used to set
architecture-specific custom attributes that can be interpreted at run
time. This is leveraged, among other things, to create MPU regions out
of DeviceTree defined memory regions on ARM, for example:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-region = "NOCACHE_REGION";
       zephyr,memory-attr = <( DT_ARM_MPU(ATTR_MPU_RAM_NOCACHE) )>;
   };

See `include/zephyr/dt-bindings/memory-attr/memory-attr-mpu.h` to see
how an architecture can define its own special memory attributes (in
this case ARM MPU).

The property can also be used to set custom software-specific
attributes. For example we can think of marking a memory region as
available to be used for memory allocation (not yet implemented):

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_NON_CACHEABLE |
			       DT_MEM_SW_ALLOCATABLE )>;
   };

Or maybe we can leverage the property to specify some alignment
requirements for the region:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_CACHEABLE |
			       DT_MEM_SW_ALIGN(32) )>;
   };

The conventional and recommended way to deal and manage with memory
regions marked with attributes is by using the provided `mem-attr`
helper library by enabling `CONFIG_MEM_ATTR` (or by using the usual DT
helpers).

When this option is enabled the list of memory regions and their
attributes are compiled in a user-accessible array and a set of
functions is made available that can be used to query, probe and act on
regions and attributes, see `include/zephyr/mem_mgmt/mem_attr.h`

Note that the `zephyr,memory-attr` property is only a descriptive
property of the capabilities of the associated memory  region, but it
does not result in any actual setting for the memory to be set. The
user, code or subsystem willing to use this information to do some work
(for example creating an MPU region out of the property) must use either
the provided `mem-attr` library or the usual DeviceTree helpers to
perform the required work / setting.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-09-15 12:46:54 +02:00
Bjarki Arge Andreasen b4cf54b8c3 subsys/modem: Add modem modules
This PR adds the following modem modules to the subsys/modem
folder:

- chat: Light implementation of the Linux chat program, used to
        send and receive text based commands statically created
        scripts.

- cmux: Implementation of the CMUX protocol
- pipe: Thread-safe async data-in/data-out binding layer between
        modem  modules.

- ppp: Implementation of the PPP protocol, binding the Zephyr PPP
       L2 stack with the data-in/data-out pipe.

These modules use the abstract pipes to communicate between each
other. To bind them with the hardware, the following backends
are provided:

- TTY: modem pipe <-> POSIX TTY file
- UART: modem pipe <-> UART, async and ISR APIs supported

The backends are used to abstract away the physical layer, UART,
TTY, IPC, I2C, SPI etc, to a modem modules friendly pipe.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-08-30 13:48:51 +02:00
Zhang Lixu 685160b4bf sensing: add Sensing Subsystem skeleton
Add Sensing Subsystem skeleton.

Signed-off-by: Guangfu Hu <guangfu.hu@intel.com>
Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-06-17 07:43:25 -04:00
Mahesh Rao dc9dc3d044 subsystem: sip_svc: Add ARM SiP SVC subsystem
Introduce a new SiP SVC subsystem to provide ARM Silicon Provider based
supervisory call services. SiP SVC service provides the capability to
send SMC/HVC call from kernel running at EL1 to hypervisor/
secure monitor firmware running at EL2/EL3 and also added SiP SVC shell
commands to exercise the service.

Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
2023-05-09 08:46:50 -04:00
Jamie McCrae 64f4404481 retention: Add retention system
Adds a retention system which builds on top of retained_mem
drivers to allow partitioning of areas and data integrity with
magic header prefixes and checksum of stored data.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-04-24 13:27:53 +02:00
Fabio Baltieri 3386e96515 input: add input subsystem
Initial commit introducing the input subsystem into Zephyr.

Includes the input_event data structure, the input_report_* APIs, an
iterables sections based subscription API and two operation modes:
synchronous, where the listeners are called directly, and asynchronous,
where the listeners are called in a dedicated thread.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-06 11:47:32 -08:00
Fabio Baltieri 8c6137d7a7 build: sort and compact drivers and subsys CMakeLists and Kconfig
There are just list of child files to include, right now there's a hint
of that trying to be alphabetical but then entries have been added with
various logic, so one has to figure where stuff has to be added.

Rewrite these to:
- keep the list alphabetical, for CMakeLists unconditional first,
  conditional after so one just has to select and sort
- drop the spaces in the Kconfig
- use a single space between  target and directory
- rename from "Sub Systems" to "Subsystems" (single word)

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-22 10:25:11 +01:00
Stephanos Ioannidis feaab27c1b lib: cpp: Relocate subsys/cpp to lib/cpp
This commit moves the files under `subsys/cpp` directory to the
`lib/cpp` directory because the C++ ABI runtime library and the
standard C++ library components are not a "subsystem" (aka. API) in
conventional sense and is better described as a "library."

Classifying the C++ ABI runtime library and the standard C++ library as
"libraries" instead of "subsystems" also better aligns with how the
existing C standard library implementation (`lib/libc`) is handled.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Johann Fischer 7c1ef35027 usb: add initial USB host support
This is initial support. Necessary to test the UHC driver API,
for the USB support test implementations, and upcoming USBIP support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-16 13:21:12 +01:00
Yuval Peress b38445eaa0 math: Introduce a DSP basicmath subsystem with a cmsis backend
Introduce an API mirroring the CMSIS-DSP's basicmath. If CMSIS_DSP is
enabled, then it will by default be used as a backend. Developers may
opt into a custom backend by setting CONFIG_DSP_BACKEND_CMSIS=n. If
done, the application must provide `zdsp_backend/dsp.h` and optionally
implement the functions in its own .c files.

Signed-off-by: Yuval Peress <peress@google.com>
2022-12-02 20:15:55 +01:00
Johann Fischer cb8b9ad38a usb: add new experimental USB device stack
The device supprt brings support for multiple stack instances,
multiple configuration, asynchronous transfer model, ability to
change most of the properties of a device at runtime and
the composition of configuration and classes at runtime.

The stack requires new UDC driver API and is not compatible
with old driver API (usb_dc_). The classes (functions) of old
(current) USB device stack cannot be used with new ones and must
be ported.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-12-02 12:55:18 +01:00
Rodrigo Peixoto b8ecbfaa57 zbus: Add message bus subsystem to Zephyr
Add zbus message bus as a Zephyr subsystem. No message bus
or communication abstraction other than the usual (message queues,
mailboxes, etc.) enabled developers to implement event-driven systems in
Zephyr quickly. Zbus would fill that gap by providing the community with
a lightweight and flexible message bus. The implementation tries to be
closest as possible to the existing ones. We use the claim/finish
approach, and the API for publishing and reading channels are similar
in message queues. Zbus is about channels, messages, and observers.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2022-11-14 17:25:29 -05:00
Sam Hurst e90f1b66d8 usb-c: Add USB-C Subsystem with Sink PD Support
This USB-C Subsystem enables an application to include
USB-C Power Delivery Sink functionality.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Tom Burdick 3d2ead38cb rtio: Real-Time Input/Output Stream
A DMA friendly Stream API for zephyr. Based on ideas from io_uring
and iio, a queue based API for I/O operations.

Provides a pair of fixed length ringbuffer backed queues for submitting
I/O requests and recieving I/O completions. The requests may be chained
together to ensure the next operation does not start until the current
one is complete.

Requests target an abstract rtio_iodev which is expected to wrap all
the hardware particulars of how to perform the operation. For example
with a SPI bus device, a description of what a read, and write mean
can be decided by the iodev wrapping a particular device
hanging off of a SPI controller.

The queue pair are submitted to an executor which may be a simple
inplace looping executor done in the callers execution context
(thread/stack) but other executors are expected. A threadpool executor
might for example allow for concurrent request chains to execute in
parallel. A DMA executor, in conjunction with DMA aware iodevs
would allow for hardware offloading of operations going so far as to
schedule with priority using hardware arbitration.

Both the iodev and executor are definable by a particular
SoC, meaning they can work in conjuction to perform IO operations
using a particular DMA controller or methodology if desired.

The application decides entirely how large the queues are, where
the buffers to read/write come from (some executors
may have particular demands!), and which executor to submit
requests to.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-06-28 13:53:13 -04:00
Daniel DeGrasse 3e8bbee9ed sd: Add common SD initialization code
All SD cards require SD CMD0 (reset) and CMD8 (send IF cond) at boot.
Add this portion of the initialization flow to SD subsystem, as well as
query command to check if card is SDIO.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-29 14:21:36 -05:00
Johann Fischer 6be45c2a18 usb: move USB device stack code to own directory
Until now the whole USB device stack code is located
in the top subsys/usb directory. Move it to own directory
in preparation for upcoming extension and rework of USB support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-03-31 18:30:14 +02:00
Gerard Marull-Paretas 99cbee3f16 pm: move power subsystem to pm
Adjust naming to make things consistent.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Anas Nashif a15f32f58c portability: move cmsis APIs to subsys/portability
Move cmsis OS apis under subsystem/portability. Those are not libraries
and only serve to provide a level of abstraction using the CMSIS OS APIs
to existing Zephyr interfaces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-20 08:45:05 -04:00
Johann Fischer 07ab652c6c modbus: add MODBUS RTU subsystem
Add MODBUS RTU (over serial line) subsystem.
MODBUS RTU implementation supports booth server and
client roles. Some components of the implementation are based
on the uC/Modbus stack, which was published under Apache license,
(https://github.com/SiliconLabs/uC-Modbus
 fdd1218a28e313c1212fed5ed42e5c65d3056a2c).

Resolves: #2854

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2021-03-19 15:50:21 +01:00
Martin Jäger 1aaf508bde task_wdt: add task-level watchdog subsystem
This new subsystem can be used to supervise individual threads. It
is based on a regularly updated kernel timer, whose ISR is never
actually called in regular system operation.

An existing hardware watchdog can be used as an optional fallback if
the task watchdog itself gets stuck.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-03-15 12:24:54 +01:00
Andrew Boie 993cf9f8eb demand_paging: add infra for demand paging modules
Backing stores and eviction algorithms will be included here.
Exactly one must be chosen, with a default option to leave
the implementation to the application.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-23 19:47:23 -05:00
Anas Nashif 5d3a21ae61 Revert "demand_paging: add infra for demand paging modules"
This reverts commit 1c2bd343ff.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-22 08:39:45 -05:00
Andrew Boie 1c2bd343ff demand_paging: add infra for demand paging modules
Backing stores and eviction algorithms will be included here.
Exactly one must be chosen, with a default option to leave
the implementation to the application.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2021-01-21 16:47:00 -05:00
Hubert Miś b0ec7a63ab ipc: RPMsg service to register multiple endpoints
This patch implements a service that adds multiendpoint
capabilities to RPMsg. Multiple endpoints are intended to be used
when multiple modules need services from a remote processor. Each
module may register one or more RPMsg endpoints.

The implementation separates backend from the service, what
allows to extend this module to support other topologies like
Linux <-> Zephyr.

Co-authored-by: Piotr Szkotak <piotr.szkotak@nordicsemi.no>
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-01-19 22:07:09 +01:00
Manivannan Sadhasivam 3ce8540f3a lorawan: Add initial support for LoRaWAN
Add initial support for LoRaWAN based on Semtech's loramac-node
library. Current implementation only supports OTAA config and
sending data to LoRaWAN server like ThingsNetwork.

While at it, this commit also moves the "loramac-node" library
definition from drivers/lora to subsys/lorawan. This is required
because, subsys/lorawan gets processed before drivers/lora and
that creates issue while building.

Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
2020-10-08 12:15:38 +02:00
Daniel Leung 0ffcfa9633 timing: introduce timing functions as a generic feature
Add timing functions and APIs.  This is now used with some of the tests
we have for performance and metrics and will be used whereever timing
informations are needed, for example for tracing, profiling and other
operations where timing info is critical.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-09-05 13:28:38 -05:00
Simon Glass 302d671ea2 emul: Create an emulation implementation
Create a header file and implementation for emulators. Set up a linker
list so that emulators can be found and initialised at start-up.

Emulators are used to emulate hardware devices, to support testing of
various subsystems. For example, it is possible to write an emulator
for an I2C compass such that it appears on the I2C bus and can be used
just like a real hardware device.

Emulators often implement special features for testing. For example a
compass may support returning bogus data if the I2C bus speed is too
high, or may return invalid measurements if calibration has not yet
been completed. This allows for testing that high-level code can
handle these situations correctly. Test coverage can therefore
approach 100% if all failure conditions are emulated.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-01 14:30:46 -04:00
Anas Nashif f5d606ef72 Kconfig: cleanup subsystems
Sort entries alphabetically and cleanup top level menu for each
subsystem. Move stats subsystem Kconfig from debug into its own Kconfig.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-24 10:24:30 +02:00
Anas Nashif 3b75a08e3f Kconfig: move power management Kconfig into subsys/power
Consolidate all PM related Kconfigs in one place.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-24 10:24:30 +02:00
Anas Nashif d4930f71fc kconfig: top level menu item for subsystems
Move all subsystems into one single menu entry to reduce the clutter in
the top level menuconfig.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-24 10:24:30 +02:00
Anas Nashif 41abcc57c1 tracing: move tracing under subsys/
Tracing subsystem is growing and although related to debugging, it does
deserve to belong into its own subsystem.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-02-07 15:58:05 -05:00
Henrik Brix Andersen 56f74da757 canbus: canopen: add zephyr driver layer for CANopenNode
Add a Zephyr driver and abstraction layer for use by the 3rd party
CANopenNode module.

CANopenNode depends on the CO_driver.h file for platform-specific type
definitions, locking primitives, and CAN bus driver API.

This fixes #15278.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-20 17:17:23 +01:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Andrew Boie 4ce652e4b2 userspace: remove APP_SHARED_MEM Kconfig
This is an integral part of userspace and cannot be used
on its own. Fold into the main userspace configuration.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-23 07:43:55 -05:00
Anas Nashif ccad9d0d09 tests: move testsuite and configs into subsys/
Move test related code and the testsuite away from tests/ and make it a
proper subsystem.
The way tests were integrate in the tree was not obvious and actual
tests were intermixed with the testsuite code.

This will allow us to have trees with the testcode and without the
samples by just remove the folders tests/ and samples, needed for
isolating actual code from test/sample code.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-22 08:58:40 -05:00
Piotr Zięcik c45961daae power: Rework OS <-> Application interface
This commit simplifies OS <-> Application interface controlling power
management. In the previous approach application-based PM required
overriding sys_suspend() and sys_resume() functions. As these functions
actually implemented power state change, in such case application
basically had to provide own implementation of all PM-related stuff,
which was not portable and hard to maintain.

This commit changes this scheme: The sys_suspend() and sys_resume()
are now system functions while the application could either use
built-in power management policies or provide its own. All details
of power mode switching are now handled by the OS.

Also, this commit cleans up the Kconfig options related to system-level
power management grouping them under common CONFIG_SYS_PM_ prefix.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-19 13:25:36 -05:00
David Brown f8b838d404 jwt: Add JSON web token library
This patch adds a JSON web token library that adds the capability
to sign JSON tokens.  This was located in subsys due to the dependency
on MBEDTLS, which resides in /ext.

Signed-off-by: David Brown <david.brown@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
2019-02-08 15:32:58 -06:00
Benoit Leforestier 26e0f9a9e1 Build: Improve C++ support
Can choose the C++ standard (C++98/11/14/17/2a)
Can link with standard C++ library (libstdc++)
Add support of C++ exceptions
Add support of C++ RTTI
Add C++ options to subsys/cpp/Kconfig
Implements new and delete using k_malloc and k_free
if CONFIG_HEAP_MEM_POOL_SIZE is defined

Signed-off-by: Benoit Leforestier <benoit.leforestier@gmail.com>
2018-10-29 09:15:04 -04:00
Johann Fischer f531e0d62e subsys: add monochrome character framebuffer
Add monochrome character framebuffer for monochrome
graphic dot matrix displays and electrophoretic displays.

These displays are mostly monochrome and can only display
black and some other color, for example white. Typically,
a byte controls 8 pixels, arranged vertically or horizontally
depending on the controller or settings.
The API is not suitable to display graphics, the purpose is
to display text or symbols. It is possible to use several fonts.
A font can also consist of graphic symbols only and thus,
for example, enable the realization of a menu.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-10-16 14:54:47 -04:00
Ramakrishna Pallala 2ad647857c subsys: power: Add OS managed Power Management framework
Add support for OS managed Power Management framework for Zephyr
under 'subsys/power'. This framework takes care of implementing
the _sys_soc_suspend/_sys_soc_resume API's, a PM policy based on
SoC Low Power residencies and also provides necessary API's to
do devices suspend and resume.

Also add necessary changes to support the existing Application
managed Power Management framework.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-08-22 08:07:14 -07:00
Shawn Mosley 573f32b6d2 userspace: compartmentalized app memory organization
Summary: revised attempt at addressing issue 6290.  The
following provides an alternative to using
CONFIG_APPLICATION_MEMORY by compartmentalizing data into
Memory Domains.  Dependent on MPU limitations, supports
compartmentalized Memory Domains for 1...N logical
applications.  This is considered an initial attempt at
designing flexible compartmentalized Memory Domains for
multiple logical applications and, with the provided python
script and edited CMakeLists.txt, provides support for power
of 2 aligned MPU architectures.

Overview: The current patch uses qualifiers to group data into
subsections.  The qualifier usage allows for dynamic subsection
creation and affords the developer a large amount of flexibility
in the grouping, naming, and size of the resulting partitions and
domains that are built on these subsections. By additional macro
calls, functions are created that help calculate the size,
address, and permissions for the subsections and enable the
developer to control application data in specified partitions and
memory domains.

Background: Initial attempts focused on creating a single
section in the linker script that then contained internally
grouped variables/data to allow MPU/MMU alignment and protection.
This did not provide additional functionality beyond
CONFIG_APPLICATION_MEMORY as we were unable to reliably group
data or determine their grouping via exported linker symbols.
Thus, the resulting decision was made to dynamically create
subsections using the current qualifier method. An attempt to
group the data by object file was tested, but found that this
broke applications such as ztest where two object files are
created: ztest and main.  This also creates an issue of grouping
the two object files together in the same memory domain while
also allowing for compartmenting other data among threads.

Because it is not possible to know a) the name of the partition
and thus the symbol in the linker, b) the size of all the data
in the subsection, nor c) the overall number of partitions
created by the developer, it was not feasible to align the
subsections at compile time without using dynamically generated
linker script for MPU architectures requiring power of 2
alignment.

In order to provide support for MPU architectures that require a
power of 2 alignment, a python script is run at build prior to
when linker_priv_stacks.cmd is generated.  This script scans the
built object files for all possible partitions and the names given
to them. It then generates a linker file (app_smem.ld) that is
included in the main linker.ld file.  This app_smem.ld allows the
compiler and linker to then create each subsection and align to
the next power of 2.

Usage:
 - Requires: app_memory/app_memdomain.h .
 - _app_dmem(id) marks a variable to be placed into a data
section for memory partition id.
 - _app_bmem(id) marks a variable to be placed into a bss
section for memory partition id.
 - These are seen in the linker.map as "data_smem_id" and
"data_smem_idb".
 - To create a k_mem_partition, call the macro
app_mem_partition(part0) where "part0" is the name then used to
refer to that partition. This macro only creates a function and
necessary data structures for the later "initialization".
 - To create a memory domain for the partition, the macro
app_mem_domain(dom0) is called where "dom0" is the name then
used for the memory domain.
 - To initialize the partition (effectively adding the partition
to a linked list), init_part_part0() is called. This is followed
by init_app_memory(), which walks all partitions in the linked
list and calculates the sizes for each partition.
 - Once the partition is initialized, the domain can be
initialized with init_domain_dom0(part0) which initializes the
domain with partition part0.
 - After the domain has been initialized, the current thread
can be added using add_thread_dom0(k_current_get()).
 - The code used in ztests ans kernel/init has been added under
a conditional #ifdef to isolate the code from other tests.
The userspace test CMakeLists.txt file has commands to insert
the CONFIG_APP_SHARED_MEM definition into the required build
targets.
  Example:
        /* create partition at top of file outside functions */
        app_mem_partition(part0);
        /* create domain */
        app_mem_domain(dom0);
        _app_dmem(dom0) int var1;
        _app_bmem(dom0) static volatile int var2;

        int main()
        {
                init_part_part0();
                init_app_memory();
                init_domain_dom0(part0);
                add_thread_dom0(k_current_get());
                ...
        }

 - If multiple partitions are being created, a variadic
preprocessor macro can be used as provided in
app_macro_support.h:

        FOR_EACH(app_mem_partition, part0, part1, part2);

or, for multiple domains, similarly:

        FOR_EACH(app_mem_domain, dom0, dom1);

Similarly, the init_part_* can also be used in the macro:

        FOR_EACH(init_part, part0, part1, part2);

Testing:
 - This has been successfully tested on qemu_x86 and the
ARM frdm_k64f board.  It compiles and builds power of 2
aligned subsections for the linker script on the 96b_carbon
boards.  These power of 2 alignments have been checked by
hand and are viewable in the zephyr.map file that is
produced during build. However, due to a shortage of
available MPU regions on the 96b_carbon board, we are unable
to test this.
 - When run on the 96b_carbon board, the test suite will
enter execution, but each individaul test will fail due to
an MPU FAULT.  This is expected as the required number of
MPU regions exceeds the number allowed due to the static
allocation. As the MPU driver does not detect this issue,
the fault occurs because the data being accessed has been
placed outside the active MPU region.
 - This now compiles successfully for the ARC boards
em_starterkit_em7d and em_starterkit_em7d_v22. However,
as we lack ARC hardware to run this build on, we are unable
to test this build.

Current known issues:
1) While the script and edited CMakeLists.txt creates the
ability to align to the next power of 2, this does not
address the shortage of available MPU regions on certain
devices (e.g. 96b_carbon).  In testing the APB and PPB
regions were commented out.
2) checkpatch.pl lists several issues regarding the
following:
a) Complex macros. The FOR_EACH macros as defined in
app_macro_support.h are listed as complex macros needing
parentheses.  Adding parentheses breaks their
functionality, and we have otherwise been unable to
resolve the reported error.
b) __aligned() preferred. The _app_dmem_pad() and
_app_bmem_pad() macros give warnings that __aligned()
is preferred. Prior iterations had this implementation,
which resulted in errors due to "complex macros".
c) Trailing semicolon. The macro init_part(name) has
a trailing semicolon as the semicolon is needed for the
inlined macro call that is generated when this macro
expands.

Update: updated to alternative CONFIG_APPLCATION_MEMORY.
Added config option CONFIG_APP_SHARED_MEM to enable a new section
app_smem to contain the shared memory component.  This commit
seperates the Kconfig definition from the definition used for the
conditional code.  The change is in response to changes in the
way the build system treats definitions.  The python script used
to generate a linker script for app_smem was also midified to
simplify the alignment directives.  A default linker script
app_smem.ld was added to remove the conditional includes dependency
on CONFIG_APP_SHARED_MEM.  By addining the default linker script
the prebuild stages link properly prior to the python script running

Signed-off-by: Joshua Domagalski <jedomag@tycho.nsa.gov>
Signed-off-by: Shawn Mosley <smmosle@tycho.nsa.gov>
2018-07-25 12:02:01 -07:00
Sebastian Bøe f9b2da37b0 kconfig: Move CPLUSPLUS from root to "Compiler Options"
Enabling C++ support for the application has been inappropriately
located at the root of the Kconfig menu. The root should be kept as
clean possible to allow easy navigation.

This commit moves CONFIG_CPLUSPLUS into

~/"Build and Linker Features"/"Compiler Options".

This is a purely cosmetic change and does not change the
'visibility' (depends) of the Kconfig option.

Arguably, it would fit better into

~/"Build and Linker Features"/"Language Options"

but this entry does not exist.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-30 13:12:01 -04:00
Andrzej Puzdrowski 94ff339cbf subsys: Add a new settings subsystem
Adapt the MyNewt non-volatile configuration system to become a settings
system in Zephyr.
The original code was modifed in the following ways:

* Renamed from config to settings
* Use the zephyr FCB, FS API, and base64 subsystems
* lltoa like function was added to sources as it was required but not
  included in Zephyr itself.
* The original code was modified to use Zephyr's slist.h as single
  linked list implementation.
* Reworked code which was using strtok_r, added function
  for decoding a string to a s64_t value.
* Thank to the above the settings subsys doesn't require newlibc anymore.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-03-28 10:44:20 -04:00
Christopher Collins 3986ef2770 subsys: mgmt: CMake and Kconfig support.
Add the necessary CMakeLists.txt and Kconfig files for the mgmt
subsystem.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-20 22:07:52 +01:00
Andrzej Puzdrowski 25269fb0ed subsys: storage: Add flash_map abstraction module
Introduce flas_map module is abstraction over flash memory and its
driver for using flash memories along with description of
available flash areas.
Module provides simple API for write/read/erase and so one.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00
Leandro Pereira adce1d1888 subsys: Add random subsystem
Some "random" drivers are not drivers at all: they just implement the
function `sys_rand32_get()`.  Move those to a random subsystem in
preparation for a reorganization.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-01 08:26:29 -04:00