Commit e9a1ab19d196aa50619fd8b77157bd11a5a8aa01

Authored by bellard
1 parent 1193610e

ram allocation functions


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2404 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 21 additions and 0 deletions
cpu-all.h
... ... @@ -848,6 +848,8 @@ void cpu_register_physical_memory(target_phys_addr_t start_addr,
848 848 unsigned long size,
849 849 unsigned long phys_offset);
850 850 uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr);
  851 +ram_addr_t qemu_ram_alloc(unsigned int size);
  852 +void qemu_ram_free(ram_addr_t addr);
851 853 int cpu_register_io_memory(int io_index,
852 854 CPUReadMemoryFunc **mem_read,
853 855 CPUWriteMemoryFunc **mem_write,
... ...
... ... @@ -82,6 +82,7 @@ int phys_ram_size;
82 82 int phys_ram_fd;
83 83 uint8_t *phys_ram_base;
84 84 uint8_t *phys_ram_dirty;
  85 +static ram_addr_t phys_ram_alloc_offset = 0;
85 86  
86 87 CPUState *first_cpu;
87 88 /* 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)
1812 1813 return p->phys_offset;
1813 1814 }
1814 1815  
  1816 +/* XXX: better than nothing */
  1817 +ram_addr_t qemu_ram_alloc(unsigned int size)
  1818 +{
  1819 + ram_addr_t addr;
  1820 + if ((phys_ram_alloc_offset + size) >= phys_ram_size) {
  1821 + fprintf(stderr, "Not enough memory (requested_size = %u, max memory = %d)\n",
  1822 + size, phys_ram_size);
  1823 + abort();
  1824 + }
  1825 + addr = phys_ram_alloc_offset;
  1826 + phys_ram_alloc_offset = TARGET_PAGE_ALIGN(phys_ram_alloc_offset + size);
  1827 + return addr;
  1828 +}
  1829 +
  1830 +void qemu_ram_free(ram_addr_t addr)
  1831 +{
  1832 +}
  1833 +
1815 1834 static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)
1816 1835 {
1817 1836 #ifdef DEBUG_UNASSIGNED
... ...