Commit graph

393 commits

Author SHA1 Message Date
Daniel Leung 04a0cf7d79 kernel: deprecate K_THREAD_STACK_MEMBER
The macro K_THREAD_STACK_MEMBER has actually been deprecated
since v2.4.0 in the macro doxygen description, but it was
never marked with __DEPRECATED_MACRO. Since this was being
used in various drivers, make it follow the deprecation
process.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-10-12 11:07:00 +01:00
Marcin Gasiorek 47822586e4 doc: Remove two redundant characters in rst file
Remove additional dot and bracket.

Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
2023-10-11 11:10:05 +02:00
Peter Mitsis d66cf91706 doc: Add missing threads references to object cores
Two references to the integration of object cores with threads were
missing from the documentation. This fixes that.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-10-09 10:16:46 +02:00
Flavio Ceolin 15aa3acaf6 kconfig: Remove MP_NUM_CPUS usage
Zephyr's code base uses MP_MAX_NUM_CPUS to
know how many cores exists in the target. It is
also expected that both symbols MP_MAX_NUM_CPUS
and MP_NUM_CPUS have the same value, so lets
just use MP_MAX_NUM_CPUS and simplify it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-03 17:45:53 +01:00
Peter Mitsis 1afc32e762 doc: Add object core documentation
Adds documentation for both object cores and object core statistics.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-09-30 08:04:14 +03:00
Grant Ramsay a8497c5216 kernel: msg_q: Remove alignment requirements from message queue docs
Alignment of the message queue's ring buffer is not necessary.
The underlying implementation uses memcpy (which is
alignment-agnostic) and does not expose any internal pointers

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-09-28 16:14:56 +02:00
Laurentiu Mihalcea b1111d9de4 doc: interrupts: Document support for shared interrupts
This commit adds the documentation for shared interrupts.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
2023-09-14 08:35:12 +02:00
Huifeng Zhang 2c22e83dfb include: arch: arm: Remove aarch32 directory
This commit follows the parent commit work.

This commit introduces the following major changes.

  1. Move all directories and files in 'include/zephyr/arch/arm/aarch32'
    to the 'include/zephyr/arch/arm' directory.

  2. Change the path string which is influenced by the changement 1.

Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
2023-09-13 10:08:05 +01:00
Carles Cufi 8c748fd005 kernel: Modify the signature of k_mem_slab_free()
Modify the signature of the k_mem_slab_free() function with a new one,
replacing the old void **mem with void *mem as a parameter.

The following function:
void k_mem_slab_free(struct k_mem_slab *slab, void **mem);

has the wrong signature. mem is only used as a regular pointer, so there
is no need to use a double-pointer. The correct signature should be:
void k_mem_slab_free(struct k_mem_slab *slab, void *mem);

The issue with the current signature, although functional, is that it is
extremely confusing. I myself, a veteran Zephyr developer, was confused
by this parameter when looking at it recently.

All in-tree uses of the function have been adapted.

Fixes #61888.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-09-03 18:20:59 -04:00
Joshua Lilly cce530cae4 scripts: build: gen_isr_tables: make bit masks configurable
Some architectures such as RISC-v support more than 255 interrupts
per aggrigator. This diff adds the ability to forgo the aggrigator
pattern and use a configurable number of bits for multilevel
interruts.

Signed-off-by: Joshua Lilly <jgl@meta.com>
2023-08-10 10:55:41 -04:00
Nicolas Pitre 52e2f83185 kernel/timeout: introduce the timepoint API
This is meant as a substitute for sys_clock_timeout_end_calc()

Current sys_clock_timeout_end_calc() usage opens up many bug
possibilities due to the actual timeout evaluation's open-coded nature.

Issue ##50611 is one example.

- Some users store the returned value in a signed variable, others in
  an unsigned one, making the comparison with UINT64_MAX (corresponding
  to K_FOREVER) wrong in the signed case.

- Some users compute the difference and store that in a signed variable
  to compare against 0 which still doesn't work with K_FOREVER. And when
  this difference is used as a timeout argument then the K_FOREVER
  nature of the timeout is lost.

