qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 50/74] pc: acpi: move FDC0 device from DSDT to SSDT
Date: Mon, 21 Dec 2015 13:42:39 +0100	[thread overview]
Message-ID: <20151221134239.0a92df7f@nial.brq.redhat.com> (raw)
In-Reply-To: <20151219194455.GB25389@redhat.com>

On Sat, 19 Dec 2015 21:44:55 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Thu, Dec 10, 2015 at 12:41:44AM +0100, Igor Mammedov wrote:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  hw/i386/acpi-build.c      | 38 ++++++++++++++++++++++++++++++++------
> >  hw/i386/acpi-dsdt-isa.dsl | 18 ------------------
> >  2 files changed, 32 insertions(+), 24 deletions(-)
> > 
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index e5ec6af..2f0f2e1 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1173,17 +1173,34 @@ static void build_hpet_aml(Aml *table)
> >  
> >  static Aml *
> >  build_eisa_device_aml(const char *name, const char *hid, Aml *crs,
> > -                      bool have_sta)
> > +                      bool have_sta, const char *present_field)
> 
> At this point, the number of arguments is getting ridiculous.
> I think you should give it up, and write a function
> per device type, even if there's a minor code duplication
> as a result.
> 
> As a bonus, we will get reasonably readable function
> names, e.g.  build_floppy_controller()
> 
> >  {
> >      Aml *dev;
> >      Aml *method;
> > -    Aml *a_device_present = aml_int(0x0f);
> >  
> >      dev = aml_device("%s", name);
> >      aml_append(dev, aml_name_decl("_HID", aml_eisaid(hid)));
> >      if (have_sta) {
> > +        Aml *if_ctx;
> > +        Aml *else_ctx;
> > +        Aml *a_zero = aml_int(0);
> > +        Aml *a_is_present = aml_local(0);
> > +        Aml *a_device_present = aml_int(0x0f);
> > +        Aml *a_device_not_present = aml_int(0x00);
> > +
> 
> What does a_ prefix mean here?
it's used to distinguish aml variables.

> 
> >          method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> > -        aml_append(method, aml_return(a_device_present));
> > +        if (!present_field) {
> > +            aml_append(method, aml_return(a_device_present));
> > +        } else {
> > +            aml_append(method,
> > +                aml_store(aml_name("%s", present_field), a_is_present));
> > +            if_ctx = aml_if(aml_equal(a_is_present, a_zero));
> > +            aml_append(if_ctx, aml_return(a_device_not_present));
> > +            aml_append(method, if_ctx);
> > +            else_ctx = aml_else();
> > +            aml_append(else_ctx, aml_return(a_device_present));
> > +            aml_append(method, else_ctx);
> > +        }
> >          aml_append(dev, method);
> >      }
> >      aml_append(dev, aml_name_decl("_CRS", crs));
> > @@ -1201,19 +1218,28 @@ static void build_isa_devices_aml(Aml *table)
> >      aml_append(crs, aml_irq_no_flags(8));
> >      aml_append(crs, aml_io(AML_DECODE16, 0x0072, 0x0072, 0x02, 0x06));
> >      aml_append(scope, build_eisa_device_aml(
> > -        "RTC", "PNP0B00", crs, false));
> > +        "RTC", "PNP0B00", crs, false, NULL));
> >  
> >      crs = aml_resource_template();
> >      aml_append(crs, aml_io(AML_DECODE16, 0x0060, 0x0060, 0x01, 0x01));
> >      aml_append(crs, aml_io(AML_DECODE16, 0x0064, 0x0064, 0x01, 0x01));
> >      aml_append(crs, aml_irq_no_flags(1));
> >      aml_append(scope, build_eisa_device_aml(
> > -        "KBD", "PNP0303", crs, true));
> > +        "KBD", "PNP0303", crs, true, NULL));
> >  
> >      crs = aml_resource_template();
> >      aml_append(crs, aml_irq_no_flags(12));
> >      aml_append(scope, build_eisa_device_aml(
> > -        "MOU", "PNP0F13", crs, true));
> > +        "MOU", "PNP0F13", crs, true, NULL));
> > +
> > +    crs = aml_resource_template();
> > +    aml_append(crs, aml_io(AML_DECODE16, 0x03F2, 0x03F2, 0x00, 0x04));
> > +    aml_append(crs, aml_io(AML_DECODE16, 0x03F7, 0x03F7, 0x00, 0x01));
> > +    aml_append(crs, aml_irq_no_flags(6));
> > +    aml_append(crs,
> > +        aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, 2));
> > +    aml_append(scope, build_eisa_device_aml(
> > +        "FDC0", "PNP0700", crs, true, "FDEN"));
> >  
> >      aml_append(table, scope);
> >  }
> > diff --git a/hw/i386/acpi-dsdt-isa.dsl b/hw/i386/acpi-dsdt-isa.dsl
> > index 8936271..64dd4ac 100644
> > --- a/hw/i386/acpi-dsdt-isa.dsl
> > +++ b/hw/i386/acpi-dsdt-isa.dsl
> > @@ -16,24 +16,6 @@
> >  /* Common legacy ISA style devices. */
> >  Scope(\_SB.PCI0.ISA) {
> >  
> > -    Device(FDC0) {
> > -        Name(_HID, EisaId("PNP0700"))
> > -        Method(_STA, 0, NotSerialized) {
> > -            Store(FDEN, Local0)
> > -            If (LEqual(Local0, 0)) {
> > -                Return (0x00)
> > -            } Else {
> > -                Return (0x0F)
> > -            }
> > -        }
> 
> All these guys have in common is the _STA method.
> So write a function generating one, and be done with it.
I'll try to do so.

> 
> 
> > -        Name(_CRS, ResourceTemplate() {
> > -            IO(Decode16, 0x03F2, 0x03F2, 0x00, 0x04)
> > -            IO(Decode16, 0x03F7, 0x03F7, 0x00, 0x01)
> > -            IRQNoFlags() { 6 }
> > -            DMA(Compatibility, NotBusMaster, Transfer8) { 2 }
> > -        })
> > -    }
> > -
> >      Device(LPT) {
> >          Name(_HID, EisaId("PNP0400"))
> >          Method(_STA, 0, NotSerialized) {
> > -- 
> > 1.8.3.1
> > 

  reply	other threads:[~2015-12-21 12:42 UTC|newest]

Thread overview: 165+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 23:40 [Qemu-devel] [PATCH 00/74] pc: acpi: convert DSDT to AML API and drop ASL templates support Igor Mammedov
2015-12-09 23:40 ` [Qemu-devel] [PATCH 01/74] tests: acpi: print ASL diff in verbose mode Igor Mammedov
2015-12-10 12:50   ` Marcel Apfelbaum
2015-12-22 15:28   ` Michael S. Tsirkin
2015-12-22 15:54     ` Igor Mammedov
2015-12-22 16:18       ` Michael S. Tsirkin
2015-12-22 16:36         ` Igor Mammedov
2015-12-22 16:59       ` Michael S. Tsirkin
2015-12-22 17:22         ` Igor Mammedov
2015-12-22 19:05           ` Michael S. Tsirkin
2015-12-09 23:40 ` [Qemu-devel] [PATCH 02/74] acpi: add aml_derefof Igor Mammedov
2015-12-09 23:40 ` [Qemu-devel] [PATCH 03/74] acpi: add aml_sizeof Igor Mammedov
2015-12-09 23:40 ` [Qemu-devel] [PATCH 04/74] acpi: add aml_lgreater_equal() Igor Mammedov
2015-12-10 12:52   ` Marcel Apfelbaum
2015-12-11  2:39   ` Shannon Zhao
2015-12-09 23:40 ` [Qemu-devel] [PATCH 05/74] acpi: add aml_mutex(), aml_acquire(), aml_release() Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 06/74] acpi: add aml_create_qword_field() Igor Mammedov
2015-12-10 12:53   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 07/74] acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern Igor Mammedov
2015-12-10  1:59   ` Shannon Zhao
2015-12-10 11:08     ` Igor Mammedov
2015-12-10 13:12   ` Marcel Apfelbaum
2015-12-11  2:36   ` Shannon Zhao
2015-12-09 23:41 ` [Qemu-devel] [PATCH 08/74] acpi: extend aml_add() to accept target argument Igor Mammedov
2015-12-10 12:59   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 09/74] acpi: add aml_decrement() and aml_subtract() Igor Mammedov
2015-12-10 13:01   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 10/74] acpi: add aml_call0() helper Igor Mammedov
2015-12-10 13:04   ` Marcel Apfelbaum
2015-12-10 13:41     ` Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 11/74] acpi: add aml_to_integer() Igor Mammedov
2015-12-10 13:05   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 12/74] acpi: extend aml_shiftright() to accept target argument Igor Mammedov
2015-12-10 13:08   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 13/74] acpi: add aml_alias() Igor Mammedov
2015-12-10 13:13   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 14/74] acpi: add aml_sleep() Igor Mammedov
2015-12-10 13:14   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 15/74] acpi: support serialized method Igor Mammedov
2015-12-11  2:58   ` Shannon Zhao
2015-12-09 23:41 ` [Qemu-devel] [PATCH 16/74] acpi: add aml_lor() Igor Mammedov
2015-12-10 13:25   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 17/74] acpi: add aml_lgreater() Igor Mammedov
2015-12-10 13:26   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 18/74] acpi: extend aml_field() to support LockRule Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 19/74] acpi: add aml_to_hexstring() Igor Mammedov
2015-12-10 13:41   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 20/74] acpi: add aml_to_buffer() Igor Mammedov
2015-12-10 13:42   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 21/74] acpi add aml_dma() Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 22/74] acpi: extend aml_or() to accept target argument Igor Mammedov
2015-12-10 13:43   ` Marcel Apfelbaum
2015-12-09 23:41 ` [Qemu-devel] [PATCH 23/74] acpi: extend aml_and() " Igor Mammedov
2015-12-10  2:07   ` Shannon Zhao
2015-12-10 11:16     ` Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 24/74] acpi: extend aml_interrupt() to support multiple irqs Igor Mammedov
2015-12-10  1:50   ` Shannon Zhao
2015-12-10 11:34     ` [Qemu-devel] [PATCH v2 " Igor Mammedov
2015-12-11  1:51       ` Shannon Zhao
2015-12-22 15:17   ` [Qemu-devel] [PATCH " Michael S. Tsirkin
2015-12-22 15:37     ` Igor Mammedov
2015-12-22 15:58       ` Michael S. Tsirkin
2015-12-22 16:19         ` Igor Mammedov
2015-12-22 16:43           ` Michael S. Tsirkin
2015-12-09 23:41 ` [Qemu-devel] [PATCH 25/74] pc: acpi: memhp: prepare context in SSDT for moving memhp DSDT code Igor Mammedov
2015-12-10 12:45   ` Marcel Apfelbaum
2015-12-10 13:43     ` Igor Mammedov
2015-12-16 13:25   ` Marcel Apfelbaum
2015-12-16 14:25     ` Igor Mammedov
2015-12-17 12:14       ` Marcel Apfelbaum
2015-12-17 13:47         ` Igor Mammedov
2015-12-17 14:12           ` Marcel Apfelbaum
2015-12-17 16:59             ` Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 26/74] pc: acpi: memhp: move MHPD._STA method into SSDT Igor Mammedov
2015-12-16 12:08   ` Marcel Apfelbaum
2015-12-16 14:30     ` Igor Mammedov
2015-12-16 14:47   ` [Qemu-devel] [PATCH v2 " Igor Mammedov
2015-12-20 10:32     ` Marcel Apfelbaum
2015-12-20 13:41     ` Michael S. Tsirkin
2015-12-21 10:52       ` Igor Mammedov
2015-12-21 17:31       ` Igor Mammedov
2015-12-22 15:11         ` Michael S. Tsirkin
2015-12-22 15:45           ` Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 27/74] pc: acpi: memhp: move MHPD.MLCK mutex " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 28/74] pc: acpi: memhp: move MHPD.MSCN method " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 29/74] pc: acpi: memhp: move MHPD.MRST " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 30/74] pc: acpi: memhp: move MHPD.MPXM " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 31/74] pc: acpi: memhp: move MHPD.MOST " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 32/74] pc: acpi: memhp: move MHPD.MEJ0 " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 33/74] pc: acpi: memhp: move MHPD.MCRS " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 34/74] pc: acpi: memhp: move MHPD Device " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 35/74] pc: acpi: factor out memhp code from build_ssdt() into separate function Igor Mammedov
2015-12-19 20:18   ` Michael S. Tsirkin
2015-12-21 11:01     ` Igor Mammedov
2015-12-21 11:38       ` Michael S. Tsirkin
2015-12-09 23:41 ` [Qemu-devel] [PATCH 36/74] pc: acpi: memhp: move \_GPE._E03 into SSDT Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 37/74] pc: acpi: memhp: drop not needed stringify(MEMORY_foo) usage Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 38/74] pc: acpi: drop unused CPU_STATUS_LEN from DSDT Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 39/74] pc: acpi: cpuhp: move CPEJ() method to SSDT Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 40/74] pc: acpi: cpuhp: move CPMA() method into SSDT Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 41/74] pc: acpi: cpuhp: move CPST() " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 42/74] pc: acpi: cpuhp: move PRSC() " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 43/74] pc: acpi: cpuhp: move \_GPE._E02() " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 44/74] pc: acpi: factor out cpu hotplug code from build_ssdt() into separate function Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 45/74] pc: acpi: move HPET from DSDT to SSDT Igor Mammedov
2015-12-19 19:50   ` Michael S. Tsirkin
2015-12-21 11:02     ` Igor Mammedov
2015-12-21 11:42       ` Michael S. Tsirkin
2015-12-09 23:41 ` [Qemu-devel] [PATCH 46/74] pc: acpi: move DBUG() " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 47/74] pc: acpi: move RTC device " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 48/74] pc: acpi: move KBD " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 49/74] pc: acpi: move MOU " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 50/74] pc: acpi: move FDC0 " Igor Mammedov
2015-12-19 19:44   ` Michael S. Tsirkin
2015-12-21 12:42     ` Igor Mammedov [this message]
2015-12-21 12:54       ` Michael S. Tsirkin
2015-12-09 23:41 ` [Qemu-devel] [PATCH 51/74] pc: acpi: move LPT " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 52/74] pc: acpi: move COM devices " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 53/74] pc: acpi: move PIIX4 isa-bridge and pm devices into SSDT Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 54/74] pc: acpi: move remaining GPE handlers " Igor Mammedov
2015-12-19 19:30   ` Michael S. Tsirkin
2015-12-19 20:34   ` Michael S. Tsirkin
2015-12-21 12:45     ` Igor Mammedov
2015-12-21 15:35     ` Igor Mammedov
2015-12-22  9:37       ` Michael S. Tsirkin
2015-12-22 14:38         ` Igor Mammedov
2015-12-22 14:47           ` Michael S. Tsirkin
2015-12-22 15:00             ` Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 55/74] pc: acpi: pci: move link devices " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 56/74] pc: acpi: piix4: move IQCR() " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 57/74] pc: acpi: piix4: move IQST() " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 58/74] pc: acpi: piix4: move PCI0._PRT() " Igor Mammedov
2015-12-10 12:32   ` Marcel Apfelbaum
2015-12-10 13:50     ` Igor Mammedov
2015-12-10 16:17     ` [Qemu-devel] [PATCH v2 " Igor Mammedov
2015-12-13 15:19       ` Marcel Apfelbaum
2015-12-14 13:20         ` Igor Mammedov
2015-12-19 19:23       ` Michael S. Tsirkin
2015-12-21 12:55         ` Igor Mammedov
2015-12-22  9:34           ` Michael S. Tsirkin
2015-12-22 14:12             ` Igor Mammedov
2015-12-22 14:52               ` Michael S. Tsirkin
2015-12-09 23:41 ` [Qemu-devel] [PATCH 59/74] pc: acpi: piix4: move remaining PCI hotplug bits " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 60/74] pc: acpi: piix4: acpi move PCI0 device to SSDT Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 61/74] pc: acpi: q35: move GSI links " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 62/74] pc: acpi: q35: move link devices " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 63/74] pc: acpi: q35: move IQCR() into SSDT Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 64/74] pc: acpi: q35: move IQST() " Igor Mammedov
2015-12-09 23:41 ` [Qemu-devel] [PATCH 65/74] pc: acpi: q35: move ISA bridge " Igor Mammedov
2015-12-09 23:42 ` [Qemu-devel] [PATCH 66/74] pc: acpi: q35: move _PRT() " Igor Mammedov
2015-12-09 23:42 ` [Qemu-devel] [PATCH 67/74] pc: acpi: q35: move PRTA routing table " Igor Mammedov
2015-12-09 23:42 ` [Qemu-devel] [PATCH 68/74] pc: acpi: q35: move PRTP " Igor Mammedov
2015-12-09 23:42 ` [Qemu-devel] [PATCH 69/74] pc: acpi: q35: move _PIC() method " Igor Mammedov
2015-12-09 23:42 ` [Qemu-devel] [PATCH 70/74] pc: acpi: q35: move PCI0._OSC() " Igor Mammedov
2015-12-09 23:42 ` [Qemu-devel] [PATCH 71/74] pc: acpi: q35: move PCI0 device definition " Igor Mammedov
2015-12-09 23:42 ` [Qemu-devel] [PATCH 72/74] pc: acpi: q35: PCST, PCSB opregions and PCIB field " Igor Mammedov
2015-12-09 23:42 ` [Qemu-devel] [PATCH 73/74] pc: acpi: switch to AML API composed DSDT Igor Mammedov
2015-12-09 23:42 ` [Qemu-devel] [PATCH 74/74] pc: acpi: remove unused ASL templates and related blobs/utils Igor Mammedov
2015-12-10 15:53 ` [Qemu-devel] [PATCH 00/74] pc: acpi: convert DSDT to AML API and drop ASL templates support Marcel Apfelbaum
2015-12-10 16:31   ` Igor Mammedov
2015-12-13 15:24     ` Marcel Apfelbaum
2015-12-10 16:44 ` Igor Mammedov
2015-12-19 20:38 ` Michael S. Tsirkin
2015-12-21 13:00   ` Igor Mammedov
2015-12-21 13:12     ` Shannon Zhao

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=20151221134239.0a92df7f@nial.brq.redhat.com \
    --to=imammedo@redhat.com \
    --cc=mst@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).