revert between 56095 -> 55830 in arch
[AROS.git] / compiler / include / exec / tasks.h
blobd774501b50e366f2e9a2206ccc4c6022dacd053e
1 #ifndef EXEC_TASKS_H
2 #define EXEC_TASKS_H
4 /*
5 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Task structure and constants
9 Lang: english
12 #ifndef EXEC_NODES_H
13 # include <exec/nodes.h>
14 #endif
15 #ifndef EXEC_LISTS_H
16 # include <exec/lists.h>
17 #endif
18 #ifndef EXEC_PORTS_H
19 # include <exec/ports.h>
20 #endif
21 #ifndef UTILITY_TAGITEM_H
22 # include <utility/tagitem.h>
23 #endif
25 struct ETask;
27 /* You must use Exec functions to modify task structure fields. */
28 struct Task
30 struct Node tc_Node;
31 UBYTE tc_Flags;
32 UBYTE tc_State;
33 BYTE tc_IDNestCnt; /* Interrupt disabled nesting */
34 BYTE tc_TDNestCnt; /* Task disabled nesting */
35 ULONG tc_SigAlloc; /* Allocated signals */
36 ULONG tc_SigWait; /* Signals we are waiting for */
37 ULONG tc_SigRecvd; /* Received signals */
38 ULONG tc_SigExcept; /* Signals we will take exceptions for */
39 union
41 struct
43 UWORD tc_ETrapAlloc; /* Allocated traps */
44 UWORD tc_ETrapAble; /* Enabled traps */
45 } tc_ETrap;
46 struct ETask *tc_ETask; /* Valid if TF_ETASK is set */
47 } tc_UnionETask;
48 APTR tc_ExceptData; /* Exception data */
49 APTR tc_ExceptCode; /* Exception code */
50 APTR tc_TrapData; /* Trap data */
51 APTR tc_TrapCode; /* Trap code */
52 APTR tc_SPReg; /* Stack pointer */
53 APTR tc_SPLower; /* Stack lower bound */
54 APTR tc_SPUpper; /* Stack upper bound */
55 VOID (* tc_Switch)(); /* Task loses CPU */
56 VOID (* tc_Launch)(); /* Task gets CPU */
57 struct List tc_MemEntry; /* Allocated memory. Freed by RemTask(). */
58 APTR tc_UserData; /* For use by the task; no restrictions! */
61 #define tc_TrapAlloc tc_UnionETask.tc_ETrap.tc_ETrapAlloc
62 #define tc_TrapAble tc_UnionETask.tc_ETrap.tc_ETrapAble
64 /* Macros */
65 #define GetTrapAlloc(t) \
66 ({struct Task *_t = (struct Task *)t;\
67 (_t->tc_Flags & TF_ETASK) ? _t->tc_UnionETask.tc_ETask->et_TrapAlloc : \
68 _t->tc_UnionETask.tc_ETrap.tc_ETrapAlloc; \
70 #define GetTrapAble(t) \
71 ({struct Task *_t = (struct Task *)t;\
72 (_t->tc_Flags & TF_ETASK) ? _t->tc_UnionETask.tc_ETask->et_TrapAble : \
73 _t->tc_UnionETask.tc_ETrap.tc_ETrapAble;\
75 #define GetETask(t) \
76 ({struct Task *_t = (struct Task *)t;\
77 (_t->tc_Flags & TF_ETASK) ? _t->tc_UnionETask.tc_ETask : NULL; \
79 #define GetETaskID(t) \
80 ({struct Task *_t = (struct Task *)t;\
81 (_t->tc_Flags & TF_ETASK) ? _t->tc_UnionETask.tc_ETask->et_UniqueID: 0UL; \
85 /* Stack swap structure as passed to StackSwap() */
86 struct StackSwapStruct
88 APTR stk_Lower; /* Lowest byte of stack */
89 APTR stk_Upper; /* Upper end of stack (size + Lowest) */
90 APTR stk_Pointer; /* Stack pointer at switch point */
93 struct StackSwapArgs
95 IPTR Args[8]; /* The C function arguments */
98 /* tc_Flags Bits */
99 #define TB_PROCTIME 0
100 #define TB_ETASK 3
101 #define TB_STACKCHK 4
102 #define TB_EXCEPT 5
103 #define TB_SWITCH 6
104 #define TB_LAUNCH 7
106 #define TF_PROCTIME (1L<<0)
107 #define TF_ETASK (1L<<3)
108 #define TF_STACKCHK (1L<<4)
109 #define TF_EXCEPT (1L<<5)
110 #define TF_SWITCH (1L<<6)
111 #define TF_LAUNCH (1L<<7)
113 /* Task States (tc_State) */
114 #define TS_INVALID 0
115 #define TS_ADDED 1
116 #define TS_RUN 2
117 #define TS_READY 3
118 #define TS_WAIT 4
119 #define TS_EXCEPT 5
120 #define TS_REMOVED 6
121 /* AROS specific */
122 #define TS_TOMBSTONED 7
123 #define TS_SPIN 8
125 /* Predefined Signals */
126 #define SIGB_ABORT 0
127 #define SIGB_CHILD 1
128 #define SIGB_BLIT 4 /* Note: same as SIGB_SINGLE */
129 #define SIGB_SINGLE 4 /* Note: same as SIGB_BLIT */
130 #define SIGB_INTUITION 5
131 #define SIGB_NET 7
132 #define SIGB_DOS 8
134 #define SIGF_ABORT (1L<<0)
135 #define SIGF_CHILD (1L<<1)
136 #define SIGF_BLIT (1L<<4)
137 #define SIGF_SINGLE (1L<<4)
138 #define SIGF_INTUITION (1L<<5)
139 #define SIGF_NET (1L<<7)
140 #define SIGF_DOS (1L<<8)
142 /* Define this when compiling MorphOS-compatible source */
143 #ifdef AROS_MORPHOS_COMPATIBLE
145 #define tc_ETask tc_UnionETask.tc_ETask
147 struct ETask
149 struct Message Message;
150 struct Task *Parent; /* Pointer to task */
151 ULONG UniqueID;
152 struct MinList Children; /* List of children */
153 UWORD TrapAlloc;
154 UWORD TrapAble;
155 ULONG Result1; /* First result */
156 APTR Result2; /* Result data pointer (AllocVec) */
157 struct MsgPort MsgPort;
158 void *MemPool;
159 void *Reserved[2];
160 void *RegFrame;
162 /* Internal fields follow */
165 #else
167 /* Extended Task structure */
168 struct ETask
170 struct Message et_Message;
171 APTR et_Parent; /* Pointer to parent task */
172 ULONG et_UniqueID;
173 struct MinList et_Children; /* List of children */
174 UWORD et_TrapAlloc;
175 UWORD et_TrapAble;
176 ULONG et_Result1; /* First result */
177 APTR et_Result2; /* Result data pointer (AllocVec) */
178 struct MsgPort et_TaskMsgPort;
179 void *et_MemPool; /* Task's private memory pool */
180 #ifdef __AROS__
181 IPTR et_Reserved[1]; /* MorphOS Private */
182 IPTR *et_TaskStorage; /* Task Storage Slots */
183 #else
184 IPTR et_Reserved[2]; /* MorphOS Private */
185 #endif
186 void *et_RegFrame;
187 /* Internal fields follow */
190 #endif
192 /* Return codes from new child functions */
193 #define CHILD_NOTNEW 1 /* Function not called from a new style task */
194 #define CHILD_NOTFOUND 2 /* Child not found */
195 #define CHILD_EXITED 3 /* Child has exited */
196 #define CHILD_ACTIVE 4 /* Child is currently active and running */
198 /* Tags for NewCreateTaskA() and NewAddTask() */
200 #define TASKTAG_Dummy (TAG_USER + 0x100000)
201 #define TASKTAG_ERROR (TASKTAG_Dummy + 0)
202 #define TASKTAG_CODETYPE (TASKTAG_Dummy + 1)
203 #define TASKTAG_PC (TASKTAG_Dummy + 2)
204 #define TASKTAG_FINALPC (TASKTAG_Dummy + 3)
205 #define TASKTAG_STACKSIZE (TASKTAG_Dummy + 4)
206 #define TASKTAG_NAME (TASKTAG_Dummy + 6)
207 #define TASKTAG_USERDATA (TASKTAG_Dummy + 7)
208 #define TASKTAG_PRI (TASKTAG_Dummy + 8)
209 #define TASKTAG_POOLPUDDLE (TASKTAG_Dummy + 9)
210 #define TASKTAG_POOLTHRESH (TASKTAG_Dummy + 10)
211 #define TASKTAG_ARG1 (TASKTAG_Dummy + 16)
212 #define TASKTAG_ARG2 (TASKTAG_Dummy + 17)
213 #define TASKTAG_ARG3 (TASKTAG_Dummy + 18)
214 #define TASKTAG_ARG4 (TASKTAG_Dummy + 19)
215 #define TASKTAG_ARG5 (TASKTAG_Dummy + 20)
216 #define TASKTAG_ARG6 (TASKTAG_Dummy + 21)
217 #define TASKTAG_ARG7 (TASKTAG_Dummy + 22)
218 #define TASKTAG_ARG8 (TASKTAG_Dummy + 23)
219 #define TASKTAG_STARTUPMSG (TASKTAG_Dummy + 24)
220 #define TASKTAG_TASKMSGPORT (TASKTAG_Dummy + 25)
221 #define TASKTAG_FLAGS (TASKTAG_Dummy + 26)
222 #define TASKTAG_TCBEXTRASIZE (TASKTAG_Dummy + 28)
223 #define TASKTAG_AFFINITY (TASKTAG_Dummy + 29)
224 #define TASKAFFINITY_BOOT 0
225 #define TASKAFFINITY_ANY ((IPTR)-1)
226 #define TASKAFFINITY_ALL_BUT_SELF ((IPTR)-2)
228 #define TASKERROR_OK 0
229 #define TASKERROR_NOMEMORY 1
231 /* Actions for ShutdownA() */
233 #define SD_ACTION_POWEROFF 0
234 #define SD_ACTION_COLDREBOOT 1
235 #define SD_ACTION_WARMREBOOT 2
237 #endif /* EXEC_TASKS_H */