Commit graph

123 commits

Author SHA1 Message Date
Carlo Caione 15e84cbfac dts: Move to 'zephyr,memory-attr'
Move to 'zephyr,memory-attr' and use the newly introduced helpers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-25 11:22:10 +02:00
Daniel Leung 90f388e9b2 linker: mark priv_stacks_noinit as NOLOAD
Currently priv_stacks_noinit is being put onto the flash waiting
to be copied into memory at boot. This is a waste of flash space
as priviledge stacks are initialized at runtime. So mark
the linker section as NOLOAD to save some flash space.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-07-24 11:08:50 -04:00
Patryk Duda b25dc410de zephyr/linker: Add NOLOAD attribute to .last_ram_section
Currently, this section has LOAD flag which means that it's part of
image layout. Attempt to generate binary file with --gap-fill results in
creating a very big file, because LMA of the section is RAM address
(e.g. 0x20000000 for STM32F4) instead of FLASH (e.g. 0x8000000 for
STM32F4).

This problem doesn't appear when linking using GNU LD, because it
removes the section in garbage collect process. However, LLVM LLD
doesn't garbage collect sections that define used symbols, so the
section is present in final ELF image.

There is no need to load this section (it has 0 size), so we can safely
add NOLOAD attribute to the section.

Fixes: #57727

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-07-05 12:34:48 +00:00
Patryk Duda fad8ae4052 linker: Introduce linker-tool-lld.h
Until now, linker-tool-gcc.h was used when LLD linker was chosen.
This causes linking issues because for GNU LD we use ALIGN_WITH_INPUT
attribute which is not available in LLVM LLD.

When using GNU LD we have to use ALIGN_WITH_INPUT to make sure that the
difference between VMA and LMA remains the same between output sections
that have different memory regions for VMA and LMA (RAM and FLASH).
With ALIGN_WITH_INPUT it's safe to do the memcpy of sections
that needs to be copied from flash to RAM in one function call:

(from z_data_copy() in kernel/xip.c)
```
z_early_memcpy(&__data_region_start, &__data_region_load_start,
               __data_region_end - __data_region_start);
```

By default, LLVM LLD aligns both VMA and LMA to the same value, but
when --omagic (-N) option is provided then only the first output section
of given region has aligned LMA and the difference between VMA addresses
(0 is this is the first section) is added.

As a result the difference between LMA and VMA is constant for every
section, so this emulates ALIGN_WITH_INPUT option present in GNU LD
(required by XIP systems).

The --omagic flag is defined in cmake/linker/lld/target_baremetal.cmake

Example:
```
MEMORY {
  ROM : ORIGIN = 0x1000, LENGTH = 1K
  RAM : ORIGIN = 0x11000, LENGTH = 1K
}
SECTIONS {
  .text 0x1000 : {
  	*(.text*)
  } >ROM

  .data.rel.ro : {
  	*(.data.rel.ro)
  } >RAM AT>ROM

  .data : {
  	*(.data*)
  } >RAM AT>ROM
}
```

```
echo '.globl _start; _start: nop; .byte 1;'\
     '.data.rel.ro; .balign 16; .byte 0;'\
     '.data; .balign 32; .byte 0;' | \
     llvm-mc -filetype=obj -triple=arm - -o test.o

armv7m-cros-eabi-ld.lld --sort-section=alignment -N -T script.ld \
     test.o -o lld_out
```

```
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000005  00001000  00001000  00000094  2**2
  1 .data.rel.ro  00000001  00011000  00001010  000000a0  2**4
  2 .data         00000001  00011020  00001030  000000c0  2**5
```

In this example the first section has lower alignment than the following
section, but with -N option the difference between VMA and LMA is the
same for .data.rel.ro and .data sections.

For comparison, using BFD linker with --omagic option results in the
following:
```
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000005  00001000  00001000  00000094  2**2
  1 .data.rel.ro  00000001  00011000  00001005  000000a0  2**4
  2 .data         00000001  00011020  00001006  000000c0  2**5

```

with ALIGN_WITH_INPUT added, GNU LD adds the difference between VMA to
LMA, but doesn't align LMA of .data.rel.ro section:
```
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000005  00001000  00001000  00000074  2**2
  1 .data.rel.ro  00000001  00011000  00001005  00000080  2**4
  2 .data         00000001  00011020  00001025  000000a0  2**5
```

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-07-05 12:33:42 +00:00
Keith Packard 710422ec5e include/zephyr: Fix linker scripts to define _end after all static RAM data
The Zephyr linker scripts have inconsistent ordering of various chunks of
data which lands in RAM at runtime. This leads to the value of _end not
being consistently defined as the maximum address of static variables used
in the application.

