• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 *    conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 *    of conditions and the following disclaimer in the documentation and/or other materials
13 *    provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 *    to endorse or promote products derived from this software without specific prior written
17 *    permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32.import HalExcHandleEntry
33.extern g_trapStackBase
34
35#ifdef CPU_CK804
36.section .text
37.align  2
38.global HandleEntry
39HandleEntry:
40    mov    r10, sp
41    lrw    r14, g_trapStackBase
42
43    stm    r0-r15, (sp)
44    stw    r10, (sp, 56)
45    addi     r0, sp, 64
46    stm      r16-r31, (r0)
47    mfcr   r0, epsr
48    stw    r0, (sp, 128)
49    mfcr   r0, epc
50    stw    r0, (sp, 132)
51    mov    r0, sp
52
53    mfcr   r1, epc
54
55    mov    sp, r10
56    lrw    r2, HalExcHandleEntry
57    jmp    r2
58
59.section .text
60.align  2
61.global IrqEntry
62IrqEntry:
63    psrset  ee
64    subi   sp, 136
65    stm    r0-r15, (sp)
66    addi     r0, sp, 64
67    stm      r16-r31, (r0)
68    mfcr   r0, epsr
69    stw    r0, (sp, 128)
70    mfcr   r0, epc
71    stw    r0, (sp, 132)
72
73    jbsr   HalInterrupt
74
75    ldw    r0, (sp, 132)
76    mtcr   r0, epc
77    ldw    r0, (sp, 128)
78    bseti  r0, r0, 6
79    mtcr   r0, epsr
80    ldm    r0-r15, (sp)
81    addi     sp, 64
82    ldm      r16-r31, (sp)
83    addi   sp, 72
84    rte
85#else
86.section .text
87.align  2
88.global HandleEntry
89HandleEntry:
90    mov    r10, sp
91    lrw    r14, g_trapStackBase
92
93    stm    r0-r15, (sp)
94    stw    r10, (sp, 56)
95    mfcr   r0, epsr
96    stw    r0, (sp, 64)
97    mfcr   r0, epc
98    stw    r0, (sp, 68)
99    mov    r0, sp
100
101    mfcr   r1, epc
102
103    mov    sp, r10
104    lrw    r2, HalExcHandleEntry
105    jmp    r2
106
107.section .text
108.align  2
109.global IrqEntry
110IrqEntry:
111    psrset  ee
112    subi   sp, 72
113    stm    r0-r15, (sp)
114    mfcr   r0, epsr
115    stw    r0, (sp, 64)
116    mfcr   r0, epc
117    stw    r0, (sp, 68)
118
119    jbsr   HalInterrupt
120
121    ldw    r0, (sp, 68)
122    mtcr   r0, epc
123    ldw    r0, (sp, 64)
124    bseti  r0, r0, 6
125    mtcr   r0, epsr
126    ldm    r0-r15, (sp)
127    addi   sp, 72
128    rte
129#endif