From: "Michael S. Tsirkin" <mst@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws, kraxel@redhat.com
Subject: Re: [Qemu-devel] [RFC 4/9] acpi: replace opencoded opcodes with defines
Date: Sun, 16 Feb 2014 14:02:17 +0200 [thread overview]
Message-ID: <20140216120217.GC30056@redhat.com> (raw)
In-Reply-To: <1391777496-3882-5-git-send-email-imammedo@redhat.com>
On Fri, Feb 07, 2014 at 01:51:31PM +0100, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
The reason I avoided doing this is that this
conflicts with qemu coding style which
only uses camel case for types.
So as a minimum this needs a comment
explaining that we are using the names from
ACPI spec as-is, that's why we deviate from
the coding style, to simplify matching against
that.
Something like below:
> ---
> hw/i386/acpi-build.c | 28 ++++++++++++++++++----------
> 1 files changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 6a43a7d..1dbe5ce 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -224,6 +224,14 @@ static void acpi_get_pci_info(PcPciInfo *info)
> #define ACPI_BUILD_TABLE_FILE "etc/acpi/tables"
> #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
/* Constants from ACPI spec 5.0a:
* ACPI Machine Language (AML) Specification
*/
We probably should add in spec link as well.
> +#define BytePrefix 0x0A
> +#define WordPrefix 0x0B
> +#define DWordPrefix 0x0C
Not sure about these ones.
There's a single user, and naming is different
from rest of operators which makes it
a bit confusing.
Maybe define near the user?
> +
> +#define NameOp 0x08
> +#define ScopeOp 0x10
> +#define DeviceOp 0x82
Hmm if we are doing this let's do this for all Ops.
> +
> static void
> build_header(GArray *linker, GArray *table_data,
> AcpiTableHeader *h, uint32_t sig, int len, uint8_t rev)
> @@ -364,13 +372,13 @@ static void build_append_value(GArray *table, uint32_t value, int size)
>
> switch (size) {
> case 1:
> - prefix = 0x0A; /* BytePrefix */
> + prefix = BytePrefix;
> break;
> case 2:
> - prefix = 0x0B; /* WordPrefix */
> + prefix = WordPrefix;
> break;
> case 4:
> - prefix = 0x0C; /* DWordPrefix */
> + prefix = DWordPrefix;
> break;
> default:
> assert(0);
> @@ -762,24 +770,24 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
> bool bus_hotplug_support = false;
>
> if (bus->parent_dev) {
> - op = 0x82; /* DeviceOp */
> + op = DeviceOp;
> build_append_nameseg(bus_table, "S%.02X_",
> bus->parent_dev->devfn);
> - build_append_byte(bus_table, 0x08); /* NameOp */
> + build_append_byte(bus_table, NameOp);
> build_append_nameseg(bus_table, "_SUN");
> build_append_value(bus_table, PCI_SLOT(bus->parent_dev->devfn), 1);
> - build_append_byte(bus_table, 0x08); /* NameOp */
> + build_append_byte(bus_table, NameOp);
> build_append_nameseg(bus_table, "_ADR");
> build_append_value(bus_table, (PCI_SLOT(bus->parent_dev->devfn) << 16) |
> PCI_FUNC(bus->parent_dev->devfn), 4);
> } else {
> - op = 0x10; /* ScopeOp */;
> + op = ScopeOp;
> build_append_nameseg(bus_table, "PCI0");
> }
>
> bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
> if (bsel) {
> - build_append_byte(bus_table, 0x08); /* NameOp */
> + build_append_byte(bus_table, NameOp);
> build_append_nameseg(bus_table, "BSEL");
> build_append_int(bus_table, qint_get_int(qobject_to_qint(bsel)));
> }
> @@ -962,7 +970,7 @@ build_ssdt(GArray *table_data, GArray *linker,
>
> {
> GArray *sb_scope = build_alloc_array();
> - uint8_t op = 0x10; /* ScopeOp */
> + uint8_t op = ScopeOp;
>
> build_append_nameseg(sb_scope, "_SB_");
>
> @@ -983,7 +991,7 @@ build_ssdt(GArray *table_data, GArray *linker,
> build_append_notify_method(sb_scope, "NTFY", "CP%0.02X", acpi_cpus);
>
> /* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" */
> - build_append_byte(sb_scope, 0x08); /* NameOp */
> + build_append_byte(sb_scope, NameOp);
> build_append_nameseg(sb_scope, "CPON");
>
> {
> --
> 1.7.1
next prev parent reply other threads:[~2014-02-16 11:57 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-07 12:51 [Qemu-devel] [RFC 0/9] generate dynamic _CRS for motherboard resources Igor Mammedov
2014-02-07 12:51 ` [Qemu-devel] [RFC 1/9] Revert "pc: Q35 DSDT: exclude CPU hotplug IO range from PCI bus resources" Igor Mammedov
2014-02-07 12:51 ` [Qemu-devel] [RFC 2/9] Revert "pc: PIIX DSDT: exclude CPU/PCI hotplug & GPE0 " Igor Mammedov
2014-02-07 12:51 ` [Qemu-devel] [RFC 3/9] Partial revert "pc: ACPI: expose PRST IO range via _CRS" Igor Mammedov
2014-02-07 12:51 ` [Qemu-devel] [RFC 4/9] acpi: replace opencoded opcodes with defines Igor Mammedov
2014-02-16 12:02 ` Michael S. Tsirkin [this message]
2014-02-07 12:51 ` [Qemu-devel] [RFC 5/9] acpi: add PNP0C02 to PCI0 bus Igor Mammedov
2014-02-16 12:06 ` Michael S. Tsirkin
2014-02-07 12:51 ` [Qemu-devel] [RFC 6/9] acpi: consume GPE0 IO resources in PNP0C02 device Igor Mammedov
2014-02-16 15:20 ` Michael S. Tsirkin
2014-02-07 12:51 ` [Qemu-devel] [RFC 7/9] acpi: consume CPU hotplug IO resource " Igor Mammedov
2014-02-16 15:39 ` Michael S. Tsirkin
2014-02-07 12:51 ` [Qemu-devel] [RFC 8/9] pcihp: expose PCI hotplug MMIO base/length as properties of piix4pm Igor Mammedov
2014-02-16 15:45 ` Michael S. Tsirkin
2014-02-07 12:51 ` [Qemu-devel] [RFC 9/9] acpi: consume PCIHP IO resource in PNP0C02 device Igor Mammedov
2014-02-16 15:53 ` [Qemu-devel] [RFC 0/9] generate dynamic _CRS for motherboard resources Michael S. Tsirkin
2014-02-17 8:32 ` Gerd Hoffmann
2014-02-17 10:28 ` Michael S. Tsirkin
2014-02-17 10:46 ` Gerd Hoffmann
2014-02-17 11:05 ` Michael S. Tsirkin
2014-02-18 16:36 ` Igor Mammedov
2014-02-18 22:04 ` Laszlo Ersek
2014-02-19 8:59 ` Igor Mammedov
2014-02-17 10:33 ` Igor Mammedov
2014-02-17 11:02 ` Michael S. Tsirkin
2014-02-18 11:10 ` Igor Mammedov
2014-02-18 11:33 ` Michael S. Tsirkin
2014-02-18 16:30 ` Igor Mammedov
2014-02-17 8:29 ` Gerd Hoffmann
2014-02-18 16:48 ` Igor Mammedov
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=20140216120217.GC30056@redhat.com \
--to=mst@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=imammedo@redhat.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).