cleanup debug
[AROS.git] / rom / exec / enable.c
blobd76e9465b6b5dbd9f92d15ecb5f7328c3a841a17
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Enable() - Allow interrupts to occur after Disable().
6 Lang: english
7 */
9 #define DEBUG 0
11 #include <exec/execbase.h>
12 #include <aros/libcall.h>
13 #include <aros/atomic.h>
14 #include <proto/kernel.h>
16 #include "exec_intern.h"
18 /*****************************************************************************/
19 #undef Exec
20 #ifdef UseExecstubs
21 # define Exec _Exec
22 #endif
24 /* NAME */
25 #include <proto/exec.h>
27 AROS_LH0(void, Enable,
29 /* LOCATION */
30 struct ExecBase *, SysBase, 21, Exec)
32 /* FUNCTION
33 This function will allow interrupts to occur after they have
34 been disabled by Disable().
36 Note that calls to Disable() nest, and for every call to
37 Disable() you need a matching call to Enable().
39 ***** WARNING *****
41 Using this function is considered very harmful, and it is
42 not recommended to use this function for ** ANY ** reason.
44 It is quite possible to either crash the system, or to prevent
45 normal activities (disk/port i/o) from occuring.
47 Note: As taskswitching is driven by the interrupts subsystem,
48 this function has the side effect of disabling
49 multitasking.
51 INPUTS
52 None.
54 RESULT
55 Interrupts will be enabled again when this call returns.
57 NOTES
58 This function preserves all registers.
60 To prevent deadlocks calling Wait() in disabled state breaks
61 the disable - thus interrupts may happen again.
63 EXAMPLE
64 No you DEFINITATELY don't want to use this function.
66 BUGS
67 The only architecture that you can rely on the registers being
68 saved is on the Motorola mc68000 family.
70 SEE ALSO
71 Forbid(), Permit(), Disable(), Wait()
73 INTERNALS
75 ******************************************************************************/
77 #undef Exec
79 AROS_LIBFUNC_INIT
81 D(bug("[Exec] Enable()\n"));
83 IDNESTCOUNT_DEC;
85 if (KernelBase && (IDNESTCOUNT_GET < 0))
87 D(bug("[Exec] Enable: Enabling interrupts\n"));
88 KrnSti();
90 if (KrnIsSuper())
92 /* The following stuff is not safe to call from within supervisor mode */
93 return;
97 * There's no dff09c like thing in x86 native which would allow
98 * us to set delayed (mark it as pending but it gets triggered
99 * only once interrupts are enabled again) software interrupt,
100 * so we check it manually here in Enable(), similar to Permit().
102 if (SysBase->SysFlags & SFF_SoftInt)
105 * First we react on SFF_SoftInt by issuing KrnCause() call. This triggers
106 * the complete interrupt processing code in kernel, which implies also
107 * rescheduling if became necessary.
109 KrnCause();
112 if ((TDNESTCOUNT_GET < 0) && FLAG_SCHEDSWITCH_ISSET)
115 * If SFF_SoftInt hasn't been set, we have a chance that task switching
116 * is enabled and pending. We need to trigger it here in such a case.
118 KrnSchedule();
122 AROS_LIBFUNC_EXIT
123 } /* Enable() */