On Thu, 20 Nov 2014 21:25:18 +0800 (GMT+08:00) Kaiyuan <kaiyu...@tju.edu.cn> wrote: > Hello, all > > I added a custom device to qemu. This device is attached to sysbus by mmio > and has an address register in which device should access the guest memory > the register point to. > I write a bare-metal program that pass an address like 0x1234ABCD to this > address register. Inside qemu device code I added, if device reads value from > register and directly accesses this value of 0x1234ABCD, it will access host > memory 0x1234ABCD rather than guest memory 0x1234ABCD. > Does qemu provide some functions that allow device to access guest memory > address? >
Have a look at *_phys* functions in the <exec/cpu-common.h> QEMU header file (cpu_physical_memory_read() for exemple). > Thanks, > Kaiyuan Liang > -- G