aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/avd/info.c62
-rw-r--r--android/avd/info.h1
-rw-r--r--android/build/common.sh6
-rw-r--r--android/cmdline-options.h1
-rw-r--r--android/config/freebsd-x86/config-host.h13
-rw-r--r--android/console.c135
-rw-r--r--android/help.c22
-rw-r--r--android/main.c36
-rw-r--r--android/utils/timezone.c4
9 files changed, 250 insertions, 30 deletions
diff --git a/android/avd/info.c b/android/avd/info.c
index e738065..6766c96 100644
--- a/android/avd/info.c
+++ b/android/avd/info.c
@@ -92,6 +92,12 @@ AvdInfo* android_avdInfo;
*/
#define SDCARD_PATH "sdcard.path"
+/* the config.ini key that is used to indicate the absolute path
+ * to the second SD Card image file, if you don't want to place it in
+ * the content directory.
+ */
+#define SDCARD2_PATH "sdcard2.path"
+
/* certain disk image files are mounted read/write by the emulator
* to ensure that several emulators referencing the same files
* do not corrupt these files, we need to lock them and respond
@@ -675,7 +681,26 @@ EXIT:
return l->pPath[0];
}
+static void _sdcardLoadImages(ImageLoader* l, AvdInfo* i, AvdInfoParams* params, AvdImageType sdcardImage)
+{
+ imageLoader_set(l, sdcardImage);
+ imageLoader_load(l, IMAGE_OPTIONAL |
+ IMAGE_IGNORE_IF_LOCKED);
+ /* if the file was not found, ignore it */
+ if (l->pPath[0] && !path_exists(l->pPath[0]))
+ {
+ D("ignoring non-existing %s at %s: %s",
+ l->imageText, l->pPath[0], strerror(errno));
+
+ /* if the user provided the SD Card path by hand,
+ * warn him. */
+ if (params->forcePaths[sdcardImage] != NULL)
+ dwarning("ignoring non-existing SD Card image");
+
+ imageLoader_setPath(l, NULL);
+ }
+}
/* find the correct path of all image files we're going to need
* and lock the files that need it.
@@ -772,23 +797,8 @@ _getImagePaths(AvdInfo* i, AvdInfoParams* params )
* already used, we must ignore it.
*/
if (!noSdCard) {
- imageLoader_set (l, AVD_IMAGE_SDCARD);
- imageLoader_load(l, IMAGE_OPTIONAL |
- IMAGE_IGNORE_IF_LOCKED);
-
- /* if the file was not found, ignore it */
- if (l->pPath[0] && !path_exists(l->pPath[0]))
- {
- D("ignoring non-existing %s at %s: %s",
- l->imageText, l->pPath[0], strerror(errno));
-
- /* if the user provided the SD Card path by hand,
- * warn him. */
- if (params->forcePaths[AVD_IMAGE_SDCARD] != NULL)
- dwarning("ignoring non-existing SD Card image");
-
- imageLoader_setPath(l, NULL);
- }
+ _sdcardLoadImages(l, i, params, AVD_IMAGE_SDCARD);
+ _sdcardLoadImages(l, i, params, AVD_IMAGE_SDCARD2);
}
return 0;
@@ -1043,22 +1053,24 @@ _getSkin( AvdInfo* i, AvdInfoParams* params )
}
/* If the user didn't explicitely provide an SD Card path,
- * check the SDCARD_PATH key in config.ini and use that if
+ * check the specfied key in config.ini and use that if
* available.
*/
static void
-_getSDCardPath( AvdInfo* i, AvdInfoParams* params )
+_getSDCardPath(AvdInfo* i, AvdInfoParams* params, AvdImageType sdcardImage,
+ const char* iniKey )
{
const char* path;
- if (params->forcePaths[AVD_IMAGE_SDCARD] != NULL)
+ if (params->forcePaths[sdcardImage] != NULL) {
return;
+ }
- path = iniFile_getString(i->configIni, SDCARD_PATH);
+ path = iniFile_getString(i->configIni, iniKey);
if (path == NULL)
return;
- params->forcePaths[AVD_IMAGE_SDCARD] = path;
+ params->forcePaths[sdcardImage] = path;
}
AvdInfo*
@@ -1087,7 +1099,8 @@ avdInfo_new( const char* name, AvdInfoParams* params )
* obsolete SDKs.
*/
_getSearchPaths(i);
- _getSDCardPath(i, params);
+ _getSDCardPath(i, params, AVD_IMAGE_SDCARD, SDCARD_PATH);
+ _getSDCardPath(i, params, AVD_IMAGE_SDCARD2, SDCARD2_PATH);
/* don't need this anymore */
iniFile_free(i->rootIni);
@@ -1255,6 +1268,9 @@ _getBuildImagePaths( AvdInfo* i, AvdInfoParams* params )
if (!noSdCard) {
imageLoader_set (l, AVD_IMAGE_SDCARD);
imageLoader_load(l, IMAGE_OPTIONAL | IMAGE_IGNORE_IF_LOCKED);
+
+ imageLoader_set (l, AVD_IMAGE_SDCARD2);
+ imageLoader_load(l, IMAGE_OPTIONAL | IMAGE_IGNORE_IF_LOCKED);
}
return 0;
diff --git a/android/avd/info.h b/android/avd/info.h
index 19df807..75dab89 100644
--- a/android/avd/info.h
+++ b/android/avd/info.h
@@ -58,6 +58,7 @@
_AVD_IMG(USERDATA,"userdata-qemu.img", "user data") \
_AVD_IMG(CACHE,"cache.img","cache") \
_AVD_IMG(SDCARD,"sdcard.img","SD Card") \
+ _AVD_IMG(SDCARD2,"sdcard2.img","SD Card 2") \
/* define the enumared values corresponding to each AVD image type
* examples are: AVD_IMAGE_KERNEL, AVD_IMAGE_SYSTEM, etc..
diff --git a/android/build/common.sh b/android/build/common.sh
index 3f2c642..93ffba7 100644
--- a/android/build/common.sh
+++ b/android/build/common.sh
@@ -88,6 +88,9 @@ case "$OS" in
Linux)
# note that building 32-bit binaries on x86_64 is handled later
OS=linux-$CPU
+ ;;
+ FreeBSD)
+ OS=freebsd-$CPU
;;
CYGWIN*|*_NT-*)
OS=windows
@@ -123,6 +126,8 @@ case $OS in
;;
darwin-*) HOST_OS=darwin
;;
+ freebsd-*) HOST_OS=freebsd
+ ;;
*) HOST_OS=$OS
esac
@@ -161,6 +166,7 @@ force_32bit_binaries ()
case $OS in
linux-x86_64) OS=linux-x86 ;;
darwin-x86_64) OS=darwin-x86 ;;
+ freebsd-x86_64) OS=freebsd-x86 ;;
esac
HOST_ARCH=x86
CPU=x86
diff --git a/android/cmdline-options.h b/android/cmdline-options.h
index 6a4e7ff..fabac5c 100644
--- a/android/cmdline-options.h
+++ b/android/cmdline-options.h
@@ -76,6 +76,7 @@ CFG_PARAM( cache, "<file>", "cache partition image (default is temporary file
CFG_FLAG ( no_cache, "disable the cache partition" )
CFG_FLAG ( nocache, "same as -no-cache" )
OPT_PARAM( sdcard, "<file>", "SD card image (default <system>/sdcard.img")
+OPT_PARAM( sdcard2, "<file>", "SD card 2 image (default <system>/sdcard2.img")
OPT_FLAG ( wipe_data, "reset the use data image (copy it from initdata)" )
CFG_PARAM( avd, "<name>", "use a specific android virtual device" )
CFG_PARAM( skindir, "<dir>", "search skins in <dir> (default <system>/skins)" )
diff --git a/android/config/freebsd-x86/config-host.h b/android/config/freebsd-x86/config-host.h
new file mode 100644
index 0000000..8a08339
--- /dev/null
+++ b/android/config/freebsd-x86/config-host.h
@@ -0,0 +1,13 @@
+/* Automatically generated by configure - do not modify */
+#define CONFIG_QEMU_SHAREDIR "/usr/local/share/qemu"
+#define HOST_I386 1
+#define HOST_LONG_BITS 32
+#define CONFIG_GDBSTUB 1
+#define CONFIG_SLIRP 1
+#define CONFIG_OSS 1
+#define QEMU_VERSION "0.8.2"
+#define O_LARGEFILE 0
+#define MAP_ANONYMOUS MAP_ANON
+#define _BSD 1
+#define CONFIG_UNAME_RELEASE ""
+#define CONFIG_SKINS 1
diff --git a/android/console.c b/android/console.c
index ab32213..45da8aa 100644
--- a/android/console.c
+++ b/android/console.c
@@ -31,6 +31,8 @@
#include "hw/power_supply.h"
#include "shaper.h"
#include "modem_driver.h"
+#include "block.h"
+#include "block_int.h"
#include "android/gps.h"
#include "android/globals.h"
#include "android/utils/bufprint.h"
@@ -2066,6 +2068,135 @@ static const CommandDefRec geo_commands[] =
/********************************************************************************************/
/********************************************************************************************/
/***** ******/
+/***** S D C A R D C O M M A N D S ******/
+/***** ******/
+/********************************************************************************************/
+/********************************************************************************************/
+
+static int
+do_sdcard_insert( ControlClient client, char* args )
+{
+ char img[255];
+ char *p;
+ int n;
+ int drv_idx;
+
+ if (!args) {
+ control_write( client, "K0: argument missing, try 'sdcard insert <slot #> [imagefile]'\r\n" );
+ return -1;
+ }
+
+ memset(img, 0, sizeof(img));
+
+ n = strtoul(args, &p, 0);
+ if (n > 2) {
+ control_write( client, "K0: argument out of range\r\n" );
+ return -1;
+ }
+
+ if (p) {
+ p++;
+ strncpy(img, p, sizeof(img) -1);
+ }
+
+ if (goldfish_mmc_is_media_inserted(n)) {
+ control_write( client, "K0: Slot %d already has media inserted\r\n", n );
+ return -1;
+ }
+
+ drv_idx = drive_get_index( IF_IDE, 0, n);
+ if (drv_idx >= 0) {
+ if (img[0] != '\0' && strcmp(img, drives_table[drv_idx].bdrv->filename)) {
+ if (drive_swap(drives_table[drv_idx].bdrv, img)) {
+ control_write (client, "K0: Drive swap failed\r\n");
+ return -1;
+ }
+ }
+ } else {
+ drv_idx = drive_hotadd(img, "index=%d,media=disk", n);
+ if (drv_idx < 0) {
+ control_write (client, "K0: Drive hot-add failed\r\n");
+ return -1;
+ }
+ }
+
+ goldfish_mmc_insert(n, drives_table[drv_idx].bdrv);
+
+ return 0;
+}
+
+static int
+do_sdcard_remove( ControlClient client, char* args )
+{
+ int n;
+ int ins;
+
+ if (!args) {
+ control_write( client, "K0: argument missing, try 'sdcard remove <slot #>'\r\n" );
+ return -1;
+ }
+
+ n = atoi(args);
+
+ if ((ins = goldfish_mmc_is_media_inserted(n)) < 0) {
+ control_write( client, "K0: Slot %d is invalid\r\n", n );
+ } else if (!ins) {
+ control_write( client, "K0: Slot %d has no media\r\n", n );
+ return -1;
+ }
+
+ goldfish_mmc_remove(n);
+ return 0;
+}
+
+static int
+do_sdcard_status( ControlClient client, char* args )
+{
+ int i;
+ control_write( client, "Current SD card status:\r\n" );
+
+ for (i = 0; i < 2; i++) {
+ int drv_idx = drive_get_index( IF_IDE, 0, i);
+
+ control_write( client,
+ " Slot %d, image %s, inserted %d\r\n", i,
+ (drv_idx >=0 ? drives_table[drv_idx].bdrv->filename : "none"),
+ goldfish_mmc_is_media_inserted(i));
+ }
+ return 0;
+}
+
+static int
+do_sdcard_fail( ControlClient client, char* args )
+{
+ return -ENOSYS;
+}
+
+static const CommandDefRec sdcard_commands[] =
+{
+ { "insert", "hot-insert a virtual sdcard",
+ "'sdcard insert <slot #> [imagefile]'\r\n",
+ NULL, do_sdcard_insert, NULL },
+
+ { "remove", "hot-remove a virtual sdcard",
+ "'sdcard remove <slot #>'\r\n",
+ NULL, do_sdcard_remove, NULL },
+
+ { "status", "query virtual device status",
+ "'sdcard status'\r\n",
+ NULL, do_sdcard_status, NULL },
+
+ { "fail", "simulate an sdcard failure",
+ "'sdcard fail <read|write>'\r\n",
+ NULL, do_sdcard_fail, NULL },
+
+ { NULL, NULL, NULL, NULL, NULL, NULL }
+};
+
+
+/********************************************************************************************/
+/********************************************************************************************/
+/***** ******/
/***** M A I N C O M M A N D S ******/
/***** ******/
/********************************************************************************************/
@@ -2176,6 +2307,10 @@ static const CommandDefRec main_commands[] =
"allows you to modify the emulator window\r\n", NULL,
NULL, window_commands },
+ { "sdcard", "manage emulator sdcards",
+ "allows you to modify the emulator sdcard configuration\r\n", NULL,
+ NULL, sdcard_commands },
+
{ NULL, NULL, NULL, NULL, NULL, NULL }
};
diff --git a/android/help.c b/android/help.c
index a142f9d..cbca332 100644
--- a/android/help.c
+++ b/android/help.c
@@ -120,8 +120,8 @@ help_build_images( stralloc_t* out )
" You can use the -sysdir, -system, -kernel, -ramdisk, -datadir, -data options\n"
" to specify different search directories or specific image files. You can\n"
- " also use the -cache and -sdcard options to indicate specific cache partition\n"
- " and SD Card image files.\n\n"
+ " also use the -cache, -sdcard, and -sdcard2 options to indicate specific \n"
+ " cache partition and SD Card image files.\n\n"
" For more details, see the corresponding -help-<option> section.\n\n"
@@ -166,6 +166,7 @@ help_disk_images( stralloc_t* out )
" system-qemu.img an *optional* persistent system image\n"
" cache.img an *optional* cache partition image\n"
" sdcard.img an *optional* SD Card partition image\n\n"
+ " sdcard2.img an *optional* second SD Card partition image\n\n"
" If you use a virtual device, its content directory should store\n"
" all writable images, and read-only ones will be found from the\n"
@@ -181,7 +182,7 @@ help_disk_images( stralloc_t* out )
" can still run the emulator by explicitely providing the paths to\n"
" *all* required disk images through a combination of the following\n"
" options: -sysdir, -datadir, -kernel, -ramdisk, -system, -data, -cache\n"
- " and -sdcard\n\n"
+ " -sdcard, and -sdcard2\n\n"
" The actual logic being that the emulator should be able to find all\n"
" images from the options you give it.\n\n"
@@ -621,6 +622,21 @@ help_sdcard(stralloc_t* out)
}
static void
+help_sdcard2(stralloc_t* out)
+{
+ PRINTF(
+ " use '-sdcard2 <file>' to specify a second SD Card image file that will be attached\n"
+ " to the emulator. By default, the 'sdcard.img' file is searched in the data\n"
+ " directory.\n\n"
+
+ " if the file does not exist, the emulator will still start, but without a\n"
+ " second SD Card attached.\n\n"
+
+ " see '-help-disk-images' for more information about disk image files\n\n"
+ );
+}
+
+static void
help_skindir(stralloc_t* out)
{
PRINTF(
diff --git a/android/main.c b/android/main.c
index e791efe..de048b9 100644
--- a/android/main.c
+++ b/android/main.c
@@ -1795,6 +1795,7 @@ int main(int argc, char **argv)
int n;
char* opt;
int use_sdcard_img = 0;
+ int use_sdcard2_img = 0;
int serial = 0;
int gps_serial = 0;
int radio_serial = 0;
@@ -2059,6 +2060,14 @@ int main(int argc, char **argv)
D("autoconfig: -sdcard %s", opts->sdcard);
}
}
+
+ if (!opts->sdcard2 && opts->datadir) {
+ bufprint(tmp, tmpend, "%s/sdcard2.img", opts->datadir);
+ if (path_exists(tmp)) {
+ opts->sdcard2 = qemu_strdup(tmp);
+ D("autoconfig: -sdcard2 %s", opts->sdcard2);
+ }
+ }
}
/* setup the virtual device parameters from our options
@@ -2079,6 +2088,7 @@ int main(int argc, char **argv)
_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);
+ _forceAvdImagePath(AVD_IMAGE_SDCARD2, opts->sdcard2, "SD Card 2", 0);
/* we don't accept -skindir without -skin now
* to simplify the autoconfig stuff with virtual devices
@@ -2471,11 +2481,14 @@ int main(int argc, char **argv)
args[n++] = strdup(tmp);
}
- if (hw->hw_sdCard != 0)
+ if (hw->hw_sdCard != 0) {
opts->sdcard = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_SDCARD);
- else if (opts->sdcard) {
+ opts->sdcard2 = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_SDCARD2);
+
+ } else if (opts->sdcard || opts->sdcard2) {
dwarning( "Emulated hardware doesn't support SD Cards" );
opts->sdcard = NULL;
+ opts->sdcard2 = NULL;
}
if(opts->sdcard) {
@@ -2497,6 +2510,25 @@ int main(int argc, char **argv)
}
}
+ if(opts->sdcard2) {
+ uint64_t size;
+ if (path_get_size(opts->sdcard2, &size) == 0) {
+ /* see if we have an sdcard image. get its size if it exists */
+ /* due to what looks like limitations of the MMC protocol, one has
+ * to use an SD Card image that is equal or larger than 9 MB
+ */
+ if (size < 9*1024*1024ULL) {
+ fprintf(stderr, "### WARNING: SD Card files must be at least 9MB, ignoring '%s'\n", opts->sdcard2);
+ } else {
+ args[n++] = "-hdb";
+ args[n++] = opts->sdcard2;
+ use_sdcard2_img = 1;
+ }
+ } else {
+ D("no SD Card image at '%s'", opts->sdcard2);
+ }
+ }
+
if (!opts->logcat || opts->logcat[0] == 0) {
opts->logcat = getenv("ANDROID_LOG_TAGS");
if (opts->logcat && opts->logcat[0] == 0)
diff --git a/android/utils/timezone.c b/android/utils/timezone.c
index b5588a3..f4b78db 100644
--- a/android/utils/timezone.c
+++ b/android/utils/timezone.c
@@ -96,7 +96,7 @@ bufprint_zoneinfo_timezone( char* p, char* end )
/* on OS X, the timezone directory is always /usr/share/zoneinfo
* this makes things easy.
*/
-#ifdef __APPLE__
+#if defined(__APPLE__)
#include <unistd.h>
#include <limits.h>
@@ -149,7 +149,7 @@ get_zoneinfo_timezone( void )
* the original timezone file. the only way to know which zoneinfo name to retrieve is to compare
* it with all files in $TZDIR (at least those that match Area/Location or Area/Location/SubLocation
*/
-#ifdef __linux__
+#if defined(__linux__) || defined (__FreeBSD__)
#include <unistd.h>
#include <limits.h>