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