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: Mon, 10 Nov 2014 15:33:26 +0800 (GMT+08:00)

> -----Origin email-----
> From: Peter Maydell <address@hidden>
> Sent Time: Friday, November 7, 2014
> To: Kaiyuan <address@hidden>
> Cc: QEMU Developers <address@hidden>
> Subject: Re: [Qemu-devel] What "opaque" stand for?
> 
> On 7 November 2014 14:42, Kaiyuan <address@hidden> wrote:
> >
> > Hello, all
> >
> > I am reviewing source of Qemu. I can see parameter called "opaque" from a 
> > lot of function like this:
> > //@hw/timer/xilinx_timer.c
> > static uint64_t timer_read(void *opaque, hwaddr addr, unsigned int size)
> >
> > {
> > ...
> > }
> >
> >
> > , and its meaning confuse me. What does "opaque" stand for?
> 
> It's a general term (not specific to QEMU) that means "this is some
> data (structure) which we cannot see into". (The word 'opaque' means
> "not able to be seen through"; it's the opposite of 'transparent'.)
> Usually there is an API layer involved which lets you register a
> callback function together with some data to be passed to it
> (in this case that API is memory_region_init_io()). The memory
> region code does not know or care what the data pointer is and
> cannot see inside it (because it's typed as a void*) -- the data
> is opaque to that code. When the callback function timer_read()
> is called, it is passed the opaque data, and the first thing it
> has to do is cast that pointer to the correct type so it can be used.
> 
> -- PMM
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?



reply via email to

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