move running tasks to the private running list
[AROS.git] / rom / exec / exec_util.h
blobdb1670e2fa6254b139d4acbf7135fb44fec43376
1 #ifndef _EXEC_UTIL_H
2 #define _EXEC_UTIL_H
4 /*
5 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Utility functions for exec.
9 Lang: english
12 #include <aros/asmcall.h>
13 #include <exec/types.h>
14 #include <utility/tagitem.h>
15 #include <proto/arossupport.h>
17 #include <stdarg.h>
19 #include "exec_intern.h"
21 /* PC and FP registers for various CPUs */
22 #ifdef __i386__
23 #define PC eip
24 #define FP ebp
25 #endif
26 #ifdef __x86_64__
27 #define PC rip
28 #define FP rbp
29 #endif
30 #ifdef __mc68000__
31 #define PC pc
32 #ifdef CONFIG_GCC_FP_A6
33 #define FP a[6]
34 #else
35 #define FP a[5]
36 #define CALLER_FRAME NULL
37 #endif
38 #endif
39 #ifdef __powerpc__
40 #define PC ip
41 #define FP gpr[1]
42 #endif
43 #ifdef __arm__
44 #define PC pc
45 #define FP r[11]
46 /* __builtin_frame_address(1) returns LR value. Perhaps not AAPCS-compatible. */
47 //#define CALLER_FRAME ({void * _fp; asm volatile("ldr %0, [%%fp, #-4]":"=r"(_fp)); _fp;})
48 #define CALLER_FRAME NULL
49 #endif
51 #ifndef PC
52 #error unsupported CPU type
53 #endif
55 #ifndef CALLER_FRAME
56 #define CALLER_FRAME __builtin_frame_address(1)
57 #endif
59 #ifndef EXEC_TASKS_H
60 struct Task;
61 #endif
62 #ifndef EXEC_LISTS_H
63 struct List;
64 #endif
65 #ifndef ETASK_H
66 struct IntETask;
67 #endif
69 struct TraceLocation
71 const char *function;
72 APTR caller;
73 APTR stack;
76 #define CURRENT_LOCATION(name) {name, __builtin_return_address(0), CALLER_FRAME}
79 Prototypes
81 BOOL PrepareContext(struct Task *task, APTR entryPoint, APTR fallBack,
82 const struct TagItem *tagList, struct ExecBase *SysBase);
84 BOOL Exec_InitETask(struct Task *task, struct ExecBase *SysBase);
85 void Exec_CleanupETask(struct Task *task, struct ExecBase *SysBase);
86 void Exec_ExpungeETask(struct ETask *et, struct ExecBase *SysBase);
87 BOOL Exec_ExpandTS(struct Task *task, struct ExecBase *SysBase);
88 struct ETask *Exec_FindChild(ULONG id, struct ExecBase *SysBase);
89 struct IntETask *FindETask(struct List *, ULONG id, struct ExecBase *SysBase);
91 BOOL Exec_CheckTask(struct Task *task, struct ExecBase *SysBase);
93 STRPTR Alert_AddString(STRPTR dest, CONST_STRPTR src);
94 STRPTR Alert_GetTitle(ULONG alertNum);
95 STRPTR Alert_GetString(ULONG alertnum, STRPTR buf);
96 STRPTR FormatAlert(char *buffer, ULONG alertNum, struct Task *task, APTR location, UBYTE type, struct ExecBase *SysBase);
97 STRPTR FormatTask(STRPTR buffer, const char *text, struct Task *, struct ExecBase *SysBase);
98 STRPTR FormatLocation(STRPTR buf, const char *text, APTR location, struct ExecBase *SysBase);
100 void FormatAlertExtra(char *buffer, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
101 char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBase *SysBase);
102 APTR UnwindFrame(APTR fp, APTR *caller);
104 void Exec_ExtAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
105 ULONG Exec_UserAlert(ULONG alertNum, struct ExecBase *SysBase);
106 void Exec_SystemAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
107 void Exec_DoResetCallbacks(struct IntExecBase *SysBase, UBYTE action);
109 APTR InternalRawDoFmt(CONST_STRPTR FormatString, APTR DataStream, VOID_FUNC PutChProc,
110 APTR PutChData, va_list VaListStream);
112 IPTR *InternalFindResident(const UBYTE *name, IPTR *list);
114 void FastPutMsg(struct MsgPort *port, struct Message *message, struct ExecBase *SysBase);
115 void InternalPutMsg(struct MsgPort *port, struct Message *message, struct ExecBase *SysBase);
117 LONG AllocTaskSignal(struct Task *ThisTask, LONG signalNum, struct ExecBase *SysBase);
119 static inline void InitMsgPort(struct MsgPort *ret)
121 /* Set port to type 'signalling' */
122 ret->mp_Flags = PA_SIGNAL;
123 /* Set port to type MsgPort */
124 ret->mp_Node.ln_Type = NT_MSGPORT;
125 /* Clear the list of messages */
126 NEWLIST(&ret->mp_MsgList);
129 /* Pseudo-functions, including SysBase for nicer calling */
130 #define FindChild(i) Exec_FindChild(i,SysBase)
131 #define FindETask(l,i) Exec_FindETask(l,i,SysBase)
132 #define InitETask(t) Exec_InitETask(t,SysBase)
133 #define CleanupETask(t) Exec_CleanupETask(t,SysBase)
134 #define ExpungeETask(e) Exec_ExpungeETask(e,SysBase)
136 #endif /* _EXEC_UTIL_H */