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

Subversion Repositories eco32

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

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 108 hellwig
        add     $8,$0,0xA8003FFF
118
        add     $9,$0,0xC0000000
119
        stw     $8,$9,0          ; 0xC0000000: j 0xC0010000
120
        stw     $8,$9,4         ; 0xC0000004: j 0xC0010004
121
        stw     $8,$9,8         ; 0xC0000008: j 0xC0010008
122 18 hellwig
        mvfs    $8,0
123
        or      $8,$8,1 << 27   ; let vector point to RAM
124
        mvts    $8,0
125
        add     $29,$0,stack     ; set sp
126
        add     $10,$0,_bdata    ; copy data segment
127
        add     $8,$0,_edata
128
        sub     $9,$8,$10
129
        add     $9,$9,_ecode
130
        j       cpytest
131
cpyloop:
132
        ldw     $11,$9,0
133
        stw     $11,$8,0
134
cpytest:
135
        sub     $8,$8,4
136
        sub     $9,$9,4
137
        bgeu    $8,$10,cpyloop
138
        add     $8,$0,_bbss      ; clear bss
139
        add     $9,$0,_ebss
140
        j       clrtest
141
clrloop:
142
        stw     $0,$8,0
143
        add     $8,$8,4
144
clrtest:
145
        bltu    $8,$9,clrloop
146
        jal     main            ; call 'main'
147
start1:
148
        j       start1          ; loop
149
 
150
enable:
151
        mvfs    $8,0
152
        or      $8,$8,1 << 23
153
        mvts    $8,0
154
        jr      $31
155
 
156
disable:
157
        mvfs    $8,0
158
        and     $8,$8,~(1 << 23)
159
        mvts    $8,0
160
        jr      $31
161
 
162
getMask:
163
        mvfs    $8,0
164
        and     $2,$8,0x0000FFFF
165
        jr      $31
166
 
167
setMask:
168
        mvfs    $8,0
169
        and     $8,$8,0xFFFF0000
170
        and     $4,$4,0x0000FFFF
171
        or      $8,$8,$4
172
        mvts    $8,0
173
        jr      $31
174
 
175
getISR:
176
        sll     $4,$4,2
177
        ldw     $2,$4,irqsrv
178
        jr      $31
179
 
180
setISR:
181
        sll     $4,$4,2
182
        stw     $5,$4,irqsrv
183
        jr      $31
184
 
185
        .data
186
 
187
; interrupt service routine table
188
 
189
        .align  4
190
 
191
irqsrv:
192
        .word   0                ; 00: terminal 0 transmitter interrupt
193
        .word   0                ; 01: terminal 0 receiver interrupt
194
        .word   0                ; 02: terminal 1 transmitter interrupt
195
        .word   0                ; 03: terminal 1 receiver interrupt
196
        .word   0                ; 04: keyboard interrupt
197
        .word   0                ; 05: unused
198
        .word   0                ; 06: unused
199
        .word   0                ; 07: unused
200
        .word   0                ; 08: disk interrupt
201
        .word   0                ; 09: unused
202
        .word   0                ; 10: unused
203
        .word   0                ; 11: unused
204
        .word   0                ; 12: unused
205
        .word   0                ; 13: unused
206 38 hellwig
        .word   0                ; 14: timer 0 interrupt
207
        .word   0                ; 15: timer 1 interrupt
208 18 hellwig
        .word   0                ; 16: bus timeout exception
209
        .word   0                ; 17: illegal instruction exception
210
        .word   0                ; 18: privileged instruction exception
211
        .word   0                ; 19: divide instruction exception
212
        .word   0                ; 20: trap instruction exception
213
        .word   0                ; 21: TLB miss exception
214
        .word   0                ; 22: TLB write exception
215
        .word   0                ; 23: TLB invalid exception
216
        .word   0                ; 24: illegal address exception
217
        .word   0                ; 25: privileged address exception
218
        .word   0                ; 26: unused
219
        .word   0                ; 27: unused
220
        .word   0                ; 28: unused
221
        .word   0                ; 29: unused
222
        .word   0                ; 30: unused
223
        .word   0                ; 31: unused
224
 
225
        .bss
226
 
227
        .align  4
228
        .space  0x800
229
stack:
230
 
231
        .align  4
232
        .space  0x800
233
istack:

powered by: WebSVN 2.1.0

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