qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 2/5] pmm: add a way to test whether memory is in


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PATCH v2 2/5] pmm: add a way to test whether memory is in FSEG
Date: Sun, 7 Jul 2013 18:42:38 +0300

Will be handy for looking for RSDP.

Signed-off-by: Michael S. Tsirkin <address@hidden>
---
 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; i<ARRAY_SIZE(Zones); i++) {
-        struct allocinfo_s *info;
-        hlist_for_each_entry(info, &Zones[i]->head, 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]