source: svn/newcon3bcm2_21bu/rockford/bsp/bcm97552/no-os/src/sde/reset.s

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 19.1 KB
Line 
1#ifndef __ASSEMBLER__
2#define __ASSEMBLER__
3#endif
4#include "bmips.h"
5#include "bmips3300.h"
6#include "mips_config.h"
7
8#include "bchp_common.h"
9#include "bchp_sca.h"
10#include "bchp_scb.h"
11#include "bchp_sun_top_ctrl.h"
12#include "bchp_bsp_glb_control.h"
13#include "bchp_nand.h"
14#include "bchp_timer.h"
15#include "bchp_clkgen.h"
16
17#ifndef MIPS_CFE
18#include "bcmtimer.h"
19#include "board.h"
20#endif
21
22#ifndef MIPS_HALT_FOR_BBS
23#define MIPS_HALT_FOR_BBS 0
24#endif
25
26#ifndef NEW_BOOT_DEBUG_LEVEL
27#define NEW_BOOT_DEBUG_LEVEL 0
28#endif
29
30#if QUICK_BOOT == 1
31//#error "Quick boot enabled"
32#endif
33
34#define LINUX_ENTRY 0x80001400
35
36
37#define INITIAL_SR      ((/*CP0_STATUS_SR_MASK |*/ CP0_STATUS_CU1_MASK | CP0_STATUS_BEV_MASK | CP0_STATUS_IE_MASK) & ~( CP0_STATUS_ERL_MASK | CP0_STATUS_EXL_MASK))       
38
39#ifndef DEBUG_RESET
40#define DEBUG_RESET
41#endif
42
43#ifndef COMPARE_CODE
44#define COMPARE_CODE
45#endif
46
47
48#ifndef BSECK_DEVICE
49#define BSECK_DEVICE
50#endif
51
52               
53.globl  rom_init                /* branch to start of system code    */
54.globl  rom_reboot               /* direct entry to reboot            */
55
56
57.globl  rom_start                /* system initialization routine     */
58
59
60#define RVECENT(f,n) \
61        b f; nop
62#define XVECENT(f,bev) \
63        b f; li k0,bev
64       
65#define SET_TRACE(trace_val)    \
66li              t0, trace_val;  \
67li              t1, PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_SUN_TOP_CTRL_UNCLEARED_SCRATCH); \
68sw              t0, 0(t1);
69
70
71
72.text
73.align  4
74.globl  __start
75__start:
76rom_init:
77_romInit:
78romInit:
79
80.set    noreorder
81#if NAND_MEM_TYPE == 1 || NAND_MEM_TYPE == 2 /* required for some MLC and SLC NAND parts where the NAND CONFIG needs to be set right away */
82
83        /* set pg size, blk size and device size */
84       
85        li              a0, PHYS_TO_K1(BCHP_PHYSICAL_OFFSET + BCHP_NAND_CONFIG )
86        lw              a1, 0(a0)
87       
88        li              a2, ~(BCHP_NAND_CONFIG_PAGE_SIZE_MASK | BCHP_NAND_CONFIG_BLOCK_SIZE_MASK | BCHP_NAND_CONFIG_DEVICE_SIZE_MASK)
89        and             a1, a1, a2
90       
91#if NAND_PAGE_SIZE == 4*1024
92        li              a2, (BCHP_NAND_CONFIG_PAGE_SIZE_PG_SIZE_4KB<<BCHP_NAND_CONFIG_PAGE_SIZE_SHIFT)
93#elif NAND_PAGE_SIZE == 2*1024         
94        li              a2, (BCHP_NAND_CONFIG_PAGE_SIZE_PG_SIZE_2KB<<BCHP_NAND_CONFIG_PAGE_SIZE_SHIFT)
95#elif   NAND_PAGE_SIZE == 512           
96        li              a2, (BCHP_NAND_CONFIG_PAGE_SIZE_PG_SIZE_512<<BCHP_NAND_CONFIG_PAGE_SIZE_SHIFT)
97#else
98#error "!!NAND page size not supported"
99#endif
100
101        or              a1, a1, a2     
102
103#if NAND_BLOCK_SIZE == 512*1024
104        li              a2, (BCHP_NAND_CONFIG_BLOCK_SIZE_BK_SIZE_512KB<<BCHP_NAND_CONFIG_BLOCK_SIZE_SHIFT)
105#elif NAND_BLOCK_SIZE == 256*1024
106#ifndef BCHP_REV_A0 /* for A0, 256KB block size is not defined */
107        li              a2, (BCHP_NAND_CONFIG_BLOCK_SIZE_BK_SIZE_256KB<<BCHP_NAND_CONFIG_BLOCK_SIZE_SHIFT)
108#endif
109#elif NAND_BLOCK_SIZE == 128*1024
110        li              a2, (BCHP_NAND_CONFIG_BLOCK_SIZE_BK_SIZE_128KB<<BCHP_NAND_CONFIG_BLOCK_SIZE_SHIFT)
111#elif NAND_BLOCK_SIZE == 16*1024
112        li              a2, (BCHP_NAND_CONFIG_BLOCK_SIZE_BK_SIZE_16KB<<BCHP_NAND_CONFIG_BLOCK_SIZE_SHIFT)
113#elif NAND_BLOCK_SIZE == 8*1024
114        li              a2, (BCHP_NAND_CONFIG_BLOCK_SIZE_BK_SIZE_8KB<<BCHP_NAND_CONFIG_BLOCK_SIZE_SHIFT)
115#else
116#error "!!NAND block size not supported"
117#endif
118
119        or              a1, a1, a2
120
121#if NAND_DEV_SIZE == 0xA
122        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_4GB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
123#elif NAND_DEV_SIZE == 9
124        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_2GB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
125#elif NAND_DEV_SIZE == 8
126        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_1GB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
127#elif NAND_DEV_SIZE == 7
128        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_512MB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
129#elif NAND_DEV_SIZE == 6
130        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_256MB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
131#elif NAND_DEV_SIZE == 5
132        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_128MB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
133#elif NAND_DEV_SIZE == 4
134        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_64MB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
135#elif NAND_DEV_SIZE == 3
136        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_32MB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
137#elif NAND_DEV_SIZE == 2
138        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_16MB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
139#elif NAND_DEV_SIZE == 1
140        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_8MB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
141#elif NAND_DEV_SIZE == 0
142        li              a2, (BCHP_NAND_CONFIG_DEVICE_SIZE_DVC_SIZE_4MB<<BCHP_NAND_CONFIG_DEVICE_SIZE_SHIFT)
143#else
144#error "NAND device size not supported"
145#endif
146
147        or              a1, a1, a2
148       
149        sw              a1, 0(a0)
150        nop
151#endif
152
153
154
155        RVECENT(__rom_init,0)            /* PROM entry point */
156romWarmInit:
157_romWarmInit:
158        RVECENT(rom_reboot,1)            /* software reboot */
159
160.align 9 /* align to 0x200 */
161
162        XVECENT(romExcHandle,0x200)     /* bfc00200: R4000 tlbmiss vector */
163        RVECENT(romReserved,65)
164        RVECENT(romReserved,66)
165        RVECENT(romReserved,67)
166        RVECENT(romReserved,68)
167        RVECENT(romReserved,69)
168        RVECENT(romReserved,70)
169        RVECENT(romReserved,71)
170        RVECENT(romReserved,72)
171        RVECENT(romReserved,73)
172        RVECENT(romReserved,74)
173        RVECENT(romReserved,75)
174        RVECENT(romReserved,76)
175        RVECENT(romReserved,77)
176        RVECENT(romReserved,78)
177        RVECENT(romReserved,79) 
178        XVECENT(romExcHandle,0x280)     /* bfc00280: R4000 xtlbmiss vector */
179        RVECENT(romReserved,81)
180        RVECENT(romReserved,82)
181        RVECENT(romReserved,83)
182        RVECENT(romReserved,84)
183        RVECENT(romReserved,85)
184        RVECENT(romReserved,86)
185        RVECENT(romReserved,87)
186        RVECENT(romReserved,88)
187        RVECENT(romReserved,89)
188        RVECENT(romReserved,90)
189        RVECENT(romReserved,91)
190        RVECENT(romReserved,92)
191        RVECENT(romReserved,93)
192        RVECENT(romReserved,94)
193        RVECENT(romReserved,95) 
194        XVECENT(romExcHandle,0x300)     /* bfc00300: R4000 cache vector */
195        RVECENT(romReserved,97)
196        RVECENT(romReserved,98)
197        RVECENT(romReserved,99)
198        RVECENT(romReserved,100)
199        RVECENT(romReserved,101)
200        RVECENT(romReserved,102)
201        RVECENT(romReserved,103)
202        RVECENT(romReserved,104)
203        RVECENT(romReserved,105)
204        RVECENT(romReserved,106)
205        RVECENT(romReserved,107)
206        RVECENT(romReserved,108)
207        RVECENT(romReserved,109)
208        RVECENT(romReserved,110)
209        RVECENT(romReserved,111)
210        XVECENT(romExcHandle,0x380)     /* bfc00380: R4000 general vector */
211        RVECENT(romReserved,113)
212        RVECENT(romReserved,114)
213        RVECENT(romReserved,115)
214        RVECENT(romReserved,116)
215        RVECENT(romReserved,116)
216        RVECENT(romReserved,118)
217        RVECENT(romReserved,119)
218        RVECENT(romReserved,120)
219        RVECENT(romReserved,121)
220        RVECENT(romReserved,122)
221        RVECENT(romReserved,123)
222        RVECENT(romReserved,124)
223        RVECENT(romReserved,125)
224        RVECENT(romReserved,126)
225        RVECENT(romReserved,127)
226
227#ifdef BSECK_DEVICE /* BSP /BSECK needs 2144(0x860) bytes to store relocatable pointer. */
228.word 0x00006780
229.fill 0x23c
230.word 0x000000FF
231.fill 0x63c
232#endif
233
234.align 4
235
236
237/*******************************************************************************
238*
239* rom_init - entry point in ROM
240*
241* rom_init
242*     (
243*     int startType  /@ only used by 2nd entry point @/
244*     )
245*/
246
247__rom_init:
248
249        .set    noreorder
250
251                SET_TRACE(1)
252               
253                /* nmi check code */
254                mfc0    k0, CP0_STATUS  /* Read CP0 Status              */
255                nop
256                nop
257                       
258                li      k1,     0x00080000              /* Bit 19 - NMI Status          */
259                and     k0, k0, k1              /* Is reset cause by NMI ?      */
260                beqz     k0,    1f                /* code in ROM/flash */       
261                nop
262       
263                /* nmi handler */
264                mfc0    k0, CP0_STATUS  /* Read CP0 Status again since it was changed */
265                nop
266                nop
267       
268                li              k1, ~0x00080000 /* (SR_CU0|SR_CU1|SR_BEV|SR_ERL) */
269                and             k0, k0, k1
270                mtc0    k0, CP0_STATUS
271                nop
272                nop
273                li              k0,0x00000001
274                li              k1,PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_SCA_SC_IF_CMD_1)
275                sw              k0,0(k1)
276                li              k1,PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_SCB_SC_IF_CMD_1)
277                sw              k0,0(k1)
278                eret
279                nop
280
2811:
282                SET_TRACE(2)
283               
284            li          t0, INITIAL_SR
285                mtc0    t0, CP0_STATUS
286                nop
287                nop
288       
289        mtc0    zero, CP0_CAUSE           # clear software interrupts
290        nop
291        nop
292       
293        /* set NMI status bit in BSP to allow NMI */
294                li              t0, PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_BSP_GLB_CONTROL_MIPS_NMI_STATUS)
295                lw              t1, 0(t0)
296                or              t1, t1, BCHP_BSP_GLB_CONTROL_MIPS_NMI_STATUS_NMI_STATUS_MASK
297                sw              t1, 0(t0)
298               
299
300                SET_TRACE(3)
301         /* initialize serial port */
302       
303        bal             init_serial
304        nop
305             
306        SET_TRACE(4)
307        /* print Chip number etc */
308       
309        bal             print_chip_details
310        nop                   
311       
3121:         
313        /* check code in cached or uncahced space*/
314        bal             set_ra          /* first get the current program counter */
315        nop
316       
317        move    t0, ra
318       
319        /* use s3 to store code loacation, cached/uncached
320         * if s3 = 0 we are ruuning from 0xbfc0_xxxx space,
321         * else we are booting from 0x9fc0_xxxx space
322         */
323         
324        li              s3 , 0
325       
326        li      t1,     0x20000000 
327                and     t1, t1, t0
328                bne     $0, t1, 1f      #code in 0xbfc0_xxxx space
329                nop
330       
331                li              s3, 1   # code in 9fc0_xxxx             
332               
3331:
334
335
336#ifdef DEBUG_RESET
337                li              a0, '1'
338                bal             _writeasm
339                nop
340               
341                li              a0, ' '
342                bal             _writeasm
343                nop
344               
345                move    a0, s3
346                bal             uartout_hex32
347                nop
348               
349                li              a0, '\r'
350                bal             _writeasm
351                nop
352               
353                li              a0, '\n'
354                bal             _writeasm
355                nop
356#endif         
357               
358        /* do chip specific init */
359       
360        bal             do_chip_init
361        nop
362       
363
364#ifdef DEBUG_RESET
365        li              a0, '2'
366                bal             _writeasm
367                nop
368#endif         
369               
3702:       
371        /* do board specific init, if any */
372             
373        bal             do_board_init
374        nop
375
376#ifdef DEBUG_RESET       
377        li              a0, '3'
378                bal             _writeasm
379                nop
380#endif
381               
382        /* check code in cached or uncached space */
383                bnez    s3, code_cached
384                nop
385
386                /* we are running from uncached space. initialize mips and cache*/
387                bal             init_mips
388                nop
389               
390code_cached:           
391               
392#ifdef DEBUG_RESET       
393        li              a0, '4'
394                bal             _writeasm
395                nop
396#endif
397
398/**************************************************/
399
400        li              a0, '\n'
401                bal             _writeasm
402                nop
403        li              a0, '\r'
404                bal             _writeasm
405                nop
406        li              a0, 'M'
407                bal             _writeasm
408                nop
409        li              a0, '0'
410                bal             _writeasm
411                nop
412
413                bal             memc_0_ddr_init
414                nop
415
416
417                bal             run_shmoo
418                nop
419
420                               
421#ifdef DEBUG_RESET       
422                li              a0, '5'
423                bal             _writeasm
424                nop
425#endif
426
427#ifdef SDRAM_SCRAMBLING
428                bal             scramble_sdram
429                nop
430#endif
431
432                                /* if we are running from uncached space we do not need to call
433                 * hide_mips_boot_rom
434                 */             
435                beqz    s3, pre_cache_new_boot
436                nop
437                               
438                bal             hide_mips_boot_rom
439                nop
440               
441                li              a0, 'b'
442                bal             _writeasm
443                nop
444
445                b               call_new_boot
446                nop
447
448pre_cache_new_boot:
449                bal             size_i_cache
450                nop
451
452                /* now v1 has the icache line size */
453                /* copy the boot code to i cache and then jump to i-cache */
454               
455                la              a0, new_boot_start
456                li              a1, ~0x20000000         /* convert the address to k0seg */
457                and             a0, a0, a1
458                move    v0, v1
459                addi    v1, v1, -1
460                not             v1
461                and             a0, a0, v1              /* align it to icache line size */
462               
463                la              t0, new_boot_end
464                and             t0, t0, a1              /* convert the address to k0seg */
465                and             t0, t0, v1              /* align it to icache line size */
466                addu    t0, t0, v0             
467       
4681:     
469                cache   Fill_I, 0(a0)
470                add             a0, a0, v0
471                bne             a0, t0, 1b
472                nop
473
474call_new_boot:         
475#ifdef DEBUG_RESET
476                li              a0, '6'
477                bal             _writeasm
478                nop
479#endif         
480
481                bal             get_boot_mode
482                nop
483               
484                li      a0, (SSBL_TEXT_ADDR) /* source address */
485                li              a1, (SSBL_SIZE)      /* size */
486                move    a2, v0               /* boot from SPI/NOR/NAND */
487                li              a3, NAND_BAD_BLOCK_INDICATOR_MAP
488
489                /* set stack */
490                la              sp, STACK_ADRS
491
492                # created a 12 byte stack for do_new_boot arguments
493                addiu   sp, sp, -12
494               
495                la              t0, do_new_boot         
496                jalr    t0
497                nop
498       
499                b               code_in_ram
500                nop
501               
502               
503rom_reboot:       
504                li              t0, INITIAL_SR /* (SR_CU0|SR_CU1|SR_BEV|SR_ERL) */
505                mtc0            t0, CP0_STATUS
506                nop
507                nop
508                mtc0            zero, CP0_CAUSE           # clear software interrupts
509                nop
510                nop             
511       
512#ifndef MIPS_CFE       
513                bal             init_timers
514                nop
515#endif
516
517
518code_in_ram:
519
520#ifdef DEBUG_RESET
521                li              a0, '7'
522                bal             _writeasm
523                nop
524#endif
525#if defined(AEGIS_UNITTEST) && defined(MEM_AUTH)
526                bal             aegis_arch_r2_setup
527                nop
528#endif /* AEGIS_UNITTEST && MEM_AUTH */
529
530                li              a0, PHYS_TO_K1(SSBL_RAM_ADDR)
531                jr              a0
532                nop
533               
534               
535                /* main should not return, but just in case */
536               
537                li              ra, R_VEC               
538                j               ra                             
539                nop
540                nop
541
542
543
544               
545/******************************************************************************
546 * Function: scb_clk_change
547 * Description:
548 * Trashes:             
549 *
550 *      pseudo code:
551 *     
552 ******************************************************************************/
553LEAF(scb_clk_change)
554        // Set SCB clock to 216 MHz
555        //CLKGEN_PLL_SYS0_PLL_CHANNEL_CTRL_CH_3/MDIV_CH3 = 18 (3888 / 14 = 277.71MHz)
556        li      t0, PHYS_TO_K1(BCHP_PHYSICAL_OFFSET+BCHP_CLKGEN_PLL_SYS0_PLL_CHANNEL_CTRL_CH_3)
557        lw      t1, 0(t0)
558        li      v0, ~BCHP_CLKGEN_PLL_SYS0_PLL_CHANNEL_CTRL_CH_3_MDIV_CH3_MASK
559        and t1, t1, v0
560        li      v0, (18 << BCHP_CLKGEN_PLL_SYS0_PLL_CHANNEL_CTRL_CH_3_MDIV_CH3_SHIFT)
561        or      t1, t1, v0
562        sw      t1, 0(t0)
563
564        //CLKGEN_PLL_SYS0_PLL_CHANNEL_CTRL_CH_3/POST_DIVIDER_LOAD_EN_CH3 = 1
565        //CLKGEN_PLL_SYS0_PLL_CHANNEL_CTRL_CH_3/POST_DIVIDER_LOAD_EN_CH3 = 0 (toggle 0 -> 1 -> 0)
566        li      v0, (1 << BCHP_CLKGEN_PLL_SYS0_PLL_CHANNEL_CTRL_CH_3_POST_DIVIDER_LOAD_EN_CH3_SHIFT)
567        or      t1, t1, v0
568        sw      t1, 0(t0)
569        li      v0, ~BCHP_CLKGEN_PLL_SYS0_PLL_CHANNEL_CTRL_CH_3_POST_DIVIDER_LOAD_EN_CH3_MASK
570        and     t1, t1, v0
571        sw      t1, 0(t0)
572               
573        jr              ra
574        nop
575
576
577END(scb_clk_change)             
578               
579               
580#if 0
581/******************************************************************************
582 * Function: compare_code
583 * Arguments: a0: src 1 address, a1: src 2 address, a2: size in bytes. 
584 * Returns:     v0, v0=0 if compare passes.
585 * Description:
586 * Trashes:             
587 *
588 *      pseudo code:
589 *     
590 ******************************************************************************/
591LEAF(compare_code)
592
5931:     
594        lw              t0, 0(a0)       
595        addiu   a0, a0, 4
596       
597        lw              t1, 0(a1)
598        addiu   a1, a1, 4
599       
600        bne             t0, t1, 2f
601        addiu   a2, a2, -4
602       
603        bnez    a2, 1b
604        nop
605       
606       
6072:
608       
609        subu    v0, t0, t1
610       
611        jr              ra
612        nop
613
614
615END(compare_code)               
616#endif         
617               
618/******************************************************************************
619 * Function: set_ra
620 * Arguments:   None
621 * Returns:             
622 * Description:
623 * Trashes:             
624 *
625 *      pseudo code:
626 *     
627 ******************************************************************************/
628LEAF(set_ra)
629
630                jr              ra
631                nop
632               
633END(set_ra)
634
635/******************************************************************************
636 * Function: romReserved
637 * Arguments:   None
638 * Returns:             
639 * Description:
640 * Trashes:             
641 *
642 *      pseudo code:
643 *     
644 ******************************************************************************/
645LEAF(romReserved)
646       
647                b       romInit        /* just start over */
648                nop
649       
650END(romReserved)
651
652
653
654
655/******************************************************************************
656 * Function: romExcHandle
657 * Arguments:   None
658 * Returns:             
659 * Description:
660 * Trashes:             
661 *
662 *      pseudo code:
663 *     
664 ******************************************************************************/
665
666LEAF(romExcHandle)
667
668
669hangExc:
670        b       hangExc                 /* HANG UNTIL REBOOT    */
671        nop
672
673END(romExcHandle)
674
675
676#ifdef SHMOO_TEST
677/******************************************************************************
678 * Function: sleep
679 * Arguments: sleep time in a0
680 * 
681 *      Description:
682 *
683 *      pseudo code:
684 *     
685 ******************************************************************************/
686LEAF(sleep)
687
688        li              t0, REG_ADDR(BCHP_TIMER_TIMER0_CTRL)
689        lw              t1, 0(t0)
690       
691        /* TIMER_TIMER0_CTRL.MODE  = 1 => count down mode */
692        li              t2, BCHP_TIMER_TIMER0_CTRL_MODE_MASK
693        or              t1, t1, t2
694
695        /* TIMER_TIMER0_CTRL.TIMEOUT_VAL = a0 */
696
697        li              t2, BCHP_TIMER_TIMER0_CTRL_TIMEOUT_VAL_MASK
698        li              t3, BCHP_TIMER_TIMER0_CTRL_TIMEOUT_VAL_SHIFT
699       
700        not             t2, t2
701        and             t1, t1, t2
702        sll             a0, a0, t3
703        or              t1, t1, a0
704
705        sw              t1, 0(t0)
706       
707        li              t0, REG_ADDR(BCHP_TIMER_TIMER_IS)
708        lw              t1, 0(t0)
709
710        /* TIMER_TIMER_IS.TMR0TO = 1 => clears this bit, resets time count */
711
712        li              t2, ~BCHP_TIMER_TIMER_IS_TMR0TO_MASK
713        and             t1, t1, t2
714        sw              t1, 0(t0)
715
716        /* TIMER_TIMER0_CTRL.ENA = 1 => start counting */
717       
718        li              t0, REG_ADDR(BCHP_TIMER_TIMER0_CTRL)
719        lw              t1, 0(t0)
720
721        li              t2, BCHP_TIMER_TIMER0_CTRL_ENA_MASK
722        or              t1, t1, t2
723        sw              t1, 0(t0)
724               
725        li              t0, REG_ADDR(BCHP_TIMER_TIMER_IS)
726        li              t2, BCHP_TIMER_TIMER_IS_TMR0TO_MASK
727       
7281:      lw              t1, 0(t0)
729        and             t1, t1, t2
730        beq             zero, t1, 1b
731        nop
732       
733        /* TIMER_TIMER0_CTRL.ENA = 0 => stop counting */
734
735        li              t0, REG_ADDR(BCHP_TIMER_TIMER0_CTRL)
736        lw              t1, 0(t0)
737        li              t2, ~BCHP_TIMER_TIMER0_CTRL_ENA_MASK
738        and             t1, t1, t2
739        sw              t1, 0(t0)
740
741       
742        jr              ra
743        nop
744
745END     (sleep)
746#endif
747
748#ifndef MIPS_CFE
749/******************************************************************************
750 * Function: init_timers
751 * Arguments:   None
752 * Returns:             
753 * Description:
754 * Trashes:             
755 *
756 *      pseudo code:
757 *     
758 ******************************************************************************/
759LEAF(init_timers)
760
761        .set    noreorder
762                li              t0, TIMR_ADR_BASE
763                sw              zero, TIMER_TIMER0_CTRL(t0)   /* disable timer 0 */
764                sw              zero, TIMER_TIMER1_CTRL(t0)   /* disable timer 1 */
765                sw              zero, TIMER_TIMER2_CTRL(t0)   /* disable timer 2 */
766                sw              zero, TIMER_TIMER3_CTRL(t0)   /* disable timer 3 */
767                sw              zero, TIMER_TIMER_IE0(t0)     /* disable timer interrupts */
768                li              v0, 0x0f
769                sw              v0, TIMER_TIMER_IS(t0)        /* reset/clear timer */
770                jr       ra
771        .set    reorder
772                nop
773       
774END(init_timers)
775/******************************************************************************
776 * Function: InstallVector
777 * Arguments: unsigned long offset,unsigned long isr_addr
778 * Returns:     None   
779 * Description:
780 * Trashes:             
781 *
782 *      pseudo code:
783 *     
784 ******************************************************************************/
785LEAF(InstallVector)
786
787        .set   noreorder
788                lui     t1,0x3c1a               # opcode for lui $k0,IMM
789                lui     t2,0x375a                       # opcode for ori $k0,$k0,IMM
790                li      t3,0x03400008           # opcode for jr $k0
791                ori     v0,zero,16              # extract upper half
792                srlv    v0,a1,v0                # of ISR_ADDR
793                or      v0,t1,v0                # create opcode
794                ori     v1,zero,0xffff          # extract lower half
795                and     v1,a1,v1                # of ISR_ADDR
796                or      v1,v1,t2                # create opcode
797                li      t0,K1_BASE               # store to SDRAM K1 segment
798                addu    t0,t0,a0                # add offset to vector table base
799                sw      v0,0(t0)                # store: lui $k0,IMM
800                sw      v1,4(t0)                # store: ori $k0,$k0,IMM
801                sw      t3,8(t0)                # store: jr $k0
802                sw      zero,0xc(t0)            # store: nop
803                jr      ra
804                nop
805        .set  reorder
806END(InstallVector)
807
808
809/******************************************************************************
810 * Function: sbrk
811 * Arguments: size
812 * Returns:     None   
813 * Description: returns a pointer to a block of memory of the requested size.
814 *       Returns zero if heap overflow is detected. Heap overflow occurs
815 *       when the upper limit of the requested size, overlaps the stack
816*       pointer.
817 * Trashes:             
818 *
819 *      pseudo code:
820 *     
821 ******************************************************************************/
822LEAF(sbrk)
823
824        .set noreorder
825        .set at
826                li      v0,0
827                la      t0,allocp1
828                lw      t6,(t0)
829                li      t1, DRAM_BASE_CACHE + DRAM_SIZE
830                addu    t7,t6,a0
831                blt     t7,t1,1f
832                nop
833                j       ra
834                nop
8351:             sw      t7,(t0)
836                move    v0,t6
837                j       ra
838                nop
839        .set noat
840        .set reorder
841END(sbrk)
842
843
844        .data
845        .globl allocp1
846        .word _ftext
847        .word etext
848allocp1: .word  end
849#endif
850
851
Note: See TracBrowser for help on using the repository browser.