- Some users complexify their code by special-casing K_NO_WAIT and
  K_FOREVER inline which is bad for both code readability and binary
  size.

Let's introduce a better abstraction to deal with absolute timepoints
with an opaque type to be used with a well-defined API.
The word "timeout" was avoided in the naming on purpose as the timeout
namespace is quite crowded already and it is preferable to make a
distinction between relative time periods (timeouts) and absolute time
values (timepoints).

A few stacks are also adjusted as they were too tight on X86.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Jamie McCrae d98656f081 doc: kernel: code-relocation: Remove erroneous note
The note about required position for the function is not valid.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-10 10:01:42 +00:00
Florian Grandel 5fa5534afc doc: kernel: clocks: define "current time"
Scheduling relative timeouts from within timer callbacks (=sys clock ISR
context) differs from scheduling relative timeouts from an application
context.

This change documents and explains the rationale of this distinction.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-30 16:07:26 +02:00
Anas Nashif d6ce537be8 doc: kernel: update thread priorities diagram
cooperative priorities are negative, 0 is not a cooperative priority.
Looks like the docs are showing an outdated diagram for some reason, try
to update that with a refresh.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-23 14:27:22 -04:00
Peter Mitsis 4c7aeb252d doc: Correct msgq data item size discrepancy
Updates the data passing summary table to indicate that the size of
a message queue data item must be a multiple of its data alignment.
This brings the documentation in both the summary table and the
message queue documentation into alignment.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-06-21 13:57:15 -04:00
Daniel Leung dbeb4d8f48 doc: kernel/syscalls: about limiting syscalls in binaries
Since not all syscalls are generated to be included in
the final binaries due to changes in build steps and CMake
files, update the document to clarify what needs to be
done to include specific syscalls in final binaries.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Peter Mitsis 2adfa3e1ae doc: Update FIFO and LIFO documentation
Updates the FIFO and LIFO documentation to clarify behavior
surrounding re-adding data items to queues.

Fixes #56336

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-05-02 04:43:08 -04:00
Anas Nashif 5238544d30 doc: change path to code relocation test
A sample was moved to tests, adapt documentation accordingly.

Fixes #56962

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-19 10:42:37 -04:00
Keith Packard 3a197934fc doc: Switch main return type from void to int.
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Sophie Tyalie e3ae110a05 fix: doc: in kernel/drivers interrupts function had mismatching types
The typedef defines an interrupt config routine with `const struct device
*dev`, while the example function had (void) as argument. This could be
considered confusing / would throw compiler warnings even though the
parameter isn't strictly necessary.

Code examples for initializing an IRQ in a device example follow the
updated pattern (e.g. see `drivers/serial/uart_npcx.c`).