Create a helper linker fragment, zephyr/linker/ram-end.ld, which can be
included after the last possible definition of RAM data, that consistently
sets _image_ram_end, _end and z_mapped_end.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-06-28 08:41:02 +00:00
Gerard Marull-Paretas 319fbe57e1 device: s/HAS_DYNAMIC_DEVICE_HANDLES/DEVICE_DEPS_DYMAMIC
Rename the Kconfig option to be in line with recent renamings in device
handles/dependencies.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Gerard Marull-Paretas 8bee39edff device: s/device_handles/device_deps/ in linker scripts
Use the "device_deps" naming scheme to emphasize we are storing device
dependencies. The fact we are using device handles to store them is an
implementation detail.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-21 09:32:05 +02:00
Guangfu Hu 335278d60a sensing: initial sensor list and enumerate each sensor
Implement sensing_init():
	1) create sensors from device tree
	2) sequence sensors following node dependency ordering rule generated by
	   Zephyr DTS
	3) initial each sensor, includes:
		a) creating sensor connection between reporter and client,
		b) calling sensor init callback,
		c) setting sensor state
Implement sensing_open_sensor():
	1) malloc connection from reporter to application
	2) bind connection
Implement sensing_close_sensr():
	1) unbind connection
	2) free connection from reporter to application
Implement sensing_set_config():
	1) call set_interval
	2) cann set_sensitivity
Implement sensing_get_config():
	1) call get_interval
	2) call get_sensitivity

Signed-off-by: Guangfu Hu <guangfu.hu@intel.com>
2023-06-17 07:43:25 -04:00
Flavio Ceolin c22c4fd49f linker: Fix __stackmem section with CONFIG_KERNEL_COHERENCE
When building whith CONFIG_KERNEL_COHERENCE enabled,
__stackmem was not being put in the user_stack section making
impossible to gen_kobject script find user capable stacks.

It is responsability of the platform to put user_stacks
section in the appropriated region.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-27 06:33:17 -04:00
Yuval Peress ca5bf10143 sensor_shell: Update to new sensor_read API
Update the sensor shell logic to use the new sensor_read() APIs and
make triggers an option of the sensor_shell sample (this avoids the
trigger stealing the interrupt status from one-shot reads).

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-26 11:04:54 -05:00
Yuval Peress ed380de152 sensors: Add new async one-shot reading API
Add a new async API based on the RTIO subsystem. This new API allows:
1. Users to create sampling configs (telling the sensor which channels
   they want to sample together).
2. Sample data in an asynchronous manner which provides greater control
   over the data processing priority.
3. Fully backwards compatible API with no driver changes needed for
   functionality (they are needed to improve performance).
