Example #1
0
def run_code(code, mem, symbols, remainders, buf):
    GPIO = 0x48000014
    out = []

    def iowrite(ctx, addr, value, bits):
        assert addr == GPIO
        out.append((ctx['ts'], value, thumb_emu.get_pc(ctx)))

    ctx = thumb_emu.init_ctx(symbols['bitbang_start'],
                             code,
                             mem,
                             iowrite=iowrite)
    ctx['r0'] = symbols['frame_a']
    ctx['r1'] = GPIO
    thumb_emu.write_mem(ctx, symbols['remainders'], remainders)
    thumb_emu.write_mem(ctx, symbols['frame_a'],
                        thumb_emu.from_le_array(buf, 2))
    thumb_emu.run(ctx, end_pc=symbols['bitbang_end'])
    data = get_output_data(out)
    remainders = thumb_emu.read_mem(ctx, symbols['remainders'],
                                    len(remainders))
    buf = thumb_emu.to_le_array(
        thumb_emu.read_mem(ctx, symbols['frame_a'],
                           len(buf) * 2), 2)
    return tuple(data), tuple(remainders), tuple(buf)
Example #2
0
def run_code(start_pc, end_pc, code, mem, remainders, buf):

    remainders = list(remainders)
    buf = list(buf)
    mem = dict(mem)
    thumb_emu.write_mem(mem, REMAINDERS, remainders)
    thumb_emu.write_mem(mem, BUFFER, thumb_emu.from_le_array(buf, 2))
    state = thumb_emu.get_state(start_pc, end_pc, code, mem, BUFFER, GPIO)
    thumb_emu.run(state)
    data = get_output_data(state)
    remainders = thumb_emu.read_mem(mem, REMAINDERS, LEDS_SIZE)
    buf = thumb_emu.to_le_array(thumb_emu.read_mem(mem, BUFFER, LEDS_SIZE * 2),
                                2)
    return tuple(data), tuple(remainders), tuple(buf)
def run_code(code, mem, symbols, remainders, buf, control, pulselength):
    GPIO = 0x48000014
    out = []

    def iowrite(ctx, addr, value, bits):
        assert addr == GPIO
        out.append((ctx['ts'], value, thumb_emu.get_pc(ctx)))

    ctx = thumb_emu.init_ctx(symbols['bitbang_start'],
                             code,
                             mem,
                             iowrite=iowrite)
    ctx['r0'] = symbols['frame_a']
    ctx['r1'] = GPIO
    ctx['r2'] = pulselength * 8
    ctx['r13'] = symbols['_estack']
    thumb_emu.write_mem(ctx, symbols['remainders'], remainders)
    thumb_emu.write_mem(ctx, symbols['frame_a'],
                        thumb_emu.from_le_array(buf, 2))
    thumb_emu.write_mem(ctx, symbols['table'], control)
    thumb_emu.write_mem32(ctx, symbols['routing_table'], symbols['table'])
    thumb_emu.run(ctx, end_pc=symbols['bitbang_end'])
    data = get_output_data(out, pulselength)
    remainders = thumb_emu.read_mem(ctx, symbols['remainders'],
                                    len(remainders))
    buf = thumb_emu.to_le_array(
        thumb_emu.read_mem(ctx, symbols['frame_a'],
                           len(buf) * 2), 2)

    assert ctx['r13'] == symbols['_estack']
    return tuple(data), tuple(remainders), tuple(buf)