From: Igor Mammedov <imammedo@redhat.com>
To: Shannon Zhao <shannon.zhao@linaro.org>
Cc: peter.maydell@linaro.org, hangaohuai@huawei.com,
"Michael S. Tsirkin" <mst@redhat.com>,
a.spyridakis@virtualopensystems.com, claudio.fontana@huawei.com,
qemu-devel@nongnu.org, peter.huangpeng@huawei.com,
alex.bennee@linaro.org, hanjun.guo@linaro.org,
Shannon Zhao <zhaoshenglong@huawei.com>,
pbonzini@redhat.com, lersek@redhat.com,
christoffer.dall@linaro.org
Subject: Re: [Qemu-devel] [PATCH v5 19/20] hw/arm/virt-acpi-build: Add PCIe controller in ACPI DSDT table
Date: Wed, 29 Apr 2015 15:58:03 +0200 [thread overview]
Message-ID: <20150429155803.124c91c2@nial.brq.redhat.com> (raw)
In-Reply-To: <5540DE87.1020204@linaro.org>
On Wed, 29 Apr 2015 21:37:11 +0800
Shannon Zhao <shannon.zhao@linaro.org> wrote:
>
>
> On 2015/4/29 16:47, Igor Mammedov wrote:
> > On Wed, 29 Apr 2015 11:12:04 +0800
> > Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> >
> >> On 2015/4/28 23:54, Michael S. Tsirkin wrote:
> >>> On Tue, Apr 28, 2015 at 05:13:10PM +0200, Igor Mammedov wrote:
> >>>>> Here I need to set the value of buffer to 1 or 0, we could
> >>>>> createbitfield, but if we want to set the value to non one or zero and
> >>>>> the BufferSize is large, how could we do? CreateByteField? It's a little
> >>>>> complex for user.
> >>>> that's what one would have to do writing it in ASL if bits
> >>>> are flipped on/off dynamically.
> >>>>
> >>>> In ASL you also can declare buffer with static initializer
> >>>>
> >>>> Buffer (0x01) { 0x03 }
> >>>>
> >>>> and compiler is smart enough to set appropriate bits but it doesn't
> >>>> allow you to do so with large values. For example:
> >>>>
> >>>> Buffer (0x01) { 0xAABBCCDD }
> >>>>
> >>>> gives error:
> >>>> Error 6139 - Constant out of range ^ (0xAABBCCDD, allowable: 0x0-0xFF)
> >>>>
> >>>> If one wants to manipulate specific fields in Buffer, ASL has
> >>>> a bunch of CreateFOOField operators, so lets follow spec and use
> >>>> API consistently to avoid confusion.
> >>>>
> >>>> BTW:
> >>>> packaging value as int (even without prefix) is wrong since
> >>>> its LE encoding will shuffle bytes and you won't get bits in
> >>>> positions that you expect if value is more than 1 byte.
> >>>
> >>> I don't care about ASL, we are writing in C
> >>> But AML is same:
> >>> DefBuffer := BufferOp PkgLength BufferSize ByteList
> >>> BufferOp := 0x11
> >>> BufferSize := TermArg => Integer
> >>>
> >>> So really just a bytelist.
> >>> We don't have any users for aml_buffer, maybe just add
> >>> const uint8_t *bytes, unsigned len as parameters.
> >>>
> >>
> >> Agree. It's consistent with the spec. If want to modify the value, could
> >> use CreateFOOField.
> >>
> >> So use following fuction to initialize Buffer?
> >>
> >> /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefBuffer */
> >> Aml *aml_buffer(int buffer_size, uint8_t *byte_list)
> >> {
> >> int i;
> >> Aml *var = aml_bundle(0x11 /* BufferOp */, AML_BUFFER);
> >> for (i = 0; i < buffer_size; i++) {
> >> build_append_byte(var->buf, *(byte_list + i));
> >> }
> >> return var;
> >> }
> > maybe
> >
> > Aml *aml_buffer_initialized(int buffer_size, uint8_t *byte_list);
> > Aml *aml_buffer(int buffer_size);
> >
> > the second one is needed for implementing code like:
> > Name(BUFF, Buffer(4){}) // Create SerialBus data buffer as BUFF
> > CreateByteField(BUFF, 0x00, STAT) // STAT = Status (Byte)
> > CreateWordField(BUFF, 0x02, DATA) // DATA = Data (Byte)
> >
> > and could reuse aml_buffer_initialized() to reserve space.
> >
>
> maybe we could use only one. For the uninitialized buffer we can pass
> byte_list as NULL and within aml_buffer check byte_list, if byte_list is
> NULL, just reserve space.
works for me with doc comment
>
> /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefBuffer */
> Aml *aml_buffer(int buffer_size, uint8_t *byte_list)
> {
> int i;
> Aml *var = aml_bundle(0x11 /* BufferOp */, AML_BUFFER);
>
> for (i = 0; i < buffer_size; i++) {
> if (byte_list == NULL)
> build_append_byte(var->buf, 0);
> else
> build_append_byte(var->buf, *(byte_list + i));
> }
>
> return var;
> }
>
> >>
> >>> Would that be enough?
> >>>
> >>>
> >>>>>
> >>>>>> ifctx1 = aml_if(aml_equal(aml_arg(2), aml_int(0)));
> >>>>>> aml_append(ifctx1, aml_store(aml_name("FNEN", aml_int(1)));
> >>>>>> ...
> >>>>>> /* create bit field for every supported function if supported */
> >>>>>> ...
> >>>>>> aml_append(method, aml_return(aml_name("RET")));
> >>>>>>
> >>>>>>
> >>>>>>>
> >>>>>>>>>
> >>>>>>>>>> + aml_append(ifctx1, aml_return(buf));
> >>>>>>>>>> + aml_append(ifctx, ifctx1);
> >>>>>>>>>> + aml_append(method, ifctx);
> >>>>>>>>>> +
> >>>>>>>>>> + buf = aml_buffer();
> >>>>>>>>>> + build_append_int_noprefix(buf->buf, 0x00, 1);
> >>>>>>>>>> + aml_append(method, aml_return(buf));
> >>>>>>>>>> + aml_append(dev, method);
> >>>>>>>>>> +
> >>>>>>>>>> + Aml *dev_rp0 = aml_device("%s", "RP0");
> >>>>>>>>>> + aml_append(dev_rp0, aml_name_decl("_ADR", aml_int(0)));
> >>>>>>>>>> + aml_append(dev, dev_rp0);
> >>>>>>>>>> + aml_append(scope, dev);
> >>>>>>>>>> +}
> >>>>>>>>>> +
> >>>>>>>>>> /* RSDP */
> >>>>>>>>>> static GArray *
> >>>>>>>>>> build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)
> >>>>>>>>>> @@ -318,6 +468,8 @@ build_dsdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> >>>>>>>>>> acpi_dsdt_add_flash(scope, info->flash_memmap);
> >>>>>>>>>> acpi_dsdt_add_virtio(scope, info->virtio_mmio_memmap,
> >>>>>>>>>> info->virtio_mmio_irq, info->virtio_mmio_num);
> >>>>>>>>>> + acpi_dsdt_add_pci(scope, guest_info->pcie_info);
> >>>>>>>>>> +
> >>>>>>>>>> aml_append(dsdt, scope);
> >>>>>>>>>>
> >>>>>>>>>> /* copy AML table into ACPI tables blob and patch header there */
> >>>>>>>>
> >>>>>>>> .
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>> .
> >>>>>>
> >>>>>
> >>>>>
> >>>
> >>> .
> >>>
> >>
> >>
> >
next prev parent reply other threads:[~2015-04-29 13:58 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-15 13:24 [Qemu-devel] [PATCH v5 00/20] Generate ACPI v5.1 tables and expose them to guest over fw_cfg on ARM Shannon Zhao
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 01/20] hw/i386: Move ACPI header definitions in an arch-independent location Shannon Zhao
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 02/20] hw/i386/acpi-build: move generic acpi building helpers into dedictated file Shannon Zhao
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 03/20] hw/arm/virt-acpi-build: Basic framework for building ACPI tables on ARM Shannon Zhao
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 04/20] hw/acpi/aml-build: Add aml_memory32_fixed() term Shannon Zhao
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 05/20] hw/acpi/aml-build: Add aml_interrupt() term Shannon Zhao
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 06/20] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices Shannon Zhao
2015-05-04 9:58 ` Igor Mammedov
2015-05-04 11:11 ` Shannon Zhao
2015-05-04 13:04 ` Igor Mammedov
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 07/20] hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers Shannon Zhao
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 08/20] hw/arm/virt-acpi-build: Generate MADT table Shannon Zhao
2015-05-04 10:21 ` Igor Mammedov
2015-05-04 11:16 ` Shannon Zhao
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 09/20] hw/arm/virt-acpi-build: Generate GTDT table Shannon Zhao
2015-04-15 13:24 ` [Qemu-devel] [PATCH v5 10/20] hw/arm/virt-acpi-build: Generate RSDT table Shannon Zhao
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 11/20] hw/arm/virt-acpi-build: Generate RSDP table Shannon Zhao
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 12/20] hw/arm/virt-acpi-build: Add PCIe info and generate MCFG table Shannon Zhao
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 13/20] hw/acpi/aml-build: Add ToUUID macro Shannon Zhao
2015-04-28 6:54 ` Igor Mammedov
2015-04-28 7:46 ` Shannon Zhao
2015-04-28 8:15 ` Igor Mammedov
2015-04-28 8:52 ` Shannon Zhao
2015-04-28 9:35 ` Igor Mammedov
2015-04-28 9:48 ` Shannon Zhao
2015-04-29 13:41 ` Shannon Zhao
2015-05-04 9:22 ` Igor Mammedov
2015-05-04 9:30 ` Shannon Zhao
2015-05-04 10:53 ` Igor Mammedov
2015-04-28 8:08 ` Shannon Zhao
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 14/20] hw/acpi/aml-build: Add aml_or() term Shannon Zhao
2015-04-28 6:56 ` Igor Mammedov
2015-04-28 7:12 ` Shannon Zhao
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 15/20] hw/acpi/aml-build: Add aml_not() term Shannon Zhao
2015-05-05 2:45 ` Shannon Zhao
2015-05-05 8:26 ` Igor Mammedov
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 16/20] hw/acpi/aml-build: Add aml_else() term Shannon Zhao
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 17/20] hw/acpi/aml-build: Add aml_create_dword_field() term Shannon Zhao
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 18/20] hw/acpi/aml-build: Add aml_dword_io() term Shannon Zhao
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 19/20] hw/arm/virt-acpi-build: Add PCIe controller in ACPI DSDT table Shannon Zhao
2015-04-28 8:42 ` Igor Mammedov
2015-04-28 8:47 ` Michael S. Tsirkin
2015-04-28 9:06 ` Shannon Zhao
2015-04-28 9:54 ` Igor Mammedov
2015-04-28 12:57 ` Shannon Zhao
2015-04-28 15:13 ` Igor Mammedov
2015-04-28 15:54 ` Michael S. Tsirkin
2015-04-29 3:12 ` Shannon Zhao
2015-04-29 8:47 ` Igor Mammedov
2015-04-29 13:37 ` Shannon Zhao
2015-04-29 13:58 ` Igor Mammedov [this message]
2015-04-15 13:25 ` [Qemu-devel] [PATCH v5 20/20] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables Shannon Zhao
2015-04-28 2:49 ` [Qemu-devel] [PATCH v5 00/20] Generate ACPI v5.1 tables and expose them to guest over fw_cfg on ARM Shannon Zhao
2015-04-28 5:20 ` Michael S. Tsirkin
2015-04-28 6:13 ` Shannon Zhao
2015-04-28 6:56 ` Michael S. Tsirkin
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=20150429155803.124c91c2@nial.brq.redhat.com \
--to=imammedo@redhat.com \
--cc=a.spyridakis@virtualopensystems.com \
--cc=alex.bennee@linaro.org \
--cc=christoffer.dall@linaro.org \
--cc=claudio.fontana@huawei.com \
--cc=hangaohuai@huawei.com \
--cc=hanjun.guo@linaro.org \
--cc=lersek@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhao@linaro.org \
--cc=zhaoshenglong@huawei.com \
/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).