From patchwork Sun Jul 7 15:42:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 257342 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F35642C009A for ; Mon, 8 Jul 2013 01:42:05 +1000 (EST) Received: from localhost ([::1]:54002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uvr6B-0002gJ-Qe for incoming@patchwork.ozlabs.org; Sun, 07 Jul 2013 11:42:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uvr5c-0002Y2-Ln for qemu-devel@nongnu.org; Sun, 07 Jul 2013 11:41:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uvr5Z-0000DX-KW for qemu-devel@nongnu.org; Sun, 07 Jul 2013 11:41:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18506) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uvr5Z-0000DR-BB for qemu-devel@nongnu.org; Sun, 07 Jul 2013 11:41:25 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r67FfNt8014639 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 7 Jul 2013 11:41:24 -0400 Received: from redhat.com (vpn1-7-187.ams2.redhat.com [10.36.7.187]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r67FfMxM023443; Sun, 7 Jul 2013 11:41:22 -0400 Date: Sun, 7 Jul 2013 18:42:38 +0300 From: "Michael S. Tsirkin" To: seabios@seabios.org Message-ID: <1373211589-8097-3-git-send-email-mst@redhat.com> References: <1373211589-8097-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1373211589-8097-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v2 2/5] pmm: add a way to test whether memory is in FSEG 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 Will be handy for looking for RSDP. Signed-off-by: Michael S. Tsirkin --- src/pmm.c | 24 ++++++++++++++++++------ src/util.h | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/pmm.c b/src/pmm.c index 8f993fd..8bd8983 100644 --- a/src/pmm.c +++ b/src/pmm.c @@ -120,15 +120,23 @@ addSpace(struct zone_s *zone, void *start, void *end) // Search all zones for an allocation obtained from allocSpace() static struct allocinfo_s * +findAllocInZone(struct zone_s *zone, void *data) +{ + struct allocinfo_s *info; + hlist_for_each_entry(info, &zone->head, node) + if (info->data == data) + return info; + return NULL; +} + +static struct allocinfo_s * findAlloc(void *data) { int i; - for (i=0; ihead, node) { - if (info->data == data) - return info; - } + for (i = 0; i < ARRAY_SIZE(Zones); i++) { + struct allocinfo_s *info = findAllocInZone(Zones[i], data); + if (info) + return info; } return NULL; } @@ -241,6 +249,10 @@ pmm_find(u32 handle) return NULL; } +int pmm_test_fseg(void *data) +{ + return !!findAllocInZone(&ZoneFSeg, data); +} /**************************************************************** * 0xc0000-0xf0000 management diff --git a/src/util.h b/src/util.h index 7b50c38..44e1c1a 100644 --- a/src/util.h +++ b/src/util.h @@ -378,6 +378,7 @@ void malloc_init(void); void malloc_prepboot(void); void *pmm_malloc(struct zone_s *zone, u32 handle, u32 size, u32 align); int pmm_free(void *data); +int pmm_test_fseg(void *data); void pmm_init(void); void pmm_prepboot(void); #define PMM_DEFAULT_HANDLE 0xFFFFFFFF