1 |
2 |
alfik |
/******************************************************************************
|
2 |
|
|
* *
|
3 |
|
|
* License Agreement *
|
4 |
|
|
* *
|
5 |
|
|
* Copyright (c) 2003-2004 Altera Corporation, San Jose, California, USA. *
|
6 |
|
|
* All rights reserved. *
|
7 |
|
|
* *
|
8 |
|
|
* Permission is hereby granted, free of charge, to any person obtaining a *
|
9 |
|
|
* copy of this software and associated documentation files (the "Software"), *
|
10 |
|
|
* to deal in the Software without restriction, including without limitation *
|
11 |
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
|
12 |
|
|
* and/or sell copies of the Software, and to permit persons to whom the *
|
13 |
|
|
* Software is furnished to do so, subject to the following conditions: *
|
14 |
|
|
* *
|
15 |
|
|
* The above copyright notice and this permission notice shall be included in *
|
16 |
|
|
* all copies or substantial portions of the Software. *
|
17 |
|
|
* *
|
18 |
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
|
19 |
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
|
20 |
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
|
21 |
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
|
22 |
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
|
23 |
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
|
24 |
|
|
* DEALINGS IN THE SOFTWARE. *
|
25 |
|
|
* *
|
26 |
|
|
* This agreement shall be governed in all respects by the laws of the State *
|
27 |
|
|
* of California and by the laws of the United States of America. *
|
28 |
|
|
* *
|
29 |
|
|
******************************************************************************/
|
30 |
|
|
|
31 |
|
|
#include "system.h"
|
32 |
|
|
|
33 |
|
|
/*
|
34 |
|
|
* This is the interrupt exception entry point code, which saves all the
|
35 |
|
|
* registers and calls the interrupt handler. It should be pulled in using
|
36 |
|
|
* a .globl from alt_irq_register.c. This scheme is used so that if an
|
37 |
|
|
* interrupt is never registered, then this code will not appear in the
|
38 |
|
|
* generated executable, thereby improving code footprint.
|
39 |
|
|
*/
|
40 |
|
|
|
41 |
|
|
/*
|
42 |
|
|
* Explicitly allow the use of r1 (the assembler temporary register)
|
43 |
|
|
* within this code. This register is normally reserved for the use of
|
44 |
|
|
* the compiler.
|
45 |
|
|
*/
|
46 |
|
|
.set noat
|
47 |
|
|
|
48 |
|
|
/*
|
49 |
|
|
* Pull in the exception handler register save code.
|
50 |
|
|
*/
|
51 |
|
|
.globl alt_exception
|
52 |
|
|
|
53 |
|
|
.globl alt_irq_entry
|
54 |
|
|
.section .exceptions.entry.label, "xa"
|
55 |
|
|
alt_irq_entry:
|
56 |
|
|
|
57 |
|
|
/*
|
58 |
|
|
* Section .exceptions.entry is in alt_exception_entry.S
|
59 |
|
|
* This saves all the caller saved registers and reads estatus into r5
|
60 |
|
|
*/
|
61 |
|
|
|
62 |
|
|
.section .exceptions.irqtest, "xa"
|
63 |
|
|
|
64 |
|
|
#ifdef ALT_CI_INTERRUPT_VECTOR_N
|
65 |
|
|
/*
|
66 |
|
|
* Use the interrupt vector custom instruction if present to accelerate
|
67 |
|
|
* this code.
|
68 |
|
|
* If the interrupt vector custom instruction returns a negative
|
69 |
|
|
* value, there are no interrupts active (estatus.pie is 0
|
70 |
|
|
* or ipending is 0) so assume it is a software exception.
|
71 |
|
|
*/
|
72 |
|
|
custom ALT_CI_INTERRUPT_VECTOR_N, r4, r0, r0
|
73 |
|
|
blt r4, r0, .Lnot_irq
|
74 |
|
|
#else
|
75 |
|
|
/*
|
76 |
|
|
* Test to see if the exception was a software exception or caused
|
77 |
|
|
* by an external interrupt, and vector accordingly.
|
78 |
|
|
*/
|
79 |
|
|
rdctl r4, ipending
|
80 |
|
|
andi r2, r5, 1
|
81 |
|
|
beq r2, zero, .Lnot_irq
|
82 |
|
|
beq r4, zero, .Lnot_irq
|
83 |
|
|
#endif /* ALT_CI_INTERRUPT_VECTOR_N */
|
84 |
|
|
|
85 |
|
|
.section .exceptions.irqhandler, "xa"
|
86 |
|
|
/*
|
87 |
|
|
* Now that all necessary registers have been preserved, call
|
88 |
|
|
* alt_irq_handler() to process the interrupts.
|
89 |
|
|
*/
|
90 |
|
|
|
91 |
|
|
call alt_irq_handler
|
92 |
|
|
|
93 |
|
|
.section .exceptions.irqreturn, "xa"
|
94 |
|
|
|
95 |
|
|
br .Lexception_exit
|
96 |
|
|
|
97 |
|
|
.section .exceptions.notirq.label, "xa"
|
98 |
|
|
|
99 |
|
|
.Lnot_irq:
|
100 |
|
|
|
101 |
|
|
/*
|
102 |
|
|
* Section .exceptions.exit is in alt_exception_entry.S
|
103 |
|
|
* This restores all the caller saved registers
|
104 |
|
|
*/
|
105 |
|
|
|
106 |
|
|
.section .exceptions.exit.label
|
107 |
|
|
.Lexception_exit:
|
108 |
|
|
|