Don't keep asking for S2EVENT_CONNECT reports if driver doen't
[AROS.git] / arch / arm-all / exec / preparecontext.c
blobd9dd045b6dfb3434dfbe6c92acb2b1a14e981319
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: PrepareContext() - Prepare a task context for dispatch, ARM version.
6 Lang: english
7 */
9 #include <exec/execbase.h>
10 #include <exec/memory.h>
11 #include <utility/tagitem.h>
12 #include <proto/arossupport.h>
13 #include <proto/kernel.h>
14 #include <aros/arm/cpucontext.h>
16 #include "exec_intern.h"
17 #include "exec_util.h"
19 BOOL PrepareContext(struct Task *task, APTR entryPoint, APTR fallBack,
20 const struct TagItem *tagList, struct ExecBase *SysBase)
22 struct TagItem *t;
23 struct ExceptionContext *ctx;
24 ULONG args[4] = {0};
25 int numargs = 0;
26 STACKULONG *sp = task->tc_SPReg;
28 if (!(task->tc_Flags & TF_ETASK) )
29 return FALSE;
31 ctx = KrnCreateContext();
32 task->tc_UnionETask.tc_ETask->et_RegFrame = ctx;
33 if (!ctx)
34 return FALSE;
36 /* Set up function arguments */
37 while((t = LibNextTagItem((struct TagItem **)&tagList)))
39 switch(t->ti_Tag)
41 #define REGARG(x) \
42 case TASKTAG_ARG ## x: \
43 ctx->r[x - 1] = t->ti_Data; \
44 break;
46 #define STACKARG(x) \
47 case TASKTAG_ARG ## x: \
48 args[x - 5] = t->ti_Data; \
49 if (x - 4 > numargs) \
50 numargs = x - 4; \
51 break;
53 REGARG(1)
54 REGARG(2)
55 REGARG(3)
56 REGARG(4)
57 STACKARG(5)
58 STACKARG(6)
59 STACKARG(7)
60 STACKARG(8)
64 /* Last four arguments are put on stack */
65 while (numargs > 0)
66 *--sp = args[--numargs];
68 task->tc_SPReg = sp;
70 /* Now prepare return address */
71 ctx->r[11] = 0;
72 ctx->lr = (ULONG)fallBack;
74 ctx->Flags = 0;
76 /* Then set up the frame to be used by Dispatch() */
77 ctx->sp = (ULONG)task->tc_SPReg;
78 ctx->pc = (ULONG)entryPoint;
80 return TRUE;
81 } /* PrepareContext() */