Add support store ddr param in flash.
[xloong.git] / zloader / startram.S
blobea82992a5cbd454ff94d28b061ec0d017e307a10
1 #ifndef _KERNEL
2 #define _KERNEL
3 #endif
6 #define zero    $0      /* always zero */
7 #define AT      $at     /* assembler temp */
8 #define v0      $2      /* return value */
9 #define v1      $3
10 #define a0      $4      /* argument registers */
11 #define a1      $5
12 #define a2      $6
13 #define a3      $7
14 #define t0      $8      /* temp registers (not saved across subroutine calls) */
15 #define t1      $9
16 #define t2      $10
17 #define t3      $11
18 #define t4      $12
19 #define t5      $13
20 #define t6      $14
21 #define t7      $15
22 #define s0      $16     /* saved across subroutine calls (callee saved) */
23 #define s1      $17
24 #define s2      $18
25 #define s3      $19
26 #define s4      $20
27 #define s5      $21
28 #define s6      $22
29 #define s7      $23
30 #define t8      $24     /* two more temp registers */
31 #define t9      $25
32 #define k0      $26     /* kernel temporary */
33 #define k1      $27
34 #define gp      $28     /* global pointer */
35 #define sp      $29     /* stack pointer */
36 #define s8      $30     /* one more callee saved */
37 #define ra      $31     /* return address */
41  * Coprocessor 0 registers:
42  */
43 #define COP_0_TLB_INDEX         $0
44 #define COP_0_TLB_RANDOM        $1
45 #define COP_0_TLB_LO0           $2
46 #define COP_0_TLB_LO1           $3
47 #define COP_0_TLB_CONTEXT       $4
48 #define COP_0_TLB_PG_MASK       $5
49 #define COP_0_TLB_WIRED         $6
50 #define COP_0_BAD_VADDR         $8
51 #define COP_0_COUNT             $9
52 #define COP_0_TLB_HI            $10
53 #define COP_0_COMPARE           $11
54 #define COP_0_STATUS_REG        $12
55 #define COP_0_CAUSE_REG         $13
56 #define COP_0_EXC_PC            $14
57 #define COP_0_PRID              $15
58 #define COP_0_CONFIG            $16
59 #define COP_0_LLADDR            $17
60 #define COP_0_WATCH_LO          $18
61 #define COP_0_WATCH_HI          $19
62 #define COP_0_TLB_XCONTEXT      $20
63 #define COP_0_ECC               $26
64 #define COP_0_CACHE_ERR         $27
65 #define COP_0_TAG_LO            $28
66 #define COP_0_TAG_HI            $29
67 #define COP_0_ERROR_PC          $30
68 /* RM7000 specific */
69 #define COP_0_WATCH_1           $18
70 #define COP_0_WATCH_2           $19
71 #define COP_0_WATCH_M           $24
72 #define COP_0_PC_COUNT          $25
73 #define COP_0_PC_CTRL           $22
75 #define COP_0_ICR               $20             /* CFC */
76 #define COP_0_DERR_0            $26             /* CFC */
77 #define COP_0_DERR_1            $27             /* CFC */
78 #define SR_BOOT_EXC_VEC         0x00400000
79 //---------------------------------------------------
81 #define CONFIG_CACHE_64K_4WAY 1
83 #define tmpsize         s1
84 #define msize           s2
85 #define sdShape         s3
86 #define bonito          s4
87 #define dbg             s5
88 #define sdCfg           s6
90 #define CFG_IB 0x00000020
91 #define CFG_DB 0x00000010
92 #define CFG_C_WBACK 3
93 #define CFG_BE 0x00008000
94 #define CFG_EPMASK 0x0f000000
95 #define CFG_EPD 0x00000000
96 #define CFG_EM_R4K 0x00000000
97 #define CFG_EMMASK 0x00c00000
98 #define CFG_AD 0x00800000
100 #define CP0_CONFIG $16
101 #define CP0_TAGLO  $28
102 #define CP0_TAGHI  $29
104 #define DDR100 0x04041091
105 #define DDR266 0x0410435e
106 #define DDR300 0x041453df
110  *   Register usage:
112  *      s0      link versus load offset, used to relocate absolute adresses.
113  *      s1      free
114  *      s2      memory size.
115  *      s3      sdShape.
116  *      s4      Bonito base address.
117  *      s5      dbg.
118  *      s6      sdCfg.
119  *      s7      rasave.
120  *      s8      L3 Cache size.
121  */
123         .set    noreorder
124         .globl  _start
125         .globl  start
126         .globl  __main
127 _start:
128 start:
129         .globl  stack
130 stack = start - 0x4000          /* Place PMON stack below PMON start in RAM */
131         mtc0    zero, COP_0_STATUS_REG
132         mtc0    zero, COP_0_CAUSE_REG
133         li      t0, SR_BOOT_EXC_VEC     /* Exception to Boostrap Location */
134         mtc0    t0, COP_0_STATUS_REG
135         la      sp, stack
136         la      gp, _gp
137         move s1,a3 //struct callvectors *cv
139         bal     locate                  /* Get current execute address */
140         nop
143  *  We get here from executing a bal to get the PC value of the current execute
144  *  location into ra. Check to see if we run from ROM or if this is ramloaded.
145  */
146 locate:
147         la      s0,start
148         subu    s0,ra,s0
149         and     s0,0xffff0000
151 #if 1 //ʹÄÜcache
152         mfc0   a0,COP_0_CONFIG
153         and    a0,a0,0xfffffff8
154         or     a0,a0,0x3
155         mtc0   a0,COP_0_CONFIG
156 #endif
158         /* Clear BSS */
159         la      a0, _edata
160         la      a2, _end
161 2:      sw      zero, 0(a0)
162         bne     a2, a0, 2b
163         addu    a0, 4
165         li      a0, 0
166         sw      a0, CpuTertiaryCacheSize /* Set L3 cache size */
167         li  a0,MEMSIZE
168         move a1,s1
170         la      v0, initmips
171         jalr    v0
172         nop
173 stuck:
174         b       stuck
175         nop
178         .rdata
179 hexchar:
180         .ascii  "0123456789abcdef"
182         .text
183         .align  2