Signed-off-by: Sophie Tyalie <dev@flowerpot.me>
2023-02-22 16:58:29 -05:00
Nicolas Pitre 6b0586ef05 riscv: improve FPU sharing documentation
Augment the doc with functionality added in commit a211970b42 ("riscv:
improve contended FPU switching").

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-02-18 01:09:16 +09:00
Nicolas Pitre ff07da6ff1 riscv: integrate the new FPU context switching support
FPU context switching is always performed on demand through the FPU
access exception handler. Actual task switching only grants or denies
FPU access depending on the current FPU owner.

Because RISC-V doesn't have a dedicated FPU access exception, we must
catch the Illegal Instruction exception and look for actual FP opcodes.

There is no longer a need to allocate FPU storage on the stack for every
exception making esf smaller and stack overflows less likely.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-01-24 15:26:18 +01:00
Daniel DeGrasse de8478b7f3 doc: code-relocation: Update usage of zephyr_code_relocate
Update usage of zephyr_code_relocate to new API, and add examples of
relocating a library target, as well as using multiple files in list or
CMake generator expressions.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-01-17 18:08:37 +01:00
Marti Bolivar 1037348b7b doc: update stale references to boilerplate.cmake
Inclusion of this file is now deprecated in favor of
find_package(Zephyr ...). Update documentation appropriately.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-01-11 09:40:14 +01:00
Henrik Brix Andersen 3c99a1e015 drivers: pcie: reintroduce support for I/O BARs
Reintroduce support for accessing I/O BARs which was removed in
43d84147d9.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-11-01 15:22:31 -04:00
Tomasz Moń fa86481692 doc: Verify write access in syscall example
Use z_user_to_copy() instead of directly writing to the user provided
pointer to validate that the user has write permission to underlying
memory location.

It is important to verify the memory not only for reads, but also for
writes, as otherwise the function can be abused by usermode code to
write to privileged read/write, unprivileged read-only memory partition.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-10-14 09:56:30 +02:00
Tomasz Moń 5c42b42116 doc: Add missing kconfig option prefix
Kconfig options have to be prefixed with :kconfig:option: in order to
appear as links in generated html output.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-10-13 13:16:06 -04:00
Gerard Marull-Paretas e42f58ec94 init: s/ARCH/EARLY, call it just before arch kernel init
The `ARCH` init level was added to solve a specific problem, call init
code (SYS_INIT/devices) before `z_cstart` in the `intel_adsp` platform.
The documentation claims it runs before `z_cstart`, but this is only
true if the SoC/arch takes care of calling:

```c
z_sys_init_run_level(_SYS_INIT_LEVEL_ARCH);
```

Which is only true for `intel_adsp` nowadays. So in practice, we now
have a platform specific init level. This patch proposes to do things in
a slightly different way. First, level name is renamed to `EARLY`, to
emphasize it runs in the early stage of the boot process. Then, it is
handled by the Kernel (inside `z_cstart()` before calling
`arch_kernel_init()`). This means that any platform can now use this
level. For `intel_adsp`, there should be no changes, other than
`gcov_static_init()` will be called before (I assume this will allow to
obtain coverage for code called in EARLY?).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 17:16:27 +09:00
Anas Nashif 8e99222114 doc: document ARCH initialization level
document new initialization level ARCH, used to init drivers/services
very early in the ARCH code and before z_cstart().

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 17:54:59 +02:00
Tomasz Moń 0e5c717434 doc: Fix kernel data structures typos
Add missing colons to properly render C references.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-10-10 21:01:51 -04:00
Tomasz Moń 800ec14cd3 doc: polling: Fix semaphore contested description
If a semaphore is contested, it is possible that the semaphore will no
longer be available when k_sem_take() is called, not k_sem_give().

Fix few typos and explicitly mention poll events instead of "they".

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2022-10-04 10:36:45 +02:00
Stephanos Ioannidis 74e6f70a63 doc: mailboxes: Remove memory block-related details
The commit c844bd87b3 removed the support
for passing a memory block (allocated in a memory pool) as message
data, but did not update the relevant documentation.

This commit removes any references to the memory block support, which
was removed in the v2.5.0 release, in the mailbox API documentation.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-28 14:24:34 +00:00
Stephanos Ioannidis 5eed8328ab doc: memory-domain: Remove stale reference to k_mem_pool
This commit replaces the stale reference to `k_mem_pool` with `k_heap`.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-28 14:24:34 +00:00
Henri Xavier 1a276d0ac6 ring_buffer: Introduce RING_BUF_ITEM_SIZEOF
Currently, to compute the 'item' size in a ring buffer, we have
`SIZE32_OF`.

Several issues with this:
- `SIZE32_OF` only works on variables, not types, due to an extra
 parenthesis pair. Indeed, `sizeof((int))` is not valid C, whereas
 `sizeof((my_var))` is.
- `SIZE32_OF` is not a proper public API
- `SIZE32_OF` rounds down if the argument size is not a multiple
 of 4 bytes.

Thus, we introduce a proper `RING_BUF_ITEM_SIZEOF`, fixing the
aforementioned issues.

Signed-off-by: Henri Xavier <datacomos@huawei.com>
2022-09-20 09:08:14 +00:00
Peter Mitsis d13a2544f7 doc: Update documentation related to pipes
The pipes implementation has been updated to allow ISRs to both
send and receive data to/from pipes provided the K_NO_WAIT timeout
option is used.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-08-17 19:31:25 +02:00
honglin leng 82e05894b7 docs: fix idle prio in cooperative mode
with cooperative mode , the idle prio should be 0

Signed-off-by: honglin leng <a909204013@gmail.com>
2022-08-09 12:28:00 +02:00
Peter Mitsis 0476d6ad69 doc: Update mutex priority inheritance description
Updates the priority inheritance description to better explain what
happens during priority inheritance and warn of the consequences of
not following best-practices.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-07-21 21:59:18 -04:00
Anas Nashif efbadbb677 scripts: move gen_kobject_list.py to scripts/build/gen_kobject_list.py
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Anas Nashif 6e1a335447 scripts: move gen_app_partitions.py to scripts/build
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 10:03:45 +02:00
Archie Atkinson 6cd8ef479f doc: change key properties from italic to bold
This is to keep it inline with the reset of the kernel docs

Signed-off-by: Archie Atkinson <archie.atkinson@chiaro.co.uk>
2022-06-28 16:17:32 +02:00
Carlo Caione b6a3d598f3 device_mmio: Introduce DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME
Currently the device MMIO APIs is only able to map single DT-defined
regions and also the _NAMED variant is assuming that each DT-defined
device has only one single region to map.

This is a limitation and a problem when in the DT are defined devices
with multiple regions that need to be mapped.

This patch is trying to overcome this limitation by introducing the
DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME macro that leveraged the 'reg-names'
DT property to map multiple regions defined by a single device.

So for example in the DT we can have a device like:

  driver@c4000000 {
    reg = <0xc4000000 0x1000>, <0xc4001000 0x1000>;
    reg-names = "region0", "region1";
  };

and then we can use DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME doing:

  struct driver_config config = {
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region0, DT_DRV_INST(0)),
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region1, DT_DRV_INST(0)),
  };

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-16 11:26:10 +02:00
Krzysztof Chruscinski 03e36855d3 doc: kernel: Add documentation to spsc_pbuf
Add documentation to spsc_pbuf module.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Stephanos Ioannidis 31b9d00e55 doc: develop: c: Add dynamic memory management documentations
This commit adds the sections describing how the dynamic memory
management is handled to the C language support and standard library
documentations.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-01 15:26:48 +02:00
Stephanos Ioannidis 5cee62acd1 doc: kernel: Re-organise memory management API pages
The kernel documentation listed the memory management API pages under
two different sections: 'Kernel/Kernel Services' and
'Kernel/Memory Management' -- this creates unnecessary confusion and
makes it hard to look up all supported kernel memory management APIs.

