Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / rom / exec / enable.c
bloba928ef0151c5f049227516aec0b54ea7f174d153
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Enable() - Allow interrupts to occur after Disable().
6 Lang: english
7 */
9 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
12 #include <aros/atomic.h>
13 #include <proto/kernel.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 *****
40 Using this function is considered very harmful, and it is
41 not recommended to use this function for ** ANY ** reason.
43 It is quite possible to either crash the system, or to prevent
44 normal activities (disk/port i/o) from occuring.
46 Note: As taskswitching is driven by the interrupts subsystem,
47 this function has the side effect of disabling
48 multitasking.
50 INPUTS
51 None.
53 RESULT
54 Interrupts will be enabled again when this call returns.
56 NOTES
57 This function preserves all registers.
59 To prevent deadlocks calling Wait() in disabled state breaks
60 the disable - thus interrupts may happen again.
62 EXAMPLE
63 No you DEFINITATELY don't want to use this function.
65 BUGS
66 The only architecture that you can rely on the registers being
67 saved is on the Motorola mc68000 family.
69 SEE ALSO
70 Forbid(), Permit(), Disable(), Wait()
72 INTERNALS
73 This function must be replaced in the $(KERNEL) or $(ARCH)
74 directories in order to do some work.
76 ******************************************************************************/
78 #undef Exec
80 AROS_LIBFUNC_INIT
82 #ifdef AROS_NO_ATOMIC_OPERATIONS
83 SysBase->IDNestCnt--;
84 #else
85 AROS_ATOMIC_DEC(SysBase->IDNestCnt);
86 #endif
88 if (KernelBase && (SysBase->IDNestCnt < 0))
90 D(bug("[Enable] Enabling interrupts\n"));
91 KrnSti();
93 if (KrnIsSuper())
94 return;
96 /* There's no dff09c like thing in x86 native which would allow
97 us to set delayed (mark it as pending but it gets triggered
98 only once interrupts are enabled again) software interrupt,
99 so we check it manually here in Enable() == same stuff as
100 in Permit(). */
102 if ((SysBase->TDNestCnt < 0) && (SysBase->AttnResched & ARF_AttnSwitch))
104 KrnSchedule();
107 if (SysBase->SysFlags & SFF_SoftInt)
108 KrnCause();
111 AROS_LIBFUNC_EXIT
112 } /* Enable() */