From mboxrd@z Thu Jan 1 00:00:00 1970 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 Date: Sun, 7 Jul 2013 18:42:38 +0300 From: "Michael S. Tsirkin" 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1373211589-8097-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/5] pmm: add a way to test whether memory is in FSEG List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: seabios@seabios.org Cc: qemu-devel@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 -- MST