This commit relocates the memory management API pages under
'Kernel/Kernel Services' to 'Kernel/Memory Management' so that all
memory management APIs provided by the kernel are described in one
unified section.

The link to the 'Kernel/Memory Management' index page is still left in
the 'Kernel Services' page because it may still be helpful to look at
it as part of the services provided by the Zephyr kernel -- it is just
more substantial than the rest and deserves more visibility.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-01 15:26:48 +02:00
Stephanos Ioannidis c45a2213c6 doc: develop: Add 'Language Support' sub-category
This commit adds the 'Language Support' sub-category under the
'Developing with Zephyr' category with programming language support-
related documentations.

The contents of the 'C standard library' page have been relocated to
the 'C Language Support' page, and the contents of the 'C++ Support for
Applications' page have been relocated to the 'C++ Language Support'
page.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-01 15:26:48 +02:00
Stephanos Ioannidis 2598f0ed3c doc: toolchains: Add Zephyr SDK documentation
This commit adds a dedicated page for the Zephyr SDK under the
'Toolchains' sub-category under 'Developing with Zephyr'.

The content of this page is based on the Zephyr SDK installation
instruction from the 'Getting Started Guide'.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-01 15:26:48 +02:00
Archie Atkinson 26d2c12884 doc: fixes errors pipes wiki entry
Moves the 'Flushing a Pipe' code example to the correct location
and section and re-adds the 'Suggested Uses' text missing
compared to v2.7.

