diff options
Diffstat (limited to 'utils/hwstub/stub/jz4760b/crt0.S')
-rw-r--r-- | utils/hwstub/stub/jz4760b/crt0.S | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/utils/hwstub/stub/jz4760b/crt0.S b/utils/hwstub/stub/jz4760b/crt0.S index 73dbe20428..94d95b3e73 100644 --- a/utils/hwstub/stub/jz4760b/crt0.S +++ b/utils/hwstub/stub/jz4760b/crt0.S | |||
@@ -51,7 +51,7 @@ reloc_loop: | |||
51 | 51 | ||
52 | /* Tricky part: as explained earlier, tcsm0 is uncached so no need to commit | 52 | /* Tricky part: as explained earlier, tcsm0 is uncached so no need to commit |
53 | * the dcache but we want to invalidate the icache ONLY AT THIS LOCATION. | 53 | * the dcache but we want to invalidate the icache ONLY AT THIS LOCATION. |
54 | * Indeed, if the invalidate the entire icache in the cache-as-ram case, we | 54 | * Indeed, if we invalidate the entire icache in the cache-as-ram case, we |
55 | * will miserably crash */ | 55 | * will miserably crash */ |
56 | cache ICHitInv, 0(t0) /* invalidate virtual address in icache */ | 56 | cache ICHitInv, 0(t0) /* invalidate virtual address in icache */ |
57 | 57 | ||
@@ -92,7 +92,71 @@ clear_bss_loop: | |||
92 | stack_setup: | 92 | stack_setup: |
93 | la sp, oc_stackend | 93 | la sp, oc_stackend |
94 | 94 | ||
95 | /* the tcsm0 is usually accessed by its weird 0xf4000000 address but this | ||
96 | * address is not in the range available for EBASE (because EBASE[31:30] | ||
97 | * is hardwired to 0b10). Fortunately, the TCSM0 can be accessed by its | ||
98 | * physical address (0x132b0000) if we ungate the AHB1 */ | ||
99 | la t0, 0xb0000028 /* CPM_CLKGATE1 */ | ||
100 | lw t1, 0(t0) | ||
101 | li t2, 0xffffff7e /* AHB1 */ | ||
102 | and t1, t2 /* clear AHB1 */ | ||
103 | sw t1, 0(t0) | ||
104 | /* keep interrupts disabled, use normal exception vectors (to use EBASE) */ | ||
105 | li t0, 0 | ||
106 | mtc0 t0, C0_STATUS | ||
107 | /* set EBASE */ | ||
108 | la t0, irqbase | ||
109 | mtc0 t0, C0_EBASE | ||
95 | /* jump to C code */ | 110 | /* jump to C code */ |
96 | la t0, main | 111 | la t0, main |
97 | jr t0 | 112 | jr t0 |
98 | move a0, k0 | 113 | move a0, k0 |
114 | |||
115 | die_blink: | ||
116 | /* die blinking */ | ||
117 | la a0, 0xb0010400 | ||
118 | li a1, 2 | ||
119 | sw a1, 0x48(a0) /* clear function (gpio or interrupt) */ | ||
120 | sw a1, 0x58(a0) /* clear select (gpio) */ | ||
121 | sw a1, 0x64(a0) /* set direction (out) */ | ||
122 | sw a1, 0x34(a0) /* set pull (disable) */ | ||
123 | /* turn backlight on and off */ | ||
124 | la a0, 0xb0010414 | ||
125 | li a1, 2 | ||
126 | .blink_loop: | ||
127 | sw a1, (a0) | ||
128 | la v0, 10000000 | ||
129 | .wait: | ||
130 | bnez v0, .wait | ||
131 | subu v0, 1 | ||
132 | sw a1, 4(a0) | ||
133 | la v0, 10000000 | ||
134 | .wait2: | ||
135 | bnez v0, .wait2 | ||
136 | subu v0, 1 | ||
137 | j .blink_loop | ||
138 | nop | ||
139 | |||
140 | /* restore_data_abort_jmp restores the context and returns from exception */ | ||
141 | .extern restore_data_abort_jmp | ||
142 | |||
143 | .global tlb_refill_handler | ||
144 | .section .exception.tlb_refill,"ax",%progbits | ||
145 | tlb_refill_handler: | ||
146 | la k0, restore_data_abort_jmp | ||
147 | jr k0 | ||
148 | nop | ||
149 | |||
150 | .global cache_error_handler | ||
151 | .section .exception.cache_error,"ax",%progbits | ||
152 | cache_error_handler: | ||
153 | la k0, restore_data_abort_jmp | ||
154 | jr k0 | ||
155 | nop | ||
156 | |||
157 | .global general_exception_handler | ||
158 | .section .exception.general_exception,"ax",%progbits | ||
159 | general_exception_handler: | ||
160 | la k0, restore_data_abort_jmp | ||
161 | jr k0 | ||
162 | nop | ||