5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
8 Desc: Task structure and constants
13 # include <exec/nodes.h>
16 # include <exec/lists.h>
19 # include <exec/ports.h>
21 #ifndef UTILITY_TAGITEM_H
22 # include <utility/tagitem.h>
27 /* You must use Exec functions to modify task structure fields. */
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 */
43 UWORD tc_ETrapAlloc
; /* Allocated traps */
44 UWORD tc_ETrapAble
; /* Enabled traps */
46 struct ETask
*tc_ETask
; /* Valid if TF_ETASK is set */
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
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;\
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 */
95 IPTR Args
[8]; /* The C function arguments */
101 #define TB_STACKCHK 4
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) */
121 #define TS_SPIN 7 /* AROS specific */
123 /* Predefined Signals */
126 #define SIGB_BLIT 4 /* Note: same as SIGB_SINGLE */
127 #define SIGB_SINGLE 4 /* Note: same as SIGB_BLIT */
128 #define SIGB_INTUITION 5
132 #define SIGF_ABORT (1L<<0)
133 #define SIGF_CHILD (1L<<1)
134 #define SIGF_BLIT (1L<<4)
135 #define SIGF_SINGLE (1L<<4)
136 #define SIGF_INTUITION (1L<<5)
137 #define SIGF_NET (1L<<7)
138 #define SIGF_DOS (1L<<8)
140 /* Define this when compiling MorphOS-compatible source */
141 #ifdef AROS_MORPHOS_COMPATIBLE
143 #define tc_ETask tc_UnionETask.tc_ETask
147 struct Message Message
;
148 struct Task
*Parent
; /* Pointer to task */
150 struct MinList Children
; /* List of children */
153 ULONG Result1
; /* First result */
154 APTR Result2
; /* Result data pointer (AllocVec) */
155 struct MsgPort MsgPort
;
160 /* Internal fields follow */
165 /* Extended Task structure */
168 struct Message et_Message
;
169 APTR et_Parent
; /* Pointer to parent task */
171 struct MinList et_Children
; /* List of children */
174 ULONG et_Result1
; /* First result */
175 APTR et_Result2
; /* Result data pointer (AllocVec) */
176 struct MsgPort et_TaskMsgPort
;
177 void *et_MemPool
; /* Task's private memory pool */
179 IPTR et_Reserved
[1]; /* MorphOS Private */
180 IPTR
*et_TaskStorage
; /* Task Storage Slots */
182 IPTR et_Reserved
[2]; /* MorphOS Private */
185 /* Internal fields follow */
190 /* Return codes from new child functions */
191 #define CHILD_NOTNEW 1 /* Function not called from a new style task */
192 #define CHILD_NOTFOUND 2 /* Child not found */
193 #define CHILD_EXITED 3 /* Child has exited */
194 #define CHILD_ACTIVE 4 /* Child is currently active and running */
196 /* Tags for NewCreateTaskA() and NewAddTask() */
198 #define TASKTAG_Dummy (TAG_USER + 0x100000)
199 #define TASKTAG_ERROR (TASKTAG_Dummy + 0)
200 #define TASKTAG_CODETYPE (TASKTAG_Dummy + 1)
201 #define TASKTAG_PC (TASKTAG_Dummy + 2)
202 #define TASKTAG_FINALPC (TASKTAG_Dummy + 3)
203 #define TASKTAG_STACKSIZE (TASKTAG_Dummy + 4)
204 #define TASKTAG_NAME (TASKTAG_Dummy + 6)
205 #define TASKTAG_USERDATA (TASKTAG_Dummy + 7)
206 #define TASKTAG_PRI (TASKTAG_Dummy + 8)
207 #define TASKTAG_POOLPUDDLE (TASKTAG_Dummy + 9)
208 #define TASKTAG_POOLTHRESH (TASKTAG_Dummy + 10)
209 #define TASKTAG_ARG1 (TASKTAG_Dummy + 16)
210 #define TASKTAG_ARG2 (TASKTAG_Dummy + 17)
211 #define TASKTAG_ARG3 (TASKTAG_Dummy + 18)
212 #define TASKTAG_ARG4 (TASKTAG_Dummy + 19)
213 #define TASKTAG_ARG5 (TASKTAG_Dummy + 20)
214 #define TASKTAG_ARG6 (TASKTAG_Dummy + 21)
215 #define TASKTAG_ARG7 (TASKTAG_Dummy + 22)
216 #define TASKTAG_ARG8 (TASKTAG_Dummy + 23)
217 #define TASKTAG_STARTUPMSG (TASKTAG_Dummy + 24)
218 #define TASKTAG_TASKMSGPORT (TASKTAG_Dummy + 25)
219 #define TASKTAG_FLAGS (TASKTAG_Dummy + 26)
220 #define TASKTAG_TCBEXTRASIZE (TASKTAG_Dummy + 28)
221 #define TASKTAG_AFFINITY (TASKTAG_Dummy + 29)
223 #define TASKERROR_OK 0
224 #define TASKERROR_NOMEMORY 1
226 /* Actions for ShutdownA() */
228 #define SD_ACTION_POWEROFF 0
229 #define SD_ACTION_COLDREBOOT 1
230 #define SD_ACTION_WARMREBOOT 2
232 #endif /* EXEC_TASKS_H */