Mail Archives: djgpp/2000/10/06/18:57:04
"Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il> 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 <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <bios.h>
#include <stdarg.h>
#include <dpmi.h>
#include <go32.h>
#include <sys/farptr.h>
#include <sys/exceptn.h>
#include <crt0.h>
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;
}
- Raw text -