diff options
author | SeokYeon Hwang <syeon.hwang@samsung.com> | 2014-06-16 12:18:43 +0900 |
---|---|---|
committer | SeokYeon Hwang <syeon.hwang@samsung.com> | 2014-06-16 14:02:16 +0900 |
commit | 182b9a44a4df628515135db9869319a34ccb296f (patch) | |
tree | 80e5d1abf0b238563823b50b24857e2b2c3dc6d5 | |
parent | 6e12ac9f22be13932cb5e9b68dc5fda06055e27a (diff) | |
download | qemu-182b9a44a4df628515135db9869319a34ccb296f.tar.gz qemu-182b9a44a4df628515135db9869319a34ccb296f.tar.bz2 qemu-182b9a44a4df628515135db9869319a34ccb296f.zip |
emulator: modify RAM preallocation logic
Change-Id: Idfe6eb74f35fa13c9518dedb18adec3b9ed1de20
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
-rw-r--r-- | hw/i386/pc_piix.c | 9 | ||||
-rw-r--r-- | util/oslib-posix.c | 8 | ||||
-rw-r--r-- | util/oslib-win32.c | 8 | ||||
-rw-r--r-- | vl.c | 6 |
4 files changed, 20 insertions, 11 deletions
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 8050a67be7..ff92135fc0 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -58,7 +58,7 @@ void pc_init_pci(QEMUMachineInitArgs *args); extern MemoryRegion *global_ram_memory; -extern void *preallocated_ptr; +extern void *preallocated_ram_ptr; #endif static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; @@ -162,13 +162,6 @@ static void pc_init1(QEMUMachineInitArgs *args, /* allocate ram and load rom/bios */ if (!xen_enabled()) { -#ifdef CONFIG_MARU - // W/A for allocate larger continuous heap. - // see vl.c - if(preallocated_ptr != NULL) { - g_free(preallocated_ptr); - } -#endif fw_cfg = pc_memory_init(system_memory, args->kernel_filename, args->kernel_cmdline, args->initrd_filename, diff --git a/util/oslib-posix.c b/util/oslib-posix.c index d891d65f23..11ff7e2fba 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -139,9 +139,17 @@ void *qemu_memalign(size_t alignment, size_t size) return ptr; } +#ifdef CONFIG_MARU +void *preallocated_ram_ptr = NULL; +#endif /* alloc shared memory pages */ void *qemu_anon_ram_alloc(size_t size) { +#ifdef CONFIG_MARU + if (preallocated_ram_ptr) { + return preallocated_ram_ptr; + } +#endif size_t align = QEMU_VMALLOC_ALIGN; size_t total = size + align - getpagesize(); void *ptr = mmap(0, total, PROT_READ | PROT_WRITE, diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 67746cc5e4..e03c9fe6ca 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -170,6 +170,9 @@ void *qemu_memalign(size_t alignment, size_t size) return ptr; } +#ifdef CONFIG_MARU +void *preallocated_ram_ptr = NULL; +#endif void *qemu_anon_ram_alloc(size_t size) { void *ptr; @@ -177,6 +180,11 @@ void *qemu_anon_ram_alloc(size_t size) /* FIXME: this is not exactly optimal solution since VirtualAlloc has 64Kb granularity, but at least it guarantees us that the memory is page aligned. */ +#ifdef CONFIG_MARU + if (preallocated_ram_ptr) { + return preallocated_ram_ptr; + } +#endif ptr = VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); trace_qemu_anon_ram_alloc(size, ptr); return ptr; @@ -2987,8 +2987,9 @@ out: #ifdef CONFIG_MARU int use_qemu_display = 0; //0:use tizen qemu sdl, 1:use original qemu sdl + // W/A for preserve larger continuous heap for RAM. -void *preallocated_ptr = 0; +extern void *preallocated_ram_ptr; #endif int main(int argc, char **argv, char **envp) @@ -4080,8 +4081,7 @@ int main(int argc, char **argv, char **envp) } #if defined(CONFIG_MARU) - // W/A for preserve larger continuous heap for RAM. - preallocated_ptr = g_malloc(ram_size); + preallocated_ram_ptr = qemu_anon_ram_alloc(ram_size); kernel_cmdline = qemu_opt_get(qemu_get_machine_opts(), "append"); // Returned variable points different address from input variable. |