tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / exec / enable.c
blob4e1d806c13a2a65296502b34c878a5aa3c51f384
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 D(bug("[Exec] Enable: IDNESTCOUNT = %d\n", IDNESTCOUNT_GET);)
87 if (KernelBase)
89 if (IDNESTCOUNT_GET < 0)
91 D(bug("[Exec] Enable: Enabling interrupts\n");)
93 KrnSti();
95 /* The following stuff is not safe to call from within supervisor mode */
96 if (!KrnIsSuper())
99 * There's no dff09c like thing in x86 native which would allow
100 * us to set delayed (mark it as pending but it gets triggered
101 * only once interrupts are enabled again) software interrupt,
102 * so we check it manually here in Enable(), similar to Permit().
104 if (SysBase->SysFlags & SFF_SoftInt)
107 * First we react on SFF_SoftInt by issuing KrnCause() call. This triggers
108 * the complete interrupt processing code in kernel, which implies also
109 * rescheduling if became necessary.
111 D(bug("[Exec] Enable: causing softints\n");)
112 KrnCause();
115 if ((TDNESTCOUNT_GET < 0) && FLAG_SCHEDSWITCH_ISSET)
118 * If SFF_SoftInt hasn't been set, we have a chance that task switching
119 * is enabled and pending. We need to trigger it here in such a case.
121 D(bug("[Exec] Enable: rescheduling\n");)
122 KrnSchedule();
128 AROS_LIBFUNC_EXIT
129 } /* Enable() */