2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 #include <hardware/intbits.h>
7 #include <exec/interrupts.h>
8 #include <exec/execbase.h>
9 #include <exec/alerts.h>
10 #include <proto/exec.h>
11 #include <aros/asmcall.h>
14 #define timeval sys_timeval
20 void os_disable(void);
21 static int sig2inttabl
[NSIG
];
25 static void sighandler (int sig
, sigcontext_t
* sc
);
27 static void SIGHANDLER (int sig
)
29 sighandler (sig
, (sigcontext_t
*)(&sig
+1));
31 #endif /* __linux__ */
34 static void UnixDispatch (sigcontext_t
* sc
, struct ExecBase
* SysBase
);
38 static void sighandler (int sig
, sigcontext_t
* sc
)
45 fprintf (stderr
, "Illegal supervisor %d\n", supervisor
);
53 iv
=&SysBase
->IntVects
[sig2inttabl
[sig
]];
56 AROS_UFC2(void,iv
->iv_Code
,
57 AROS_UFCA(APTR
,iv
->iv_Data
,A1
),
58 AROS_UFCA(struct ExecBase
*,SysBase
,A6
)
62 if(SysBase
->AttnResched
&0x8000)
64 SysBase
->AttnResched
&=~0x8000;
66 /* UnixDispatch (sc, SysBase); */
74 static void UnixDispatch (sigcontext_t
* sc
, struct ExecBase
* SysBase
)
79 /* Get the address of the current task */
80 this = FindTask (NULL
);
82 printf ("Dispatch(): Old task=%p (%s)\n",
83 this, this && this->tc_Node
.ln_Name
? this->tc_Node
.ln_Name
: "(null)"
87 this->tc_SPReg
= (APTR
)SP(sc
);
89 /* Switch flag set ? Call user function */
90 if (this->tc_Flags
& TF_SWITCH
)
91 (*(this->tc_Switch
)) (SysBase
);
94 this->tc_IDNestCnt
= SysBase
->IDNestCnt
;
95 SysBase
->IDNestCnt
= -1;
97 /* Get next task from ready list */
98 AddTail (&SysBase
->TaskReady
, (struct Node
*)this);
99 this = (struct Task
*)RemHead (&SysBase
->TaskReady
);
101 /* Set state to RUNNING */
102 this->tc_State
= TS_RUN
;
104 /* Restore IDNestCnt */
105 SysBase
->IDNestCnt
= this->tc_IDNestCnt
;
107 /* Launch flag set ? Call user function */
108 if (this->tc_Flags
& TF_LAUNCH
)
109 (*(this->tc_Launch
)) (SysBase
);
114 /* Check stack pointer */
115 if (sp
< this->tc_SPLower
|| sp
> this->tc_SPUpper
)
117 Alert (AT_DeadEnd
|AN_StackProbe
);
118 /* This function never returns */
123 if (this->tc_Flags
& TF_EXCEPT
)
126 printf ("Dispatch(): New task=%p (%s)\n",
127 this, this && this->tc_Node
.ln_Name
? this->tc_Node
.ln_Name
: "(null)"
135 static const int sig2int
[][2]=
137 { SIGALRM
, INTB_VERTB
},
139 struct itimerval interval
;
143 sa
.sa_handler
= (SIGHANDLER_T
)SIGHANDLER
;
144 sigfillset (&sa
.sa_mask
);
145 sa
.sa_flags
= SA_RESTART
;
146 sa
.sa_restorer
= NULL
;
148 for (i
=0; i
<(sizeof(sig2int
)/sizeof(sig2int
[0])); i
++)
150 sig2inttabl
[sig2int
[i
][0]] = sig2int
[i
][1];
152 sigaction (sig2int
[i
][0], &sa
, NULL
);
155 interval
.it_interval
.tv_sec
= interval
.it_value
.tv_sec
= 0;
156 interval
.it_interval
.tv_usec
= interval
.it_value
.tv_usec
= 1000000/50;
158 setitimer (ITIMER_REAL
, &interval
, NULL
);