From patchwork Wed Apr 23 13:42:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 341865 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 A515A140149 for ; Wed, 23 Apr 2014 23:43:31 +1000 (EST) Received: from localhost ([::1]:32895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcxST-0004R5-9m for incoming@patchwork.ozlabs.org; Wed, 23 Apr 2014 09:43:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcxS0-0003q2-Cq for qemu-devel@nongnu.org; Wed, 23 Apr 2014 09:43:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcxRu-0004zD-Mj for qemu-devel@nongnu.org; Wed, 23 Apr 2014 09:43:00 -0400 Received: from mail-qg0-x236.google.com ([2607:f8b0:400d:c04::236]:48773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcxRu-0004z9-IS for qemu-devel@nongnu.org; Wed, 23 Apr 2014 09:42:54 -0400 Received: by mail-qg0-f54.google.com with SMTP id q107so242045qgd.41 for ; Wed, 23 Apr 2014 06:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6LeWpw9UOQF22jiLhLjrJPBtSNOyiIT4w//wth+ZJoU=; b=n0wOddEwRO7Bq3xtU2AdwNyPGMIChHEoLO1KDplcX3XEhex9nEcliutZeXrwHrWl1c b1uiKjXQpg0o/NRvV9rzPhbqeudD6AhTh1r/YhYRu5pEdRq2RwjmpfvcIh/kp8r5Bgqx EsrtrpwQiv024J5L7W8WBPo2zamFon8/bTzNpz/fIqh8OjMQ1Q+/BbyhT5W03w4A3X+n 91MyNgJ2HrO8ng0eAqjcg+kR1R3uWL/bbk9yWdLibXz1yBOd/xq2g8uyoYGQ/62xF4BR ELsc+YEChm3x+fFpT3ya9KLzjoMbEyyJMEpfZdSXpprW7sW42eYyhnaCe/PN+GqiDwV1 1gtQ== X-Received: by 10.229.96.199 with SMTP id i7mr21085284qcn.20.1398260574056; Wed, 23 Apr 2014 06:42:54 -0700 (PDT) Received: from ERROL.ini.cmu.edu (ERROL.INI.CMU.EDU. [128.2.16.43]) by mx.google.com with ESMTPSA id 104sm1157221qgq.1.2014.04.23.06.42.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Apr 2014 06:42:53 -0700 (PDT) X-Google-Original-From: "Gabriel L. Somlo" From: "Gabriel L. Somlo" To: qemu-devel@nongnu.org Date: Wed, 23 Apr 2014 09:42:36 -0400 Message-Id: <1398260562-7933-2-git-send-email-somlo@cmu.edu> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1398260562-7933-1-git-send-email-somlo@cmu.edu> References: <1398260562-7933-1-git-send-email-somlo@cmu.edu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::236 Cc: seabios@seabios.org, agraf@suse.de, armbru@redhat.com, kevin@koconnor.net, kraxel@redhat.com, lersek@redhat.com Subject: [Qemu-devel] [QEMU v8 PATCH 1/7] E820: Add interface for accessing e820 table 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 Add the following two functions: - e820_get_num_entries() - query the size of the e820 table - e820_get_entry() - grab an entry matching a given set of criteria This interface is currently necessary for creating type 19 (memory array mapped address) structures in smbios. Signed-off-by: Gabriel Somlo --- hw/i386/pc.c | 15 +++++++++++++++ include/hw/i386/pc.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 14f0d91..aefb315 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -612,6 +612,21 @@ int e820_add_entry(uint64_t address, uint64_t length, uint32_t type) return e820_entries; } +int e820_get_num_entries(void) +{ + return e820_entries; +} + +bool e820_get_entry(int idx, uint32_t type, uint64_t *address, uint64_t *length) +{ + if (idx < e820_entries && e820_table[idx].type == cpu_to_le32(type)) { + *address = le64_to_cpu(e820_table[idx].address); + *length = le64_to_cpu(e820_table[idx].length); + return true; + } + return false; +} + /* Calculates the limit to CPU APIC ID values * * This function returns the limit for the APIC ID value, so that all diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 9010246..9f26e14 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -239,6 +239,8 @@ uint16_t pvpanic_port(void); #define E820_UNUSABLE 5 int e820_add_entry(uint64_t, uint64_t, uint32_t); +int e820_get_num_entries(void); +bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); #define PC_Q35_COMPAT_1_7 \ PC_COMPAT_1_7, \