Test initialisation of MUIA_List_AdjustWidth and MUIA_List_AdjustHeight, and
[AROS.git] / arch / .unmaintained / m68k-emul / initcore.c
blobf0c815a4f544e8832393fa41656a45289d8911f4
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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>
12 #include <stdio.h>
13 #include "sigcore.h"
14 #define timeval sys_timeval
15 #include <sys/time.h>
16 #undef timeval
18 #define NOISY 0
20 void os_disable(void);
21 static int sig2inttabl[NSIG];
22 int supervisor;
24 #ifdef __linux__
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__ */
33 #if 0
34 static void UnixDispatch (sigcontext_t * sc, struct ExecBase * SysBase);
35 #endif
38 static void sighandler (int sig, sigcontext_t * sc)
40 struct IntVector *iv;
42 if (supervisor)
44 #if NOISY
45 fprintf (stderr, "Illegal supervisor %d\n", supervisor);
46 fflush (stderr);
47 #endif
48 return;
51 supervisor++;
53 iv=&SysBase->IntVects[sig2inttabl[sig]];
54 if (iv->iv_Code)
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); */
67 Dispatch ();
70 supervisor--;
71 } /* sighandler */
73 #if 0
74 static void UnixDispatch (sigcontext_t * sc, struct ExecBase * SysBase)
76 struct Task * this;
77 APTR sp;
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)"
86 /* Save old SP */
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);
93 /* Save IDNestCnt */
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);
111 /* Get new SP */
112 sp = this->tc_SPReg;
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 */
121 SP(sc) = (long)sp;
123 if (this->tc_Flags & TF_EXCEPT)
124 Exception ();
126 printf ("Dispatch(): New task=%p (%s)\n",
127 this, this && this->tc_Node.ln_Name ? this->tc_Node.ln_Name : "(null)"
130 } /* UnixDispatch */
131 #endif
133 void InitCore(void)
135 static const int sig2int[][2]=
137 { SIGALRM, INTB_VERTB },
139 struct itimerval interval;
140 int i;
141 struct sigaction sa;
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);
159 } /* InitCore */