diff options
author | David 'Digit' Turner <digit@android.com> | 2011-03-01 14:02:42 +0100 |
---|---|---|
committer | David 'Digit' Turner <digit@android.com> | 2011-03-01 15:31:11 +0100 |
commit | 0b0194940523fa3f318c380d0693907bd522241c (patch) | |
tree | 69d2e8db93e660fc22b468faeb5d097653ff71ad | |
parent | 25eb6557b94da066d6e137c07aeced39badf5aa6 (diff) | |
download | external_qemu-0b0194940523fa3f318c380d0693907bd522241c.zip external_qemu-0b0194940523fa3f318c380d0693907bd522241c.tar.gz external_qemu-0b0194940523fa3f318c380d0693907bd522241c.tar.bz2 |
Move kernel/ramdisk initialization to the core.
The QEMU -kernel, -initrd and -append options are still supported for
overriding the hardware configuration.
Change-Id: I034d9e25d0a23341086aa052f449db5de50b2c8d
-rw-r--r-- | android/avd/hardware-properties.ini | 15 | ||||
-rw-r--r-- | android/avd/hw-config-defs.h | 15 | ||||
-rw-r--r-- | android/avd/info.c | 82 | ||||
-rw-r--r-- | android/avd/info.h | 10 | ||||
-rw-r--r-- | android/main-common.c | 24 | ||||
-rw-r--r-- | android/main.c | 41 | ||||
-rw-r--r-- | vl-android.c | 12 |
7 files changed, 124 insertions, 75 deletions
diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini index 7473e7d..06ac447 100644 --- a/android/avd/hardware-properties.ini +++ b/android/avd/hardware-properties.ini @@ -194,15 +194,24 @@ default = yes abstract = Proximity support description = Whether there is an proximity in the device. -# Path to the kernel image. -name = disk.kernel.path +# Kernel image. +# +# kernel.path specified the path to the kernel image +# kernel.parameters specifies the string of kernel boot parameters. +# +name = kernel.path type = string default = abstract = Path to the kernel image description = Path to the kernel image. +name = kernel.parameters +type = string +default = +abstract = kernel boot parameters string. + # Path to the ramdisk image. -name = disk.ramDisk.path +name = disk.ramdisk.path type = string default = abstract = Path to the ramdisk image diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h index a6cce01..c3e0a77 100644 --- a/android/avd/hw-config-defs.h +++ b/android/avd/hw-config-defs.h @@ -193,15 +193,22 @@ HWCFG_BOOL( "Whether there is an proximity in the device.") HWCFG_STRING( - disk_kernel_path, - "disk.kernel.path", + kernel_path, + "kernel.path", "", "Path to the kernel image", "Path to the kernel image.") HWCFG_STRING( - disk_ramDisk_path, - "disk.ramDisk.path", + kernel_parameters, + "kernel.parameters", + "", + "kernel boot parameters string.", + "") + +HWCFG_STRING( + disk_ramdisk_path, + "disk.ramdisk.path", "", "Path to the ramdisk image", "Path to the ramdisk image.") diff --git a/android/avd/info.c b/android/avd/info.c index 5f110d3..fa32c24 100644 --- a/android/avd/info.c +++ b/android/avd/info.c @@ -1139,15 +1139,6 @@ _avdInfo_getImagePaths(AvdInfo* i, AvdInfoParams* params ) imageLoader_init(l, i, params); - /* pick up the kernel and ramdisk image files - these don't - * need a specific handling. - */ - imageLoader_set ( l, AVD_IMAGE_KERNEL ); - imageLoader_load( l, IMAGE_REQUIRED | IMAGE_SEARCH_SDK | IMAGE_DONT_LOCK ); - - imageLoader_set ( l, AVD_IMAGE_RAMDISK ); - imageLoader_load( l, IMAGE_REQUIRED | IMAGE_SEARCH_SDK | IMAGE_DONT_LOCK ); - /* the system image * * if there is one in the content directory just lock @@ -1327,31 +1318,12 @@ _avdInfo_getBuildImagePaths( AvdInfo* i, AvdInfoParams* params ) int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0; int noSnapshots = (params->flags & AVDINFO_NO_SNAPSHOTS) != 0; - char temp[PATH_MAX], *p=temp, *end=p+sizeof temp; + char temp[PATH_MAX]; char* srcData; ImageLoader l[1]; imageLoader_init(l, i, params); - /** load the kernel image - **/ - - /* if it is not in the out directory, get it from prebuilt - */ - imageLoader_set ( l, AVD_IMAGE_KERNEL ); - - if ( !imageLoader_load( l, IMAGE_OPTIONAL | - IMAGE_DONT_LOCK ) ) - { - p = bufprint(temp, end, "%s/prebuilt/android-%s/kernel/kernel-qemu", - i->androidBuildRoot, i->targetArch); - if (p >= end || !path_exists(temp)) { - derror("bad workspace: cannot find prebuilt kernel in: %s", temp); - exit(1); - } - imageLoader_setPath(l, temp); - } - /** load the data partition. note that we use userdata-qemu.img ** since we don't want to modify userdata.img at all **/ @@ -1405,12 +1377,6 @@ _avdInfo_getBuildImagePaths( AvdInfo* i, AvdInfoParams* params ) AFREE(srcData); - /** load the ramdisk image - **/ - imageLoader_set ( l, AVD_IMAGE_RAMDISK ); - imageLoader_load( l, IMAGE_REQUIRED | - IMAGE_DONT_LOCK ); - /** load the system image. read-only. the caller must ** take care of checking the state **/ @@ -1549,6 +1515,52 @@ avdInfo_isImageReadOnly( AvdInfo* i, AvdImageType imageType ) return (i->imageState[imageType] == IMAGE_STATE_READONLY); } +char* +avdInfo_getKernelPath( AvdInfo* i ) +{ + const char* imageName = _imageFileNames[ AVD_IMAGE_KERNEL ]; + + char* kernelPath = _avdInfo_getContentOrSdkFilePath(i, imageName); + + if (kernelPath == NULL && i->inAndroidBuild) { + /* When in the Android build, look into the prebuilt directory + * for our target architecture. + */ + char temp[PATH_MAX], *p = temp, *end = p + sizeof(temp); + + p = bufprint(temp, end, "%s/prebuilt/android-%s/kernel/kernel-qemu", + i->androidBuildRoot, i->targetArch); + if (p >= end || !path_exists(temp)) { + derror("bad workspace: cannot find prebuilt kernel in: %s", temp); + exit(1); + } + kernelPath = ASTRDUP(temp); + } + return kernelPath; +} + + +char* +avdInfo_getRamdiskPath( AvdInfo* i ) +{ + const char* imageName = _imageFileNames[ AVD_IMAGE_RAMDISK ]; + return _avdInfo_getContentOrSdkFilePath(i, imageName); +} + +char* +avdInfo_getSystemInitImagePath( AvdInfo* i ) +{ + const char* imageName = _imageFileNames[ AVD_IMAGE_INITSYSTEM ]; + return _avdInfo_getContentOrSdkFilePath(i, imageName); +} + +char* +avdInfo_getDataInitImagePath( AvdInfo* i ) +{ + const char* imageName = _imageFileNames[ AVD_IMAGE_INITDATA ]; + return _avdInfo_getContentOrSdkFilePath(i, imageName); +} + int avdInfo_getHwConfig( AvdInfo* i, AndroidHwConfig* hw ) { diff --git a/android/avd/info.h b/android/avd/info.h index adcabfd..d00e9c6 100644 --- a/android/avd/info.h +++ b/android/avd/info.h @@ -130,6 +130,16 @@ void avdInfo_free( AvdInfo* i ); */ const char* avdInfo_getName( AvdInfo* i ); +/* Returns the path to various images corresponding to a given AVD. + * NULL if the image cannot be found. Returned strings must be freed + * by the caller. + */ +char* avdInfo_getKernelPath( AvdInfo* i ); +char* avdInfo_getRamdiskPath( AvdInfo* i ); + +char* avdInfo_getSystemInitImagePath( AvdInfo* i ); +char* avdInfo_getDataInitImagePath( AvdInfo* i ); + /* Returns the path to a given AVD image file. This will return NULL if * the file cannot be found / does not exist. */ diff --git a/android/main-common.c b/android/main-common.c index 3bca6c4..24ad808 100644 --- a/android/main-common.c +++ b/android/main-common.c @@ -789,6 +789,18 @@ void sanitizeOptions( AndroidOptions* opts ) exit(1); } } + + if (opts->bootchart) { + char* end; + int timeout = strtol(opts->bootchart, &end, 10); + if (timeout == 0) + opts->bootchart = NULL; + else if (timeout < 0 || timeout > 15*60) { + derror( "timeout specified for -bootchart option is invalid.\n" + "please use integers between 1 and 900\n"); + exit(1); + } + } } AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild) @@ -925,9 +937,7 @@ AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild) /* if certain options are set, we can force the path of * certain kernel/disk image files */ - _forceAvdImagePath(AVD_IMAGE_KERNEL, opts->kernel, "kernel", 1); _forceAvdImagePath(AVD_IMAGE_INITSYSTEM, opts->system, "system", 1); - _forceAvdImagePath(AVD_IMAGE_RAMDISK, opts->ramdisk, "ramdisk", 1); _forceAvdImagePath(AVD_IMAGE_USERDATA, opts->data, "user data", 0); _forceAvdImagePath(AVD_IMAGE_CACHE, opts->cache, "cache", 0); _forceAvdImagePath(AVD_IMAGE_SDCARD, opts->sdcard, "SD Card", 0); @@ -1031,16 +1041,6 @@ updateHwConfigFromAVD(AndroidHwConfig* hwConfig, { unsigned defaultPartitionSize = convertMBToBytes(66); - if (_update_hwconfig_path(&hwConfig->disk_kernel_path, avd, AVD_IMAGE_KERNEL)) { - dprint("kernel image path %s is invalid", hwConfig->disk_kernel_path); - exit(1); - } - - if (_update_hwconfig_path(&hwConfig->disk_ramDisk_path, avd, AVD_IMAGE_RAMDISK)) { - dprint("ramdisk image path %s is invalid", hwConfig->disk_ramDisk_path); - exit(1); - } - if (_update_hwconfig_path(&hwConfig->disk_systemPartition_initPath, avd, AVD_IMAGE_INITSYSTEM)) { dprint("system path %s is invalid", hwConfig->disk_systemPartition_initPath); exit(1); diff --git a/android/main.c b/android/main.c index ddf8463..e8bdac9 100644 --- a/android/main.c +++ b/android/main.c @@ -334,11 +334,23 @@ int main(int argc, char **argv) n = 1; /* generate arguments for the underlying qemu main() */ { - const char* kernelFile = avdInfo_getImageFile(avd, AVD_IMAGE_KERNEL); - int kernelFileLen = strlen(kernelFile); + char* kernelFile = opts->kernel; + int kernelFileLen; + + if (kernelFile == NULL) { + kernelFile = avdInfo_getKernelPath(avd); + if (kernelFile == NULL) { + derror( "This AVD's configuration is missing a kernel file!!" ); + exit(2); + } + D("autoconfig: -kernel %s", kernelFile); + } + if (!path_exists(kernelFile)) { + derror( "Invalid or missing kernel image file: %s", kernelFile ); + exit(2); + } - args[n++] = "-kernel"; - args[n++] = (char*)kernelFile; + hw->kernel_path = kernelFile; /* If the kernel image name ends in "-armv7", then change the cpu * type automatically. This is a poor man's approach to configuration @@ -353,6 +365,7 @@ int main(int argc, char **argv) * some build system changes. I prefer not to do that for now for reasons * of simplicity. */ + kernelFileLen = strlen(kernelFile); if (kernelFileLen > 6 && !memcmp(kernelFile + kernelFileLen - 6, "-armv7", 6)) { args[n++] = "-cpu"; args[n++] = "cortex-a8"; @@ -408,8 +421,8 @@ int main(int argc, char **argv) args[n++] = opts->dns_server; } - args[n++] = "-initrd"; - args[n++] = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_RAMDISK); + hw->disk_ramdisk_path = avdInfo_getRamdiskPath(avd); + D("autoconfig: -ramdisk %s", hw->disk_ramdisk_path); { const char* filetype = "file"; @@ -684,20 +697,6 @@ int main(int argc, char **argv) } } - args[n++] = "-append"; - - if (opts->bootchart) { - char* end; - int timeout = strtol(opts->bootchart, &end, 10); - if (timeout == 0) - opts->bootchart = NULL; - else if (timeout < 0 || timeout > 15*60) { - derror( "timeout specified for -bootchart option is invalid.\n" - "please use integers between 1 and 900\n"); - exit(1); - } - } - /* Setup the kernel init options */ { @@ -764,7 +763,7 @@ int main(int argc, char **argv) exit(1); } - args[n++] = strdup(params); + hw->kernel_parameters = strdup(params); } if (opts->ports) { diff --git a/vl-android.c b/vl-android.c index ff21db9..d5b37ae 100644 --- a/vl-android.c +++ b/vl-android.c @@ -5061,6 +5061,14 @@ int main(int argc, char **argv, char **envp) if (qemu_init_main_loop()) { PANIC("qemu_init_main_loop failed"); } + + if (kernel_filename == NULL) { + kernel_filename = android_hw->kernel_path; + } + if (initrd_filename == NULL) { + initrd_filename = android_hw->disk_ramdisk_path; + } + linux_boot = (kernel_filename != NULL); net_boot = (boot_devices_bitmap >> ('n' - 'a')) & 0xF; @@ -5333,6 +5341,10 @@ int main(int argc, char **argv, char **envp) { const char* kernel_parameters; + if (android_hw->kernel_parameters) { + stralloc_add_str(kernel_params, android_hw->kernel_parameters); + } + /* If not empty, kernel_config always contains a leading space */ stralloc_append(kernel_params, kernel_config); |