Commit Graph
346 Commits
Author SHA1 Message Date
Ben Levinsky 9dd72ddbfd lib: a53: remove redundant MB and GB macros
lib/utilities.h provided MB and GB macros so include from there
instead of providing the definition again for a53 platforms.

Signed-off-by: Ben Levinsky <ben.levinsky@amd.com>
2023-10-17 19:08:08 +02:00
Arnaud Pouliquen 9fe00e0582 Remove vim editor configuration in files
Remove all remaining instances of "# vim: ..." in files.
This vim settings were part of the initial commit. But no reason
to keep them.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2023-10-17 09:02:59 +02:00
Sergei Korneichuk 37f1660b20 log: add function name, line number prefix
Add convenience macros metal_err, metal_warn, metal_info, metal_dbg
to avoid using excessively long and redundant metal_log(METAL_LOG_*).
Add "function-name:line-number" prefix to all messages if the option
WITH_FUNC_LINE_LOG is set ON during the configuration phase.

Signed-off-by: Sergei Korneichuk <sergei.korneichuk@amd.com>
2023-10-13 18:26:14 +02:00
Tanmay Shah 0ad1183a82 lib: utilities: add MB and GB defines
If MB and GB definition is not available then define new ones

Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
2023-09-11 09:48:39 +02:00
Ben Levinsky 6d571fd068 lib: system: freertos: Add metal/errno.h to match standalone
As lib/system/generic/sys.h has metal/errno.h add this to the freertos
equivalent.

This fixes some compilation issues when linking against certain FreeRTOS port
BSPs.

Signed-off-by: Ben Levinsky <ben.levinsky@amd.com>
2023-09-11 09:47:18 +02:00
Sergei Korneichuk 548f642855 Export each of the memory_order enumerators
The lib/atomic.h exports memory_order enum into the global namespace,
but none of its enumerators. According to Section 7.3.3 "The using
declaration" of the C++ standard: "specifying an enumeration name
in a using-declaration does not declare its enumerators in
the using-declaration's declarative region." See also:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0943r1.html

Signed-off-by: Sergei Korneichuk <sergei.korneichuk@amd.com>
2023-08-21 18:46:33 +02:00
Andrew Davis f2144b12ae lib: refactor alloc.h to not need forward declaration
This should have no functional change, but makes this header consistent
with how the other headers are organized.

Signed-off-by: Andrew Davis <afd@ti.com>
2023-08-16 17:17:14 +02:00
Xiang Xiao 6fb9f4565f Add reference count to metal_common_state
to allow to invoke metal_init and metal_finish multiple times

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-19 09:17:59 +02:00
Ben Levinsky 7ec5b636e7 lib: add support for A78 Baremetal
Enable cache, IPI, exception and shared-memory operations on Versal A78
for Libmetal.

Signed-off-by: Ben Levinsky <ben.levinsky@amd.com>
2023-06-29 09:36:00 +02:00
Ben Levinsky 6e4b016151 lib: add support for A72 Baremetal
Enable cache, IPI, exception and shared-memory operations on Versal A72
for Libmetal.

Additionally, as the code for A72 and A53 is almost identical, move
the common code to generic/xlnx_common/zynqmp_aarch64 and differentiate
the slight differences with macro checks.

Signed-off-by: Ben Levinsky <ben.levinsky@xilinx.com>

Acked-by: tanmay.shah@xilinx.com
2023-06-29 09:36:00 +02:00
Arnaud Pouliquen a136ce83b3 lib: system: freertos: remove deprecated METAL_MUTEX_INIT
The METAL_MUTEX_INIT macro has been deprecated in release 2021.04.0
Remove it after it has been in a deprecated state for 2 years.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2023-04-20 13:26:28 +02:00
Gustavo Henrique Nihei 5a87db2f0c nuttx: Add missing include header in IRQ implementation
Missing header became evident after a code refactor in another NuttX
component, which resulted in build warnings.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2023-03-23 09:56:59 +01:00
Carlo Caione ea2b894138 zephyr: cache: Use new cache API
Use the new cache API for the cache hooks.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-11-18 10:29:30 +01:00
Tammy Leino c1c4e55992 New routine to find a node on a list
metal_list_find_node is used to ensure a node is not on a list before adding it
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
2022-10-04 09:31:23 +02:00
Sergei Korneichuk d077e286a4 cmake: set PROJECT_EC_FLAGS to be GLOBAL property
Declare PROJECT_EC_FLAGS to be a global property
to simplify code for target_compile_options.

