From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhGza-0004xX-V9 for qemu-devel@nongnu.org; Mon, 05 May 2014 07:23:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhGzU-0000Rk-EE for qemu-devel@nongnu.org; Mon, 05 May 2014 07:23:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhGzU-0000RN-5I for qemu-devel@nongnu.org; Mon, 05 May 2014 07:23:24 -0400 From: Gerd Hoffmann Date: Mon, 5 May 2014 13:23:11 +0200 Message-Id: <1399288996-9721-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1399288996-9721-1-git-send-email-kraxel@redhat.com> References: <1399288996-9721-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL v2 2/7] E820: Add interface for accessing e820 table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Gabriel L. Somlo" , "Michael S. Tsirkin" , Gabriel Somlo , Anthony Liguori , Gerd Hoffmann From: "Gabriel L. Somlo" 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 Signed-off-by: Gerd Hoffmann --- 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, \ -- 1.8.3.1