diff --git a/CMakeLists.txt b/CMakeLists.txt index 32032afb00e..6db5aedf3fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -561,16 +561,21 @@ else() set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${syscalls_subdirs_txt}) endif() -# SYSCALL_INCLUDE_DIRECTORY will include the directories that needs to be -# searched for syscall declarations if CONFIG_APPLICATION_DEFINED_SYSCALL is set +# syscall declarations are searched for in the SYSCALL_INCLUDE_DIRS if(CONFIG_APPLICATION_DEFINED_SYSCALL) - set(SYSCALL_INCLUDE_DIRECTORY --include ${APPLICATION_SOURCE_DIR}) + list(APPEND SYSCALL_INCLUDE_DIRS ${APPLICATION_SOURCE_DIR}) endif() if(CONFIG_ZTEST) - set(SYSCALL_ZTEST_DIRECTORY --include ${ZEPHYR_BASE}/subsys/testsuite/ztest/include) + list(APPEND SYSCALL_INCLUDE_DIRS ${ZEPHYR_BASE}/subsys/testsuite/ztest/include) endif() +foreach(d ${SYSCALL_INCLUDE_DIRS}) + list(APPEND parse_syscalls_include_args + --include ${d} + ) +endforeach() + add_custom_command( OUTPUT ${syscalls_json} @@ -578,8 +583,7 @@ add_custom_command( ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/parse_syscalls.py --include ${ZEPHYR_BASE}/include # Read files from this dir - ${SYSCALL_INCLUDE_DIRECTORY} - ${SYSCALL_ZTEST_DIRECTORY} + ${parse_syscalls_include_args} # Read files from these dirs also --json-file ${syscalls_json} # Write this file DEPENDS ${syscalls_subdirs_trigger} ${PARSE_SYSCALLS_HEADER_DEPENDS} ) diff --git a/doc/reference/usermode/syscalls.rst b/doc/reference/usermode/syscalls.rst index a1665248eb2..037fb7fbd00 100644 --- a/doc/reference/usermode/syscalls.rst +++ b/doc/reference/usermode/syscalls.rst @@ -26,8 +26,9 @@ Components All system calls have the following components: -* A **C prototype** for the API, declared in some header under ``include/`` and - prefixed with :c:macro:`__syscall`. This prototype is never implemented +* A **C prototype** prefixed with :c:macro:`__syscall` for the API. It + will be declared in some header under ``include/`` or in another + ``SYSCALL_INCLUDE_DIRS`` directory. This prototype is never implemented manually, instead it gets created by the :ref:`gen_syscalls.py` script. What gets generated is an inline function which either calls the implementation function directly (if called from supervisor mode) or goes @@ -88,6 +89,15 @@ bottom of ``include/sensor.h``: #include +C prototype functions must be declared in one of the directories +listed in the CMake variable ``SYSCALL_INCLUDE_DIRS``. This list +always contains ``${ZEPHYR_BASE}/include``, but will also contain +``APPLICATION_SOURCE_DIR`` when ``CONFIG_APPLICATION_DEFINED_SYSCALL`` +is set, or ``${ZEPHYR_BASE}/subsys/testsuite/ztest/include`` when +``CONFIG_ZTEST`` is set. Additional paths can be added to the list +through the CMake command line or in CMake code that is run before +``${ZEPHYR_BASE}/cmake/app/boilerplate.cmake`` is run. + Invocation Context ==================