On 04/05/2012 06:33 PM, Julien Grall wrote: > This patch replaces all register_ioport* be the new memory API functions. > It permits to use the new Memory stuff like listener. > > enum { > @@ -149,7 +151,7 @@ static inline int getff (struct dma_cont *d) > return ff; > } > > -static uint32_t read_chan (void *opaque, uint32_t nport) > +static uint64_t read_chan(void *opaque, uint64_t nport, unsigned size) > { > struct dma_cont *d = opaque; > int ichan, nreg, iport, ff, val, dir; > @@ -171,7 +173,8 @@ static uint32_t read_chan (void *opaque, uint32_t nport) > return (val >> (d->dshift + (ff << 3))) & 0xff; > } > > -static void write_chan (void *opaque, uint32_t nport, uint32_t data) > +static void write_chan(void *opaque, target_phys_addr_t nport, uint64_t data, > + unsigned size) > { > struct dma_cont *d = opaque; > int iport, ichan, nreg; > @@ -189,7 +192,8 @@ static void write_chan (void *opaque, uint32_t nport, > uint32_t data) > } > } > > + > /* dshift = 0: 8 bit DMA, 1 = 16 bit DMA */ > static void dma_init2(struct dma_cont *d, int base, int dshift, > int page_base, int pageh_base, > qemu_irq *cpu_request_exit) > { > - static const int page_port_list[] = { 0x1, 0x2, 0x3, 0x7 }; > int i; > > d->dshift = dshift; > d->cpu_request_exit = cpu_request_exit; > for (i = 0; i < 8; i++) { > - register_ioport_write (base + (i << dshift), 1, 1, write_chan, d); > - register_ioport_read (base + (i << dshift), 1, 1, read_chan, d); > + memory_region_init_io(&d->channel_io[i], &channel_io_ops, d, > + "dma-chan", 1); > + memory_region_add_subregion(isa_address_space_io(NULL), > + base + (i << dshift), &d->channel_io[i]); > } >
This isn't quite correct. MemoryRegion callback addresses are offsets, so 'nport' will always be 0 and ichan/nreg will be incorrect in read_chan() write_chan(). This is fixable, but dshift makes it quite hard. We need either two separate regions for even i and odd i (one region per register), or make one region per channel of size (2 << dshift), and pass the channel as the opaque instead of the . Or even one large region of size (8 << dshift), then nport becomes correct again. Please verify that the other conversions don't suffer from this problem. -- error compiling committee.c: too many arguments to function