[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V3 6/8] hw/dma.c: replace register_ioport*
From: |
Avi Kivity |
Subject: |
Re: [Qemu-devel] [PATCH V3 6/8] hw/dma.c: replace register_ioport* |
Date: |
Sun, 08 Apr 2012 17:21:34 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120316 Thunderbird/11.0 |
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
- [Qemu-devel] [PATCH V3 0/8] memory: unify ioport registration, Julien Grall, 2012/04/05
- [Qemu-devel] [PATCH V3 5/8] hw/pc.c: replace register_ioport*, Julien Grall, 2012/04/05
- [Qemu-devel] [PATCH V3 7/8] hw/apm.c: replace register_ioport*, Julien Grall, 2012/04/05
- [Qemu-devel] [PATCH V3 8/8] smb: replace_register_ioport*, Julien Grall, 2012/04/05
- [Qemu-devel] [PATCH V3 6/8] hw/dma.c: replace register_ioport*, Julien Grall, 2012/04/05
- [Qemu-devel] [PATCH V3 4/8] hw/serial.c: replace register_ioport*, Julien Grall, 2012/04/06
- [Qemu-devel] [PATCH V3 1/8] isa: add isa_address_space_io, Julien Grall, 2012/04/06
- [Qemu-devel] [PATCH V3 3/8] hw/cirrus_vga.c: replace register_ioport*, Julien Grall, 2012/04/06
- [Qemu-devel] [PATCH V3 2/8] hw/acpi_piix4.c: replace register_ioport*, Julien Grall, 2012/04/06
- Re: [Qemu-devel] [PATCH V3 0/8] memory: unify ioport registration, Avi Kivity, 2012/04/08