qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <andreas.faerber@web.de>
To: qemu-devel Developers <qemu-devel@nongnu.org>
Cc: Avi Kivity <avi@redhat.com>, Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] Memory read/write issues (was: Initializing PC from memory on reset?)
Date: Fri, 25 Nov 2011 17:25:06 +0100	[thread overview]
Message-ID: <4ECFC162.5050408@web.de> (raw)
In-Reply-To: <4ECD88EF.2030200@web.de>

Am 24.11.2011 00:59, schrieb Andreas Färber:
> Unlike PowerPC, an architecture that I'm trying to emulate does not
> store branch instructions in the reset vector but a memory address. I'm
> therefore trying to read physical address 0x00000 and store its value
> into my env->pc.
> 
> I've verified by running with -S that xp /xh 0x00000 shows the expected
> value.
> 
> When doing lduw_phys(0x00000) or cpu_read_physical_memory() in the CPU
> reset function though, I just seem to read from uninitialized memory
> (0xbaba). I've taken care to reorder CPU initialization to after the
> BIOS file is loaded in the machine initialization function.

Another weird memory issue is that tcg_gen_qemu_st16() succeeds but the
value stored doesn't show up with xp or x on the monitor but 0x0000.

MOVW 0xf8,#0xfee0 (at 0x02010) is trying to write 0xfee0 to 0xFFFf8.

Similarly, a subsequent tcg_gen_qemu_ld16u() reads 0x0000 from there.

TCG snippet:
https://github.com/afaerber/qemu-rl78/commit/d3880bd53a26d224c56d16a6ea5950019d411cf0

            uint8_t sfrp = ldub_code(s->pc + 1) & ~0x1;
            uint16_t data = lduw_code(s->pc + 2);
            LOG_DISAS("MOVW 0x%" PRIx8 ",#0x%04" PRIx16 "\n", sfrp, data);
            TCGv addr = tcg_const_tl(0xFFF00 | sfrp);
            TCGv_i32 val = tcg_const_i32(data);
            tcg_gen_qemu_st16(val, addr, 0);

/* for testing: */
        tcg_gen_qemu_ld16u(env_sp, addr, 0);

            tcg_temp_free(addr);
            tcg_temp_free(val);

(qemu) info mtree
memory
00000000-fffffffe (prio 0): system
  00000000-0000ffff (prio 0): rl78g13_pb.code_flash
  000fef00-000ffeff (prio 0): rl78g13_pb.ram
    000ffee0-000ffeff (prio 0): rl78g13_pb.gpr
  000fff00-000fffff (prio 0): rl78g13_pb.sfr

https://github.com/afaerber/qemu-rl78/blob/d3880bd53a26d224c56d16a6ea5950019d411cf0/hw/rl78g13_pb.c#L88

    memory_region_init_ram(sfr, NULL, "rl78g13_pb.sfr", 256);
    memory_region_add_subregion(get_system_memory(), 0xFFF00, sfr);

Anything obvious that I'm missing?

Thanks,
Andreas

  parent reply	other threads:[~2011-11-25 16:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23 23:59 [Qemu-devel] Initializing PC from memory on reset? Andreas Färber
2011-11-24  7:47 ` Peter Maydell
2011-11-24 21:24   ` Andreas Färber
2011-11-25 16:25 ` Andreas Färber [this message]
2011-11-27  8:32   ` [Qemu-devel] Memory read/write issues Avi Kivity
2011-11-27 14:07     ` Andreas Färber
2011-11-27 14:17       ` Avi Kivity
2011-11-27 22:16         ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ECFC162.5050408@web.de \
    --to=andreas.faerber@web.de \
    --cc=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).