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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [stdalone/] [onetask/] [os/] [start.s] - Blame information for rev 122

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 getISR
17
        .export setISR
18
        .export startTask
19
        .export setTLB
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    ; setup interrupt stack
48
        sub     $29,$29,128     ; save registers
49
        stw     $2,$29,8
50
        stw     $3,$29,12
51
        stw     $4,$29,16
52
        stw     $5,$29,20
53
        stw     $6,$29,24
54
        stw     $7,$29,28
55
        stw     $8,$29,32
56
        stw     $9,$29,36
57
        stw     $10,$29,40
58
        stw     $11,$29,44
59
        stw     $12,$29,48
60
        stw     $13,$29,52
61
        stw     $14,$29,56
62
        stw     $15,$29,60
63
        stw     $16,$29,64
64
        stw     $17,$29,68
65
        stw     $18,$29,72
66
        stw     $19,$29,76
67
        stw     $20,$29,80
68
        stw     $21,$29,84
69
        stw     $22,$29,88
70
        stw     $23,$29,92
71
        stw     $24,$29,96
72
        stw     $25,$29,100
73
        stw     $26,$29,116     ; this is the task's sp
74
        stw     $27,$29,4       ; this is the task's $1
75
        stw     $30,$29,120     ; this is the task's resumption address
76
        stw     $31,$29,124
77
        add     $5,$29,$0        ; $5 = pointer to register array
78
        mvfs    $4,0             ; $4 = IRQ number
79
        slr     $4,$4,16
80
        and     $4,$4,0x1F
81
        sll     $26,$4,2        ; $26 = 4 * IRQ number
82
        ldw     $26,$26,irqsrv  ; get addr of service routine
83
        jalr    $26             ; call service routine
84
        j       resume          ; resume interrupted task if ISR returns
85
 
86
        ; resume a task
87
resume:
88
        ldw     $2,$29,8        ; restore registers
89
        ldw     $3,$29,12
90
        ldw     $4,$29,16
91
        ldw     $5,$29,20
92
        ldw     $6,$29,24
93
        ldw     $7,$29,28
94
        ldw     $8,$29,32
95
        ldw     $9,$29,36
96
        ldw     $10,$29,40
97
        ldw     $11,$29,44
98
        ldw     $12,$29,48
99
        ldw     $13,$29,52
100
        ldw     $14,$29,56
101
        ldw     $15,$29,60
102
        ldw     $16,$29,64
103
        ldw     $17,$29,68
104
        ldw     $18,$29,72
105
        ldw     $19,$29,76
106
        ldw     $20,$29,80
107
        ldw     $21,$29,84
108
        ldw     $22,$29,88
109
        ldw     $23,$29,92
110
        ldw     $24,$29,96
111
        ldw     $25,$29,100
112
        ldw     $26,$29,116     ; this is the task's sp
113
        ldw     $27,$29,4       ; this is the task's $1
114
        ldw     $30,$29,120     ; this is the task's resumption address
115
        ldw     $31,$29,124
116
        add     $1,$27,$0        ; $27 -> $1
117
        add     $29,$26,$0       ; $26 -> sp
118
        rfx                     ; return from exception
119
 
120
start:
121 100 hellwig
        add     $8,$0,0xA8003FFF
122
        add     $9,$0,0xC0000000
123
        stw     $8,$9,0          ; 0xC0000000: j 0xC0010000
124
        stw     $8,$9,4         ; 0xC0000004: j 0xC0010004
125
        stw     $8,$9,8         ; 0xC0000008: j 0xC0010008
126 18 hellwig
        mvfs    $8,0
127
        or      $8,$8,1 << 27   ; let vector point to RAM
128
        mvts    $8,0
129
        add     $29,$0,stack     ; set sp
130
        add     $10,$0,_bdata    ; copy data segment
131
        add     $8,$0,_edata
132
        sub     $9,$8,$10
133
        add     $9,$9,_ecode
134
        j       cpytest
135
cpyloop:
136
        ldw     $11,$9,0
137
        stw     $11,$8,0
138
cpytest:
139
        sub     $8,$8,4
140
        sub     $9,$9,4
141
        bgeu    $8,$10,cpyloop
142
        add     $8,$0,_bbss      ; clear bss
143
        add     $9,$0,_ebss
144
        j       clrtest
145
clrloop:
146
        stw     $0,$8,0
147
        add     $8,$8,4
