* [Qemu-devel] Some patches for QEMU
@ 2006-12-30 10:24 Volker Ruppert
2006-12-30 18:35 ` malc
0 siblings, 1 reply; 2+ messages in thread
From: Volker Ruppert @ 2006-12-30 10:24 UTC (permalink / raw)
To: Qemu Devel
[-- Attachment #1: Type: text/plain, Size: 804 bytes --]
Hi all,
I have created a set of patches for QEMU. Here is the list of changes:
* updated block driver for Bochs 2.3 "growing" images. The change was
necessary to fix the alignment of 64-bit values on different platforms (e.g.
it wasn't possible to share images between Windows and Linux).
* fixed comment in the floppy emulation code. The Bochs BIOS format function
and the Linux fdformat utility are expecting DMA operations here.
* fixed hard disk translation hint when an image formatted with translation
active is detected.
* standard and Cirrus VGA: implemented vertical retrace timing instead of just
toggling the register bits.
* implemented refresh clock toggle every 15 usec (used by INT 15h, AH=86h).
Please let me know when you need test cases for the changes.
--
Thanks
Volker
[-- Attachment #2: patch.qemu-block-bochs --]
[-- Type: text/x-diff, Size: 2737 bytes --]
diff -urNX /home/volker/exclude-qemu /home/volker/qemu/block-bochs.c ./block-bochs.c
--- /home/volker/qemu/block-bochs.c 2006-08-01 19:04:41.000000000 +0200
+++ ./block-bochs.c 2006-12-30 09:58:56.908199376 +0100
@@ -28,7 +28,8 @@
/**************************************************************/
#define HEADER_MAGIC "Bochs Virtual HD Image"
-#define HEADER_VERSION 0x00010000
+#define HEADER_VERSION 0x00020000
+#define HEADER_V1 0x00010000
#define HEADER_SIZE 512
#define REDOLOG_TYPE "Redolog"
@@ -37,7 +38,7 @@
// not allocated: 0xffffffff
// always little-endian
-struct bochs_header {
+struct bochs_header_v1 {
char magic[32]; // "Bochs Virtual HD Image"
char type[16]; // "Redolog"
char subtype[16]; // "Undoable" / "Volatile" / "Growing"
@@ -56,6 +57,27 @@
} extra;
};
+// always little-endian
+struct bochs_header {
+ char magic[32]; // "Bochs Virtual HD Image"
+ char type[16]; // "Redolog"
+ char subtype[16]; // "Undoable" / "Volatile" / "Growing"
+ uint32_t version;
+ uint32_t header; // size of header
+
+ union {
+ struct {
+ uint32_t catalog; // num of entries
+ uint32_t bitmap; // bitmap size
+ uint32_t extent; // extent size
+ uint32_t reserved; // for ???
+ uint64_t disk; // disk size
+ char padding[HEADER_SIZE - 64 - 8 - 24];
+ } redolog;
+ char padding[HEADER_SIZE - 64 - 8];
+ } extra;
+};
+
typedef struct BDRVBochsState {
int fd;
@@ -79,7 +101,8 @@
if (!strcmp(bochs->magic, HEADER_MAGIC) &&
!strcmp(bochs->type, REDOLOG_TYPE) &&
!strcmp(bochs->subtype, GROWING_TYPE) &&
- (le32_to_cpu(bochs->version) == HEADER_VERSION))
+ ((le32_to_cpu(bochs->version) == HEADER_VERSION) ||
+ (le32_to_cpu(bochs->version) == HEADER_V1)))
return 100;
return 0;
@@ -90,6 +113,7 @@
BDRVBochsState *s = bs->opaque;
int fd, i;
struct bochs_header bochs;
+ struct bochs_header_v1 header_v1;
fd = open(filename, O_RDWR | O_BINARY);
if (fd < 0) {
@@ -109,11 +133,17 @@
if (strcmp(bochs.magic, HEADER_MAGIC) ||
strcmp(bochs.type, REDOLOG_TYPE) ||
strcmp(bochs.subtype, GROWING_TYPE) ||
- (le32_to_cpu(bochs.version) != HEADER_VERSION)) {
+ ((le32_to_cpu(bochs.version) != HEADER_VERSION) &&
+ (le32_to_cpu(bochs.version) != HEADER_V1))) {
goto fail;
}
- bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
+ if (le32_to_cpu(bochs.version) == HEADER_V1) {
+ memcpy(&header_v1, &bochs, sizeof(bochs));
+ bs->total_sectors = le64_to_cpu(header_v1.extra.redolog.disk) / 512;
+ } else {
+ bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
+ }
lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET);
[-- Attachment #3: patch.qemu-fdc-comment --]
[-- Type: text/x-diff, Size: 698 bytes --]
diff -urNX /home/volker/exclude-qemu /home/volker/qemu/hw/fdc.c ./hw/fdc.c
--- /home/volker/qemu/hw/fdc.c 2006-12-11 13:20:25.000000000 +0100
+++ ./hw/fdc.c 2006-12-30 10:48:07.831590832 +0100
@@ -1673,8 +1673,9 @@
#else
cur_drv->last_sect = fdctrl->fifo[3];
#endif
- /* Bochs BIOS is buggy and don't send format informations
- * for each sector. So, pretend all's done right now...
+ /* TODO: implement format using DMA expected by the Bochs BIOS
+ * and Linux fdformat (read 3 bytes per sector via DMA and fill
+ * the sector with the specified fill byte
*/
fdctrl->data_state &= ~FD_STATE_FORMAT;
fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00);
[-- Attachment #4: patch.qemu-hd-translation --]
[-- Type: text/x-diff, Size: 3153 bytes --]
diff -urNX /home/volker/exclude-qemu /home/volker/qemu/hw/ide.c ./hw/ide.c
--- /home/volker/qemu/hw/ide.c 2006-12-22 09:01:06.000000000 +0100
+++ ./hw/ide.c 2006-12-30 10:36:29.307782592 +0100
@@ -2069,7 +2069,7 @@
{
IDEState *s;
static int drive_serial = 1;
- int i, cylinders, heads, secs, translation;
+ int i, cylinders, heads, secs, translation, lba_detected = 0;
int64_t nb_sectors;
for(i = 0; i < 2; i++) {
@@ -2083,6 +2083,7 @@
s->nb_sectors = nb_sectors;
/* if a geometry hint is available, use it */
bdrv_get_geometry_hint(s->bs, &cylinders, &heads, &secs);
+ translation = bdrv_get_translation_hint(s->bs);
if (cylinders != 0) {
s->cylinders = cylinders;
s->heads = heads;
@@ -2093,6 +2094,7 @@
/* if heads > 16, it means that a BIOS LBA
translation was active, so the default
hardware geometry is OK */
+ lba_detected = 1;
goto default_geometry;
} else {
s->cylinders = cylinders;
@@ -2100,7 +2102,6 @@
s->sectors = secs;
/* disable any translation to be in sync with
the logical geometry */
- translation = bdrv_get_translation_hint(s->bs);
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_set_translation_hint(s->bs,
BIOS_ATA_TRANSLATION_NONE);
@@ -2117,6 +2118,15 @@
s->cylinders = cylinders;
s->heads = 16;
s->sectors = 63;
+ if ((lba_detected == 1) && (translation == BIOS_ATA_TRANSLATION_AUTO)) {
+ if ((s->cylinders * s->heads) <= 131072) {
+ bdrv_set_translation_hint(s->bs,
+ BIOS_ATA_TRANSLATION_LARGE);
+ } else {
+ bdrv_set_translation_hint(s->bs,
+ BIOS_ATA_TRANSLATION_LBA);
+ }
+ }
}
bdrv_set_geometry_hint(s->bs, s->cylinders, s->heads, s->sectors);
}
diff -urNX /home/volker/exclude-qemu /home/volker/qemu/vl.h ./vl.h
--- /home/volker/qemu/vl.h 2006-12-25 09:12:41.000000000 +0100
+++ ./vl.h 2006-12-30 10:59:39.773399688 +0100
@@ -592,9 +592,11 @@
#define BDRV_TYPE_HD 0
#define BDRV_TYPE_CDROM 1
#define BDRV_TYPE_FLOPPY 2
-#define BIOS_ATA_TRANSLATION_AUTO 0
-#define BIOS_ATA_TRANSLATION_NONE 1
-#define BIOS_ATA_TRANSLATION_LBA 2
+#define BIOS_ATA_TRANSLATION_AUTO 0
+#define BIOS_ATA_TRANSLATION_NONE 1
+#define BIOS_ATA_TRANSLATION_LBA 2
+#define BIOS_ATA_TRANSLATION_LARGE 3
+#define BIOS_ATA_TRANSLATION_RECHS 4
void bdrv_set_geometry_hint(BlockDriverState *bs,
int cyls, int heads, int secs);
[-- Attachment #5: patch.qemu-timers --]
[-- Type: text/x-diff, Size: 2676 bytes --]
diff -urNX /home/volker/exclude-qemu /home/volker/qemu/hw/cirrus_vga.c ./hw/cirrus_vga.c
--- /home/volker/qemu/hw/cirrus_vga.c 2006-08-18 17:48:26.000000000 +0200
+++ ./hw/cirrus_vga.c 2006-10-01 19:18:43.721496136 +0200
@@ -2649,11 +2649,18 @@
break;
case 0x3ba:
case 0x3da:
- /* just toggle to fool polling */
- s->st01 ^= ST01_V_RETRACE | ST01_DISP_ENABLE;
- val = s->st01;
- s->ar_flip_flop = 0;
- break;
+ {
+ uint64_t usec;
+ usec = muldiv64(qemu_get_clock(vm_clock), 1000000, ticks_per_sec);
+ if ((usec % 13888) < 70) {
+ s->st01 |= ST01_V_RETRACE | ST01_DISP_ENABLE;
+ } else {
+ s->st01 = 0;
+ }
+ val = s->st01;
+ s->ar_flip_flop = 0;
+ }
+ break;
default:
val = 0x00;
break;
diff -urNX /home/volker/exclude-qemu /home/volker/qemu/hw/pcspk.c ./hw/pcspk.c
--- /home/volker/qemu/hw/pcspk.c 2006-07-05 01:20:54.000000000 +0200
+++ ./hw/pcspk.c 2006-10-01 19:28:43.952247192 +0200
@@ -38,7 +38,7 @@
unsigned int samples;
unsigned int play_pos;
int data_on;
- int dummy_refresh_clock;
+ int refresh_clock;
} PCSpkState;
static const char *s_spk = "pcspk";
@@ -117,10 +117,10 @@
PCSpkState *s = opaque;
int out;
- s->dummy_refresh_clock ^= (1 << 4);
+ s->refresh_clock = (((qemu_get_clock(vm_clock) / 15000) & 1) << 4);
out = pit_get_out(s->pit, 2, qemu_get_clock(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) | s->refresh_clock | out;
}
static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val)
diff -urNX /home/volker/exclude-qemu /home/volker/qemu/hw/vga.c ./hw/vga.c
--- /home/volker/qemu/hw/vga.c 2006-09-26 18:04:22.000000000 +0200
+++ ./hw/vga.c 2006-10-01 19:17:09.377838552 +0200
@@ -223,10 +223,17 @@
break;
case 0x3ba:
case 0x3da:
- /* just toggle to fool polling */
- s->st01 ^= ST01_V_RETRACE | ST01_DISP_ENABLE;
- val = s->st01;
- s->ar_flip_flop = 0;
+ {
+ uint64_t usec;
+ usec = muldiv64(qemu_get_clock(vm_clock), 1000000, ticks_per_sec);
+ if ((usec % 13888) < 70) {
+ s->st01 |= ST01_V_RETRACE | ST01_DISP_ENABLE;
+ } else {
+ s->st01 = 0;
+ }
+ val = s->st01;
+ s->ar_flip_flop = 0;
+ }
break;
default:
val = 0x00;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-12-30 18:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-30 10:24 [Qemu-devel] Some patches for QEMU Volker Ruppert
2006-12-30 18:35 ` malc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).