aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android/cmdline-options.h1
-rw-r--r--android/help.c14
-rw-r--r--android/main.c67
-rw-r--r--android/utils/stralloc.c36
-rw-r--r--android/utils/stralloc.h5
-rw-r--r--vl-android.c76
6 files changed, 117 insertions, 82 deletions
diff --git a/android/cmdline-options.h b/android/cmdline-options.h
index b9105af..b7d7bfa 100644
--- a/android/cmdline-options.h
+++ b/android/cmdline-options.h
@@ -131,7 +131,6 @@ OPT_PARAM( report_console, "<socket>", "report console port to remote socket" )
OPT_PARAM( gps, "<device>", "redirect NMEA GPS to character device" )
OPT_PARAM( keyset, "<name>", "specify keyset file name" )
OPT_PARAM( shell_serial, "<device>", "specific character device for root shell" )
-OPT_FLAG ( old_system, "support old (pre 1.4) system images" )
OPT_PARAM( tcpdump, "<file>", "capture network packets to file" )
OPT_PARAM( bootchart, "<timeout>", "enable bootcharting")
diff --git a/android/help.c b/android/help.c
index e3a6643..cd5a3a6 100644
--- a/android/help.c
+++ b/android/help.c
@@ -1333,20 +1333,6 @@ help_keyset(stralloc_t* out)
);
}
-static void
-help_old_system(stralloc_t* out)
-{
- PRINTF(
- " use '-old-system' if you want to use a recent emulator binary to run\n"
- " an old version of the Android SDK system images. Here, 'old' means anything\n"
- " older than version 1.4 of the emulator.\n\n"
-
- " NOTE: using '-old-system' with recent system images is likely to not work\n"
- " properly, though you may not notice it immediately (e.g. failure to\n"
- " start the emulated GPS hardware)\n\n"
- );
-}
-
#ifdef CONFIG_NAND_LIMITS
static void
help_nand_limits(stralloc_t* out)
diff --git a/android/main.c b/android/main.c
index 808ca4d..64314b0 100644
--- a/android/main.c
+++ b/android/main.c
@@ -162,9 +162,6 @@ int main(int argc, char **argv)
int n;
char* opt;
int serial = 0;
- int gps_serial = 0;
- int radio_serial = 0;
- int qemud_serial = 0;
int shell_serial = 0;
AndroidHwConfig* hw;
@@ -821,14 +818,8 @@ int main(int argc, char **argv)
}
/* we always send the kernel messages from ttyS0 to android_kmsg */
- {
- if (opts->show_kernel) {
- args[n++] = "-show-kernel";
- }
-
- args[n++] = "-serial";
- args[n++] = "android-kmsg";
- serial++;
+ if (opts->show_kernel) {
+ args[n++] = "-show-kernel";
}
/* XXXX: TODO: implement -shell and -logcat through qemud instead */
@@ -848,39 +839,14 @@ int main(int argc, char **argv)
shell_serial = serial++;
}
- if (opts->old_system)
- {
- if (opts->radio) {
- args[n++] = "-serial";
- args[n++] = opts->radio;
- radio_serial = serial++;
- }
- else {
- args[n++] = "-serial";
- args[n++] = "android-modem";
- radio_serial = serial++;
- }
- if (opts->gps) {
- args[n++] = "-serial";
- args[n++] = opts->gps;
- gps_serial = serial++;
- }
+ if (opts->radio) {
+ args[n++] = "-radio";
+ args[n++] = opts->radio;
}
- else /* !opts->old_system */
- {
- args[n++] = "-serial";
- args[n++] = "android-qemud";
- qemud_serial = serial++;
- if (opts->radio) {
- args[n++] = "-radio";
- args[n++] = opts->radio;
- }
-
- if (opts->gps) {
- args[n++] = "-gps";
- args[n++] = opts->gps;
- }
+ if (opts->gps) {
+ args[n++] = "-gps";
+ args[n++] = opts->gps;
}
if (opts->memory) {
@@ -970,7 +936,9 @@ int main(int argc, char **argv)
static char params[1024];
char *p = params, *end = p + sizeof(params);
- p = bufprint(p, end, "qemu=1 console=ttyS0" );
+ /* Don't worry about having a leading space here, this is handled
+ * by the core later. */
+
#ifdef TARGET_I386
p = bufprint(p, end, " androidboot.hardware=goldfish");
p = bufprint(p, end, " clocksource=pit");
@@ -1008,19 +976,6 @@ int main(int argc, char **argv)
p = q;
}
- if (opts->old_system)
- {
- p = bufprint(p, end, " android.ril=ttyS%d", radio_serial);
-
- if (opts->gps) {
- p = bufprint(p, end, " android.gps=ttyS%d", gps_serial);
- }
- }
- else
- {
- p = bufprint(p, end, " android.qemud=ttyS%d", qemud_serial);
- }
-
if (opts->bootchart) {
p = bufprint(p, end, " androidboot.bootchart=%s", opts->bootchart);
}
diff --git a/android/utils/stralloc.c b/android/utils/stralloc.c
index 2a924e4..ce5d800 100644
--- a/android/utils/stralloc.c
+++ b/android/utils/stralloc.c
@@ -19,7 +19,7 @@
#include <limits.h>
extern void
-stralloc_tabular( stralloc_t* out,
+stralloc_tabular( stralloc_t* out,
const char** strings, int count,
const char* prefix, int width )
{
@@ -138,6 +138,40 @@ stralloc_cstr( stralloc_t* s )
return s->s;
}
+void
+stralloc_lstrip( stralloc_t* s )
+{
+ int count;
+
+ for (count = 0; count < s->n; count++) {
+ if (s->s[count] != ' ' && s->s[count] != '\t')
+ break;
+ }
+
+ if (count > 0) {
+ memmove(s->s, s->s + count, s->n - count);
+ s->n -= count;
+ }
+}
+
+void
+stralloc_rstrip( stralloc_t* s )
+{
+ int count = s->n;
+
+ while (count > 0 && (s->s[count-1] == ' ' || s->s[count-1] == '\t'))
+ count--;
+
+ s->n = count;
+}
+
+void
+stralloc_strip( stralloc_t* s )
+{
+ stralloc_rstrip(s);
+ stralloc_lstrip(s);
+}
+
extern char*
stralloc_to_tempstr( stralloc_t* s )
{
diff --git a/android/utils/stralloc.h b/android/utils/stralloc.h
index 4d17060..626a638 100644
--- a/android/utils/stralloc.h
+++ b/android/utils/stralloc.h
@@ -52,6 +52,11 @@ extern void stralloc_add_quote_bytes( stralloc_t* s, const void* from, unsig
extern void stralloc_add_hex( stralloc_t* s, unsigned value, int num_digits );
extern void stralloc_add_hexdump( stralloc_t* s, void* base, int size, const char* prefix );
+/* Remove leading, trailing or leading+trailing whitespace */
+extern void stralloc_lstrip( stralloc_t* s );
+extern void stralloc_rstrip( stralloc_t* s );
+extern void stralloc_strip( stralloc_t* s );
+
extern void stralloc_tabular( stralloc_t* s, const char** strings, int count,
const char* prefix, int width );
diff --git a/vl-android.c b/vl-android.c
index fd587ae..a5510a0 100644
--- a/vl-android.c
+++ b/vl-android.c
@@ -284,6 +284,8 @@ static int no_frame = 0;
#endif
int no_quit = 0;
CharDriverState *serial_hds[MAX_SERIAL_PORTS];
+int serial_hds_count;
+
CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
#ifdef TARGET_I386
@@ -3762,6 +3764,53 @@ slirp_allow(const char *optarg, u_int8_t proto)
free(argument);
}
+/* Add a serial device at a given location in the emulated hardware table.
+ * On failure, this function aborts the program with an error message.
+ */
+static void
+serial_hds_add_at(int index, const char* devname)
+{
+ char label[32];
+
+ if (!devname || !strcmp(devname,"none"))
+ return;
+
+ if (index >= MAX_SERIAL_PORTS) {
+ PANIC("qemu: invalid serial index for %s (%d >= %d)",
+ devname, index, MAX_SERIAL_PORTS);
+ }
+ if (serial_hds[index] != NULL) {
+ PANIC("qemu: invalid serial index for %s (%d: already taken!)",
+ devname, index);
+ }
+ snprintf(label, sizeof(label), "serial%d", index);
+ serial_hds[index] = qemu_chr_open(label, devname, NULL);
+ if (!serial_hds[index]) {
+ PANIC("qemu: could not open serial device '%s'", devname);
+ }
+}
+
+
+/* Find a free slot in the emulated serial device table, and register
+ * it. Return the allocated table index.
+ */
+static int
+serial_hds_add(const char* devname)
+{
+ int index;
+
+ /* Find first free slot */
+ for (index = 0; index < MAX_SERIAL_PORTS; index++) {
+ if (serial_hds[index] == NULL) {
+ serial_hds_add_at(index, devname);
+ return index;
+ }
+ }
+
+ PANIC("qemu: too many serial devices registered (%d)", index);
+ return -1; /* shouldn't happen */
+}
+
int main(int argc, char **argv, char **envp)
{
const char *gdbstub_dev = NULL;
@@ -5093,6 +5142,19 @@ int main(int argc, char **argv, char **envp)
nand_add_dev(tmp);
}
+ /* We always force qemu=1 when running inside QEMU */
+ stralloc_add_str(kernel_params, " qemu=1");
+
+ /* We always initialize the first serial port for the android-kmsg
+ * character device (used to send kernel messages) */
+ serial_hds_add_at(0, "android-kmsg");
+ stralloc_add_str(kernel_params, " console=ttyS0");
+
+ /* We always initialize the second serial port for the android-qemud
+ * character device as well */
+ serial_hds_add_at(1, "android-qemud");
+ stralloc_add_str(kernel_params, " android.qemud=ttyS1");
+
#if defined(CONFIG_KVM) && defined(CONFIG_KQEMU)
if (kvm_allowed && kqemu_allowed) {
PANIC(
@@ -5399,16 +5461,7 @@ int main(int argc, char **argv, char **envp)
}
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
- const char *devname = serial_devices[i];
- if (devname && strcmp(devname, "none")) {
- char label[32];
- snprintf(label, sizeof(label), "serial%d", i);
- serial_hds[i] = qemu_chr_open(label, devname, NULL);
- if (!serial_hds[i]) {
- PANIC("qemu: could not open serial device '%s'",
- devname);
- }
- }
+ serial_hds_add(serial_devices[i]);
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
@@ -5477,6 +5530,9 @@ int main(int argc, char **argv, char **envp)
stralloc_add_str(kernel_params, kernel_cmdline);
}
+ /* Remove any leading/trailing spaces */
+ stralloc_strip(kernel_params);
+
kernel_parameters = stralloc_cstr(kernel_params);
VERBOSE_PRINT(init, "Kernel parameters: %s", kernel_parameters);