提交 f3dcfada 编写于 作者: T ths

Implement -clock selection, by Luca Tettamanti.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3129 c046a42c-6fe2-441c-8c8c-71466251a162
上级 fcdc2129
......@@ -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;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册