From patchwork Mon Jan 16 19:20:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ben@skyportsystems.com X-Patchwork-Id: 9519347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C93A6020B for ; Mon, 16 Jan 2017 19:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E47A2823E for ; Mon, 16 Jan 2017 19:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61EEC2833F; Mon, 16 Jan 2017 19:23:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D91E72823E for ; Mon, 16 Jan 2017 19:23:00 +0000 (UTC) Received: from localhost ([::1]:59054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTCrs-0003x7-0w for patchwork-qemu-devel@patchwork.kernel.org; Mon, 16 Jan 2017 14:23:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTCq4-0002Td-Ow for qemu-devel@nongnu.org; Mon, 16 Jan 2017 14:21:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cTCq3-0007Hb-0C for qemu-devel@nongnu.org; Mon, 16 Jan 2017 14:21:08 -0500 Received: from mail-pf0-x230.google.com ([2607:f8b0:400e:c00::230]:35841) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cTCq2-0007HQ-QX for qemu-devel@nongnu.org; Mon, 16 Jan 2017 14:21:06 -0500 Received: by mail-pf0-x230.google.com with SMTP id 189so55491815pfu.3 for ; Mon, 16 Jan 2017 11:21:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skyportsystems.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=V7vhA0I9bllcuhmkIeig1Ad4Ycrii1rP7m1h0m1oQlY=; b=0VDJGLqLrioB9cfo/8ptK+zeZXomVa2SjCXN6413OF+g9PVIWLYTnB4gWGZN8v0e7N Ltvb4IvHjmOWVwWWJWNKqmWGS5TA9PuWzZfuMy4MfeQH850N/ZQlgdn/L307jPFekW6w OajGfPSSRHX8rLHzMflMN3fdHW6wE6QSz2THQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=V7vhA0I9bllcuhmkIeig1Ad4Ycrii1rP7m1h0m1oQlY=; b=md0R/rnW+eVbKXOFRbCBs5ESxWCIWu/AxwiuTzqrpKsXgytuEAl2++DpABm7V002SZ 1G8MhlrcqnEw8DWIW/C5OH6r4d7hugNj/+fnav8YfdeR1lPUpFqRoK6GSMANx/QqY5v+ ZSieMz2PyhzRgqALftCgnfel0ZwXWKvLXwfeq7KFF6sfnE1kWDmJfdJQ88K0BxaOsTYb /9cmA761+Dal5cYGJYfUFUIi3ZTSjVYmrPIyHxLZTP7bYkLZRNpphYmzeGMDcM4roMgL I1R6HIgLc3u7OkadE/ThmqbmWHxlO++Su9Iq8D8L/9poEsQhOSxWrYrY6pEjBFLXJzp/ VpHw== X-Gm-Message-State: AIkVDXJR4FS11i1pjn4KLu8/1eeh/WCfa+Y97PFYIHkHlS1SHJ4nWPcvZilxetGiuW8l3Vdj X-Received: by 10.84.160.203 with SMTP id v11mr3370023plg.133.1484594465971; Mon, 16 Jan 2017 11:21:05 -0800 (PST) Received: from Arrow.corp.skyportsystems.com (67-207-112-138.static.wiline.com. [67.207.112.138]) by smtp.gmail.com with ESMTPSA id w76sm43886299pfd.74.2017.01.16.11.21.05 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Jan 2017 11:21:05 -0800 (PST) From: ben@skyportsystems.com To: qemu-devel@nongnu.org Date: Mon, 16 Jan 2017 11:20:54 -0800 Message-Id: <555bb80fd172974474a90f832b76f63bb98c512b.1484594095.git.ben@skyportsystems.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::230 Subject: [Qemu-devel] [PATCH v2 2/6] ACPI: Add a function for building named qword entries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Warren Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Warren Signed-off-by: Ben Warren --- hw/acpi/aml-build.c | 28 ++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index b2a1e40..dc4edc2 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -285,6 +285,34 @@ build_append_named_dword(GArray *array, const char *name_format, ...) return offset; } +/* + * Build NAME(XXXX, 0x00000000) where 0x00000000 is encoded as a qword, + * and return the offset to 0x00000000 for runtime patching. + * + * Warning: runtime patching is best avoided. Only use this as + * a replacement for DataTableRegion (for guests that don't + * support it). + */ +int +build_append_named_qword(GArray *array, const char *name_format, ...) +{ + int offset; + va_list ap; + + build_append_byte(array, 0x08); /* NameOp */ + va_start(ap, name_format); + build_append_namestringv(array, name_format, ap); + va_end(ap); + + build_append_byte(array, 0x0E); /* QWordPrefix */ + + offset = array->len; + build_append_int_noprefix(array, 0x00000000, 8); + assert(array->len == offset + 8); + + return offset; +} + static GPtrArray *alloc_list; static Aml *aml_alloc(void) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 559326c..dbf63cf 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -385,6 +385,10 @@ int build_append_named_dword(GArray *array, const char *name_format, ...) GCC_FMT_ATTR(2, 3); +int +build_append_named_qword(GArray *array, const char *name_format, ...) +GCC_FMT_ATTR(2, 3); + void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags);