source: trunk/kernel/kern/signal.h @ 1

Last change on this file since 1 was 1, checked in by alain, 7 years ago

First import

File size: 7.3 KB
RevLine 
[1]1/*
2 * signal.h - signal-management related operations
3 *
4 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
5 *         Mohamed Lamine Karaoui (2015)
6 *         Alain Greiner    (2016)
7 *
8 * Copyright (c) UPMC Sorbonne Universites
9 *
10 * This file is part of ALMOS-MKH.
11 *
12 * ALMOS-MKH is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2.0 of the License.
15 *
16 * ALMOS-MKH is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#ifndef _SIGNAL_H_
27#define _SIGNAL_H_
28
29#include <hal_types.h>
30
31#define SIG_DEFAULT    (void*)0L
32#define SIG_IGNORE     (void*)1L
33#define SIG_ERROR     -1L
34
35#define SIGHUP     1       /*! hangup */
36#define SIGINT     2       /*! interrupt */
37#define SIGQUIT    3       /*! quit */
38#define SIGILL     4       /*! illegal instruction (not reset when caught) */
39#define SIGTRAP    5       /*! trace trap (not reset when caught) */
40#define SIGIOT     6       /*! IOT instruction */
41#define SIGABRT    6       /*! used by abort, replace SIGIOT in the future */
42#define SIGEMT     7       /*! EMT instruction */
43#define SIGFPE     8       /*! floating point exception */
44#define SIGKILL    9       /*! kill (cannot be caught or ignored) */
45#define SIGBUS     10      /*! bus error */
46#define SIGSEGV    11      /*! segmentation violation */
47#define SIGSYS     12      /*! bad argument to system call */
48#define SIGPIPE    13      /*! write on a pipe with no one to read it */
49#define SIGALRM    14      /*! alarm clock */
50#define SIGTERM    15      /*! software termination signal from kill */
51#define SIGURG     16      /*! urgent condition on IO channel */
52#define SIGSTOP    17      /*! sendable stop signal not from tty */
53#define SIGTSTP    18      /*! stop signal from tty */
54#define SIGCONT    19      /*! continue a stopped process */
55#define SIGCHLD    20      /*! to parent on child stop or exit */
56#define SIGCLD     20      /*! System V name for SIGCHLD */
57#define SIGTTIN    21      /*! to readers pgrp upon background tty read */
58#define SIGTTOU    22      /*! like TTIN for output if (tp->t_local&LTOSTOP) */
59#define SIGIO      23      /*! input/output possible signal */
60#define SIGPOLL    SIGIO   /*! System V name for SIGIO */
61#define SIGXCPU    24      /*! exceeded CPU time limit */
62#define SIGXFSZ    25      /*! exceeded file size limit */
63#define SIGVTALRM  26      /*! virtual time alarm */
64#define SIGPROF    27      /*! profiling time alarm */
65#define SIGWINCH   28      /*! window changed */
66#define SIGLOST    29      /*! resource lost (eg, record-lock lost) */
67#define SIGUSR1    30      /*! user defined signal 1 */
68#define SIGUSR2    31      /*! user defined signal 2 */
69#define SIG_NR     32      /*! signal 0 implied */
70
71#define SIG_DEFAULT_MASK         0xFFEEFFFF
72#define SIG_DEFAULT_STACK_SIZE   2048
73
74/****  Forward declarations  ****/
75
76struct process_s;
77struct thread_s;
78
79typedef uint32_t         sigval_t;
80typedef uint32_t         sigset_t;
81
82/*******************************************************************************************
83 * This structure ...
84 ******************************************************************************************/
85
86typedef struct siginfo_s
87{
88        int      si_signo;    /*! Signal number */
89        int      si_errno;    /*! An errno value */
90        int      si_code;     /*! Signal code */
91        pid_t    si_pid;      /*! Sending process ID */
92        uid_t    si_uid;      /*! Real user ID of sending process */
93        int      si_status;   /*! Exit value or signal */
94        clock_t  si_utime;    /*! User time consumed */
95        clock_t  si_stime;    /*! System time consumed */
96        sigval_t si_value;    /*! Signal value */
97        int      si_int;      /*! POSIX.1b signal */
98        void    *si_ptr;      /*! POSIX.1b signal */
99        void    *si_addr;     /*! Memory location which caused fault */
100        int      si_band;     /*! Band event */
101        int      si_fd;       /*! File descriptor */
102}
103siginfo_t;
104
105/*******************************************************************************************
106 * This structure ...
107 ******************************************************************************************/
108
109typedef void (sa_handler_t) ( uint32_t sig );
110
111typedef struct sigaction_s
112{
113        sigset_t sa_mask;
114        uint32_t sa_flags;
115        union
116        { 
117                sa_handler_t *sa_handler;
118                void (*sa_sigaction)(int, siginfo_t *, void *);
119        };
120}
121sigaction_t;
122
123/*******************************************************************************************
124 * This structure TODO
125 ******************************************************************************************/
126
127typedef struct sig_mgr_s
128{
129        sa_handler_t        * sigactions[SIG_NR];
130 ster   struct thread_s     * handler;
131}
132sig_mgr_t;
133
134
135/*******************************************************************************************
136 * This function TODO
137 ******************************************************************************************/
138int sys_signal ( uint32_t       sig, 
139                 sa_handler_t * handler );
140
141/*******************************************************************************************
142 * This function TODO
143 ******************************************************************************************/
144int sys_sigreturn_setup( void * sigreturn_func );
145
146/*******************************************************************************************
147 * This function TODO
148 ******************************************************************************************/
149int sys_kill( pid_t    pid,
150              uint32_t sig );
151
152/*******************************************************************************************
153 * This function TODO
154 ******************************************************************************************/
155error_t signal_manager_init( struct process_s * process );
156
157/*******************************************************************************************
158 * This function TODO
159 ******************************************************************************************/
160error_t signal_init( struct thread_s * thread );
161
162/*******************************************************************************************
163 * This function register the signal <sig> in the bit-vector of all threads of a given
164 * process identified by its <pid>, on all clusters containing a thread .
165 * It can be executed by any thread running in any cluster.
166 ******************************************************************************************/
167error_t signal_rise( pid_t     pid, 
168                     uint32_t  sig );
169
170/*******************************************************************************************
171 * This function TODO
172 ******************************************************************************************/
173void signal_notify( struct thread_s * this);
174
175/*******************************************************************************************
176 * This function do nothing in this implementation.
177 ******************************************************************************************/
178#define signal_manager_destroy(task)
179
180#endif  /*! _SIGNAL_H_ */
Note: See TracBrowser for help on using the repository browser.