Setting up repository
[linux-libre-firmware.git] / ath9k_htc / sboot / magpie_1_1 / sboot / athos / src / xtos / kernel-vector.S
1 // kernel-vector.S  -  Kernel Vector for General Exceptions
2 // $Id: //depot/rel/Cottonwood/Xtensa/OS/xtos/kernel-vector.S#3 $
3
4 // Copyright (c) 1999-2002, 2004, 2006, 2010 Tensilica Inc.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the
8 // "Software"), to deal in the Software without restriction, including
9 // without limitation the rights to use, copy, modify, merge, publish,
10 // distribute, sublicense, and/or sell copies of the Software, and to
11 // permit persons to whom the Software is furnished to do so, subject to
12 // the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included
15 // in all copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25 /*
26  *  General exceptions in kernel vector mode (PS.UM==0) go to this kernel
27  *  vector.  This kernel vector does very little.
28  *  Under normal operation of the single-threaded runtime ("XTOS"), kernel
29  *  vectored general exceptions do not occur, so nothing needs to be done.
30  *  However when debugging, such as when writing exception and
31  *  interrupt handlers, kernel vectored exceptions may occur.
32  *  They are usually the sign of a bug, so here we take a breakpoint
33  *  (if debug option enabled) or take drastic action (infinite loop)
34  *  otherwise.
35  *
36  *  XTOS does not allow exceptions in interrupt or exception handlers.
37  *  If it did, a more elaborate kernel vector handler would be needed.
38  *  See the Xtensa Microprocessor Programmer's Guide for an
39  *  example of how to implement such a kernel vector handler.
40  */
41
42 #include <xtensa/coreasm.h>
43 #include <xtensa/config/system.h>
44 #ifdef SIMULATOR
45 #include <xtensa/simcall.h>
46 #endif
47
48 #if XCHAL_HAVE_EXCEPTIONS
49
50         .begin  literal_prefix  .KernelExceptionVector
51         .section                .KernelExceptionVector.text, "ax"
52
53         .align 4
54         .global _KernelExceptionVector
55 _KernelExceptionVector:
56 # if XCHAL_HAVE_DEBUG
57 1:      break   1,0                     // unexpected kernel exception
58 # elif defined(SIMULATOR)
59         wsr     a2, EXCSAVE1            // save a2 where simulator expects it
60         movi    a2, SYS_unhandled_kernel_exc
61 1:      simcall                         // let simulator/debugger report unhandled exception
62 # else
63 1:
64 # endif
65         j       1b                      // infinite loop - unexpected kernel exception
66
67         .size   _KernelExceptionVector, . - _KernelExceptionVector
68         .text
69         .end    literal_prefix
70
71 #endif /* XCHAL_HAVE_EXCEPTIONS */
72