From patchwork Mon Dec 19 22:46:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ben@skyportsystems.com X-Patchwork-Id: 707269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3tjGKq0B50z9t25 for ; Tue, 20 Dec 2016 09:48:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=skyportsystems.com header.i=@skyportsystems.com header.b="Y6ZQg3Eh"; dkim-atps=neutral Received: from localhost ([::1]:48117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJ6jH-0006cr-8J for incoming@patchwork.ozlabs.org; Mon, 19 Dec 2016 17:48:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJ6hf-0004nw-Gy for qemu-devel@nongnu.org; Mon, 19 Dec 2016 17:46:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJ6hc-0008Aj-FX for qemu-devel@nongnu.org; Mon, 19 Dec 2016 17:46:43 -0500 Received: from mail-io0-x22e.google.com ([2607:f8b0:4001:c06::22e]:34759) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cJ6hc-0008AP-BV for qemu-devel@nongnu.org; Mon, 19 Dec 2016 17:46:40 -0500 Received: by mail-io0-x22e.google.com with SMTP id p42so165412081ioo.1 for ; Mon, 19 Dec 2016 14:46:40 -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=Y6ZQg3Ehm/WJDvgnZXi2t7NsHu10de+LbxPCmkjGkP0SHDX0i4fQh+DNXq4b9qOQ2t a6t3p8Ui9mk0TnxG//RMe+t5o8mlzkw0qi8/xcdgZmNBEVObVbM39ArwvtF8j5fSTGFU C3FfeSIhbQF+pbRRr8NoZmtawbJkhpxT7bTn8= 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=JyATurpLdHP5jvVXf+5dpyd51g4e5xSDUCT8F7kYeXc4XEj0qVLuOMiVwUjN7EU1Im A2tQMSbW57JJGqxMIrJJc3JUFZkOk9E1JFq9ja3ySOIQVFRqnm2BtMMynC3ybFcCO7RI MgJxipJw2hu3Q1KHlGC1N6zsLsLVfp15Pgca2STmkSMvajrnYE4K2E5WDHUW3tG3A8Wt 8LeNSm0CFTmSfkvHmYFOfr3k8+q31+kJQ3nZKCYVeXsQXR8X+ZZkL/rgbSkepyEl+QUO DF6LsdjNPGx+9MBXjZuNvD/szu6xo84U1RZkIi30VCqkJTvH0WyknzR8bcumlq6rfvAi BH6Q== X-Gm-Message-State: AIkVDXJvEiOR8o+7cOmzPsU80Istd7saF+eekyqy63EAryOYUWy6phKRwETGabLJ4QtP1Aoz X-Received: by 10.107.59.15 with SMTP id i15mr18229407ioa.79.1482187599687; Mon, 19 Dec 2016 14:46:39 -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 p20sm7773759itc.8.2016.12.19.14.46.39 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Dec 2016 14:46:39 -0800 (PST) From: ben@skyportsystems.com To: qemu-devel@nongnu.org Date: Mon, 19 Dec 2016 14:46:31 -0800 Message-Id: <8f8971ae6feb51f445e50f65ad70d276b1ac231e.1482187052.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:4001:c06::22e Subject: [Qemu-devel] [PATCH 2/5] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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);