Commit 02ba45c5362011ce323c69f04b49fe61663a68e3
1 parent
107db443
use RT signal for /dev/rtc - restore stdin flags (Bob Barry) - cpu save fix (Johannes Schindelin)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@970 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
38 additions
and
3 deletions
vl.c
| ... | ... | @@ -787,6 +787,35 @@ void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg, |
| 787 | 787 | static void host_alarm_handler(int host_signum) |
| 788 | 788 | #endif |
| 789 | 789 | { |
| 790 | +#if 0 | |
| 791 | +#define DISP_FREQ 1000 | |
| 792 | + { | |
| 793 | + static int64_t delta_min = INT64_MAX; | |
| 794 | + static int64_t delta_max, delta_cum, last_clock, delta, ti; | |
| 795 | + static int count; | |
| 796 | + ti = qemu_get_clock(vm_clock); | |
| 797 | + if (last_clock != 0) { | |
| 798 | + delta = ti - last_clock; | |
| 799 | + if (delta < delta_min) | |
| 800 | + delta_min = delta; | |
| 801 | + if (delta > delta_max) | |
| 802 | + delta_max = delta; | |
| 803 | + delta_cum += delta; | |
| 804 | + if (++count == DISP_FREQ) { | |
| 805 | + printf("timer: min=%lld us max=%lld us avg=%lld us avg_freq=%0.3f Hz\n", | |
| 806 | + muldiv64(delta_min, 1000000, ticks_per_sec), | |
| 807 | + muldiv64(delta_max, 1000000, ticks_per_sec), | |
| 808 | + muldiv64(delta_cum, 1000000 / DISP_FREQ, ticks_per_sec), | |
| 809 | + (double)ticks_per_sec / ((double)delta_cum / DISP_FREQ)); | |
| 810 | + count = 0; | |
| 811 | + delta_min = INT64_MAX; | |
| 812 | + delta_max = 0; | |
| 813 | + delta_cum = 0; | |
| 814 | + } | |
| 815 | + } | |
| 816 | + last_clock = ti; | |
| 817 | + } | |
| 818 | +#endif | |
| 790 | 819 | if (qemu_timer_expired(active_timers[QEMU_TIMER_VIRTUAL], |
| 791 | 820 | qemu_get_clock(vm_clock)) || |
| 792 | 821 | qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME], |
| ... | ... | @@ -892,7 +921,8 @@ static void init_timers(void) |
| 892 | 921 | setitimer(ITIMER_REAL, &itv, NULL); |
| 893 | 922 | |
| 894 | 923 | /* use the RTC */ |
| 895 | - sigaction(SIGIO, &act, NULL); | |
| 924 | + sigaction(SIGRTMIN, &act, NULL); | |
| 925 | + fcntl(rtc_fd, F_SETSIG, SIGRTMIN); | |
| 896 | 926 | fcntl(rtc_fd, F_SETFL, O_ASYNC); |
| 897 | 927 | fcntl(rtc_fd, F_SETOWN, getpid()); |
| 898 | 928 | } else { |
| ... | ... | @@ -1184,10 +1214,12 @@ static void term_init(void) |
| 1184 | 1214 | |
| 1185 | 1215 | /* init terminal so that we can grab keys */ |
| 1186 | 1216 | static struct termios oldtty; |
| 1217 | +static int old_fd0_flags; | |
| 1187 | 1218 | |
| 1188 | 1219 | static void term_exit(void) |
| 1189 | 1220 | { |
| 1190 | 1221 | tcsetattr (0, TCSANOW, &oldtty); |
| 1222 | + fcntl(0, F_SETFL, old_fd0_flags); | |
| 1191 | 1223 | } |
| 1192 | 1224 | |
| 1193 | 1225 | static void term_init(void) |
| ... | ... | @@ -1196,6 +1228,7 @@ static void term_init(void) |
| 1196 | 1228 | |
| 1197 | 1229 | tcgetattr (0, &tty); |
| 1198 | 1230 | oldtty = tty; |
| 1231 | + old_fd0_flags = fcntl(0, F_GETFL); | |
| 1199 | 1232 | |
| 1200 | 1233 | tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP |
| 1201 | 1234 | |INLCR|IGNCR|ICRNL|IXON); |
| ... | ... | @@ -1570,6 +1603,7 @@ int qemu_loadvm(const char *filename) |
| 1570 | 1603 | |
| 1571 | 1604 | static void cpu_put_seg(QEMUFile *f, SegmentCache *dt) |
| 1572 | 1605 | { |
| 1606 | + qemu_put_be32(f, dt->selector); | |
| 1573 | 1607 | qemu_put_be32(f, (uint32_t)dt->base); |
| 1574 | 1608 | qemu_put_be32(f, dt->limit); |
| 1575 | 1609 | qemu_put_be32(f, dt->flags); |
| ... | ... | @@ -1577,6 +1611,7 @@ static void cpu_put_seg(QEMUFile *f, SegmentCache *dt) |
| 1577 | 1611 | |
| 1578 | 1612 | static void cpu_get_seg(QEMUFile *f, SegmentCache *dt) |
| 1579 | 1613 | { |
| 1614 | + dt->selector = qemu_get_be32(f); | |
| 1580 | 1615 | dt->base = (uint8_t *)qemu_get_be32(f); |
| 1581 | 1616 | dt->limit = qemu_get_be32(f); |
| 1582 | 1617 | dt->flags = qemu_get_be32(f); |
| ... | ... | @@ -1650,7 +1685,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) |
| 1650 | 1685 | uint32_t hflags; |
| 1651 | 1686 | uint16_t fpus, fpuc, fptag; |
| 1652 | 1687 | |
| 1653 | - if (version_id != 1) | |
| 1688 | + if (version_id != 2) | |
| 1654 | 1689 | return -EINVAL; |
| 1655 | 1690 | for(i = 0; i < 8; i++) |
| 1656 | 1691 | qemu_get_be32s(f, &env->regs[i]); |
| ... | ... | @@ -2683,7 +2718,7 @@ int main(int argc, char **argv) |
| 2683 | 2718 | cpu_single_env = env; |
| 2684 | 2719 | |
| 2685 | 2720 | register_savevm("timer", 0, 1, timer_save, timer_load, env); |
| 2686 | - register_savevm("cpu", 0, 1, cpu_save, cpu_load, env); | |
| 2721 | + register_savevm("cpu", 0, 2, cpu_save, cpu_load, env); | |
| 2687 | 2722 | register_savevm("ram", 0, 1, ram_save, ram_load, NULL); |
| 2688 | 2723 | qemu_register_reset(main_cpu_reset, global_env); |
| 2689 | 2724 | ... | ... |