Signed-off-by: Sergei Korneichuk <sergei.korneichuk@amd.com>
2022-10-03 16:55:01 +02:00
Sergei Korneichuk 9a814dac13 zynqmp_r5: replace Xil_SetMPURegion with Xil_MemMap
The metal_machine_io_mem_map() used to call Xil_SetMPURegion directly
and could get into an infinite loop. Replace the faulty code in
metal_machine_io_mem_map() with Xil_MemMap() call and assert it succeeds.

Signed-off-by: Sergei Korneichuk <sergei.korneichuk@amd.com>
2022-09-21 17:23:24 +02:00
Gerard Marull-Paretas 8bb3fa38e7 zephyr: use <zephyr/kernel.h>
<zephyr/zephyr.h> is a shim to the Kernel header, so let's use it
directly.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-05-16 10:27:20 +02:00
Gerard Marull-Paretas e9d4531300 zephyr: update include paths to use <zephyr/...>
Zephyr has prefixed all of its includes with <zephyr/...>. While the old
mode can still be used (CONFIG_LEGACY_INCLUDE_PATH) and is still enabled
by default, it's better to be prepared for its removal in the future.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-05-16 10:27:20 +02:00
Eugene Cohen 239e836c21 zephyr: simplify zephyr system to remove machine
Replace the architecture-specific machine directories with a common
C function for polling which calls to arch_cpu_idle.

Add a special case to map Zephyr arm64 to libmetal aarch64 in defining
PROJECT_PROCESSOR variable.

Set the MACHINE variable based CONFIG_ARCH instead of testing
individual arch config flags.

Signed-off-by: Eugene Cohen <quic_egmc@quicinc.com>
2022-05-06 18:37:37 +02:00
Kenta Sato 86fd1ba48e Create an eventfd object with EFD_CLOEXEC flag
The file descriptor `irq_notify_fd` does not have the close-on-exec
(`FD_CLOEXEC`) flag so it possibly leaks to child processes.
This adds an `EFD_CLOEXEC` flag to the second argument of the `exentfd(2)` call,
which tells it to set an `FD_CLOEXEC` flag on the new file descriptor.

Signed-off-by: Kenta Sato <tosainu.maple@gmail.com>
2022-05-06 14:09:12 +02:00
Arnaud Pouliquen d2555ab254 Doc: fix doc generation warnings in system sleep.h files
Fix "unbalanced grouping commands" warnings by cleaning up
the end-of-block occurrences, defined without starting tag.
No need to define an API interface block in these files, the
interface is already described in the main sleep.h file.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-04-11 09:21:15 +02:00
Matthias Fend 695d29ba60 lib: system: zephyr: implement __metal_sleep_usec
The currently missing implementation causes invalid timeouts when sending
remoteproc messages over virtIO. With this change, the specified timeout
of 15 seconds can be achieved. This seems to be the only usage in Zephyr.

Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
2022-02-14 11:12:49 +01:00
Arnaud Pouliquen af82d35f7a freertos: io: fix IAR compile error due to 'void *' variable
Fix EWARM compilation error due to void pointer usage.
This fix has already been implemented for the generic system, but
was missing for the FreeRTOS.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2022-01-24 09:37:03 +01:00
Daniel Baluta bd3729afa0 zephyr: Enable support for Xtensa
Make libmetal usable also for Xtensa targets.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2022-01-19 08:50:02 +01:00
Carlo Caione c6ae2c663b zephyr: Enable support for RISCV
Make libmetal usable also for RISCV targets.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-01-04 12:14:00 +01:00
Luz Paz 210b9ec37a Fix various typos
Found via `codespell -q 3 -S ./scripts/spelling.txt`

