You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/11/23 14:25:57 UTC

(nuttx) 02/02: driver/tee: add some comments and document files in LICENSE

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 5a043548329113f6a4cd47fd4d6d0b061dcd4616
Author: hujun5 <hu...@xiaomi.com>
AuthorDate: Tue Nov 21 15:19:04 2023 +0800

    driver/tee: add some comments and document files in LICENSE
    
    Signed-off-by: hujun5 <hu...@xiaomi.com>
---
 LICENSE              | 33 +++++++++++++++++++++++++++++++++
 drivers/misc/Kconfig | 16 ++++++++++++----
 drivers/misc/optee.c | 20 ++++++++++++++------
 3 files changed, 59 insertions(+), 10 deletions(-)

diff --git a/LICENSE b/LICENSE
index 2247c20b2e..ae678e7e39 100644
--- a/LICENSE
+++ b/LICENSE
@@ -8464,3 +8464,36 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 ----------------------------------------------------------------------
+
+drivers/misc/optee_msg.h
+======================
+PDX-License-Identifier: BSD-2-Clause
+Copyright (c) 2015-2020, Linaro Limited
+
+include/nuttx/tee.h
+======================
+Copyright (c) 2015-2016, Linaro Limited
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following
+conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 8f4a492e12..f2582dc40d 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -33,24 +33,32 @@ config DEV_RPMSG_SERVER
 	depends on RPTUN
 
 choice
-	prompt "Select optee dev implementation"
+	prompt "Select OP-TEE dev implementation"
 	default DEV_OPTEE_NONE
+	---help---
+		There are two 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 is teeos which runs in the secure state of
+		the cpu and uses rpmsg cross-core communication.
 
 config DEV_OPTEE_LOCAL
 	bool "OPTEE Local Socket Support"
 	depends on NET_LOCAL
+	depends on ALLOW_BSD_COMPONENTS
 
 config DEV_OPTEE_RPMSG
-	bool "OPTEE RPMSG Socket Support"
+	bool "OP-TEE RPMSG Socket Support"
 	depends on NET_RPMSG
+	depends on ALLOW_BSD_COMPONENTS
 
 config DEV_OPTEE_NONE
-	bool "Disable optee driver"
+	bool "Disable OP-TEE driver"
 
 endchoice
 
 config OPTEE_REMOTE_CPU_NAME
-	string "The cpuname on which the optee server runs"
+	string "The cpuname on which the OP-TEE server runs"
 	default "tee"
 	depends on DEV_OPTEE_RPMSG
 
diff --git a/drivers/misc/optee.c b/drivers/misc/optee.c
index 1faf7f1126..96e4310917 100644
--- a/drivers/misc/optee.c
+++ b/drivers/misc/optee.c
@@ -35,6 +35,14 @@
 
 #include "optee_msg.h"
 
+/****************************************************************************
+ *   The driver's main purpose is to support the porting of the open source
+ * component optee_client (https://github.com/OP-TEE/optee_client) to NuttX.
+ *   The basic function of the driver module is to convert
+ * the REE application layer data and send it to the TEE through rpmsg.
+ * TEE implementation is optee_os(https://github.com/OP-TEE/optee_os).
+ ****************************************************************************/
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
@@ -51,7 +59,7 @@
 
 #define TEE_ORIGIN_COMMS               0x00000002
 
-#define TEE_IOCTL_PARAM_SIZE(x)         (sizeof(struct tee_ioctl_param) * (x))
+#define TEE_IOCTL_PARAM_SIZE(x)        (sizeof(struct tee_ioctl_param) * (x))
 
 #define OPTEE_MAX_IOVEC_NUM             7
 #define OPTEE_MAX_PARAM_NUM             6
@@ -72,7 +80,7 @@
 static int optee_open(FAR struct file *filep);
 static int optee_close(FAR struct file *filep);
 static int optee_ioctl(FAR struct file *filep, int cmd,
-                          unsigned long arg);
+                       unsigned long arg);
 
 /****************************************************************************
  * Private Data
@@ -448,7 +456,7 @@ static int optee_ioctl_open_session(FAR struct socket *psocket,
     }
 
   ret = optee_from_msg_param(arg->params, arg->num_params,
-                                msg->params + 2);
+                             msg->params + 2);
   if (ret < 0)
     {
       return ret;
@@ -565,20 +573,20 @@ optee_ioctl_shm_alloc(FAR struct tee_ioctl_shm_alloc_data *data)
 
   if (memfd < 0)
     {
-      return -errno;
+      return get_errno();
     }
 
   if (ftruncate(memfd, data->size) < 0)
     {
       close(memfd);
-      return -errno;
+      return get_errno();
     }
 
   data->id = (uintptr_t)mmap(NULL, data->size, PROT_READ | PROT_WRITE,
                              MAP_SHARED, memfd, 0);
   if (data->id == (uintptr_t)MAP_FAILED)
     {
-      return -errno;
+      return get_errno();
     }
 
   return memfd;