Mail Archives: djgpp/1994/08/03/06:21:08
Please help me !!
Situation:
I used DJGPP 1.11.maint5
I intercept the timer interrupt and set my new timer handler
Problem:
I wanna call the old timer interrupt handler
in my new timer handler
But i don't know how to do this,
because of the difference of selector
between the old timer interrupt handler and my new handler
I can't use _go32_dpmi_chain_protected_mode_interrupt_vector()
because i wanna explicitly call the old timer handler
when some condition is satisfied.
I used _go32_dpmi_simulate_fcall_iret()
but after my new handler was called successfully a few times
and then the violation of segmentation has occured.
Sample Program:
--------------cut here--------------------------------------------------
#include <stdio.h>
#include <pc.h>
#include <dos.h>
#include <sys/types.h>
#include <dpmi.h>
volatile int new_tc;
_go32_dpmi_seginfo old_handler, new_handler,rm_old;
_go32_dpmi_registers rm_regs;
union REGS r;
void tic_handler()
{
new_tc ++;
_go32_dpmi_simulate_fcall_iret(&rm_regs);
}
int main()
{
int old_tc = 0, iter=0;
printf("grabbing timer interrupt\n");
_go32_dpmi_get_protected_mode_interrupt_vector(8, &old_handler);
_go32_dpmi_get_protected_mode_interrupt_vector(8, &rm_old);
rm_regs.x.cs=rm_old.rm_segment;
rm_regs.x.ip=rm_old.rm_offset;
new_handler.pm_offset = (int)tic_handler;
new_handler.pm_selector = _go32_my_cs();
_go32_dpmi_set_protected_mode_interrupt_vector(8,&new_handler);
printf("Trapping timer tics, press any key to stop\n");
while (!kbhit())
{
if (old_tc != new_tc)
{
printf("iter = %d, tics = %d\n", iter, new_tc);
old_tc = new_tc;
}
iter++;
}
getkey();
printf("releasing timer interrupt\n");
_go32_dpmi_set_protected_mode_interrupt_vector(8, &old_handler);
return 0;
}
- Raw text -