This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 947fdeab65ac39181779e29e1091622bd1b6cd27 Author: hujun5 <[email protected]> AuthorDate: Fri Jan 16 19:34:41 2026 +0800 tee: Move TEE functionality to a separate directory Move the OP-TEE and TEE-related implementation from drivers/misc to drivers/tee and add the corresponding build-system integration. Signed-off-by: hujun5 <[email protected]> --- drivers/CMakeLists.txt | 1 + drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/misc/CMakeLists.txt | 13 ------ drivers/misc/Kconfig | 67 ------------------------------ drivers/misc/Make.defs | 13 ------ drivers/{ => tee}/CMakeLists.txt | 23 +++++++---- drivers/tee/Kconfig | 71 ++++++++++++++++++++++++++++++++ drivers/{misc => tee}/Make.defs | 65 ++--------------------------- drivers/{misc => tee}/optee.c | 2 +- drivers/{misc => tee}/optee.h | 8 ++-- drivers/{misc => tee}/optee_msg.h | 8 ++-- drivers/{misc => tee}/optee_rpc.c | 2 +- drivers/{misc => tee}/optee_rpc.h | 8 ++-- drivers/{misc => tee}/optee_smc.c | 2 +- drivers/{misc => tee}/optee_smc.h | 8 ++-- drivers/{misc => tee}/optee_socket.c | 2 +- drivers/{misc => tee}/optee_supplicant.c | 2 +- drivers/{misc => tee}/optee_supplicant.h | 8 ++-- 19 files changed, 117 insertions(+), 188 deletions(-) diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt index f176cbb2afa..cd0335ac476 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/CMakeLists.txt @@ -26,5 +26,6 @@ nuttx_add_kernel_library(drivers) # included automatically. nuttx_add_subdirectory() +# The TEE driver is discovered through its own CMakeLists.txt. target_sources(drivers PRIVATE drivers_initialize.c) target_include_directories(drivers PRIVATE ${CMAKE_CURRENT_LIST_DIR}) diff --git a/drivers/Kconfig b/drivers/Kconfig index 29305f13428..7a10e943a7e 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -88,3 +88,4 @@ source "drivers/reset/Kconfig" source "drivers/pci/Kconfig" source "drivers/coresight/Kconfig" source "drivers/aie/Kconfig" +source "drivers/tee/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index 7cf5e810f2f..7b709b747aa 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -87,6 +87,7 @@ include reset/Make.defs include pci/Make.defs include coresight/Make.defs include aie/Make.defs +include tee/Make.defs ifeq ($(CONFIG_SPECIFIC_DRIVERS),y) -include platform/Make.defs diff --git a/drivers/misc/CMakeLists.txt b/drivers/misc/CMakeLists.txt index fc7508b7c48..1fb3099fef1 100644 --- a/drivers/misc/CMakeLists.txt +++ b/drivers/misc/CMakeLists.txt @@ -78,19 +78,6 @@ if(CONFIG_BLK_RPMSG_SERVER) list(APPEND SRCS rpmsgblk_server.c) endif() -if(NOT CONFIG_DEV_OPTEE_NONE) - list(APPEND SRCS optee.c) - if(CONFIG_DEV_OPTEE_SMC) - list(APPEND SRCS optee_smc.c) - list(APPEND SRCS optee_rpc.c) - if(CONFIG_DEV_OPTEE_SUPPLICANT) - list(APPEND SRCS optee_supplicant.c) - endif() - else() - list(APPEND SRCS optee_socket.c) - endif() -endif() - if(CONFIG_GOLDFISH_PIPE) list(APPEND SRCS goldfish_pipe.c) endif() diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 0add6b7cfca..4d351aa03ad 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -72,73 +72,6 @@ config DEV_RPMSG_SERVER_WORK_STACKSIZE endif # DEV_RPMSG_SERVER -choice - prompt "Select OP-TEE dev implementation" - default DEV_OPTEE_NONE - ---help--- - There are three implementations of optee server, - one is soft tee server which does not distinguish - between secure and non-secure states and uses socket communication, - and the other two is teeos which runs in the secure state of - the cpu and uses either RPMsg cross-core communication or arm SMCs. - Warning: SMC implementation has only been tested on arm64. - -config DEV_OPTEE_LOCAL - bool "OPTEE Local Socket Support" - depends on NET_LOCAL - depends on FS_ANONMAP - depends on ALLOW_BSD_COMPONENTS - -config DEV_OPTEE_RPMSG - bool "OP-TEE RPMSG Socket Support" - depends on NET_RPMSG - depends on FS_ANONMAP - depends on ALLOW_BSD_COMPONENTS - -config DEV_OPTEE_SMC - bool "OP-TEE SMC CC Support" - depends on ARCH_ARM || ARCH_ARM64 - depends on FS_ANONMAP - depends on ALLOW_BSD_COMPONENTS - -config DEV_OPTEE_NONE - bool "Disable OP-TEE driver" - -endchoice - -config DEV_OPTEE_SUPPLICANT - bool "Enables kernel driver for TEE supplicant" - default n - depends on DEV_OPTEE_SMC - -if DEV_OPTEE_RPMSG - -config OPTEE_REMOTE_CPU_NAME - string "The cpuname on which the OP-TEE server runs" - default "tee" - -endif # DEV_OPTEE_RPMSG - -if DEV_OPTEE_SMC - -choice - prompt "Select OP-TEE conduit method" - default DEV_OPTEE_SMC_CONDUIT_SMC - ---help--- - Select between the 2 supported conduit methods for invoking the secure - world: SMC (when running at EL1) and HVC (when running at EL2, which is - not supported by NuttX yet). - -config DEV_OPTEE_SMC_CONDUIT_SMC - bool "Use SMC calls to invoke OP-TEE" - -config DEV_OPTEE_SMC_CONDUIT_HVC - bool "Use HVC calls to invoke OP-TEE" - -endchoice - -endif # DEV_OPTEE_SMC - config DRVR_MKRD bool "RAM disk wrapper (mkrd)" default n diff --git a/drivers/misc/Make.defs b/drivers/misc/Make.defs index 722e192ec28..63b683b5cfd 100644 --- a/drivers/misc/Make.defs +++ b/drivers/misc/Make.defs @@ -75,19 +75,6 @@ ifeq ($(CONFIG_BLK_RPMSG_SERVER),y) CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)fs endif -ifneq ($(CONFIG_DEV_OPTEE_NONE),y) - CSRCS += optee.c - ifeq ($(CONFIG_DEV_OPTEE_SMC),y) - CSRCS += optee_smc.c - CSRCS += optee_rpc.c - ifeq ($(CONFIG_DEV_OPTEE_SUPPLICANT),y) - CSRCS += optee_supplicant.c - endif - else - CSRCS += optee_socket.c - endif -endif - ifeq ($(CONFIG_GOLDFISH_PIPE),y) CSRCS += goldfish_pipe.c endif diff --git a/drivers/CMakeLists.txt b/drivers/tee/CMakeLists.txt similarity index 71% copy from drivers/CMakeLists.txt copy to drivers/tee/CMakeLists.txt index f176cbb2afa..1a473392086 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/tee/CMakeLists.txt @@ -1,5 +1,5 @@ # ############################################################################## -# drivers/CMakeLists.txt +# drivers/tee/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # @@ -19,12 +19,19 @@ # the License. # # ############################################################################## +set(SRCS) -nuttx_add_kernel_library(drivers) +if(NOT CONFIG_DEV_OPTEE_NONE) + list(APPEND SRCS optee.c) + if(CONFIG_DEV_OPTEE_SMC) + list(APPEND SRCS optee_smc.c) + list(APPEND SRCS optee_rpc.c) + if(CONFIG_DEV_OPTEE_SUPPLICANT) + list(APPEND SRCS optee_supplicant.c) + endif() + else() + list(APPEND SRCS optee_socket.c) + endif() +endif() -# Subdirectories that provide their own CMakeLists.txt (for example dma-buf) are -# included automatically. -nuttx_add_subdirectory() - -target_sources(drivers PRIVATE drivers_initialize.c) -target_include_directories(drivers PRIVATE ${CMAKE_CURRENT_LIST_DIR}) +target_sources(drivers PRIVATE ${SRCS}) diff --git a/drivers/tee/Kconfig b/drivers/tee/Kconfig new file mode 100644 index 00000000000..67978acd7cb --- /dev/null +++ b/drivers/tee/Kconfig @@ -0,0 +1,71 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +choice + prompt "Select OP-TEE dev implementation" + default DEV_OPTEE_NONE + ---help--- + There are three implementations of optee server, + one is soft tee server which does not distinguish + between secure and non-secure states and uses socket communication, + and the other two is teeos which runs in the secure state of + the cpu and uses either RPMsg cross-core communication or arm SMCs. + Warning: SMC implementation has only been tested on arm64. + +config DEV_OPTEE_LOCAL + bool "OPTEE Local Socket Support" + depends on NET_LOCAL + depends on FS_ANONMAP + depends on ALLOW_BSD_COMPONENTS + +config DEV_OPTEE_RPMSG + bool "OP-TEE RPMSG Socket Support" + depends on NET_RPMSG + depends on FS_ANONMAP + depends on ALLOW_BSD_COMPONENTS + +config DEV_OPTEE_SMC + bool "OP-TEE SMC CC Support" + depends on ARCH_ARM || ARCH_ARM64 + depends on FS_ANONMAP + depends on ALLOW_BSD_COMPONENTS + +config DEV_OPTEE_NONE + bool "Disable OP-TEE driver" + +endchoice + +config DEV_OPTEE_SUPPLICANT + bool "Enables kernel driver for TEE supplicant" + default n + depends on DEV_OPTEE_SMC + +if DEV_OPTEE_RPMSG + +config OPTEE_REMOTE_CPU_NAME + string "The cpuname on which the OP-TEE server runs" + default "tee" + +endif # DEV_OPTEE_RPMSG + +if DEV_OPTEE_SMC + +choice + prompt "Select OP-TEE conduit method" + default DEV_OPTEE_SMC_CONDUIT_SMC + ---help--- + Select between the 2 supported conduit methods for invoking the secure + world: SMC (when running at EL1) and HVC (when running at EL2, which is + not supported by NuttX yet). + +config DEV_OPTEE_SMC_CONDUIT_SMC + bool "Use SMC calls to invoke OP-TEE" + +config DEV_OPTEE_SMC_CONDUIT_HVC + bool "Use HVC calls to invoke OP-TEE" + +endchoice + +endif # DEV_OPTEE_SMC diff --git a/drivers/misc/Make.defs b/drivers/tee/Make.defs similarity index 53% copy from drivers/misc/Make.defs copy to drivers/tee/Make.defs index 722e192ec28..a80e945baeb 100644 --- a/drivers/misc/Make.defs +++ b/drivers/tee/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# drivers/misc/Make.defs +# drivers/tee/Make.defs # # SPDX-License-Identifier: Apache-2.0 # @@ -20,61 +20,6 @@ # ############################################################################ -ifeq ($(CONFIG_DEV_SIMPLE_ADDRENV),y) - CSRCS += addrenv.c -endif - -ifeq ($(CONFIG_DEV_NULL),y) - CSRCS += dev_null.c -endif - -ifeq ($(CONFIG_DEV_ZERO),y) - CSRCS += dev_zero.c -endif - -ifeq ($(CONFIG_DEV_MEM),y) - CSRCS += dev_mem.c -endif - -ifeq ($(CONFIG_DEV_ASCII),y) - CSRCS += dev_ascii.c -endif - -ifeq ($(CONFIG_LWL_CONSOLE),y) - CSRCS += lwl_console.c -endif - -ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y) - CSRCS += ramdisk.c -ifeq ($(CONFIG_DRVR_MKRD),y) - CSRCS += mkrd.c -endif -endif - -ifeq ($(CONFIG_DRVR_WRITEBUFFER),y) - CSRCS += rwbuffer.c -else ifeq ($(CONFIG_DRVR_READAHEAD),y) - CSRCS += rwbuffer.c -endif - -ifeq ($(CONFIG_DEV_RPMSG),y) - CSRCS += rpmsgdev.c -endif - -ifeq ($(CONFIG_DEV_RPMSG_SERVER),y) - CSRCS += rpmsgdev_server.c -endif - -ifeq ($(CONFIG_BLK_RPMSG),y) - CSRCS += rpmsgblk.c -endif - -ifeq ($(CONFIG_BLK_RPMSG_SERVER),y) - CSRCS += rpmsgblk_server.c - CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)fs$(DELIM)inode - CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)fs -endif - ifneq ($(CONFIG_DEV_OPTEE_NONE),y) CSRCS += optee.c ifeq ($(CONFIG_DEV_OPTEE_SMC),y) @@ -88,11 +33,7 @@ ifneq ($(CONFIG_DEV_OPTEE_NONE),y) endif endif -ifeq ($(CONFIG_GOLDFISH_PIPE),y) - CSRCS += goldfish_pipe.c -endif - # Include build support -DEPPATH += --dep-path misc -VPATH += :misc +DEPPATH += --dep-path tee +VPATH += :tee diff --git a/drivers/misc/optee.c b/drivers/tee/optee.c similarity index 99% rename from drivers/misc/optee.c rename to drivers/tee/optee.c index 4056e7ff134..bece11acd52 100644 --- a/drivers/misc/optee.c +++ b/drivers/tee/optee.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/misc/optee.c + * drivers/tee/optee.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/drivers/misc/optee.h b/drivers/tee/optee.h similarity index 97% rename from drivers/misc/optee.h rename to drivers/tee/optee.h index 855cd4d8c84..b2f6c1fab3e 100644 --- a/drivers/misc/optee.h +++ b/drivers/tee/optee.h @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/misc/optee.h + * drivers/tee/optee.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __DRIVERS_MISC_OPTEE_H -#define __DRIVERS_MISC_OPTEE_H +#ifndef __DRIVERS_TEE_OPTEE_H +#define __DRIVERS_TEE_OPTEE_H /**************************************************************************** * Included Files @@ -141,4 +141,4 @@ uint32_t optee_convert_from_errno(int err); #if defined(__cplusplus) } #endif -#endif /* __DRIVERS_MISC_OPTEE_H */ +#endif /* __DRIVERS_TEE_OPTEE_H */ diff --git a/drivers/misc/optee_msg.h b/drivers/tee/optee_msg.h similarity index 99% rename from drivers/misc/optee_msg.h rename to drivers/tee/optee_msg.h index 0dfba8b41ea..b91e0818d23 100644 --- a/drivers/misc/optee_msg.h +++ b/drivers/tee/optee_msg.h @@ -1,13 +1,13 @@ /**************************************************************************** - * drivers/misc/optee_msg.h + * drivers/tee/optee_msg.h * * SPDX-License-Identifier: BSD-2-Clause * Copyright (c) 2015-2020, Linaro Limited * ****************************************************************************/ -#ifndef __DRIVERS_MISC_OPTEE_MSG_H -#define __DRIVERS_MISC_OPTEE_MSG_H +#ifndef __DRIVERS_TEE_OPTEE_MSG_H +#define __DRIVERS_TEE_OPTEE_MSG_H /**************************************************************************** * Included Files @@ -486,4 +486,4 @@ struct optee_msg_arg #define OPTEE_MSG_RPC_CMD_I2C_FLAGS_TEN_BIT BIT(0) -#endif /* __DRIVERS_MISC_OPTEE_MSG_H */ +#endif /* __DRIVERS_TEE_OPTEE_MSG_H */ diff --git a/drivers/misc/optee_rpc.c b/drivers/tee/optee_rpc.c similarity index 99% rename from drivers/misc/optee_rpc.c rename to drivers/tee/optee_rpc.c index 3566aee0dc0..38fbaafb5ac 100644 --- a/drivers/misc/optee_rpc.c +++ b/drivers/tee/optee_rpc.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/misc/optee_rpc.c + * drivers/tee/optee_rpc.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/drivers/misc/optee_rpc.h b/drivers/tee/optee_rpc.h similarity index 92% rename from drivers/misc/optee_rpc.h rename to drivers/tee/optee_rpc.h index 447dc1b0067..28f46e180de 100644 --- a/drivers/misc/optee_rpc.h +++ b/drivers/tee/optee_rpc.h @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/misc/optee_rpc.h + * drivers/tee/optee_rpc.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __DRIVERS_MISC_OPTEE_RPC_H -#define __DRIVERS_MISC_OPTEE_RPC_H +#ifndef __DRIVERS_TEE_OPTEE_RPC_H +#define __DRIVERS_TEE_OPTEE_RPC_H /**************************************************************************** * Included Files @@ -45,4 +45,4 @@ void optee_rpc_handle_cmd(FAR struct optee_priv_data *priv, #if defined(__cplusplus) } #endif -#endif /* __DRIVERS_MISC_OPTEE_RPC_H */ +#endif /* __DRIVERS_TEE_OPTEE_RPC_H */ diff --git a/drivers/misc/optee_smc.c b/drivers/tee/optee_smc.c similarity index 99% rename from drivers/misc/optee_smc.c rename to drivers/tee/optee_smc.c index 2e29880691a..3321f7c2d00 100644 --- a/drivers/misc/optee_smc.c +++ b/drivers/tee/optee_smc.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/misc/optee_smc.c + * drivers/tee/optee_smc.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/drivers/misc/optee_smc.h b/drivers/tee/optee_smc.h similarity index 99% rename from drivers/misc/optee_smc.h rename to drivers/tee/optee_smc.h index c9237dd24b3..279c8299d2d 100644 --- a/drivers/misc/optee_smc.h +++ b/drivers/tee/optee_smc.h @@ -1,13 +1,13 @@ /**************************************************************************** - * drivers/misc/optee_smc.h + * drivers/tee/optee_smc.h * * SPDX-License-Identifier: BSD-2-Clause * Copyright (c) 2015-2018, Linaro Limited * ****************************************************************************/ -#ifndef __DRIVERS_MISC_OPTEE_SMC_H -#define __DRIVERS_MISC_OPTEE_SMC_H +#ifndef __DRIVERS_TEE_OPTEE_SMC_H +#define __DRIVERS_TEE_OPTEE_SMC_H /**************************************************************************** * Included Files @@ -445,4 +445,4 @@ static inline bool optee_smc_return_is_rpc(uint32_t ret) OPTEE_SMC_RETURN_RPC_PREFIX; } -#endif /* __DRIVERS_MISC_OPTEE_SMC_H */ +#endif /* __DRIVERS_TEE_OPTEE_SMC_H */ diff --git a/drivers/misc/optee_socket.c b/drivers/tee/optee_socket.c similarity index 99% rename from drivers/misc/optee_socket.c rename to drivers/tee/optee_socket.c index a13899ac85d..d2bf3f1f99a 100644 --- a/drivers/misc/optee_socket.c +++ b/drivers/tee/optee_socket.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/misc/optee_socket.c + * drivers/tee/optee_socket.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/drivers/misc/optee_supplicant.c b/drivers/tee/optee_supplicant.c similarity index 99% rename from drivers/misc/optee_supplicant.c rename to drivers/tee/optee_supplicant.c index 3537db6e289..6ea8eb5d236 100644 --- a/drivers/misc/optee_supplicant.c +++ b/drivers/tee/optee_supplicant.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/misc/optee_supplicant.c + * drivers/tee/optee_supplicant.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/drivers/misc/optee_supplicant.h b/drivers/tee/optee_supplicant.h similarity index 92% rename from drivers/misc/optee_supplicant.h rename to drivers/tee/optee_supplicant.h index 0e97e86e1db..3fe870037d4 100644 --- a/drivers/misc/optee_supplicant.h +++ b/drivers/tee/optee_supplicant.h @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/misc/optee_supplicant.h + * drivers/tee/optee_supplicant.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __DRIVERS_MISC_OPTEE_SUPPLICANT_H -#define __DRIVERS_MISC_OPTEE_SUPPLICANT_H +#ifndef __DRIVERS_TEE_OPTEE_SUPPLICANT_H +#define __DRIVERS_TEE_OPTEE_SUPPLICANT_H /**************************************************************************** * Included Files @@ -61,4 +61,4 @@ int optee_supplicant_recv(FAR uint32_t *func, FAR uint32_t *num_params, #if defined(__cplusplus) } #endif -#endif /* __DRIVERS_MISC_OPTEE_SUPPLICANT_H */ +#endif /* __DRIVERS_TEE_OPTEE_SUPPLICANT_H */
