2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* sched/sig_internal.h
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2008-01-10 20:16:50 +01:00
|
|
|
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
2007-02-18 00:21:28 +01:00
|
|
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
|
|
|
*
|
|
|
|
* 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.
|
2008-01-10 20:16:50 +01:00
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
2007-02-18 00:21:28 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
#ifndef __SIG_INTERNAL_H
|
|
|
|
#define __SIG_INTERNAL_H
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-02-27 22:17:21 +01:00
|
|
|
#include <nuttx/compiler.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <queue.h>
|
|
|
|
#include <sched.h>
|
|
|
|
#include <nuttx/kmalloc.h>
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Definitions
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The following definition determines the number of signal structures to
|
|
|
|
* allocate in a block
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define NUM_SIGNAL_ACTIONS 16
|
|
|
|
#define NUM_PENDING_ACTIONS 16
|
|
|
|
#define NUM_PENDING_INT_ACTIONS 8
|
|
|
|
#define NUM_SIGNALS_PENDING 16
|
|
|
|
#define NUM_INT_SIGNALS_PENDING 8
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Type Definitions
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
enum sigalloc_e
|
|
|
|
{
|
|
|
|
SIG_ALLOC_FIXED = 0, /* pre-allocated; never freed */
|
|
|
|
SIG_ALLOC_DYN, /* dynamically allocated; free when unused */
|
|
|
|
SIG_ALLOC_IRQ /* Preallocated, reserved for interrupt handling */
|
|
|
|
};
|
|
|
|
typedef enum sigalloc_e sigalloc_t;
|
|
|
|
|
|
|
|
/* The following defines the sigaction queue entry */
|
|
|
|
|
|
|
|
struct sigactq
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR struct sigactq *flink; /* Forward link */
|
|
|
|
struct sigaction act; /* Sigaction data */
|
2009-12-14 19:39:29 +01:00
|
|
|
uint8_t signo; /* Signal associated with action */
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
typedef struct sigactq sigactq_t;
|
|
|
|
|
|
|
|
/* The following defines the queue structure within each TCB
|
|
|
|
* to hold pending signals received by the task. These are signals that
|
|
|
|
* cannot be processed because: (1) the task is not waiting for them, or
|
|
|
|
* (2) the task has no action associated with the signal.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct sigpendq
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR struct sigpendq *flink; /* Forward link */
|
|
|
|
siginfo_t info; /* Signal information */
|
2009-12-14 19:39:29 +01:00
|
|
|
uint8_t type; /* (Used to manage allocations) */
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
typedef struct sigpendq sigpendq_t;
|
|
|
|
|
|
|
|
/* The following defines the queue structure within each TCB
|
|
|
|
* to hold queued signal actions that need action by the task
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct sigq_s
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR struct sigq_s *flink; /* Forward link */
|
2007-02-18 00:21:28 +01:00
|
|
|
union
|
|
|
|
{
|
2007-02-21 03:19:19 +01:00
|
|
|
void (*sighandler)(int signo, siginfo_t *info, void *context);
|
2007-02-18 00:21:28 +01:00
|
|
|
} action; /* Signal action */
|
2007-02-27 22:17:21 +01:00
|
|
|
sigset_t mask; /* Additional signals to mask while the
|
2007-02-18 00:21:28 +01:00
|
|
|
* the signal-catching functin executes */
|
2007-02-27 22:17:21 +01:00
|
|
|
siginfo_t info; /* Signal information */
|
2009-12-14 19:39:29 +01:00
|
|
|
uint8_t type; /* (Used to manage allocations) */
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
typedef struct sigq_s sigq_t;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Global Variables
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigfreeaction data structure is a list of available signal action
|
|
|
|
* structures.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigfreeaction;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingaction data structure is a list of available pending
|
|
|
|
* signal action structures.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingaction;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingirqaction is a list of available pending signal actions
|
|
|
|
* that are reserved for use by interrupt handlers.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingirqaction;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingsignal data structure is a list of available pending
|
|
|
|
* signal structures.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingsignal;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingirqsignal data structure is a list of available pending
|
|
|
|
* signal structures that are reserved for use by interrupt handlers.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingirqsignal;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Function Prototypes
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* Internal signal-related interfaces ***************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* sig_intialize.c */
|
|
|
|
|
|
|
|
extern void weak_function sig_initialize(void);
|
|
|
|
extern void sig_allocateactionblock(void);
|
|
|
|
|
|
|
|
/* sig_action.c */
|
|
|
|
|
2007-02-27 22:17:21 +01:00
|
|
|
extern void sig_releaseaction(FAR sigactq_t *sigact);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* sig_pending.c */
|
|
|
|
|
2007-02-27 22:17:21 +01:00
|
|
|
extern sigset_t sig_pendingset(FAR _TCB *stcb);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* In files of the same name */
|
|
|
|
|
2007-02-27 22:17:21 +01:00
|
|
|
extern FAR sigq_t *sig_allocatependingsigaction(void);
|
|
|
|
extern void sig_cleanup(FAR _TCB *stcb);
|
|
|
|
extern void sig_deliver(FAR _TCB *stcb);
|
|
|
|
extern FAR sigactq_t *sig_findaction(FAR _TCB *stcb, int signo);
|
2007-02-18 00:21:28 +01:00
|
|
|
extern int sig_lowest(sigset_t *set);
|
2007-02-21 00:51:56 +01:00
|
|
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
2008-01-10 20:16:50 +01:00
|
|
|
extern int sig_mqnotempty(int tid, int signo, union sigval value);
|
2007-02-21 00:51:56 +01:00
|
|
|
#else
|
|
|
|
extern int sig_mqnotempty(int tid, int signo,
|
|
|
|
void *sival_ptr);
|
|
|
|
#endif
|
2007-02-27 22:17:21 +01:00
|
|
|
extern int sig_received(FAR _TCB *stcb, siginfo_t *info);
|
|
|
|
extern void sig_releasependingsigaction(FAR sigq_t *sigq);
|
|
|
|
extern void sig_releasependingsignal(FAR sigpendq_t *sigpend);
|
|
|
|
extern FAR sigpendq_t *sig_removependingsignal(FAR _TCB *stcb, int signo);
|
2007-02-18 00:21:28 +01:00
|
|
|
extern void sig_unmaskpendingsignal(void);
|
|
|
|
|
|
|
|
#endif /* __SIG_INTERNAL_H */
|