Commit f3dcfadac7ecb89a44c1c91d6dc1858ab517d102
1 parent
fcdc2129
Implement -clock selection, by Luca Tettamanti.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3129 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
72 additions
and
0 deletions
vl.c
@@ -835,6 +835,71 @@ static struct qemu_alarm_timer alarm_timers[] = { | @@ -835,6 +835,71 @@ static struct qemu_alarm_timer alarm_timers[] = { | ||
835 | {NULL, } | 835 | {NULL, } |
836 | }; | 836 | }; |
837 | 837 | ||
838 | +static void show_available_alarms() | ||
839 | +{ | ||
840 | + int i; | ||
841 | + | ||
842 | + printf("Available alarm timers, in order of precedence:\n"); | ||
843 | + for (i = 0; alarm_timers[i].name; i++) | ||
844 | + printf("%s\n", alarm_timers[i].name); | ||
845 | +} | ||
846 | + | ||
847 | +static void configure_alarms(char const *opt) | ||
848 | +{ | ||
849 | + int i; | ||
850 | + int cur = 0; | ||
851 | + int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1; | ||
852 | + char *arg; | ||
853 | + char *name; | ||
854 | + | ||
855 | + if (!strcmp(opt, "help")) { | ||
856 | + show_available_alarms(); | ||
857 | + exit(0); | ||
858 | + } | ||
859 | + | ||
860 | + arg = strdup(opt); | ||
861 | + | ||
862 | + /* Reorder the array */ | ||
863 | + name = strtok(arg, ","); | ||
864 | + while (name) { | ||
865 | + struct qemu_alarm_timer tmp; | ||
866 | + | ||
867 | + for (i = 0; i < count; i++) { | ||
868 | + if (!strcmp(alarm_timers[i].name, name)) | ||
869 | + break; | ||
870 | + } | ||
871 | + | ||
872 | + if (i == count) { | ||
873 | + fprintf(stderr, "Unknown clock %s\n", name); | ||
874 | + goto next; | ||
875 | + } | ||
876 | + | ||
877 | + if (i < cur) | ||
878 | + /* Ignore */ | ||
879 | + goto next; | ||
880 | + | ||
881 | + /* Swap */ | ||
882 | + tmp = alarm_timers[i]; | ||
883 | + alarm_timers[i] = alarm_timers[cur]; | ||
884 | + alarm_timers[cur] = tmp; | ||
885 | + | ||
886 | + cur++; | ||
887 | +next: | ||
888 | + name = strtok(NULL, ","); | ||
889 | + } | ||
890 | + | ||
891 | + free(arg); | ||
892 | + | ||
893 | + if (cur) { | ||
894 | + /* Disable remaining timers */ | ||
895 | + for (i = cur; i < count; i++) | ||
896 | + alarm_timers[i].name = NULL; | ||
897 | + } | ||
898 | + | ||
899 | + /* debug */ | ||
900 | + show_available_alarms(); | ||
901 | +} | ||
902 | + | ||
838 | QEMUClock *rt_clock; | 903 | QEMUClock *rt_clock; |
839 | QEMUClock *vm_clock; | 904 | QEMUClock *vm_clock; |
840 | 905 | ||
@@ -6846,6 +6911,8 @@ static void help(int exitcode) | @@ -6846,6 +6911,8 @@ static void help(int exitcode) | ||
6846 | #ifdef TARGET_SPARC | 6911 | #ifdef TARGET_SPARC |
6847 | "-prom-env variable=value set OpenBIOS nvram variables\n" | 6912 | "-prom-env variable=value set OpenBIOS nvram variables\n" |
6848 | #endif | 6913 | #endif |
6914 | + "-clock force the use of the given methods for timer alarm.\n" | ||
6915 | + " To see what timers are available use -clock help\n" | ||
6849 | "\n" | 6916 | "\n" |
6850 | "During emulation, the following keys are useful:\n" | 6917 | "During emulation, the following keys are useful:\n" |
6851 | "ctrl-alt-f toggle full screen\n" | 6918 | "ctrl-alt-f toggle full screen\n" |
@@ -6943,6 +7010,7 @@ enum { | @@ -6943,6 +7010,7 @@ enum { | ||
6943 | QEMU_OPTION_name, | 7010 | QEMU_OPTION_name, |
6944 | QEMU_OPTION_prom_env, | 7011 | QEMU_OPTION_prom_env, |
6945 | QEMU_OPTION_old_param, | 7012 | QEMU_OPTION_old_param, |
7013 | + QEMU_OPTION_clock, | ||
6946 | }; | 7014 | }; |
6947 | 7015 | ||
6948 | typedef struct QEMUOption { | 7016 | typedef struct QEMUOption { |
@@ -7047,6 +7115,7 @@ const QEMUOption qemu_options[] = { | @@ -7047,6 +7115,7 @@ const QEMUOption qemu_options[] = { | ||
7047 | #if defined(TARGET_ARM) | 7115 | #if defined(TARGET_ARM) |
7048 | { "old-param", 0, QEMU_OPTION_old_param }, | 7116 | { "old-param", 0, QEMU_OPTION_old_param }, |
7049 | #endif | 7117 | #endif |
7118 | + { "clock", HAS_ARG, QEMU_OPTION_clock }, | ||
7050 | { NULL }, | 7119 | { NULL }, |
7051 | }; | 7120 | }; |
7052 | 7121 | ||
@@ -7826,6 +7895,9 @@ int main(int argc, char **argv) | @@ -7826,6 +7895,9 @@ int main(int argc, char **argv) | ||
7826 | case QEMU_OPTION_old_param: | 7895 | case QEMU_OPTION_old_param: |
7827 | old_param = 1; | 7896 | old_param = 1; |
7828 | #endif | 7897 | #endif |
7898 | + case QEMU_OPTION_clock: | ||
7899 | + configure_alarms(optarg); | ||
7900 | + break; | ||
7829 | } | 7901 | } |
7830 | } | 7902 | } |
7831 | } | 7903 | } |