Signed-off-by: luz paz <luzpaz@users.noreply.github.com>
2022-01-04 10:05:40 +01:00
Arnaud Pouliquen cca70035d3 lib: fix compilation error with gcc++
The header files including must be outside of the extern "C" { statement.
To be able to be included from C++ code.

Else such error can occur (reproduce on STM32MP1Cube distribution)
gcc/arm-none-eabi/include/c++/10.2.1/atomic:1467:3: error: template
with C linkage
 1467 |   template<typename _ITp>
      |   ^~~~~~~~
In file included from STM32CubeMP1/Middlewares/Third_Party/OpenAMP/
                      open-amp/lib/include/openamp/rpmsg.h:16,
                 from STM32CubeMP1/Middlewares/Third_Party/OpenAMP/
                      open-amp/lib/include/openamp/open_amp.h:11,
                 from empty_main.cpp:1:
STM32CubeMP1/Middlewares/Third_Party/OpenAMP/libmetal/lib/include/
metal/mutex.h:16:1: note: 'extern "C"' linkage
started here
   16 | extern "C" {
      | ^~~~~~~~~~

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2021-12-16 18:02:49 +01:00
Guiding Li d561222376 libmetal: fix the type miss match warning in nuttx porting
warning: makes pointer from integer without a cast
note: expected ‘void *’ but argument is of type ‘long unsigned int’

Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
2021-10-29 13:26:57 -07:00
Guiding Li 000568db41 libmetal: add xtensa support
make openamp can run on xtensa dsp

Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
2021-10-29 13:25:39 -07:00
Arnaud Pouliquen d523dbb788 lib: system: freertos: mutex: add deprecated message for METAL_MUTEX_INIT
Associated to the re-use of FreeRTOS mutex relying on the FreeRTOS
scheduling policy.
Add compilation warning message to indicate that the use of static
initialization of the atomic mutex for FreeRTOS environment is deprecated.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2021-10-22 15:11:56 +02:00
Arnaud Pouliquen 8d98a70fdb system:freertos: fix typo in sys.c path
Fix the path replacing generic by freertos.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2021-10-22 15:11:56 +02:00
Arnaud Pouliquen 1a38d78f5c Revert "lib: system: freertos: mutex: change to use atomic_int instead of freertos construct"
Re-enable the use of FreeRTOS mutex to take advantage of the
FreeRTOS priority-based preemptive scheduling policy.

This reverts commit 10a0d5be4a.

Fix checkpatch complaints, associated to the patch revert. Initial
patch did not respect the new coding rules.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2021-10-22 15:11:56 +02:00
Jiuzhu Dong dd4165793f openamp/libmetal: fix Non-zero offsets to null pointers
leads to ASAN errors:
libmetal/lib/system/nuttx/io.c:78:9: runtime error: applying non-zero offset 4124131344 to null pointer
metal/io.h:136:3: runtime error: applying non-zero offset 4124131440 to null pointer
metal/io.h:136:3: runtime error: applying non-zero offset 4124131440 to null pointer
metal/io.h:136:3: runtime error: applying non-zero offset 4124131440 to null pointer
metal/io.h:136:3: runtime error: applying non-zero offset 4124131552 to null pointer
metal/io.h:136:3: runtime error: applying non-zero offset 4124132000 to null pointer

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-08-12 14:36:24 +02:00
Julien Massot e73f0b0139 zephyr: enable support for Arm AArch32 processors
Arm AArch32 processors have the same WFI assembly instruction
and so can works with the existing cortexm support.

Rename cortexm directory to arm.

Build tested with stm32mp157c_dk2 for Cortex-M,
rcar_h3ulcb for Cortex-R.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-06-17 10:24:21 +02:00
Mark-PK Tsai 7e171668c5 io: add null pointer check in io block ops
metal_io_virt returns NULL on invalid input metal_io_region.
Check ptr before use it and remove the offset check which
is already tested in metal_io_virt.

Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
2021-06-08 10:47:57 +02:00
Carlo Caione ecac36a4c9 zephyr: cache: Use new Zephyr cache APIs
Zephyr ships now a different API for cache management. Instead of
hijacking the call into Zephyr, use the proper API directly in libmetal.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-05-28 10:23:34 +02:00
Lane Kolbly 4faa1c9d36 linux: device: unmap regions for linux device
This unmaps the device regions which were opened during metal_uio_dev_open.
Failure to do this results in a file descriptor leak.

Signed-off-by: Lane Kolbly <lane.kolbly@ni.com>
2021-05-28 10:12:49 +02:00
Arnaud Pouliquen ad87802d6e Rework the version management
PROJECT_VERSION* variables are recognized by cmake. Rename the
PROJECT_VER* variables used for the version.

Create a version file to make it easier to find and update the version.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
2021-04-15 09:37:07 +02:00
Ed Mooring f252f0e007 FreeRTOS: Allow tick rates greater than 1000 for metal_sleep_usec().
metal_sleep_usec() used portTICK_PERIOD_MS to determine how long to
sleep. If the FreeRTOS tick rate is set to greater than 1000, this will
be 0, resulting in a divide by zero error at run time. This changes it
to use pdMS_TO_TICKS(), which can accomodate higher tick rates.

Signed-off-by: Ed Mooring <ed.mooring@linaro.org>
2021-01-11 16:56:48 +01:00
Leo Sartre 73f746ecf6 lib/system/linux: pass correct offset to metal_map()
According to UIO documentation, the offset device tree property
purpose is to be used "if the device’s memory is not page aligned".
Quoting the same documentation:
"To map the memory of mapping N, you have to use N times the page
size as your offset"
So wee need to pass i * getpagesize() to get the correct mapping,
otherwise, we end up with all io_region pointing to the same area.

Signed-off-by: Leo Sartre <sartre.l@ecagroup.com>
2020-12-15 12:49:38 -08:00
Arnaud Pouliquen 9c807f04e7 compiler: Add support of metal/errno.h for ARMCC
Add ARMCC errno.h to support non posix error values used in baremetal.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-12-15 12:46:08 -08:00
Haithem Rahmani 65d77a680b Make ARMCC use GCC atomic routines
The MDK-ARM ARMCC doesn't provide the "stdatomic.h", however, with the
option "--gnu", it can support the standard gcc atomic routines.

This patch makes the armcc compiler use the "compiler/gcc/atomic.h"

Signed-off-by: Haithem Rahmani <haithem.rahmani@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-12-15 12:46:08 -08:00
Arnaud Pouliquen a55c8a2cb7 Generate a compiler error when ARMCC is not using GNU extentions
The GNU extensions enableable via the "--gnu" compile option, is
mandatory for the ARMCC to benefit from GNU atomic routines and macros.
This commit adds compilation error to notify user about ARMCC

Signed-off-by: Haithem Rahmani <haithem.rahmani@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-12-15 12:46:08 -08:00
Arnaud Pouliquen bf57c47cd5 lib: include metal/errno instead of errno.h
include metal/errno to better support non GCC compilers.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-12-10 16:49:59 +01:00
Arnaud Pouliquen 11bb1ac46d compiler: Add specific errno.h file for EWARM compilation
Error values use in the library are not POSIX. Unlike the GNU gcc,the
EWARM toolchain doesn't support error such as EINVAL. To ensure coherency
in error management we have to ensure that library and application use
the same errno. Currently an "errno.h" is provided at application level
which makes GCC work correctly, but this is not the case for the IAR.
the added list is based on FreeBSD errno.h.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-12-10 16:49:59 +01:00
Arnaud Pouliquen bbf692005c generic: fix compilation error when compiling using IAR
Includes are not found by the IAR.
As they seems unused, just suppress them.

Signed-off-by: Haithem Rahmani <haithem.rahmani@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-12-10 16:49:59 +01:00
Arnaud Pouliquen 07c523bdd2 atomic: fix typo in the header file comments
Replace GCC by Arm.

Signed-off-by: Haithem Rahmani <haithem.rahmani@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-12-10 16:49:59 +01:00
Arnaud Pouliquen 4081b0d562 io: fix IAR compile error due to 'void *' variable
Fix EWARM compilation error due to void pointer usage.

Signed-off-by: Haithem Rahmani <haithem.rahmani@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
2020-12-10 16:49:59 +01:00
Leo Sartre 6e81fb67c7 lib/system/linux: fix memory leak in metal_uio_read_map_attr()
The sysfs attribute must be closed before metal_uio_read_map_attr()
function returns otherwise a resource is leaked.

Signed-off-by: Leo Sartre <sartre.l@ecagroup.com>
2020-11-20 14:37:32 +01:00
Ed Mooring 30af011301 FreeRTOS: fix sleep and timestamp handling
libmetal's libmetal_sleep_usec() takes a sleep time in micro-seconds.
The FreeRTOS function underlying it takes a sleep time in task ticks.
This was not properly corrected for, resulting in sleep times that
were off by an order of magnitude. The test code attempted to
correct for this as well, in the same wrong way.

Lastly, the metal_get_timestamp() function returned a value in
task ticks alone. This is a configuration dependent value.

This patch changes all three places to use microseconds for the
input and output values.

Signed-off-by: Ed Mooring <ed.mooring@linaro.org>
2020-10-15 11:26:36 +02:00