Setting up repository
[linux-libre-firmware.git] / ath9k_htc / sboot / magpie_1_1 / sboot / athos / src / xtos / ints-on.S
1 // ints-on.S - Interrupt related assembler code - _xtos_ints_on
2
3 // Copyright (c) 2004-2010 Tensilica Inc.
4 //
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:
12 //
13 // The above copyright notice and this permission notice shall be included
14 // in all copies or substantial portions of the Software.
15 //
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.
23
24 #include <xtensa/coreasm.h>
25 #include <xtensa/config/specreg.h>
26 #include "xtos-internal.h"
27
28
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.
33  */
34
35
36 // u32  _xtos_ints_on( u32 mask );
37 //      Enables a set of interrupts.
38 //      With INTENABLE virtualizing, does not simply set INTENABLE directly, but rather
39 //      computes it as a function of the current virtual priority.
40 //
41 //      MUST NOT be called when PS.INTLEVEL > XTOS_LOCKLEVEL
42 //      (otherwise PS.INTLEVEL gets lowered; and operation may be inconsistent
43 //       if this is called in the handler of an interrupt of level > LOCKLEVEL).
44 //
45         .text
46         .align 4
47         .global _xtos_ints_on
48         .type _xtos_ints_on,@function
49 _xtos_ints_on:
50         abi_entry
51 #if XCHAL_HAVE_INTERRUPTS
52 # if XTOS_VIRTUAL_INTENABLE
53         movi    a4, _xtos_intstruct
54         xtos_lock       a7      // MUST USE highest address register of function to avoid window overflows in critical section
55         l32i    a3, a4, XTOS_ENABLED_OFS        // a3 = xtos_enabled
56         l32i    a6, a4, XTOS_VPRI_ENABLED_OFS   // a6 = xtos_vpri_enabled
57         or      a5, a3, a2                      // xtos_enabled | mask
58         s32i    a5, a4, XTOS_ENABLED_OFS        // xtos_enabled |= mask
59         and     a5, a5, a6                      // a5 = xtos_enabled & xtos_vpri_enabled
60 # else
61         xtos_lock       a7      // MUST USE highest address register of function to avoid window overflows in critical section
62         rsr     a3, INTENABLE
63         //interlock
64         or      a5, a3, a2                      // INTENABLE | mask
65 # endif
66         wsr     a5, INTENABLE
67         xtos_unlock     a7
68         mov     a2, a3                          // return previous (virtual or real) INTENABLE value
69 #else /*XCHAL_HAVE_INTERRUPTS*/
70         movi    a2, 0           // this config does not have interrupts, so return 0
71 #endif /*XCHAL_HAVE_INTERRUPTS*/
72         abi_return
73
74         .size   _xtos_ints_on, . - _xtos_ints_on
75