qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Wu, Michael Y [US] (MS)" <Michael.Wu@ngc.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] Emulating external registers
Date: Wed, 5 Apr 2017 21:03:30 +0000	[thread overview]
Message-ID: <7a623fb8d2284ee28ddbd6e1ccf277e0@XCGC3021.northgrum.com> (raw)

Hi,

I've been doing some bare metal programming using the powerpc system emulator. I was able to run some of my code using the g3beige system emulation. I am now currently trying emulate some external registers. Simply a powerpc address will be mapped to a register. My plan is to write a bare metal  C program that will access the contents of a given powerpc address via pointers.

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);
memory_region_add_subregion(sysmem, 0xfc000000, reg);

In my bare metal program I used the following lines to see  if it works using GDB. The issue is that GDB hangs when the pointer is either read or written. This makes me think I am doing something incorrectly.
volatile unsigned int  * const test = (unsigned int *) 0xFC000000;
  *test = 5640;

  //read from register to confirm
  if (5640 == *test) //seems to pause as well...
  {
    breakpoint_hit();
  }

I have very little limited experience with emulators so I thought I would ask to see if anyone has tips or suggestions.

Thanks!

             reply	other threads:[~2017-04-05 21:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05 21:03 Wu, Michael Y [US] (MS) [this message]
2017-04-06  8:32 ` [Qemu-devel] Emulating external registers Peter Maydell
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=7a623fb8d2284ee28ddbd6e1ccf277e0@XCGC3021.northgrum.com \
    --to=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).