diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2017-01-18 14:39:03 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2017-01-24 15:34:20 +0100 |
commit | fdb98c258f56c8fbdc28e256ed3edab0bf47009b (patch) | |
tree | 86dba5e242ac4f9d020aed3c41a3302635ce7c17 /utils/hwstub | |
parent | 9bb6050d40b9936beda5cb1cd15040f6c1b07179 (diff) | |
download | rockbox-fdb98c258f56c8fbdc28e256ed3edab0bf47009b.tar.gz rockbox-fdb98c258f56c8fbdc28e256ed3edab0bf47009b.zip |
hwstub/jz4760b: add lua code to probe for ei/di and ext instructions
Add lua code to check whether ei/di and ext instructions are supported. This
is unclear since xburst is somewhere between mips32r1 and mips32r2. Details
results are below, but in summary: they don't work (ei has no effect, di/ext
cause illegal instruction exceptions)
> ./hwstub_shell -q -b -e 'require("jz/misc"); JZ.misc.enable_sram()' \
-f lua/xburst.lua -e "XBURST.test_ext_inst(0xb32d0000)"
[...]
Selecting soc jz4760b. Redirecting HW to hwstub.soc.jz4760b
data: d7168acf
error: lua/xburst.lua:209: call failed
trapped exception in call
> ./hwstub_shell -q -b -e 'require("jz/misc"); JZ.misc.enable_sram()' \
-f lua/xburst.lua -e "XBURST.test_ei_di_inst(0xb32d0000)"
[...]
Selecting soc jz4760b. Redirecting HW to hwstub.soc.jz4760b
Testing ei
Test SR
Enable interrupts with CP0
SR: 0x1
Disable interrupts with CP0
SR: 0x0
Test ei/di
Enable interrupts with ei
SR: 0x0
Disable interrupts with di
error: lua/xburst.lua:244: call failed
trapped exception in call
Change-Id: I2e162b5dd5e70488bcd8b58f3ca401a3ecab3c4b
Diffstat (limited to 'utils/hwstub')
-rw-r--r-- | utils/hwstub/tools/lua/xburst.lua | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/utils/hwstub/tools/lua/xburst.lua b/utils/hwstub/tools/lua/xburst.lua index ddaf7fbc66..62e94faa7c 100644 --- a/utils/hwstub/tools/lua/xburst.lua +++ b/utils/hwstub/tools/lua/xburst.lua | |||
@@ -181,6 +181,73 @@ function XBURST.test_ebase(mem_addr) | |||
181 | print(" Exception result: " .. XBURST.do_ebase_exc_test(mem_addr)) | 181 | print(" Exception result: " .. XBURST.do_ebase_exc_test(mem_addr)) |
182 | end | 182 | end |
183 | 183 | ||
184 | function XBURST.test_ext_inst(mem_addr) | ||
185 | data_addr = mem_addr + 0x80 | ||
186 | ----------- | ||
187 | -- test ext | ||
188 | ----------- | ||
189 | for pos = 0, 31 do | ||
190 | for size = 1, 32 - pos do | ||
191 | -- lui v0,<low part of data_addr> | ||
192 | -- addiu v0,v0,<high part> | ||
193 | -- lw v1,0(v0) | ||
194 | DEV.write32(mem_addr + 0, 0x3c020000 + bit32.rshift(data_addr, 16)) | ||
195 | DEV.write32(mem_addr + 4, 0x8c430000 + bit32.band(data_addr, 0xffff)) | ||
196 | DEV.write32(mem_addr + 8, 0x8c430000) | ||
197 | -- ext v1, v1, pos, size | ||
198 | DEV.write32(mem_addr + 12, 0x7c630000 + bit32.rshift(size - 1, 11) + bit32.rshift(pos, 6)) | ||
199 | -- sw v1,0(v0) | ||
200 | DEV.write32(mem_addr + 16, 0xac430000) | ||
201 | -- jr ra | ||
202 | -- nop | ||
203 | DEV.write32(mem_addr + 20, 0x03e00008) | ||
204 | DEV.write32(mem_addr + 24, 0) | ||
205 | -- write some random data | ||
206 | data = math.random(0xffffffff) | ||
207 | print(string.format(" data: %x", data)) | ||
208 | DEV.write32(data_addr, data) | ||
209 | DEV.call(mem_addr) | ||
210 | ext_data = DEV.read32(data_addr) | ||
211 | print(string.format(" result: %x vs %x", ext_data, bit32.extract(data, pos, size))) | ||
212 | break | ||
213 | end | ||
214 | break | ||
215 | end | ||
216 | end | ||
217 | |||
218 | function XBURST.test_ei_di_inst(mem_addr) | ||
219 | -- save SR and disable interrupts | ||
220 | old_sr = XBURST.read_cp0(12, 0) | ||
221 | XBURST.write_cp0(12, 0, bit32.replace(old_sr, 0, 0)) -- clear EI | ||
222 | print("Testing ei") | ||
223 | print(" Test SR") | ||
224 | print(" Enable interrupts with CP0") | ||
225 | XBURST.write_cp0(12, 0, bit32.replace(old_sr, 1, 0)) -- set EI | ||
226 | print(string.format(" SR: 0x%x", XBURST.read_cp0(12, 0))) | ||
227 | print(" Disable interrupts with CP0") | ||
228 | XBURST.write_cp0(12, 0, bit32.replace(old_sr, 0, 0)) -- clear EI | ||
229 | print(string.format(" SR: 0x%x", XBURST.read_cp0(12, 0))) | ||
230 | |||
231 | print(" Test ei/di") | ||
232 | print(" Enable interrupts with ei") | ||
233 | -- ei | ||
234 | -- jr ra | ||
235 | -- nop | ||
236 | DEV.write32(mem_addr + 4, 0x41606020) | ||
237 | DEV.write32(mem_addr + 4, 0x03e00008) | ||
238 | DEV.write32(mem_addr + 8, 0) | ||
239 | DEV.call(mem_addr) | ||
240 | print(string.format(" SR: 0x%x", XBURST.read_cp0(12, 0))) | ||
241 | print(" Disable interrupts with di") | ||
242 | -- di | ||
243 | DEV.write32(mem_addr + 4, 0x41606000) | ||
244 | DEV.call(mem_addr) | ||
245 | print(string.format(" SR: 0x%x", XBURST.read_cp0(12, 0))) | ||
246 | |||
247 | -- restore SR | ||
248 | XBURST.write_cp0(old_sr) | ||
249 | end | ||
250 | |||
184 | function XBURST.init() | 251 | function XBURST.init() |
185 | -- enable CP1 in SR | 252 | -- enable CP1 in SR |
186 | sr_old = XBURST.read_cp0(12, 0) | 253 | sr_old = XBURST.read_cp0(12, 0) |