summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-08-24 01:26:02 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-08-24 01:26:02 +0000
commitf3dcfadac7ecb89a44c1c91d6dc1858ab517d102 (patch)
treeed33183f5a818428c3d22f408a0852c2ce931e10 /vl.c
parentfcdc2129931c3bf6fe36a7a4ed35cdffb894c9c5 (diff)
downloadqemu-f3dcfadac7ecb89a44c1c91d6dc1858ab517d102.tar.gz
Implement -clock selection, by Luca Tettamanti.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3129 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index bfdf5204ff..a5c1ce64eb 100644
--- a/vl.c
+++ b/vl.c
@@ -835,6 +835,71 @@ static struct qemu_alarm_timer alarm_timers[] = {
{NULL, }
};
+static void show_available_alarms()
+{
+ int i;
+
+ printf("Available alarm timers, in order of precedence:\n");
+ for (i = 0; alarm_timers[i].name; i++)
+ printf("%s\n", alarm_timers[i].name);
+}
+
+static void configure_alarms(char const *opt)
+{
+ int i;
+ int cur = 0;
+ int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;
+ char *arg;
+ char *name;
+
+ if (!strcmp(opt, "help")) {
+ show_available_alarms();
+ exit(0);
+ }
+
+ arg = strdup(opt);
+
+ /* Reorder the array */
+ name = strtok(arg, ",");
+ while (name) {
+ struct qemu_alarm_timer tmp;
+
+ for (i = 0; i < count; i++) {
+ if (!strcmp(alarm_timers[i].name, name))
+ break;
+ }
+
+ if (i == count) {
+ fprintf(stderr, "Unknown clock %s\n", name);
+ goto next;
+ }
+
+ if (i < cur)
+ /* Ignore */
+ goto next;
+
+ /* Swap */
+ tmp = alarm_timers[i];
+ alarm_timers[i] = alarm_timers[cur];
+ alarm_timers[cur] = tmp;
+
+ cur++;
+next:
+ name = strtok(NULL, ",");
+ }
+
+ free(arg);
+
+ if (cur) {
+ /* Disable remaining timers */
+ for (i = cur; i < count; i++)
+ alarm_timers[i].name = NULL;
+ }
+
+ /* debug */
+ show_available_alarms();
+}
+
QEMUClock *rt_clock;
QEMUClock *vm_clock;
@@ -6846,6 +6911,8 @@ static void help(int exitcode)
#ifdef TARGET_SPARC
"-prom-env variable=value set OpenBIOS nvram variables\n"
#endif
+ "-clock force the use of the given methods for timer alarm.\n"
+ " To see what timers are available use -clock help\n"
"\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n"
@@ -6943,6 +7010,7 @@ enum {
QEMU_OPTION_name,
QEMU_OPTION_prom_env,
QEMU_OPTION_old_param,
+ QEMU_OPTION_clock,
};
typedef struct QEMUOption {
@@ -7047,6 +7115,7 @@ const QEMUOption qemu_options[] = {
#if defined(TARGET_ARM)
{ "old-param", 0, QEMU_OPTION_old_param },
#endif
+ { "clock", HAS_ARG, QEMU_OPTION_clock },
{ NULL },
};
@@ -7826,6 +7895,9 @@ int main(int argc, char **argv)
case QEMU_OPTION_old_param:
old_param = 1;
#endif
+ case QEMU_OPTION_clock:
+ configure_alarms(optarg);
+ break;
}
}
}