[Top][All Lists]

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

Re: [Qemu-devel] Emulating external registers

From: Peter Maydell
Subject: Re: [Qemu-devel] Emulating external registers
Date: Thu, 6 Apr 2017 09:32:42 +0100

On 5 April 2017 at 22:03, Wu, Michael Y [US] (MS) <address@hidden> 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.

-- PMM

reply via email to

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