revert between 56095 -> 55830 in arch
[AROS.git] / arch / .unmaintained / m68k-emul / dispatch.s
blob971f5d0d85351510d6038a308d8c00ab366d20f3
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Exec function Dispatch()
6 Lang: english
7 */
9 /******************************************************************************
11 NAME
12 AROS_LH0(void, Dispatch,
14 LOCATION
15 struct ExecBase *, SysBase, 10, Exec)
17 FUNCTION
19 INPUTS
21 RESULT
23 NOTES
25 EXAMPLE
27 BUGS
29 SEE ALSO
31 INTERNALS
33 HISTORY
35 ******************************************************************************/
37 #include "machine.i"
39 .text
40 .balign 16
41 .globl AROS_SLIB_ENTRY(Dispatch,Exec)
42 .type AROS_SLIB_ENTRY(Dispatch,Exec),@function
44 AROS_SLIB_ENTRY(Dispatch,Exec):
45 /* move whole user context to user stack */
46 movem.l %d0-%d7/%a0-%a6,-(%sp)
47 #if !UseRegisterArgs
48 move.l 64(%sp),%a6
49 #endif
51 jbsr AROS_CSYMNAME(os_disable)
53 /* get current task and store sp there */
54 move.l ThisTask(%a6),%a2
55 move.l %sp,tc_SPReg(%a2)
57 /* call the switch routine if necessary */
58 btst #TB_SWITCH,tc_Flags(%a2)
59 jbeq .noswch
60 move.l tc_Switch(%a2),%a5
61 jsr (%a5)
63 /* store IDNestCnt */
64 .noswch:
65 move.b IDNestCnt(%a6),tc_IDNestCnt(%a2)
66 move.b #-1,IDNestCnt(%a6)
68 /* get task from ready list */
69 move.l TaskReady(%a6),%a2
70 move.l (%a2),%a0
71 move.l %a0,TaskReady(%a6)
72 lea.l TaskReady(%a6),%a1
73 move.l %a1,4.w(%a0)
75 /* and use it as new current task */
76 move.l %a2,ThisTask(%a6)
77 move.b #TS_RUN,tc_State(%a2)
78 move.b tc_IDNestCnt(%a2),IDNestCnt(%a6)
80 /* call the launch routine if necessary */
81 btst #TB_LAUNCH,tc_Flags(%a2)
82 jbeq .nolnch
83 move.l tc_Launch(%a2),%a5
84 jsr (%a5)
86 /* get stack pointer */
87 .nolnch:
88 move.l tc_SPReg(%a2),%d0
90 /* Compare against SPLower */
91 cmp.l tc_SPLower(%a2),%d0
92 jbls .alert
94 /* Compare against SPUpper */
95 cmp.l tc_SPUpper(%a2),%d0
96 jbcc .alert
98 /* Put the SP into the correct register after checking */
99 move.l %d0,%sp
100 /* Unblock signals if necessary */
101 tst.b tc_IDNestCnt(%a2)
102 jbpl .noen
103 /* If called from the signal handler don't do it. */
104 tst.b AROS_CSYMNAME(supervisor)
105 jbne .noen
106 jbsr AROS_CSYMNAME(os_enable)
108 .noen:
109 /* Except bit set? */
110 btst #TB_EXCEPT,tc_Flags(%a2)
111 jbeq .noexpt
113 /* Raise a task exception in Disable()d state. */
114 #if !UseRegisterArgs
115 move.l %a6,-(%sp)
116 #endif
117 /* jsr Disable(%a6) */
118 jsr Exception(%a6)
119 /* jsr Enable(%a6) */
120 #if !UseRegisterArgs
121 addq.w #4,%sp
122 #endif
124 /* restore context. */
125 .noexpt:
126 movem.l (%sp)+,%d0-%d7/%a0-%a6
129 .alert:
130 /* Call Alert() */
131 #if !UseRegisterArgs
132 move.l %a6,-(%sp)
133 #endif
134 move.l #AT_DeadEnd,%d7
135 or.l #AN_StackProbe,%d7
136 #if !UseRegisterArgs
137 move.l %d0,-(%sp)
138 #endif
139 jsr Alert(%a6)
140 /* Function does not return */