b08a86171f
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3 42af7a65-404d-4744-a932-0658087f49c3
191 lines
6.5 KiB
C
191 lines
6.5 KiB
C
/************************************************************
|
|
* sig_internal.h
|
|
*
|
|
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
|
* 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.
|
|
* 3. Neither the name Gregory Nutt 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 __SIG_INTERNAL_H
|
|
#define __SIG_INTERNAL_H
|
|
|
|
/************************************************************
|
|
* Included Files
|
|
************************************************************/
|
|
|
|
#include <queue.h>
|
|
#include <sched.h>
|
|
#include <nuttx/kmalloc.h>
|
|
#include <nuttx/os_external.h>
|
|
|
|
/************************************************************
|
|
* Definitions
|
|
************************************************************/
|
|
|
|
/* The following definition determines the number of signal
|
|
* structures to allocate in a block
|
|
*/
|
|
|
|
#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
|
|
|
|
/************************************************************
|
|
* Public Type Definitions
|
|
************************************************************/
|
|
|
|
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
|
|
{
|
|
struct sigactq *flink; /* Forward link */
|
|
struct sigaction act; /* Sigaction data */
|
|
ubyte signo; /* Signal associated with action */
|
|
};
|
|
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
|
|
{
|
|
struct sigpendq *flink; /* Forward link */
|
|
siginfo_t info; /* Signal information */
|
|
ubyte type; /* (Used to manage allocations) */
|
|
};
|
|
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
|
|
{
|
|
struct sigq_s *flink; /* Forward link */
|
|
union
|
|
{
|
|
saVxHandType *sighandler;
|
|
} action; /* Signal action */
|
|
sigset_t mask; /* Additional signals to mask while the
|
|
* the signal-catching functin executes */
|
|
siginfo_t info; /* Signal information */
|
|
ubyte type; /* (Used to manage allocations) */
|
|
};
|
|
typedef struct sigq_s sigq_t;
|
|
|
|
/************************************************************
|
|
* Global Variables
|
|
************************************************************/
|
|
|
|
/* The g_sigfreeaction data structure is a list of available
|
|
* signal action structures.
|
|
*/
|
|
|
|
extern sq_queue_t g_sigfreeaction;
|
|
|
|
/* The g_sigpendingaction data structure is a list of available
|
|
* pending signal action structures.
|
|
*/
|
|
|
|
extern sq_queue_t g_sigpendingaction;
|
|
|
|
/* The g_sigpendingirqaction is a list of available
|
|
* pending signal actions that are reserved for use by
|
|
* interrupt handlers.
|
|
*/
|
|
|
|
extern sq_queue_t g_sigpendingirqaction;
|
|
|
|
/* The g_sigpendingsignal data structure is a list of
|
|
* available pending signal structures.
|
|
*/
|
|
|
|
extern sq_queue_t g_sigpendingsignal;
|
|
|
|
/* The g_sigpendingirqsignal data structure is a list
|
|
* of available pending signal structures that are reserved
|
|
* for use by interrupt handlers.
|
|
*/
|
|
|
|
extern sq_queue_t g_sigpendingirqsignal;
|
|
|
|
/************************************************************
|
|
* Public Inline Functions
|
|
************************************************************/
|
|
|
|
/************************************************************
|
|
* Public Function Prototypes
|
|
************************************************************/
|
|
|
|
/* Internal signal-related interfaces ***********************/
|
|
|
|
/* sig_intialize.c */
|
|
|
|
extern void weak_function sig_initialize(void);
|
|
extern void sig_allocateactionblock(void);
|
|
|
|
/* sig_action.c */
|
|
|
|
extern void sig_releaseaction(sigactq_t *sigact);
|
|
|
|
/* sig_pending.c */
|
|
|
|
extern sigset_t sig_pendingset(_TCB *stcb);
|
|
|
|
/* In files of the same name */
|
|
|
|
extern sigq_t *sig_allocatependingsigaction(void);
|
|
extern void sig_cleanup(_TCB *stcb);
|
|
extern void sig_deliver(_TCB *stcb);
|
|
extern sigactq_t *sig_findaction(_TCB *stcb, int signo);
|
|
extern int sig_lowest(sigset_t *set);
|
|
extern int sig_mqnotempty (int tid, int signo,
|
|
const union sigval value);
|
|
extern int sig_received(_TCB *stcb, siginfo_t *info);
|
|
extern void sig_releasependingsigaction(sigq_t *sigq);
|
|
extern void sig_releasependingsignal(sigpendq_t *sigpend);
|
|
extern sigpendq_t *sig_removependingsignal(_TCB *stcb, int signo);
|
|
extern void sig_unmaskpendingsignal(void);
|
|
|
|
#endif /* __SIG_INTERNAL_H */
|