Signed-off-by: Archie Atkinson <archie.atkinson@chiaro.co.uk>
2022-05-20 12:38:37 +02:00
Aleksandar Markovic 7af3b8cbb3 doc: Fix links to Zephyr include directory on Github
At some recent point, directory <zephyr-root>/include was moved to
<zephyr-root>/include/zephyr. However, links from documentation to
Zephyr source on Github were not updated. Update them now.

Signed-off-by: Aleksandar Markovic <aleksandar.markovic.sa@gmail.com>
2022-04-21 18:35:16 -04:00
Yuval Peress 41e7f30d0f include: update documentation to use zephyr/ prefix
Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-21 07:40:54 -05:00
Carlo Caione 1dcea253d2 shared_multi_heap: Rework framework
Entirely rework the shared_multi_heap framework. Refer to the
documentation for more information.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-21 13:15:26 +02:00
Peter Mitsis 111865a8c5 doc: threads: Clarify ready/running states
Updates the threads documentation to clarify the distinction between
ready and running states.

Fixes 44255

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-04-20 10:25:59 -04:00
Anas Nashif a084be3ba9 doc: move sections from guides
Move remaining items from guides into the appropriate locations using
the new structure.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 6fe0a373fc doc: move misc services into OS Service section
Move remaining services from guides into OS services.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 6bc70460ff doc: move timeutil to kernel
Move this section under the kernel and alongside other core and low
level features that are tied to the kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif f2848a7761 doc: move memory management to kernel
Move this section under the kernel and alongside other core and low
level features that are tied to the kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 4206710cf2 doc: move utility functions to kernel
Move this section under the kernel and alongside other core and low
level features that are tied to the kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 88cb3eada5 doc: move timing functions under kernel
Move this section under the kernel and alongside other core and low
level features that are tied to the kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 74a67d995c doc: move data structures under kernel/
Move this section under the kernel and alongside other core and low
level features that are tied to the kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 6ccc614abe doc: move usermode under kernel
Move this section under the kernel and alongside other core and low
level features that are tied to the kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 38635f8899 doc: move kernel services under kernel
Move all kernel documentation under kernel/services.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 71f27a34ef doc: kernel: move cpu idling section to scheduling
Move cpu idling documentation to the scheduling section.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 06696bc1c5 doc: kernel: move polling/interrupts out of other/
Move out of others and make those two sections part of the core kernel
documentation.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 7f98259a45 doc: kernel section title
Change the kernel main title from 'Kernel Services' to the 'The Zephyr
Kernel'

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 087a8bfe25 doc: operation without threads
Revise text about disabling threading support.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif 8e9e0b7087 doc: move kernel docs as a main chapter
Move the kernel documentation up and make it a main chapter. Right now
it is hidden very low in the structure under references.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Anas Nashif d6f72a67fc doc: introduce final structure
Move guides and APIs into separate directories and cleanup naming
introducing index files rather than named section files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-02-05 07:04:40 -05:00
Andrew Boie c253a686bf app_shmem: auto-initialize partitions
There are no longer per-partition initialization functions.
Instead, we iterate over all of them at boot to set up the
derived k_mem_partitions properly.

Some ARC-specific hacks that should never have been applied
have been removed from the userspace test.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-01-30 23:15:51 -05:00
Andrew Boie 85e1fcb02a app_shmem: renamespace and document
The public APIs for application shared memory are now
properly documented and conform to zephyr naming
conventions.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-01-30 15:43:58 -08:00
Anas Nashif 47fc5095f8 doc: move version API to kernel
Move this last doxygen API to the kernel section.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-30 18:38:48 -05:00
Andrew Boie f278f31da1 app_shmem: delete parallel API for domains
The app shared memory macros for declaring domains provide
no value, despite the stated intentions.

Just declare memory domains using the standard APIs for it.

To support this, symbols declared for app shared memory
partitions now are struct k_mem_partition, which can be
passed to the k_mem_domain APIs as normal, instead of the
app_region structs which are of no interest to the end
user.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-01-29 11:11:49 -08:00
Anas Nashif 4bcb294f45 doc: move usermode API documentation
Move API reference to the main documentation section under the kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-24 09:16:03 -05:00
Anas Nashif 3499312249 doc: kernel: use zephyr_file role
Link to files in git tree on Github.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-24 09:16:03 -05:00
Anas Nashif 2dc4e270b2 doc: kernel: flatten kernel docs and add API references
Instead of having kernel APIs documentated in a separate page, move the
API references to the object pages and have everything in one place.

