Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / rom / exec / exec_util.h
blob15211b6a6bf0681104ff76c10c46999b6f0a5fd9
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
70 Prototypes
72 APTR Exec_AllocTaskMem (struct Task * task, ULONG size, ULONG flags, struct ExecBase *SysBase);
73 void Exec_FreeTaskMem (struct Task * task, APTR mem, struct ExecBase *SysBase);
75 void Exec_InitETask(struct Task *task, struct ETask *etask, struct ExecBase *SysBase);
76 void Exec_CleanupETask(struct Task *task, struct ETask *et, struct ExecBase *SysBase);
77 struct ETask *Exec_FindChild(ULONG id, struct ExecBase *SysBase);
78 struct IntETask *FindETask(struct List *, ULONG id, struct ExecBase *SysBase);
80 BOOL Exec_CheckTask(struct Task *task, struct ExecBase *SysBase);
82 STRPTR Alert_AddString(STRPTR dest, CONST_STRPTR src);
83 STRPTR Alert_GetTitle(ULONG alertNum);
84 STRPTR Alert_GetString(ULONG alertnum, STRPTR buf);
85 STRPTR FormatAlert(char *buffer, ULONG alertNum, struct Task *task, APTR location, UBYTE type, struct ExecBase *SysBase);
86 STRPTR FormatTask(STRPTR buffer, const char *text, struct Task *, struct ExecBase *SysBase);
87 STRPTR FormatLocation(STRPTR buf, const char *text, APTR location, struct ExecBase *SysBase);
89 void FormatAlertExtra(char *buffer, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
90 char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBase *SysBase);
91 APTR UnwindFrame(APTR fp, APTR *caller);
93 void Exec_ExtAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
94 ULONG Exec_UserAlert(ULONG alertNum, struct ExecBase *SysBase);
95 void Exec_SystemAlert(ULONG alertNum, APTR location, APTR stack, UBYTE type, APTR data, struct ExecBase *SysBase);
96 void Exec_DoResetCallbacks(struct IntExecBase *SysBase);
98 APTR InternalRawDoFmt(CONST_STRPTR FormatString, APTR DataStream, VOID_FUNC PutChProc,
99 APTR PutChData, va_list VaListStream);
101 IPTR *InternalFindResident(const UBYTE *name, IPTR *list);
103 void FastPutMsg(struct MsgPort *port, struct Message *message, struct ExecBase *SysBase);
104 void InternalPutMsg(struct MsgPort *port, struct Message *message, struct ExecBase *SysBase);
106 LONG AllocTaskSignal(struct Task *ThisTask, LONG signalNum, struct ExecBase *SysBase);
108 static inline void InitMsgPort(struct MsgPort *ret)
110 /* Set port to type 'signalling' */
111 ret->mp_Flags = PA_SIGNAL;
112 /* Set port to type MsgPort */
113 ret->mp_Node.ln_Type = NT_MSGPORT;
114 /* Clear the list of messages */
115 NEWLIST(&ret->mp_MsgList);
119 * Pseudo-functions, including SysBase for nicer calling...
121 #define AllocTaskMem(t,s,f) Exec_AllocTaskMem(t,s,f,SysBase)
122 #define FreeTaskMem(t,m) Exec_FreeTaskMem(t,m,SysBase)
123 #define FindChild(i) Exec_FindChild(i,SysBase)
124 #define FindETask(l,i) Exec_FindETask(l,i,SysBase)
125 #define InitETask(t,e) Exec_InitETask(t,e,SysBase)
126 #define CleanupETask(t,e) Exec_CleanupETask(t,e,SysBase)
128 #endif /* _EXEC_UTIL_H */