Added useful custom dimensions to some top-level drawers that lacked them.
[AROS.git] / rom / exec / exec_util.h
blob8a5e10317c1e4a03d2275b60c570696414121e0c
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 #if __GNUC__ > 4 || \
26 (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 ))
27 #define CALLER_FRAME NULL
28 #endif
29 #endif
30 #ifdef __x86_64__
31 #define PC rip
32 #define FP rbp
33 #if __GNUC__ > 4 || \
34 (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 ))
35 #define CALLER_FRAME NULL
36 #endif
37 #endif
38 #ifdef __mc68000__
39 #define PC pc
40 #ifdef CONFIG_GCC_FP_A6
41 #define FP a[6]
42 #else
43 #define FP a[5]
44 #define CALLER_FRAME NULL
45 #endif
46 #endif
47 #ifdef __powerpc__
48 #define PC ip
49 #define FP gpr[1]
50 #endif
51 #ifdef __arm__
52 #define PC pc
53 #define FP r[11]
54 /* __builtin_frame_address(1) returns LR value. Perhaps not AAPCS-compatible. */
55 //#define CALLER_FRAME ({void * _fp; asm volatile("ldr %0, [%%fp, #-4]":"=r"(_fp)); _fp;})
56 #define CALLER_FRAME NULL
57 #endif
59 #ifndef PC
60 #error unsupported CPU type
61 #endif
63 #ifndef CALLER_FRAME
64 #define CALLER_FRAME __builtin_frame_address(1)
65 #endif
67 #ifndef EXEC_TASKS_H
68 struct Task;
69 #endif
70 #ifndef EXEC_LISTS_H
71 struct List;
72 #endif
73 #ifndef ETASK_H
74 struct IntETask;
75 #endif
77 struct TraceLocation
79 const char *function;
80 APTR caller;
81 APTR stack;
84 #define CURRENT_LOCATION(name) {name, __builtin_return_address(0), CALLER_FRAME}
87 Prototypes
89 BOOL PrepareContext(struct Task *task, APTR entryPoint, APTR fallBack,
90 const struct TagItem *tagList, struct ExecBase *SysBase);
92 BOOL Exec_InitETask(struct Task *task, struct ExecBase *SysBase);
93 void Exec_CleanupETask(struct Task *task, struct ExecBase *SysBase);
94 void Exec_ExpungeETask(struct ETask *et, struct ExecBase *SysBase);
95 BOOL Exec_ExpandTS(struct Task *task, struct ExecBase *SysBase);
96 struct ETask *Exec_FindChild(ULONG id, struct ExecBase *SysBase);
97 struct IntETask *FindETask(struct List *, ULONG id, struct ExecBase *SysBase);
99 BOOL Exec_CheckTask(struct Task *task, struct ExecBase *SysBase);
101 STRPTR Alert_AddString(STRPTR dest, CONST_STRPTR src);
102 STRPTR Alert_GetTitle(ULONG alertNum);
103 STRPTR Alert_GetString(ULONG alertnum, STRPTR buf);
104 STRPTR FormatAlert(char *buffer, ULONG alertNum, struct Task *task, APTR location, UBYTE type, struct ExecBase *SysBase);
105 STRPTR FormatTask(STRPTR buffer, const char *text, struct Task *, struct ExecBase *SysBase);
106 STRPTR FormatLocation(STRPTR buf, const char *text, APTR location, struct ExecBase *SysBase);
108 void FormatAlertExtra(char *buffer, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
109 char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBase *SysBase);
110 APTR UnwindFrame(APTR fp, APTR *caller);
112 void Exec_ExtAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
113 ULONG Exec_UserAlert(ULONG alertNum, struct ExecBase *SysBase);
114 void Exec_SystemAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
115 void Exec_DoResetCallbacks(struct IntExecBase *SysBase, UBYTE action);
117 APTR InternalRawDoFmt(CONST_STRPTR FormatString, APTR DataStream, VOID_FUNC PutChProc,
118 APTR PutChData, va_list VaListStream);
120 IPTR *InternalFindResident(const UBYTE *name, IPTR *list);
122 void FastPutMsg(struct MsgPort *port, struct Message *message, struct ExecBase *SysBase);
123 void InternalPutMsg(struct MsgPort *port, struct Message *message, struct ExecBase *SysBase);
125 LONG AllocTaskSignal(struct Task *ThisTask, LONG signalNum, struct ExecBase *SysBase);
127 static inline void InitMsgPort(struct MsgPort *ret)
129 /* Set port to type 'signalling' */
130 ret->mp_Flags = PA_SIGNAL;
131 /* Set port to type MsgPort */
132 ret->mp_Node.ln_Type = NT_MSGPORT;
133 /* Clear the list of messages */
134 NEWLIST(&ret->mp_MsgList);
137 /* Pseudo-functions, including SysBase for nicer calling */
138 #define FindChild(i) Exec_FindChild(i,SysBase)
139 #define FindETask(l,i) Exec_FindETask(l,i,SysBase)
140 #define InitETask(t) Exec_InitETask(t,SysBase)
141 #define CleanupETask(t) Exec_CleanupETask(t,SysBase)
142 #define ExpungeETask(e) Exec_ExpungeETask(e,SysBase)
144 #endif /* _EXEC_UTIL_H */