prism2.device: Compiler delint
[AROS.git] / arch / .unmaintained / m68k-linux / sigcore.h.src
blob9304f44a9b09d93cf6f8f12837bef919fda1e922
1 /*
2     Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3     $Id$
4 */
6 #ifndef _SIGCORE_H
7 #define _SIGCORE_H
9 #include <signal.h>
10 #include "etask.h"
12 /* Put a value of type SP_TYPE on the stack or get it off the stack. */
14 #define _PUSH(sp,val)   (*--sp = (SP_TYPE)(val))
15 #define _POP(sp)        (*sp++)
17 #include <asm/sigcontext.h>
19 /* sigcontext_t is the type of the signals' context. Linux offers no way
20    to get this context in a legal way, so I have to use tricks. */
22 typedef @sigcontext@ sigcontext_t;
24 /* name and type of the signal handler */
25 #define SIGHANDLER      linux_sighandler
26 #if defined(__GLIBC__) && (__GLIBC__ >= 2)
27 #  define SIGHANDLER_T  __sighandler_t
28 #else
29 #  define SIGHANDLER_T  SignalHandler
30 #endif
32 #define GLOBAL_SIGNAL_INIT \
33         static void sighandler (int sig, sigcontext_t * sc);    \
34                                                                 \
35         extern void SIGHANDLER (int sig, long sigcode, sigcontext_t * scp);  \
36                                                                 \
37         void call_inthandlers(int sig) {                        \
38             struct IntVector *iv;                               \
39                                                                 \
40             iv = &SysBase->IntVects[sig2tab[sig]];              \
41             if (iv->iv_Code)                                    \
42             {                                                   \
43                 AROS_UFC5(void,iv->iv_Code,                     \
44                     AROS_UFCA(ULONG, 0, D1),                    \
45                     AROS_UFCA(ULONG, 0, A0),                    \
46                     AROS_UFCA(APTR,iv->iv_Data,A1),             \
47                     AROS_UFCA(APTR,iv->iv_Code,A5),             \
48                     AROS_UFCA(struct ExecBase *,SysBase,A6)     \
49                 );                                              \
50             }                                                   \
51         }
53 /* Type of the values which can be stored on the stack. A variable
54    which is to be used as a stack pointer must be declared as
55    "SP_TYPE *". */
57 #define SP_TYPE long
59 /* How many general purpose registers are to be saved on the stack
60    when a task switch happens. */
62 #define CPU_NUMREGS     0
64 /* This structure is used to save/restore registers, because the stack is too
65    small. */
67 struct AROS_cpu_context
69     sigcontext_t sc;    /* Signal context struct */
70     ULONG regs[11];     /* normal regs not in sigcontext_t */
71     ULONG fpregs[6*3];  /* FP regs not in sigcontext_t */
74 #define SIZEOF_ALL_REGISTERS    (sizeof (struct AROS_cpu_context))
75 #define GetCpuContext(task)     ((struct AROS_cpu_context *)\
76                                  (GetIntETask(task)->iet_Context))
77 #define GetSP(task)             ((SP_TYPE*)(task->tc_SPReg))
80 /* Macros to access the stack pointer and program counter,
81    PC is the current address in the program code. */
83 #define SP(sc)  (sc->sc_usp) 
84 #define PC(sc)  (sc->sc_pc)
86 /* Macros to enable or disable all signals after the signal handler
87    has returned and the normal execution commences. */
89 #define SC_DISABLE(sc)  (sc->sc_mask = ~0L)
90 #define SC_ENABLE(sc)   (sc->sc_mask = 0L)
92 /* This stuff is not used on Linux/m68k, because the signal handler context
93    doesn't contain enough registers. Some assembler is needed for the signal
94    handler instead. */
96 #define SAVE_CPU(task,sc) /**/
98 #define RESTORE_CPU(task,sc) /**/
100 #define PREPARE_INITIAL_FRAME(sp,pc)    /**/
102 /* Prepare the cpu context */
104 #define PREPARE_INITIAL_CONTEXT(task,pc) \
105         (GetCpuContext(task)->sc.sc_pc = (LONG)pc)
107 /* This macro is similar to PREPARE_INITIAL_FRAME() but also saves
108    all general purpose registers. Use this macro when you want to
109    leave the current tasks' context to save the registers. Note that
110    the argument "sp" of the macro is just the name of the stack
111    pointer. The macro will load it from the sigcontext "sc". You
112    must store the value of "sp" after the macro and hand it to
113    RESTOREREGS() below to restore this context. */
115 #define SAVEREGS(task,sc)       /**/
117 /* This macro does the opposite to SAVEREGS(). It restores all
118    general purpose registers. After that, you can enter the new
119    tasks' context. Both "sp" and "sc" must be initialized.
120    The macro will save the new SP into the sigcontext "sc". */
122 #define RESTOREREGS(task,sc)    /**/
124 /* This macro prints the current signals' context */
126 #define PRINT_SC(sc) \
127         printf ("SC: SP=%08lx  PC=%08lx\n" \
128             , SP(sc), PC(sc) \
129         )
131 /* This macro prints the current stack (after SAVEREGS()) */
133 #define PRINT_STACK(sp) /**/
135 #endif /* _SIGCORE_H */