qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Emulating external registers


From: Wu, Michael Y [US] (MS)
Subject: [Qemu-devel] Emulating external registers
Date: Wed, 5 Apr 2017 21:03:30 +0000

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 via email to

[Prev in Thread] Current Thread [Next in Thread]