You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/14 15:30:02 UTC
[incubator-nuttx] 02/04: arch: risc-v: Add up_pthread_start.c and
up_task_start.c to common dir
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch pr282
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 5fcde14cd1081ddbf7a641a701da51c38b7ab57c
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Fri Feb 14 16:08:36 2020 +0900
arch: risc-v: Add up_pthread_start.c and up_task_start.c to common dir
---
arch/risc-v/src/common/up_pthread_start.c | 70 +++++++++++++++++++++++++++++++
arch/risc-v/src/common/up_task_start.c | 70 +++++++++++++++++++++++++++++++
2 files changed, 140 insertions(+)
diff --git a/arch/risc-v/src/common/up_pthread_start.c b/arch/risc-v/src/common/up_pthread_start.c
new file mode 100644
index 0000000..5b346c5
--- /dev/null
+++ b/arch/risc-v/src/common/up_pthread_start.c
@@ -0,0 +1,70 @@
+/****************************************************************************
+ * arch/risc-v/src/common/up_pthread_start.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <pthread.h>
+#include <nuttx/arch.h>
+
+#include "svcall.h"
+#include "up_internal.h"
+
+#if ((defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \
+ defined(CONFIG_BUILD_KERNEL)) && !defined(CONFIG_DISABLE_PTHREAD)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_pthread_start
+ *
+ * Description:
+ * In this kernel mode build, this function will be called to execute a
+ * pthread in user-space. When the pthread is first started, a kernel-mode
+ * stub will first run to perform some housekeeping functions. This
+ * kernel-mode stub will then be called transfer control to the user-mode
+ * pthread.
+ *
+ * Normally the a user-mode start-up stub will also execute before the
+ * pthread actually starts. See libc/pthread/pthread_startup.c
+ *
+ * Input Parameters:
+ * entrypt - The user-space address of the pthread entry point
+ * arg - Standard argument for the pthread entry point
+ *
+ * Returned Value:
+ * This function should not return. It should call the user-mode start-up
+ * stub and that stub should call pthread_exit if/when the user pthread
+ * terminates.
+ *
+ ****************************************************************************/
+
+void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg)
+{
+ /* Let sys_call2() do all of the work */
+
+ sys_call2(SYS_pthread_start, (uintptr_t)entrypt, (uintptr_t)arg);
+}
+
+#endif /* (CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && !CONFIG_DISABLE_PTHREAD */
diff --git a/arch/risc-v/src/common/up_task_start.c b/arch/risc-v/src/common/up_task_start.c
new file mode 100644
index 0000000..52920b2
--- /dev/null
+++ b/arch/risc-v/src/common/up_task_start.c
@@ -0,0 +1,70 @@
+/****************************************************************************
+ * arch/risc-v/src/common/up_task_start.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/arch.h>
+
+#include "svcall.h"
+#include "up_internal.h"
+
+#if defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_task_start
+ *
+ * Description:
+ * In this kernel mode build, this function will be called to execute a
+ * task in user-space. When the task is first started, a kernel-mode
+ * stub will first run to perform some housekeeping functions. This
+ * kernel-mode stub will then be called transfer control to the user-mode
+ * task.
+ *
+ * Normally the a user-mode start-up stub will also execute before the
+ * task actually starts. See libc/sched/task_startup.c
+ *
+ * Input Parameters:
+ * taskentry - The user-space entry point of the task.
+ * argc - The number of parameters being passed.
+ * argv - The parameters being passed. These lie in kernel-space memory
+ * and will have to be reallocated in user-space memory.
+ *
+ * Returned Value:
+ * This function should not return. It should call the user-mode start-up
+ * stub and that stub should call exit if/when the user task terminates.
+ *
+ ****************************************************************************/
+
+void up_task_start(main_t taskentry, int argc, FAR char *argv[])
+{
+ /* Let sys_call3() do all of the work */
+
+ sys_call3(SYS_task_start, (uintptr_t)taskentry, (uintptr_t)argc,
+ (uintptr_t)argv);
+}
+
+#endif /* CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL */