summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2023-09-28 22:04:11 +0200
committerMarcin Bukat <marcin.bukat@gmail.com>2023-09-28 22:04:11 +0200
commit440fcb86d69aa6d42b032d0315b2263a348cbd9e (patch)
tree246aaf25d08fb59c69b302feb8a08f9a824646f6
parent0bfdb73b4d7512ca223ca44417612bcbfe2536a1 (diff)
downloadrockbox-440fcb86d69aa6d42b032d0315b2263a348cbd9e.tar.gz
rockbox-440fcb86d69aa6d42b032d0315b2263a348cbd9e.zip
ATJ213x: minor changes to hwstub port
1) Make use of $gp addressing. This saves some bin size and makes code slightly faster. 2) Substitute jr with simple j instruction in exception handling. Code is small and j can easily encode target address. 3) Remove nop after eret in interrupt handler. According to mips32r2 ISA manual eret does not have branch delay slot. Change-Id: If63feb12eef189f08f7b50c832a8091be5e6f570
-rw-r--r--utils/hwstub/stub/atj213x/Makefile2
-rw-r--r--utils/hwstub/stub/atj213x/crt0.S18
-rw-r--r--utils/hwstub/stub/atj213x/hwstub.lds5
3 files changed, 12 insertions, 13 deletions
diff --git a/utils/hwstub/stub/atj213x/Makefile b/utils/hwstub/stub/atj213x/Makefile
index d653017a0f..81dfd30f54 100644
--- a/utils/hwstub/stub/atj213x/Makefile
+++ b/utils/hwstub/stub/atj213x/Makefile
@@ -8,7 +8,7 @@ AS=$(PREFIX)gcc
8OC=$(PREFIX)objcopy 8OC=$(PREFIX)objcopy
9DEFINES= 9DEFINES=
10INCLUDES=-I$(CURDIR) 10INCLUDES=-I$(CURDIR)
11GCCOPTS=-march=mips32r2 -G0 -msoft-float 11GCCOPTS=-Os -march=mips32r2 -G128 -msoft-float
12BUILD_DIR=$(CURDIR)/build/ 12BUILD_DIR=$(CURDIR)/build/
13ROOT_DIR=$(CURDIR)/.. 13ROOT_DIR=$(CURDIR)/..
14 14
diff --git a/utils/hwstub/stub/atj213x/crt0.S b/utils/hwstub/stub/atj213x/crt0.S
index 7d5bcde9b2..32797b513a 100644
--- a/utils/hwstub/stub/atj213x/crt0.S
+++ b/utils/hwstub/stub/atj213x/crt0.S
@@ -130,38 +130,34 @@ stack_munge_loop:
130 bne t0, sp, stack_munge_loop 130 bne t0, sp, stack_munge_loop
131 addiu t0, 4 131 addiu t0, 4
132 132
133 # setup Global Pointer
134 la gp, _gp
135
133 # jump to C code with enabled interrupts 136 # jump to C code with enabled interrupts
134 la t0, main 137 la t0, main
135 jr.hb t0 138 jr.hb t0
136 ei 139 ei
137 140
138 .extern exception_jmp_ctx_ptr
139 .global tlb_refill_handler 141 .global tlb_refill_handler
140 .section .exception.tlb_refill,"ax",%progbits 142 .section .exception.tlb_refill,"ax",%progbits
141 143
142tlb_refill_handler: 144tlb_refill_handler:
145 j restore_exception_jmp
143 li a0, EXCEPTION_ADDR 146 li a0, EXCEPTION_ADDR
144 la k0, restore_exception_jmp
145 jr k0
146 nop
147 147
148 .global cache_error_handler 148 .global cache_error_handler
149 .section .exception.cache_error,"ax",%progbits 149 .section .exception.cache_error,"ax",%progbits
150 150
151cache_error_handler: 151cache_error_handler:
152 j restore_exception_jmp
152 li a0, EXCEPTION_ADDR 153 li a0, EXCEPTION_ADDR
153 la k0, restore_exception_jmp
154 jr k0
155 nop
156 154
157 .global general_exception_handler 155 .global general_exception_handler
158 .section .exception.general_exception,"ax",%progbits 156 .section .exception.general_exception,"ax",%progbits
159 157
160general_exception_handler: 158general_exception_handler:
159 j restore_exception_jmp
161 li a0, EXCEPTION_UNSP 160 li a0, EXCEPTION_UNSP
162 la k0, restore_exception_jmp
163 jr k0
164 nop
165 161
166/* s0-s7 not saved as this are callee saved registers 162/* s0-s7 not saved as this are callee saved registers
167 * CO_STATUS is not saved as nested interrupts are not supported 163 * CO_STATUS is not saved as nested interrupts are not supported
@@ -249,8 +245,6 @@ restore:
249 addiu sp, sp, 84 245 addiu sp, sp, 84
250 move sp, k1 246 move sp, k1
251 eret 247 eret
252 nop
253 248
254 .set reorder 249 .set reorder
255 .set at 250 .set at
256
diff --git a/utils/hwstub/stub/atj213x/hwstub.lds b/utils/hwstub/stub/atj213x/hwstub.lds
index 06912fb56f..818e836452 100644
--- a/utils/hwstub/stub/atj213x/hwstub.lds
+++ b/utils/hwstub/stub/atj213x/hwstub.lds
@@ -28,6 +28,11 @@ SECTIONS
28 *(.rodata*) 28 *(.rodata*)
29 *(.data*) 29 *(.data*)
30 *(.rel.dyn) 30 *(.rel.dyn)
31
32 . = ALIGN(8);
33 _gp = ABSOLUTE(. + 0x7ff0);
34
35 *(.sdata*)
31 } > IRAM 36 } > IRAM
32 37
33 .bss (NOLOAD) : 38 .bss (NOLOAD) :