From: Peter Maydell <peter.maydell@linaro.org>
To: "Wu, Michael Y [US] (MS)" <Michael.Wu@ngc.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Emulating external registers
Date: Thu, 6 Apr 2017 09:32:42 +0100 [thread overview]
Message-ID: <CAFEAcA8C17TnnBKim9T9k32Re9C-pWUokF-UeVAd=itcpROvRg@mail.gmail.com> (raw)
In-Reply-To: <7a623fb8d2284ee28ddbd6e1ccf277e0@XCGC3021.northgrum.com>
On 5 April 2017 at 22:03, Wu, Michael Y [US] (MS) <Michael.Wu@ngc.com> wrote:
> My current approach is to create a new MemoryRegion in the init function of the g3beige source code (mac_oldworld.c). My idea is to set up some mmio to certain address to represent those registers. For now I only care about reading and writing, but in the future I hope to add additional logic when the registers are written.
> I added the following lines:
> MemoryRegion *reg = g_new(MemoryRegion, 1);
> memory_region_init_alias(reg, NULL, "reg_mmio",
> get_system_io(), 0, 0x00200000);
This is defining your region to be an alias into the
system IO region, so reading/writing your region will
act like reads and writes into those IO ports. This
doesn't sound like what you were trying to do.
Usually memory regions for registers are defined using
memory_region_init_io(), where you pass in a structure
that includes pointers to functions which are called
for reads and writes.
> memory_region_add_subregion(sysmem, 0xfc000000, reg);
Typically you would create a device model for whatever this device
is, and then map it in the board code, not directly create a
memory region in the board code.
You might find it useful to look at hw/misc/unimp.c, which
is a device which simply prints log messages when it is
read or written. Or try a simple device that your board
already has.
thanks
-- PMM
next prev parent reply other threads:[~2017-04-06 8:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-05 21:03 [Qemu-devel] Emulating external registers Wu, Michael Y [US] (MS)
2017-04-06 8:32 ` Peter Maydell [this message]
2017-04-06 17:23 ` [Qemu-devel] EXT :Re: " Wu, Michael Y [US] (MS)
2017-04-06 17:37 ` Peter Maydell
2017-04-12 18:44 ` Wu, Michael Y [US] (MS)
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='CAFEAcA8C17TnnBKim9T9k32Re9C-pWUokF-UeVAd=itcpROvRg@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=Michael.Wu@ngc.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).