diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-12-30 17:55:19 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-12-30 17:55:19 -0600 |
commit | 4f38b4fdae5e0b74d551e65cc67021168c05e969 (patch) | |
tree | 7e94c8d5255b943abbdbc9d6f7b5f201fd8764a0 /nuttx | |
parent | ef06e94a13aa48b0f9c1dde244ee3d4299a9156c (diff) | |
download | px4-nuttx-4f38b4fdae5e0b74d551e65cc67021168c05e969.tar.gz px4-nuttx-4f38b4fdae5e0b74d551e65cc67021168c05e969.tar.bz2 px4-nuttx-4f38b4fdae5e0b74d551e65cc67021168c05e969.zip |
NX server needs to be on a kernel thread for the kernel build
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/ChangeLog | 3 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nx_start.c | 26 | ||||
-rw-r--r-- | nuttx/include/nuttx/kthread.h | 108 | ||||
-rw-r--r-- | nuttx/sched/os_bringup.c | 1 | ||||
-rw-r--r-- | nuttx/sched/os_internal.h | 20 | ||||
-rw-r--r-- | nuttx/sched/task_create.c | 1 |
6 files changed, 128 insertions, 31 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index d0ff108d9..de3a448d1 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -6349,3 +6349,6 @@ which allocator is used in the different configurations. Always uses the user-space allocator because that one is required in certain configurations (2013-12-30). + * include/nuttx/kthread.h: Move kernel thread definitions out of + os_internal.h so that the rest of the OS can start kernel threads as + well (2013-12-30). diff --git a/nuttx/graphics/nxmu/nx_start.c b/nuttx/graphics/nxmu/nx_start.c index a15316d04..3b26cc0c5 100644 --- a/nuttx/graphics/nxmu/nx_start.c +++ b/nuttx/graphics/nxmu/nx_start.c @@ -45,6 +45,7 @@ #include <errno.h> #include <debug.h> +#include <nuttx/kthread.h> #include <nuttx/nx/nx.h> #include "nxfe.h" @@ -72,11 +73,11 @@ ****************************************************************************/ /**************************************************************************** - * Name: nx_servertask + * Name: nx_server * * Description: - * NX server thread. This is the entry point into the server thread that - * serializes the multi-threaded accesses to the display. + * NX server thread. This is the entry point into the server kernel + * thread that serializes the multi-threaded accesses to the display. * * Input Parameters: * Standard task start-up parameters (none of which are used) @@ -87,7 +88,7 @@ * ****************************************************************************/ -int nx_servertask(int argc, char *argv[]) +int nx_server(int argc, char *argv[]) { FAR NX_DRIVERTYPE *dev; int ret; @@ -144,7 +145,7 @@ int nx_servertask(int argc, char *argv[]) #endif /* CONFIG_NX_LCDDRIVER */ - /* Then start the server (nx_run does not normally retun) */ + /* Then start the server (nx_run does not normally return) */ ret = nx_run(dev); gvdbg("nx_run returned: %d\n", errno); @@ -184,24 +185,27 @@ int nx_start(void) { pid_t server; - /* Start the server task */ + /* Start the server kernel thread */ gvdbg("Starting server task\n"); - server = TASK_CREATE("NX Server", CONFIG_NXSTART_SERVERPRIO, - CONFIG_NXSTART_SERVERSTACK, nx_servertask, - (FAR char * const *)0); + server = KERNEL_THREAD("NX Server", CONFIG_NXSTART_SERVERPRIO, + CONFIG_NXSTART_SERVERSTACK, nx_server, + (FAR char * const *)0); if (server < 0) { int errcode = errno; DEBUGASSERT(errcode > 0); - gdbg("ERROR: Failed to create nx_servertask task: %d\n", errcode); + gdbg("ERROR: Failed to create nx_server kernel thread: %d\n", errcode); return -errcode; } - /* Wait a bit to let the server get started */ +#if 0 /* Can't do this on the IDLE thread */ + /* Wait a bit to make sure that the server get started */ usleep(50*1000); +#endif + return OK; } diff --git a/nuttx/include/nuttx/kthread.h b/nuttx/include/nuttx/kthread.h new file mode 100644 index 000000000..7d840915c --- /dev/null +++ b/nuttx/include/nuttx/kthread.h @@ -0,0 +1,108 @@ +/**************************************************************************** + * include/nuttx/kthread.h + * Non-standard, NuttX-specific kernel thread-related declarations. + * + * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * 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. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * 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 OWNER 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. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_KTHREAD_H +#define __INCLUDE_NUTTX_KTHREAD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <sched.h> + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/* One processor family supported by NuttX has a single, fixed hardware stack. + * That is the 8051 family. So for that family only, there is a variant form + * of kernel_thread() that does not take a stack size parameter. The following + * helper macro is provided to work around the ugliness of that exception. + */ + +#ifndef CONFIG_CUSTOM_STACK +# define KERNEL_THREAD(n,p,s,e,a) kernel_thread(n,p,s,e,a) +#else +# define KERNEL_THREAD(n,p,s,e,a) kernel_thread(n,p,e,a) +#endif + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/******************************************************************************** + * Name: kernel_thread + * + * Description: + * This function creates and activates a kernel thread task with kernel-mode + * privileges. It is identical to task_create() except that it configures the + * newly started thread to run in kernel model. + * + * Input Parameters: + * (same as task_create()) + * + * Return Value: + * (same as task_create()) + * + ********************************************************************************/ + +#ifndef CONFIG_CUSTOM_STACK +int kernel_thread(FAR const char *name, int priority, int stack_size, + main_t entry, FAR char * const argv[]); +#else +int kernel_thread(FAR const char *name, int priority, main_t entry, + FAR char * const argv[]); +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_NUTTX_KTHREAD_H */ diff --git a/nuttx/sched/os_bringup.c b/nuttx/sched/os_bringup.c index bdaa0e86a..6a41b4248 100644 --- a/nuttx/sched/os_bringup.c +++ b/nuttx/sched/os_bringup.c @@ -50,6 +50,7 @@ #include <nuttx/arch.h> #include <nuttx/init.h> #include <nuttx/wqueue.h> +#include <nuttx/kthread.h> #include <nuttx/userspace.h> #include "os_internal.h" diff --git a/nuttx/sched/os_internal.h b/nuttx/sched/os_internal.h index ed5014cdc..6073bb39f 100644 --- a/nuttx/sched/os_internal.h +++ b/nuttx/sched/os_internal.h @@ -69,18 +69,6 @@ #define MAX_TASKS_MASK (CONFIG_MAX_TASKS-1) #define PIDHASH(pid) ((pid) & MAX_TASKS_MASK) -/* One processor family supported by NuttX has a single, fixed hardware stack. - * That is the 8051 family. So for that family only, there is a variant form - * of kernel_thread() that does not take a stack size parameter. The following - * helper macro is provided to work around the ugliness of that exception. - */ - -#ifndef CONFIG_CUSTOM_STACK -# define KERNEL_THREAD(n,p,s,e,a) kernel_thread(n,p,s,e,a) -#else -# define KERNEL_THREAD(n,p,s,e,a) kernel_thread(n,p,e,a) -#endif - /* A more efficient ways to access the errno */ #define SET_ERRNO(e) \ @@ -238,14 +226,6 @@ int task_exit(void); int task_terminate(pid_t pid, bool nonblocking); void task_exithook(FAR struct tcb_s *tcb, int status, bool nonblocking); void task_recover(FAR struct tcb_s *tcb); - -#ifndef CONFIG_CUSTOM_STACK -int kernel_thread(FAR const char *name, int priority, int stack_size, - main_t entry, FAR char * const argv[]); -#else -int kernel_thread(FAR const char *name, int priority, main_t entry, - FAR char * const argv[]); -#endif bool sched_addreadytorun(FAR struct tcb_s *rtrtcb); bool sched_removereadytorun(FAR struct tcb_s *rtrtcb); bool sched_addprioritized(FAR struct tcb_s *newTcb, DSEG dq_queue_t *list); diff --git a/nuttx/sched/task_create.c b/nuttx/sched/task_create.c index a2221c527..a64b4e21b 100644 --- a/nuttx/sched/task_create.c +++ b/nuttx/sched/task_create.c @@ -46,6 +46,7 @@ #include <nuttx/arch.h> #include <nuttx/kmalloc.h> +#include <nuttx/kthread.h> #include "os_internal.h" #include "group_internal.h" |