From patchwork Thu Oct 10 08:04:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 282152 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 52F4F2C00E7 for ; Thu, 10 Oct 2013 19:02:42 +1100 (EST) Received: from localhost ([::1]:45508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUBCi-0003Mc-Fp for incoming@patchwork.ozlabs.org; Thu, 10 Oct 2013 04:02:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUBCH-0003Ft-Li for qemu-devel@nongnu.org; Thu, 10 Oct 2013 04:02:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUBCB-0007XJ-Dx for qemu-devel@nongnu.org; Thu, 10 Oct 2013 04:02:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUBCB-0007XD-5L for qemu-devel@nongnu.org; Thu, 10 Oct 2013 04:02:07 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9A825NU005698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Oct 2013 04:02:05 -0400 Received: from redhat.com (vpn1-5-5.ams2.redhat.com [10.36.5.5]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r9A821bV016568; Thu, 10 Oct 2013 04:02:02 -0400 Date: Thu, 10 Oct 2013 11:04:30 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Anthony Liguori Message-ID: <1381392240-6133-2-git-send-email-mst@redhat.com> References: <1381392240-6133-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1381392240-6133-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, imammedo@redhat.com, afaerber@suse.de, kraxel@redhat.com Subject: [Qemu-devel] [PATCH 1/3] acpi: add interface to access user-installed tables 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 Also add a new API to install builtin tables, so that we can distinguish between the two. Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi.h | 4 ++++ hw/acpi/core.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index 51733d3..6bbcb17 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -165,6 +165,10 @@ extern int acpi_enabled; extern char unsigned *acpi_tables; extern size_t acpi_tables_len; +uint8_t *acpi_table_first(void); +uint8_t *acpi_table_next(uint8_t *current); +unsigned acpi_table_len(void *current); void acpi_table_add(const QemuOpts *opts, Error **errp); +void acpi_table_add_builtin(const QemuOpts *opts, Error **errp); #endif /* !QEMU_HW_ACPI_H */ diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 7467b88..4d25d8e 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -309,6 +309,46 @@ out: error_propagate(errp, err); } +static bool acpi_table_builtin = false; + +void acpi_table_add_builtin(const QemuOpts *opts, Error **errp) +{ + acpi_table_builtin = true; + acpi_table_add(opts, errp); +} + +unsigned acpi_table_len(void *current) +{ + struct acpi_table_header *hdr = current - sizeof(hdr->_length); + return hdr->_length; +} + +static +void *acpi_table_hdr(void *h) +{ + struct acpi_table_header *hdr = h; + return &hdr->sig; +} + +uint8_t *acpi_table_first(void) +{ + if (acpi_table_builtin || !acpi_tables) { + return NULL; + } + return acpi_table_hdr(acpi_tables + ACPI_TABLE_PFX_SIZE); +} + +uint8_t *acpi_table_next(uint8_t *current) +{ + uint8_t *next = current + acpi_table_len(current); + + if (next - acpi_tables >= acpi_tables_len) { + return NULL; + } else { + return acpi_table_hdr(next); + } +} + static void acpi_notify_wakeup(Notifier *notifier, void *data) { ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup);