qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] What "opaque" stand for?


From: Kaiyuan
Subject: Re: [Qemu-devel] What "opaque" stand for?
Date: Wed, 12 Nov 2014 09:56:42 +0800 (GMT+08:00)

> -----Origin email-----
> From: Peter Maydell <address@hidden>
> Sent Time: Monday, November 10, 2014
> To: Kaiyuan <address@hidden>
> Cc: QEMU Developers <address@hidden>
> Subject: Re: Re: [Qemu-devel] What &#034;opaque&#034; stand for?
> 
> On 10 November 2014 07:33, Kaiyuan <address@hidden> wrote:
> > Thanks for your explanation, Peter. In this case of
> > timer_read(void *opaque, hwaddr addr, unsigned int size), could
> > I think that opaque is a pointer to a register located in mmio
> > address? If I cast opaque pointer to corresponding structure,
> > the beginning address of structure == hwaddr addr and the size of
> > structure == parameter size?
> 
> No, I think you're confused. The "opaque" parameter is simply
> whatever was passed as the fourth argument to memory_region_init_io()
> [see the documentation for that function in include/exec/memory.h].
> Typically in device models we pass the pointer to the device object
> itself, so that the callback can access any relevant internal state.
> 
> This has no relation at all to the 'hwaddr' and 'size' arguments
> to the callback, which tell you what relative address within your
> MMIO region the guest was accessing and at what size.
> 
> -- PMM
I think I get your point. In this case, opaque points to device after casting 
in timer_read(), and hwaddr is relative address. It will read registers' value 
or internal state inside device according hwaddr offset and size.



reply via email to

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