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