📄 crt0.lst
字号:
GAS LISTING /tmp/ccZtg9Qb.s page 1 1 # 1 "/mnt/hgfs/boot/booter/source/crt0.S" 2 # 1 "/mnt/hgfs/boot/booter/source//" 1 # 1 ... 0 0 2 # Low-level startup code for C programs. 3 # Also provides alot of common low-level utilities 4 # to facilitate C code. 5 # 6 7 #define zero $0 8 #define v0 $2 9 #define v1 $3 10 #define a0 $4 11 #define a1 $5 12 #define a2 $6 13 #define a3 $7 14 #define t0 $8 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 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 31 #define t9 $25 32 #define k0 $26 33 #define k1 $27 34 #define gp $28 35 #define sp $29 36 #define fp $30 37 #define s8 $30 38 #define ra $31 39 40 #define CP0_Index $0 41 #define CP0_Random $1 42 #define CP0_EntryLo0 $2 43 #define CP0_EntryLo1 $3 44 #define CP0_Context $4 45 #define CP0_PageMask $5 46 #define CP0_Wired $6 47 #define CP0_BadVAddr $8 48 #define CP0_Count $9 49 #define CP0_EntryHi $10 50 #define CP0_Compare $11 51 #define CP0_Status $12 52 #define CP0_Cause $13GAS LISTING /tmp/ccZtg9Qb.s page 2 53 #define CP0_EPC $14 54 #define CP0_PRId $15 55 #define CP0_Config $16 56 #define CP0_Config0 $16 57 #define CP0_Config1 $16,1 58 #define CP0_LLAddr $17 59 #define CP0_WatchLo $18 60 #define CP0_IWatchLo $18,1 61 #define CP0_WatchHi $19 62 #define CP0_IWatchHi $19,1 63 #define CP0_Scratch $22 64 #define CP0_Debug $23 65 #define CP0_DEPC $24 66 #define CP0_PerfCnt $25 67 #define CP0_PerfCtrl $25,1 68 #define CP0_DTag $28 69 #define CP0_DData $28,1 70 #define CP0_ITag $29 71 #define CP0_IData $29,1 72 #define CP0_ErrorEPC $30 73 #define CP0_DESave $31 74 75 .section ".init" 76 .text 77 .extern main 78 .extern commonInit 79 .extern platformInit 80 .extern startupStackFrame 81 82 83 .global start 84 start: 85 # 86 # Save SP for exitToYamon() 87 # 88 89 0000 0000083C la t0,startupStackFrame 89 00000825 90 0008 00001DAD sw sp,0(t0) 91 92 # 93 # Initialize Stack Pointer 94 # 95 000c 00001D3C la sp,__stacktop 95 0000BD27 96 97 0014 E8FFBD27 addiu sp,sp,-24 98 99 # Preserve a0,a1,a2,a3 from YAMON (argc, argv, envp) 100 0018 0000A4AF sw a0,0(sp) 101 001c 0400A5AF sw a1,4(sp) 102 0020 0800A6AF sw a2,8(sp) 103 0024 0C00A7AF sw a3,12(sp) 104 # Preserve return address into YAMON 105 0028 1000BFAF sw ra,16(sp) 106 107 #GAS LISTING /tmp/ccZtg9Qb.s page 3 108 # Initialize GP (needed by prebuilt libs) 109 # 110 002c 00001C3C la gp,_gp 110 00009C27 111 112 113 /* turn off mem_stcfg0[PM], it interferes */ 114 /*commented by shuaiwen for sdram running 115 li t2,0xB4001000 116 lw t0,0(t2) 117 li t1,~0x00000010 118 and t0,t0,t1 119 sw t0,0(t2) 120 sync 121 shuaiwen comment ended*/ 122 /* Execute From Cachable Space */ 123 /*shuaiwen comment begian 124 la t0, executeCache 125 jr t0 126 nop 127 executeCache: 128 shuaiwen comment ended 129 */ 130 # 131 # zero out bss 132 # 133 0034 0000000C jal initialize_bss 133 00000000 134 003c 00000000 nop 135 136 # 137 # Copy data segment if it needs to be relocated 138 # 139 0040 0000000C jal copy_data_segment 139 00000000 140 0048 00000000 nop 141 142 # 143 # Initialize infrastructure 144 # 145 #jal commonInit comment by shuaiwen 146 004c 00000000 nop 147 0050 0000000C jal platformInit 147 00000000 148 0058 00000000 nop 149 150 # Restore a0,a1,a2,a3 from YAMON for args to main() 151 005c 0000A48F lw a0,0(sp) 152 0060 0400A58F lw a1,4(sp) 153 0064 0800A68F lw a2,8(sp) 154 0068 0C00A78F lw a3,12(sp) 155 156 # Call c main() 157 006c 0000000C jal main 157 00000000 158 0074 00000000 nop 159 GAS LISTING /tmp/ccZtg9Qb.s page 4 160 .global exitToYamon 161 exitToYamon: 162 # Pause 0.5 second to allow UART queues to drain 163 0078 F4010424 li a0, 500 164 007c 0000000C jal msdelay 164 00000000 165 0084 00000000 nop 166 167 # Restore return address into YAMON 168 0088 1000BF8F lw ra,16(sp) 169 170 # Restore YAMON stack frame 171 008c 0000083C la t0,startupStackFrame 171 00000825 172 0094 00001D8D lw sp,0(t0) 173 174 # Return to YAMON 175 0098 0800E003 jr ra 175 00000000 176 00a0 00000000 nop 177 178 # 179 # GCC 2.95.3 automatically calls __gccmain() from main() 180 # GCC 3.0.1 automatically calls __main() from main() 181 # 182 .global __gccmain 183 .global __main 184 __gccmain: 185 __main: 186 00a4 0800E003 jr ra 186 00000000 187 00ac 00000000 nop 188 189 ######################################################################## 190 191 192 .text 193 /* 194 * Cache flush and invalidate routines 195 */ 196 .global icacheFlush 197 icacheFlush: 198 00b0 00400824 li t0,(16*1024) 199 00b4 20000924 li t1,32 200 00b8 00800A3C li t2,0x80000000 201 00bc 21580A01 addu t3,t0,t2 202 iloop: 203 00c0 000040BD cache 0,0(t2) 204 00c4 21504901 addu t2,t1 205 00c8 FDFF4B15 bne t2,t3,iloop 205 00000000 206 00d0 00000000 nop 207 00d4 0800E003 jr ra 207 00000000 208 00dc 00000000 nop 209 210 .global dcacheFlushGAS LISTING /tmp/ccZtg9Qb.s page 5 211 dcacheFlush: 212 00e0 00400824 li t0,(16*1024) 213 00e4 20000924 li t1,32 214 00e8 00800A3C li t2,0x80000000 215 00ec 21580A01 addu t3,t0,t2 216 dloop: 217 00f0 000041BD cache 1,0(t2) 218 00f4 21504901 addu t2,t1 219 00f8 FDFF4B15 bne t2,t3,dloop 219 00000000 220 0100 00000000 nop 221 0104 0800E003 jr ra 221 00000000 222 010c 00000000 nop 223 224 ######################################################################## 225 /* 226 * Cache flush and invalidate routines for fixed range 227 */ 228 /* 229 * a0 -> buffer start address. 230 * a1 -> length/range to be flushed/invalidated. 231 */ 232 .global dcacheFlushInvalidateRange 233 dcacheFlushInvalidateRange: 234 0110 2148A400 addu t1,a1,a0 # end of range 235 dfiloop: 236 0114 000095BC cache 0x15,0(a0) # wb inv address 237 0118 20008424 addiu a0,32 # cache line size 238 011c 2B088900 bltu a0,t1,dfiloop # loop if not end of range 238 FCFF2014 238 00000000 239 0128 00000000 nop 240 012c 0800E003 jr ra 240 00000000 241 0134 00000000 nop 242 243 244 /* 245 * a0 -> buffer start address, must be cache line aligned. 246 * a1 -> length/range to be invalidated. 247 */ 248 .global dcacheInvalidateRange 249 dcacheInvalidateRange: 250 0138 2148A400 addu t1,a1,a0 # end of range 251 diloop: 252 013c 000091BC cache 0x11,0(a0) # inv address 253 0140 20008424 addiu a0,32 # cache line size 254 0144 2B088900 bltu a0,t1,diloop # loop if not end of range 254 FCFF2014 254 00000000 255 0150 00000000 nop 256 0154 0800E003 jr ra 256 00000000 257 015c 00000000 nop 258 259 GAS LISTING /tmp/ccZtg9Qb.s page 6 260 261 ######################################################################## 262 #if 0 263 /* 264 * # of loops passed in A0 265 * ptr to start counter passed in A1 266 * ptr to stop counter passed in A2 267 * start Counter passed out in V0 268 * end Counter passed out in V1 269 */ 270 .global maddloop 271 maddloop: 272 .set noreorder 273 mthi zero 274 mtlo zero 275 li t0, 1 276 mfc0 t1, CP0_Count 277 sw t1, 0(a1) 278 ml: 279 madd t0, a0 280 #madd t0, a0 281 #madd t0, a0 282 bne zero, a0, ml 283 addiu a0, -1 284 mfc0 t1, CP0_Count 285 sw t1, 0(a2) 286 j ra 287 nop 288 .set reorder 289 #endif 290 291 ######################################################################## 292 293 /* t1 has chip-select sdaddr value */ 294 /* it updates v0 accordingly */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -