OpenCores
URL https://opencores.org/ocsvn/mips32r1/mips32r1/trunk

Subversion Repositories mips32r1

[/] [mips32r1/] [trunk/] [Software/] [demos/] [XD5_Threads/] [src/] [os/] [exceptions.asm] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ayersg
###############################################################################
2
# TITLE: Exception Vectors
3
# AUTHOR: Grant Ayers (ayers@cs.utah.edu)
4
# DATE: 23 May 2012
5
# FILENAME: exceptions.asm
6
# PROJECT: University of Utah XUM Single Core
7
# DESCRIPTION:
8
#   Provides the exception vectors which jump to
9
#   exception-handling routines.
10
#
11
###############################################################################
12
 
13
        .text
14
        .balign 4
15
        .set    noreorder
16
 
17
exc_save:
18
        addiu   $sp, $sp, -96
19
        sw      $2,   0($sp)
20
        sw      $3,   4($sp)
21
        sw      $4,   8($sp)
22
        sw      $5,  12($sp)
23
        sw      $6,  16($sp)
24
        sw      $7,  20($sp)
25
        sw      $8,  24($sp)
26
        sw      $9,  28($sp)
27
        sw      $10, 32($sp)
28
        sw      $11, 36($sp)
29
        sw      $12, 40($sp)
30
        sw      $13, 44($sp)
31
        sw      $14, 48($sp)
32
        sw      $15, 52($sp)
33
        sw      $16, 56($sp)
34
        sw      $17, 60($sp)
35
        sw      $18, 64($sp)
36
        sw      $19, 68($sp)
37
        sw      $20, 72($sp)
38
        sw      $21, 76($sp)
39
        sw      $22, 80($sp)
40
        sw      $23, 84($sp)
41
        sw      $24, 88($sp)
42
        jr      $ra
43
        sw      $25, 92($sp)
44
 
45
exc_restore:
46
        lw      $2,   0($sp)
47
        lw      $3,   4($sp)
48
        lw      $4,   8($sp)
49
        lw      $5,  12($sp)
50
        lw      $6,  16($sp)
51
        lw      $7,  20($sp)
52
        lw      $8,  24($sp)
53
        lw      $9,  28($sp)
54
        lw      $10, 32($sp)
55
        lw      $11, 36($sp)
56
        lw      $12, 40($sp)
57
        lw      $13, 44($sp)
58
        lw      $14, 48($sp)
59
        lw      $15, 52($sp)
60
        lw      $16, 56($sp)
61
        lw      $17, 60($sp)
62
        lw      $18, 64($sp)
63
        lw      $19, 68($sp)
64
        lw      $20, 72($sp)
65
        lw      $21, 76($sp)
66
        lw      $22, 80($sp)
67
        lw      $23, 84($sp)
68
        lw      $24, 88($sp)
69
        lw      $25, 92($sp)
70
        jr      $ra
71
        addiu   $sp, $sp, 96
72
 
73
 
74
        .global mips32_general_exception
75
        .ent    mips32_general_exception
76
mips32_general_exception:
77
        or      $26, $0, $ra
78
        jal     exc_save
79
        nop
80
        mfc0    $27, $13, 0             # Read Cause which has ExcCode bits
81
        srl     $27, $27, 2             # Extract exception code to $k1
82
        andi    $27, $27, 0x001f
83
 
84
        la      $ra, $end_exception     # Jump to the appropriate handler
85
        addiu   $t0, $0, 4
86
        addiu   $t1, $0, 5
87
        addiu   $t2, $0, 8
88
        addiu   $t3, $0, 9
89
        beq     $t0, $27, mips32_handler_AdEL
90
        addiu   $t0, $0, 10
91
        beq     $t1, $27, mips32_handler_AdES
92
        addiu   $t1, $0, 11
93
        beq     $t2, $27, mips32_handler_Sys
94
        addiu   $t2, $0, 12
95
        beq     $t3, $27, mips32_handler_Bp
96
        addiu   $t3, $0, 13
97
        beq     $t0, $27, mips32_handler_RI
98
        nop
99
        beq     $t1, $27, mips32_handler_CpU
100
        nop
101
        beq     $t2, $27, mips32_handler_Ov
102
        nop
103
        beq     $t3, $27, mips32_handler_Tr
104
        nop
105
 
106
$end_exception:
107
        jal     exc_restore
108
        xor     $27, $0, $0
109
        or      $ra, $0, $26
110
        xor     $26, $0, $0
111
        eret
112
        .end    mips32_general_exception
113
 
114
 
115
 
116
### "Special" Interrupt Vector: Cause_IV must be set.
117
 
118
        .ent    mips32_interrupt_exception
119
        .global mips32_interrupt_exception
120
mips32_interrupt_exception:
121
        mfc0    $26, $12, 0             # Status register for IM bits
122
        mfc0    $27, $13, 0             # Cause register for IP bits
123
        and     $26, $26, $27           # Extract pending, unmasked interrupts
124
        srl     $26, $26, 8
125
        andi    $26, $26, 0x00ff
126
 
127
        clz     $26, $26
128
        addiu   $27, $0, 24
129
        beq     $26, $27, scheduler     # Hw Int 5 goes directly to scheduler
130
        nop
131
 
132
        addu    $27, $0, $ra
133
        jal     exc_save
134
        nop
135
        la      $ra, $end_interrupt
136
        addiu   $t0, $0, 25
137
        addiu   $t1, $0, 26
138
        addiu   $t2, $0, 27
139
        beq     $26, $t0, mips32_handler_HwInt4
140
        addiu   $t0, $0, 28
141
        beq     $26, $t1, mips32_handler_HwInt3
142
        addiu   $t1, $0, 29
143
        beq     $26, $t2, mips32_handler_HwInt2
144
        addiu   $t2, $0, 30
145
        beq     $26, $t0, mips32_handler_HwInt1
146
        addiu   $t0, $0, 31
147
        beq     $26, $t1, mips32_handler_HwInt0
148
        nop
149
        beq     $26, $t2, mips32_handler_SwInt1
150
        nop
151
        beq     $26, $t0, mips32_handler_SwInt0
152
        nop
153
 
154
$end_interrupt:
155
        jal     exc_restore
156
        xor     $27, $0, $0
157
        or      $ra, $0, $26
158
        xor     $26, $0, $0
159
        eret
160
        .end    mips32_interrupt_exception
161
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.