On 7 November 2014 14:42, Kaiyuan <kaiyu...@tju.edu.cn> 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