r4684@vps: verhaegs | 2007-05-04 21:04:10 -0400
[AROS.git] / rom / exec / disable.c
blobcd5af1769b8427703ffa4caed6ef7d9391ec97e4
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Disable() - Stop interrupts from occurring.
6 Lang: english
7 */
9 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
12 #include <aros/atomic.h>
14 /*****************************************************************************/
15 #undef Exec
16 #ifdef UseExecstubs
17 # define Exec _Exec
18 #endif
20 /* NAME */
21 #include <proto/exec.h>
23 AROS_LH0(void, Disable,
25 /* LOCATION */
26 struct ExecBase *, SysBase, 20, Exec)
28 /* FUNCTION
29 This function will prevent interrupts from occuring. You can
30 start the interrupts again with a call to Enable().
32 Note that calls to Disable() nest, and for every call to
33 Disable() you need a matching call to Enable().
35 ***** WARNING *****
37 Using this function is considered very harmful, and it is
38 not recommended to use this function for ** ANY ** reason.
40 It is quite possible to either crash the system, or to prevent
41 normal activities (disk/port i/o) from occuring.
43 Note: As taskswitching is driven by the interrupts subsystem,
44 this function has the side effect of disabling
45 multitasking.
47 INPUTS
49 RESULT
50 Interrupts will be disabled AFTER this call returns.
52 NOTES
53 This function preserves all registers.
55 To prevent deadlocks calling Wait() in disabled state breaks
56 the disable - thus interrupts may happen again.
58 EXAMPLE
59 No you DEFINITELY don't want to use this function.
61 BUGS
62 The only architecture that you can rely on the registers being
63 saved is on the Motorola mc68000 family.
65 SEE ALSO
66 Forbid(), Permit(), Enable(), Wait()
68 INTERNALS
69 This function must be replaced in the $(KERNEL) or $(ARCH)
70 directories in order to do some work.
72 ******************************************************************************/
74 #undef Exec
76 AROS_LIBFUNC_INIT
78 /* Only disable interrupts if they are not already disabled. The
79 initial (enabled) value of IDNestCnt is -1
82 AROS_ATOMIC_INC(SysBase->IDNestCnt);
85 We have to disable interrupts, however some silly person
86 hasn't written the code required to do it yet. They should
87 have created a file in config/$(KERNEL)/exec or
88 config/$(ARCH)/exec called disable.c or disable.s which
89 implements this function.
91 #ifndef __CXREF__
92 #error You have not written the $(KERNEL) interrupt subsystem!
93 #endif
95 AROS_LIBFUNC_EXIT
96 } /* Disable() */