From patchwork Tue Nov 17 09:40:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56732 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1826195lbb; Tue, 17 Nov 2015 01:46:05 -0800 (PST) X-Received: by 10.31.164.216 with SMTP id n207mr2692647vke.36.1447753565829; Tue, 17 Nov 2015 01:46:05 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id b70si2022340vkf.94.2015.11.17.01.46.05 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Nov 2015 01:46:05 -0800 (PST) Received-SPF: neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=50.57.142.19; Authentication-Results: mx.google.com; spf=neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zycoo-0004TM-CW; Tue, 17 Nov 2015 09:44:54 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zycom-0004QA-86 for xen-devel@lists.xen.org; Tue, 17 Nov 2015 09:44:52 +0000 Received: from [193.109.254.147] by server-4.bemta-14.messagelabs.com id BB/6F-10715-217FA465; Tue, 17 Nov 2015 09:44:50 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-11.tower-27.messagelabs.com!1447753489!3767533!1 X-Originating-IP: [74.125.82.43] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.19.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60874 invoked from network); 17 Nov 2015 09:44:49 -0000 Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by server-11.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Nov 2015 09:44:49 -0000 Received: by wmec201 with SMTP id c201so217977233wme.0 for ; Tue, 17 Nov 2015 01:44:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dMlrFfdjPNw3LyUWJODeFaStqhHCE+D/mnYrmBHylMk=; b=v2hvr5GOdNNMsI85+qICDxu0ZJw5/0IQ4f+rowfl00+09jriEDBDUIc1Bm33RFLYu0 ZwReyXiKVqILl2qzumW25RSp9SaeejhTZx3gs+zTAbm0OJyQSkpyGBlDH0smF+WFDjVX Uroe+9Nb3l4x6LJEg8VFsgrVePBhoPsg3fIIyRyQW+dUA/2+jjggBPDgHaiYTxhTA6jS S87mre4eH9gbjZyV+jH7eMs+ycoRXwnStxooB3sQLGzIb93lJwMzDUjdXfuyp+jBV6Tk CPBn3036SB2qoLfmAsvI7mDDCHA+hUyTB6arTVd7uVEW0Zsh9NMn1gz1SpR00dqkp8Gb KzPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dMlrFfdjPNw3LyUWJODeFaStqhHCE+D/mnYrmBHylMk=; b=ihTl7puU76CMcpQ9bwxLOZT2TcxroCqwVv+8dwB878N/udaygSV5TuLdvbSskZIO1/ hANQTpcy8N0ollPZLwjUTyMniwMKAOVLv8buKjc8fkzufDzZzBvqTQBNOTARZTIN8ykl 6CIZxlwKdK9uCTDNEKLRVTkTBWdTbhpL0tYhtDz3jZpFhTDkOEBGO6AAk4hZLgd1+dFS nWoDqJem62iMMEB+leBJUSxFWiLk6QyJVwun3UKagZE0gut9mrzxFLyo3jnIeAhBv4GA SNzdIRMr2IFGjHoOcb7suf8tP5Z0XOpacy1AxuST/yZkDmpmyz2uEk7Iz1V3Hr1CMw0D GefA== X-Gm-Message-State: ALoCoQkjEJ9U/KeKXcal3QXL38RUiqcxI065HmeOfqUVfCbOAVJYmXMm+m6qQhMgQbgU3CFJdq2G X-Received: by 10.28.15.194 with SMTP id 185mr1561821wmp.9.1447753489730; Tue, 17 Nov 2015 01:44:49 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id kj3sm21712091wjb.19.2015.11.17.01.44.47 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:44:49 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, julien.grall@citrix.com, xen-devel@lists.xen.org Date: Tue, 17 Nov 2015 17:40:24 +0800 Message-Id: <1447753261-7552-26-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> Cc: mark.rutland@arm.com, hangaohuai@huawei.com, ard.biesheuvel@linaro.org, shannon.zhao@linaro.org, christoffer.dall@linaro.org, peter.huangpeng@huawei.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, linux-arm-kernel@lists.infradead.org, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org From: Shannon Zhao When constructing MADT table for Dom0, it needs to create GICC subtable according to the dom0_max_vcpus. This function could be used for get the specified entry. Signed-off-by: Shannon Zhao --- xen/drivers/acpi/tables.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/acpi.h | 4 ++++ 2 files changed, 49 insertions(+) -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c index 2fba206..3ba8bad 100644 --- a/xen/drivers/acpi/tables.c +++ b/xen/drivers/acpi/tables.c @@ -221,6 +221,51 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) } } +struct acpi_subtable_header * __init +acpi_get_entry(char *id, unsigned long table_size, + struct acpi_table_header *table_header, int entry_id, + unsigned int entry_index) +{ + struct acpi_subtable_header *entry; + unsigned int count = 0; + unsigned long table_end; + + if ( !table_size ) + return NULL; + + if ( !table_header ) + { + printk("Table header not present\n"); + return NULL; + } + + table_end = (unsigned long)table_header + table_header->length; + + /* Parse all entries looking for a match. */ + entry = (struct acpi_subtable_header *) + ((unsigned long)table_header + table_size); + + while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < + table_end) { + if (entry->length < sizeof(*entry)) { + printk(KERN_ERR PREFIX "[%4.4s:%#x] Invalid length\n", + id, entry_id); + return NULL; + } + + if (entry->type == entry_id) { + if (count == entry_index) + return entry; + count++; + } + + entry = (struct acpi_subtable_header *) + ((unsigned long)entry + entry->length); + } + + return NULL; +} + int __init acpi_parse_entries(char *id, unsigned long table_size, diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index 23f8261..3339374 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -72,6 +72,10 @@ int acpi_table_init (void); int acpi_table_parse(char *id, acpi_table_handler handler); int acpi_table_parse_entries(char *id, unsigned long table_size, int entry_id, acpi_table_entry_handler handler, unsigned int max_entries); +struct acpi_subtable_header * +acpi_get_entry(char *id, unsigned long table_size, + struct acpi_table_header *table_header, int entry_id, + unsigned int entry_index); int acpi_parse_entries(char *id, unsigned long table_size, acpi_table_entry_handler handler, struct acpi_table_header *table_header, int entry_id, unsigned int max_entries);