source: rtems/c/src/lib/libbsp/mips/genmongoosev/start/start.S @ cba119c9

4.104.114.84.95
Last change on this file since cba119c9 was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/21/04 at 16:01:48

Remove duplicate white lines.

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