1 | /* |
---|
2 | ** start.S -- startup file for Mongoose V BSP based upon crt0.S from |
---|
3 | ** newlib-1.8.2/libgloss/mips and adapted for RTEMS. |
---|
4 | ** |
---|
5 | ** crt0.S -- startup file for MIPS. |
---|
6 | ** |
---|
7 | ** Copyright (c) 1995, 1996, 1997 Cygnus Support |
---|
8 | ** |
---|
9 | ** The authors hereby grant permission to use, copy, modify, distribute, |
---|
10 | ** and license this software and its documentation for any purpose, provided |
---|
11 | ** that existing copyright notices are retained in all copies and that this |
---|
12 | ** notice is included verbatim in any distributions. No written agreement, |
---|
13 | ** license, or royalty fee is required for any of the authorized uses. |
---|
14 | ** Modifications to this software may be copyrighted by their authors |
---|
15 | ** and need not follow the licensing terms described here, provided that |
---|
16 | ** the new terms are clearly indicated on the first page of each file where |
---|
17 | ** they apply. |
---|
18 | ** |
---|
19 | ** |
---|
20 | ** Modification History: |
---|
21 | ** 01/XX/01 Joel Sherrill, OAR Corp, |
---|
22 | ** Modified for Mongoose V BSP for NASA/GSFC Code 582. |
---|
23 | ** |
---|
24 | ** 06/XX/01 Greg Menke, Raytheon, Code 582 |
---|
25 | ** Debug modifications. Removed R4000 dependencies. |
---|
26 | ** Added HACKED_PMON defines to facilitate startup. |
---|
27 | ** Added DEFAULT_EXIT_RETURN_TO_MONITOR option. |
---|
28 | ** |
---|
29 | ** 11/14/01 A.Ferrer, NASA/GSFC, Code 582 |
---|
30 | ** Cleanup for ST5 mission. |
---|
31 | ** |
---|
32 | ** 11/27/01 A.Ferrer, NASA/GSFC, Code 582 |
---|
33 | ** Added cache flush routines. |
---|
34 | */ |
---|
35 | |
---|
36 | #define LANGUAGE_ASSEMBLY |
---|
37 | |
---|
38 | |
---|
39 | #include <asm.h> |
---|
40 | #include "regs.S" |
---|
41 | #include "mg5.h" |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | #ifdef __mips16 |
---|
46 | /* This file contains 32 bit assembly code. */ |
---|
47 | .set nomips16 |
---|
48 | #endif |
---|
49 | |
---|
50 | |
---|
51 | /* |
---|
52 | ** defined by linkcmds, pointing to the start of the relocation target |
---|
53 | ** memory, referenced in this way so we can avoid defining it |
---|
54 | ** multiply |
---|
55 | */ |
---|
56 | .bss |
---|
57 | .word 0 |
---|
58 | .text |
---|
59 | .align 2 |
---|
60 | |
---|
61 | |
---|
62 | /********************************************************************** |
---|
63 | ** |
---|
64 | ** Function: _start |
---|
65 | */ |
---|
66 | |
---|
67 | /* Without the following nop, GDB thinks _start is a data variable. |
---|
68 | ** This is probably a bug in GDB in handling a symbol that is at the |
---|
69 | ** start of the .text section. |
---|
70 | */ |
---|
71 | nop |
---|
72 | .globl _start |
---|
73 | .ent _start |
---|
74 | |
---|
75 | .globl putch_rom |
---|
76 | _start: |
---|
77 | .set noreorder |
---|
78 | $LF1 = . + 8 |
---|
79 | |
---|
80 | /* |
---|
81 | ** Get the address of start into $5 in a position independent fashion. |
---|
82 | ** This lets us know whether we have been relocated or not. |
---|
83 | */ |
---|
84 | |
---|
85 | bal $LF1 |
---|
86 | nop |
---|
87 | _branch: |
---|
88 | move a1, ra /* save return address from the jump above */ |
---|
89 | |
---|
90 | /* ensure we're sane before doing anything */ |
---|
91 | |
---|
92 | li t0, SR_CU0|SR_PE |
---|
93 | mtc0 t0, C0_SR |
---|
94 | nop |
---|
95 | li t0, 0 |
---|
96 | mtc0 t0, C0_DCIC |
---|
97 | nop |
---|
98 | mtc0 t0, C0_CAUSE |
---|
99 | nop |
---|
100 | |
---|
101 | |
---|
102 | /* |
---|
103 | ** Call cpuinit. Masking used to call EEPROM address of _cpuinit. Label is RAM label. |
---|
104 | */ |
---|
105 | move t2,a1 |
---|
106 | and t2,0xffff0000 |
---|
107 | la t0,_cpuinit |
---|
108 | and t0,0x0000ffff |
---|
109 | or t0,t2 |
---|
110 | jal t0 |
---|
111 | nop |
---|
112 | |
---|
113 | /* |
---|
114 | ** Configure UART |
---|
115 | */ |
---|
116 | move t2,a1 |
---|
117 | and t2,0xffff0000 |
---|
118 | la t0,config_uart |
---|
119 | and t0,0x0000ffff |
---|
120 | or t0,t2 |
---|
121 | jal t0 |
---|
122 | nop |
---|
123 | |
---|
124 | |
---|
125 | |
---|
126 | /* |
---|
127 | ** Print 'b'. Show that we started. |
---|
128 | */ |
---|
129 | move t2,a1 |
---|
130 | and t2,0xffff0000 |
---|
131 | li a0,'b' |
---|
132 | la t0,putch_rom |
---|
133 | and t0,0x0000ffff |
---|
134 | or t0,t2 |
---|
135 | jal t0 |
---|
136 | nop |
---|
137 | |
---|
138 | |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | li k0,0 |
---|
143 | li k1,0 |
---|
144 | |
---|
145 | move t1,a1 |
---|
146 | nop |
---|
147 | li t2,0xa0000000 /* lower limit of kseg1 */ |
---|
148 | li t3,0xbfffffff /* upper limit of kseg1 */ |
---|
149 | |
---|
150 | subu t0,t1,t2 |
---|
151 | srl t0,31 /* shift high bit down to bit 0 */ |
---|
152 | bnez t0,1f /* booting from below kseg1 */ |
---|
153 | |
---|
154 | subu t0,t3,t1 |
---|
155 | srl t0,31 /* shift high bit down to bit 0 */ |
---|
156 | bnez t0,1f /* booting from above kseg1 */ |
---|
157 | |
---|
158 | |
---|
159 | |
---|
160 | /* |
---|
161 | ** Call IcacheFlush. Masking used to call EEPROM address of IcacheFlush. Label is RAM label. |
---|
162 | */ |
---|
163 | move t2,a1 |
---|
164 | and t2,0xffff0000 |
---|
165 | la t0,IcacheFlush |
---|
166 | and t0,0x0000ffff |
---|
167 | or t0,t2 |
---|
168 | move k0,t0 /* save cache flush in-prom address */ |
---|
169 | jal t0 |
---|
170 | nop |
---|
171 | |
---|
172 | |
---|
173 | /* |
---|
174 | ** Print 'I'. Show that we flushed I cache. |
---|
175 | */ |
---|
176 | move t2,a1 |
---|
177 | and t2,0xffff0000 |
---|
178 | li a0,'I' |
---|
179 | la t0,putch_rom |
---|
180 | and t0,0x0000ffff |
---|
181 | or t0,t2 |
---|
182 | jal t0 |
---|
183 | nop |
---|
184 | |
---|
185 | |
---|
186 | /* |
---|
187 | ** Call DcacheFlush. Masking used to call EEPROM address of DcacheFlush. Label is RAM label. |
---|
188 | */ |
---|
189 | move t2,a1 |
---|
190 | and t2,0xffff0000 |
---|
191 | la t0,DcacheFlush |
---|
192 | and t0,0x0000ffff |
---|
193 | or t0,t2 |
---|
194 | jal t0 |
---|
195 | nop |
---|
196 | |
---|
197 | |
---|
198 | /* |
---|
199 | ** Print 'D'. Show that we flushed D cache. |
---|
200 | */ |
---|
201 | move t2,a1 |
---|
202 | and t2,0xffff0000 |
---|
203 | li a0,'D' |
---|
204 | la t0,putch_rom |
---|
205 | and t0,0x0000ffff |
---|
206 | or t0,t2 |
---|
207 | move k1,t0 /* save cache flush in-prom address */ |
---|
208 | jal t0 |
---|
209 | nop |
---|
210 | |
---|
211 | |
---|
212 | 1: |
---|
213 | /* |
---|
214 | ** Print ' RTEMS b'. Show that we are booting. |
---|
215 | */ |
---|
216 | move t2,a1 |
---|
217 | and t2,0xffff0000 |
---|
218 | li a0,' ' |
---|
219 | la t0,putch_rom |
---|
220 | and t0,0x0000ffff |
---|
221 | or t0,t2 |
---|
222 | jal t0 |
---|
223 | nop |
---|
224 | |
---|
225 | move t2,a1 |
---|
226 | and t2,0xffff0000 |
---|
227 | li a0,'R' |
---|
228 | la t0,putch_rom |
---|
229 | and t0,0x0000ffff |
---|
230 | or t0,t2 |
---|
231 | jal t0 |
---|
232 | nop |
---|
233 | |
---|
234 | move t2,a1 |
---|
235 | and t2,0xffff0000 |
---|
236 | li a0,'T' |
---|
237 | la t0,putch_rom |
---|
238 | and t0,0x0000ffff |
---|
239 | or t0,t2 |
---|
240 | jal t0 |
---|
241 | nop |
---|
242 | |
---|
243 | move t2,a1 |
---|
244 | and t2,0xffff0000 |
---|
245 | li a0,'E' |
---|
246 | la t0,putch_rom |
---|
247 | and t0,0x0000ffff |
---|
248 | or t0,t2 |
---|
249 | jal t0 |
---|
250 | nop |
---|
251 | |
---|
252 | move t2,a1 |
---|
253 | and t2,0xffff0000 |
---|
254 | li a0,'M' |
---|
255 | la t0,putch_rom |
---|
256 | and t0,0x0000ffff |
---|
257 | or t0,t2 |
---|
258 | jal t0 |
---|
259 | nop |
---|
260 | |
---|
261 | move t2,a1 |
---|
262 | and t2,0xffff0000 |
---|
263 | li a0,'S' |
---|
264 | la t0,putch_rom |
---|
265 | and t0,0x0000ffff |
---|
266 | or t0,t2 |
---|
267 | jal t0 |
---|
268 | nop |
---|
269 | |
---|
270 | move t2,a1 |
---|
271 | and t2,0xffff0000 |
---|
272 | li a0,' ' |
---|
273 | la t0,putch_rom |
---|
274 | and t0,0x0000ffff |
---|
275 | or t0,t2 |
---|
276 | jal t0 |
---|
277 | nop |
---|
278 | |
---|
279 | move t2,a1 |
---|
280 | and t2,0xffff0000 |
---|
281 | li a0,'b' |
---|
282 | la t0,putch_rom |
---|
283 | and t0,0x0000ffff |
---|
284 | or t0,t2 |
---|
285 | jal t0 |
---|
286 | nop |
---|
287 | |
---|
288 | |
---|
289 | /* |
---|
290 | ** get the address of the _branch label above as it would appear in |
---|
291 | ** the relocated code |
---|
292 | */ |
---|
293 | |
---|
294 | la a2, _branch /* relocation destination */ |
---|
295 | beq a1, a2, _start_in_ram /* skip relocating if we're already there */ |
---|
296 | nop |
---|
297 | |
---|
298 | /* relocate the code from EEPROM to RAM */ |
---|
299 | |
---|
300 | /* |
---|
301 | ** Print 'r' |
---|
302 | */ |
---|
303 | move t2,a1 |
---|
304 | and t2,0xffff0000 |
---|
305 | li a0,'r' |
---|
306 | la t0,putch_rom |
---|
307 | and t0,0x0000ffff |
---|
308 | or t0,t2 |
---|
309 | jal t0 |
---|
310 | nop |
---|
311 | |
---|
312 | la a3, _edata |
---|
313 | relocate: |
---|
314 | lw t0, (a1) /* load from EEPROM */ |
---|
315 | addu a1, 4 |
---|
316 | sw t0, (a2) /* store to RAM */ |
---|
317 | addu a2, 4 |
---|
318 | bne a2, a3, relocate /* copied all the way to edata? */ |
---|
319 | nop |
---|
320 | |
---|
321 | /* |
---|
322 | ** Print 'R' |
---|
323 | */ |
---|
324 | li a0,'R' |
---|
325 | la t0,putch_rom |
---|
326 | and t0,0x0000ffff |
---|
327 | or t0,t2 |
---|
328 | jal t0 |
---|
329 | nop |
---|
330 | |
---|
331 | la a2, _start_in_ram |
---|
332 | jr a2 |
---|
333 | nop |
---|
334 | .end _start |
---|
335 | |
---|
336 | |
---|
337 | /********************************************************************** |
---|
338 | ** |
---|
339 | ** Function: _start_in_ram |
---|
340 | */ |
---|
341 | |
---|
342 | .globl _start_in_ram |
---|
343 | .ent _start_in_ram |
---|
344 | _start_in_ram: |
---|
345 | |
---|
346 | /* |
---|
347 | ** Print 'S'. Already in RAM no need to reference EEPROM address. |
---|
348 | */ |
---|
349 | li a0,'S' |
---|
350 | jal putch_rom |
---|
351 | nop |
---|
352 | |
---|
353 | la gp, _gp /* set the global data pointer */ |
---|
354 | .end _start_in_ram |
---|
355 | |
---|
356 | |
---|
357 | /********************************************************************** |
---|
358 | ** |
---|
359 | ** Function: zerobss |
---|
360 | */ |
---|
361 | .globl __memsize |
---|
362 | .globl zerobss |
---|
363 | .ent zerobss |
---|
364 | zerobss: |
---|
365 | |
---|
366 | /* |
---|
367 | ** Print 'z'. Starting to zero out bss. |
---|
368 | */ |
---|
369 | li a0,'z' |
---|
370 | jal putch_rom |
---|
371 | nop |
---|
372 | |
---|
373 | la v0, _fbss |
---|
374 | la v1, _end |
---|
375 | 3: |
---|
376 | sw zero,0(v0) |
---|
377 | bltu v0,v1,3b |
---|
378 | addiu v0,v0,4 /* executed in delay slot */ |
---|
379 | |
---|
380 | la t0, _stack_init /* initialize stack so we */ |
---|
381 | |
---|
382 | /* |
---|
383 | ** We must subtract 24 bytes for the 3 8 byte arguments to main, in |
---|
384 | ** case main wants to write them back to the stack. The caller is |
---|
385 | ** supposed to allocate stack space for parameters in registers in |
---|
386 | ** the old MIPS ABIs. We must do this even though we aren't passing |
---|
387 | ** arguments, because main might be declared to have them. |
---|
388 | ** |
---|
389 | ** Some ports need a larger alignment for the stack, so we subtract |
---|
390 | ** 32, which satisifes the stack for the arguments and keeps the |
---|
391 | ** stack pointer better aligned. |
---|
392 | */ |
---|
393 | subu t0,t0,32 |
---|
394 | move sp,t0 /* set stack pointer */ |
---|
395 | nop |
---|
396 | |
---|
397 | /* |
---|
398 | ** Print 'Z'. Finished zeroing bss. |
---|
399 | */ |
---|
400 | li a0,'Z' |
---|
401 | jal putch_rom |
---|
402 | nop |
---|
403 | |
---|
404 | .end zerobss |
---|
405 | |
---|
406 | |
---|
407 | /********************************************************************** |
---|
408 | ** |
---|
409 | ** Function: _init |
---|
410 | */ |
---|
411 | .globl exit .text |
---|
412 | .globl _init |
---|
413 | .ent _init |
---|
414 | _init: |
---|
415 | |
---|
416 | /* |
---|
417 | ** Print 'i'. Starting to initialize RTEMS. |
---|
418 | */ |
---|
419 | li a0, 'i' |
---|
420 | jal putch_rom |
---|
421 | nop |
---|
422 | |
---|
423 | |
---|
424 | /* |
---|
425 | ** Save the boot-time addresses of the I & D cache flush routines. |
---|
426 | ** Note, if we're running from RAM, we cannot manipulate the cache |
---|
427 | ** so we just disable the cache flush functions. |
---|
428 | */ |
---|
429 | la a0,_promIcache |
---|
430 | sw k0,0(a0) |
---|
431 | nop |
---|
432 | |
---|
433 | la a0,_promDcache |
---|
434 | sw k1,0(a0) |
---|
435 | nop |
---|
436 | |
---|
437 | move a0,zero /* set argc to 0 */ |
---|
438 | jal boot_card /* call the program start function */ |
---|
439 | nop |
---|
440 | |
---|
441 | /* |
---|
442 | ** fall through to the "exit" routine |
---|
443 | */ |
---|
444 | jal _sys_exit |
---|
445 | nop |
---|
446 | .end _init |
---|
447 | |
---|
448 | |
---|
449 | /********************************************************************** |
---|
450 | ** |
---|
451 | ** Function: _sys_exit |
---|
452 | ** |
---|
453 | ** Exit from the application by jumping to PMON address in EEPROM. |
---|
454 | */ |
---|
455 | .globl _sys_exit |
---|
456 | .ent _sys_exit |
---|
457 | _sys_exit: |
---|
458 | la t0, PMON_ADDRESS |
---|
459 | jal t0 |
---|
460 | .end _sys_exit |
---|
461 | |
---|
462 | |
---|
463 | |
---|
464 | /********************************************************************** |
---|
465 | ** |
---|
466 | ** function: putch |
---|
467 | ** input : ASCII character in A0 |
---|
468 | ** registers used: ra, a0, t0, t1 |
---|
469 | ** |
---|
470 | */ |
---|
471 | .globl putch_rom |
---|
472 | .ent putch_rom |
---|
473 | putch_rom: |
---|
474 | |
---|
475 | /* |
---|
476 | ** Delay for UART |
---|
477 | */ |
---|
478 | li t0, 1000 |
---|
479 | move t1, zero |
---|
480 | 2: |
---|
481 | beq t0, t1, 3f |
---|
482 | addu t1, 1 |
---|
483 | b 2b |
---|
484 | nop |
---|
485 | |
---|
486 | 3: |
---|
487 | /* |
---|
488 | ** Print a character out from a0 |
---|
489 | */ |
---|
490 | |
---|
491 | li t0, MG5_INT_STATUS_REG /* load uart register base address */ |
---|
492 | lw t1, 0(t0) /* Read status */ |
---|
493 | nop |
---|
494 | and t1, t1, UART_0_TX_READY_BIT /* see if the transmitter is ready */ |
---|
495 | beq t1 , zero , 1f /* skip uart output if not ready */ |
---|
496 | nop |
---|
497 | la t0, MG5_UART_0_TX_REG |
---|
498 | sw a0, 0(t0) |
---|
499 | nop |
---|
500 | |
---|
501 | 1: /* |
---|
502 | ** if jumped to here, UART was not ready...forget it |
---|
503 | */ |
---|
504 | j ra |
---|
505 | .end putch_rom |
---|
506 | |
---|
507 | |
---|
508 | /********************************************************************** |
---|
509 | ** |
---|
510 | ** function: config_uart |
---|
511 | ** registers used: ra, t0, t1 |
---|
512 | ** |
---|
513 | */ |
---|
514 | |
---|
515 | .globl config_uart |
---|
516 | .ent config_uart |
---|
517 | config_uart: |
---|
518 | |
---|
519 | /* |
---|
520 | ** Configure UART 0 |
---|
521 | */ |
---|
522 | |
---|
523 | /* First, reset the uart */ |
---|
524 | la t0, MG5_COMMAND_REG |
---|
525 | li t1, UART_RESET_BIT |
---|
526 | sw t1, 0(t0) |
---|
527 | |
---|
528 | /* Next, set the baud rate register for 19200 with a clock speed of 12 Mhz*/ |
---|
529 | la t0, MG5_UART_0_BAUD_REG |
---|
530 | li t1, 0x02700270 |
---|
531 | sw t1, 0(t0) |
---|
532 | |
---|
533 | /* Now, clear the reset bit & set the tx enable bit */ |
---|
534 | la t0, MG5_COMMAND_REG |
---|
535 | li t1, UART_0_TX_ENABLE_BIT |
---|
536 | sw t1, 0(t0) |
---|
537 | |
---|
538 | /* |
---|
539 | ** return |
---|
540 | */ |
---|
541 | j ra |
---|
542 | .end config_uart |
---|
543 | |
---|
544 | |
---|
545 | /************************************************************* |
---|
546 | * CpuInit: |
---|
547 | * Perform CPU-specific initialization |
---|
548 | * This routine is only callable from assembly because it |
---|
549 | * clobbers s7. It should be called from your ROM-based startup |
---|
550 | * code. It returns: |
---|
551 | * s0 = address of cache flush routine |
---|
552 | */ |
---|
553 | |
---|
554 | .globl _cpuinit |
---|
555 | .ent _cpuinit |
---|
556 | _cpuinit: |
---|
557 | |
---|
558 | # |
---|
559 | # BIU/Cache config register setup |
---|
560 | # |
---|
561 | # RES = 0: 31 -> 18 : Reserved |
---|
562 | # RES = 1: 17 : Reserved must be set to 1 (Synova Manual) |
---|
563 | # RES = 0: 16 : Reserved must be set to 0 (Synova Manual) |
---|
564 | # BGNT = 0: 15 : Disable Bus Grant (set to 0) |
---|
565 | # NOPAD = 1: 14 : No padding of waitstates between transactions |
---|
566 | # RDPRI = 1: 13 : Loads have priority over stores |
---|
567 | # INTP = 1: 12 : Interrupts are active high |
---|
568 | # IS1 = 1: 11 : Enable I-Cache |
---|
569 | # IS0 = 0: 10 : Hardwired to zero |
---|
570 | # IBLKSZ =10: 9 -> 8 : I-Cache refill size = 8 words |
---|
571 | # DS = 1: 7 : Enable D-Cache |
---|
572 | # RES = 0: 6 : Hardwared to zero |
---|
573 | # DBLKSZ =10: 5 -> 4 : D-Cache refill block size 8 words |
---|
574 | # RAM = 0: 3 : No Scratchpad RAM |
---|
575 | # TAG = 0: 2 : Disable tag test |
---|
576 | # INV = 0: 1 : Disable invalidate mode |
---|
577 | # LOCK = 0: 0 : Disable cache lock |
---|
578 | # |
---|
579 | li t0,0x00027AA0 |
---|
580 | sw t0,M_BIU |
---|
581 | |
---|
582 | # |
---|
583 | # Refresh register setup |
---|
584 | # |
---|
585 | # set 94 clock cycles at 12Mhz |
---|
586 | # |
---|
587 | li t1,M_RTIC |
---|
588 | li t0,0x5E |
---|
589 | sw t0,(t1) |
---|
590 | |
---|
591 | # |
---|
592 | # DRAM register setup |
---|
593 | # |
---|
594 | # |
---|
595 | # RESERVED=0: 31 -> 29 : Reserved |
---|
596 | # SYNC = 0 : 27 : No Syncronous DRAM |
---|
597 | # SCFG = 0 : 26 : No Syncronous DRAM |
---|
598 | # DMARDY =1 : 25 : Internal DRDY for DMA |
---|
599 | # DMABLK =0 : 24 -> 22 : 2 word blk size for DMA transfers |
---|
600 | # DPTH = 0 : 21 -> 20 : No interleaved or syncronous memory |
---|
601 | # RDYW = 0 : 19 : No interleaved or syncronous memory |
---|
602 | # PGSZ = 110: 18 -> 16 : Page size = 1K |
---|
603 | # PGMW = 0 : 15 : Disable page mode write |
---|
604 | # RFWE = 0 : 14 -> 13 : Allow BIU to do non-DRAM work during refresh |
---|
605 | # RFEN = 1 : 12 : Enable Refresh generator |
---|
606 | # RDYEN = 1 : 11 : Internal DRDY |
---|
607 | # BFD = 1 : 10 : Block fetch disable |
---|
608 | # PE = 0 : 9 : No parity checking |
---|
609 | # RPC = 0 : 8 -> 7 : RAS Precharge = 2 SYSCLK cycles |
---|
610 | # RCD = 1 : 6 -> 5 : RAS-to-CAS delay = 3 cycles |
---|
611 | # CS = 0 : 4 : CAS shortened by 1/2 cycle |
---|
612 | # CL = 1 : 3 -> 1 : 2.5 cycle CAS pulse width |
---|
613 | # DCE = 1 : 0 : Enable DRAM controller |
---|
614 | li s0,0x02061C23 |
---|
615 | sw s0,M_DRAM |
---|
616 | |
---|
617 | # |
---|
618 | # SRAM setup |
---|
619 | # Dont Care about this, we are not using SRAM |
---|
620 | # Power on default of 0x0 is ok |
---|
621 | # |
---|
622 | li t0,0 |
---|
623 | sw t0,M_SRAM |
---|
624 | |
---|
625 | # |
---|
626 | # SPEC0 setup |
---|
627 | # |
---|
628 | # SPEC0 contains the BCRT registers, BCRT Shared RAM and EEPROM |
---|
629 | # This area is configured to use an external waitstate generator |
---|
630 | # and Data Ready signal. |
---|
631 | # Also, I see no need to cache this data. It could confuse the |
---|
632 | # BCRT. |
---|
633 | # |
---|
634 | # - 9/29/99 - APC - set NOSNOOP to 1 and EXTGNT to 1 |
---|
635 | # Bit 23 = 1 : EXTGNT External data ready = 1 |
---|
636 | # Bit 19 = 1 : NOSNOOP No Snoop = 1 |
---|
637 | li t0,0x00880000 # use external waitstates |
---|
638 | sw t0,M_SPEC0 |
---|
639 | |
---|
640 | # |
---|
641 | # SPEC1 setup |
---|
642 | # |
---|
643 | # This is where most of the SDB I/O is. |
---|
644 | # |
---|
645 | # Important fields: |
---|
646 | # |
---|
647 | # Bit 19 =1 : NOSNOOP = 1 |
---|
648 | # Bit 6 = 1 : Enable DAWG |
---|
649 | # Bit 5 -> 0 = 1 : 1 Wait state |
---|
650 | # |
---|
651 | li t0,0x00880000 /* Bit23 EXTGNT set to 1, Bit19 NOSNOOP set to 1 */ |
---|
652 | sw t0,M_SPEC1 |
---|
653 | |
---|
654 | # |
---|
655 | # SPEC2 setup |
---|
656 | # |
---|
657 | # SPEC2 is not currently used on the SDB. |
---|
658 | # Bit 19 = 1 : NOSNOOP = 1 |
---|
659 | # |
---|
660 | #li t0, 0x00080000 |
---|
661 | #sw t0,M_SPEC2 |
---|
662 | # |
---|
663 | li t0, 0x0 |
---|
664 | sw t0,M_SPEC2 |
---|
665 | |
---|
666 | |
---|
667 | # |
---|
668 | # SPEC3 Setup |
---|
669 | # SPEC3 will be used for the SONIC ethernet controller. |
---|
670 | # Use the same # of waitstates that the turborocket board uses. |
---|
671 | # Bit 19 = 1 : NOSNOOP = 1 |
---|
672 | # |
---|
673 | #li t0, (SPC_CACHED | SPC_WAITENA | (16<<SPC_WAITSHFT)) |
---|
674 | #sw t0,M_SPEC3 |
---|
675 | # |
---|
676 | li t0, 0x0 |
---|
677 | sw t0,M_SPEC3 |
---|
678 | |
---|
679 | # |
---|
680 | # Finally, delay to allow RAM to stabilize |
---|
681 | # |
---|
682 | li t0,2000 |
---|
683 | 1: subu t0,1 |
---|
684 | bne t0,zero,1b |
---|
685 | nop |
---|
686 | |
---|
687 | # |
---|
688 | # Init Mongoose V registers. |
---|
689 | # |
---|
690 | |
---|
691 | /* |
---|
692 | ** Mongoose V Control Register Setup |
---|
693 | ** For now just setup UART defaults, turn edac off. |
---|
694 | ** May not even need to put anything in here... |
---|
695 | */ |
---|
696 | li t0,0 |
---|
697 | sw t0,MG5_COMMAND_REG |
---|
698 | |
---|
699 | /* |
---|
700 | ** Setup Mongoose V extended interrupt mask |
---|
701 | */ |
---|
702 | li t0,0 |
---|
703 | sw t0,MG5_INT_MASK_REG |
---|
704 | |
---|
705 | /* |
---|
706 | ** Clear Mongoose V extended interrupts |
---|
707 | ** Clear all of the pulse interrupts that may be pending. |
---|
708 | */ |
---|
709 | li t0,( EDAC_SERR_BIT | EDAC_MERR_BIT | UART_0_RX_OVERRUN_BIT | UART_0_FRAME_ERR_BIT | UART_1_RX_OVERRUN_BIT | UART_1_FRAME_ERR_BIT | MAVN_WRITE_ACC_BIT | MAVN_READ_ACC_BIT ) |
---|
710 | sw t0,MG5_INT_STATUS_REG |
---|
711 | |
---|
712 | /* |
---|
713 | ** Setup MAVN Access Priv Register |
---|
714 | */ |
---|
715 | li t0,0x7FFFFFFF /* Default reset value */ |
---|
716 | sw t0,MG5_MAVN_PRIVLEGE_REG |
---|
717 | |
---|
718 | /* |
---|
719 | ** Mavn Range Register 0 -- 0 and 1 cover EEPROM |
---|
720 | ** 0xbfc00000 -> 0xbfe00000 |
---|
721 | */ |
---|
722 | li t0,( 0xBFC00000 | 0x15 ) |
---|
723 | sw t0,MG5_MAVN_RANGE_0_REG |
---|
724 | |
---|
725 | /* |
---|
726 | ** Mavn Range Register 1 |
---|
727 | ** 0xbfe00000 -> 0xc0000000 |
---|
728 | */ |
---|
729 | li t0,( 0xBFE00000 | 0x15 ) |
---|
730 | sw t0,MG5_MAVN_RANGE_1_REG |
---|
731 | |
---|
732 | /* |
---|
733 | ** Mavn Range Register 2 -- 2 and 3 cover the first RAM |
---|
734 | ** 0x80000000 -> 0x80200000 |
---|
735 | */ |
---|
736 | li t0,( 0x80000000 | 0x15 ) |
---|
737 | sw t0,MG5_MAVN_RANGE_2_REG |
---|
738 | |
---|
739 | /* |
---|
740 | ** Mavn Range Register 3 |
---|
741 | ** 0x80200000 -> 0x80400000 |
---|
742 | */ |
---|
743 | li t0, ( 0x80200000 | 0x15 ) |
---|
744 | sw t0, MG5_MAVN_RANGE_3_REG |
---|
745 | |
---|
746 | /* |
---|
747 | ** Mavn Range Register 4 -- IO Space 1 |
---|
748 | ** 0xBE00000 -> 0xBe0000200 |
---|
749 | */ |
---|
750 | li t0, ( 0xBe000000 | 0x09 ) |
---|
751 | sw t0, MG5_MAVN_RANGE_4_REG |
---|
752 | |
---|
753 | /* |
---|
754 | ** Mavn Range Register 5 -- IO Space 2 |
---|
755 | ** 0xBe200000 -> 0xbe400000 |
---|
756 | */ |
---|
757 | li t0, ( 0xBE200000 | 0x15 ) |
---|
758 | sw t0, MG5_MAVN_RANGE_5_REG |
---|
759 | |
---|
760 | /* |
---|
761 | ** MAVN Error Address Register ( Unstick ) |
---|
762 | */ |
---|
763 | la t0, MG5_MAVN_VIOLATION_REG |
---|
764 | lw t1, 0(t0) |
---|
765 | |
---|
766 | /* |
---|
767 | ** Read EDAC Error Register to unstick it |
---|
768 | */ |
---|
769 | la t0, MG5_EDAC_ADDR_REG |
---|
770 | lw t1, 0(t0) |
---|
771 | |
---|
772 | /* |
---|
773 | ** Enable Mongoose V EDAC |
---|
774 | */ |
---|
775 | la t0, MG5_COMMAND_REG |
---|
776 | li t1, EDAC_ENABLE_BIT |
---|
777 | sw t1, 0(t0) |
---|
778 | nop |
---|
779 | |
---|
780 | /* |
---|
781 | ** Program Watchdog to 10 seconds - If PMON will |
---|
782 | ** run, it will be set to MAX later. |
---|
783 | */ |
---|
784 | la t0, 0xBE000000 |
---|
785 | li t1, 0xA0 |
---|
786 | sw t1, 0(t0) |
---|
787 | |
---|
788 | 3: nop |
---|
789 | |
---|
790 | j ra |
---|
791 | .end _cpuinit |
---|
792 | |
---|
793 | |
---|
794 | |
---|
795 | |
---|
796 | |
---|
797 | |
---|
798 | |
---|
799 | |
---|
800 | |
---|
801 | /********************************************************************** |
---|
802 | ** |
---|
803 | ** Keep the boot-time address of the I & D cache reset code for |
---|
804 | ** later on. If we need to clear the I/D caches, we <must> run from |
---|
805 | ** non-cached memory. This means the relocated versions are useless, |
---|
806 | ** thankfully they are quite small. |
---|
807 | */ |
---|
808 | |
---|
809 | _promIcache: .word 0 |
---|
810 | _promDcache: .word 0 |
---|
811 | |
---|
812 | |
---|
813 | |
---|
814 | .globl promCopyIcacheFlush |
---|
815 | .ent promCopyIcacheFlush |
---|
816 | .set noreorder |
---|
817 | promCopyIcacheFlush: |
---|
818 | move a0,ra |
---|
819 | |
---|
820 | la t1,_promIcache |
---|
821 | lw t0,0(t1) |
---|
822 | nop |
---|
823 | beqz t0,1f |
---|
824 | |
---|
825 | jal t0 |
---|
826 | nop |
---|
827 | |
---|
828 | 1: j a0 |
---|
829 | nop |
---|
830 | .set reorder |
---|
831 | .end promCopyIcacheFlush |
---|
832 | |
---|
833 | |
---|
834 | |
---|
835 | .globl promCopyDcacheFlush |
---|
836 | .ent promCopyDcacheFlush |
---|
837 | .set noreorder |
---|
838 | promCopyDcacheFlush: |
---|
839 | move a0,ra |
---|
840 | |
---|
841 | la t1,_promDcache |
---|
842 | lw t0,0(t1) |
---|
843 | nop |
---|
844 | beqz t0,1f |
---|
845 | |
---|
846 | jal t0 |
---|
847 | nop |
---|
848 | |
---|
849 | 1: j a0 |
---|
850 | nop |
---|
851 | .set reorder |
---|
852 | .end promCopyDcacheFlush |
---|
853 | |
---|
854 | |
---|
855 | |
---|
856 | |
---|
857 | |
---|
858 | /******************************************************************************* |
---|
859 | ** Function Name: IcacheFlush |
---|
860 | ** Description: This functions flushes the on chip icache. |
---|
861 | */ |
---|
862 | |
---|
863 | .ent IcacheFlush |
---|
864 | .set noreorder |
---|
865 | IcacheFlush: |
---|
866 | |
---|
867 | 1: |
---|
868 | # Assume I cache is already enabled in BIU/Cache setup |
---|
869 | # Get contents of M_BIU register and save in t1 |
---|
870 | li t0, M_BIU |
---|
871 | lw t1, 0(t0) |
---|
872 | |
---|
873 | # Isolate I cache |
---|
874 | mfc0 t3, C0_SR /* Read Status Register */ |
---|
875 | nop |
---|
876 | or t0, t3, SR_ISC /* Isolate Cache so we don't propagate operations */ |
---|
877 | mtc0 t0, C0_SR /* Write it back to Status Register */ |
---|
878 | nop |
---|
879 | |
---|
880 | # Setup for cache flush |
---|
881 | li t8, 0 /* Store zero */ |
---|
882 | li t9, LR33300_IC_SIZE |
---|
883 | |
---|
884 | icache_write: |
---|
885 | sw zero, 0(t8) /* Store zero to memory addres in t8 */ |
---|
886 | addu t8, 4 /* Increment t8 address by 4 */ |
---|
887 | bltu t8, t9, icache_write /* check to see if we are done */ |
---|
888 | nop |
---|
889 | |
---|
890 | |
---|
891 | # De-isolate I cache |
---|
892 | mtc0 t3, C0_SR /* Load unchanged t3 to Status Register */ |
---|
893 | nop |
---|
894 | |
---|
895 | jal ra |
---|
896 | nop |
---|
897 | .set reorder |
---|
898 | .end IcacheFlush |
---|
899 | |
---|
900 | |
---|
901 | /******************************************************** |
---|
902 | ** Function Name: DcacheFlush |
---|
903 | ** Description: This functions flushes the on chip dcache. |
---|
904 | */ |
---|
905 | |
---|
906 | |
---|
907 | .ent DcacheFlush |
---|
908 | .set noreorder |
---|
909 | DcacheFlush: |
---|
910 | |
---|
911 | # isolate icache |
---|
912 | mfc0 t3,C0_SR |
---|
913 | nop |
---|
914 | or t0, t3, SR_ISC |
---|
915 | mtc0 t0, C0_SR |
---|
916 | nop |
---|
917 | |
---|
918 | # Setup up for cache flush |
---|
919 | li t8, 0 |
---|
920 | li t9, LR33300_DC_SIZE |
---|
921 | |
---|
922 | dcache_write: |
---|
923 | sw zero, 0(t8) |
---|
924 | addu t8, 4 |
---|
925 | bltu t8, t9, dcache_write /* check to see if we are done */ |
---|
926 | nop |
---|
927 | |
---|
928 | # De-isolate cache |
---|
929 | mtc0 t3, C0_SR |
---|
930 | nop |
---|
931 | |
---|
932 | jal ra |
---|
933 | nop |
---|
934 | .set reorder |
---|
935 | .end DcacheFlush |
---|
936 | |
---|
937 | |
---|
938 | /* EOF start.S */ |
---|