graphics.library: MakeVPort() RastInfo based double-buffering fixes
[AROS.git] / rom / exec / exec_util.h
blobc200e2079a3cbcf274bf8d638b40d92dfbff3b23
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 #endif
50 #ifndef PC
51 #error unsupported CPU type
52 #endif
54 #ifndef CALLER_FRAME
55 #define CALLER_FRAME __builtin_frame_address(1)
56 #endif
58 #ifndef EXEC_TASKS_H
59 struct Task;
60 #endif
61 #ifndef EXEC_LISTS_H
62 struct List;
63 #endif
64 #ifndef ETASK_H
65 struct IntETask;
66 #endif
68 struct TraceLocation
70 const char *function;
71 APTR caller;
72 APTR stack;
75 #define CURRENT_LOCATION(name) {name, __builtin_return_address(0), CALLER_FRAME}
78 Prototypes
80 BOOL PrepareContext(struct Task *task, APTR entryPoint, APTR fallBack,
81 const struct TagItem *tagList, struct ExecBase *SysBase);
83 BOOL Exec_InitETask(struct Task *task, struct ExecBase *SysBase);
84 void Exec_CleanupETask(struct Task *task, struct ExecBase *SysBase);
85 void Exec_ExpungeETask(struct ETask *et, struct ExecBase *SysBase);
86 BOOL Exec_ExpandTS(struct Task *task, struct ExecBase *SysBase);
87 struct ETask *Exec_FindChild(ULONG id, struct ExecBase *SysBase);
88 struct IntETask *FindETask(struct List *, ULONG id, struct ExecBase *SysBase);
90 BOOL Exec_CheckTask(struct Task *task, struct ExecBase *SysBase);
92 STRPTR Alert_AddString(STRPTR dest, CONST_STRPTR src);
93 STRPTR Alert_GetTitle(ULONG alertNum);
94 STRPTR Alert_GetString(ULONG alertnum, STRPTR buf);
95 STRPTR FormatAlert(char *buffer, ULONG alertNum, struct Task *task, APTR location, UBYTE type, struct ExecBase *SysBase);
96 STRPTR FormatTask(STRPTR buffer, const char *text, struct Task *, struct ExecBase *SysBase);
97 STRPTR FormatLocation(STRPTR buf, const char *text, APTR location, struct ExecBase *SysBase);
99 void FormatAlertExtra(char *buffer, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
100 char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBase *SysBase);
101 APTR UnwindFrame(APTR fp, APTR *caller);
103 void Exec_ExtAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
104 ULONG Exec_UserAlert(ULONG alertNum, struct ExecBase *SysBase);
105 void Exec_SystemAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
106 void Exec_DoResetCallbacks(struct IntExecBase *SysBase, UBYTE action);
108 APTR InternalRawDoFmt(CONST_STRPTR FormatString, APTR DataStream, VOID_FUNC PutChProc,
109 APTR PutChData, va_list VaListStream);
111 IPTR *InternalFindResident(const UBYTE *name, IPTR *list);
113 void FastPutMsg(struct MsgPort *port, struct Message *message, struct ExecBase *SysBase);
114 void InternalPutMsg(struct MsgPort *port, struct Message *message, struct ExecBase *SysBase);
116 LONG AllocTaskSignal(struct Task *ThisTask, LONG signalNum, struct ExecBase *SysBase);
118 static inline void InitMsgPort(struct MsgPort *ret)
120 /* Set port to type 'signalling' */
121 ret->mp_Flags = PA_SIGNAL;
122 /* Set port to type MsgPort */
123 ret->mp_Node.ln_Type = NT_MSGPORT;
124 /* Clear the list of messages */
125 NEWLIST(&ret->mp_MsgList);
128 /* Pseudo-functions, including SysBase for nicer calling */
129 #define FindChild(i) Exec_FindChild(i,SysBase)
130 #define FindETask(l,i) Exec_FindETask(l,i,SysBase)
131 #define InitETask(t) Exec_InitETask(t,SysBase)
132 #define CleanupETask(t) Exec_CleanupETask(t,SysBase)
133 #define ExpungeETask(e) Exec_ExpungeETask(e,SysBase)
135 #endif /* _EXEC_UTIL_H */