5 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
8 Desc: Utility functions for exec.
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>
21 #include "exec_intern.h"
23 /* PC and FP registers for various CPUs */
36 #ifdef CONFIG_GCC_FP_A6
40 #define CALLER_FRAME NULL
52 #define CALLER_FRAME NULL
56 #error unsupported CPU type
59 /* Newer gcc gives an error for calling __builtin_frame_address with non 0 arg */
60 /* FIXME: Find a way to get caller's frame, until then it's disabled for now */
61 #if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6 ))
62 #define CALLER_FRAME NULL
66 #define CALLER_FRAME __builtin_frame_address(1)
86 #define CURRENT_LOCATION(name) {name, __builtin_return_address(0), CALLER_FRAME}
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
);
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 */