4. Helper functions for processing loop.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-26 11:04:54 -05:00
Gerard Marull-Paretas dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00
Gerard Marull-Paretas d0e58ad0a6 device: use iterable sections
Use iterable sections to handle devices list. This simplifies devices
implementation by using standard APIs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Gerard Marull-Paretas b8efac92e0 linker: add ITERABLE_SECTION_RA|OM_NUMERIC
In some cases, like devices, it is necessary to sort numerically, that
is, sort 10 before 2. Add a new helper function to do that, up to 2
numeric digits.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-12 12:01:10 +02:00
Evgeniy Paltsev 4e81b0e081 linker: restore CREATE_OBJ_LEVEL wildcard pattern
The 2c98a001a4 (#57597) cause
regression with ARC MWDT toolchain.

Restore CREATE_OBJ_LEVEL wildcard pattern to be suitable for
both GNU and MWDT toolchains. We return asterisk symbol which
was dropped in 2c98a001a4
(but keep rest of the changes to wildcard pattern).

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2023-05-11 19:44:37 +02:00
Gerard Marull-Paretas 2c98a001a4 linker: align CREATE_OBJ_LEVEL and zephyr_linker_section_obj_level
Use the same wildcard pattern for sorting. Note that the range wildcard,
e.g. [0-9], can't be used as not all linkers support it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-09 11:03:06 -05:00
Tom Burdick ea8930bd78 rtio: Cleanup the various define macros
Reworks the zephyr macros and pools to be objects in their own right. Each
pool can be statically defined with a Z_ private macro. The objects can
then be initialized with an rtio instance statically.

This cleans up a lot of code that was otherwise doing little bits of
management around allocation/freeing and reduces the scope those functions
has to the data it needs.

This should enable sharing the pools of sqe, cqe, and mem blocks among rtio
instances in a future improvement easily.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-10 00:39:43 +09:00
Tom Burdick e4b10328b4 rtio: Use mpsc for submission and completion queue
Rather than the rings, which weren't shared between userspace and kernel
space in Zephyr like they are in Linux with io_uring, use atomic mpsc
queues for submission and completion queues.

Most importantly this removes a potential head of line blocker in the
submission queue as the sqe would be held until a task is completed.

As additional bonuses this avoids some additional locks and restrictions
about what can be submitted and where. It also removes the need for
two executors as all chains/transactions are done concurrently.

Lastly this opens up the possibility for a common pool of sqe's to
allocate from potentially saving lots of memory.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-10 00:39:43 +09:00
Kumar Gala b07be57875 logging: Use TYPE_SECTION macros for log dynamic
Clean up log_dynamic to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Kumar Gala bae0a5b8b6 logging: Use TYPE_SECTION macros for log const
Clean up log_const to utilize macros for handling sections.

Update database_gen.py to match naming convention change.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-05-03 10:43:31 +02:00
Krzysztof Kopyściński 0a55ec8d52 Bluetooth: Mesh: Add callback for received beacons
This adds callbacks for Secure and Private Network Beacons.
SNB callbacks are called after `secure_beacon_authenticate` ends
with success, and Private Beacon callback after Private Beacon
payload is decrypted succsessfully.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2023-04-24 13:36:12 +02:00
Kumar Gala 30653bfbed console: uart_mux: Use TYPE_SECTION macros for uart_mux
Clean up uart_mux to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-21 12:55:38 +02:00
Kumar Gala caea9dc196 logging: Use TYPE_SECTION macros for log strings
Clean up log_strings to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:52:07 +02:00
Kumar Gala 301d0c4712 net: buf: cleanup net_buf_pool use of iterable section
Cleanup linker scripts for net_buf_pool section to use the linker
script related iterable section macros.

Also replace _net_buf_pool_list with macro's instead to complete
iterable section usage.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-20 10:50:04 +02:00
Kumar Gala eec299c130 pm: Use TYPE_SECTION macros for pm_device_slots
Clean up pm_device_slots to utilize TYPE_SECTION macros for handling
sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:15:29 +02:00
Kumar Gala 47cf00058e fb: cfb: Use TYPE_SECTION macros for cfb_fonts
Clean up cfb_fonts to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:54 +02:00
Kumar Gala 7469ad426a drivers: pcie: Use TYPE_SECTION macros for irq_alloc
Clean up irq_alloc to utilize TYPE_SECTION macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:46 +02:00
Kumar Gala 5b5fbc4c11 shell: remove dead linker section for shell
The initshell sections in the linker scripts where associated with theo
old shell code.  The old shell code has been removed for some time so
remove references to initshell in the linker scripts and size_calc.py

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-19 17:14:37 +02:00
Kumar Gala 1105fa9092 rtio: Remove unused linker section
rtio is utilizing iterable sections so the explicit linker
code does not need to exist so we can remove it.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-18 12:21:24 -04:00
Kumar Gala 6b5139c4bb shell: Convert to using iterable sections
Convert handling of shell_root_cmds, shell_subcmds, and
shell_dynamic_subcmds to use iterable section macros.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-18 12:48:16 +02:00
Kumar Gala 5c4d184016 emul: Use STRUCT_SECTION macros for emul devices
Clean up emulator code to utilize macros for handling sections.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-08 12:33:54 +02:00
Fabio Baltieri 9889e8e20a input: move the listener section in common-rom
Move the input listener section declaration in common-rom-misc.ld
instead of using a custom input.ld file. This seems to be the common
practice for upstream iterable sections and seems to solve a
compatibility issue where the section was getting allocated incorrectly
on esp32 based platforms.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-20 12:56:18 -07:00
Chris Friedt 79d4107beb net: http: define http service and resource iterable sections
Provide a means of declaring zero or more HTTP services, each
with zero or more static HTTP resources.

Static HTTP resources are those which have fixed paths[1] which
are known prior to system initialization. Some examples of
static http resources would be

* a forwarder from '/' to '/index.html'
* a REST endpoint with fixed path '/api/foo' and detail
  pointing at some implementation-specific function
* a Javascript file in string form with fixed path '/js/util.js'
* a 'construction' image with path '/res/work.png'
* a gzip-compressed 'Hello' HTML file at '/hello.html'

Without describing in any detail how static HTTP resources are
organized or served by any given HTTP server, we can describe
what static resources exist on a system in a common way that
does not require any optional facilities (e.g. filesystem) and
relies only on addressable memory.

Additionally, for the purposes of simply allowing others
to implement custom HTTP servers in a consistent way, or
benchmarking implementations, or having a consistent testsuite
to use across multiple implementations, it is helpful to have
a common method to declare HTTP services and static resources
for Zephyr.

[1] https://en.wikipedia.org/wiki/URL

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-08 13:57:13 +00:00
Stephanos Ioannidis 404e7a9bf7 treewide: Use CONFIG_CPP_EXCEPTIONS instead of CONFIG_EXCEPTIONS
This commit updates all in-tree code to use `CONFIG_CPP_EXCEPTIONS`
instead of `CONFIG_EXCEPTIONS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis 4a64bfe351 treewide: Use CONFIG_CPP instead of CONFIG_CPLUSPLUS
This commit updates all in-tree code to use `CONFIG_CPP` instead of
`CONFIG_CPLUSPLUS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Flavio Ceolin 02d5290e07 linker: kobject: Handle literal section
Add kobject_data prefix to kobject literals and group it close to
text area to avoid changing .text addresses in the final linkage.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-02 11:05:06 +01:00
Jamie McCrae d7557102c0 mgmt: mcumgr: Add iterable section to register MCUmgr handlers
This replaces the requirement for applications to manually
register MCUmgr handlers by having an iterable section which
then automatically registers the handlers at boot time.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-22 11:03:04 +01:00
Flavio Ceolin e3aac24821 xtensa: linker: Use zephyr's convention for rodata
Zephyr maps start/end of rodata section with variables
using __rodata_region namespace. The exception was Xtensa.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-11-17 15:44:48 +09:00
Nikolay Agishev 6e215ce6af boards: nsim_hs: Add separate config for XIP memory organization
Add XIP support with MWDT toolchain. To have it proper tested
add separate nsim platforms for XIP (flash + sram) and
non-XIP (sram) memory organization in addition to existing
nsim_hs platfor with CCMs (ICCM + DCCM) memory organization.

This PR also enables MPU for all nsim hs3x based platforms
(like we previously enabled it for qemu_arc_hs) to have proper
memory regions permissions.

Signed-off-by: Nikolay Agishev <agishev@synopsys.com>
2022-11-16 11:18:51 +01:00
Johan Hedberg 0eed096f99 pcie: Add support for centralized lookup of BDF values
The BDF values can differ on the same platform, based on e.g. BIOS
configuration, and in the case of qemu the command line parameters. It's
therefore more reliable to always look up the BDF value based on the
known Vendor and Device IDs.

This patch introduces such a framework, and allows the incremental
update of PCIe drivers to start taking advantage of it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2022-11-16 11:18:43 +01:00
Gerard Marull-Paretas 4f4ca3905d linker: devicetree_regions: add missing includes
The devicetree_regions.h did not include any header, however, it uses
multiple APIs: DT, utils and toolchain macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-11 11:00:26 +01:00
Tom Burdick e3d877f811 rtio: Userspace support
Add support for userspace with RTIO by making rtio and rtio_iodev
k_objects. As well as adding three syscalls for copying in submissions,
copying out completions, and starting tasks with submit.

For the small devices Zephyr typically runs on one of the most important
attributes tends to be low memory usage. To maintain the low footprint of
RTIO and its current executor implementations the rings are not shared with
userspace. Sharing the rings it turns out would require copying submissions
before working with them to avoid TOCTOU issues.

The API could still support shared rings in the future so that a
kernel thread could directly poll, copy, verify, and start the submitted
work. This would require a third executor implementation that maintains its
own copy of submissions similiar to how io_uring in Linux works.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-11-08 10:44:03 +01:00
Maureen Helm eee3d8f566 drivers: sensor: Add sensor info iterable section
Adds an iterable section in ROM to hold constant information, such as
vendor and model name, for all enabled sensor driver instances. This
will be used by the future sensor subsystem to enumerate all available
sensors in the system.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-31 11:21:37 +01:00
Krzysztof Chruscinski e322447109 logging: Initial multidomain support
Adding multidomain support by introducing log_link module which
acts as a receiver of log messages created by another domain.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-17 10:16:53 +02: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 e8395351e6 kernel: init: introduce a new init level: ARCH
We have cases where some devices needs to be initialized very early and
before c_start is call, i.e. to setup very early console or to setup
memory. Traditionally this would be hardcoded as part of the soc layer
and not using device model or the init levels.

This patch adds a new level ARCH, which will be called in early
architecture code and before we jump to the kernel code.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 08:28:25 -04:00
Keith Short d823f88e3b kernel: move _static_thread_data to ROM
Move the _static_thread_data created by K_THREAD_DEFINE to ROM. This
change also deletes the unused .init_abort field from the static
thread data.

Signed-off-by: Keith Short <keithshort@google.com>
2022-10-04 17:24:14 +00:00
Krzysztof Chruscinski e6bbc6941a logging: Use STRUCT_SECTION macros for log backend
Clean up logging code to utilize macros for handling sections.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-10-03 10:11:03 +02:00
Stephanos Ioannidis ed13880f1d linker: Remove k_mem_pool section
This commit removes the `k_mem_pool` section for the memory pool API,
which was removed in the v2.5.0 release.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-28 14:24:34 +00:00
Stephanos Ioannidis 40bbf78d77 arch: arc: Rename ARC64 output format to elf64-littlearc64
This commit renames the ARC64 output format from `elf64-littlearc` to
`elf64-littlearc64` as required by the updated ARC patches for the GCC
12.1 release.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-29 16:57:18 +02:00
Yuval Peress 84dfb8edf8 ztest: allow asserts anywhere
Updates the ztest_test_fail() function to allow failures in setup.
When executed, a failed assert will fail every test in the suite owning
the setup function. This was verified by adding a suite which asserts
in the setup function and has a test that should pass. During
exeuction, ztest marks the test as failing.

In order to verify exection I also added 2 new APIs:
- ZTEST_EXPECT_FAIL(suite_name, test_name)
- ZTEST_EXPECT_SKIP(suite_name, test_name)

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-09 13:30:15 -04:00
Benjamin Björnsson 2399145406 include: zephyr: Add missing guard macro
Add guard macros to header files for consistency.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-20 13:39:23 -05:00
Anas Nashif 76f990af8a intel_adsp: move attribute macros to dedicated linker header
Those belong where other attribute macros are usually defined. They are
not xtensa or ADSP specific and are used across Intel SoCs on all
architectures.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 11:15:46 -04:00
Anas Nashif d5dcf20382 scripts: move gen_kobject_placeholders.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
Carlo Caione 8c4f98d263 linker: Fix _vector_end symbol location
The 219d5b5adb commit is breaking the STM32F0 platforms.

The problem is that the PR is changing the location the _vector_end
symbol is pointing to. These platforms require the symbol to be pointing
to a location in memory after the IRQ vector table.

Fix the issue by introducing a new _vector_end symbol when the IRQ
vector table is present that points to the correct location.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-07-05 15:40:55 +00:00
Krzysztof Chruscinski abe1eb6ced toolchain: Add macro for keeping a symbol in the binary
Add LINKER_KEEP macro which can be used to prevent linker garbage
collector from removing unused symbol (function or variable).

Example use case is to use it for functions which are part of a test
application which has functions which are indirectly called by the
host test tools. Since they are not called explicitely by the
application so without marking them with LINKER_KEEP they would be
removed by the linker garbage collector.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-07-01 11:33:30 +02:00
Carlo Caione 3a48365bab irq: Fix IRQ vector table relocation
The generation of the software ISR table and the IRQ vector table
(respectively generated by CONFIG_GEN_SW_ISR_TABLE and
CONFIG_GEN_IRQ_VECTOR_TABLE) should (in theory) go through three stages:

1. A placeholder table is generated in arch/common/isr_tables.c and
   placed in an orphaned .gnu.linkonce.{irq_vector_table, sw_isr_table}
   section

2. The real table is generated by arch/common/gen_isr_tables.py (creating
   the build/zephyr/isr_tables.c file)

3. The real table is un-orphaned by moving it in a proper section with a
   proper alignment

While all the steps are done automatically for the software ISR table,
for the IRQ vector table each architectures must take care of modiying
its own linker script to place somewhere the generated IRQ vector table
(basically step 3 is missing).

This is currently only done for 2 architectures: Cortex-M (ARMv7) and
ARC. But when another architecture tries to use the IRQ vector table,
the linker complains about that. For example:

  Linking C executable zephyr/zephyr.elf
  riscv64-zephyr-elf/bin/ld.bfd: warning: orphan section
    `.gnu.linkonce.irq_vector_table' from
    `zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj' being placed in
    section `.gnu.linkonce.irq_vector_table'

In this patch we introduce a new CONFIG_ARCH_IRQ_VECTOR_TABLE_ALIGN to
support the architectures requiring a special alignment for the IRQ
vector table and we also introduce a way to automatically place the IRQ
vector table in place in the same way it is done for the ISR software
table.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-28 12:29:42 +02:00
David Palchak b4a7f0f2ca linker: ensure global constructors only run once
Rename the symbols used to denote the locations of the global
constructor lists and modify the Zephyr start-up code accordingly.
On POSIX systems this ensures that the native libc init code won't
find any constructors to run before Zephyr loads.

Fixes #39347, #36858

Signed-off-by: David Palchak <palchak@google.com>
2022-06-09 11:33:36 +02:00
Carlo Caione 86bb739b7b reserved_memory: Remove it and cleanup
The reserved memory mechanism (sections and regions definition) has been
entirely replaced, greatly extended and made it better by the work done
on the zephyr,memory-region compatible.

Since there is are no actual users, we can remove it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-07 09:41:57 -07:00
Georgij Cernysiov 70003e8eb0 dts: bindings: mpu: add PPB and IO regions
Extends #43119 with PPB and IO values of
`memory-region-mpu`.

That allows MPU region definition with
PPB or IO attributes in the DTS.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-06-05 14:46:11 +02:00
Yuval Peress 86cadf9283 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Evgeniy Paltsev 48301dde0f ARC: ARCv3: add HS5x support
Add HS5x CPU support - ARCv3 32bit ISA.

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2022-05-10 14:12:25 -04:00
Gerard Marull-Paretas d342e4c4c1 linker: update files with <zephyr/...> include prefix
Linker files were not migrated with the new <zephyr/...> prefix.  Note
that the conversion has been scripted, refer to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:45:29 -04:00
Gerard Marull-Paretas fb9b3bcd93 include: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all includes within
include directory to the new prefix <zephyr/...>. Note that the
conversion has been scripted, refer to zephyrproject-rtos#45388 for more
details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:03:00 +02:00
Krzysztof Chruscinski 3ee5c57934 shell: Add new way of adding subcommands
Added macro SHELL_SUBCMD_SET_CREATE which creates a set of subcommands.
SHELL_SUBCMD_ADD and SHELL_SUBCMD_COND_ADD can be used from any file to
add command to the set. This approach allows to have subcommands added
from multiple files.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-04-29 14:54:08 +02:00
Anas Nashif 462b13e16e Revert "ztest: Fix userspace ztests in new API"
This reverts commit 900b6723e7.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-26 18:55:32 -04:00
Yuval Peress 900b6723e7 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-26 14:29:18 -04:00
Daniel Leung c6f6dd0ddd linker: split common-rom.ld into smaller snippets
This splits common-rom.ld into smaller snippets so that these
chunks can be placed at different locations if so desired.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-26 14:26:53 -04:00
Yuval Peress 3b5c61d618 include: Update references for devicetree.h
Use zephyr/ prefix for devicetree.h includes.

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-21 07:40:54 -05:00
Flavio Ceolin 370ce60152 linker: Re-use device handle logic
Add a new file with the device handles logic that is included in both
ram and ROM

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Flavio Ceolin 0b13b44a66 pm: device: Dynamically add a device to a power domain
Add API to add devices to a power domain in runtime. The number of
devices that can be added is defined in build time.

The script gen_handles.py will check the number defined in
`CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC` to resize the handles vector,
adding empty slots in the supported sector to be used later.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-04-18 17:25:01 -07:00
Szymon Czapracki af2e781f5a Bluetooth: Immediate Alert Service
This commits adds IAS for zephyr bluetooth.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-04-12 09:59:34 +02:00
Yuval Peress 53ef68d459 include: Prefix includes to use a scope
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
  example: <irq.h> -> <zephyr/irq.h>

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-08 19:03:32 +02:00