A new Kconfig option which generates syscall stubs assuming that
extensions will always run on userspace, thus simplifying linking
them, as there's no need for z_impl_ stubs (used for direct syscalls),
CONFIG_LLEXT_EDK_USERSPACE_ONLY.
While defining __ZEPHYR_USER__ could have the same effect for optmised
builds, people building extensions on debug environments - thus
non-optimised - would suffer, as they'd need to somehow make the stubs
available (by either exporting the symbol or implementing dummy stubs).
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Pull in the latest uf2conv.py and newly needed uf2families.json file
to address Python warning on Python 3.12 and keep us in sync.
Signed-off-by: Peter Johanson <peter@peterjohanson.com>
The gen_kobject_list.py script looks at DWARF debug information in the
elf file to determine the address of variables. Make sure that when
looking at DW_FORM_exprloc, it looks at both DW_OP_addr and
DW_OP_plus_uconst.
Signed-off-by: Nick Goote <ngoote@gmail.com>
Since there is a K_THREAD_STACK_LEN, its kernel counterpart
should also be prefixed with K_ for consistency.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
commit 67bb6db3f8 ("syscall: Export all emitted syscalls, enabling
them for extensions") exports all emitted syscalls, however, it does
that only for the `z_mrsh` symbols, effectively only available for
userspace. If an extension running at kernel level tries to use a
syscall, it will fail to load.
This patch fixes that by exposing the `z_impl` symbols instead. However,
this is not as straightforward as the `z_mrsh` ones. As, in their
signatures, they can basically contain any type, it's not just a matter
of emitting `EXPORT_SYMBOL(z_impl_<syscall>)`, as the compiler will
complain about the undefined types. Here, there are a few approaches.
One of them is to have the `EXPORT_SYMBOL` being generated on the same
files where the syscall is implemented - injecting it there would allow
it to access all known symbols. But changing a lot of files is
undesirable, and it was one of the nice points of first patch.
Another one would be to reconstruct - or simply use the absolute path -
for the includes where the syscalls are defined. Reconstruct the paths
seems fragile and I'm not sure using absolute paths is portable.
Finally, the approach used in this patch is to declare, on a different
generated file, all `z_impl_` symbols as `void *` - after all, only the
address (and the name) to the function is relevant to EXPORT_SYMBOL. By
living in an compilation unit that doesn't include any header which
would expose any of the syscalls, there shouldn't be any conflicts. And
to account for the possibility that a syscall is not compiled - due
being configured out via Kconfig - all those symbols are also weak
aliases to a pointer to NULL. This file is then included in
`llext_export.c` (which should naturally not include any conflicting
header).
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Linkable loadable extensions can only use syscalls if they are exported
via EXPORT_SYSCALL (or EXPORT_SYMBOL). Instead of enabling used syscalls
one by one, this patch exports all of them automatically via
`gen_syscalls.py`. If CONFIG_LLEXT=n, the section where the exported
symbols live is discarded, so it should be a non-op when llext is not
enabled.
This patch also removes the now redundant EXPORT_SYSCALL macro. Note
that EXPORT_SYMBOL is still useful on different situations (and is
indeed used by the code generated by `gen_syscalls.py`).
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Remove a message that had a typo in it but, more importantly that was
not needed.
The CONFIG_ISR_TABLES_LOCAL_DECLARATION already selects EXPERIMENTAL so
a user is properly alerted about the consequences just like any other
EXPERIMENTAL features if they enable WARN_EXPERIMENTAL.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
According to the Zephyr documentation, the multi-level interrupts
are encoded as follows:
`L1_ID | ((L2_ID + 1) << L2_BITS) | ((L3_ID + 1) << (L3_BITS + L2_BITS))`
This means that when L3 interrupts are enabled, the gen_isr_table.py
script will receive the value of L2_ID + 1. Currently, the script
takes this value and directly compares it with the offsets set via
`CONFIG_3RD_LVL_INTR_xx_OFFSET`. This is wrong because the values from
said configurations are the same as L2_ID and because of that the
script will generate an error. To fix this, use the value of L2_ID
instead of L2_ID + 1.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
This commit moves all the functionality related to the current
interrupt parser into gen_isr_tables_parser_carrays.py file.
The new parser file gen_isr_tables_parser_local.py file is
implemented with the new parser that.
Additional information added to the generated interrupt header
that contains data required by the new parser.
Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
This commit breaks the code into functional classes.
This way the functionality is visibly splitted into
functional parts and it is easier to replace the
specific parser part to implement new code generators.
There is also common functionality to handle multi level interrupts
moved to configuration class.
Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
This commit cleans up the gen_isr_tables code for better clarity
and easier modification.
Changes include:
- Separate functions to load intList section.
- Replace spurious handlers in internal data with None.
Now it is the output generator work to choose right function.
- All the work to generate vt and swt separated into its own functions.
- Remove the need for internal shared array - all the information
is here in swt array.
- The update_masks function - more functionality moved here.
- Simplify bit_mask function.
Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
When using direct isrs, a vector table is needed. However, if none is
present , i.e. `CONFIG_GEN_IRQ_VECTOR_TABLE=n`, this script failed. The
given error message was not helpful (`'NoneType' has no len()`).
This change makes it clearer, where to look for the problem.
Signed-off-by: Greter Raffael <rgreter@baumer.com>
When using the code and data relocation feature, every relocated symbol
would be marked with `KEEP()` in the generated linker script. Therefore,
if any input files contained unused code, then it wouldn't be discarded
by the linker, even when invoked with `--gc-sections`.
This can cause unexpected bloat, or other link-time issues stemming from
some symbols being discarded and others not.
On the other hand, this behavior has been present since the feature's
introduction, so it should remain default for the users who rely on it.
This patch introduces support for `zephyr_code_relocate(... NOKEEP)`.
This will suppress the generation of `KEEP()` statements for all symbols
in a particular library or set of files.
Much like `NOCOPY`, the `NOKEEP` flag is passed to `gen_relocate_app.py`
in string form. The script is now equipped to handle multiple such flags
when passed from CMake as a semicolon-separated list, like so:
"SRAM2:NOCOPY;NOKEEP:/path/to/file1.c;/path/to/file2.c"
Documentation and tests are updated here as well.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
Rename the bitmask variables from `*_LVL_INTERRUPTS` to
`INTERRUPT_LVL_BITMASK[]` array to be consistent with
`INTERRUPT_BITS`, making it easier to loop over the bitmasks.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
The calculation of `THIRD_LVL_INTERRUPTS` bitmask in the
`update_masks()` function is wrong, the number of bits to shift
should be the sum of the first two levels.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
It's not good to see struct_tags.json change from one build to the next
when nothing changes.
Python's sets are not deterministic, see long story for older commit
f896fc2306 ("scripts: gen_handles: Sort the device handles")
Simply convert multiple_directories to a sorted list before using it.
Fixes commit 80e78208e6 ("kernel: syscalls: no need to include all
syscalls in binary")
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Python's sets are not deterministic.
`devices` were already sorted but `dev_supports` is still a
non-deterministic set. Sort dev_supports to make the graph output
deterministic.
Fixes commit 29942475c5 ("scripts: gen_handles: output dependency graph")
It is quite ironic that this initial and non-deterministic graph commit
was concurrent with and slightly delayed other commit
f896fc2306 ("scripts: gen_handles: Sort the device handles") which
fixed another, similar non-determinism issue in the same area. A true
"whack-a-mole"!
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This allows sorting objects consistently without having to specific a
key.
No functional change yet.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The current error messages are a bit cryptic, rework them to make them
more meaningful:
- add an extra message on the first error to explain what the errors
refer to.
- rework the error message to be more explicit.
- rework the priority string print to use a LEVEL+offset format to
somehow highlight that the number is the offset from the level, not
the actual priority.
- print the init function name in addition to the devicetree path.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Since bb590b5b6e introduced ordinals in the priority sequence, the "same
priority" case cannot happen anymore, furthermore the priority value in
the script is now the position of the function in the init sequence, so
if two devices have the same priority there's something real bad going
on.
Drop all the "same priority" handling code and tests, convert the case
into ane exception instead. Drop the init stubs as well from the test,
they are not required anymore.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Now that child nodes are handled by edtlib there's no need to parse
child nodes in check_init_priorities anymore.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit removes the needs or generating isrList.bin temporary file.
Now gen_isr_tables.py script access the required section directly in
elf file, that was accessed by the script anyway.
It simplifies the building removing one step.
Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
Rework check_init_priorities to use the main executable file instead of
the individual object files for discovering the devices.
This should make the script more robust in case of stale files in the
build directory, and also makes it work with LTO object files.
Additionally, keep track of the detected init calls, and add a handy
"-i" option to produce a human readable print of the initcalls in the
call sequence, which can be useful for debugging initialization problems
due to odd SYS_INIT and DEVICE interactions.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit introduces all the necessary changes for
enabling the usage of shared interrupts.
This works by using a second interrupt table: _shared_sw_isr_table
which keeps track of all of the ISR/arg pairs sharing the same
interrupt line. Whenever a second ISR/arg pair is registered
on the same interrupt line using IRQ_CONNECT(), the entry in
_sw_isr_table will be overwriten by a
(shared_isr, _shared_sw_isr_table[irq]) pair. In turn, shared_isr()
will invoke all of the ISR/arg pairs registered on the same
interrupt line.
This feature only works statically, meaning you can only make use
of shared interrupts using IRQ_CONNECT(). Attempting to dynamically
register a ISR/arg pair will overwrite the hijacked _sw_isr_table
entry.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Update CFB font generator so it works with Pillow version 10. They
deprecated some methods, with no direct replacements, so the generated
fonts might be slightly different.
Signed-off-by: Jonathan Rico <jonathan@rico.live>
Log the device priority on the file debug output print, this is
convenient to list out all the defined devices and their priority, even
if they don't depend on each other.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
It is only available if CONFIG_DEVICE_DEPS=y, so the ZephyrElf class
would fail to load if it does not treat _DEVICE_STRUCT_HANDLES_OFFSET as
optional.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
The generated stubs use retval for function return value.
However, this is too generic and is going to collide with
other code. So rename those to be more specific. Note
that the double underscore is intentional to minimize
chance of being shadow variables.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
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>
For applications relocating big parts of the code with many sections,
builds were failing on Windows due to hitting the max command-line
length on that platform.
Fix this by using a file to store the dictionary passed to the python
script.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/60994.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Update the script to parse the new section naming. The ordering type
is converted from an integer to a tuple, which still compares correctly
due to the elementwise behaviour of tuple comparison.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The new stack zephyr,cdc-acm-uart driver has two separate init path, one
of which kicks in before the USB stack to start buffering log messages.
This generates a false positive in the build time priority checking,
adding a check to ignore that compatible entirely.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Rename the device dependencies array variable to use the "deps" name, in
line with latest renamings in device.h
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>