Setting up repository
[linux-libre-firmware.git] / ath9k_htc / sboot / magpie_1_1 / sboot / athos / src / xtos / exit.S
1 // exit.S
2 //
3 // For hardware / boards, this is the default _exit routine called by the
4 // C library exit() function.  If the program ever exits, we eventually
5 // end up here after all C library cleanup (such as closing open files,
6 // calling exit callbacks and C++ destructors, etc) is complete.
7
8 // Copyright (c) 1998-2010 Tensilica Inc.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be included
19 // in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 #include <xtensa/coreasm.h>
30 #include <xtensa/config/core-isa.h>
31 #include "xtos-internal.h"
32
33 // Macros to abstract away ABI differences
34 #if __XTENSA_CALL0_ABI__
35 # define CALL   call0
36 #else
37 # define CALL   call4
38 #endif
39
40
41         .text
42         .align 4
43         .global _exit
44         .type   _exit, @function
45 _exit:
46         abi_entry 0, 4
47
48         // sync dirty data to memory before terminating
49 #if XCHAL_DCACHE_IS_COHERENT
50         CALL    xthal_cache_coherence_optout
51 #elif XCHAL_DCACHE_IS_WRITEBACK
52         CALL    xthal_dcache_all_writeback
53 #endif
54
55         // sync queues (if any, only for LX and later):
56 #if XCHAL_HW_MIN_VERSION >= XTENSA_HWVERSION_RA_2004_1  /* LX or later? */
57         extw
58 #endif
59         // can break to debug monitor, go to sleep with waiti, or just spin in a loop
60 .L0:
61 #if XCHAL_HAVE_DEBUG
62         break   0, 0            // back to debugger, if one is attached
63 #elif XCHAL_HAVE_INTERRUPTS
64         waiti   15
65 #elif XCHAL_HAVE_HALT
66         halt
67 #endif
68         j       .L0
69         //abi_exit
70
71         .size   _exit, . - _exit
72