return result
+
def qemu_register_compare(sim, q, regs, fprs):
qpc, qxer, qcr, qlr = q.get_pc(), q.get_xer(), q.get_cr(), q.get_lr()
sim_cr = sim.cr.value
if _pc is None:
break
- # cleanup
- if qemu:
- qemu.exit()
-
sim.add_process(process)
sim.run()
- return simulator
+ return simulator, qemu
def help():
lst = f.read()
with Program(lst, bigendian=False, orig_filename=binaryname) as prog:
- simulator = run_tst(None, prog, qemu_cosim,
+ simulator, qemu = run_tst(None, prog, qemu_cosim,
initial_regs,
initial_sprs=initial_sprs,
svstate=0, mmu=False,
for fname, offs, length in write_to:
write_data(simulator.mem, fname, offs, length)
+ if qemu:
+ qmem = qemu.get_mem(offs, length)
+ for i, mem in enumerate(qmem):
+ log(hex(offs+i*8), hex(mem))
+ # cleanup
+ if qemu:
+ qemu.exit()
if __name__ == "__main__":
run_simulation()
def set_bytes(self, addr, v, wid):
print("qemu set bytes", hex(addr), hex(v))
+ v = swap_order(v, wid)
faddr = '&{int}0x%x' % addr
fmt = '"%%0%dx"' % (wid * 2)
cmd = '-data-write-memory-bytes %s ' + fmt
def get_mem(self, addr, nbytes):
res = self.gdb.write("-data-read-memory %d u 1 1 %d" %
- (addr, 8*nbytes))
+ (addr, nbytes))
#print ("get_mem", res)
for x in res:
if(x["type"] == "result"):
q = QemuController(program.binfile.name, bigendian)
q.connect()
q.set_endian(init_endian) # easier to set variables this way
- if initial_mem:
- q.upload_mem(initial_mem, skip_zeros=True)
# Run to the start of the program
q.set_pc(start_addr)
# set endian before SPR set
q.set_endian(bigendian)
+ # upload memory
+ if initial_mem:
+ q.upload_mem(initial_mem, skip_zeros=True)
+
# dump msr after endian set
msr = q.get_msr()
print("msr", bigendian, hex(msr), bin(msr))
-TOOLCHAIN=powerpc64-linux-gnu
+TOOLCHAIN=powerpc64le-linux-gnu
CC=$(TOOLCHAIN)-gcc
AS=$(TOOLCHAIN)-as
AFLAGS=-mpwr9
sim: kernel.bin
echo -n -e \\0060\\0000\\0061\\0000 > test.bin
echo -n -e \\0060\\0000\\0061\\0000 >> test.bin
- pypowersim --load test.bin:0 \
+ pypowersim -q --load test.bin:0 \
+ -p 0x20000000 \
--dump testout.bin:0x20000100:8 \
--dump testout2.bin:0x0:16 \
-g gpr.list -i kernel.bin