From mboxrd@z Thu Jan 1 00:00:00 1970 From: x.zupftom@web.de Subject: Re: freezes when not emulating CPU (was: MIDI input patch) Date: Wed, 09 Sep 2009 21:17:07 +0200 Message-ID: <809264611@web.de> Mime-Version: 1.0 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Sender: linux-msdos-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="iso-8859-1" To: linux-msdos@vger.kernel.org Hi all, Stas Sergeev has once more offered his help offlist, and he's again don= e a great job. It turned out that my problems were FPU related. Stas = worked out the patch below to fix them. The patch has been tested with= out problems in every day use on two machines so far, on a Pentium III = ThinkPad and in a virtual Linux box in VMware on a Mac. And here is the patch. I hope it's good for application to the trunk. Index: src/include/memory.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/include/memory.h (revision 1905) +++ src/include/memory.h (working copy) @@ -118,6 +118,10 @@ #define INT70_OFF 0x63f0 #define INT70_ADD ((INT70_SEG << 4) + INT70_OFF) =20 +#define INT75_SEG ROMBIOSSEG +#define INT75_OFF 0x7f00 +#define INT75_ADD ((INT75_SEG << 4) + INT75_OFF) + #define INT1E_SEG ROMBIOSSEG #define INT1E_OFF 0x6fc7 #define INT41_SEG ROMBIOSSEG Index: src/base/bios/setup.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/base/bios/setup.c (revision 1905) +++ src/base/bios/setup.c (working copy) @@ -127,16 +127,13 @@ SETIVEC(0x1e, INT1E_SEG, INT1E_OFF); SETIVEC(0x41, INT41_SEG, INT41_OFF); SETIVEC(0x46, INT46_SEG, INT46_OFF); - - /* This is an int e7 used for FCB opens */ - SETIVEC(0xe7, INTE7_SEG, INTE7_OFF); - /* End of int 0xe7 for FCB opens */ - + SETIVEC(0x75, INT75_SEG, INT75_OFF); #ifdef IPX /* IPX. Dummy but should not crash */ if (config.ipxsup) SETIVEC(0x7a, BIOSSEG, INT_OFF(0x7a)); #endif + SETIVEC(0xe7, INTE7_SEG, INTE7_OFF); =20 /* Install new handler for video-interrupt into bios_f000_int10ptr, * for video initialization at f800:4200 Index: src/base/bios/bios.S =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/base/bios/bios.S (revision 1905) +++ src/base/bios/bios.S (working copy) @@ -947,7 +947,18 @@ iret /* return to interrupted code */ .globl CISH(INT08_dummy_end) CISH(INT08_dummy_end): - =20 + +/* ----------------------------------------------------------------- *= / =20 + .org ((INT75_SEG-BIOSSEG) << 4)+INT75_OFF +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= Addr =3D F800:7F00 (FFF00) */ + xorb %al, %al + outb %al, $0xf0 + movb $0x20, %al + outb %al, $0xa0 + outb %al, $0x20 + int $2 /* bochs does this */ + iret + /* COMPAS FFEF3 vector table for INT08-INT1F */ /* COMPAS FFF23 vector table for INT70-INT77 */ /* COMPAS FFF33-FFF53 reserved */ Index: src/base/dev/sb16/dspio.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/base/dev/sb16/dspio.c (revision 1905) +++ src/base/dev/sb16/dspio.c (working copy) @@ -288,7 +288,6 @@ { int dma_cnt, fifo_cnt; unsigned long long time_dst; - double period; Bit16u buf; =20 dma_cnt =3D fifo_cnt =3D 0; @@ -298,7 +297,6 @@ state->dma.stereo =3D sb_dma_samp_stereo(); state->dma.rate =3D sb_get_dma_sampling_rate(); } - period =3D pcm_samp_period(state->dma.rate, state->dma.stereo + 1)= ; =20 while (state->output_running && (state->output_time_cur <=3D time_= dst || fifo_cnt % (state->dma.stereo + 1))) { @@ -321,7 +319,8 @@ samp_signed), state->dma_strm); } - state->output_time_cur +=3D period; + state->output_time_cur +=3D pcm_samp_period(state->dma.rate, + state->dma.stereo + 1); fifo_cnt++; } else { if (!sb_dma_active()) { @@ -359,7 +358,8 @@ dspio_run_dma(&state->dma); dma_cnt++; } - state->input_time_cur +=3D period; + state->input_time_cur +=3D pcm_samp_period(state->dma.rate, + state->dma.stereo + 1); fifo_cnt++; } =20 @@ -368,9 +368,9 @@ dspio_fill_output(state); =20 if (fifo_cnt || dma_cnt) - S_printf("SB: Processed %i FIFO, %i DMA, or=3D%i dr=3D%i time=3D%lli = period=3D%f\n", + S_printf("SB: Processed %i FIFO, %i DMA, or=3D%i dr=3D%i time=3D%lli\= n", fifo_cnt, dma_cnt, state->output_running, state->dma.running, - time_dst, period); + time_dst); } =20 static void dspio_process_midi(void) Index: src/arch/linux/async/sigsegv.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/arch/linux/async/sigsegv.c (revision 1905) +++ src/arch/linux/async/sigsegv.c (working copy) @@ -110,6 +110,7 @@ return 0; =20 case 0x10: /* coprocessor error */ + print_exception_info(scp); pic_request(PIC_IRQ13); /* this is the 386 way of signalling this *= / return 0; =20 @@ -252,7 +253,7 @@ =20 int retcode; if (_trapno =3D=3D 0x10) { - g_printf("coprocessor exception, calling IRQ13\n"); + print_exception_info(scp); pic_request(PIC_IRQ13); dpmi_return(scp); return -1; Index: src/emu-i386/cpu.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/emu-i386/cpu.c (revision 1905) +++ src/emu-i386/cpu.c (working copy) @@ -235,6 +235,56 @@ REG(eflags) =3D 0; } =20 +#if 0 +static void fpu_init(void) +{ +#ifdef __x86_64__ + vm86_fpu_state.cwd =3D 0x037F; + vm86_fpu_state.swd =3D 0; + vm86_fpu_state.ftw =3D 0xFFFF; // bochs +#else + vm86_fpu_state.cw =3D 0x40; + vm86_fpu_state.sw =3D 0; + vm86_fpu_state.tag =3D 0xFFFF; // bochs +#endif +} +#endif + +static void fpu_reset(void) +{ +#ifdef __x86_64__ + vm86_fpu_state.cwd =3D 0x0040; + vm86_fpu_state.swd =3D 0; + vm86_fpu_state.ftw =3D 0x5555; //bochs +#else + vm86_fpu_state.cw =3D 0x40; + vm86_fpu_state.sw =3D 0; + vm86_fpu_state.tag =3D 0x5555; // bochs +#endif +} + +static Bit8u fpu_io_read(ioport_t port) +{ + return 0xff; +} + +static void fpu_io_write(ioport_t port, Bit8u val) +{ + switch (port) { + case 0xf0: + /* not sure about this */ +#ifdef __x86_64__ + vm86_fpu_state.swd &=3D ~0x8000; +#else + vm86_fpu_state.sw &=3D ~0x8000; +#endif + break; + case 0xf1: + fpu_reset(); + break; + } +} + /*=20 * DANG_BEGIN_FUNCTION cpu_setup * @@ -247,11 +297,25 @@ */ void cpu_setup(void) { + emu_iodev_t io_dev; + io_dev.read_portb =3D fpu_io_read; + io_dev.write_portb =3D fpu_io_write; + io_dev.read_portw =3D NULL; + io_dev.write_portw =3D NULL; + io_dev.read_portd =3D NULL; + io_dev.write_portd =3D NULL; + io_dev.irq =3D PIC_IRQ13; + io_dev.fd =3D -1; + io_dev.start_addr =3D 0xf0; + io_dev.end_addr =3D 0xff; + io_dev.handler_name =3D "Math Coprocessor"; + port_register_handler(io_dev, 0); + int_vector_setup(); =20 cpu_reset(); - savefpstate(vm86_fpu_state); + fpu_reset(); =20 #ifdef X86_EMULATOR if (config.cpuemu) { ______________________________________________________ GRATIS f=FCr alle WEB.DE-Nutzer: Die maxdome Movie-FLAT! Jetzt freischalten unter http://movieflat.web.de -- To unsubscribe from this list: send the line "unsubscribe linux-msdos" = in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html