148
clrtest:
149
        bltu    $8,$9,clrloop
150
        jal     main            ; call 'main'
151
start1:
152
        j       start1          ; loop
153
 
154
enable:
155
        mvfs    $8,0
156
        or      $8,$8,1 << 23
157
        mvts    $8,0
158
        jr      $31
159
 
160
disable:
161
        mvfs    $8,0
162
        and     $8,$8,~(1 << 23)
163
        mvts    $8,0
164
        jr      $31
165
 
166
getISR:
167
        sll     $4,$4,2
168
        ldw     $2,$4,irqsrv
169
        jr      $31
170
 
171
setISR:
172
        sll     $4,$4,2
173
        stw     $5,$4,irqsrv
174
        jr      $31
175
 
176
startTask:
177
        or      $29,$4,0xC0000000
178
        sub     $29,$29,128
179
        stw     $0,$29,0  ; preset registers
180
        stw     $0,$29,4
181
        stw     $0,$29,8
182
        stw     $0,$29,12
183
        stw     $0,$29,16
184
        stw     $0,$29,20
185
        stw     $0,$29,24
186
        stw     $0,$29,28
187
        stw     $0,$29,32
188
        stw     $0,$29,36
189
        stw     $0,$29,40
190
        stw     $0,$29,44
191
        stw     $0,$29,48
192
        stw     $0,$29,52
193
        stw     $0,$29,56
194
        stw     $0,$29,60
195
        stw     $0,$29,64
196
        stw     $0,$29,68
197
        stw     $0,$29,72
198
        stw     $0,$29,76
199
        stw     $0,$29,80
200
        stw     $0,$29,84
201
        stw     $0,$29,88
202
        stw     $0,$29,92
203
        stw     $0,$29,96
204
        stw     $0,$29,100
205
        stw     $0,$29,104
206
        stw     $0,$29,108
207
        stw     $0,$29,112
208
        add     $8,$0,0x80000000
209
        stw     $8,$29,116      ; sp
210
        stw     $0,$29,120       ; task starts at virtual address 0
211
        stw     $0,$29,124
212
        mvfs    $8,0
213
        or      $8,$8,1 << 25   ; set previous mode to 'user'
214
        mvts    $8,0
215
        j       resume
216
 
217
setTLB:
218
        mvts    $4,1            ; set index
219
        mvts    $5,2            ; set entryHi
220
        mvts    $6,3            ; set entryLo
221
        tbwi                    ; write TLB entry at index
222
        jr      $31
223
 
224
        .data
225
 
226
; interrupt service routine table
227
 
228
        .align  4
229
 
230
irqsrv:
231
        .word   0                ; 00: terminal 0 transmitter interrupt
232
        .word   0                ; 01: terminal 0 receiver interrupt
233
        .word   0                ; 02: terminal 1 transmitter interrupt
234
        .word   0                ; 03: terminal 1 receiver interrupt
235
        .word   0                ; 04: keyboard interrupt
236
        .word   0                ; 05: unused
237
        .word   0                ; 06: unused
238
        .word   0                ; 07: unused
239
        .word   0                ; 08: disk interrupt
240
        .word   0                ; 09: unused
241
        .word   0                ; 10: unused
242
        .word   0                ; 11: unused
243
        .word   0                ; 12: unused
244
        .word   0                ; 13: unused
245 38 hellwig
        .word   0                ; 14: timer 0 interrupt
246
        .word   0                ; 15: timer 1 interrupt
247 18 hellwig
        .word   0                ; 16: bus timeout exception
248
        .word   0                ; 17: illegal instruction exception
249
        .word   0                ; 18: privileged instruction exception
250
        .word   0                ; 19: divide instruction exception
251
        .word   0                ; 20: trap instruction exception
252
        .word   0                ; 21: TLB miss exception
253
        .word   0                ; 22: TLB write exception
254
        .word   0                ; 23: TLB invalid exception
255
        .word   0                ; 24: illegal address exception
256
        .word   0                ; 25: privileged address exception
257
        .word   0                ; 26: unused
258
        .word   0                ; 27: unused
259
        .word   0                ; 28: unused
260
        .word   0                ; 29: unused
261
        .word   0                ; 30: unused
262
        .word   0                ; 31: unused
263
 
264
        .bss
265
 
266
        .align  4
267
        .space  0x800
268
stack:
269
 
270
        .align  4
271
        .space  0x800
272
istack:

powered by: WebSVN 2.1.0

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