1 // ints-off.S - Interrupt related assembler code - _xtos_ints_off
3 // Copyright (c) 2004-2010 Tensilica Inc.
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the
7 // "Software"), to deal in the Software without restriction, including
8 // without limitation the rights to use, copy, modify, merge, publish,
9 // distribute, sublicense, and/or sell copies of the Software, and to
10 // permit persons to whom the Software is furnished to do so, subject to
11 // the following conditions:
13 // The above copyright notice and this permission notice shall be included
14 // in all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #include <xtensa/coreasm.h>
25 #include <xtensa/config/specreg.h>
26 #include "xtos-internal.h"
29 /***************************************************************************
30 * _xtos_ints_on() and _xtos_ints_off() are used
31 * to enable and disable interrupts from C code;
32 * they can be called from the application or from a C interrupt handler.
35 // u32 _xtos_ints_off( u32 mask ); [T1050.0 docs this as returning old INTENABLE value]
36 // Disables a set of interrupts. See _xtos_ints_on().
38 // MUST NOT be called when PS.INTLEVEL > XTOS_LOCKLEVEL
39 // (otherwise PS.INTLEVEL gets lowered; and operation may be inconsistent
40 // if this is called in the handler of an interrupt of level > LOCKLEVEL).
44 .global _xtos_ints_off
45 .type _xtos_ints_off,@function
48 #if XCHAL_HAVE_INTERRUPTS
49 # if XTOS_VIRTUAL_INTENABLE
50 movi a4, _xtos_intstruct
51 xtos_lock a7 // MUST USE highest address register of function to avoid window overflows in critical section
52 l32i a3, a4, XTOS_ENABLED_OFS // a3 = xtos_enabled
53 l32i a6, a4, XTOS_VPRI_ENABLED_OFS // a6 = xtos_vpri_enabled
54 or a5, a3, a2 // a5 = xtos_enabled | mask
55 xor a5, a5, a2 // a5 = xtos_enabled & ~mask
56 s32i a5, a4, XTOS_ENABLED_OFS // xtos_enabled &= ~mask
57 and a5, a5, a6 // a5 = xtos_enabled & xtos_vpri_enabled
59 xtos_lock a7 // MUST USE highest address register of function to avoid window overflows in critical section
62 or a5, a3, a2 // a5 = INTENABLE | mask
63 xor a5, a5, a2 // a5 = INTENABLE & ~mask
67 mov a2, a3 // return previous (virtual or real) INTENABLE value
68 #else /*XCHAL_HAVE_INTERRUPTS*/
69 movi a2, 0 // this config does not have interrupts, so return 0
70 #endif /*XCHAL_HAVE_INTERRUPTS*/
73 .size _xtos_ints_off, . - _xtos_ints_off