diff options
author | David 'Digit' Turner <digit@android.com> | 2011-02-10 16:52:19 +0100 |
---|---|---|
committer | David 'Digit' Turner <digit@android.com> | 2011-02-10 17:52:56 +0100 |
commit | 5377c5bfde6ba62490417bb0a7d7c1be1151692e (patch) | |
tree | e8d1af24005c5fe9de2397fbd13cfe6f71c29f80 | |
parent | 2507cab8a78fb609461a2b9cc4708bab60fc53a4 (diff) | |
download | external_qemu-5377c5bfde6ba62490417bb0a7d7c1be1151692e.zip external_qemu-5377c5bfde6ba62490417bb0a7d7c1be1151692e.tar.gz external_qemu-5377c5bfde6ba62490417bb0a7d7c1be1151692e.tar.bz2 |
Correct auto-detection of default VM heap size.
This patch removes the need for the -m <memory> core option.
Instead, the RAM size is taken by default from qemu-hardware.ini.
Also, the default value of vm.heapSize is no longer 16MB, it is
now adjusted based on the RAM size (16/32/48 values)
+ Get rid of core -lcd-density option (use .ini file instead)
Change-Id: I93919926b61a132c7943a1bb2c41f7a3ab7f2d2f
-rw-r--r-- | android/avd/hardware-properties.ini | 5 | ||||
-rw-r--r-- | android/avd/hw-config-defs.h | 2 | ||||
-rw-r--r-- | android/main-common.c | 19 | ||||
-rw-r--r-- | android/main-ui.c | 37 | ||||
-rw-r--r-- | android/main.c | 41 | ||||
-rw-r--r-- | android/qemulator.c | 2 | ||||
-rw-r--r-- | android/qemulator.h | 4 | ||||
-rw-r--r-- | vl-android.c | 17 |
8 files changed, 69 insertions, 58 deletions
diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini index 79263a1..a936603 100644 --- a/android/avd/hardware-properties.ini +++ b/android/avd/hardware-properties.ini @@ -24,6 +24,8 @@ # # Ram size +# Default value will be computed based on screen pixels +# or skin version name = hw.ramSize type = integer default = 0 @@ -162,9 +164,10 @@ description = Must be one of 120, 160 or 240. A value used to roughly describe t # Maximum VM heap size # Higher values are required for high-dpi devices +# Default will depend on RAM size. name = vm.heapSize type = integer -default = 16 +default = 0 abstract = Max VM application heap size description = The maximum heap size a Dalvik application might allocate before being killed by the system. Value is in megabytes. diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h index 8d58478..5f97a25 100644 --- a/android/avd/hw-config-defs.h +++ b/android/avd/hw-config-defs.h @@ -167,7 +167,7 @@ HWCFG_INT( HWCFG_INT( vm_heapSize, "vm.heapSize", - 16, + 0, "Max VM application heap size", "The maximum heap size a Dalvik application might allocate before being killed by the system. Value is in megabytes.") diff --git a/android/main-common.c b/android/main-common.c index e11662c..a63983b 100644 --- a/android/main-common.c +++ b/android/main-common.c @@ -584,22 +584,3 @@ init_sdl_ui(AConfig* skinConfig, qemulator_get()->onion_rotation = rotate; } } - -int64_t get_screen_pixels(AConfig* skinConfig) -{ - int64_t pixels = 0; - AConfig* disp; - - if (skinConfig != NULL) { - disp = aconfig_find(skinConfig, "display"); - if (disp != NULL) { - int width = aconfig_int(disp, "width", 0); - int height = aconfig_int(disp, "height", 0); - pixels = (int64_t)width*height; - } - } - if (pixels == 0) - pixels = 320*240; - - return pixels; -} diff --git a/android/main-ui.c b/android/main-ui.c index 373f13d..21b3aa3 100644 --- a/android/main-ui.c +++ b/android/main-ui.c @@ -490,8 +490,6 @@ int main(int argc, char **argv) char* android_build_out = NULL; AndroidOptions opts[1]; - /* LCD density value to pass to the core. */ - char lcd_density[16]; /* net.shared_net_ip boot property value. */ char boot_prop_ip[64]; boot_prop_ip[0] = '\0'; @@ -1257,6 +1255,7 @@ int main(int argc, char **argv) derror( "physical memory size must be between 32 and 4096 MB" ); exit(1); } + hw->hw_ramSize = ramSize; } if (!opts->memory) { int ramSize = hw->hw_ramSize; @@ -1266,8 +1265,7 @@ int main(int argc, char **argv) * size through its hardware.ini (i.e. legacy ones) or when * in the full Android build system. */ - int64_t pixels = get_screen_pixels(skinConfig); - + int64_t pixels = hw->hw_lcd_width * hw->hw_lcd_height; /* The following thresholds are a bit liberal, but we * essentially want to ensure the following mappings: * @@ -1285,8 +1283,30 @@ int main(int argc, char **argv) else ramSize = 256; } - bufprint(tmp, tmpend, "%d", ramSize); - opts->memory = android_strdup(tmp); + hw->hw_ramSize = ramSize; + } + + D("Physical RAM size: %dMB\n", hw->hw_ramSize); + + if (hw->vm_heapSize == 0) { + /* Compute the default heap size based on the RAM size. + * Essentially, we want to ensure the following liberal mappings: + * + * 96MB RAM -> 16MB heap + * 128MB RAM -> 24MB heap + * 256MB RAM -> 48MB heap + */ + int ramSize = hw->hw_ramSize; + int heapSize; + + if (ramSize < 100) + heapSize = 16; + else if (ramSize < 192) + heapSize = 24; + else + heapSize = 48; + + hw->vm_heapSize = heapSize; } if (opts->trace) { @@ -1296,11 +1316,6 @@ int main(int argc, char **argv) args[n++] = "off"; } - /* Pass LCD density value to the core. */ - snprintf(lcd_density, sizeof(lcd_density), "%d", hw->hw_lcd_density); - args[n++] = "-lcd-density"; - args[n++] = lcd_density; - /* Pass boot properties to the core. */ if (opts->prop != NULL) { ParamList* pl = opts->prop; diff --git a/android/main.c b/android/main.c index 4e2bc42..9eddb70 100644 --- a/android/main.c +++ b/android/main.c @@ -298,8 +298,6 @@ int main(int argc, char **argv) char* android_build_out = NULL; AndroidOptions opts[1]; - /* LCD density value to pass to the core. */ - char lcd_density[16]; /* net.shared_net_ip boot property value. */ char boot_prop_ip[64]; boot_prop_ip[0] = '\0'; @@ -1050,6 +1048,7 @@ int main(int argc, char **argv) derror( "physical memory size must be between 32 and 4096 MB" ); exit(1); } + hw->hw_ramSize = ramSize; } if (!opts->memory) { int ramSize = hw->hw_ramSize; @@ -1059,8 +1058,7 @@ int main(int argc, char **argv) * size through its hardware.ini (i.e. legacy ones) or when * in the full Android build system. */ - int64_t pixels = get_screen_pixels(skinConfig); - + int64_t pixels = hw->hw_lcd_width * hw->hw_lcd_height; /* The following thresholds are a bit liberal, but we * essentially want to ensure the following mappings: * @@ -1078,8 +1076,30 @@ int main(int argc, char **argv) else ramSize = 256; } - bufprint(tmp, tmpend, "%d", ramSize); - opts->memory = android_strdup(tmp); + hw->hw_ramSize = ramSize; + } + + D("Physical RAM size: %dMB\n", hw->hw_ramSize); + + if (hw->vm_heapSize == 0) { + /* Compute the default heap size based on the RAM size. + * Essentially, we want to ensure the following liberal mappings: + * + * 96MB RAM -> 16MB heap + * 128MB RAM -> 24MB heap + * 256MB RAM -> 48MB heap + */ + int ramSize = hw->hw_ramSize; + int heapSize; + + if (ramSize < 100) + heapSize = 16; + else if (ramSize < 192) + heapSize = 24; + else + heapSize = 48; + + hw->vm_heapSize = heapSize; } if (opts->trace) { @@ -1089,11 +1109,6 @@ int main(int argc, char **argv) args[n++] = "off"; } - /* Pass LCD density value to the core. */ - snprintf(lcd_density, sizeof(lcd_density), "%d", get_device_dpi(opts)); - args[n++] = "-lcd-density"; - args[n++] = lcd_density; - /* Pass boot properties to the core. */ if (opts->prop != NULL) { ParamList* pl = opts->prop; @@ -1216,9 +1231,7 @@ int main(int argc, char **argv) args[n++] = opts->memcheck; } - /* physical memory */ - args[n++] = "-m"; - args[n++] = opts->memory; + /* physical memory is now in hw->hw_ramSize */ /* on Linux, the 'dynticks' clock sometimes doesn't work * properly. this results in the UI freezing while emulation diff --git a/android/qemulator.c b/android/qemulator.c index ee9ccbb..b15d751 100644 --- a/android/qemulator.c +++ b/android/qemulator.c @@ -258,7 +258,7 @@ qemulator_set_title(QEmulator* emulator) * Helper routines */ -int +static int get_device_dpi( AndroidOptions* opts ) { int dpi_device = corecmd_get_hw_lcd_density(); diff --git a/android/qemulator.h b/android/qemulator.h index 189cc53..bd77ae1 100644 --- a/android/qemulator.h +++ b/android/qemulator.h @@ -66,8 +66,4 @@ qemulator_get_layout( QEmulator* emulator ); QFrameBuffer* qemulator_get_first_framebuffer(QEmulator* emulator); -/* A helper routine for getting device DPI. */ -int -get_device_dpi( AndroidOptions* opts ); - #endif // QEMU_ANDROID_QEMULATOR_H diff --git a/vl-android.c b/vl-android.c index 3b71469..a35f351 100644 --- a/vl-android.c +++ b/vl-android.c @@ -4646,11 +4646,10 @@ int main(int argc, char **argv, char **envp) } /* Initialize LCD density */ - if (android_op_lcd_density) { - char* end; - long density = strtol(android_op_lcd_density, &end, 0); - if (end == NULL || *end || density < 0) { - PANIC("option -lcd-density must be a positive integer"); + if (android_hw->hw_lcd_density) { + long density = android_hw->hw_lcd_density; + if (density <= 0) { + PANIC("Invalid hw.lcd.density value: %ld", density); } hwLcd_setBootProperty(density); } @@ -4925,8 +4924,12 @@ int main(int argc, char **argv, char **envp) } /* init the memory */ - if (ram_size == 0) - ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; + if (ram_size == 0) { + ram_size = android_hw->hw_ramSize * 1024LL * 1024; + if (ram_size == 0) { + ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; + } + } #ifdef CONFIG_KQEMU /* FIXME: This is a nasty hack because kqemu can't cope with dynamic |