- Implemented execp*.
[planlOS.git] / system / include / ke / level.h
blobf8754224f84b7485a87237216c6591c6466045be
1 /*
2 Copyright (C) 2008 Mathias Gottschlag
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 /**
22 * \file level.h
23 * Functions for changing execution levels.
26 #ifndef KE_LEVEL_H_INCLUDED
27 #define KE_LEVEL_H_INCLUDED
29 /**
30 * The execution level sets whether interrupts will interrupt the running code.
31 * This is necessary especially as quite some functions need locks, calling this
32 * code once from threads and once from an interrupt handler at the same time
33 * results in a deadlock as the code executed before the interrupt cannot unlock
34 * the needed locks any more.
36 typedef enum
38 /**
39 * Normal execution level. IRQs can interrupt the code.
41 KE_LEVEL_NORMAL,
42 /**
43 * Higher execution level. No IRQs can interrupt the code.
44 * This is the default mode for interrupt handlers.
46 KE_LEVEL_HIGH
47 } KeExecLevel;
49 /**
50 * Sets the execution level for the current CPU.
51 * \return Previous execution level
53 KeExecLevel keSetExecutionLevel(KeExecLevel level);
54 /**
55 * Returns the execution level of the current CPU.
56 * \return Current execution level
58 KeExecLevel keGetExecutionLevel(void);
60 #endif