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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [stdalone/] [mkpart/] [start.s] - Blame information for rev 21

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 hellwig
;
2
; start.s -- startup code
3
;
4
 
5
        .import main
6
        .import _ecode
7
        .import _edata
8
        .import _ebss
9
 
10
        .export _bcode
11
        .export _bdata
12
        .export _bbss
13
 
14
        .export enable
15
        .export disable
16
        .export getMask
17
        .export setMask
18
        .export getISR
19
        .export setISR
20
 
21
        .code
22
_bcode:
23
 
24
        .data
25
_bdata:
26
 
27
        .bss
28
_bbss:
29
 
30
        .code
31
 
32
        ; reset arrives here
33
reset:
34
        j       start
35
 
36
        ; interrupts arrive here
37
intrpt:
38
        j       isr
39
 
40
        ; user TLB misses arrive here
41
userMiss:
42
        j       userMiss
43
 
44
isr:
45
        add     $26,$29,$0       ; sp -> $26
46
        add     $27,$1,$0        ; $1 -> $27
47
        add     $29,$0,istack    ; set stack
48
        sub     $29,$29,108
49
        stw     $2,$29,0 ; save registers
50
        stw     $3,$29,4
51
        stw     $4,$29,8
52
        stw     $5,$29,12
53
        stw     $6,$29,16
54
        stw     $7,$29,20
55
        stw     $8,$29,24
56
        stw     $9,$29,28
57
        stw     $10,$29,32
58
        stw     $11,$29,36
59
        stw     $12,$29,40
60
        stw     $13,$29,44
61
        stw     $14,$29,48
62
        stw     $15,$29,52
63
        stw     $16,$29,56
64
        stw     $17,$29,60
65
        stw     $18,$29,64
66
        stw     $19,$29,68
67
        stw     $20,$29,72
68
        stw     $21,$29,76
69
        stw     $22,$29,80
70
        stw     $23,$29,84
71
        stw     $24,$29,88
72
        stw     $25,$29,92
73
        stw     $26,$29,96
74
        stw     $27,$29,100
75
        stw     $31,$29,104
76
        mvfs    $4,0             ; $4 = IRQ number
77
        slr     $4,$4,16
78
        and     $4,$4,0x1F
79
        sll     $26,$4,2        ; $26 = 4 * IRQ number
80
        ldw     $26,$26,irqsrv  ; get addr of service routine
81
        jalr    $26             ; call service routine
82
        beq     $2,$0,resume     ; resume instruction if ISR returned 0
83
        add     $30,$30,4       ; else skip offending instruction
84
resume:
85
        ldw     $2,$29,0
86
        ldw     $3,$29,4
87
        ldw     $4,$29,8
88
        ldw     $5,$29,12
89
        ldw     $6,$29,16
90
        ldw     $7,$29,20
91
        ldw     $8,$29,24
92
        ldw     $9,$29,28
93
        ldw     $10,$29,32
94
        ldw     $11,$29,36
95
        ldw     $12,$29,40
96
        ldw     $13,$29,44
97
        ldw     $14,$29,48
98
        ldw     $15,$29,52
99
        ldw     $16,$29,56
100
        ldw     $17,$29,60
101
        ldw     $18,$29,64
102
        ldw     $19,$29,68
103
        ldw     $20,$29,72
104
        ldw     $21,$29,76
105
        ldw     $22,$29,80
106
        ldw     $23,$29,84
107
        ldw     $24,$29,88
108
        ldw     $25,$29,92
109
        ldw     $26,$29,96
110
        ldw     $27,$29,100
111
        ldw     $31,$29,104
112
        add     $1,$27,$0        ; $27 -> $1
113
        add     $29,$26,0        ; $26 -> sp
114
        rfx                     ; return from exception
115
 
116
start:
117
        mvfs    $8,0
118
        or      $8,$8,1 << 27   ; let vector point to RAM
119
        mvts    $8,0
120
        add     $29,$0,stack     ; set sp
121
        add     $10,$0,_bdata    ; copy data segment
122
        add     $8,$0,_edata
123
        sub     $9,$8,$10
124
        add     $9,$9,_ecode
125
        j       cpytest
126
cpyloop:
127
        ldw     $11,$9,0
128
        stw     $11,$8,0
129
cpytest:
130
        sub     $8,$8,4
131
        sub     $9,$9,4
132
        bgeu    $8,$10,cpyloop
133
        add     $8,$0,_bbss      ; clear bss
134
        add     $9,$0,_ebss
135
        j       clrtest
136
clrloop:
137
        stw     $0,$8,0
138
        add     $8,$8,4
139
clrtest:
140
        bltu    $8,$9,clrloop
141
        jal     main            ; call 'main'
142
start1:
143
        j       start1          ; loop
144
 
145
enable:
146
        mvfs    $8,0
147
        or      $8,$8,1 << 23
148
        mvts    $8,0
149
        jr      $31
150
 
151
disable:
152
        mvfs    $8,0
153
        and     $8,$8,~(1 << 23)
154
        mvts    $8,0
155
        jr      $31
156
 
157
getMask:
158
        mvfs    $8,0
159
        and     $2,$8,0x0000FFFF
160
        jr      $31
161
 
162
setMask:
163
        mvfs    $8,0
164
        and     $8,$8,0xFFFF0000
165
        and     $4,$4,0x0000FFFF
166
        or      $8,$8,$4
167
        mvts    $8,0
168
        jr      $31
169
 
170
getISR:
171
        sll     $4,$4,2
172
        ldw     $2,$4,irqsrv
173
        jr      $31
174
 
175
setISR:
176
        sll     $4,$4,2
177
        stw     $5,$4,irqsrv
178
        jr      $31
179
 
180
        .data
181
 
182
; interrupt service routine table
183
 
184
        .align  4
185
 
186
irqsrv:
187
        .word   0                ; 00: terminal 0 transmitter interrupt
188
        .word   0                ; 01: terminal 0 receiver interrupt
189
        .word   0                ; 02: terminal 1 transmitter interrupt
190
        .word   0                ; 03: terminal 1 receiver interrupt
191
        .word   0                ; 04: keyboard interrupt
192
        .word   0                ; 05: unused
193
        .word   0                ; 06: unused
194
        .word   0                ; 07: unused
195
        .word   0                ; 08: disk interrupt
196
        .word   0                ; 09: unused
197
        .word   0                ; 10: unused
198
        .word   0                ; 11: unused
199
        .word   0                ; 12: unused
200
        .word   0                ; 13: unused
201
        .word   0                ; 14: timer interrupt
202
        .word   0                ; 15: unused
203
        .word   0                ; 16: bus timeout exception
204
        .word   0                ; 17: illegal instruction exception
205
        .word   0                ; 18: privileged instruction exception
206
        .word   0                ; 19: divide instruction exception
207
        .word   0                ; 20: trap instruction exception
208
        .word   0                ; 21: TLB miss exception
209
        .word   0                ; 22: TLB write exception
210
        .word   0                ; 23: TLB invalid exception
211
        .word   0                ; 24: illegal address exception
212
        .word   0                ; 25: privileged address exception
213
        .word   0                ; 26: unused
214
        .word   0                ; 27: unused
215
        .word   0                ; 28: unused
216
        .word   0                ; 29: unused
217
        .word   0                ; 30: unused
218
        .word   0                ; 31: unused
219
 
220
        .bss
221
 
222
        .align  4
223
        .space  0x800
224
stack:
225
 
226
        .align  4
227
        .space  0x800
228
istack:

powered by: WebSVN 2.1.0

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