Minor fixes to comments.
[AROS.git] / rom / exec / exec_util.h
blob869f1ba7d0558f3f14acbd22362d6bf19b3572ea
1 #ifndef _EXEC_UTIL_H
2 #define _EXEC_UTIL_H
4 /*
5 Copyright © 1995-2011, 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/alib.h>
16 #include <proto/arossupport.h>
18 #include <stdarg.h>
20 #include "exec_intern.h"
22 /* PC and FP registers for various CPUs */
23 #ifdef __i386__
24 #define PC eip
25 #define FP ebp
26 #endif
27 #ifdef __x86_64__
28 #define PC rip
29 #define FP rbp
30 #endif
31 #ifdef __mc68000__
32 #define PC pc
33 #ifdef CONFIG_GCC_FP_A6
34 #define FP a[6]
35 #else
36 #define FP a[5]
37 #define CALLER_FRAME NULL
38 #endif
39 #endif
40 #ifdef __powerpc__
41 #define PC ip
42 #define FP gpr[1]
43 #endif
44 #ifdef __arm__
45 #define PC pc
46 #define FP r[11]
47 /* __builtin_frame_address(1) returns LR value. Perhaps not AAPCS-compatible. */
48 #define CALLER_FRAME ({void * _fp; asm volatile("ldr %0, [%%fp, #-4]":"=r"(_fp)); _fp;})
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);
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 */