Remove the intermediate category page and list all section under the
kernel directly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-24 09:16:03 -05:00
Anas Nashif 29f37f0ddb doc: threads: merge into one document
Merge kernel sections into one single document and remove the
intermediate page grouping objects.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-24 09:16:03 -05:00
Anas Nashif bea9c6e88d doc: move kernel overview up
Put the kernel overview at the top level of the kernel documentation and
make it visible immediatly when browsing the kernel docs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-22 14:09:24 -05:00
Anas Nashif 218599d6b7 doc: move source structure to application/
This is the structure of the whole tree, not really related to the
kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-22 14:09:24 -05:00
Sebastian Bøe 1526070082 cmake: Use a variable for 'zephyr_prebuilt'
There is an effort underway to make most of the Zephyr build script's
reentrant. Meaning, the build scripts can be executed multiple times
during the same CMake invocation.

Reentrancy enables several use-cases, the motivating one is the
ability to build several Zephyr executables, or images, for instance a
bootloader and an application.

For build scripts to be reentrant they cannot be directly referencing
global variables, like target names, but must instead reference
variables, which can vary from entry to entry.

Therefore, in this patch, we replace global targets with variables.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-19 07:21:55 -05:00
Peter A. Bigot bfad9721d2 kernel: remove k_alert API
This API was used in only one place in non-test code.  See whether we
can remove it.

Closes #12232

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-01-16 21:34:07 -05:00
Anas Nashif 276c589dc3 doc: restructure documentation
With the new theme we are able to have more section in the top level.
Move things around and expose the most important sections in the top
table of content.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-07 10:31:51 -05:00
Anas Nashif 6b22a93286 doc: remove leading 'Zephyr' for some documentation sections
This is redundant information. We already know we are Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-07 10:31:51 -05:00
Andrew Boie 74f114caef userspace: easy checking for specific driver
In general driver system calls are implemented at a subsystem
layer. However, some drivers may have capabilities specific to
the hardware not covered by the subsystem API. Such drivers may
want to define their own system calls.

This macro makes it simple to validate in the driver-specific
system call handlers that not only does the untrusted device
pointer correspond to the expected subsystem, initialization
state, and caller permissions, but also that the device object
is an instance of a specific driver (and not just any driver in
that subsystem).

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-12-27 20:31:58 -05:00
Sathish Kuttan e275ae5e06 doc: kernel: add k_msgq_peek() API
Add documentation for k_msgq_peek()

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
2018-11-19 17:53:22 -05:00
Harry Jiang b0d2a7add7 doc: fix the example code typo
This commit fix the typo of k_poll_signal_raise() api example code

Signed-off-by: Harry Jiang <explora26@gmail.com>
2018-11-13 08:09:53 -05:00
Andrew Boie 110728af53 doc: add details about dynamic interrupts
Update interrupts.rst with information on how to use dynamic
interrupts. As they are used in the same way as IRQ_CONNECT(),
not much needs to be written.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-11-10 11:01:22 -05:00
Ioannis Glaropoulos e9432c6e94 doc: kernel: usermode: correct prefixes in app memory section
Application shared memory API uses 'appmem_' prefix for
its functions and macros. This commit updates the respective
documentation to align with the API convention.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-11-06 16:14:41 -05:00
Flavio Ceolin aecd4ecb8d kernel: Change k_poll_signal api
k_poll_signal was being used by both, struct and function. Besides
this being extremely error prone it is also a MISRA-C violation.
Changing the function to contain a verb, since it performs an action
and the struct will be a noun. This pattern must be formalized and
followed and across the project.

