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

4.104.114.84.95
Last change on this file since 9d64bc73 was 9d64bc73, checked in by Joel Sherrill <joel.sherrill@…>, on 03/08/02 at 17:35:39

2001-03-08 Joel Sherrill <joel@…>

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