summaryrefslogtreecommitdiff
path: root/utils/hwstub/stub/jz4760b/crt0.S
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-01-17 22:54:13 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2017-01-24 15:34:19 +0100
commitf3cce72269703e983e4a4e6ec8dc9217b0c2b6fe (patch)
treedc66a06febd287a5f0d146376b69d6a4322d81f1 /utils/hwstub/stub/jz4760b/crt0.S
parent07bc348c914f04657b284cb1ace92df8ef3a15d9 (diff)
downloadrockbox-f3cce72269703e983e4a4e6ec8dc9217b0c2b6fe.tar.gz
rockbox-f3cce72269703e983e4a4e6ec8dc9217b0c2b6fe.zip
hwstub/jz460b: implement exception recovery
Now that we now that jz4760b implements EBASE, we can use it to rebase exceptions to use a k1seg address, that maps to the physical address of the TCSM0. It requires to enable HAB1 to have this translation. This most the most inefficient way to access tighly coupled memory ever, but it works. Change-Id: I894ca929c9835696102eb2fef44b06e6eaf96d44
Diffstat (limited to 'utils/hwstub/stub/jz4760b/crt0.S')
-rw-r--r--utils/hwstub/stub/jz4760b/crt0.S66
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:
92stack_setup: 92stack_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
115die_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
145tlb_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
152cache_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
159general_exception_handler:
160 la k0, restore_data_abort_jmp
161 jr k0
162 nop