added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / compiler / include / exec / tasks.h
blobf3d46392c75eb04eb6755e6c220752c839654857
1 #ifndef EXEC_TASKS_H
2 #define EXEC_TASKS_H
4 /*
5 Copyright © 1995-2001, 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 /* You must use Exec functions to modify task structure fields. */
26 struct Task
28 struct Node tc_Node;
29 UBYTE tc_Flags;
30 UBYTE tc_State;
31 BYTE tc_IDNestCnt; /* Interrupt disabled nesting */
32 BYTE tc_TDNestCnt; /* Task disabled nesting */
33 ULONG tc_SigAlloc; /* Allocated signals */
34 ULONG tc_SigWait; /* Signals we are waiting for */
35 ULONG tc_SigRecvd; /* Received signals */
36 ULONG tc_SigExcept; /* Signals we will take exceptions for */
37 union
39 struct
41 UWORD tc_ETrapAlloc; /* Allocated traps */
42 UWORD tc_ETrapAble; /* Enabled traps */
43 } tc_ETrap;
44 APTR tc_ETask; /* Valid if TF_ETASK is set */
45 } tc_UnionETask;
46 APTR tc_ExceptData; /* Exception data */
47 APTR tc_ExceptCode; /* Exception code */
48 APTR tc_TrapData; /* Trap data */
49 APTR tc_TrapCode; /* Trap code */
50 APTR tc_SPReg; /* Stack pointer */
51 APTR tc_SPLower; /* Stack lower bound */
52 APTR tc_SPUpper; /* Stack upper bound */
53 VOID (* tc_Switch)(); /* Task loses CPU */
54 VOID (* tc_Launch)(); /* Task gets CPU */
55 struct List tc_MemEntry; /* Allocated memory. Freed by RemTask(). */
56 APTR tc_UserData; /* For use by the task; no restrictions! */
59 #define tc_TrapAlloc tc_UnionETask.tc_ETrap.tc_ETrapAlloc
60 #define tc_TrapAble tc_UnionETask.tc_ETrap.tc_ETrapAble
62 /* Macros */
63 #define GetTrapAlloc(t) \
64 ((((struct Task *)t)->tc_Flags & TF_ETASK) ? \
65 ((struct ETask *)(((struct Task *)t)->tc_UnionETask.tc_ETask))-> \
66 et_TrapAlloc : \
67 ((struct Task *)t)->tc_UnionETask.tc_ETrap.tc_ETrapAlloc)
68 #define GetTrapAble(t) \
69 ((((struct Task *)t)->tc_Flags & TF_ETASK) ? \
70 ((struct ETask *)(((struct Task *)t)->tc_UnionETask.tc_ETask))-> \
71 et_TrapAble : \
72 ((struct Task *)t)->tc_UnionETask.tc_ETrap.tc_ETrapAble)
73 #define GetETask(t) \
74 ((((struct Task *)t)->tc_Flags & TF_ETASK) ? \
75 ((struct ETask *)(((struct Task *)t)->tc_UnionETask.tc_ETask)) \
76 : NULL \
78 #define GetETaskID(t) \
79 ( (((struct Task *)(t))->tc_Flags & TF_ETASK) \
80 ? (((struct ETask *) \
81 (((struct Task *)(t))->tc_UnionETask.tc_ETask))->et_UniqueID) \
82 : 0UL \
86 /* Stack swap structure as passed to StackSwap() */
87 struct StackSwapStruct
89 APTR stk_Lower; /* Lowest byte of stack */
90 APTR stk_Upper; /* Upper end of stack (size + Lowest) */
91 APTR stk_Pointer; /* Stack pointer at switch point */
94 /* tc_Flags Bits */
95 #define TB_PROCTIME 0
96 #define TB_ETASK 3
97 #define TB_STACKCHK 4
98 #define TB_EXCEPT 5
99 #define TB_SWITCH 6
100 #define TB_LAUNCH 7
102 #define TF_PROCTIME (1L<<0)
103 #define TF_ETASK (1L<<3)
104 #define TF_STACKCHK (1L<<4)
105 #define TF_EXCEPT (1L<<5)
106 #define TF_SWITCH (1L<<6)
107 #define TF_LAUNCH (1L<<7)
109 /* Task States (tc_State) */
110 #define TS_INVALID 0
111 #define TS_ADDED 1
112 #define TS_RUN 2
113 #define TS_READY 3
114 #define TS_WAIT 4
115 #define TS_EXCEPT 5
116 #define TS_REMOVED 6
118 /* Predefined Signals */
119 #define SIGB_ABORT 0
120 #define SIGB_CHILD 1
121 #define SIGB_BLIT 4 /* Note: same as SIGB_SINGLE */
122 #define SIGB_SINGLE 4 /* Note: same as SIGB_BLIT */
123 #define SIGB_INTUITION 5
124 #define SIGB_NET 7
125 #define SIGB_DOS 8
127 #define SIGF_ABORT (1L<<0)
128 #define SIGF_CHILD (1L<<1)
129 #define SIGF_BLIT (1L<<4)
130 #define SIGF_SINGLE (1L<<4)
131 #define SIGF_INTUITION (1L<<5)
132 #define SIGF_NET (1L<<7)
133 #define SIGF_DOS (1L<<8)
135 /* Extended Task structure */
136 struct ETask
138 struct Message et_Message;
139 APTR et_Parent; /* Pointer to task */
140 ULONG et_UniqueID;
141 struct MinList et_Children; /* List of children */
142 UWORD et_TrapAlloc;
143 UWORD et_TrapAble;
144 ULONG et_Result1; /* First result */
145 APTR et_Result2; /* Result data pointer (AllocVec) */
146 struct MsgPort et_TaskMsgPort;
148 /* Internal fields follow */
151 /* Return codes from new child functions */
152 #define CHILD_NOTNEW 1 /* Function not called from a new style task */
153 #define CHILD_NOTFOUND 2 /* Child not found */
154 #define CHILD_EXITED 3 /* Child has exited */
155 #define CHILD_ACTIVE 4 /* Child is currently active and running */
157 /* Tags for NewAddTask() */
159 #define TASKTAG_Dummy (TAG_USER + 0x100000)
160 #define TASKTAG_ARG1 (TASKTAG_Dummy + 16)
161 #define TASKTAG_ARG2 (TASKTAG_Dummy + 17)
162 #define TASKTAG_ARG3 (TASKTAG_Dummy + 18)
163 #define TASKTAG_ARG4 (TASKTAG_Dummy + 19)
164 #define TASKTAG_ARG5 (TASKTAG_Dummy + 20)
165 #define TASKTAG_ARG6 (TASKTAG_Dummy + 21)
166 #define TASKTAG_ARG7 (TASKTAG_Dummy + 22)
167 #define TASKTAG_ARG8 (TASKTAG_Dummy + 23)
170 #endif /* EXEC_TASKS_H */