pkgsrc/emulators/qemu/patches/patch-ba
ryoon a9338ea4ce Update to 0.15.0
* Many bug fixes and improvements
* Add LatticeMico32 and unicore32 targets are added.
* And many changes. See http://wiki.qemu.org/ChangeLog/0.15

Tested on NetBSD/i386 current, NetBSD/i386 5.1, DragonFly/i386 2.10.1,
and Gentoo Linux/i386.
2011-08-22 12:00:34 +00:00

46 lines
1.4 KiB
Text

$NetBSD: patch-ba,v 1.5 2011/08/22 12:00:34 ryoon Exp $
--- hw/pcspk.c.orig 2011-08-08 18:28:42 +0000
+++ hw/pcspk.c
@@ -42,7 +42,6 @@ typedef struct {
unsigned int samples;
unsigned int play_pos;
int data_on;
- int dummy_refresh_clock;
} PCSpkState;
static const char *s_spk = "pcspk";
@@ -112,15 +111,31 @@ int pcspk_audio_init(qemu_irq *pic)
return 0;
}
+/*
+ * Emulate the speaker port's refresh clock bit. This is supposed
+ * to toggle between 0 and 1<<4 every 15 microseconds. XXX: We use
+ * gettimeofday() in the real machine instead of a monotonic clock
+ * in the virtual machine, and we are a bit sloppy about the 15
+ * microseconds. This should be good enough for crude loops that
+ * measure approximate delays by counting how often this line toggles.
+ */
+static uint32_t pcspk_dummy_refresh_clock(void)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ return ((tv.tv_sec ^ (tv.tv_usec / 15)) & 1) << 4;
+}
+
static uint32_t pcspk_ioport_read(void *opaque, uint32_t addr)
{
PCSpkState *s = opaque;
int out;
- s->dummy_refresh_clock ^= (1 << 4);
out = pit_get_out(s->pit, 2, qemu_get_clock_ns(vm_clock)) << 5;
- return pit_get_gate(s->pit, 2) | (s->data_on << 1) | s->dummy_refresh_clock | out;
+ return pit_get_gate(s->pit, 2) | (s->data_on << 1) |
+ pcspk_dummy_refresh_clock() | out;
}
static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val)