BeRTOS
|
00001 00048 #ifndef KERN_SIGNAL_H 00049 #define KERN_SIGNAL_H 00050 00051 #include <cfg/compiler.h> 00052 #include <cfg/macros.h> // BV() 00053 00054 #include <cpu/irq.h> 00055 00056 #include <kern/proc.h> 00057 00058 #if CONFIG_KERN_SIGNALS 00059 00060 INLINE sigmask_t __sig_checkSignal(Signal *s, sigmask_t sigs) 00061 { 00062 sigmask_t result; 00063 00064 result = s->recv & sigs; 00065 s->recv &= ~sigs; 00066 00067 return result; 00068 } 00069 00075 INLINE sigmask_t sig_checkSignal(Signal *s, sigmask_t sigs) 00076 { 00077 cpu_flags_t flags; 00078 sigmask_t result; 00079 00080 IRQ_SAVE_DISABLE(flags); 00081 result = __sig_checkSignal(s, sigs); 00082 IRQ_RESTORE(flags); 00083 00084 return result; 00085 } 00086 00092 INLINE sigmask_t sig_check(sigmask_t sigs) 00093 { 00094 Process *proc = proc_current(); 00095 return sig_checkSignal(&proc->sig, sigs); 00096 } 00097 00098 void sig_sendSignal(Signal *s, Process *proc, sigmask_t sig); 00099 00110 INLINE void sig_send(Process *proc, sigmask_t sig) 00111 { 00112 sig_sendSignal(&proc->sig, proc, sig); 00113 } 00114 00115 void sig_postSignal(Signal *s, Process *proc, sigmask_t sig); 00116 00123 INLINE void sig_post(Process *proc, sigmask_t sig) 00124 { 00125 sig_postSignal(&proc->sig, proc, sig); 00126 } 00127 00128 /* 00129 * XXX: this is provided for backword compatibility, consider to make this 00130 * deprecated for the future. 00131 */ 00132 INLINE void sig_signal(Process *proc, sigmask_t sig) 00133 { 00134 sig_postSignal(&proc->sig, proc, sig); 00135 } 00136 00137 sigmask_t sig_waitSignal(Signal *s, sigmask_t sigs); 00138 00144 INLINE sigmask_t sig_wait(sigmask_t sigs) 00145 { 00146 Process *proc = proc_current(); 00147 return sig_waitSignal(&proc->sig, sigs); 00148 } 00149 00150 sigmask_t sig_waitTimeoutSignal(Signal *s, sigmask_t sigs, ticks_t timeout, 00151 Hook func, iptr_t data); 00152 00159 INLINE sigmask_t sig_waitTimeout(sigmask_t sigs, ticks_t timeout) 00160 { 00161 Process *proc = proc_current(); 00162 return sig_waitTimeoutSignal(&proc->sig, sigs, timeout, 00163 NULL, NULL); 00164 } 00165 00166 #endif /* CONFIG_KERN_SIGNALS */ 00167 00168 int signal_testRun(void); 00169 int signal_testSetup(void); 00170 int signal_testTearDown(void); 00171 00176 #define SIG_USER0 BV(0) 00177 #define SIG_USER1 BV(1) 00178 #define SIG_USER2 BV(2) 00179 #define SIG_USER3 BV(3) 00180 #define SIG_SINGLE BV(4) 00181 #define SIG_SYSTEM5 BV(5) 00182 #define SIG_SYSTEM6 BV(6) 00183 #define SIG_TIMEOUT BV(7) 00188 #define SIG_USER_MAX SIG_SINGLE 00189 /*\}*/ 00190 00191 /* \} */ //defgroup kern_signal 00192 00193 #endif /* KERN_SIGNAL_H */