ram allocation functions
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 8 Feb 2007 23:08:38 +0000 (23:08 +0000)
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 8 Feb 2007 23:08:38 +0000 (23:08 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2404 c046a42c-6fe2-441c-8c8c-71466251a162

cpu-all.h
exec.c

index ed5355319aff90498bf1c8dafef3669ceeba6298..8a4730d32c1b6c0a4191b9b302500809017b0f05 100644 (file)
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -848,6 +848,8 @@ void cpu_register_physical_memory(target_phys_addr_t start_addr,
                                   unsigned long size,
                                   unsigned long phys_offset);
 uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr);
+ram_addr_t qemu_ram_alloc(unsigned int size);
+void qemu_ram_free(ram_addr_t addr);
 int cpu_register_io_memory(int io_index,
                            CPUReadMemoryFunc **mem_read,
                            CPUWriteMemoryFunc **mem_write,
diff --git a/exec.c b/exec.c
index ae2d825da34f44036eec24378c2e114ab9964996..2e09b4bc3e9a9269f80c708f4b413b643541c8f9 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -82,6 +82,7 @@ int phys_ram_size;
 int phys_ram_fd;
 uint8_t *phys_ram_base;
 uint8_t *phys_ram_dirty;
+static ram_addr_t phys_ram_alloc_offset = 0;
 
 CPUState *first_cpu;
 /* current CPU in the current thread. It is only valid inside
@@ -1812,6 +1813,24 @@ uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr)
     return p->phys_offset;
 }
 
+/* XXX: better than nothing */
+ram_addr_t qemu_ram_alloc(unsigned int size)
+{
+    ram_addr_t addr;
+    if ((phys_ram_alloc_offset + size) >= phys_ram_size) {
+        fprintf(stderr, "Not enough memory (requested_size = %u, max memory = %d)\n", 
+                size, phys_ram_size);
+        abort();
+    }
+    addr = phys_ram_alloc_offset;
+    phys_ram_alloc_offset = TARGET_PAGE_ALIGN(phys_ram_alloc_offset + size);
+    return addr;
+}
+
+void qemu_ram_free(ram_addr_t addr)
+{
+}
+
 static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)
 {
 #ifdef DEBUG_UNASSIGNED