MISRA-C rules 5.7 and 5.9

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-11-04 11:37:24 -05:00
Paul Sokolovsky bd0ab78677 doc: usermode: Add missing "called" in _k_object_init() description
The phrase "object must have _k_object_init() on it at some point"
visibly misses "called".

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-11-01 16:36:26 -04:00
Ioannis Glaropoulos 3e02f38a38 kernel: mem_domain: minor typo fixes
Fixing a few minor typo fixes in kernel/mem_domain.c
and the respective documentation section.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-10-29 12:34:12 -04:00
Krzysztof Chruscinski 26031f7bfd lib: ring_buffer: add raw byte access mode
Extended ring buffer to allow storing raw bytes in it. API has been
extended keeping 'data item' mode untouched.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-10-09 13:58:44 -04:00
Krzysztof Chruscinski ff5f00f2c3 lib: ring_buffer: Rename sys_ring_buf_ to ring_buf_item_
Deprecate API prefixed with sys_ring_buf_ and rename it
to ring_buf_item_ since this API is not a typical ring buffer
but ring buffer of data items (metadata + 32bit words).

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-10-09 13:58:44 -04:00
David B. Kinder 3654752e2d doc: use https for docs.zephyrproject.org references
doc site now supports https access

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-09-10 17:46:34 -04:00
Ioannis Glaropoulos 56312cdd19 doc: fix minor typo in clock.rst
Remove redundant "is" in the description of Kernel system clock.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-09-04 11:56:03 -04:00
Ismael Fillonneau 84908fa2ff doc: kernel: usermode: fix macro name
_SYSCALL_HANDLER macro has not been updated to Z_SYSCALL_HANDLER

Signed-off-by: Ismael Fillonneau <ismael.fillonneau@stimio.fr>
2018-08-31 13:53:44 -04:00
Yasushi SHOJI 1f1307e1d6 doc: enhance multi-level interrupts diagram
Make the multi-level interrupts diagram more clear by saying:

  - the "-" means an interrupt slot
  - all interrupt slots are numbered from 0 starting from right most
  - alphabets denote devices
  - add an example chain for device D

Signed-off-by: Yasushi SHOJI <y-shoji@ispace-inc.com>
2018-08-30 10:52:59 -04:00
David B. Kinder 6750b8d2e8 doc: fix misspellings in docs
Occasional scan for misspellings missed during normal doc reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-08-08 01:49:14 -05: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
Rodrigo Peixoto f5e3813010 docs: Fix mailbox k_mbox_msg.tx_block documentation
- Replace old tx_block.pool_id to tx_block.data;
- Fix code examples.

Signed-off-by: Rodrigo Peixoto <rodrigopex@ayna.tech>
Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-06-14 18:00:17 -04:00
Andrew Boie 1fd8b139c8 doc: update syscall docs to new handler APIs
The syscall handler APIs were renamespaced and have
different semantics now.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-23 16:58:16 -04:00
Andy Ross 7aa25fa5eb kernel: Add "meta IRQ" thread priorities
This patch adds a set of priorities at the (numerically) lowest end of
the range which have "meta-irq" behavior.  Runnable threads at these
priorities will always be scheduled before threads at lower
priorities, EVEN IF those threads are otherwise cooperative and/or
have taken a scheduler lock.

Making such a thread runnable in any way thus has the effect of
"interrupting" the current task and running the meta-irq thread
synchronously, like an exception or system call.  The intent is to use
these priorities to implement "interrupt bottom half" or "tasklet"
behavior, allowing driver subsystems to return from interrupt context
but be guaranteed that user code will not be executed (on the current
CPU) until the remaining work is finished.

As this breaks the "promise" of non-preemptibility granted by the
current API for cooperative threads, this tool probably shouldn't be
used from application code.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-05-23 14:25:52 -04:00
Andrew Boie 2b9b4b2cf7 k_queue: allow user mode access via allocators
User mode may now use queue objects. Instead of embedding the kernel's
linked list information directly in the data item, a container struct
is allocated from the caller's resource pool which is then added to
the queue. The new sflist type is now used to store a flag indicating
whether a data item needs to be freed when removed from the queue.

FIFO/LIFOs are derived from k_queues and have had allocator functions
added.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-17 23:34:03 +03:00