revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / enable.c
blobee7889a9b00544b5b6c497d6bdc4a2b88da02441
1 /*
2 Copyright © 1995-2018, 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>
15 #include "exec_intern.h"
17 /*****************************************************************************/
18 #undef Exec
19 #ifdef UseExecstubs
20 # define Exec _Exec
21 #endif
23 /* NAME */
24 #include <proto/exec.h>
26 AROS_LH0(void, Enable,
28 /* LOCATION */
29 struct ExecBase *, SysBase, 21, Exec)
31 /* FUNCTION
32 This function will allow interrupts to occur (*) after they have
33 been disabled by Disable().
35 Note that calls to Disable() nest, and for every call to
36 Disable() you need a matching call to Enable().
38 ***** WARNING *****
41 Using this function is considered very harmful, and it should only
42 ever be used to protect data that could also be accessed in interrupts.
44 It is quite possible to either crash the system, or to prevent
45 normal activities (disk/port i/o) from occuring.
47 INPUTS
48 None.
50 RESULT
51 Interrupts will be enabled again when this call returns.
53 NOTES
54 This function preserves all registers.
56 To prevent deadlocks calling Wait() in disabled state breaks
57 the disable - thus interrupts may happen again.
59 As the schedulers pre-emption is interrupt driven,
60 this function has the side effect of disabling
61 multitasking.
63 (*) On EXECSMP builds, Enable() only applies to the processor
64 it is called from. Data which needs to be protected from
65 parallel access will also require a spinlock.
67 EXAMPLE
68 In most userspace code, you will not want to use this function.
70 BUGS
71 The only architecture that you can rely on the registers being
72 saved is on the Motorola mc68000 family.
74 SEE ALSO
75 Forbid(), Permit(), Disable(), Wait()
77 INTERNALS
79 ******************************************************************************/
81 #undef Exec
83 AROS_LIBFUNC_INIT
85 D(bug("[Exec] Enable()\n");)
87 IDNESTCOUNT_DEC;
89 D(bug("[Exec] Enable: IDNESTCOUNT = %d\n", IDNESTCOUNT_GET);)
91 if (KernelBase)
93 if (IDNESTCOUNT_GET < 0)
95 D(bug("[Exec] Enable: Enabling interrupts\n");)
97 /* The following stuff is not safe to call from within supervisor mode */
98 if (!KrnIsSuper())
100 KrnSti();
103 * There's no dff09c like thing in x86 native which would allow
104 * us to set delayed (mark it as pending but it gets triggered
105 * only once interrupts are enabled again) software interrupt,
106 * so we check it manually here in Enable(), similar to Permit().
108 if (SysBase->SysFlags & SFF_SoftInt)
111 * First we react on SFF_SoftInt by issuing KrnCause() call. This triggers
112 * the complete interrupt processing code in kernel, which implies also
113 * rescheduling if it becomes necessary.
115 D(bug("[Exec] Enable: causing softints\n");)
116 KrnCause();
119 if ((TDNESTCOUNT_GET < 0) && FLAG_SCHEDSWITCH_ISSET)
122 * If SFF_SoftInt hasn't been set, we have a chance that task switching
123 * is enabled and pending. We need to trigger it here in such a case.
125 D(bug("[Exec] Enable: rescheduling\n");)
126 KrnSchedule();
132 AROS_LIBFUNC_EXIT
133 } /* Enable() */