diff options
Diffstat (limited to 'utils/hwstub/tools/lua/xburst.lua')
-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) |