5 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
8 Desc: Utility functions for exec.
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>
20 #include "exec_intern.h"
22 /* PC and FP registers for various CPUs */
33 #ifdef CONFIG_GCC_FP_A6
37 #define CALLER_FRAME NULL
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;})
52 #error unsupported CPU type
56 #define CALLER_FRAME __builtin_frame_address(1)
76 #define CURRENT_LOCATION(name) {name, __builtin_return_address(0), CALLER_FRAME}
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
, UBYTE action
);
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 */