[Qemu-devel] Suggested stubs for coming a bit closer to functional native sparcv9 HOST support:
Hi, <> ## only a messy personal testing-snapshot FYI, with no compatibility or clarity in mind ## a gdiff -Nurb against 20060930's http://www.opensolaris.org/os/project/qemu/downloads/qemu-0.8.2-solaris.tar.gz Current Status: = This is still the very best I can get on an OpenSolaris sparc64 host when cd'ing to linux-test (from http://www.qemu.com/linux-test-0.5.1.tar.gz) and running # /tmp/Q_E_M_U/sparcv9_testing/qemu-0.8.2-solaris__v9_stubs/i386-softmmu/qemu -nographic -hda linux.img -kernel bzImage-2.4.21 -append "console=ttyS0 root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe" -d all : # uname -a SunOS mb1x-ws1 5.11 snv_41 sun4u sparc SUNW,Sun-Fire-280R # isainfo -k sparcv9 # ls -al /tmp/qemu.log -rw-r--r-- 1 root root2022 Oct 5 13:03 /tmp/qemu.log # cat /tmp/qemu.log EAX= EBX= ECX= EDX=0600 ESI= EDI= EBP= ESP= EIP=fff0 EFL=0002 [---] CPL=0 II=0 A20=1 HLT=0 ES = CS =f000 SS = DS = FS = GS = LDT= 8000 TR = 8000 GDT= IDT= CR0=6010 CR2= CR3= CR4= CCS= CCD= CCO=EFLAGS IN: 0xfff0: ljmp $0xf000,$0xe05b OP: 0x: movl_T0_im 0xf000 0x0001: movl_T1_imu 0xe05b 0x0002: movl_seg_T0_vm 0x4c 0x0003: movl_T0_T1 0x0004: jmp_T0 0x0005: movl_T0_0 0x0006: exit_tb 0x0007: end AFTER FLAGS OPT: 0x: movl_T0_im 0xf000 0x0001: movl_T1_imu 0xe05b 0x0002: movl_seg_T0_vm 0x4c 0x0003: movl_T0_T1 0x0004: jmp_T0 0x0005: movl_T0_0 0x0006: exit_tb 0x0007: end OUT: [size=124] 0x101242060: sethi %hi(0), %o5 0x101242064: or %o5, 1, %o5 ! 0x1 0x101242068: unknown 0x10124206c: sethi %hi(0x11f9400), %o4 0x101242070: add %o5, %o4, %o5 0x101242074: mov %o5, %o5 0x101242078: mov %o5, %g4 0x10124207c: sethi %hi(0), %o5 0x101242080: or %o5, 1, %o5 ! 0x1 0x101242084: unknown 0x101242088: sethi %hi(0x11f9400), %o4 0x10124208c: add %o5, %o4, %o5 0x101242090: or %o5, 0x5b, %o5 0x101242094: mov %o5, %g5 0x101242098: sethi %hi(0xfc00), %o5 0x10124209c: or %o5, 0x3ff, %o5 ! 0x 0x1012420a0: and %g4, %o5, %o3 0x1012420a4: sethi %hi(0), %o5 0x1012420a8: or %o5, 1, %o5 ! 0x1 0x1012420ac: unknown 0x1012420b0: sethi %hi(0x11f9400), %o4 0x1012420b4: add %o5, %o4, %o5 0x1012420b8: or %o5, 0x4c, %o5 0x1012420bc: add %g3, %o5, %o5 0x1012420c0: st %o3, [ %o5 ] 0x1012420c4: sll %o3, 4, %o3 0x1012420c8: st %o3, [ %o5 + 4 ] 0x1012420cc: mov %g5, %g4 0x1012420d0: st %g4, [ %g3 + 0x20 ] 0x1012420d4: clr %g4 0x1012420d8: jmp %i0 + 8 # file /tmp/Q_E_M_U/sparcv9_testing/qemu-0.8.2-solaris__v9_stubs/i386-softmmu/qemu i386-softmmu/qemu: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped # Summary = I know, being able to natively build for sparcv9 is not "required" by any means (because ultrasparc asm [i.e. ticks] _can_ already be used via sparcv8plus [which is basically 32bit with UltraSPARC extensions / no v8plus cpu ever existed], no sparc-X-sparc kqemu LKM driver exists as of now that would make building for sparcv9 a requirement, and of course can qemu be built now for v8plus, v8 or v7 [special thanks again to Juergen Keil and Johannes Schindelin] and then be run under a booted sparcv9 host kernel), but it would be interesting to see, how one would get it working / what is still missing. References: http://www.cs.utexas.edu/users/novak/sparcv9.pdf http://libvncserver.sourceforge.net/qemu/qemu-porting.html http://www.qemu.com/qemu-tech.html p.s. I finally return to the rather trivial task of bringing the promised SUNWqemu and CSWqemu packages out, plus a patch against http://www.qemu.com/qemu-0.8.2.tar.gz Globally switching to current CVS afterwards (already tested it on sparc32). I apologize for the delay. Regards, Maddin http://www.martux.org diff -Nurb ./qemu-0.8.2-solaris__20060930/Makefile ./qemu-0.8.2-solaris__v9_stubs/Makefile --- ./qemu-0.8.2-solaris__20060930/Makefile 2006-09-13 09:40:58.0 +0200 +++ ./qemu-0.8.2-solaris__v9_stubs/Makefile 2006-10-05 11:23:34.109516000 +0200 @@ -5,12 +5,12 @@ .PHONY: all clean distclean dvi info install install-doc tar tarbin \ speed test test2 html dvi info -CFLAGS+=-Wall -O2 -g -fno-strict-aliasing -I. +CFLAGS+=-Wall -O1 -g -fno-strict-aliasing -I. ifdef CONFIG_DARWIN CFLAGS+= -mdynamic-no-pic endif ifeq ($(ARCH),sparc) -CFLAGS+=-mcpu=ultrasparc +CFLAGS+=-mcpu=ultrasparc -O2 endif LDFLAGS+=-g LIBS= diff -Nurb ./qemu-0.8.2-solaris__20060930/Makefile.target ./qemu-0.8.2-solaris__v9_stubs/Makefile.target --- ./qemu-0.8.2-solaris__20060930/Makefile.target 2006-09-13 09:40:58.0
[Qemu-devel] Patch to see all tracks on CDROM
Hello, Here is a dirty patch to see all tracks of a CD-ROM as I need it. It basically reads TOC in the cdrom_read_toc function. The patch only works for Linux (but adding support for other OS should not be difficult) What would be needed is to have a BlockDriverState parameter for cdrom_read_toc in order to avoid exporting the list and searching for a CDROM inside it. Another nice thing would be to handle .toc/.bin but that would need adding a field somewhere to keep the .toc filename. BTW, why does -snapshot apply to cdrom ? Index: hw/cdrom.c === RCS file: /sources/qemu/qemu/hw/cdrom.c,v retrieving revision 1.1 diff -u -r1.1 cdrom.c --- hw/cdrom.c 25 May 2006 23:58:51 - 1.1 +++ hw/cdrom.c 5 Oct 2006 18:00:31 - @@ -26,6 +26,14 @@ here. */ #include +#include "block_int.h" + +#if defined(__linux__) +#include +#include +#endif + +extern BlockDriverState *bdrv_first; static void lba_to_msf(uint8_t *buf, int lba) { @@ -39,45 +47,125 @@ /* XXX: check this */ int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track) { -uint8_t *q; -int len; - -if (start_track > 1 && start_track != 0xaa) -return -1; -q = buf + 2; -*q++ = 1; /* first session */ -*q++ = 1; /* last session */ -if (start_track <= 1) { -*q++ = 0; /* reserved */ -*q++ = 0x14; /* ADR, control */ -*q++ = 1;/* track number */ -*q++ = 0; /* reserved */ -if (msf) { -*q++ = 0; /* reserved */ -lba_to_msf(q, 0); -q += 3; -} else { -/* sector 0 */ -cpu_to_be32wu((uint32_t *)q, 0); -q += 4; -} + uint8_t *q; + int len; + int i; + char * filename = NULL; + + /* Find the device filename */ + BlockDriverState *bs; + + for (bs = bdrv_first; bs != NULL; bs = bs->next) { +if(bs->type == BDRV_TYPE_CDROM) { + /* Looks like -snapshot also applies to CD */ + if(bs->backing_file) { + filename = bs->backing_file; + } else { + filename = bs->filename; + } } -/* lead out track */ -*q++ = 0; /* reserved */ -*q++ = 0x16; /* ADR, control */ -*q++ = 0xaa; /* track number */ -*q++ = 0; /* reserved */ + } + + int fd = 0; +#if defined(__linux__) + fd = open(filename, O_RDONLY); + if(fd<0) { +return -1; + } +#endif + + struct cdrom_tochdr tochdr; +#if defined(__linux__) + if (ioctl(fd, CDROMREADTOCHDR, &tochdr)) { +/* If we have a file and not a real CD-ROM, revert to old behaviour */ +/*FIXME We should rather check bs->drv */ +close(fd); +fd = 0; +#else + { +#endif +tochdr.cdth_trk0 = 1; +tochdr.cdth_trk1 = 1; + + } + + if ((start_track > tochdr.cdth_trk1) && (start_track != 0xaa)) { +if (fd) + close(fd); +return -1; + } + + if (start_track < tochdr.cdth_trk0) +start_track = tochdr.cdth_trk0; + + q = buf + 2; + *q++ = tochdr.cdth_trk0; /* first session */ + *q++ = tochdr.cdth_trk1; /* last session */ + + for (i = start_track; i <= tochdr.cdth_trk1; i++) { +struct cdrom_tocentry tocentry; + +#if defined(__linux__) +tocentry.cdte_format = (msf) ? CDROM_MSF : CDROM_LBA; +tocentry.cdte_track = i; +if (fd) { + if (ioctl(fd, CDROMREADTOCENTRY, &tocentry)) { + perror("cdrom: read_toc: READTOCENTRY lead-out failed"); + close(fd); + return -1; + } +} else { +#else +{ +#endif + tocentry.cdte_adr = 0; + tocentry.cdte_ctrl = 0x14; + if (msf) { + tocentry.cdte_addr.msf.minute = 0; + tocentry.cdte_addr.msf.second = 2; + tocentry.cdte_addr.msf.frame = 0; + } else { + tocentry.cdte_addr.lba = 0; + } +} + +*q++ = 0; // Reserved +*q++ = (tocentry.cdte_adr << 4) | tocentry.cdte_ctrl ; // ADR, control +*q++ = i; // Track number +*q++ = 0; // Reserved + +// Start address if (msf) { -*q++ = 0; /* reserved */ -lba_to_msf(q, nb_sectors); -q += 3; + *q++ = 0; // reserved + *q++ = tocentry.cdte_addr.msf.minute; + *q++ = tocentry.cdte_addr.msf.second; + *q++ = tocentry.cdte_addr.msf.frame; } else { -cpu_to_be32wu((uint32_t *)q, nb_sectors); -q += 4; + *q++ = (((unsigned)tocentry.cdte_addr.lba) >> 24) & 0xff; + *q++ = (((unsigned)tocentry.cdte_addr.lba) >> 16) & 0xff; + *q++ = (((unsigned)tocentry.cdte_addr.lba) >> 8) & 0xff; + *q++ = (((unsigned)tocentry.cdte_addr.lba) >> 0) & 0xff; } -len = q - buf; -cpu_to_be16wu((uint16_t *)buf, len - 2); -return len; + } + + /* lead out track */ + *q++ = 0; /* reserved */ + *q++ = 0x16; /* ADR, control */ + *q++ = 0xaa; /* track number */ + *q++ = 0; /* reserved */ + if (msf) { +*q++ = 0; /* reserved */ +lba_to_msf(q, nb_sectors); +q += 3; + } else { +cpu_to_be32wu((uint32_t *)q, nb_sectors); +q += 4; + } + len = q - buf; + cpu_to_be16wu((uint