From: "Peter Remmers" Newsgroups: comp.os.msdos.djgpp Subject: Re: strange interrupt chaining problem with keyboard interrupt Date: Sat, 7 Oct 2000 00:07:23 +0200 Organization: T-Online Lines: 120 Message-ID: <8rliej$ecd$14$1@news.t-online.com> References: <8rhi12$4up$10$1 AT news DOT t-online DOT com> <9003-Thu05Oct2000231854+0300-eliz AT is DOT elta DOT co DOT il> <8rj5td$l0o$14$1 AT news DOT t-online DOT com> <7458-Fri06Oct2000114142+0300-eliz AT is DOT elta DOT co DOT il> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.t-online.com 970870035 14 14733 320094726121-0001 001006 22:07:15 X-Complaints-To: abuse AT t-online DOT de X-Sender: 320094726121-0001 AT t-dialin DOT net X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Eli Zaretskii" schrieb... > It stikes me that you should have posted the full code of your program > to begin with. That would have saved lots of bandwidth waste, to say > nothing of the factors I would have to consider as possibly relevant. > It would also allow those who want, to try the program on their > machines; who knows, perhaps this is something specific to your system > setup? Okay here we go, at the end of this posting is a minimal source code which should reproduce the problem, ready to be compiled. If anyone wants to test it, we can see if it's only on my machine or not. Note that it's C++ (but that doesn't matter, I tried it). > By modifying the source of the startup code (function > `__djgpp_exception_setup' in the file dpmiexcp.c from djlsr203.zip). I didn't go as far as changing DJGPP's source code (yet). But I read the sources of the keyboard handler and it has a testb $1, ___djgpp_hwint_flags /* Disable? */ jne Lkbd_chain So I tried and set the bit, but that didn't help either... > One issue that might be worth exploring is the registers used by your > handler. You don't save/restore any of them around the call to the > old ISR; however, the old ISR might destroy some of them while doing > its thing. I'd suggest to push all of the registers before the lcall, > then pop them after the old ISR returns, and see if that changes > anything. Isn't an interrupt handler supposed to save all registers? I mean, it "interrupt"s code which doesn't even know it gets interrupted, let alone has the chance to save all the registers for the ISR... As far as I can see from the sources, DJGPP's keyboard handler does proper saving and restoring of the registers. > If you can add this to the library code (see file gopint.c in > djlsr203.zip), I'm sure the patches will be gratefully accepted. Maybe I'll even do it :-) Peter --------snip------------ #include #include #include #include #include #include #include #include #include #include int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY; void textput(int x, int y, char *text, ...) { va_list args; char buf[80]; va_start(args, text); vsprintf(buf, text, args); va_end(args); char *p = buf; while (*p) _farpokew (_dos_ds, 0xB8000 + 160*y + 2*x++, 0x1700 | *p++); } _go32_dpmi_seginfo irq1; __dpmi_paddr oldirq1; int count = 0; void irq1handler() { // removing this textput doesn't help // (it uses the libc's vsprintf which might have been a problem?) textput(0,0, " %d ", ++count); asm volatile ("pushf"); asm volatile ("lcall *_oldirq1"); } int main() { // this should make DJGPP's keyboard interrupt handler // chain to the next ISR without doing anything itself. // but it doesn't help // __djgpp_hwint_flags |= 1; __dpmi_get_protected_mode_interrupt_vector(0x09, &oldirq1); irq1.pm_offset = (int)irq1handler; _go32_dpmi_allocate_iret_wrapper(&irq1); _go32_dpmi_set_protected_mode_interrupt_vector(0x09, &irq1); setmode (0, O_BINARY); int k = 0; while ((k&0xFF) != 27) { k = bioskey(0x10); printf("%04x '%c'\n", k, k&0xFF); } setmode (0, O_TEXT); __dpmi_set_protected_mode_interrupt_vector(0x09, &oldirq1); _go32_dpmi_free_iret_wrapper(&irq1); return 0; }