X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Date: Wed, 15 Dec 2004 01:12:34 -0200 From: Jonatan Liljedahl To: djgpp AT delorie DOT com Subject: Problems with timer interrupt chaining and SmartDrv Message-Id: <20041215011234.44376f01.lijon@kymatica.com> Organization: Kymatica X-Mailer: Sylpheed version 0.9.10 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Hi! I'm having some problems with hardware interrupts and smartdrv in my compositional environment (see http://kymatica.com/kyce if you're interrested). Situation: I'm replacing the timer interrupt handler with my own protected mode handler. I'm also reprogramming the PIT chip to 600Hz frequency. I keep a counter so that I can call the original realmode handler at 18.2Hz interval. Now, everything works fine if I do NOT have smartdrv installed. But if smartdrv is installed, the computer hangs when smartdrv is writing from cache to disc. And, if I turn off write-cache (> smartdrv /X) then it works fine! If I DON'T chain to the original handler, then it works too (as the original handler, where smartdrv has it hook, never gets called - smartdrv never runs, and cache is only written when I put back the original handler again). Any help/thoughts about this would make me very happy! Am I doing something wrong? Is smartdrv a hopeless piece of bugs? If so, can I work around it somehow? I'd love to not have to write "You must disable smartdrv's write-cache or this program will hang your computer" in the manual! Here's the (simplified) code: #define TIMER_INTR 8 static _go32_dpmi_seginfo new_vector, old_vector, rm_old_vector; static _go32_dpmi_registers r; void clocktick(void) { disable(); /* ...do stuff... */ if(time_to_call_original_handler) { memset(&r,0,sizeof(r)); r.x.cs = rm_old_vector.rm_segment; r.x.ip = rm_old_vector.rm_offset; _go32_dpmi_simulate_fcall_iret(&r); } else { outportb(0x20,0x20); } enable(); } void install_handler(void) { disable() _go32_dpmi_get_protected_mode_interrupt_vector(TIMER_INTR, &old_vector); _go32_dpmi_get_real_mode_interrupt_vector (TIMER_INTR, &rm_old_vector); new_vector.pm_offset = (int) clocktick; new_vector.pm_selector = _go32_my_cs(); _go32_dpmi_allocate_iret_wrapper(&new_vector); _go32_dpmi_set_protected_mode_interrupt_vector(TIMER_INTR, &new_vector) outportb(0x43,0x34); outportb(0x40,PITFREQ&0xff); outportb(0x40,PITFREQ>>8); enable(); } /Jonatan -=( http://kymatica.com )=-