From patchwork Fri Dec 19 02:02:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 422688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A3944140082 for ; Fri, 19 Dec 2014 13:03:59 +1100 (AEDT) Received: from localhost ([::1]:56278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1mv7-0002Qd-H5 for incoming@patchwork.ozlabs.org; Thu, 18 Dec 2014 21:03:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muK-0000w2-TF for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1muE-0002f6-C9 for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muE-0002ek-2X for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:02 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBJ22xMM007466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 18 Dec 2014 21:02:59 -0500 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBJ22lHw015753; Thu, 18 Dec 2014 21:02:57 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 19 Dec 2014 02:02:02 +0000 Message-Id: <1418954562-13716-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1418954562-13716-1-git-send-email-imammedo@redhat.com> References: <1418954562-13716-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, drjones@redhat.com, claudio.fontana@huawei.com, mst@redhat.com Subject: [Qemu-devel] [RFC 07/47] acpi: factor out ACPI const int packing out build_append_value() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org it will be reused for adding a plain integer value into AML. Signed-off-by: Igor Mammedov --- hw/acpi/acpi_gen_utils.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c index cfccb42..36d7a47 100644 --- a/hw/acpi/acpi_gen_utils.c +++ b/hw/acpi/acpi_gen_utils.c @@ -204,24 +204,8 @@ void build_extop_package(GArray *package, uint8_t op) void build_append_value(GArray *table, uint32_t value, int size) { - uint8_t prefix; int i; - switch (size) { - case 1: - prefix = 0x0A; /* BytePrefix */ - break; - case 2: - prefix = 0x0B; /* WordPrefix */ - break; - case 4: - prefix = 0x0C; /* DWordPrefix */ - break; - default: - assert(0); - return; - } - build_append_byte(table, prefix); for (i = 0; i < size; ++i) { build_append_byte(table, value & 0xFF); value = value >> 8; @@ -235,10 +219,13 @@ void build_append_int(GArray *table, uint32_t value) } else if (value == 0x01) { build_append_byte(table, 0x01); /* OneOp */ } else if (value <= 0xFF) { + build_append_byte(table, 0x0A); /* BytePrefix */ build_append_value(table, value, 1); } else if (value <= 0xFFFF) { + build_append_byte(table, 0x0B); /* WordPrefix */ build_append_value(table, value, 2); } else { + build_append_byte(table, 0x0C); /* DWordPrefix */ build_append_value(table, value, 4); } }