qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Julien Grall <julien.grall@citrix.com>
Cc: jan.kiszka@siemens.com, kraxel@redhat.com, qemu-devel@nongnu.org,
	afaerber@suse.de, Stefano.Stabellini@eu.citrix.com
Subject: Re: [Qemu-devel] [PATCH V6 2/8] hw/acpi_piix4.c: replace register_ioport*
Date: Mon, 03 Sep 2012 14:25:59 +0300	[thread overview]
Message-ID: <504493C7.7020704@redhat.com> (raw)
In-Reply-To: <af298e3b574d762094f5af3cf05828e0152879cc.1346208853.git.julien.grall@citrix.com>

On 08/29/2012 06:01 AM, Julien Grall wrote:
> This patch replaces all register_ioport* with the new memory API. It permits
> to use the new Memory stuff like listener.
> 
>  
> @@ -55,7 +55,8 @@ struct pci_status {
>  
>  typedef struct PIIX4PMState {
>      PCIDevice dev;
> -    IORange ioport;
> +    MemoryRegion pm_io;
> +    bool pm_io_enabled;
>      ACPIREGS ar;
>  
>  
> -static void pm_ioport_write(IORange *ioport, uint64_t addr, unsigned width,
> -                            uint64_t val)
> +static void pm_ioport_write(void *opaque, target_phys_addr_t addr,
> +                            uint64_t val, unsigned size)
>  {

Generally we don't change argument names needlessly.

> -    PIIX4PMState *s = container_of(ioport, PIIX4PMState, ioport);
> +    PIIX4PMState *s = opaque;
>  
> -    if (width != 2) {
> +    if (size != 2) {
>          PIIX4_DPRINTF("PM write port=0x%04x width=%d val=0x%08x\n",
>                        (unsigned)addr, width, (unsigned)val);

So the printf above doesn't break.

>  }
>  
> -static const IORangeOps pm_iorange_ops = {
> +static const MemoryRegionOps pm_io_ops = {
>      .read = pm_ioport_read,
>      .write = pm_ioport_write,
> +    .endianness = DEVICE_NATIVE_ENDIAN,

DEVICE_LITTLE_ENDIAN

> +    .impl = {
> +        .min_access_size = 2,
> +        .max_access_size = 2,
> +    },
>  };
>  
> @@ -192,14 +207,22 @@ static void pm_io_space_update(PIIX4PMState *s)
>  {
>      uint32_t pm_io_base;
>  
> +    if (s->pm_io_enabled) {
> +        memory_region_del_subregion(pci_address_space_io(&s->dev), &s->pm_io);
> +        s->pm_io_enabled = false;
> +    }
> +

You can drop this code (and s->pm_io_enabled) and replace it with
memory_region_set_enabled().

>  
> @@ -380,6 +403,25 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque)
>  
>  }
>  
> +static const MemoryRegionOps smb_io_ops = {
> +    .read = smb_ioport_readb,
> +    .write = smb_ioport_writeb,
> +    .endianness = DEVICE_NATIVE_ENDIAN,

DEVICE_LITTLE_ENDIAN

> +    .impl = {
> +        .min_access_size = 1,
> +        .max_access_size = 1,
> +    },
> +};
> +
> +static const MemoryRegionOps acpi_io_ops = {
> +    .write = acpi_dbg_writel,
> +    .endianness = DEVICE_NATIVE_ENDIAN,

DEVICE_LITTLE_ENDIAN

> +    .impl = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
> +};
> +

> @@ -560,20 +613,65 @@ static uint32_t pcirmv_read(void *opaque, uint32_t addr)
>  static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
>                                  PCIHotplugState state);
>  
> -static void piix4_acpi_system_hot_add_init(PCIBus *bus, PIIX4PMState *s)
> -{
> +static const MemoryRegionOps acpi_hot_io_ops = {
> +    .read = gpe_readb,
> +    .write = gpe_writeb,
> +    .endianness = DEVICE_NATIVE_ENDIAN,

DEVICE_LITTLE_ENDIAN

> +    .impl = {
> +        .min_access_size = 1,
> +        .max_access_size = 1,
> +    },
> +};
>  
> -    register_ioport_write(GPE_BASE, GPE_LEN, 1, gpe_writeb, s);
> -    register_ioport_read(GPE_BASE, GPE_LEN, 1,  gpe_readb, s);
> -    acpi_gpe_blk(&s->ar, GPE_BASE);
> +/* PCI hot plug registers */
> +static const MemoryRegionPortio pci_hot_portio_list[] = {
> +    { 0x00, 4, 4, .read = pci_up_read, }, /* 0xae00 */
> +    { 0x04, 4, 4, .read = pci_down_read, }, /* 0xae04 */
> +    PORTIO_END_OF_LIST(),
> +};
> +
> +static const MemoryRegionOps pciej_hot_io_ops = {
> +    .read = pci_features_read,
> +    .write = pciej_write,
> +    .endianness = DEVICE_NATIVE_ENDIAN,

DEVICE_LITTLE_ENDIAN

> +    .impl = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
> +};
>  


-- 
error compiling committee.c: too many arguments to function

  parent reply	other threads:[~2012-09-03 11:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-29  3:01 [Qemu-devel] [PATCH V6 0/8] memory: unify ioport registration Julien Grall
2012-08-29  3:01 ` [Qemu-devel] [PATCH V6 1/8] isa: add isa_address_space_io Julien Grall
2012-08-29  3:01 ` [Qemu-devel] [PATCH V6 2/8] hw/acpi_piix4.c: replace register_ioport* Julien Grall
2012-09-01  7:44   ` Jan Kiszka
2012-09-03 12:56     ` Julien Grall
2012-09-03 12:56       ` Jan Kiszka
2012-09-03 13:04         ` Julien Grall
2012-09-03 11:19   ` Avi Kivity
2012-09-03 13:00     ` Julien Grall
2012-09-03 11:25   ` Avi Kivity [this message]
2012-08-29  3:01 ` [Qemu-devel] [PATCH V6 3/8] hw/cirrus_vga.c: " Julien Grall
2012-08-29  3:01 ` [Qemu-devel] [PATCH V6 4/8] hw/serial.c: " Julien Grall
2012-08-29  3:01 ` [Qemu-devel] [PATCH V6 5/8] hw/pc.c: " Julien Grall
2012-08-29  3:01 ` [Qemu-devel] [PATCH V6 6/8] hw/dma.c: " Julien Grall
2012-08-29  3:01 ` [Qemu-devel] [PATCH V6 7/8] hw/apm.c: " Julien Grall
2012-08-29  3:01 ` [Qemu-devel] [PATCH V6 8/8] smb: replace_register_ioport* Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=504493C7.7020704@redhat.com \
    --to=avi@redhat.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=afaerber@suse.de \
    --cc=jan.kiszka@siemens.com \
    --cc=julien.grall@citrix.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).