If SYS_CLOCK_EXISTS is not enabled, then the SYS_CLOCK_HW_CYCLES_PER_SEC
still gets created, but with no value. This causes the code generation
in misc/generated/CMakeLists.txt to create an empty assembly macro:
`.equ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC,`
which then causes a build error.
Disable SYS_CLOCK_HW_CYCLES_PER_SEC entirely when SYS_CLOCK_EXISTS is
disabled to fix this.
This is a follow-up to 03f46db859.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Introduce work timeout, which is an optional workqueue configuration
which enables monitoring for work items which take longer than
expected. This could be due to long running or deadlocked handlers.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Sets the default for CONFIG_TIMESLICE_SIZE to 20 to approximate the
historical clamping behavior that was removed in 405611d.
Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
Handle both of these sections in a single chunk of code instead of
separately. We don't need to use the legacy .ctors ABI as both
the constructors array and startup logic are managed within a single
link result.
This can now also be used with ARC MWDT which had been using the .ctors
sections but with .init_array semantics. For ARC MWDT, we now always
discard .dtors and .fini sections as Zephyr will never cause global
destructors to execute. Stop discarding .eh_frame sections so that
exception handling works as expected.
When building a NATIVE_APPLICATION, we ask the native C library to run all
of the constructors to ensure any non-Zephyr constructors are run before
main is invoked. It might be "nice" to split the constructors so that the
Zephyr constructors were executed by the Zephyr code while the non-Zephyr
ones were executed by the native C library. I think that could be done if
we knew the pathnames of either the Zephyr or non-Zephyr files. That might
make a good future enhancement.
Signed-off-by: Keith Packard <keithp@keithp.com>
Improve naming of the scheduler and call it what it is: simple. Using
'dumb' for the default scheduler algorithm in Zephyr is a bad idea.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
CONFIG_DYNAMIC_BOOTARGS currently depends on CONFIG_MULTIBOOT_INFO
and CONFIG_BUILD_OUTPUT_EFI which are x86 specific.
This change removes those dependencies so that another architecture
can use CONFIG_DYNAMIC_BOOTARGS without the x86 specifc features.
Signed-off-by: William Tambe <williamt@cadence.com>
Fix compilation with CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y and
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC unset at the board/SoC level.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
Setting CONFIG_NUM_PREEMPT_PRIORITIES to 128 causes the idle thread to be
assigned priority 128, which exceeds the int8_t range. This results in the
idle thread being assigned the highest priority (-128) instead of the
lowest, causing threads to not wake up from k_sleep.
Restrict the range of CONFIG_NUM_PREEMPT_PRIORITIES to 0 to 127 to ensure
the idle thread always has the lowest priority.
Signed-off-by: Jonas Spinner <jonas.spinner@burkert.com>
The `k_pipe_*` API has been reworked to provide a more consistent and
intuitive interface. The new API aims to provide a simple to use byte
stream interface that is more in line with the POSIX pipe API.
The previous API has been deprecated and will be removed in a future
release.
Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
Mostly a revert of commit b1def7145f ("arch: deprecate `_current`").
This commit was part of PR #80716 whose initial purpose was about providing
an architecture specific optimization for _current. The actual deprecation
was sneaked in later on without proper discussion.
The Zephyr core always used _current before and that was fine. It is quite
prevalent as well and the alternative is proving rather verbose.
Furthermore, as a concept, the "current thread" is not something that is
necessarily architecture specific. Therefore the primary abstraction
should not carry the arch_ prefix.
Hence this revert.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
STACK_CANARIES was enabling canaries in all functions using the compiler
flag -fstack-protector-all. This became confuse with the addition of the
options STRONG and EXPLICIT.
This commit adds the missing option (default level) and disambiguous the
options mapping them close to the compiler flags.
Now we have the following options:
STACK_CANARIES -> fstack-protector
STACK_CANARIES_STRONG -> fstack-protector-strong
STACK_CANARIES_ALL -> fstack-protector-all
STACK_CANARIES_EXPLICIT -> fstack-protector-explicit
Note that from now on STACK_CANARIES_ALL is the symbol that adds canaries
for all functions.
Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
Add option to enable stack canaries only when explicitely
declared. It adds a new function attribute, __stack_protect, that
can be used to enable stack protection in a function.
Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
Previously, when stack canaries were enabled, Zephyr applied this
protection to all functions. This commit introduces a new option that
allows stack canary protection to be applied selectively to specific
functions based on certain criteria.
Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
Makes the validation of both allocated memory slab pointer and the
memory slab pointer to free configurable.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
`_current` is now functionally equals to `arch_curr_thread()`, remove
its usage in-tree and deprecate it instead of removing it outright,
as it has been with us since forever.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This reverts commit 6d4031f96c.
Those makes majority of builds og platforms with blobs tainted although
the blob were not used or compiled in. So it is very misleading.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Due to the (potentially) hard to understand effects of blobs, it seems
prudent to make their presence more noticeable.
With this change, whenever blobs are present in the Zephyr work space,
the hello world sample output looks like this:
> *** Booting Zephyr OS build (tainted) v3.7.0-4569-gd4f8765ef20e ***
> Hello World! esp32c3_devkitm/esp32c3
Before, it looked like this:
> *** Booting Zephyr OS build v3.7.0-4568-g69c47471d187 ***
> Hello World! esp32c3_devkitm/esp32c3
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
x86 architectures require a dynamic stack size that is a multiple
of 4096 bytes due to mmu restrictions.
For example, this test would previously fail when using the
default dynamic stack size of 1024 bytes for 32-bit
platforms.
```
west build -p auto -b qemu_x86/atom/nopae -t run \
tests/posix/common/ -- -DCONFIG_USERSPACE=y
```
It would pass with an additional argument
```
west build -p auto -b qemu_x86/atom/nopae -t run \
tests/posix/common/ -- -DCONFIG_USERSPACE=y \
-DCONFIG_DYNAMIC_THREAD_STACK_SIZE=4096
```
Add a special default for x86 when using dynamic thread stacks.
The x86 default removes the need for `boards/qemu_x86*.conf`,
with the exception of `qemu_x86_tiny`.
qemu_x86_tiny did not have sufficient memory (or configuration)
to run the non-userspace tests, so bump up the available ram
from 256k to 512k for this test and clone the .conf from the
demand paging tests.
Eventually, the common posix test should be split into more
concise functional categories.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Introduce soc and board hooks to replace arch specific code
and replace usages of SYS_INIT for platform initialization.
include/zephyr/platform/hooks.h introduces the hooks to be implemented
by boards and SoCs.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add bootargs support to zefi. This implements
get_bootargs() when both efi and bootargs are
selected in config.
Signed-off-by: Jakub Michalski <jmichalski@internships.antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Add bootargs support for multiboot. This
implements get_bootargs() when multiboot and
bootargs are selected in config.
Signed-off-by: Jakub Michalski <jmichalski@internships.antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Add support for passing args to main(). The
content of bootargs is taken from get_bootargs()
which should be implemented for each loader and
then its split into args and passed to main.
Signed-off-by: Jakub Michalski <jmichalski@internships.antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
The intention of this API is to allow setting the posix thread
name equal to the zephyr thread name.
By defining it as an arch interface, the implementation becomes
generic.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `kernel` directory.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
native_posix (unlike native_sim) or its breathen (NATIVE_APPLICATION)
link together the "runner" code and the embedded code.
This means that when CONFIG_STATIC_INIT_GNU is set,
any host library code (like the llvm fuzzer) constructors will get
postponed to the Zephyr initialization.
These libraries are unlikely to work if we do this.
(the llvm fuzzer does not)
So let's instead not enable STATIC_INIT_GNU for these targets.
This means possible embedded library constructors will continue to be
picked during the link and be still called during the native runner
initialization instead of during the Zephyr OS initialization as they
were just before we introduced STATIC_INIT_GNU in
6e977ae2d5
Note that native_posix will be deprecated shortly and its users
are strongly encouraged to move to native_sim.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
* Move ctors and init_array from the CPP library
to the kernel library, as this is common for both C
and C++ and it is the kernel who is running it.
* Rename the hidden kconfig option CPP_STATIC_INIT_GNU
STATIC_INIT_GNU instead.
* If STATIC_INIT_GNU is not selected verify there is
constructors left behind.
* Rename common-rom-cpp.ld to common-rom-init.ld
* Rename z_cpp_init_static to z_init_static,
and have the kernel always call it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Signed-off-by: Keith Packard <keithp@keithp.com>
On each reboot, this option causes the serial output to start top-left
on the users terminal, simplifying (human) parsing.
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
Updates the CONFIG_PIPES Kconfig description to add a note that
enabling it will cause a slight increase to the thread structure.
This mirrors a similar comment in CONFIG_EVENTS.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Dynamic code execution applications not using LLEXT for "extension"
loading are subject to the same linker optimization symbol resolution
issue described in commit 321e395 (in summary, libkernel.a syscalls
not used directly by the application result in weak symbol resolution
of their z_mrsh_ wrapper).
To support usecases where an application is using alternative methods
to load and execute code calling syscalls (likely from userspace) or
is using a mechanism where the linker may not be aware, the configuration
option has been decoupled from CONFIG_LLEXT (who is now a selector) to
KERNEL_WHOLE_ARCHIVE.
Signed-off-by: Daniel Apperloo <daniel.apperloo@intel.com>
update kernel timeout logic based on retrieve system timer clock
frequency at runtime or static way based on Kconfig
TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
Signed-off-by: Najumon B.A <najumon.ba@intel.com>
This introduces support for memory mapped thread stacks,
where each thread stack is mapped into virtual memory
address space with two guard pages to catch
under-/over-flowing the stack. This is just on the kernel
side. Additional architecture code is required to fully
support this feature.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds the mechanism to do cleanup after k_thread_abort()
is called with the current thread. This is mainly used for
cleaning up things when the thread cannot be running, e.g.,
cleanup the thread stack.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Modified bitmask to bitmask array, it can make multilevel queue remove
32 bit prioriry limit.
We can scan bitmask array to find which queue have ready thread.
Only need the number of queues as priority because the priority
is checked on create_thread.
Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>
Move thread monitor related functions, not enabled in most cases outside
of thread.c and cleanup headers.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This function is only being used by a test, so instead of reimplementing
a syscall in the test, provide a Kconfig option to provide the
functionality that only works with tests and remove some of the
duplication and extra code.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
We shouldn't be calling hooks from optional and upper layer subsystems
in the kernel, instead, just call the hook to set thread status in the
API where it is needed.
This now clears related bit in cmsis thread status bitarray when
terminating a thread in the cmsis rtos v1 layer directly and not in the
kenrel code.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The kernel kconfig is becoming too big and unmanageable with too many
options scattered across the file. Move some areas out and reorg main
Kconfig slightly.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This extends the wording so that not only architecture code can
start secondary CPUs at a later time. Also adds a missing 'to'.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Use the new HEAP_MEM_POOL_ADD_SIZE_ prefix to construct a minimum
requirement for posix message queue usage. This way we can remove the
"special case" default values from the HEAP_MEM_POOL_SIZE Kconfig
definition.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are several subsystems and boards which require a relatively large
system heap (used by k_malloc()) to function properly. This became even
more notable with the recent introduction of the ACPICA library, which
causes ACPI-using boards to require a system heap of up to several
megabytes in size.
Until now, subsystems and boards have tried to solve this by having
Kconfig overlays which modify the default value of HEAP_MEM_POOL_SIZE.
This works ok, except when applications start explicitly setting values
in their prj.conf files:
$ git grep CONFIG_HEAP_MEM_POOL_SIZE= tests samples|wc -l
157
The vast majority of values set by current sample or test applications
is much too small for subsystems like ACPI, which results in the
application not being able to run on such boards.
To solve this situation, we introduce support for subsystems to specify
their own custom system heap size requirement. Subsystems do
this by defining Kconfig options with the prefix HEAP_MEM_POOL_ADD_SIZE_.
The final value of the system heap is the sum of the custom
minimum requirements, or the value existing HEAP_MEM_POOL_SIZE option,
whichever is greater.
We also introduce a new HEAP_MEM_POOL_IGNORE_MIN Kconfig option which
applications can use to force a lower value than what subsystems have
specficied, however this behavior is disabled by default.
Whenever the minimum is greater than the requested value a CMake warning
will be issued in the build output.
This patch ends up modifying several places outside of kernel code,
since the presence of the system heap is no longer detected using a
non-zero CONFIG_HEAP_MEM_POOL_SIZE value, rather it's now detected using
a new K_HEAP_MEM_POOL_SIZE value that's evaluated at build.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for mutable devices. Mutable devices are those which
can be modified after declaration, in-place, in kernel mode.
In order for a device to be mutable, the following must be true
* `CONFIG_DEVICE_MUTABLE` must be y-selected
* the Devicetree bindings for the device must include
`mutable.yaml`
* the Devicetree node must include the `zephyr,mutable` property
Signed-off-by: Christopher Friedt <cfriedt@meta.com>