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.
8 // Copyright (c) 1998-2010 Tensilica Inc.
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:
18 // The above copyright notice and this permission notice shall be included
19 // in all copies or substantial portions of the Software.
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.
29 #include <xtensa/coreasm.h>
30 #include <xtensa/config/core-isa.h>
31 #include "xtos-internal.h"
33 // Macros to abstract away ABI differences
34 #if __XTENSA_CALL0_ABI__
44 .type _exit, @function
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
55 // sync queues (if any, only for LX and later):
56 #if XCHAL_HW_MIN_VERSION >= XTENSA_HWVERSION_RA_2004_1 /* LX or later? */
59 // can break to debug monitor, go to sleep with waiti, or just spin in a loop
62 break 0, 0 // back to debugger, if one is attached
63 #elif XCHAL_HAVE_INTERRUPTS
71 .size _exit, . - _exit